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
dd5d5ea8
Commit
dd5d5ea8
authored
Jun 04, 2004
by
David S. Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[COMPAT]: Add __user attributes for pointers passed while KERNEL_DS.
parent
5a4d68e6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
22 deletions
+41
-22
kernel/compat.c
kernel/compat.c
+41
-22
No files found.
kernel/compat.c
View file @
dd5d5ea8
...
@@ -182,7 +182,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
...
@@ -182,7 +182,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
mm_segment_t
old_fs
=
get_fs
();
mm_segment_t
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
ret
=
sys_sigpending
(
&
s
);
ret
=
sys_sigpending
(
(
old_sigset_t
__user
*
)
&
s
);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
if
(
ret
==
0
)
if
(
ret
==
0
)
ret
=
put_user
(
s
,
set
);
ret
=
put_user
(
s
,
set
);
...
@@ -200,7 +200,9 @@ asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *set,
...
@@ -200,7 +200,9 @@ asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *set,
return
-
EFAULT
;
return
-
EFAULT
;
old_fs
=
get_fs
();
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
ret
=
sys_sigprocmask
(
how
,
set
?
&
s
:
NULL
,
oset
?
&
s
:
NULL
);
ret
=
sys_sigprocmask
(
how
,
set
?
(
old_sigset_t
__user
*
)
&
s
:
NULL
,
oset
?
(
old_sigset_t
__user
*
)
&
s
:
NULL
);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
if
(
ret
==
0
)
if
(
ret
==
0
)
if
(
oset
)
if
(
oset
)
...
@@ -223,7 +225,7 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, int val,
...
@@ -223,7 +225,7 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, int val,
timeout
=
timespec_to_jiffies
(
&
t
)
+
1
;
timeout
=
timespec_to_jiffies
(
&
t
)
+
1
;
}
}
if
(
op
>=
FUTEX_REQUEUE
)
if
(
op
>=
FUTEX_REQUEUE
)
val2
=
(
int
)
(
long
)
utime
;
val2
=
(
int
)
(
unsigned
long
)
utime
;
return
do_futex
((
unsigned
long
)
uaddr
,
op
,
val
,
timeout
,
return
do_futex
((
unsigned
long
)
uaddr
,
op
,
val
,
timeout
,
(
unsigned
long
)
uaddr2
,
val2
,
val3
);
(
unsigned
long
)
uaddr2
,
val2
,
val3
);
...
@@ -250,7 +252,7 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource,
...
@@ -250,7 +252,7 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource,
if
(
r
.
rlim_max
==
COMPAT_RLIM_INFINITY
)
if
(
r
.
rlim_max
==
COMPAT_RLIM_INFINITY
)
r
.
rlim_max
=
RLIM_INFINITY
;
r
.
rlim_max
=
RLIM_INFINITY
;
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
ret
=
sys_setrlimit
(
resource
,
&
r
);
ret
=
sys_setrlimit
(
resource
,
(
struct
rlimit
__user
*
)
&
r
);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
return
ret
;
return
ret
;
}
}
...
@@ -292,7 +294,7 @@ asmlinkage long compat_sys_getrlimit (unsigned int resource,
...
@@ -292,7 +294,7 @@ asmlinkage long compat_sys_getrlimit (unsigned int resource,
mm_segment_t
old_fs
=
get_fs
();
mm_segment_t
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
ret
=
sys_getrlimit
(
resource
,
&
r
);
ret
=
sys_getrlimit
(
resource
,
(
struct
rlimit
__user
*
)
&
r
);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
if
(
!
ret
)
{
if
(
!
ret
)
{
if
(
r
.
rlim_cur
>
COMPAT_RLIM_INFINITY
)
if
(
r
.
rlim_cur
>
COMPAT_RLIM_INFINITY
)
...
@@ -340,7 +342,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
...
@@ -340,7 +342,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
mm_segment_t
old_fs
=
get_fs
();
mm_segment_t
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
ret
=
sys_getrusage
(
who
,
&
r
);
ret
=
sys_getrusage
(
who
,
(
struct
rusage
__user
*
)
&
r
);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
if
(
ret
)
if
(
ret
)
...
@@ -365,7 +367,10 @@ compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options,
...
@@ -365,7 +367,10 @@ compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options,
mm_segment_t
old_fs
=
get_fs
();
mm_segment_t
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
ret
=
sys_wait4
(
pid
,
stat_addr
?
&
status
:
NULL
,
options
,
&
r
);
ret
=
sys_wait4
(
pid
,
(
stat_addr
?
(
unsigned
int
__user
*
)
&
status
:
NULL
),
options
,
(
struct
rusage
__user
*
)
&
r
);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
...
@@ -382,18 +387,18 @@ asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
...
@@ -382,18 +387,18 @@ asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
unsigned
int
len
,
unsigned
int
len
,
compat_ulong_t
__user
*
user_mask_ptr
)
compat_ulong_t
__user
*
user_mask_ptr
)
{
{
unsigned
long
kern
el
_mask
;
unsigned
long
kern_mask
;
mm_segment_t
old_fs
;
mm_segment_t
old_fs
;
int
ret
;
int
ret
;
if
(
get_user
(
kern
el
_mask
,
user_mask_ptr
))
if
(
get_user
(
kern_mask
,
user_mask_ptr
))
return
-
EFAULT
;
return
-
EFAULT
;
old_fs
=
get_fs
();
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
ret
=
sys_sched_setaffinity
(
pid
,
ret
=
sys_sched_setaffinity
(
pid
,
sizeof
(
kern
el
_mask
),
sizeof
(
kern_mask
),
&
kernel
_mask
);
(
unsigned
long
__user
*
)
&
kern
_mask
);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
return
ret
;
return
ret
;
...
@@ -402,20 +407,20 @@ asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
...
@@ -402,20 +407,20 @@ asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
asmlinkage
long
compat_sys_sched_getaffinity
(
compat_pid_t
pid
,
unsigned
int
len
,
asmlinkage
long
compat_sys_sched_getaffinity
(
compat_pid_t
pid
,
unsigned
int
len
,
compat_ulong_t
__user
*
user_mask_ptr
)
compat_ulong_t
__user
*
user_mask_ptr
)
{
{
unsigned
long
kern
el
_mask
;
unsigned
long
kern_mask
;
mm_segment_t
old_fs
;
mm_segment_t
old_fs
;
int
ret
;
int
ret
;
old_fs
=
get_fs
();
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
ret
=
sys_sched_getaffinity
(
pid
,
ret
=
sys_sched_getaffinity
(
pid
,
sizeof
(
kern
el
_mask
),
sizeof
(
kern_mask
),
&
kernel
_mask
);
(
unsigned
long
__user
*
)
&
kern
_mask
);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
ret
=
sizeof
(
compat_ulong_t
);
ret
=
sizeof
(
compat_ulong_t
);
if
(
put_user
(
kern
el
_mask
,
user_mask_ptr
))
if
(
put_user
(
kern_mask
,
user_mask_ptr
))
return
-
EFAULT
;
return
-
EFAULT
;
}
}
...
@@ -454,7 +459,9 @@ long compat_timer_settime(timer_t timer_id, int flags,
...
@@ -454,7 +459,9 @@ long compat_timer_settime(timer_t timer_id, int flags,
return
-
EFAULT
;
return
-
EFAULT
;
oldfs
=
get_fs
();
oldfs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
err
=
sys_timer_settime
(
timer_id
,
flags
,
&
newts
,
&
oldts
);
err
=
sys_timer_settime
(
timer_id
,
flags
,
(
struct
itimerspec
__user
*
)
&
newts
,
(
struct
itimerspec
__user
*
)
&
oldts
);
set_fs
(
oldfs
);
set_fs
(
oldfs
);
if
(
!
err
&&
old
&&
put_compat_itimerspec
(
old
,
&
oldts
))
if
(
!
err
&&
old
&&
put_compat_itimerspec
(
old
,
&
oldts
))
return
-
EFAULT
;
return
-
EFAULT
;
...
@@ -467,9 +474,11 @@ long compat_timer_gettime(timer_t timer_id,
...
@@ -467,9 +474,11 @@ long compat_timer_gettime(timer_t timer_id,
long
err
;
long
err
;
mm_segment_t
oldfs
;
mm_segment_t
oldfs
;
struct
itimerspec
ts
;
struct
itimerspec
ts
;
oldfs
=
get_fs
();
oldfs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
err
=
sys_timer_gettime
(
timer_id
,
&
ts
);
err
=
sys_timer_gettime
(
timer_id
,
(
struct
itimerspec
__user
*
)
&
ts
);
set_fs
(
oldfs
);
set_fs
(
oldfs
);
if
(
!
err
&&
put_compat_itimerspec
(
setting
,
&
ts
))
if
(
!
err
&&
put_compat_itimerspec
(
setting
,
&
ts
))
return
-
EFAULT
;
return
-
EFAULT
;
...
@@ -482,11 +491,13 @@ long compat_clock_settime(clockid_t which_clock,
...
@@ -482,11 +491,13 @@ long compat_clock_settime(clockid_t which_clock,
long
err
;
long
err
;
mm_segment_t
oldfs
;
mm_segment_t
oldfs
;
struct
timespec
ts
;
struct
timespec
ts
;
if
(
get_compat_timespec
(
&
ts
,
tp
))
if
(
get_compat_timespec
(
&
ts
,
tp
))
return
-
EFAULT
;
return
-
EFAULT
;
oldfs
=
get_fs
();
oldfs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
err
=
sys_clock_settime
(
which_clock
,
&
ts
);
err
=
sys_clock_settime
(
which_clock
,
(
struct
timespec
__user
*
)
&
ts
);
set_fs
(
oldfs
);
set_fs
(
oldfs
);
return
err
;
return
err
;
}
}
...
@@ -497,9 +508,11 @@ long compat_clock_gettime(clockid_t which_clock,
...
@@ -497,9 +508,11 @@ long compat_clock_gettime(clockid_t which_clock,
long
err
;
long
err
;
mm_segment_t
oldfs
;
mm_segment_t
oldfs
;
struct
timespec
ts
;
struct
timespec
ts
;
oldfs
=
get_fs
();
oldfs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
err
=
sys_clock_gettime
(
which_clock
,
&
ts
);
err
=
sys_clock_gettime
(
which_clock
,
(
struct
timespec
__user
*
)
&
ts
);
set_fs
(
oldfs
);
set_fs
(
oldfs
);
if
(
!
err
&&
put_compat_timespec
(
&
ts
,
tp
))
if
(
!
err
&&
put_compat_timespec
(
&
ts
,
tp
))
return
-
EFAULT
;
return
-
EFAULT
;
...
@@ -512,9 +525,11 @@ long compat_clock_getres(clockid_t which_clock,
...
@@ -512,9 +525,11 @@ long compat_clock_getres(clockid_t which_clock,
long
err
;
long
err
;
mm_segment_t
oldfs
;
mm_segment_t
oldfs
;
struct
timespec
ts
;
struct
timespec
ts
;
oldfs
=
get_fs
();
oldfs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
err
=
sys_clock_getres
(
which_clock
,
&
ts
);
err
=
sys_clock_getres
(
which_clock
,
(
struct
timespec
__user
*
)
&
ts
);
set_fs
(
oldfs
);
set_fs
(
oldfs
);
if
(
!
err
&&
put_compat_timespec
(
&
ts
,
tp
))
if
(
!
err
&&
put_compat_timespec
(
&
ts
,
tp
))
return
-
EFAULT
;
return
-
EFAULT
;
...
@@ -528,11 +543,15 @@ long compat_clock_nanosleep(clockid_t which_clock, int flags,
...
@@ -528,11 +543,15 @@ long compat_clock_nanosleep(clockid_t which_clock, int flags,
long
err
;
long
err
;
mm_segment_t
oldfs
;
mm_segment_t
oldfs
;
struct
timespec
in
,
out
;
struct
timespec
in
,
out
;
if
(
get_compat_timespec
(
&
in
,
rqtp
))
if
(
get_compat_timespec
(
&
in
,
rqtp
))
return
-
EFAULT
;
return
-
EFAULT
;
oldfs
=
get_fs
();
oldfs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
err
=
sys_clock_nanosleep
(
which_clock
,
flags
,
&
in
,
&
out
);
err
=
sys_clock_nanosleep
(
which_clock
,
flags
,
(
struct
timespec
__user
*
)
&
in
,
(
struct
timespec
__user
*
)
&
out
);
set_fs
(
oldfs
);
set_fs
(
oldfs
);
if
((
err
==
-
ERESTART_RESTARTBLOCK
)
&&
rmtp
&&
if
((
err
==
-
ERESTART_RESTARTBLOCK
)
&&
rmtp
&&
put_compat_timespec
(
&
out
,
rmtp
))
put_compat_timespec
(
&
out
,
rmtp
))
...
...
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