* [PATCH] sysv: use BUILD_BUG_ON instead of runtime check
@ 2021-08-13 12:30 Pavel Skripkin
2021-09-01 10:15 ` Pavel Skripkin
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Skripkin @ 2021-08-13 12:30 UTC (permalink / raw)
To: hch; +Cc: linux-kernel, Pavel Skripkin
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
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
fs/sysv/super.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/sysv/super.c b/fs/sysv/super.c
index cc8e2ed155c8..d1def0771a40 100644
--- a/fs/sysv/super.c
+++ b/fs/sysv/super.c
@@ -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)
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sysv: use BUILD_BUG_ON instead of runtime check
2021-08-13 12:30 [PATCH] sysv: use BUILD_BUG_ON instead of runtime check Pavel Skripkin
@ 2021-09-01 10:15 ` Pavel Skripkin
2021-09-27 12:12 ` Pavel Skripkin
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Skripkin @ 2021-09-01 10:15 UTC (permalink / raw)
To: dhowells, viro; +Cc: linux-kernel, hch
On 8/13/21 15:30, Pavel Skripkin wrote:
> 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
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
> ---
> fs/sysv/super.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/sysv/super.c b/fs/sysv/super.c
> index cc8e2ed155c8..d1def0771a40 100644
> --- a/fs/sysv/super.c
> +++ b/fs/sysv/super.c
> @@ -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)
>
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/20210813123020.22971-1-paskripkin@gmail.com/
Thank you!
With regards,
Pavel Skripkin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sysv: use BUILD_BUG_ON instead of runtime check
2021-09-01 10:15 ` Pavel Skripkin
@ 2021-09-27 12:12 ` Pavel Skripkin
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Skripkin @ 2021-09-27 12:12 UTC (permalink / raw)
To: dhowells, viro, akpm; +Cc: linux-kernel, hch
On 9/1/21 13:15, Pavel Skripkin wrote:
> On 8/13/21 15:30, Pavel Skripkin wrote:
>> 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
>>
>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
>> ---
>> fs/sysv/super.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/sysv/super.c b/fs/sysv/super.c
>> index cc8e2ed155c8..d1def0771a40 100644
>> --- a/fs/sysv/super.c
>> +++ b/fs/sysv/super.c
>> @@ -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)
>>
>
> 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/20210813123020.22971-1-paskripkin@gmail.com/
>
>
>
> Thank you!
Hi, Andrew,
Maybe this one can go through your tree?
With regards,
Pavel Skripkin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-27 12:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13 12:30 [PATCH] sysv: use BUILD_BUG_ON instead of runtime check Pavel Skripkin
2021-09-01 10:15 ` Pavel Skripkin
2021-09-27 12:12 ` Pavel Skripkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).