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
7ef95e3d
Commit
7ef95e3d
authored
Nov 20, 2020
by
Kees Cook
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'for-linus/seccomp' into for-next/seccomp
parents
fab686eb
4c222f31
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
18 deletions
+11
-18
kernel/ptrace.c
kernel/ptrace.c
+5
-11
kernel/seccomp.c
kernel/seccomp.c
+2
-3
tools/testing/selftests/seccomp/seccomp_bpf.c
tools/testing/selftests/seccomp/seccomp_bpf.c
+4
-4
No files found.
kernel/ptrace.c
View file @
7ef95e3d
...
@@ -264,17 +264,11 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
...
@@ -264,17 +264,11 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
return
ret
;
return
ret
;
}
}
static
bool
ptrace_has_cap
(
const
struct
cred
*
cred
,
struct
user_namespace
*
ns
,
static
bool
ptrace_has_cap
(
struct
user_namespace
*
ns
,
unsigned
int
mode
)
unsigned
int
mode
)
{
{
int
ret
;
if
(
mode
&
PTRACE_MODE_NOAUDIT
)
if
(
mode
&
PTRACE_MODE_NOAUDIT
)
ret
=
security_capable
(
cred
,
ns
,
CAP_SYS_PTRACE
,
CAP_OPT_NOAUDIT
);
return
ns_capable_noaudit
(
ns
,
CAP_SYS_PTRACE
);
else
return
ns_capable
(
ns
,
CAP_SYS_PTRACE
);
ret
=
security_capable
(
cred
,
ns
,
CAP_SYS_PTRACE
,
CAP_OPT_NONE
);
return
ret
==
0
;
}
}
/* Returns 0 on success, -errno on denial. */
/* Returns 0 on success, -errno on denial. */
...
@@ -326,7 +320,7 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
...
@@ -326,7 +320,7 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
gid_eq
(
caller_gid
,
tcred
->
sgid
)
&&
gid_eq
(
caller_gid
,
tcred
->
sgid
)
&&
gid_eq
(
caller_gid
,
tcred
->
gid
))
gid_eq
(
caller_gid
,
tcred
->
gid
))
goto
ok
;
goto
ok
;
if
(
ptrace_has_cap
(
cred
,
tcred
->
user_ns
,
mode
))
if
(
ptrace_has_cap
(
tcred
->
user_ns
,
mode
))
goto
ok
;
goto
ok
;
rcu_read_unlock
();
rcu_read_unlock
();
return
-
EPERM
;
return
-
EPERM
;
...
@@ -345,7 +339,7 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
...
@@ -345,7 +339,7 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
mm
=
task
->
mm
;
mm
=
task
->
mm
;
if
(
mm
&&
if
(
mm
&&
((
get_dumpable
(
mm
)
!=
SUID_DUMP_USER
)
&&
((
get_dumpable
(
mm
)
!=
SUID_DUMP_USER
)
&&
!
ptrace_has_cap
(
cred
,
mm
->
user_ns
,
mode
)))
!
ptrace_has_cap
(
mm
->
user_ns
,
mode
)))
return
-
EPERM
;
return
-
EPERM
;
return
security_ptrace_access_check
(
task
,
mode
);
return
security_ptrace_access_check
(
task
,
mode
);
...
...
kernel/seccomp.c
View file @
7ef95e3d
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
#include <linux/filter.h>
#include <linux/filter.h>
#include <linux/pid.h>
#include <linux/pid.h>
#include <linux/ptrace.h>
#include <linux/ptrace.h>
#include <linux/
secur
ity.h>
#include <linux/
capabil
ity.h>
#include <linux/tracehook.h>
#include <linux/tracehook.h>
#include <linux/uaccess.h>
#include <linux/uaccess.h>
#include <linux/anon_inodes.h>
#include <linux/anon_inodes.h>
...
@@ -649,8 +649,7 @@ static struct seccomp_filter *seccomp_prepare_filter(struct sock_fprog *fprog)
...
@@ -649,8 +649,7 @@ static struct seccomp_filter *seccomp_prepare_filter(struct sock_fprog *fprog)
* behavior of privileged children.
* behavior of privileged children.
*/
*/
if
(
!
task_no_new_privs
(
current
)
&&
if
(
!
task_no_new_privs
(
current
)
&&
security_capable
(
current_cred
(),
current_user_ns
(),
!
ns_capable_noaudit
(
current_user_ns
(),
CAP_SYS_ADMIN
))
CAP_SYS_ADMIN
,
CAP_OPT_NOAUDIT
)
!=
0
)
return
ERR_PTR
(
-
EACCES
);
return
ERR_PTR
(
-
EACCES
);
/* Allocate a new seccomp_filter */
/* Allocate a new seccomp_filter */
...
...
tools/testing/selftests/seccomp/seccomp_bpf.c
View file @
7ef95e3d
...
@@ -1758,10 +1758,10 @@ TEST_F(TRACE_poke, getpid_runs_normally)
...
@@ -1758,10 +1758,10 @@ TEST_F(TRACE_poke, getpid_runs_normally)
* and the code is stored as a positive value. \
* and the code is stored as a positive value. \
*/
\
*/
\
if (_result < 0) { \
if (_result < 0) { \
SYSCALL_RET(_regs) = -result; \
SYSCALL_RET(_regs) = -
_
result; \
(_regs).ccr |= 0x10000000; \
(_regs).ccr |= 0x10000000; \
} else { \
} else { \
SYSCALL_RET(_regs) = result; \
SYSCALL_RET(_regs) =
_
result; \
(_regs).ccr &= ~0x10000000; \
(_regs).ccr &= ~0x10000000; \
} \
} \
} while (0)
} while (0)
...
@@ -1804,8 +1804,8 @@ TEST_F(TRACE_poke, getpid_runs_normally)
...
@@ -1804,8 +1804,8 @@ TEST_F(TRACE_poke, getpid_runs_normally)
#define SYSCALL_RET(_regs) (_regs).a[(_regs).windowbase * 4 + 2]
#define SYSCALL_RET(_regs) (_regs).a[(_regs).windowbase * 4 + 2]
#elif defined(__sh__)
#elif defined(__sh__)
# define ARCH_REGS struct pt_regs
# define ARCH_REGS struct pt_regs
# define SYSCALL_NUM(_regs) (_regs).
gpr
[3]
# define SYSCALL_NUM(_regs) (_regs).
regs
[3]
# define SYSCALL_RET(_regs) (_regs).
gpr
[0]
# define SYSCALL_RET(_regs) (_regs).
regs
[0]
#else
#else
# error "Do not know how to find your architecture's registers and syscalls"
# error "Do not know how to find your architecture's registers and syscalls"
#endif
#endif
...
...
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