Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'sysctl-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl

Pull sysctl updates from Joel Granados:

- Remove sentinel elements from ctl_table structs in kernel/*

Removing sentinels in ctl_table arrays reduces the build time size
and runtime memory consumed by ~64 bytes per array. Removals for
net/, io_uring/, mm/, ipc/ and security/ are set to go into mainline
through their respective subsystems making the next release the most
likely place where the final series that removes the check for
proc_name == NULL will land.

This adds to removals already in arch/, drivers/ and fs/.

- Adjust ctl_table definitions and references to allow constification
- Remove unused ctl_table function arguments
- Move non-const elements from ctl_table to ctl_table_header
- Make ctl_table pointers const in ctl_table_root structure

Making the static ctl_table structs const will increase safety by
keeping the pointers to proc_handler functions in .rodata. Though no
ctl_tables where made const in this PR, the ground work for making
that possible has started with these changes sent by Thomas
Weißschuh.

* tag 'sysctl-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl:
sysctl: drop now unnecessary out-of-bounds check
sysctl: move sysctl type to ctl_table_header
sysctl: drop sysctl_is_perm_empty_ctl_table
sysctl: treewide: constify argument ctl_table_root::permissions(table)
sysctl: treewide: drop unused argument ctl_table_root::set_ownership(table)
bpf: Remove the now superfluous sentinel elements from ctl_table array
delayacct: Remove the now superfluous sentinel elements from ctl_table array
kprobes: Remove the now superfluous sentinel elements from ctl_table array
printk: Remove the now superfluous sentinel elements from ctl_table array
scheduler: Remove the now superfluous sentinel elements from ctl_table array
seccomp: Remove the now superfluous sentinel elements from ctl_table array
timekeeping: Remove the now superfluous sentinel elements from ctl_table array
ftrace: Remove the now superfluous sentinel elements from ctl_table array
umh: Remove the now superfluous sentinel elements from ctl_table array
kernel misc: Remove the now superfluous sentinel elements from ctl_table array

+28 -67
+9 -12
fs/proc/proc_sysctl.c
··· 30 30 static const struct inode_operations proc_sys_dir_operations; 31 31 32 32 /* Support for permanently empty directories */ 33 - static struct ctl_table sysctl_mount_point[] = { 34 - {.type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY } 35 - }; 33 + static struct ctl_table sysctl_mount_point[] = { }; 36 34 37 35 /** 38 36 * register_sysctl_mount_point() - registers a sysctl mount point ··· 46 48 } 47 49 EXPORT_SYMBOL(register_sysctl_mount_point); 48 50 49 - #define sysctl_is_perm_empty_ctl_table(tptr) \ 50 - (tptr[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) 51 51 #define sysctl_is_perm_empty_ctl_header(hptr) \ 52 - (sysctl_is_perm_empty_ctl_table(hptr->ctl_table)) 52 + (hptr->type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) 53 53 #define sysctl_set_perm_empty_ctl_header(hptr) \ 54 - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) 54 + (hptr->type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) 55 55 #define sysctl_clear_perm_empty_ctl_header(hptr) \ 56 - (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_DEFAULT) 56 + (hptr->type = SYSCTL_TABLE_TYPE_DEFAULT) 57 57 58 58 void proc_sys_poll_notify(struct ctl_table_poll *poll) 59 59 { ··· 206 210 node++; 207 211 } 208 212 } 213 + if (table == sysctl_mount_point) 214 + sysctl_set_perm_empty_ctl_header(head); 209 215 } 210 216 211 217 static void erase_header(struct ctl_table_header *head) ··· 230 232 return -EROFS; 231 233 232 234 /* Am I creating a permanently empty directory? */ 233 - if (header->ctl_table_size > 0 && 234 - sysctl_is_perm_empty_ctl_table(header->ctl_table)) { 235 + if (sysctl_is_perm_empty_ctl_header(header)) { 235 236 if (!RB_EMPTY_ROOT(&dir->root)) 236 237 return -EINVAL; 237 238 sysctl_set_perm_empty_ctl_header(dir_h); ··· 477 480 } 478 481 479 482 if (root->set_ownership) 480 - root->set_ownership(head, table, &inode->i_uid, &inode->i_gid); 483 + root->set_ownership(head, &inode->i_uid, &inode->i_gid); 481 484 else { 482 485 inode->i_uid = GLOBAL_ROOT_UID; 483 486 inode->i_gid = GLOBAL_ROOT_GID; ··· 1201 1204 struct ctl_table *entry, *link; 1202 1205 1203 1206 if (header->ctl_table_size == 0 || 1204 - sysctl_is_perm_empty_ctl_table(header->ctl_table)) 1207 + sysctl_is_perm_empty_ctl_header(header)) 1205 1208 return true; 1206 1209 1207 1210 /* Are there links available for every entry in table? */
+12 -13
include/linux/sysctl.h
··· 137 137 void *data; 138 138 int maxlen; 139 139 umode_t mode; 140 - /** 141 - * enum type - Enumeration to differentiate between ctl target types 142 - * @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations 143 - * @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently 144 - * empty directory target to serve 145 - * as mount point. 146 - */ 147 - enum { 148 - SYSCTL_TABLE_TYPE_DEFAULT, 149 - SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY 150 - } type; 151 140 proc_handler *proc_handler; /* Callback for text formatting */ 152 141 struct ctl_table_poll *poll; 153 142 void *extra1; ··· 177 188 struct ctl_dir *parent; 178 189 struct ctl_node *node; 179 190 struct hlist_head inodes; /* head for proc_inode->sysctl_inodes */ 191 + /** 192 + * enum type - Enumeration to differentiate between ctl target types 193 + * @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations 194 + * @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently 195 + * empty directory target to serve 196 + * as mount point. 197 + */ 198 + enum { 199 + SYSCTL_TABLE_TYPE_DEFAULT, 200 + SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY, 201 + } type; 180 202 }; 181 203 182 204 struct ctl_dir { ··· 205 205 struct ctl_table_set default_set; 206 206 struct ctl_table_set *(*lookup)(struct ctl_table_root *root); 207 207 void (*set_ownership)(struct ctl_table_header *head, 208 - struct ctl_table *table, 209 208 kuid_t *uid, kgid_t *gid); 210 - int (*permissions)(struct ctl_table_header *head, struct ctl_table *table); 209 + int (*permissions)(struct ctl_table_header *head, const struct ctl_table *table); 211 210 }; 212 211 213 212 #define register_sysctl(path, table) \
+2 -3
ipc/ipc_sysctl.c
··· 192 192 } 193 193 194 194 static void ipc_set_ownership(struct ctl_table_header *head, 195 - struct ctl_table *table, 196 195 kuid_t *uid, kgid_t *gid) 197 196 { 198 197 struct ipc_namespace *ns = ··· 204 205 *gid = gid_valid(ns_root_gid) ? ns_root_gid : GLOBAL_ROOT_GID; 205 206 } 206 207 207 - static int ipc_permissions(struct ctl_table_header *head, struct ctl_table *table) 208 + static int ipc_permissions(struct ctl_table_header *head, const struct ctl_table *table) 208 209 { 209 210 int mode = table->mode; 210 211 ··· 223 224 kuid_t ns_root_uid; 224 225 kgid_t ns_root_gid; 225 226 226 - ipc_set_ownership(head, table, &ns_root_uid, &ns_root_gid); 227 + ipc_set_ownership(head, &ns_root_uid, &ns_root_gid); 227 228 228 229 if (uid_eq(current_euid(), ns_root_uid)) 229 230 mode >>= 6;
+2 -3
ipc/mq_sysctl.c
··· 78 78 } 79 79 80 80 static void mq_set_ownership(struct ctl_table_header *head, 81 - struct ctl_table *table, 82 81 kuid_t *uid, kgid_t *gid) 83 82 { 84 83 struct ipc_namespace *ns = ··· 90 91 *gid = gid_valid(ns_root_gid) ? ns_root_gid : GLOBAL_ROOT_GID; 91 92 } 92 93 93 - static int mq_permissions(struct ctl_table_header *head, struct ctl_table *table) 94 + static int mq_permissions(struct ctl_table_header *head, const struct ctl_table *table) 94 95 { 95 96 int mode = table->mode; 96 97 kuid_t ns_root_uid; 97 98 kgid_t ns_root_gid; 98 99 99 - mq_set_ownership(head, table, &ns_root_uid, &ns_root_gid); 100 + mq_set_ownership(head, &ns_root_uid, &ns_root_gid); 100 101 101 102 if (uid_eq(current_euid(), ns_root_uid)) 102 103 mode >>= 6;
-1
kernel/acct.c
··· 84 84 .mode = 0644, 85 85 .proc_handler = proc_dointvec, 86 86 }, 87 - { } 88 87 }; 89 88 90 89 static __init int kernel_acct_sysctls_init(void)
-1
kernel/bpf/syscall.c
··· 6035 6035 .mode = 0644, 6036 6036 .proc_handler = bpf_stats_handler, 6037 6037 }, 6038 - { } 6039 6038 }; 6040 6039 6041 6040 static int __init bpf_syscall_sysctl_init(void)
-1
kernel/delayacct.c
··· 74 74 .extra1 = SYSCTL_ZERO, 75 75 .extra2 = SYSCTL_ONE, 76 76 }, 77 - { } 78 77 }; 79 78 80 79 static __init int kernel_delayacct_sysctls_init(void)
-1
kernel/exit.c
··· 94 94 .mode = 0644, 95 95 .proc_handler = proc_douintvec, 96 96 }, 97 - { } 98 97 }; 99 98 100 99 static __init int kernel_exit_sysctls_init(void)
-1
kernel/hung_task.c
··· 314 314 .proc_handler = proc_dointvec_minmax, 315 315 .extra1 = SYSCTL_NEG_ONE, 316 316 }, 317 - {} 318 317 }; 319 318 320 319 static void __init hung_task_sysctl_init(void)
-1
kernel/kexec_core.c
··· 948 948 .mode = 0644, 949 949 .proc_handler = kexec_limit_handler, 950 950 }, 951 - { } 952 951 }; 953 952 954 953 static int __init kexec_core_sysctl_init(void)
-1
kernel/kprobes.c
··· 968 968 .extra1 = SYSCTL_ZERO, 969 969 .extra2 = SYSCTL_ONE, 970 970 }, 971 - {} 972 971 }; 973 972 974 973 static void __init kprobe_sysctls_init(void)
-1
kernel/latencytop.c
··· 85 85 .mode = 0644, 86 86 .proc_handler = sysctl_latencytop, 87 87 }, 88 - {} 89 88 }; 90 89 #endif 91 90
-1
kernel/panic.c
··· 100 100 .mode = 0644, 101 101 .proc_handler = proc_douintvec, 102 102 }, 103 - { } 104 103 }; 105 104 106 105 static __init int kernel_panic_sysctls_init(void)
-1
kernel/pid_namespace.c
··· 307 307 .extra1 = SYSCTL_ZERO, 308 308 .extra2 = &pid_max, 309 309 }, 310 - { } 311 310 }; 312 311 #endif /* CONFIG_CHECKPOINT_RESTORE */ 313 312
-1
kernel/pid_sysctl.h
··· 41 41 .extra1 = SYSCTL_ZERO, 42 42 .extra2 = SYSCTL_TWO, 43 43 }, 44 - { } 45 44 }; 46 45 static inline void register_pid_ns_sysctl_table_vm(void) 47 46 {
-1
kernel/printk/sysctl.c
··· 76 76 .extra1 = SYSCTL_ZERO, 77 77 .extra2 = SYSCTL_TWO, 78 78 }, 79 - {} 80 79 }; 81 80 82 81 void __init printk_sysctl_init(void)
-1
kernel/reboot.c
··· 1295 1295 .mode = 0644, 1296 1296 .proc_handler = proc_dointvec, 1297 1297 }, 1298 - { } 1299 1298 }; 1300 1299 1301 1300 static void __init kernel_reboot_sysctls_init(void)
-1
kernel/sched/autogroup.c
··· 19 19 .extra1 = SYSCTL_ZERO, 20 20 .extra2 = SYSCTL_ONE, 21 21 }, 22 - {} 23 22 }; 24 23 25 24 static void __init sched_autogroup_sysctl_init(void)
-1
kernel/sched/core.c
··· 4741 4741 .extra2 = SYSCTL_FOUR, 4742 4742 }, 4743 4743 #endif /* CONFIG_NUMA_BALANCING */ 4744 - {} 4745 4744 }; 4746 4745 static int __init sched_core_sysctl_init(void) 4747 4746 {
-1
kernel/sched/deadline.c
··· 43 43 .proc_handler = proc_douintvec_minmax, 44 44 .extra2 = (void *)&sysctl_sched_dl_period_max, 45 45 }, 46 - {} 47 46 }; 48 47 49 48 static int __init sched_dl_sysctl_init(void)
-1
kernel/sched/fair.c
··· 151 151 .extra1 = SYSCTL_ZERO, 152 152 }, 153 153 #endif /* CONFIG_NUMA_BALANCING */ 154 - {} 155 154 }; 156 155 157 156 static int __init sched_fair_sysctl_init(void)
-1
kernel/sched/rt.c
··· 56 56 .mode = 0644, 57 57 .proc_handler = sched_rr_handler, 58 58 }, 59 - {} 60 59 }; 61 60 62 61 static int __init sched_rt_sysctl_init(void)
-1
kernel/sched/topology.c
··· 322 322 .extra1 = SYSCTL_ZERO, 323 323 .extra2 = SYSCTL_ONE, 324 324 }, 325 - {} 326 325 }; 327 326 328 327 static int __init sched_energy_aware_sysctl_init(void)
-1
kernel/seccomp.c
··· 2445 2445 .mode = 0644, 2446 2446 .proc_handler = seccomp_actions_logged_handler, 2447 2447 }, 2448 - { } 2449 2448 }; 2450 2449 2451 2450 static int __init seccomp_sysctl_init(void)
-1
kernel/signal.c
··· 4840 4840 .proc_handler = proc_dointvec 4841 4841 }, 4842 4842 #endif 4843 - { } 4844 4843 }; 4845 4844 4846 4845 static int __init init_signal_sysctls(void)
-1
kernel/stackleak.c
··· 54 54 .extra1 = SYSCTL_ZERO, 55 55 .extra2 = SYSCTL_ONE, 56 56 }, 57 - {} 58 57 }; 59 58 60 59 static int __init stackleak_sysctls_init(void)
-2
kernel/sysctl.c
··· 2034 2034 .extra2 = SYSCTL_INT_MAX, 2035 2035 }, 2036 2036 #endif 2037 - { } 2038 2037 }; 2039 2038 2040 2039 static struct ctl_table vm_table[] = { ··· 2239 2240 .extra2 = (void *)&mmap_rnd_compat_bits_max, 2240 2241 }, 2241 2242 #endif 2242 - { } 2243 2243 }; 2244 2244 2245 2245 int __init sysctl_init_bases(void)
-1
kernel/time/timer.c
··· 312 312 .extra1 = SYSCTL_ZERO, 313 313 .extra2 = SYSCTL_ONE, 314 314 }, 315 - {} 316 315 }; 317 316 318 317 static int __init timer_sysctl_init(void)
-1
kernel/trace/ftrace.c
··· 8269 8269 .mode = 0644, 8270 8270 .proc_handler = ftrace_enable_sysctl, 8271 8271 }, 8272 - {} 8273 8272 }; 8274 8273 8275 8274 static int __init ftrace_sysctl_init(void)
-1
kernel/trace/trace_events_user.c
··· 2833 2833 .mode = 0644, 2834 2834 .proc_handler = set_max_user_events_sysctl, 2835 2835 }, 2836 - {} 2837 2836 }; 2838 2837 2839 2838 static int __init trace_events_user_init(void)
+2 -3
kernel/ucount.c
··· 38 38 } 39 39 40 40 static int set_permissions(struct ctl_table_header *head, 41 - struct ctl_table *table) 41 + const struct ctl_table *table) 42 42 { 43 43 struct user_namespace *user_ns = 44 44 container_of(head->set, struct user_namespace, set); ··· 87 87 UCOUNT_ENTRY("max_fanotify_groups"), 88 88 UCOUNT_ENTRY("max_fanotify_marks"), 89 89 #endif 90 - { } 91 90 }; 92 91 #endif /* CONFIG_SYSCTL */ 93 92 ··· 95 96 #ifdef CONFIG_SYSCTL 96 97 struct ctl_table *tbl; 97 98 98 - BUILD_BUG_ON(ARRAY_SIZE(user_table) != UCOUNT_COUNTS + 1); 99 + BUILD_BUG_ON(ARRAY_SIZE(user_table) != UCOUNT_COUNTS); 99 100 setup_sysctl_set(&ns->set, &set_root, set_is_seen); 100 101 tbl = kmemdup(user_table, sizeof(user_table), GFP_KERNEL); 101 102 if (tbl) {
-1
kernel/umh.c
··· 560 560 .mode = 0600, 561 561 .proc_handler = proc_cap_handler, 562 562 }, 563 - { } 564 563 }; 565 564 566 565 static int __init init_umh_sysctls(void)
-1
kernel/utsname_sysctl.c
··· 120 120 .proc_handler = proc_do_uts_string, 121 121 .poll = &domainname_poll, 122 122 }, 123 - {} 124 123 }; 125 124 126 125 #ifdef CONFIG_PROC_SYSCTL
-2
kernel/watchdog.c
··· 1155 1155 }, 1156 1156 #endif /* CONFIG_SMP */ 1157 1157 #endif 1158 - {} 1159 1158 }; 1160 1159 1161 1160 static struct ctl_table watchdog_hardlockup_sysctl[] = { ··· 1167 1168 .extra1 = SYSCTL_ZERO, 1168 1169 .extra2 = SYSCTL_ONE, 1169 1170 }, 1170 - {} 1171 1171 }; 1172 1172 1173 1173 static void __init watchdog_sysctl_init(void)
+1 -2
net/sysctl_net.c
··· 40 40 41 41 /* Return standard mode bits for table entry. */ 42 42 static int net_ctl_permissions(struct ctl_table_header *head, 43 - struct ctl_table *table) 43 + const struct ctl_table *table) 44 44 { 45 45 struct net *net = container_of(head->set, struct net, sysctls); 46 46 ··· 54 54 } 55 55 56 56 static void net_ctl_set_ownership(struct ctl_table_header *head, 57 - struct ctl_table *table, 58 57 kuid_t *uid, kgid_t *gid) 59 58 { 60 59 struct net *net = container_of(head->set, struct net, sysctls);