public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: haveblue@us.ibm.com, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] fix sys_mknodat breakage from r/o bind mounts
Date: Wed, 26 Sep 2007 16:03:45 +0100	[thread overview]
Message-ID: <20070926150345.GA24744@infradead.org> (raw)
In-Reply-To: <E1IaJMd-000535-00@dorka.pomaz.szeredi.hu>

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;


      parent reply	other threads:[~2007-09-26 15:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-25 22:58 [patch] fix sys_mknodat breakage from r/o bind mounts Miklos Szeredi
2007-09-25 23:13 ` Dave Hansen
2007-09-25 23:18   ` Miklos Szeredi
2007-09-26 15:03 ` Christoph Hellwig [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070926150345.GA24744@infradead.org \
    --to=hch@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox