lkml.org 
[lkml]   [2007]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] fix sys_mknodat breakage from r/o bind mounts
On Wed, Sep 26, 2007 at 12:58:47AM +0200, Miklos Szeredi wrote:
> if (!S_ISREG(mode) && !S_ISCHR(mode) && !S_ISBLK(mode) &&
> - !S_ISFIFO(mode) && !S_ISSOCK(mode) && mode != 0) {
> + !S_ISFIFO(mode) && !S_ISSOCK(mode) && (mode & S_IFMT) != 0) {

FYI this whole section might be cleaner as


static int may_mknod(mode_t mode)
{
switch (mode & S_IFMT) {
case S_IFREG:
case S_IFCHR:
case S_IFBLK:
case S_IFFIFO:
case S_IFSOCK:
case 0: /* zero mode translates to S_IFREG *
return 0;
case S_IFDIR:
return -EPERM;
default:
return -EINVAL;
}
}

and then in sys_mknodat just a

error = may_mknod(mode);
if (error)
goto out_dput;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-09-26 17:07    [W:0.095 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site