Skip to content

Commit

Permalink
Merge tag 'sysctl-6.15-rc1' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/sysctl/sysctl

Pull sysctl updates from Joel Granados:

 - Move vm_table members out of kernel/sysctl.c

   All vm_table array members have moved to their respective subsystems
   leading to the removal of vm_table from kernel/sysctl.c. This
   increases modularity by placing the ctl_tables closer to where they
   are actually used and at the same time reducing the chances of merge
   conflicts in kernel/sysctl.c.

 - ctl_table range fixes

   Replace the proc_handler function that checks variable ranges in
   coredump_sysctls and vdso_table with the one that actually uses the
   extra{1,2} pointers as min/max values. This tightens the range of the
   values that users can pass into the kernel effectively preventing
   {under,over}flows.

 - Misc fixes

   Correct grammar errors and typos in test messages. Update sysctl
   files in MAINTAINERS. Constified and removed array size in
   declaration for alignment_tbl

* tag 'sysctl-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl: (22 commits)
  selftests/sysctl: fix wording of help messages
  selftests: fix spelling/grammar errors in sysctl/sysctl.sh
  MAINTAINERS: Update sysctl file list in MAINTAINERS
  sysctl: Fix underflow value setting risk in vm_table
  coredump: Fixes core_pipe_limit sysctl proc_handler
  sysctl: remove unneeded include
  sysctl: remove the vm_table
  sh: vdso: move the sysctl to arch/sh/kernel/vsyscall/vsyscall.c
  x86: vdso: move the sysctl to arch/x86/entry/vdso/vdso32-setup.c
  fs: dcache: move the sysctl to fs/dcache.c
  sunrpc: simplify rpcauth_cache_shrink_count()
  fs: drop_caches: move sysctl to fs/drop_caches.c
  fs: fs-writeback: move sysctl to fs/fs-writeback.c
  mm: nommu: move sysctl to mm/nommu.c
  security: min_addr: move sysctl to security/min_addr.c
  mm: mmap: move sysctl to mm/mmap.c
  mm: util: move sysctls to mm/util.c
  mm: vmscan: move vmscan sysctls to mm/vmscan.c
  mm: swap: move sysctl to mm/swap.c
  mm: filemap: move sysctl to mm/filemap.c
  ...
  • Loading branch information
Linus Torvalds committed Mar 27, 2025
2 parents 336b4da + 29fa7d7 commit 592329e
Show file tree
Hide file tree
Showing 27 changed files with 350 additions and 322 deletions.
7 changes: 4 additions & 3 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -19081,9 +19081,10 @@ S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl.git sysctl-next
F: fs/proc/proc_sysctl.c
F: include/linux/sysctl.h
F: kernel/sysctl-test.c
F: kernel/sysctl.c
F: tools/testing/selftests/sysctl/
F: kernel/sysctl*
F: tools/testing/selftests/sysctl/*
F: lib/test_sysctl.c
F: scripts/check-sysctl-docs

PS3 NETWORK SUPPORT
M: Geoff Levand <geoff@infradead.org>
Expand Down
2 changes: 1 addition & 1 deletion arch/csky/abiv1/alignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions arch/sh/kernel/vsyscall/vsyscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/elf.h>
#include <linux/sched.h>
#include <linux/sysctl.h>
#include <linux/err.h>

/*
Expand All @@ -30,6 +31,18 @@ static int __init vdso_setup(char *s)
}
__setup("vdso=", vdso_setup);

static const struct ctl_table vdso_table[] = {
{
.procname = "vdso_enabled",
.data = &vdso_enabled,
.maxlen = sizeof(vdso_enabled),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
};

/*
* These symbols are defined by vsyscall.o to mark the bounds
* of the ELF DSO images included therein.
Expand Down Expand Up @@ -58,6 +71,14 @@ int __init vsyscall_init(void)
return 0;
}

static int __init vm_sysctl_init(void)
{
register_sysctl_init("vm", vdso_table);
return 0;
}

fs_initcall(vm_sysctl_init);

/* Setup a VMA at program startup for the vsyscall page */
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
{
Expand Down
16 changes: 11 additions & 5 deletions arch/x86/entry/vdso/vdso32-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ __setup("vdso32=", vdso32_setup);
__setup_param("vdso=", vdso_setup, vdso32_setup, 0);
#endif

#ifdef CONFIG_X86_64

#ifdef CONFIG_SYSCTL
/* Register vsyscall32 into the ABI table */
#include <linux/sysctl.h>

static const struct ctl_table abi_table2[] = {
static const struct ctl_table vdso_table[] = {
{
#ifdef CONFIG_X86_64
.procname = "vsyscall32",
#else
.procname = "vdso_enabled",
#endif
.data = &vdso32_enabled,
.maxlen = sizeof(int),
.mode = 0644,
Expand All @@ -71,10 +73,14 @@ static const struct ctl_table abi_table2[] = {

static __init int ia32_binfmt_init(void)
{
register_sysctl("abi", abi_table2);
#ifdef CONFIG_X86_64
/* Register vsyscall32 into the ABI table */
register_sysctl("abi", vdso_table);
#else
register_sysctl_init("vm", vdso_table);
#endif
return 0;
}
__initcall(ia32_binfmt_init);
#endif /* CONFIG_SYSCTL */

#endif /* CONFIG_X86_64 */
4 changes: 3 additions & 1 deletion fs/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,9 @@ static const struct ctl_table coredump_sysctls[] = {
.data = &core_pipe_limit,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_INT_MAX,
},
{
.procname = "core_file_note_size_limit",
Expand Down
21 changes: 19 additions & 2 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@
* If no ancestor relationship:
* arbitrary, since it's serialized on rename_lock
*/
int sysctl_vfs_cache_pressure __read_mostly = 100;
EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
static int sysctl_vfs_cache_pressure __read_mostly = 100;

unsigned long vfs_pressure_ratio(unsigned long val)
{
return mult_frac(val, sysctl_vfs_cache_pressure, 100);
}
EXPORT_SYMBOL_GPL(vfs_pressure_ratio);

__cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);

Expand Down Expand Up @@ -211,8 +216,20 @@ static const struct ctl_table fs_dcache_sysctls[] = {
},
};

static const struct ctl_table vm_dcache_sysctls[] = {
{
.procname = "vfs_cache_pressure",
.data = &sysctl_vfs_cache_pressure,
.maxlen = sizeof(sysctl_vfs_cache_pressure),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
},
};

static int __init init_fs_dcache_sysctls(void)
{
register_sysctl_init("vm", vm_dcache_sysctls);
register_sysctl_init("fs", fs_dcache_sysctls);
return 0;
}
Expand Down
23 changes: 21 additions & 2 deletions fs/drop_caches.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "internal.h"

/* A global variable is a bit ugly, but it keeps the code simple */
int sysctl_drop_caches;
static int sysctl_drop_caches;

static void drop_pagecache_sb(struct super_block *sb, void *unused)
{
Expand Down Expand Up @@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
iput(toput_inode);
}

int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
static int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos)
{
int ret;
Expand Down Expand Up @@ -77,3 +77,22 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
}
return 0;
}

static const struct ctl_table drop_caches_table[] = {
{
.procname = "drop_caches",
.data = &sysctl_drop_caches,
.maxlen = sizeof(int),
.mode = 0200,
.proc_handler = drop_caches_sysctl_handler,
.extra1 = SYSCTL_ONE,
.extra2 = SYSCTL_FOUR,
},
};

static int __init init_vm_drop_caches_sysctls(void)
{
register_sysctl_init("vm", drop_caches_table);
return 0;
}
fs_initcall(init_vm_drop_caches_sysctls);
30 changes: 21 additions & 9 deletions fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct wb_writeback_work {
* timestamps written to disk after 12 hours, but in the worst case a
* few inodes might not their timestamps updated for 24 hours.
*/
unsigned int dirtytime_expire_interval = 12 * 60 * 60;
static unsigned int dirtytime_expire_interval = 12 * 60 * 60;

static inline struct inode *wb_inode(struct list_head *head)
{
Expand Down Expand Up @@ -2435,14 +2435,7 @@ static void wakeup_dirtytime_writeback(struct work_struct *w)
schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ);
}

static int __init start_dirtytime_writeback(void)
{
schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ);
return 0;
}
__initcall(start_dirtytime_writeback);

int dirtytime_interval_handler(const struct ctl_table *table, int write,
static int dirtytime_interval_handler(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int ret;
Expand All @@ -2453,6 +2446,25 @@ int dirtytime_interval_handler(const struct ctl_table *table, int write,
return ret;
}

static const struct ctl_table vm_fs_writeback_table[] = {
{
.procname = "dirtytime_expire_seconds",
.data = &dirtytime_expire_interval,
.maxlen = sizeof(dirtytime_expire_interval),
.mode = 0644,
.proc_handler = dirtytime_interval_handler,
.extra1 = SYSCTL_ZERO,
},
};

static int __init start_dirtytime_writeback(void)
{
schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ);
register_sysctl_init("vm", vm_fs_writeback_table);
return 0;
}
__initcall(start_dirtytime_writeback);

/**
* __mark_inode_dirty - internal function to mark an inode dirty
*
Expand Down
7 changes: 1 addition & 6 deletions include/linux/dcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,7 @@ static inline int simple_positive(const struct dentry *dentry)
return d_really_is_positive(dentry) && !d_unhashed(dentry);
}

extern int sysctl_vfs_cache_pressure;

static inline unsigned long vfs_pressure_ratio(unsigned long val)
{
return mult_frac(val, sysctl_vfs_cache_pressure, 100);
}
unsigned long vfs_pressure_ratio(unsigned long val);

/**
* d_inode - Get the actual inode of this dentry
Expand Down
23 changes: 0 additions & 23 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ struct user_struct;
struct pt_regs;
struct folio_batch;

extern int sysctl_page_lock_unfairness;

void mm_core_init(void);
void init_mm_internals(void);

Expand Down Expand Up @@ -78,8 +76,6 @@ static inline void totalram_pages_add(long count)
}

extern void * high_memory;
extern int page_cluster;
extern const int page_cluster_max;

#ifdef CONFIG_SYSCTL
extern int sysctl_legacy_va_layout;
Expand Down Expand Up @@ -209,17 +205,6 @@ extern int sysctl_max_map_count;
extern unsigned long sysctl_user_reserve_kbytes;
extern unsigned long sysctl_admin_reserve_kbytes;

extern int sysctl_overcommit_memory;
extern int sysctl_overcommit_ratio;
extern unsigned long sysctl_overcommit_kbytes;

int overcommit_ratio_handler(const struct ctl_table *, int, void *, size_t *,
loff_t *);
int overcommit_kbytes_handler(const struct ctl_table *, int, void *, size_t *,
loff_t *);
int overcommit_policy_handler(const struct ctl_table *, int, void *, size_t *,
loff_t *);

#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
#define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio))
Expand Down Expand Up @@ -3809,12 +3794,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr)

extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm);

#ifdef CONFIG_SYSCTL
extern int sysctl_drop_caches;
int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *,
loff_t *);
#endif

void drop_slab(void);

#ifndef CONFIG_MMU
Expand Down Expand Up @@ -4086,8 +4065,6 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping,
pgoff_t first_index, pgoff_t nr);
#endif

extern int sysctl_nr_trim_pages;

#ifdef CONFIG_ANON_VMA_NAME
int madvise_set_anon_name(struct mm_struct *mm, unsigned long start,
unsigned long len_in,
Expand Down
2 changes: 0 additions & 2 deletions include/linux/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
| MAP_HUGE_1GB)

extern int sysctl_overcommit_memory;
extern int sysctl_overcommit_ratio;
extern unsigned long sysctl_overcommit_kbytes;
extern struct percpu_counter vm_committed_as;

#ifdef CONFIG_SMP
Expand Down
9 changes: 0 additions & 9 deletions include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,19 +433,10 @@ extern int vm_swappiness;
long remove_mapping(struct address_space *mapping, struct folio *folio);

#ifdef CONFIG_NUMA
extern int node_reclaim_mode;
extern int sysctl_min_unmapped_ratio;
extern int sysctl_min_slab_ratio;
#else
#define node_reclaim_mode 0
#endif

static inline bool node_reclaim_enabled(void)
{
/* Is any node_reclaim_mode bit set? */
return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP);
}

void check_move_unevictable_folios(struct folio_batch *fbatch);

extern void __meminit kswapd_run(int nid);
Expand Down
11 changes: 0 additions & 11 deletions include/linux/vmstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@
#include <linux/static_key.h>
#include <linux/mmdebug.h>

extern int sysctl_stat_interval;

#ifdef CONFIG_NUMA
#define ENABLE_NUMA_STAT 1
#define DISABLE_NUMA_STAT 0
extern int sysctl_vm_numa_stat;
DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);
int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos);
#endif

struct reclaim_stat {
Expand Down Expand Up @@ -304,10 +297,6 @@ void quiet_vmstat(void);
void cpu_vm_stats_fold(int cpu);
void refresh_zone_stat_thresholds(void);

struct ctl_table;
int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp,
loff_t *ppos);

void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *);

int calculate_pressure_threshold(struct zone *zone);
Expand Down
4 changes: 0 additions & 4 deletions include/linux/writeback.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,8 @@ extern struct wb_domain global_wb_domain;
/* These are exported to sysctl. */
extern unsigned int dirty_writeback_interval;
extern unsigned int dirty_expire_interval;
extern unsigned int dirtytime_expire_interval;
extern int laptop_mode;

int dirtytime_interval_handler(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);

void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh);
unsigned long cgwb_calc_thresh(struct bdi_writeback *wb);
Expand Down
Loading

0 comments on commit 592329e

Please sign in to comment.