mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] Use path_put instead of combination of two functions
@ 2012-06-29  3:29 Guo Chao
  2012-06-29  3:29 ` [PATCH 2/3] Check node type at the beginning of mknodat Guo Chao
  2012-06-29  3:29 ` [PATCH 3/3] fs/namei: fix some typos Guo Chao
  0 siblings, 2 replies; 3+ messages in thread
From: Guo Chao @ 2012-06-29  3:29 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel


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

diff --git a/fs/namei.c b/fs/namei.c
index 0e1b9c3..8dccfcc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -846,8 +846,7 @@ int follow_down_one(struct path *path)
 
 	mounted = lookup_mnt(path);
 	if (mounted) {
-		dput(path->dentry);
-		mntput(path->mnt);
+		path_put(path);
 		path->mnt = mounted;
 		path->dentry = dget(mounted->mnt_root);
 		return 1;
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] Check node type at the beginning of mknodat
  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
  2012-06-29  3:29 ` [PATCH 3/3] fs/namei: fix some typos Guo Chao
  1 sibling, 0 replies; 3+ messages in thread
From: Guo Chao @ 2012-06-29  3:29 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] fs/namei: fix some typos
  2012-06-29  3:29 [PATCH 1/3] Use path_put instead of combination of two functions Guo Chao
  2012-06-29  3:29 ` [PATCH 2/3] Check node type at the beginning of mknodat Guo Chao
@ 2012-06-29  3:29 ` Guo Chao
  1 sibling, 0 replies; 3+ messages in thread
From: Guo Chao @ 2012-06-29  3:29 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel


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

diff --git a/fs/namei.c b/fs/namei.c
index 05b9053..adf61b3 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1080,7 +1080,7 @@ static struct dentry *lookup_dcache(struct qstr *name, struct dentry *dir,
 
 /*
  * Call i_op->lookup on the dentry.  The dentry must be negative but may be
- * hashed if it was pouplated with DCACHE_NEED_LOOKUP.
+ * hashed if it was populated with DCACHE_NEED_LOOKUP.
  *
  * dir->d_inode->i_mutex must be held
  */
@@ -1737,7 +1737,7 @@ static inline int lookup_last(struct nameidata *nd, struct path *path)
 					nd->flags & LOOKUP_FOLLOW);
 }
 
-/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
+/* Returns 0 and nd will be valid on success; Returns error, otherwise. */
 static int path_lookupat(int dfd, const char *name,
 				unsigned int flags, struct nameidata *nd)
 {
@@ -2002,7 +2002,7 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
  *	a. be owner of dir, or
  *	b. be owner of victim, or
  *	c. have CAP_FOWNER capability
- *  6. If the victim is append-only or immutable we can't do antyhing with
+ *  6. If the victim is append-only or immutable we can't do anything with
  *     links pointing to it.
  *  7. If we were asked to remove a directory and victim isn't one - ENOTDIR.
  *  8. If we were asked to remove a non-directory and victim isn't one - EISDIR.
@@ -3018,7 +3018,7 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
  * dentry, and if that is true (possibly after pruning the dcache),
  * then we drop the dentry now.
  *
- * A low-level filesystem can, if it choses, legally
+ * A low-level filesystem can, if it chooses, legally
  * do a
  *
  *	if (!d_unhashed(dentry))
@@ -3366,7 +3366,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
 	/*
 	 * To use null names we require CAP_DAC_READ_SEARCH
 	 * This ensures that not everyone will be able to create
-	 * handlink using the passed filedescriptor.
+	 * hardlink using the passed filedescriptor.
 	 */
 	if (flags & AT_EMPTY_PATH) {
 		if (!capable(CAP_DAC_READ_SEARCH))
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-29  3:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29  3:29 [PATCH 1/3] Use path_put instead of combination of two functions Guo Chao
2012-06-29  3:29 ` [PATCH 2/3] Check node type at the beginning of mknodat Guo Chao
2012-06-29  3:29 ` [PATCH 3/3] fs/namei: fix some typos Guo Chao

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