Skip to content

Commit c8da96e

Browse files
bwhacksxjamesmorris
authored andcommitted
TOMOYO: Don't abuse sys_getpid(), sys_getppid()
System call entry functions sys_*() are never to be called from general kernel code. The fact that they aren't declared in header files should have been a clue. These functions also don't exist on Alpha since it has sys_getxpid() instead. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Acked-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 91e71c1 commit c8da96e

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎security/tomoyo/common.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,15 +1416,19 @@ static char *tomoyo_print_header(struct tomoyo_request_info *r)
14161416
const pid_t gpid = task_pid_nr(current);
14171417
static const int tomoyo_buffer_len = 4096;
14181418
char *buffer = kmalloc(tomoyo_buffer_len, GFP_NOFS);
1419+
pid_t ppid;
14191420
if (!buffer)
14201421
return NULL;
14211422
do_gettimeofday(&tv);
1423+
rcu_read_lock();
1424+
ppid = task_tgid_vnr(current->real_parent);
1425+
rcu_read_unlock();
14221426
snprintf(buffer, tomoyo_buffer_len - 1,
14231427
"#timestamp=%lu profile=%u mode=%s (global-pid=%u)"
14241428
" task={ pid=%u ppid=%u uid=%u gid=%u euid=%u"
14251429
" egid=%u suid=%u sgid=%u fsuid=%u fsgid=%u }",
14261430
tv.tv_sec, r->profile, tomoyo_mode[r->mode], gpid,
1427-
(pid_t) sys_getpid(), (pid_t) sys_getppid(),
1431+
task_tgid_vnr(current), ppid,
14281432
current_uid(), current_gid(), current_euid(),
14291433
current_egid(), current_suid(), current_sgid(),
14301434
current_fsuid(), current_fsgid());

‎security/tomoyo/common.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,6 @@ struct tomoyo_profile {
689689

690690
/********** Function prototypes. **********/
691691

692-
extern asmlinkage long sys_getpid(void);
693-
extern asmlinkage long sys_getppid(void);
694-
695692
/* Check whether the given string starts with the given keyword. */
696693
bool tomoyo_str_starts(char **src, const char *find);
697694
/* Get tomoyo_realpath() of current process. */

0 commit comments

Comments
 (0)