Re: [PATCH] pstore: ram_core: fix possible overflow in persistent_ram_init_ecc()

2023-12-03 Thread Sergey Shtylyov
On 12/2/23 11:47 PM, Kees Cook wrote: [...] >> In persistent_ram_init_ecc(), on 64-bit arches DIV_ROUND_UP() will return >> 64-bit value since persistent_ram_zone::buffer_size has type size_t which >> is derived from the 64-bit *unsigned long*, while the ecc_blocks variable >> this value gets assig

Re: [PATCH RFC 0/7] sysctl: constify sysctl ctl_tables

2023-12-03 Thread Thomas Weißschuh
Hi Joel, On 2023-12-01 17:31:20+0100, Joel Granados wrote: > Hey Thomas. > > Thx for the clarifications. I did more of a deep dive into your set and > have additional comments (in line). I think const-ing all this is a good > approach. The way forward is to be able to see the entire patch set of

[PATCH] md/md-multipath: Convert "struct mpconf" to flexible array

2023-12-03 Thread Christophe JAILLET
The 'multipaths' field of 'struct mpconf' can be declared as a flexible array. The advantages are: - 1 less indirection when accessing to the 'multipaths' array - save 1 pointer in the structure - improve memory usage - give the opportunity to use __counted_by() for additional safety

[PATCH v2 03/18] sysctl: drop sysctl_is_perm_empty_ctl_table

2023-12-03 Thread Thomas Weißschuh
It is used only once and that caller would be simpler with sysctl_is_perm_empty_ctl_header(). So use this sibling function. Signed-off-by: Thomas Weißschuh --- fs/proc/proc_sysctl.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sys

[PATCH v2 01/18] watchdog/core: remove sysctl handlers from public header

2023-12-03 Thread Thomas Weißschuh
The functions are only used in the file where they are defined. Remove them from the header and make them static. Signed-off-by: Thomas Weißschuh --- include/linux/nmi.h | 7 --- kernel/watchdog.c | 10 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/include/lin

[PATCH v2 02/18] sysctl: delete unused define SYSCTL_PERM_EMPTY_DIR

2023-12-03 Thread Thomas Weißschuh
It seems it was never used. Signed-off-by: Thomas Weißschuh --- include/linux/sysctl.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 61b40ea81f4d..26a38161c28f 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -255,8

[PATCH v2 04/18] cgroup: bpf: constify ctl_table arguments and fields

2023-12-03 Thread Thomas Weißschuh
In a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that adapt the cgroup-bpf code. Signed-off-by: Thomas Weißschuh --- include/linux/bpf-cgroup.h | 2 +- include/linux/filter.h | 2 +- kernel/bpf/cgroup.c| 2 +- 3 files changed, 3 insertio

[PATCH v2 00/18] sysctl: constify sysctl ctl_tables

2023-12-03 Thread Thomas Weißschuh
Problem description: The kernel contains a lot of struct ctl_table throught the tree. These are very often 'static' definitions. It would be good to make the tables unmodifiable by marking them "const" to avoid accidental or malicious modifications. This is in line with a general effort to move as

[PATCH v2 07/18] utsname: constify ctl_table arguments of utility function

2023-12-03 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to "const struct ctl_table". As a preparation for that adapt the internal helper. Signed-off-by: Thomas Weißschuh --- kernel/utsname_sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/utsname_sysctl.c b/

[PATCH v2 06/18] hugetlb: constify ctl_table arguments of utility functions

2023-12-03 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to "const struct ctl_table". As a preparation for that adapt the internal helpers. Signed-off-by: Thomas Weißschuh --- mm/hugetlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c inde

[PATCH v2 10/18] sysctl: treewide: constify ctl_table_root::permissions

2023-12-03 Thread Thomas Weißschuh
In a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that adapt the permission callbacks. Signed-off-by: Thomas Weißschuh --- include/linux/sysctl.h | 2 +- ipc/ipc_sysctl.c | 2 +- kernel/ucount.c| 2 +- net/sysctl_net.c | 2 +- 4 f

[PATCH v2 05/18] seccomp: constify ctl_table arguments of utility functions

2023-12-03 Thread Thomas Weißschuh
In a future commit the proc_handlers themselves will change to "const struct ctl_table". As a preparation for that adapt the internal helpers. Signed-off-by: Thomas Weißschuh --- kernel/seccomp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/seccomp.c b/kernel/se

[PATCH v2 09/18] sysctl: treewide: constify ctl_table_root::set_ownership

2023-12-03 Thread Thomas Weißschuh
In a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that adapt the set_ownership callbacks. Signed-off-by: Thomas Weißschuh --- include/linux/sysctl.h | 2 +- net/sysctl_net.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a

[PATCH v2 18/18] sysctl: constify standard sysctl tables

2023-12-03 Thread Thomas Weißschuh
Recent changes in the sysctl allow sysctl tables to be put into .rodata. Signed-off-by: Thomas Weißschuh --- kernel/sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d60daa4e36fc..e48a60887c7e 100644 --- a/kernel/sysctl.c +++ b/k

[PATCH v2 08/18] stackleak: don't modify ctl_table argument

2023-12-03 Thread Thomas Weißschuh
In a future commit the proc_handlers will change to "const struct ctl_table". As a preparation for that adapt the logic to work with a temporary variable, similar to how it is done in other parts of the kernel. Signed-off-by: Thomas Weißschuh --- kernel/stackleak.c | 7 --- 1 file changed, 4

[PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header

2023-12-03 Thread Thomas Weißschuh
In a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that move this mutable field from "struct ctl_table" to "struct ctl_table_header". This is also more correct in general as this is in fact a property of the header and not the table itself. Signed-off-

[PATCH v2 11/18] sysctl: treewide: constify ctl_table_header::ctl_table_arg

2023-12-03 Thread Thomas Weißschuh
In a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that adapt the ctl_table_arg member. Signed-off-by: Thomas Weißschuh --- drivers/net/vrf.c | 2 +- include/linux/sysctl.h | 2 +- ipc/ipc_sysctl.c

[PATCH v2 16/18] const_structs.checkpatch: add ctl_table

2023-12-03 Thread Thomas Weißschuh
Now that the sysctl core can handle "const struct ctl_table", make sure that new usages of the struct already enter the tree as const. Signed-off-by: Thomas Weißschuh --- scripts/const_structs.checkpatch | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/const_structs.checkpatch b/scrip

[PATCH v2 15/18] sysctl: allow registration of const struct ctl_table

2023-12-03 Thread Thomas Weißschuh
This allows sysctl table to be put into read-only data. Signed-off-by: Thomas Weißschuh --- fs/proc/proc_sysctl.c | 6 +++--- include/linux/sysctl.h | 10 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index e7fd1680d479.

[PATCH v2 14/18] sysctl: move internal interfaces to const struct ctl_table

2023-12-03 Thread Thomas Weißschuh
As a preparation to make all the sysctl code work with const struct ctl_table switch over the internal function to use the const variant. Signed-off-by: Thomas Weißschuh --- fs/proc/internal.h | 2 +- fs/proc/proc_sysctl.c | 81 +- include/li

[PATCH v2 17/18] sysctl: make ctl_table sysctl_mount_point const

2023-12-03 Thread Thomas Weißschuh
This is a first example on how to use const struct ctl_table. Signed-off-by: Thomas Weißschuh --- fs/proc/proc_sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index d09107a5b43f..f2b663e0be33 100644 --- a/fs/proc/proc_sys

[PATCH v2 12/18] sysctl: treewide: constify the ctl_table argument of handlers

2023-12-03 Thread Thomas Weißschuh
In a future commit the sysctl core will only use "const struct ctl_table". As a preparation for that adapt all the proc handlers. Signed-off-by: Thomas Weißschuh --- arch/arm64/kernel/armv8_deprecated.c | 2 +- arch/arm64/kernel/fpsimd.c| 2 +- arch/s390/appldata/appldata_