]> git.itanic.dy.fi Git - linux-stable/commit
fs: fix undefined behavior in bit shift for SB_NOUSER
authorHao Ge <gehao@kylinos.cn>
Mon, 24 Apr 2023 05:18:35 +0000 (13:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 13:17:26 +0000 (14:17 +0100)
commit571593b673774ee90e89fc1d3fd6aae0c778a8ee
treeab8300d08d2669b2bb9d35757c9380798e6a7730
parent93d0cbe88118fcef234d3ebcbdadcb9ebe9d34f1
fs: fix undefined behavior in bit shift for SB_NOUSER

commit f15afbd34d8fadbd375f1212e97837e32bc170cc upstream.

Shifting signed 32-bit value by 31 bits is undefined, so changing
significant bit to unsigned. It was spotted by UBSAN.

So let's just fix this by using the BIT() helper for all SB_* flags.

Fixes: e462ec50cb5f ("VFS: Differentiate mount flags (MS_*) from internal superblock flags")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
Message-Id: <20230424051835.374204-1-gehao@kylinos.cn>
[brauner@kernel.org: use BIT() for all SB_* flags]
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/fs.h