mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	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/20200423200316.164518-3-gladkov.alexey@gmail.com/ Link: https://lore.kernel.org/lkml/20200423112858.95820-1-gladkov.alexey@gmail.com/ Link: https://lore.kernel.org/lkml/06B50A1C-406F-4057-BFA8-3A7729EA7469@lca.pw/ Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
		
							parent
							
								
									6ade99ec61
								
							
						
					
					
						commit
						c59f415a7c
					
				
					 2 changed files with 5 additions and 3 deletions
				
			
		|  | @ -2823,7 +2823,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, | ||||||
| { | { | ||||||
| 	struct inode *inode = NULL; | 	struct inode *inode = NULL; | ||||||
| 	unsigned int fl_pid; | 	unsigned int fl_pid; | ||||||
| 	struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info; | 	struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file)); | ||||||
| 
 | 
 | ||||||
| 	fl_pid = locks_translate_pid(fl, proc_pidns); | 	fl_pid = locks_translate_pid(fl, proc_pidns); | ||||||
| 	/*
 | 	/*
 | ||||||
|  | @ -2901,7 +2901,7 @@ static int locks_show(struct seq_file *f, void *v) | ||||||
| { | { | ||||||
| 	struct locks_iterator *iter = f->private; | 	struct locks_iterator *iter = f->private; | ||||||
| 	struct file_lock *fl, *bfl; | 	struct file_lock *fl, *bfl; | ||||||
| 	struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info; | 	struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file)); | ||||||
| 
 | 
 | ||||||
| 	fl = hlist_entry(v, struct file_lock, fl_link); | 	fl = hlist_entry(v, struct file_lock, fl_link); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "common.h" | #include "common.h" | ||||||
| #include <linux/magic.h> | #include <linux/magic.h> | ||||||
|  | #include <linux/proc_fs.h> | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * tomoyo_encode2 - Encode binary string to ascii string. |  * tomoyo_encode2 - Encode binary string to ascii string. | ||||||
|  | @ -161,9 +162,10 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer, | ||||||
| 	if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') { | 	if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') { | ||||||
| 		char *ep; | 		char *ep; | ||||||
| 		const pid_t pid = (pid_t) simple_strtoul(pos + 1, &ep, 10); | 		const pid_t pid = (pid_t) simple_strtoul(pos + 1, &ep, 10); | ||||||
|  | 		struct pid_namespace *proc_pidns = proc_pid_ns(d_inode(dentry)); | ||||||
| 
 | 
 | ||||||
| 		if (*ep == '/' && pid && pid == | 		if (*ep == '/' && pid && pid == | ||||||
| 		    task_tgid_nr_ns(current, sb->s_fs_info)) { | 		    task_tgid_nr_ns(current, proc_pidns)) { | ||||||
| 			pos = ep - 5; | 			pos = ep - 5; | ||||||
| 			if (pos < buffer) | 			if (pos < buffer) | ||||||
| 				goto out; | 				goto out; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Alexey Gladkov
						Alexey Gladkov