[PATCH] Trig a BUG when kern_path see LOOKUP_ROOT in flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kern_path does not prepare for LOOKUP_ROOT, if this flag is passed down,
path_init will reference uninitialized nameidata. When things go wrong, it will 
not be as obvious as dereferencing a null pointer. Kindly trig a bug here.

Signed-off-by: Guo Chao <yan@xxxxxxxxxxxxxxxxxx>
---
 fs/namei.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/namei.c b/fs/namei.c
index 1b64746..2b8c226 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1888,6 +1888,9 @@ struct dentry *kern_path_locked(const char *name, struct path *path)
 int kern_path(const char *name, unsigned int flags, struct path *path)
 {
 	struct nameidata nd;
+
+	BUG_ON(flags & LOOKUP_ROOT);
+
 	int res = do_path_lookup(AT_FDCWD, name, flags, &nd);
 	if (!res)
 		*path = nd.path;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux