Commit b9a8a0bd authored by Linus Torvalds's avatar Linus Torvalds

Annotate sysct with user pointer annotations

parent 75b08514
...@@ -679,8 +679,8 @@ extern void sysctl_init(void); ...@@ -679,8 +679,8 @@ extern void sysctl_init(void);
typedef struct ctl_table ctl_table; typedef struct ctl_table ctl_table;
typedef int ctl_handler (ctl_table *table, int *name, int nlen, typedef int ctl_handler (ctl_table *table, int *name, int nlen,
void *oldval, size_t *oldlenp, void __user *oldval, size_t __user *oldlenp,
void *newval, size_t newlen, void __user *newval, size_t newlen,
void **context); void **context);
typedef int proc_handler (ctl_table *ctl, int write, struct file * filp, typedef int proc_handler (ctl_table *ctl, int write, struct file * filp,
...@@ -707,8 +707,8 @@ extern int do_sysctl (int *name, int nlen, ...@@ -707,8 +707,8 @@ extern int do_sysctl (int *name, int nlen,
extern int do_sysctl_strategy (ctl_table *table, extern int do_sysctl_strategy (ctl_table *table,
int *name, int nlen, int *name, int nlen,
void *oldval, size_t *oldlenp, void __user *oldval, size_t __user *oldlenp,
void *newval, size_t newlen, void ** context); void __user *newval, size_t newlen, void ** context);
extern ctl_handler sysctl_string; extern ctl_handler sysctl_string;
extern ctl_handler sysctl_intvec; extern ctl_handler sysctl_intvec;
......
...@@ -403,7 +403,7 @@ int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp, ...@@ -403,7 +403,7 @@ int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
return -ENOTDIR; return -ENOTDIR;
} }
extern asmlinkage long sys_sysctl(struct __sysctl_args *args) asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
{ {
struct __sysctl_args tmp; struct __sysctl_args tmp;
int error; int error;
...@@ -444,8 +444,8 @@ static inline int ctl_perm(ctl_table *table, int op) ...@@ -444,8 +444,8 @@ static inline int ctl_perm(ctl_table *table, int op)
} }
static int parse_table(int *name, int nlen, static int parse_table(int *name, int nlen,
void *oldval, size_t *oldlenp, void __user *oldval, size_t __user *oldlenp,
void *newval, size_t newlen, void __user *newval, size_t newlen,
ctl_table *table, void **context) ctl_table *table, void **context)
{ {
int n; int n;
...@@ -485,8 +485,8 @@ static int parse_table(int *name, int nlen, ...@@ -485,8 +485,8 @@ static int parse_table(int *name, int nlen,
/* Perform the actual read/write of a sysctl table entry. */ /* Perform the actual read/write of a sysctl table entry. */
int do_sysctl_strategy (ctl_table *table, int do_sysctl_strategy (ctl_table *table,
int *name, int nlen, int *name, int nlen,
void *oldval, size_t *oldlenp, void __user *oldval, size_t __user *oldlenp,
void *newval, size_t newlen, void **context) void __user *newval, size_t newlen, void **context)
{ {
int op = 0, rc; int op = 0, rc;
size_t len; size_t len;
...@@ -787,10 +787,11 @@ static int proc_sys_permission(struct inode *inode, int op) ...@@ -787,10 +787,11 @@ static int proc_sys_permission(struct inode *inode, int op)
* Returns 0 on success. * Returns 0 on success.
*/ */
int proc_dostring(ctl_table *table, int write, struct file *filp, int proc_dostring(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp) void __user *buffer, size_t *lenp)
{ {
size_t len; size_t len;
char *p, c; char __user *p;
char c;
if (!table->data || !table->maxlen || !*lenp || if (!table->data || !table->maxlen || !*lenp ||
(filp->f_pos && !write)) { (filp->f_pos && !write)) {
...@@ -840,7 +841,7 @@ int proc_dostring(ctl_table *table, int write, struct file *filp, ...@@ -840,7 +841,7 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
*/ */
static int proc_doutsstring(ctl_table *table, int write, struct file *filp, static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp) void __user *buffer, size_t *lenp)
{ {
int r; int r;
...@@ -863,7 +864,7 @@ static int proc_doutsstring(ctl_table *table, int write, struct file *filp, ...@@ -863,7 +864,7 @@ static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
#define OP_MIN 4 #define OP_MIN 4
static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp, int conv, int op) void __user *buffer, size_t *lenp, int conv, int op)
{ {
int *i, vleft, first=1, neg, val; int *i, vleft, first=1, neg, val;
size_t left, len; size_t left, len;
...@@ -885,12 +886,12 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, ...@@ -885,12 +886,12 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
if (write) { if (write) {
while (left) { while (left) {
char c; char c;
if(get_user(c,(char *) buffer)) if (get_user(c,(char __user *) buffer))
return -EFAULT; return -EFAULT;
if (!isspace(c)) if (!isspace(c))
break; break;
left--; left--;
((char *) buffer)++; buffer++;
} }
if (!left) if (!left)
break; break;
...@@ -979,7 +980,7 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, ...@@ -979,7 +980,7 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
* Returns 0 on success. * Returns 0 on success.
*/ */
int proc_dointvec(ctl_table *table, int write, struct file *filp, int proc_dointvec(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp) void __user *buffer, size_t *lenp)
{ {
return do_proc_dointvec(table,write,filp,buffer,lenp,1,OP_SET); return do_proc_dointvec(table,write,filp,buffer,lenp,1,OP_SET);
} }
...@@ -989,7 +990,7 @@ int proc_dointvec(ctl_table *table, int write, struct file *filp, ...@@ -989,7 +990,7 @@ int proc_dointvec(ctl_table *table, int write, struct file *filp,
*/ */
int proc_dointvec_bset(ctl_table *table, int write, struct file *filp, int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp) void __user *buffer, size_t *lenp)
{ {
if (!capable(CAP_SYS_MODULE)) { if (!capable(CAP_SYS_MODULE)) {
return -EPERM; return -EPERM;
...@@ -1015,7 +1016,7 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp, ...@@ -1015,7 +1016,7 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
* Returns 0 on success. * Returns 0 on success.
*/ */
int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp) void __user *buffer, size_t *lenp)
{ {
int *i, *min, *max, vleft, first=1, neg, val; int *i, *min, *max, vleft, first=1, neg, val;
size_t len, left; size_t len, left;
...@@ -1043,7 +1044,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, ...@@ -1043,7 +1044,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
if (!isspace(c)) if (!isspace(c))
break; break;
left--; left--;
((char *) buffer)++; buffer++;
} }
if (!left) if (!left)
break; break;
...@@ -1113,7 +1114,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, ...@@ -1113,7 +1114,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
static int do_proc_doulongvec_minmax(ctl_table *table, int write, static int do_proc_doulongvec_minmax(ctl_table *table, int write,
struct file *filp, struct file *filp,
void *buffer, size_t *lenp, void __user *buffer, size_t *lenp,
unsigned long convmul, unsigned long convmul,
unsigned long convdiv) unsigned long convdiv)
{ {
...@@ -1139,12 +1140,12 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, ...@@ -1139,12 +1140,12 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
if (write) { if (write) {
while (left) { while (left) {
char c; char c;
if(get_user(c, (char *) buffer)) if (get_user(c, (char __user *) buffer))
return -EFAULT; return -EFAULT;
if (!isspace(c)) if (!isspace(c))
break; break;
left--; left--;
((char *) buffer)++; buffer++;
} }
if (!left) if (!left)
break; break;
...@@ -1152,7 +1153,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, ...@@ -1152,7 +1153,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
len = left; len = left;
if (len > TMPBUFLEN-1) if (len > TMPBUFLEN-1)
len = TMPBUFLEN-1; len = TMPBUFLEN-1;
if(copy_from_user(buf, buffer, len)) if (copy_from_user(buf, buffer, len))
return -EFAULT; return -EFAULT;
buf[len] = 0; buf[len] = 0;
p = buf; p = buf;
...@@ -1232,7 +1233,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, ...@@ -1232,7 +1233,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
* Returns 0 on success. * Returns 0 on success.
*/ */
int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp) void __user *buffer, size_t *lenp)
{ {
return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l); return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
} }
...@@ -1256,7 +1257,7 @@ int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, ...@@ -1256,7 +1257,7 @@ int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
*/ */
int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
struct file *filp, struct file *filp,
void *buffer, size_t *lenp) void __user *buffer, size_t *lenp)
{ {
return do_proc_doulongvec_minmax(table, write, filp, buffer, return do_proc_doulongvec_minmax(table, write, filp, buffer,
lenp, HZ, 1000l); lenp, HZ, 1000l);
...@@ -1279,7 +1280,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, ...@@ -1279,7 +1280,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
* Returns 0 on success. * Returns 0 on success.
*/ */
int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp, int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp) void __user *buffer, size_t *lenp)
{ {
return do_proc_dointvec(table,write,filp,buffer,lenp,HZ,OP_SET); return do_proc_dointvec(table,write,filp,buffer,lenp,HZ,OP_SET);
} }
...@@ -1345,8 +1346,8 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, ...@@ -1345,8 +1346,8 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
/* The generic string strategy routine: */ /* The generic string strategy routine: */
int sysctl_string(ctl_table *table, int *name, int nlen, int sysctl_string(ctl_table *table, int *name, int nlen,
void *oldval, size_t *oldlenp, void __user *oldval, size_t __user *oldlenp,
void *newval, size_t newlen, void **context) void __user *newval, size_t newlen, void **context)
{ {
size_t l, len; size_t l, len;
...@@ -1453,7 +1454,7 @@ int sysctl_jiffies(ctl_table *table, int *name, int nlen, ...@@ -1453,7 +1454,7 @@ int sysctl_jiffies(ctl_table *table, int *name, int nlen,
#else /* CONFIG_SYSCTL */ #else /* CONFIG_SYSCTL */
extern asmlinkage long sys_sysctl(struct __sysctl_args *args) extern asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
{ {
return -ENOSYS; return -ENOSYS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment