Skip to contentSkip to conversation

Trig a BUG when kern_path see LOOKUP_ROOT in flag

PATCH New Guo Chao 1 participant 1 message Jul 4, 2012 VFS

lore
Share & tools
lore

Guo Chao

author
#0 lore raw

PATCH 1/1 Trig a BUG when kern_path see LOOKUP_ROOT in flag

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.

---
 fs/namei.c |    3 +++
 1 file changed, 3 insertions(+)
fs/namei.c +3 -0
index 1b64746..2b8c226 100644
@@ -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;
Signature · 1 line
1.7.9.5