From: Theodore Ts'o Date: Wed, 1 Aug 2018 16:36:52 +0000 (-0400) Subject: ext4: check for NUL characters in extended attribute's name X-Git-Tag: v4.4.154~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac92782e4ef6fc9f4694bdc9e1b5d5bfb72027ff;p=profile%2Fcommon%2Fplatform%2Fkernel%2Flinux-artik7.git ext4: check for NUL characters in extended attribute's name commit 7d95178c77014dbd8dce36ee40bbbc5e6c121ff5 upstream. Extended attribute names are defined to be NUL-terminated, so the name must not contain a NUL character. This is important because there are places when remove extended attribute, the code uses strlen to determine the length of the entry. That should probably be fixed at some point, but code is currently really messy, so the simplest fix for now is to simply validate that the extended attributes are sane. https://bugzilla.kernel.org/show_bug.cgi?id=200401 Reported-by: Wen Xu Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index c7cad05..9fb2a75 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -197,6 +197,8 @@ ext4_xattr_check_names(struct ext4_xattr_entry *entry, void *end, struct ext4_xattr_entry *next = EXT4_XATTR_NEXT(e); if ((void *)next >= end) return -EFSCORRUPTED; + if (strnlen(e->e_name, e->e_name_len) != e->e_name_len) + return -EFSCORRUPTED; e = next; }