From aaf431b4f92152d46ab54079692633aa422262b1 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Mon, 9 May 2016 13:28:49 +0200 Subject: xattr: Fail with -EINVAL for NULL attribute names Commit 98e9cb57 improved the xattr name checks in xattr_resolve_name but didn't update the NULL attribute name check appropriately, so NULL attribute names lead to NULL pointer dereferences. Turn that into -EINVAL results instead. Signed-off-by: Andreas Gruenbacher fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Signed-off-by: Al Viro --- fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs') diff --git a/fs/xattr.c b/fs/xattr.c index b11945e15fde..4231488f2122 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -668,7 +668,7 @@ xattr_resolve_name(const struct xattr_handler **handlers, const char **name) const struct xattr_handler *handler; if (!*name) - return NULL; + return ERR_PTR(-EINVAL); for_each_xattr_handler(handlers, handler) { const char *n; -- cgit v1.2.3 From 0040773bff7b585fc948565a0558e5a6a4680e96 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 25 May 2016 17:34:41 -0400 Subject: make xattr_resolve_handlers() safe to use with NULL ->s_xattr Signed-off-by: Al Viro --- fs/xattr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'fs') diff --git a/fs/xattr.c b/fs/xattr.c index 4231488f2122..fc81e771488a 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -655,6 +655,7 @@ strcmp_prefix(const char *a, const char *a_prefix) * operations to the correct xattr_handler. */ #define for_each_xattr_handler(handlers, handler) \ + if (handlers) \ for ((handler) = *(handlers)++; \ (handler) != NULL; \ (handler) = *(handlers)++) -- cgit v1.2.3