Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
b9a8a0bd
Commit
b9a8a0bd
authored
Apr 09, 2003
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Annotate sysct with user pointer annotations
parent
75b08514
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
29 deletions
+30
-29
include/linux/sysctl.h
include/linux/sysctl.h
+4
-4
kernel/sysctl.c
kernel/sysctl.c
+26
-25
No files found.
include/linux/sysctl.h
View file @
b9a8a0bd
...
@@ -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
;
...
...
kernel/sysctl.c
View file @
b9a8a0bd
...
@@ -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
,(
cha
r
*
)
buffer
))
if
(
get_user
(
c
,(
char
__use
r
*
)
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
,
(
cha
r
*
)
buffer
))
if
(
get_user
(
c
,
(
char
__use
r
*
)
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
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment