kernel_samsung_a53x/fs/nilfs2
Ryusuke Konishi 5ff878bcc2 nilfs2: avoid undefined behavior in nilfs_cnt32_ge macro
[ Upstream commit 0f3819e8c483771a59cf9d3190cd68a7a990083c ]

According to the C standard 3.4.3p3, the result of signed integer overflow
is undefined.  The macro nilfs_cnt32_ge(), which compares two sequence
numbers, uses signed integer subtraction that can overflow, and therefore
the result of the calculation may differ from what is expected due to
undefined behavior in different environments.

Similar to an earlier change to the jiffies-related comparison macros in
commit 5a581b367b5d ("jiffies: Avoid undefined behavior from signed
overflow"), avoid this potential issue by changing the definition of the
macro to perform the subtraction as unsigned integers, then cast the
result to a signed integer for comparison.

Link: https://lkml.kernel.org/r/20130727225828.GA11864@linux.vnet.ibm.com
Link: https://lkml.kernel.org/r/20240702183512.6390-1-konishi.ryusuke@gmail.com
Fixes: 9ff05123e3bf ("nilfs2: segment constructor")
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:20:12 +01:00
..
alloc.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-11-19 14:19:43 +01:00
alloc.h nilfs2: fix incorrect inode allocation from reserved inodes 2024-11-19 14:19:43 +01:00
bmap.c
bmap.h
btnode.c
btnode.h
btree.c
btree.h
cpfile.c
cpfile.h
dat.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-11-19 14:19:43 +01:00
dat.h
dir.c nilfs2: fix kernel bug on rename operation of broken directory 2024-11-19 14:19:46 +01:00
direct.c
direct.h
export.h
file.c
gcinode.c
ifile.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-11-19 14:19:43 +01:00
ifile.h
inode.c
ioctl.c
Kconfig
Makefile
mdt.c
mdt.h
namei.c
nilfs.h nilfs2: add missing check for inode numbers on directory entries 2024-11-19 14:19:41 +01:00
page.c
page.h
recovery.c
segbuf.c
segbuf.h
segment.c nilfs2: avoid undefined behavior in nilfs_cnt32_ge macro 2024-11-23 23:20:12 +01:00
segment.h
sufile.c
sufile.h
super.c
sysfs.c
sysfs.h
the_nilfs.c nilfs2: fix inode number range checks 2024-11-19 14:19:41 +01:00
the_nilfs.h nilfs2: fix inode number range checks 2024-11-19 14:19:41 +01:00