lkml.org 
[lkml]   [2008]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [patch 11/14] vfs: move executable checking into ->permission()
From
Date
On Wed, 2008-05-21 at 19:15 +0200, Miklos Szeredi wrote:

> +/**
> + * exec_permission - check for general execute permission on file
> + * @inode: inode to check access rights for
> + * @mask: right to check for
> + *
> + * Exec permission on a regular file is denied if none of the execute
> + * bits are set.
> + *
> + * This needs to be called by filesystems which define a
> + * ->permission() method, and don't call generic_permission().
> + */
> +int exec_permission(struct inode *inode, int mask)
> +{
> + if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode) &&
> + !(inode->i_mode & S_IXUGO))
> + return -EACCES;
> +
> + return 0;
> +}

Hmm... What if !(mask & MAY_EXEC)? AFAICS, the above will return 0.
A better approach would be to use something like

if (!(mask & MAY_EXEC))
return -EACCES;
if (S_ISREG(inode->i_mode) && !(inode->i_mode & S_IXUGO))
return -EACCES;
return 0;





\
 
 \ /
  Last update: 2008-05-21 20:19    [W:0.161 / U:9.824 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site