All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Hao Ge <gehao@kylinos.cn>
Cc: brauner@kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, gehao618@163.com
Subject: Re: [PATCH V2] fs: fix undefined behavior in bit shift for SB_NOUSER
Date: Mon, 24 Apr 2023 06:01:58 +0100	[thread overview]
Message-ID: <20230424050158.GN3390869@ZenIV> (raw)
In-Reply-To: <20230424045122.370511-1-gehao@kylinos.cn>

On Mon, Apr 24, 2023 at 12:51:22PM +0800, Hao Ge wrote:
> Shifting signed 32-bit value by 31 bits is undefined, so changing
> significant bit to unsigned. The UBSAN warning calltrace like below:

> UBSAN: shift-out-of-bounds in fs/nsfs.c:306:32
> left shift of 1 by 31 places cannot be represented in type 'int'
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.3.0-rc4+ #2
> Call trace:
> <TASK>
> dump_backtrace+0x134/0x1e0
> show_stack+0x2c/0x3c
> dump_stack_lvl+0xb0/0xd4
> dump_stack+0x14/0x1c
> ubsan_epilogue+0xc/0x3c
> __ubsan_handle_shift_out_of_bounds+0xb0/0x14c
> nsfs_init+0x4c/0xb0
> start_kernel+0x38c/0x738
> __primary_switched+0xbc/0xc4
> </TASK>
> 
> Fixes: e462ec50cb5f ("VFS: Differentiate mount flags (MS_*) from internal superblock flags")
> Signed-off-by: Hao Ge <gehao@kylinos.cn>

*snort*

IMO something like "spotted by UBSAN" is more than enough here -
stack trace is completely pointless.

Otherwise, no problems with the patch - it's obviously safe.

  reply	other threads:[~2023-04-24  5:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24  3:00 [PATCH] fs: fix undefined behavior in bit shift for SB_NOUSER Hao Ge
2023-04-24  4:51 ` [PATCH V2] " Hao Ge
2023-04-24  5:01   ` Al Viro [this message]
2023-04-24  5:18     ` [PATCH V3] " Hao Ge
2023-04-24  5:43     ` [PATCH V2] " Hao Ge
  -- strict thread matches above, loose matches on Subject: below --
2022-10-31 13:48 [PATCH v2] " Gaosheng Cui
2022-10-31 13:50 ` Christoph Hellwig
2022-10-31 13:53 ` Matthew Wilcox
2022-10-31 14:05   ` Christoph Hellwig
2022-10-31 14:36   ` cuigaosheng

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=20230424050158.GN3390869@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=brauner@kernel.org \
    --cc=gehao618@163.com \
    --cc=gehao@kylinos.cn \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.