From: Paulo Alcantara <pc@manguebit.com>
To: Wang Zhaolong <wangzhaolong1@huawei.com>,
sfrench@samba.org, sfrench@us.ibm.com
Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org, chengzhihao1@huawei.com,
wangzhaolong1@huawei.com, yi.zhang@huawei.com,
yangerkun@huawei.com
Subject: Re: [PATCH V2 0/2] smb: client: Fix use-after-free in readdir
Date: Fri, 16 May 2025 10:49:59 -0300 [thread overview]
Message-ID: <860a4f7600814b17e48dbabe1ae19f68@manguebit.com> (raw)
In-Reply-To: <20250516091256.2756826-1-wangzhaolong1@huawei.com>
Wang Zhaolong <wangzhaolong1@huawei.com> writes:
> V2:
> - Correct spelling mistakes in the commit message, such as 'lopp' -> 'loop'.
> - The titles of patches follow the same style.
>
> This patch series addresses a use-after-free vulnerability in the SMB/CIFS
> client readdir implementation that can be triggered during concurrent
> directory reads when a signal interrupts directory enumeration.
>
> The root cause is in the operation sequence in find_cifs_entry():
> 1. When query_dir_next() fails due to signal interruption (ERESTARTSYS)
> 2. The code continues to access last_entry pointer before checking the return code
> 3. This can access freed memory since the buffer may have been released
>
> The race condition can be triggered by processes accessing the same directory
> with concurrent readdir operations, especially when signals are involved.
>
> The fix is straightforward:
> 1. First patch ensures we check the return code before using any pointers
> 2. Second patch improves defensiveness by resetting all related buffer pointers
> when freeing the network buffer
>
> Wang Zhaolong (2):
> smb: client: Fix use-after-free in cifs_fill_dirent
> smb: client: Reset all search buffer pointers when releasing buffer
>
> fs/smb/client/readdir.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
next prev parent reply other threads:[~2025-05-16 13:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 9:12 [PATCH V2 0/2] smb: client: Fix use-after-free in readdir Wang Zhaolong
2025-05-16 9:12 ` [PATCH V2 1/2] smb: client: Fix use-after-free in cifs_fill_dirent Wang Zhaolong
2025-05-16 9:12 ` [PATCH V2 2/2] smb: client: Reset all search buffer pointers when releasing buffer Wang Zhaolong
2025-05-16 13:49 ` Paulo Alcantara [this message]
2025-05-17 20:18 ` [PATCH V2 0/2] smb: client: Fix use-after-free in readdir Steve French
2025-05-19 2:56 ` Wang Zhaolong
2025-05-19 15:41 ` Steve French
2025-05-22 12:53 ` Wang Zhaolong
2025-05-22 14:00 ` Wang Zhaolong
2025-05-22 15:39 ` Steve French
2025-05-23 2:33 ` Wang Zhaolong
2025-08-05 2:38 ` Wang Zhaolong
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=860a4f7600814b17e48dbabe1ae19f68@manguebit.com \
--to=pc@manguebit.com \
--cc=chengzhihao1@huawei.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=sfrench@us.ibm.com \
--cc=wangzhaolong1@huawei.com \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.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