linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Trig a BUG when kern_path see LOOKUP_ROOT in flag
@ 2012-07-04  2:00 Guo Chao
  0 siblings, 0 replies; only message in thread
From: Guo Chao @ 2012-07-04  2:00 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel

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@linux.vnet.ibm.com>
---
 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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-07-04  2:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-04  2:00 [PATCH] Trig a BUG when kern_path see LOOKUP_ROOT in flag Guo Chao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).