FAILED: patch "[PATCH] ocfs2: strict bound check before memcmp in" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x af77c4fc1871847b528d58b7fdafb4aa1f6a9262
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024072553-viewing-trapped-d0a4@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
af77c4fc1871 ("ocfs2: strict bound check before memcmp in ocfs2_xattr_find_entry()")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From af77c4fc1871847b528d58b7fdafb4aa1f6a9262 Mon Sep 17 00:00:00 2001
From: Ferry Meng <[email protected]>
Date: Mon, 20 May 2024 10:40:24 +0800
Subject: [PATCH] ocfs2: strict bound check before memcmp in
ocfs2_xattr_find_entry()
xattr in ocfs2 maybe 'non-indexed', which saved with additional space requested. It's better to check if the memory is out of bound before memcmp, although this possibility mainly comes from crafted poisonous images.
fs/ocfs2/xattr.c +10 -5
@@ -1068,7 +1068,7 @@ static int ocfs2_xattr_find_entry(struct inode *inode, int name_index, {struct ocfs2_xattr_entry *entry;size_t name_len; -int i, cmp =1 ; +int i, name_offset, cmp =1 ;if (name ==NULL )return -EINVAL ;
@@ -1083,10 +1083,15 @@ static int ocfs2_xattr_find_entry(struct inode *inode, int name_index, cmp = name_index -ocfs2_xattr_get_type (entry);if (!cmp) cmp = name_len - entry->xe_name_len; -if (!cmp) - cmp =memcmp (name, (xs->base + -le16_to_cpu (entry->xe_name_offset)), - name_len); +if (!cmp) { + name_offset =le16_to_cpu (entry->xe_name_offset); +if ((xs->base + name_offset + name_len) > xs->end) { +ocfs2_error (inode->i_sb, +"corrupted xattr entries" ); +return -EFSCORRUPTED ; + } + cmp =memcmp (name, (xs->base + name_offset), name_len); + }if (cmp ==0 )break ; entry +=1 ;