Message ID | kndlh7lx2gfmz5m3ilwzp7fcsmimsnjgh434hnaro2pmy7evl6@jfui76m22kig (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [GIT,PULL] sysctl constification changes for v6.14-rc1 | expand |
On Wed, 29 Jan 2025 at 00:14, Joel Granados <joel.granados@kernel.org> wrote: > > All ctl_table declared outside of functions and that remain unmodified after > initialization are const qualified. Hmm. A quick grep shows static struct ctl_table alignment_tbl[5] = { in arch/csky/abiv1/alignment.c that didn't get converted. And a couple of rdma drivers (iwcm_ctl_table and ucma_ctl_table), but maybe those weren't converted due to being in the "net" address space? Anyway, taken as-is, I'm just noting the lacking cases. Linus
The pull request you sent on Wed, 29 Jan 2025 09:14:20 +0100:
> git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl.git/ tags/constfy-sysctl-6.14-rc1
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/af13ff1c33e043b746cd96c83c7660ddf0272f73
Thank you!
On Wed, Jan 29, 2025 at 10:48:02AM -0800, Linus Torvalds wrote: > On Wed, 29 Jan 2025 at 00:14, Joel Granados <joel.granados@kernel.org> wrote: > > > > All ctl_table declared outside of functions and that remain unmodified after > > initialization are const qualified. > > Hmm. A quick grep shows > > static struct ctl_table alignment_tbl[5] = { Very good catch! I missed this one because it defines the size of the ctl_table array and my spatch did not account for that case. It turns out that the number in the square brackets does not coincide with the number of elements in the array. I would expect this results in a failure in the sysctl_check_table function; I dont have a csky system to test though. In any case there is an easy untested fix: From 431abf6c9c11a8b7321842ed0747b3200d43ef34 Mon Sep 17 00:00:00 2001 From: Joel Granados <joel.granados@kernel.org> Date: Fri, 31 Jan 2025 14:10:57 +0100 Subject: [PATCH] csky: Remove the size from alignment_tbl declaration Having to synchronize the number of ctl_table array elements with the size in the declaration can lead to discrepancies between the two values. Since commit d7a76ec87195 ("sysctl: Remove check for sentinel element in ctl_table arrays"), the calculation of the ctl_table array size is done solely by the ARRAY_SIZE macro removing the need for the size in the declaration. Remove the size for the aligment_tbl declaration and const qualify the array for good measure. Signed-off-by: Joel Granados <joel.granados@kernel.org> --- arch/csky/abiv1/alignment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/csky/abiv1/alignment.c b/arch/csky/abiv1/alignment.c index e5b8b4b2109a..aee904833dec 100644 --- a/arch/csky/abiv1/alignment.c +++ b/arch/csky/abiv1/alignment.c @@ -300,7 +300,7 @@ void csky_alignment(struct pt_regs *regs) force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)addr); } -static struct ctl_table alignment_tbl[5] = { +static const struct ctl_table alignment_tbl[] = { { .procname = "kernel_enable", .data = &align_kern_enable,
On Fri, Jan 31, 2025 at 02:57:40PM +0100, Joel Granados wrote: > From 431abf6c9c11a8b7321842ed0747b3200d43ef34 Mon Sep 17 00:00:00 2001 > From: Joel Granados <joel.granados@kernel.org> > Date: Fri, 31 Jan 2025 14:10:57 +0100 > Subject: [PATCH] csky: Remove the size from alignment_tbl declaration > > Having to synchronize the number of ctl_table array elements with the > size in the declaration can lead to discrepancies between the two > values. Since commit d7a76ec87195 ("sysctl: Remove check for sentinel > element in ctl_table arrays"), the calculation of the ctl_table array > size is done solely by the ARRAY_SIZE macro removing the need for the > size in the declaration. > > Remove the size for the aligment_tbl declaration and const qualify the > array for good measure. > > Signed-off-by: Joel Granados <joel.granados@kernel.org> FWIW, this looks correct to me. Reviewed-by: Kees Cook <kees@kernel.org>