t/.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogblamecommitdiffstats
path: root/fs/proc/root.c
blob: 87dbcbef7fe4b3535d4bfdcbc7590af24d3d5f0a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                           
                       
                        

                         
                                 
                        
                                
                         
 

                     






                                                              





                                                                        

 
      
                                      


                                     

                                    






                                                                       
                   








                                                     
                                                 

                                                     


                                                         
                                                                            









                                                                                         















                                                                        

                                                                  
 


                                 
                      
 
                                   
                                                  

                               
                                                 
                               
 




                                                                             
                                               
         
 
                                                                       
                       
                                    
 




                                               
                          

                                          
                                                    
                                            

                 
                                         

         
                                






                                                   

                                    

                            

 
                                               
                                 
                                     
                                       
                                          

  

                                


                               


                                                 
 
                         
                                                    

                        



                                    
                               
                                   








                                                                                          
                                
                        

 

                                                                                            
 



                                                       
 
                                                                                                      
 
                                             
                            
        
                                                   

 
                                                                        
 
                                             


                                                    
                                               
         
 
                                           






                                                     
                                                            
                                            
                                             
                                         




                                    
                                                                   
                                           
                                            







                                               

                                                       
                                         


                                                       
                                  

  







                                                 
                           




                                                  
                                   
 
/*
 *  linux/fs/proc/root.c
 *
 *  Copyright (C) 1991, 1992 Linus Torvalds
 *
 *  proc root directory handling functions
 */

#include <asm/uaccess.h>

#include <linux/errno.h>
#include <linux/time.h>
#include <linux/proc_fs.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/bitops.h>
#include <linux/user_namespace.h>
#include <linux/mount.h>
#include <linux/pid_namespace.h>
#include <linux/parser.h>

#include "internal.h"

static int proc_test_super(struct super_block *sb, void *data)
{
	return sb->s_fs_info == data;
}

static int proc_set_super(struct super_block *sb, void *data)
{
	int err = set_anon_super(sb, NULL);
	if (!err) {
		struct pid_namespace *ns = (struct pid_namespace *)data;
		sb->s_fs_info = get_pid_ns(ns);
	}
	return err;
}

enum {
	Opt_gid, Opt_hidepid, Opt_err,
};

static const match_table_t tokens = {
	{Opt_hidepid, "hidepid=%u"},
	{Opt_gid, "gid=%u"},
	{Opt_err, NULL},
};

static int proc_parse_options(char *options, struct pid_namespace *pid)
{
	char *p;
	substring_t args[MAX_OPT_ARGS];
	int option;

	if (!options)
		return 1;

	while ((p = strsep(&options, ",")) != NULL) {
		int token;
		if (!*p)
			continue;

		args[0].to = args[0].from = NULL;
		token = match_token(p, tokens, args);
		switch (token) {
		case Opt_gid:
			if (match_int(&args[0], &option))
				return 0;
			pid->pid_gid = make_kgid(current_user_ns(), option);
			break;
		case Opt_hidepid:
			if (match_int(&args[0], &option))
				return 0;
			if (option < 0 || option > 2) {
				pr_err("proc: hidepid value must be between 0 and 2.\n");
				return 0;
			}
			pid->hide_pid = option;
			break;
		default:
			pr_err("proc: unrecognized mount option \"%s\" "
			       "or missing value\n", p);
			return 0;
		}
	}

	return 1;
}

int proc_remount(struct super_block *sb, int *flags, char *data)
{
	struct pid_namespace *pid = sb->s_fs_info;
	return !proc_parse_options(data, pid);
}

static struct dentry *proc_mount(struct file_system_type *fs_type,