mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guo Chao <yan@linux.vnet.ibm.com>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] Check node type at the beginning of mknodat
Date: Fri, 29 Jun 2012 11:29:17 +0800	[thread overview]
Message-ID: <1340940558-9893-2-git-send-email-yan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1340940558-9893-1-git-send-email-yan@linux.vnet.ibm.com>

We make sure node is not directory at beginning of mknodat, which is in 
effect included in a latter may_mknod check.

Move may_mknod up to replace directory check. We can also avoid cleanup 
if check fails.

Signed-off-by: Guo Chao <yan@linux.vnet.ibm.com>
---
 fs/namei.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 8dccfcc..05b9053 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2910,8 +2910,9 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
 	struct path path;
 	int error;
 
-	if (S_ISDIR(mode))
-		return -EPERM;
+	error = may_mknod(mode);
+	if (error)
+		return error;
 
 	dentry = user_path_create(dfd, filename, &path, 0);
 	if (IS_ERR(dentry))
@@ -2919,9 +2920,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
 
 	if (!IS_POSIXACL(path.dentry->d_inode))
 		mode &= ~current_umask();
-	error = may_mknod(mode);
-	if (error)
-		goto out_dput;
+
 	error = mnt_want_write(path.mnt);
 	if (error)
 		goto out_dput;
-- 
1.7.9.5


  reply	other threads:[~2012-06-29  3:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29  3:29 [PATCH 1/3] Use path_put instead of combination of two functions Guo Chao
2012-06-29  3:29 ` Guo Chao [this message]
2012-06-29  3:29 ` [PATCH 3/3] fs/namei: fix some typos Guo Chao

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=1340940558-9893-2-git-send-email-yan@linux.vnet.ibm.com \
    --to=yan@linux.vnet.ibm.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

Powered by JetHome