FAILED: patch "[PATCH] ksmbd: free ppace array on error in parse_dacl" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-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-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 8cf9bedfc3c47d24bb0de386f808f925dc52863e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024011859-dragging-hermit-6aa8@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
8cf9bedfc3c4 ("ksmbd: free ppace array on error in parse_dacl")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8cf9bedfc3c47d24bb0de386f808f925dc52863e Mon Sep 17 00:00:00 2001
From: Fedor Pchelkin <[email protected]>
Date: Tue, 9 Jan 2024 17:14:44 +0300
Subject: [PATCH] ksmbd: free ppace array on error in parse_dacl
The ppace array is not freed if one of the init_acl_state() calls inside parse_dacl() fails. At the moment the function may fail only due to the memory allocation errors so it's highly unlikely in this case but nevertheless a fix is needed.
Move ppace allocation after the init_acl_state() calls with proper error handling.
Found by Linux Verification Center (linuxtesting.org).
fs/smb/server/smbacl.c +7 -4
@@ -401,10 +401,6 @@ static void parse_dacl(struct mnt_idmap *idmap,if (num_aces >ULONG_MAX /sizeof (struct smb_ace *))return ; - ppace =kmalloc_array (num_aces,sizeof (struct smb_ace *),GFP_KERNEL ); -if (!ppace) -return ; - ret =init_acl_state (&acl_state, num_aces);if (ret)return ;
@@ -414,6 +410,13 @@ static void parse_dacl(struct mnt_idmap *idmap,return ; } + ppace =kmalloc_array (num_aces,sizeof (struct smb_ace *),GFP_KERNEL ); +if (!ppace) { +free_acl_state (&default_acl_state); +free_acl_state (&acl_state); +return ; + } +/* * reset rwx permissions for user/group/other. * Also, if num_aces is 0 i.e. DACL has no ACEs,