From: Namjae Jeon <linkinjeon@kernel.org>
To: Ferry Meng <mengferry@linux.alibaba.com>
Cc: Steve French <smfrench@gmail.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Tom Talpey <tom@talpey.com>,
Tristan Madani <tristan@talencesecurity.com>,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] ksmbd: fix SID memory leak in set_posix_acl_entries_dacl() on overflow
Date: Tue, 12 May 2026 09:32:53 +0900 [thread overview]
Message-ID: <CAKYAXd8Ut2=r=3r6t6GJFdKkKa_w7oDfVB3SX3OYOt_9ob5rtQ@mail.gmail.com> (raw)
In-Reply-To: <20260511131816.93314-1-mengferry@linux.alibaba.com>
On Mon, May 11, 2026 at 10:18 PM Ferry Meng <mengferry@linux.alibaba.com> wrote:
>
> Commit 299f962c0b02 ("ksmbd: use check_add_overflow() to prevent u16
> DACL size overflow") added check_add_overflow() guards that break out
> of the ACE-building loops in set_posix_acl_entries_dacl() when the
> accumulated DACL size would wrap past 65535.
>
> However, each iteration allocates a struct smb_sid via kmalloc_obj()
> at the top of the loop and relies on the kfree(sid) call at the end
> of the loop body (the 'pass_same_sid' label in the first loop, and
> the explicit kfree at the tail of the second loop) to release it.
> The newly introduced 'break' statements bypass those kfree() calls,
> leaking the sid buffer every time an overflow is detected.
>
> A malicious or malformed file with enough POSIX ACL entries to trip
> the overflow check will leak one or more struct smb_sid allocations
> on every request that touches the file's DACL, providing a trivial
> kernel memory exhaustion vector.
>
> Free sid before breaking out of the loops to plug the leak.
>
> Fixes: 299f962c0b02 ("ksmbd: use check_add_overflow() to prevent u16 DACL size overflow")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ferry Meng <mengferry@linux.alibaba.com>
Applied it to #ksmbd-for-next-next.
Thanks!
prev parent reply other threads:[~2026-05-12 0:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 13:18 [PATCH] ksmbd: fix SID memory leak in set_posix_acl_entries_dacl() on overflow Ferry Meng
2026-05-12 0:32 ` Namjae Jeon [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKYAXd8Ut2=r=3r6t6GJFdKkKa_w7oDfVB3SX3OYOt_9ob5rtQ@mail.gmail.com' \
--to=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mengferry@linux.alibaba.com \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tom@talpey.com \
--cc=tristan@talencesecurity.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).