Re: [PATCH v1 1/3] kallsyms: avoid hardcoding the buffer size

From: Miguel Ojeda
Date: Fri May 06 2022 - 08:58:44 EST


Hi James,

On Fri, May 6, 2022 at 1:19 PM James Bottomley
<James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> wrote:
>
> When you raise KSYM_NAME_LEN to 512, this on stack allocation becomes
> 2049 bytes. How did you manage not to trigger the frame size warning,
> which is 1024 on 32 bit and 2048 on 64 bit by default?

Thanks for taking a look!

If you mean `CONFIG_FRAME_WARN`, that applies to kernel objects, not scripts.

If I enable it for `HOSTCC` with a 2048 threshold, we do get the warning:

scripts/kallsyms.c: In function 'read_symbol':
scripts/kallsyms.c:257:1: warning: the frame size of 2080 bytes is
larger than 2048 bytes [-Wframe-larger-than=]
257 | }
| ^

as well as in a few other places (e.g. for my config [0]), but given
it is userspace it should be fine unless they happen to end up
recursing quite a few times.

Cheers,
Miguel

[0]
scripts/mod/modpost.c: In function 'main':
scripts/mod/modpost.c:2636:1: warning: the frame size of 4208
bytes is larger than 2048 bytes [-Wframe-larger-than=]
2636 | }
| ^
scripts/mod/sumversion.c: In function 'get_src_version':
scripts/mod/sumversion.c:419:1: warning: the frame size of 4272
bytes is larger than 2048 bytes [-Wframe-larger-than=]
419 | }
| ^
usr/gen_init_cpio.c: In function 'cpio_mkgeneric_line':
usr/gen_init_cpio.c:223:1: warning: the frame size of 4384 bytes
is larger than 2048 bytes [-Wframe-larger-than=]
223 | }
| ^
usr/gen_init_cpio.c: In function 'cpio_mknod_line':
usr/gen_init_cpio.c:293:1: warning: the frame size of 4400 bytes
is larger than 2048 bytes [-Wframe-larger-than=]
293 | }
| ^
usr/gen_init_cpio.c: In function 'cpio_mkfile_line':
usr/gen_init_cpio.c:456:1: warning: the frame size of 12560 bytes
is larger than 2048 bytes [-Wframe-larger-than=]
456 | }
| ^
usr/gen_init_cpio.c: In function 'cpio_mkslink_line':
usr/gen_init_cpio.c:150:1: warning: the frame size of 8496 bytes
is larger than 2048 bytes [-Wframe-larger-than=]
150 | }
| ^
usr/gen_init_cpio.c: In function 'main':
usr/gen_init_cpio.c:640:1: warning: the frame size of 8528 bytes
is larger than 2048 bytes [-Wframe-larger-than=]
640 | }
| ^
drivers/tty/vt/conmakehash.c: In function 'main':
drivers/tty/vt/conmakehash.c:290:1: warning: the frame size of
65584 bytes is larger than 2048 bytes [-Wframe-larger-than=]
290 | }
| ^