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>,
	"Author : Randy Dunlap" <rdunlap@infradead.org>,
	<syzbot+35b87c668935bb55e666@syzkaller.appspotmail.com>
Subject: Re: [PATCH] fs/ntfs3: Avoid UBSAN error on true_sectors_per_clst()
Date: Fri, 30 Sep 2022 18:53:30 +0300	[thread overview]
Message-ID: <136fa55a-56d5-7d62-bbf0-602a357ab46d@paragon-software.com> (raw)
In-Reply-To: <20220823144625.1627736-1-syoshida@redhat.com>



On 8/23/22 17:46, Shigeru Yoshida wrote:
> syzbot reported UBSAN error as below:
> 
> [   76.901829][ T6677] ================================================================================
> [   76.903908][ T6677] UBSAN: shift-out-of-bounds in fs/ntfs3/super.c:675:13
> [   76.905363][ T6677] shift exponent -247 is negative
> 
> This patch avoid this error.
> 
> Link: https://syzkaller.appspot.com/bug?id=b0299c09a14aababf0f1c862dd4ebc8ab9eb0179
> Fixes: a3b774342fa7 (fs/ntfs3: validate BOOT sectors_per_clusters)
> Cc: Author: Randy Dunlap <rdunlap@infradead.org>
> Reported-by: syzbot+35b87c668935bb55e666@syzkaller.appspotmail.com
> Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
> ---
>   fs/ntfs3/super.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 47012c9bf505..adc4f73722b7 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -672,7 +672,7 @@ static u32 true_sectors_per_clst(const struct NTFS_BOOT *boot)
>   	if (boot->sectors_per_clusters <= 0x80)
>   		return boot->sectors_per_clusters;
>   	if (boot->sectors_per_clusters >= 0xf4) /* limit shift to 2MB max */
> -		return 1U << (0 - boot->sectors_per_clusters);
> +		return 1U << -(s8)boot->sectors_per_clusters;
>   	return -EINVAL;
>   }
>   

Applied, thanks again for the patch!

      parent reply	other threads:[~2022-09-30 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 14:46 [PATCH] fs/ntfs3: Avoid UBSAN error on true_sectors_per_clst() Shigeru Yoshida
2022-09-07 16:01 ` Shigeru Yoshida
2022-09-30 15:53 ` 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=136fa55a-56d5-7d62-bbf0-602a357ab46d@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=rdunlap@infradead.org \
    --cc=syoshida@redhat.com \
    --cc=syzbot+35b87c668935bb55e666@syzkaller.appspotmail.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