sysv: use BUILD_BUG_ON instead of runtime check
PATCH 1/1 sysv: use BUILD_BUG_ON instead of runtime check
There was runtime checks about sizes of struct v7_super_block and struct sysv_inode. If one of these checks fail kernel will panic. Since these values are known on complite time let's use BUILD_BUG_ON(), because it's standard mechanism for validation checking at build time
--- fs/sysv/super.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/sysv/super.c +2 -4
@@ -474,10 +474,8 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)struct sysv_sb_info *sbi;struct buffer_head *bh; -if (440 !=sizeof (struct v7_super_block )) -panic ("V7 FS: bad super-block size" ); -if (64 !=sizeof (struct sysv_inode )) -panic ("sysv fs: bad i-node size" ); +BUILD_BUG_ON (sizeof (struct v7_super_block ) !=440 ); +BUILD_BUG_ON (sizeof (struct sysv_inode ) !=64 ); sbi =kzalloc (sizeof (struct sysv_sb_info ),GFP_KERNEL );if (!sbi)
Signature · 1 line
2.32.0
Quoted 19 lines · Pavel Skripkin
There was runtime checks about sizes of struct
v7_super_blockand structsysv_inode. If one of these checks fail kernel will panic. Since these values are known on complite time let's useBUILD_BUG_ON(), because it's standard mechanism for validation checking at build timeFixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Pavel Skripkin <[email protected]>--- fs/sysv/super.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/sysv/super.c +0
-0@@ -474,10 +474,8 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)struct sysv_sb_info *sbi;struct buffer_head *bh;
fs/sysv/super.c static int v7_fill_super(struct super_block *sb, void *data, int silent) · line 481
Quoted 10 lines
fs/sysv/super.c +2
-4-if (440 !=sizeof (struct v7_super_block )) -panic ("V7 FS: bad super-block size" ); -if (64 !=sizeof (struct sysv_inode )) -panic ("sysv fs: bad i-node size" ); +BUILD_BUG_ON (sizeof (struct v7_super_block ) !=440 ); +BUILD_BUG_ON (sizeof (struct sysv_inode ) !=64 ); sbi =kzalloc (sizeof (struct sysv_sb_info ),GFP_KERNEL );if (!sbi)
Hi, David and Alexander!
Maybe, this one can go through one of your trees? I didn't find any sysv related trees, so..
Lore link to the patch: https://lore.kernel.org/lkml/[email protected]/
Thank you!
With regards,
Pavel Skripkin
Quoted 37 lines · Pavel Skripkin
Quoted 19 lines · Pavel Skripkin
There was runtime checks about sizes of struct
v7_super_blockand structsysv_inode. If one of these checks fail kernel will panic. Since these values are known on complite time let's useBUILD_BUG_ON(), because it's standard mechanism for validation checking at build timeFixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Pavel Skripkin <[email protected]>--- fs/sysv/super.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/sysv/super.c +0
-0@@ -474,10 +474,8 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)struct sysv_sb_info *sbi;struct buffer_head *bh;fs/sysv/super.c static int v7_fill_super(struct super_block *sb, void *data, int silent) · line 481
Quoted 10 lines
fs/sysv/super.c +2
-4-if (440 !=sizeof (struct v7_super_block )) -panic ("V7 FS: bad super-block size" ); -if (64 !=sizeof (struct sysv_inode )) -panic ("sysv fs: bad i-node size" ); +BUILD_BUG_ON (sizeof (struct v7_super_block ) !=440 ); +BUILD_BUG_ON (sizeof (struct sysv_inode ) !=64 ); sbi =kzalloc (sizeof (struct sysv_sb_info ),GFP_KERNEL );if (!sbi)Hi, David and Alexander!
Maybe, this one can go through one of your trees? I didn't find any sysv related trees, so..
Quoted 6 lines
Lore link to the patch:
https://lore.kernel.org/lkml/[email protected]/Thank you!
Hi, Andrew,
Maybe this one can go through your tree?
With regards,
Pavel Skripkin