Skip to content

Commit c59f415

Browse files
legionusebiederm
authored andcommitted
Use proc_pid_ns() to get pid_namespace from the proc superblock
To get pid_namespace from the procfs superblock should be used a special helper. This will avoid errors when s_fs_info will change the type. Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Alexey Gladkov <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent 6ade99e commit c59f415

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

fs/locks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,7 +2823,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
28232823
{
28242824
struct inode *inode = NULL;
28252825
unsigned int fl_pid;
2826-
struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info;
2826+
struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file));
28272827

28282828
fl_pid = locks_translate_pid(fl, proc_pidns);
28292829
/*
@@ -2901,7 +2901,7 @@ static int locks_show(struct seq_file *f, void *v)
29012901
{
29022902
struct locks_iterator *iter = f->private;
29032903
struct file_lock *fl, *bfl;
2904-
struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info;
2904+
struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file));
29052905

29062906
fl = hlist_entry(v, struct file_lock, fl_link);
29072907

security/tomoyo/realpath.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "common.h"
99
#include <linux/magic.h>
10+
#include <linux/proc_fs.h>
1011

1112
/**
1213
* tomoyo_encode2 - Encode binary string to ascii string.
@@ -161,9 +162,10 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
161162
if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') {
162163
char *ep;
163164
const pid_t pid = (pid_t) simple_strtoul(pos + 1, &ep, 10);
165+
struct pid_namespace *proc_pidns = proc_pid_ns(d_inode(dentry));
164166

165167
if (*ep == '/' && pid && pid ==
166-
task_tgid_nr_ns(current, sb->s_fs_info)) {
168+
task_tgid_nr_ns(current, proc_pidns)) {
167169
pos = ep - 5;
168170
if (pos < buffer)
169171
goto out;

0 commit comments

Comments
 (0)