This is a note to let you know that I've just added the patch titled xfs: prevent a WARN_ONCE() in xfs_ioc_attr_list() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-prevent-a-warn_once-in-xfs_ioc_attr_list.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Sat Jul 23 05:23:15 PM CEST 2022 From: Leah Rumancik <leah.rumancik@xxxxxxxxx> Date: Thu, 21 Jul 2022 14:36:10 -0700 Subject: xfs: prevent a WARN_ONCE() in xfs_ioc_attr_list() To: stable@xxxxxxxxxxxxxxx, linux-xfs@xxxxxxxxxxxxxxx Cc: amir73il@xxxxxxxxx, Dan Carpenter <dan.carpenter@xxxxxxxxxx>, "Darrick J . Wong" <djwong@xxxxxxxxxx>, Leah Rumancik <leah.rumancik@xxxxxxxxx> Message-ID: <20220721213610.2794134-7-leah.rumancik@xxxxxxxxx> From: Dan Carpenter <dan.carpenter@xxxxxxxxxx> [ Upstream commit 6ed6356b07714e0198be3bc3ecccc8b40a212de4 ] The "bufsize" comes from the root user. If "bufsize" is negative then, because of type promotion, neither of the validation checks at the start of the function are able to catch it: if (bufsize < sizeof(struct xfs_attrlist) || bufsize > XFS_XATTR_LIST_MAX) return -EINVAL; This means "bufsize" will trigger (WARN_ON_ONCE(size > INT_MAX)) in kvmalloc_node(). Fix this by changing the type from int to size_t. Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Leah Rumancik <leah.rumancik@xxxxxxxxx> Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_ioctl.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -372,7 +372,7 @@ int xfs_ioc_attr_list( struct xfs_inode *dp, void __user *ubuf, - int bufsize, + size_t bufsize, int flags, struct xfs_attrlist_cursor __user *ucursor) { --- a/fs/xfs/xfs_ioctl.h +++ b/fs/xfs/xfs_ioctl.h @@ -38,8 +38,9 @@ xfs_readlink_by_handle( int xfs_ioc_attrmulti_one(struct file *parfilp, struct inode *inode, uint32_t opcode, void __user *uname, void __user *value, uint32_t *len, uint32_t flags); -int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf, int bufsize, - int flags, struct xfs_attrlist_cursor __user *ucursor); +int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf, + size_t bufsize, int flags, + struct xfs_attrlist_cursor __user *ucursor); extern struct dentry * xfs_handle_to_dentry( Patches currently in stable-queue which might be from leah.rumancik@xxxxxxxxx are queue-5.15/xfs-prevent-a-warn_once-in-xfs_ioc_attr_list.patch queue-5.15/xfs-rename-the-next_agno-perag-iteration-variable.patch queue-5.15/xfs-fix-perag-reference-leak-on-iteration-race-with-growfs.patch queue-5.15/xfs-terminate-perag-iteration-reliably-on-agcount.patch queue-5.15/xfs-fold-perag-loop-iteration-logic-into-helper-function.patch queue-5.15/xfs-fix-maxlevels-comparisons-in-the-btree-staging-code.patch