Skip to content

Commit 23b0f90

Browse files
committed
Merge tag 'sysctl-7.00-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl
Pull sysctl updates from Joel Granados: - Remove macros from proc handler converters Replace the proc converter macros with "regular" functions. Though it is more verbose than the macro version, it helps when debugging and better aligns with coding-style.rst. - General cleanup Remove superfluous ctl_table forward declarations. Const qualify the memory_allocation_profiling_sysctl and loadpin_sysctl_table arrays. Add missing kernel doc to proc_dointvec_conv. - Testing This series was run through sysctl selftests/kunit test suite in x86_64. And went into linux-next after rc4, giving it a good 3 weeks of testing * tag 'sysctl-7.00-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl: sysctl: replace SYSCTL_INT_CONV_CUSTOM macro with functions sysctl: Replace unidirectional INT converter macros with functions sysctl: Add kernel doc to proc_douintvec_conv sysctl: Replace UINT converter macros with functions sysctl: Add CONFIG_PROC_SYSCTL guards for converter macros sysctl: clarify proc_douintvec_minmax doc sysctl: Return -ENOSYS from proc_douintvec_conv when CONFIG_PROC_SYSCTL=n sysctl: Remove unused ctl_table forward declarations loadpin: Implement custom proc_handler for enforce alloc_tag: move memory_allocation_profiling_sysctls into .rodata sysctl: Add missing kernel-doc for proc_dointvec_conv
2 parents 7ad54bb + d174174 commit 23b0f90

11 files changed

Lines changed: 436 additions & 176 deletions

File tree

fs/pipe.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,10 +1481,24 @@ static struct file_system_type pipe_fs_type = {
14811481
};
14821482

14831483
#ifdef CONFIG_SYSCTL
1484-
static SYSCTL_USER_TO_KERN_UINT_CONV(_pipe_maxsz, round_pipe_size)
1485-
static SYSCTL_UINT_CONV_CUSTOM(_pipe_maxsz,
1486-
sysctl_user_to_kern_uint_conv_pipe_maxsz,
1487-
sysctl_kern_to_user_uint_conv, true)
1484+
1485+
static ulong round_pipe_size_ul(ulong size)
1486+
{
1487+
return round_pipe_size(size);
1488+
}
1489+
1490+
static int u2k_pipe_maxsz(const ulong *u_ptr, uint *k_ptr)
1491+
{
1492+
return proc_uint_u2k_conv_uop(u_ptr, k_ptr, round_pipe_size_ul);
1493+
}
1494+
1495+
static int do_proc_uint_conv_pipe_maxsz(ulong *u_ptr, uint *k_ptr,
1496+
int dir, const struct ctl_table *table)
1497+
{
1498+
return proc_uint_conv(u_ptr, k_ptr, dir, table, true,
1499+
u2k_pipe_maxsz,
1500+
proc_uint_k2u_conv);
1501+
}
14881502

14891503
static int proc_dopipe_max_size(const struct ctl_table *table, int write,
14901504
void *buffer, size_t *lenp, loff_t *ppos)

include/linux/fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,6 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
35253525
ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
35263526
size_t len, loff_t *ppos);
35273527

3528-
struct ctl_table;
35293528
int __init list_bdev_fs_names(char *buf, size_t size);
35303529

35313530
#define __FMODE_EXEC ((__force int) FMODE_EXEC)

include/linux/hugetlb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <linux/userfaultfd_k.h>
1717
#include <linux/nodemask.h>
1818

19-
struct ctl_table;
20-
struct user_struct;
2119
struct mmu_gather;
2220
struct node;
2321

include/linux/printk.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ extern void console_verbose(void);
7878
/* strlen("ratelimit") + 1 */
7979
#define DEVKMSG_STR_MAX_SIZE 10
8080
extern char devkmsg_log_str[DEVKMSG_STR_MAX_SIZE];
81-
struct ctl_table;
8281

8382
extern int suppress_printk;
8483

include/linux/sysctl.h

Lines changed: 17 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ extern const int sysctl_vals[];
5959
#define SYSCTL_LONG_ONE ((void *)&sysctl_long_vals[1])
6060
#define SYSCTL_LONG_MAX ((void *)&sysctl_long_vals[2])
6161

62-
#define SYSCTL_CONV_IDENTITY(val) (val)
6362
/**
6463
*
6564
* "dir" originates from read_iter (dir = 0) or write_iter (dir = 1)
@@ -73,107 +72,6 @@ extern const int sysctl_vals[];
7372
#define SYSCTL_USER_TO_KERN(dir) (!!(dir))
7473
#define SYSCTL_KERN_TO_USER(dir) (!dir)
7574

76-
#define SYSCTL_USER_TO_KERN_INT_CONV(name, u_ptr_op) \
77-
int sysctl_user_to_kern_int_conv##name(const bool *negp, \
78-
const unsigned long *u_ptr,\
79-
int *k_ptr) \
80-
{ \
81-
unsigned long u = u_ptr_op(*u_ptr); \
82-
if (*negp) { \
83-
if (u > (unsigned long) INT_MAX + 1) \
84-
return -EINVAL; \
85-
WRITE_ONCE(*k_ptr, -u); \
86-
} else { \
87-
if (u > (unsigned long) INT_MAX) \
88-
return -EINVAL; \
89-
WRITE_ONCE(*k_ptr, u); \
90-
} \
91-
return 0; \
92-
}
93-
94-
#define SYSCTL_KERN_TO_USER_INT_CONV(name, k_ptr_op) \
95-
int sysctl_kern_to_user_int_conv##name(bool *negp, \
96-
unsigned long *u_ptr, \
97-
const int *k_ptr) \
98-
{ \
99-
int val = READ_ONCE(*k_ptr); \
100-
if (val < 0) { \
101-
*negp = true; \
102-
*u_ptr = -k_ptr_op((unsigned long)val); \
103-
} else { \
104-
*negp = false; \
105-
*u_ptr = k_ptr_op((unsigned long)val); \
106-
} \
107-
return 0; \
108-
}
109-
110-
/**
111-
* To range check on a converted value, use a temp k_ptr
112-
* When checking range, value should be within (tbl->extra1, tbl->extra2)
113-
*/
114-
#define SYSCTL_INT_CONV_CUSTOM(name, user_to_kern, kern_to_user, \
115-
k_ptr_range_check) \
116-
int do_proc_int_conv##name(bool *negp, unsigned long *u_ptr, int *k_ptr,\
117-
int dir, const struct ctl_table *tbl) \
118-
{ \
119-
if (SYSCTL_KERN_TO_USER(dir)) \
120-
return kern_to_user(negp, u_ptr, k_ptr); \
121-
\
122-
if (k_ptr_range_check) { \
123-
int tmp_k, ret; \
124-
if (!tbl) \
125-
return -EINVAL; \
126-
ret = user_to_kern(negp, u_ptr, &tmp_k); \
127-
if (ret) \
128-
return ret; \
129-
if ((tbl->extra1 && *(int *)tbl->extra1 > tmp_k) || \
130-
(tbl->extra2 && *(int *)tbl->extra2 < tmp_k)) \
131-
return -EINVAL; \
132-
WRITE_ONCE(*k_ptr, tmp_k); \
133-
} else \
134-
return user_to_kern(negp, u_ptr, k_ptr); \
135-
return 0; \
136-
}
137-
138-
#define SYSCTL_USER_TO_KERN_UINT_CONV(name, u_ptr_op) \
139-
int sysctl_user_to_kern_uint_conv##name(const unsigned long *u_ptr,\
140-
unsigned int *k_ptr) \
141-
{ \
142-
unsigned long u = u_ptr_op(*u_ptr); \
143-
if (u > UINT_MAX) \
144-
return -EINVAL; \
145-
WRITE_ONCE(*k_ptr, u); \
146-
return 0; \
147-
}
148-
149-
#define SYSCTL_UINT_CONV_CUSTOM(name, user_to_kern, kern_to_user, \
150-
k_ptr_range_check) \
151-
int do_proc_uint_conv##name(unsigned long *u_ptr, unsigned int *k_ptr, \
152-
int dir, const struct ctl_table *tbl) \
153-
{ \
154-
if (SYSCTL_KERN_TO_USER(dir)) \
155-
return kern_to_user(u_ptr, k_ptr); \
156-
\
157-
if (k_ptr_range_check) { \
158-
unsigned int tmp_k; \
159-
int ret; \
160-
if (!tbl) \
161-
return -EINVAL; \
162-
ret = user_to_kern(u_ptr, &tmp_k); \
163-
if (ret) \
164-
return ret; \
165-
if ((tbl->extra1 && \
166-
*(unsigned int *)tbl->extra1 > tmp_k) || \
167-
(tbl->extra2 && \
168-
*(unsigned int *)tbl->extra2 < tmp_k)) \
169-
return -ERANGE; \
170-
WRITE_ONCE(*k_ptr, tmp_k); \
171-
} else \
172-
return user_to_kern(u_ptr, k_ptr); \
173-
return 0; \
174-
}
175-
176-
17775
extern const unsigned long sysctl_long_vals[];
17876

17977
typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
@@ -182,20 +80,37 @@ typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
18280
int proc_dostring(const struct ctl_table *, int, void *, size_t *, loff_t *);
18381
int proc_dobool(const struct ctl_table *table, int write, void *buffer,
18482
size_t *lenp, loff_t *ppos);
83+
18584
int proc_dointvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
18685
int proc_dointvec_minmax(const struct ctl_table *table, int dir, void *buffer,
18786
size_t *lenp, loff_t *ppos);
18887
int proc_dointvec_conv(const struct ctl_table *table, int dir, void *buffer,
18988
size_t *lenp, loff_t *ppos,
19089
int (*conv)(bool *negp, unsigned long *u_ptr, int *k_ptr,
19190
int dir, const struct ctl_table *table));
91+
int proc_int_k2u_conv_kop(ulong *u_ptr, const int *k_ptr, bool *negp,
92+
ulong (*k_ptr_op)(const ulong));
93+
int proc_int_u2k_conv_uop(const ulong *u_ptr, int *k_ptr, const bool *negp,
94+
ulong (*u_ptr_op)(const ulong));
95+
int proc_int_conv(bool *negp, ulong *u_ptr, int *k_ptr, int dir,
96+
const struct ctl_table *tbl, bool k_ptr_range_check,
97+
int (*user_to_kern)(const bool *negp, const ulong *u_ptr, int *k_ptr),
98+
int (*kern_to_user)(bool *negp, ulong *u_ptr, const int *k_ptr));
99+
192100
int proc_douintvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
193101
int proc_douintvec_minmax(const struct ctl_table *table, int write, void *buffer,
194102
size_t *lenp, loff_t *ppos);
195103
int proc_douintvec_conv(const struct ctl_table *table, int write, void *buffer,
196104
size_t *lenp, loff_t *ppos,
197105
int (*conv)(unsigned long *lvalp, unsigned int *valp,
198106
int write, const struct ctl_table *table));
107+
int proc_uint_k2u_conv(ulong *u_ptr, const uint *k_ptr);
108+
int proc_uint_u2k_conv_uop(const ulong *u_ptr, uint *k_ptr,
109+
ulong (*u_ptr_op)(const ulong));
110+
int proc_uint_conv(ulong *u_ptr, uint *k_ptr, int dir,
111+
const struct ctl_table *tbl, bool k_ptr_range_check,
112+
int (*user_to_kern)(const ulong *u_ptr, uint *k_ptr),
113+
int (*kern_to_user)(ulong *u_ptr, const uint *k_ptr));
199114

200115
int proc_dou8vec_minmax(const struct ctl_table *table, int write, void *buffer,
201116
size_t *lenp, loff_t *ppos);
@@ -206,7 +121,6 @@ int proc_doulongvec_minmax_conv(const struct ctl_table *table, int dir,
206121
int proc_do_large_bitmap(const struct ctl_table *, int, void *, size_t *, loff_t *);
207122
int proc_do_static_key(const struct ctl_table *table, int write, void *buffer,
208123
size_t *lenp, loff_t *ppos);
209-
int sysctl_kern_to_user_uint_conv(unsigned long *u_ptr, const unsigned int *k_ptr);
210124

211125
/*
212126
* Register a set of sysctl names by calling register_sysctl

include/net/ax25.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ typedef struct {
211211
unsigned short slave_timeout; /* when? */
212212
} ax25_dama_info;
213213

214-
struct ctl_table;
215-
216214
typedef struct ax25_dev {
217215
struct list_head list;
218216

kernel/printk/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*/
55
#include <linux/console.h>
66
#include <linux/types.h>
7+
#include <linux/sysctl.h>
78

89
#if defined(CONFIG_PRINTK) && defined(CONFIG_SYSCTL)
9-
struct ctl_table;
1010
void __init printk_sysctl_init(void);
1111
int devkmsg_sysctl_set_loglvl(const struct ctl_table *table, int write,
1212
void *buffer, size_t *lenp, loff_t *ppos);

kernel/printk/sysctl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* sysctl.c: General linux system control interface
44
*/
55

6-
#include <linux/sysctl.h>
76
#include <linux/printk.h>
87
#include <linux/capability.h>
98
#include <linux/ratelimit.h>

0 commit comments

Comments
 (0)