public inbox for ntfs3@lists.linux.dev
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Shigeru Yoshida <syoshida@redhat.com>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fs/ntfs3: Fix slab-out-of-bounds in ntfs_trim_fs()
Date: Mon, 26 Dec 2022 19:45:59 +0400	[thread overview]
Message-ID: <d7805125-cd44-3dba-8f79-95c989844191@paragon-software.com> (raw)
In-Reply-To: <20221130145705.488351-1-syoshida@redhat.com>

On 30.11.2022 18:57, Shigeru Yoshida wrote:
> ntfs_trim_fs() should loop with wnd->nwnd, not wnd->nbits.  KASAN
> detects this as an out-of-bounds access like below:
>
> ==================================================================
> BUG: KASAN: slab-out-of-bounds in ntfs_trim_fs (fs/ntfs3/bitmap.c:1434)
> Read of size 2 at addr ffff8881745b4f02 by task repro/19678
>
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-2.fc37 04/01/2014
> Call Trace:
>   <TASK>
> dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4))
> print_report (mm/kasan/report.c:285 mm/kasan/report.c:395)
> ? __virt_addr_valid (arch/x86/mm/physaddr.c:66)
> ? __phys_addr (arch/x86/mm/physaddr.c:32 (discriminator 4))
> ? ntfs_trim_fs (fs/ntfs3/bitmap.c:1434)
> ? ntfs_trim_fs (fs/ntfs3/bitmap.c:1434)
> kasan_report (mm/kasan/report.c:162 mm/kasan/report.c:497)
> ? ntfs_trim_fs (fs/ntfs3/bitmap.c:1434)
> ntfs_trim_fs (fs/ntfs3/bitmap.c:1434)
> ntfs_ioctl (fs/ntfs3/file.c:41 fs/ntfs3/file.c:57)
> ? ntfs_fiemap (fs/ntfs3/file.c:51)
> ? bpf_lsm_file_ioctl (./include/linux/lsm_hook_defs.h:165)
> ? ntfs_fiemap (fs/ntfs3/file.c:51)
> __x64_sys_ioctl (fs/ioctl.c:52 fs/ioctl.c:870 fs/ioctl.c:856 fs/ioctl.c:856)
> do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
> entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120)
>
> Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
> ---
>   fs/ntfs3/bitmap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c
> index e92bbd754365..1930640be31a 100644
> --- a/fs/ntfs3/bitmap.c
> +++ b/fs/ntfs3/bitmap.c
> @@ -1424,7 +1424,7 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range)
>   
>   	down_read_nested(&wnd->rw_lock, BITMAP_MUTEX_CLUSTERS);
>   
> -	for (; iw < wnd->nbits; iw++, wbit = 0) {
> +	for (; iw < wnd->nwnd; iw++, wbit = 0) {
>   		CLST lcn_wnd = iw * wbits;
>   		struct buffer_head *bh;
>   

Thanks for work, this bug has already been fixed:

https://lore.kernel.org/ntfs3/20221001070024.1366018-1-abdun.nihaal@gmail.com/


      reply	other threads:[~2022-12-26 15:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 14:57 [PATCH] fs/ntfs3: Fix slab-out-of-bounds in ntfs_trim_fs() Shigeru Yoshida
2022-12-26 15:45 ` Konstantin Komarov [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=d7805125-cd44-3dba-8f79-95c989844191@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=syoshida@redhat.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