All of lore.kernel.org
 help / color / mirror / Atom feed
From: kbuild test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [hch-misc:set_fs-sysctl 6/6] fs/proc/proc_sysctl.c:602:16: error: invalid storage class for function 'proc_sys_read'
Date: Tue, 14 Apr 2020 11:56:34 +0800	[thread overview]
Message-ID: <202004141122.GiPNCOUb%lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 31637 bytes --]

tree:   git://git.infradead.org/users/hch/misc.git set_fs-sysctl
head:   862858db7419b3123f7b182ceb2026ef94efc2a5
commit: 862858db7419b3123f7b182ceb2026ef94efc2a5 [6/6] sysctl: pass kernel pointers to ->proc_handler
config: sparc-allyesconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 862858db7419b3123f7b182ceb2026ef94efc2a5
        # save the attached .config to linux build tree
        GCC_VERSION=9.3.0 make.cross ARCH=sparc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   fs/proc/proc_sysctl.c: In function 'proc_sys_call_handler':
>> fs/proc/proc_sysctl.c:602:16: error: invalid storage class for function 'proc_sys_read'
     602 | static ssize_t proc_sys_read(struct file *filp, char __user *buf,
         |                ^~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:602:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     602 | static ssize_t proc_sys_read(struct file *filp, char __user *buf,
         | ^~~~~~
>> fs/proc/proc_sysctl.c:608:16: error: invalid storage class for function 'proc_sys_write'
     608 | static ssize_t proc_sys_write(struct file *filp, const char __user *buf,
         |                ^~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:614:12: error: invalid storage class for function 'proc_sys_open'
     614 | static int proc_sys_open(struct inode *inode, struct file *filp)
         |            ^~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:631:17: error: invalid storage class for function 'proc_sys_poll'
     631 | static __poll_t proc_sys_poll(struct file *filp, poll_table *wait)
         |                 ^~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:663:13: error: invalid storage class for function 'proc_sys_fill_cache'
     663 | static bool proc_sys_fill_cache(struct file *file,
         |             ^~~~~~~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:712:13: error: invalid storage class for function 'proc_sys_link_fill_cache'
     712 | static bool proc_sys_link_fill_cache(struct file *file,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:733:12: error: invalid storage class for function 'scan'
     733 | static int scan(struct ctl_table_header *head, struct ctl_table *table,
         |            ^~~~
>> fs/proc/proc_sysctl.c:753:12: error: invalid storage class for function 'proc_sys_readdir'
     753 | static int proc_sys_readdir(struct file *file, struct dir_context *ctx)
         |            ^~~~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:782:12: error: invalid storage class for function 'proc_sys_permission'
     782 | static int proc_sys_permission(struct inode *inode, int mask)
         |            ^~~~~~~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:810:12: error: invalid storage class for function 'proc_sys_setattr'
     810 | static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
         |            ^~~~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:827:12: error: invalid storage class for function 'proc_sys_getattr'
     827 | static int proc_sys_getattr(const struct path *path, struct kstat *stat,
         |            ^~~~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:846:11: error: initializer element is not constant
     846 |  .open  = proc_sys_open,
         |           ^~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:846:11: note: (near initialization for 'proc_sys_file_operations.open')
   fs/proc/proc_sysctl.c:847:11: error: initializer element is not constant
     847 |  .poll  = proc_sys_poll,
         |           ^~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:847:11: note: (near initialization for 'proc_sys_file_operations.poll')
   fs/proc/proc_sysctl.c:848:11: error: initializer element is not constant
     848 |  .read  = proc_sys_read,
         |           ^~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:848:11: note: (near initialization for 'proc_sys_file_operations.read')
   fs/proc/proc_sysctl.c:849:12: error: initializer element is not constant
     849 |  .write  = proc_sys_write,
         |            ^~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:849:12: note: (near initialization for 'proc_sys_file_operations.write')
   fs/proc/proc_sysctl.c:855:20: error: initializer element is not constant
     855 |  .iterate_shared = proc_sys_readdir,
         |                    ^~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:855:20: note: (near initialization for 'proc_sys_dir_file_operations.iterate_shared')
   fs/proc/proc_sysctl.c:860:16: error: initializer element is not constant
     860 |  .permission = proc_sys_permission,
         |                ^~~~~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:860:16: note: (near initialization for 'proc_sys_inode_operations.permission')
   fs/proc/proc_sysctl.c:861:13: error: initializer element is not constant
     861 |  .setattr = proc_sys_setattr,
         |             ^~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:861:13: note: (near initialization for 'proc_sys_inode_operations.setattr')
   fs/proc/proc_sysctl.c:862:13: error: initializer element is not constant
     862 |  .getattr = proc_sys_getattr,
         |             ^~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:862:13: note: (near initialization for 'proc_sys_inode_operations.getattr')
   fs/proc/proc_sysctl.c:867:16: error: initializer element is not constant
     867 |  .permission = proc_sys_permission,
         |                ^~~~~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:867:16: note: (near initialization for 'proc_sys_dir_operations.permission')
   fs/proc/proc_sysctl.c:868:13: error: initializer element is not constant
     868 |  .setattr = proc_sys_setattr,
         |             ^~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:868:13: note: (near initialization for 'proc_sys_dir_operations.setattr')
   fs/proc/proc_sysctl.c:869:13: error: initializer element is not constant
     869 |  .getattr = proc_sys_getattr,
         |             ^~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:869:13: note: (near initialization for 'proc_sys_dir_operations.getattr')
>> fs/proc/proc_sysctl.c:872:12: error: invalid storage class for function 'proc_sys_revalidate'
     872 | static int proc_sys_revalidate(struct dentry *dentry, unsigned int flags)
         |            ^~~~~~~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:879:12: error: invalid storage class for function 'proc_sys_delete'
     879 | static int proc_sys_delete(const struct dentry *dentry)
         |            ^~~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:884:12: error: invalid storage class for function 'sysctl_is_seen'
     884 | static int sysctl_is_seen(struct ctl_table_header *p)
         |            ^~~~~~~~~~~~~~
>> fs/proc/proc_sysctl.c:899:12: error: invalid storage class for function 'proc_sys_compare'
     899 | static int proc_sys_compare(const struct dentry *dentry,
         |            ^~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:920:18: error: initializer element is not constant
     920 |  .d_revalidate = proc_sys_revalidate,
         |                  ^~~~~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:920:18: note: (near initialization for 'proc_sys_dentry_operations.d_revalidate')
   fs/proc/proc_sysctl.c:921:14: error: initializer element is not constant
     921 |  .d_delete = proc_sys_delete,
         |              ^~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:921:14: note: (near initialization for 'proc_sys_dentry_operations.d_delete')
   fs/proc/proc_sysctl.c:922:15: error: initializer element is not constant
     922 |  .d_compare = proc_sys_compare,
         |               ^~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:922:15: note: (near initialization for 'proc_sys_dentry_operations.d_compare')
>> fs/proc/proc_sysctl.c:925:24: error: invalid storage class for function 'find_subdir'
     925 | static struct ctl_dir *find_subdir(struct ctl_dir *dir,
         |                        ^~~~~~~~~~~
>> fs/proc/proc_sysctl.c:939:24: error: invalid storage class for function 'new_dir'
     939 | static struct ctl_dir *new_dir(struct ctl_table_set *set,
         |                        ^~~~~~~
>> fs/proc/proc_sysctl.c:977:24: error: invalid storage class for function 'get_subdir'
     977 | static struct ctl_dir *get_subdir(struct ctl_dir *dir,
         |                        ^~~~~~~~~~
>> fs/proc/proc_sysctl.c:1027:24: error: invalid storage class for function 'xlate_dir'
    1027 | static struct ctl_dir *xlate_dir(struct ctl_table_set *set, struct ctl_dir *dir)
         |                        ^~~~~~~~~
   fs/proc/proc_sysctl.c:1040:12: error: invalid storage class for function 'sysctl_follow_link'
    1040 | static int sysctl_follow_link(struct ctl_table_header **phead,
         |            ^~~~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1074:12: error: invalid storage class for function 'sysctl_err'
    1074 | static int sysctl_err(const char *path, struct ctl_table *table, char *fmt, ...)
         |            ^~~~~~~~~~
   fs/proc/proc_sysctl.c:1090:12: error: invalid storage class for function 'sysctl_check_table_array'
    1090 | static int sysctl_check_table_array(const char *path, struct ctl_table *table)
         |            ^~~~~~~~~~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1103:12: error: invalid storage class for function 'sysctl_check_table'
    1103 | static int sysctl_check_table(const char *path, struct ctl_table *table)
         |            ^~~~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1137:33: error: invalid storage class for function 'new_links'
    1137 | static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
         |                                 ^~~~~~~~~
   fs/proc/proc_sysctl.c:1180:13: error: invalid storage class for function 'get_links'
    1180 | static bool get_links(struct ctl_dir *dir,
         |             ^~~~~~~~~
   fs/proc/proc_sysctl.c:1208:12: error: invalid storage class for function 'insert_links'
    1208 | static int insert_links(struct ctl_table_header *head)
         |            ^~~~~~~~~~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/kernel.h:8,
                    from include/linux/list.h:9,
                    from include/linux/sysctl.h:25,
                    from fs/proc/proc_sysctl.c:6:
   fs/proc/proc_sysctl.c:1373:15: error: non-static declaration of 'register_sysctl' follows static declaration
    1373 | EXPORT_SYMBOL(register_sysctl);
         |               ^~~~~~~~~~~~~~~
   include/linux/export.h:98:21: note: in definition of macro '___EXPORT_SYMBOL'
      98 |  extern typeof(sym) sym;       \
         |                     ^~~
   include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
     155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
         |                                  ^~~~~~~~~~~~~~~
   include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL'
     158 | #define EXPORT_SYMBOL(sym)  _EXPORT_SYMBOL(sym, "")
         |                             ^~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1373:1: note: in expansion of macro 'EXPORT_SYMBOL'
    1373 | EXPORT_SYMBOL(register_sysctl);
         | ^~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1368:26: note: previous definition of 'register_sysctl' was here
    1368 | struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
         |                          ^~~~~~~~~~~~~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/kernel.h:8,
                    from include/linux/list.h:9,
                    from include/linux/sysctl.h:25,
                    from fs/proc/proc_sysctl.c:6:
   include/linux/export.h:67:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
      67 |  static const struct kernel_symbol __ksymtab_##sym  \
         |  ^~~~~~
   include/linux/export.h:108:2: note: in expansion of macro '__KSYMTAB_ENTRY'
     108 |  __KSYMTAB_ENTRY(sym, sec)
         |  ^~~~~~~~~~~~~~~
   include/linux/export.h:147:39: note: in expansion of macro '___EXPORT_SYMBOL'
     147 | #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns)
         |                                       ^~~~~~~~~~~~~~~~
   include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
     155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
         |                                  ^~~~~~~~~~~~~~~
   include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL'
     158 | #define EXPORT_SYMBOL(sym)  _EXPORT_SYMBOL(sym, "")
         |                             ^~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1373:1: note: in expansion of macro 'EXPORT_SYMBOL'
    1373 | EXPORT_SYMBOL(register_sysctl);
         | ^~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1375:14: error: invalid storage class for function 'append_path'
    1375 | static char *append_path(const char *path, char *pos, const char *name)
         |              ^~~~~~~~~~~
   fs/proc/proc_sysctl.c:1388:12: error: invalid storage class for function 'count_subheaders'
    1388 | static int count_subheaders(struct ctl_table *table)
         |            ^~~~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1407:12: error: invalid storage class for function 'register_leaf_sysctl_tables'
    1407 | static int register_leaf_sysctl_tables(const char *path, char *pos,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/kernel.h:8,
                    from include/linux/list.h:9,
                    from include/linux/sysctl.h:25,
                    from fs/proc/proc_sysctl.c:6:
   fs/proc/proc_sysctl.c:1569:15: error: non-static declaration of 'register_sysctl_paths' follows static declaration
    1569 | EXPORT_SYMBOL(register_sysctl_paths);
         |               ^~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:98:21: note: in definition of macro '___EXPORT_SYMBOL'
      98 |  extern typeof(sym) sym;       \
         |                     ^~~
   include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
     155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
         |                                  ^~~~~~~~~~~~~~~
   include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL'
     158 | #define EXPORT_SYMBOL(sym)  _EXPORT_SYMBOL(sym, "")
         |                             ^~~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1569:1: note: in expansion of macro 'EXPORT_SYMBOL'
    1569 | EXPORT_SYMBOL(register_sysctl_paths);
         | ^~~~~~~~~~~~~
   fs/proc/proc_sysctl.c:1563:26: note: previous definition of 'register_sysctl_paths' was here
    1563 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
--
   kernel/bpf/cgroup.c: In function '__cgroup_bpf_run_filter_sysctl':
>> kernel/bpf/cgroup.c:1173:64: error: 'pos' undeclared (first use in this function); did you mean 'ppos'?
    1173 |  if (table->proc_handler(table, 0, ctx.cur_val, &ctx.cur_len, &pos)) {
         |                                                                ^~~
         |                                                                ppos
   kernel/bpf/cgroup.c:1173:64: note: each undeclared identifier is reported only once for each function it appears in

vim +/proc_sys_read +602 fs/proc/proc_sysctl.c

77b14db502cb85 Eric W. Biederman 2007-02-14  601  
7708bfb1c855f2 Pavel Emelyanov   2008-04-29 @602  static ssize_t proc_sys_read(struct file *filp, char __user *buf,
77b14db502cb85 Eric W. Biederman 2007-02-14  603  				size_t count, loff_t *ppos)
77b14db502cb85 Eric W. Biederman 2007-02-14  604  {
7708bfb1c855f2 Pavel Emelyanov   2008-04-29  605  	return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 0);
7708bfb1c855f2 Pavel Emelyanov   2008-04-29  606  }
77b14db502cb85 Eric W. Biederman 2007-02-14  607  
7708bfb1c855f2 Pavel Emelyanov   2008-04-29 @608  static ssize_t proc_sys_write(struct file *filp, const char __user *buf,
7708bfb1c855f2 Pavel Emelyanov   2008-04-29  609  				size_t count, loff_t *ppos)
7708bfb1c855f2 Pavel Emelyanov   2008-04-29  610  {
7708bfb1c855f2 Pavel Emelyanov   2008-04-29  611  	return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 1);
77b14db502cb85 Eric W. Biederman 2007-02-14  612  }
77b14db502cb85 Eric W. Biederman 2007-02-14  613  
f1ecf06854a66e Lucas De Marchi   2011-11-02 @614  static int proc_sys_open(struct inode *inode, struct file *filp)
f1ecf06854a66e Lucas De Marchi   2011-11-02  615  {
4e474a00d7ff74 Lucas De Marchi   2012-03-22  616  	struct ctl_table_header *head = grab_header(inode);
f1ecf06854a66e Lucas De Marchi   2011-11-02  617  	struct ctl_table *table = PROC_I(inode)->sysctl_entry;
f1ecf06854a66e Lucas De Marchi   2011-11-02  618  
4e474a00d7ff74 Lucas De Marchi   2012-03-22  619  	/* sysctl was unregistered */
4e474a00d7ff74 Lucas De Marchi   2012-03-22  620  	if (IS_ERR(head))
4e474a00d7ff74 Lucas De Marchi   2012-03-22  621  		return PTR_ERR(head);
4e474a00d7ff74 Lucas De Marchi   2012-03-22  622  
f1ecf06854a66e Lucas De Marchi   2011-11-02  623  	if (table->poll)
f1ecf06854a66e Lucas De Marchi   2011-11-02  624  		filp->private_data = proc_sys_poll_event(table->poll);
f1ecf06854a66e Lucas De Marchi   2011-11-02  625  
4e474a00d7ff74 Lucas De Marchi   2012-03-22  626  	sysctl_head_finish(head);
4e474a00d7ff74 Lucas De Marchi   2012-03-22  627  
f1ecf06854a66e Lucas De Marchi   2011-11-02  628  	return 0;
f1ecf06854a66e Lucas De Marchi   2011-11-02  629  }
f1ecf06854a66e Lucas De Marchi   2011-11-02  630  
076ccb76e1a6cf Al Viro           2017-07-03 @631  static __poll_t proc_sys_poll(struct file *filp, poll_table *wait)
f1ecf06854a66e Lucas De Marchi   2011-11-02  632  {
496ad9aa8ef448 Al Viro           2013-01-23  633  	struct inode *inode = file_inode(filp);
4e474a00d7ff74 Lucas De Marchi   2012-03-22  634  	struct ctl_table_header *head = grab_header(inode);
f1ecf06854a66e Lucas De Marchi   2011-11-02  635  	struct ctl_table *table = PROC_I(inode)->sysctl_entry;
076ccb76e1a6cf Al Viro           2017-07-03  636  	__poll_t ret = DEFAULT_POLLMASK;
4e474a00d7ff74 Lucas De Marchi   2012-03-22  637  	unsigned long event;
4e474a00d7ff74 Lucas De Marchi   2012-03-22  638  
4e474a00d7ff74 Lucas De Marchi   2012-03-22  639  	/* sysctl was unregistered */
4e474a00d7ff74 Lucas De Marchi   2012-03-22  640  	if (IS_ERR(head))
a9a08845e9acbd Linus Torvalds    2018-02-11  641  		return EPOLLERR | EPOLLHUP;
f1ecf06854a66e Lucas De Marchi   2011-11-02  642  
f1ecf06854a66e Lucas De Marchi   2011-11-02  643  	if (!table->proc_handler)
f1ecf06854a66e Lucas De Marchi   2011-11-02  644  		goto out;
f1ecf06854a66e Lucas De Marchi   2011-11-02  645  
f1ecf06854a66e Lucas De Marchi   2011-11-02  646  	if (!table->poll)
f1ecf06854a66e Lucas De Marchi   2011-11-02  647  		goto out;
f1ecf06854a66e Lucas De Marchi   2011-11-02  648  
4e474a00d7ff74 Lucas De Marchi   2012-03-22  649  	event = (unsigned long)filp->private_data;
f1ecf06854a66e Lucas De Marchi   2011-11-02  650  	poll_wait(filp, &table->poll->wait, wait);
f1ecf06854a66e Lucas De Marchi   2011-11-02  651  
f1ecf06854a66e Lucas De Marchi   2011-11-02  652  	if (event != atomic_read(&table->poll->event)) {
f1ecf06854a66e Lucas De Marchi   2011-11-02  653  		filp->private_data = proc_sys_poll_event(table->poll);
a9a08845e9acbd Linus Torvalds    2018-02-11  654  		ret = EPOLLIN | EPOLLRDNORM | EPOLLERR | EPOLLPRI;
f1ecf06854a66e Lucas De Marchi   2011-11-02  655  	}
f1ecf06854a66e Lucas De Marchi   2011-11-02  656  
f1ecf06854a66e Lucas De Marchi   2011-11-02  657  out:
4e474a00d7ff74 Lucas De Marchi   2012-03-22  658  	sysctl_head_finish(head);
4e474a00d7ff74 Lucas De Marchi   2012-03-22  659  
f1ecf06854a66e Lucas De Marchi   2011-11-02  660  	return ret;
f1ecf06854a66e Lucas De Marchi   2011-11-02  661  }
77b14db502cb85 Eric W. Biederman 2007-02-14  662  
f0c3b5093addc8 Al Viro           2013-05-16 @663  static bool proc_sys_fill_cache(struct file *file,
f0c3b5093addc8 Al Viro           2013-05-16  664  				struct dir_context *ctx,
9043476f726802 Al Viro           2008-07-15  665  				struct ctl_table_header *head,
9043476f726802 Al Viro           2008-07-15  666  				struct ctl_table *table)
77b14db502cb85 Eric W. Biederman 2007-02-14  667  {
f0c3b5093addc8 Al Viro           2013-05-16  668  	struct dentry *child, *dir = file->f_path.dentry;
77b14db502cb85 Eric W. Biederman 2007-02-14  669  	struct inode *inode;
77b14db502cb85 Eric W. Biederman 2007-02-14  670  	struct qstr qname;
77b14db502cb85 Eric W. Biederman 2007-02-14  671  	ino_t ino = 0;
77b14db502cb85 Eric W. Biederman 2007-02-14  672  	unsigned type = DT_UNKNOWN;
77b14db502cb85 Eric W. Biederman 2007-02-14  673  
77b14db502cb85 Eric W. Biederman 2007-02-14  674  	qname.name = table->procname;
77b14db502cb85 Eric W. Biederman 2007-02-14  675  	qname.len  = strlen(table->procname);
8387ff2577eb9e Linus Torvalds    2016-06-10  676  	qname.hash = full_name_hash(dir, qname.name, qname.len);
77b14db502cb85 Eric W. Biederman 2007-02-14  677  
77b14db502cb85 Eric W. Biederman 2007-02-14  678  	child = d_lookup(dir, &qname);
77b14db502cb85 Eric W. Biederman 2007-02-14  679  	if (!child) {
76aab3ab61f305 Al Viro           2016-04-20  680  		DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
76aab3ab61f305 Al Viro           2016-04-20  681  		child = d_alloc_parallel(dir, &qname, &wq);
76aab3ab61f305 Al Viro           2016-04-20  682  		if (IS_ERR(child))
76aab3ab61f305 Al Viro           2016-04-20  683  			return false;
76aab3ab61f305 Al Viro           2016-04-20  684  		if (d_in_lookup(child)) {
888e2b03ef5669 Al Viro           2018-05-03  685  			struct dentry *res;
9043476f726802 Al Viro           2008-07-15  686  			inode = proc_sys_make_inode(dir->d_sb, head, table);
ea5751ccd665a2 Ivan Delalande    2018-12-13  687  			if (IS_ERR(inode)) {
76aab3ab61f305 Al Viro           2016-04-20  688  				d_lookup_done(child);
9043476f726802 Al Viro           2008-07-15  689  				dput(child);
f0c3b5093addc8 Al Viro           2013-05-16  690  				return false;
76aab3ab61f305 Al Viro           2016-04-20  691  			}
fb045adb99d9b7 Nick Piggin       2011-01-07  692  			d_set_d_op(child, &proc_sys_dentry_operations);
888e2b03ef5669 Al Viro           2018-05-03  693  			res = d_splice_alias(inode, child);
888e2b03ef5669 Al Viro           2018-05-03  694  			d_lookup_done(child);
888e2b03ef5669 Al Viro           2018-05-03  695  			if (unlikely(res)) {
888e2b03ef5669 Al Viro           2018-05-03  696  				if (IS_ERR(res)) {
888e2b03ef5669 Al Viro           2018-05-03  697  					dput(child);
888e2b03ef5669 Al Viro           2018-05-03  698  					return false;
888e2b03ef5669 Al Viro           2018-05-03  699  				}
888e2b03ef5669 Al Viro           2018-05-03  700  				dput(child);
888e2b03ef5669 Al Viro           2018-05-03  701  				child = res;
888e2b03ef5669 Al Viro           2018-05-03  702  			}
77b14db502cb85 Eric W. Biederman 2007-02-14  703  		}
77b14db502cb85 Eric W. Biederman 2007-02-14  704  	}
2b0143b5c986be David Howells     2015-03-17  705  	inode = d_inode(child);
77b14db502cb85 Eric W. Biederman 2007-02-14  706  	ino  = inode->i_ino;
77b14db502cb85 Eric W. Biederman 2007-02-14  707  	type = inode->i_mode >> 12;
77b14db502cb85 Eric W. Biederman 2007-02-14  708  	dput(child);
f0c3b5093addc8 Al Viro           2013-05-16  709  	return dir_emit(ctx, qname.name, qname.len, ino, type);
9043476f726802 Al Viro           2008-07-15  710  }
9043476f726802 Al Viro           2008-07-15  711  
f0c3b5093addc8 Al Viro           2013-05-16 @712  static bool proc_sys_link_fill_cache(struct file *file,
f0c3b5093addc8 Al Viro           2013-05-16  713  				    struct dir_context *ctx,
0e47c99d7fe25e Eric W. Biederman 2012-01-07  714  				    struct ctl_table_header *head,
0e47c99d7fe25e Eric W. Biederman 2012-01-07  715  				    struct ctl_table *table)
0e47c99d7fe25e Eric W. Biederman 2012-01-07  716  {
f0c3b5093addc8 Al Viro           2013-05-16  717  	bool ret = true;
a0b0d1c345d031 Danilo Krummrich  2018-04-10  718  
0e47c99d7fe25e Eric W. Biederman 2012-01-07  719  	head = sysctl_head_grab(head);
a0b0d1c345d031 Danilo Krummrich  2018-04-10  720  	if (IS_ERR(head))
a0b0d1c345d031 Danilo Krummrich  2018-04-10  721  		return false;
0e47c99d7fe25e Eric W. Biederman 2012-01-07  722  
0e47c99d7fe25e Eric W. Biederman 2012-01-07  723  	/* It is not an error if we can not follow the link ignore it */
835b94e05c92e6 Danilo Krummrich  2018-04-10  724  	if (sysctl_follow_link(&head, &table))
0e47c99d7fe25e Eric W. Biederman 2012-01-07  725  		goto out;
0e47c99d7fe25e Eric W. Biederman 2012-01-07  726  
f0c3b5093addc8 Al Viro           2013-05-16  727  	ret = proc_sys_fill_cache(file, ctx, head, table);
0e47c99d7fe25e Eric W. Biederman 2012-01-07  728  out:
0e47c99d7fe25e Eric W. Biederman 2012-01-07  729  	sysctl_head_finish(head);
0e47c99d7fe25e Eric W. Biederman 2012-01-07  730  	return ret;
0e47c99d7fe25e Eric W. Biederman 2012-01-07  731  }
0e47c99d7fe25e Eric W. Biederman 2012-01-07  732  
e5eea0981a3840 Joe Perches       2014-08-08 @733  static int scan(struct ctl_table_header *head, struct ctl_table *table,
9043476f726802 Al Viro           2008-07-15  734  		unsigned long *pos, struct file *file,
f0c3b5093addc8 Al Viro           2013-05-16  735  		struct dir_context *ctx)
9043476f726802 Al Viro           2008-07-15  736  {
f0c3b5093addc8 Al Viro           2013-05-16  737  	bool res;
9043476f726802 Al Viro           2008-07-15  738  
f0c3b5093addc8 Al Viro           2013-05-16  739  	if ((*pos)++ < ctx->pos)
f0c3b5093addc8 Al Viro           2013-05-16  740  		return true;
9043476f726802 Al Viro           2008-07-15  741  
0e47c99d7fe25e Eric W. Biederman 2012-01-07  742  	if (unlikely(S_ISLNK(table->mode)))
f0c3b5093addc8 Al Viro           2013-05-16  743  		res = proc_sys_link_fill_cache(file, ctx, head, table);
0e47c99d7fe25e Eric W. Biederman 2012-01-07  744  	else
f0c3b5093addc8 Al Viro           2013-05-16  745  		res = proc_sys_fill_cache(file, ctx, head, table);
9043476f726802 Al Viro           2008-07-15  746  
f0c3b5093addc8 Al Viro           2013-05-16  747  	if (res)
f0c3b5093addc8 Al Viro           2013-05-16  748  		ctx->pos = *pos;
6a75ce167c53b4 Eric W. Biederman 2012-01-18  749  
6a75ce167c53b4 Eric W. Biederman 2012-01-18  750  	return res;
77b14db502cb85 Eric W. Biederman 2007-02-14  751  }
77b14db502cb85 Eric W. Biederman 2007-02-14  752  
f0c3b5093addc8 Al Viro           2013-05-16 @753  static int proc_sys_readdir(struct file *file, struct dir_context *ctx)
77b14db502cb85 Eric W. Biederman 2007-02-14  754  {
f0c3b5093addc8 Al Viro           2013-05-16  755  	struct ctl_table_header *head = grab_header(file_inode(file));
9043476f726802 Al Viro           2008-07-15  756  	struct ctl_table_header *h = NULL;
6a75ce167c53b4 Eric W. Biederman 2012-01-18  757  	struct ctl_table *entry;
7ec66d06362da7 Eric W. Biederman 2011-12-29  758  	struct ctl_dir *ctl_dir;
77b14db502cb85 Eric W. Biederman 2007-02-14  759  	unsigned long pos;
77b14db502cb85 Eric W. Biederman 2007-02-14  760  
9043476f726802 Al Viro           2008-07-15  761  	if (IS_ERR(head))
9043476f726802 Al Viro           2008-07-15  762  		return PTR_ERR(head);
9043476f726802 Al Viro           2008-07-15  763  
7ec66d06362da7 Eric W. Biederman 2011-12-29  764  	ctl_dir = container_of(head, struct ctl_dir, header);
77b14db502cb85 Eric W. Biederman 2007-02-14  765  
f0c3b5093addc8 Al Viro           2013-05-16  766  	if (!dir_emit_dots(file, ctx))
93362fa47fe98b Zhou Chengming    2017-01-06  767  		goto out;
f0c3b5093addc8 Al Viro           2013-05-16  768  
77b14db502cb85 Eric W. Biederman 2007-02-14  769  	pos = 2;
77b14db502cb85 Eric W. Biederman 2007-02-14  770  
7ec66d06362da7 Eric W. Biederman 2011-12-29  771  	for (first_entry(ctl_dir, &h, &entry); h; next_entry(&h, &entry)) {
f0c3b5093addc8 Al Viro           2013-05-16  772  		if (!scan(h, entry, &pos, file, ctx)) {
9043476f726802 Al Viro           2008-07-15  773  			sysctl_head_finish(h);
9043476f726802 Al Viro           2008-07-15  774  			break;
77b14db502cb85 Eric W. Biederman 2007-02-14  775  		}
77b14db502cb85 Eric W. Biederman 2007-02-14  776  	}
93362fa47fe98b Zhou Chengming    2017-01-06  777  out:
77b14db502cb85 Eric W. Biederman 2007-02-14  778  	sysctl_head_finish(head);
f0c3b5093addc8 Al Viro           2013-05-16  779  	return 0;
77b14db502cb85 Eric W. Biederman 2007-02-14  780  }
77b14db502cb85 Eric W. Biederman 2007-02-14  781  
10556cb21a0d0b Al Viro           2011-06-20 @782  static int proc_sys_permission(struct inode *inode, int mask)
77b14db502cb85 Eric W. Biederman 2007-02-14  783  {
77b14db502cb85 Eric W. Biederman 2007-02-14  784  	/*
77b14db502cb85 Eric W. Biederman 2007-02-14  785  	 * sysctl entries that are not writeable,
77b14db502cb85 Eric W. Biederman 2007-02-14  786  	 * are _NOT_ writeable, capabilities or not.
77b14db502cb85 Eric W. Biederman 2007-02-14  787  	 */
f696a3659fc4b3 Miklos Szeredi    2008-07-31  788  	struct ctl_table_header *head;
f696a3659fc4b3 Miklos Szeredi    2008-07-31  789  	struct ctl_table *table;
77b14db502cb85 Eric W. Biederman 2007-02-14  790  	int error;
77b14db502cb85 Eric W. Biederman 2007-02-14  791  
f696a3659fc4b3 Miklos Szeredi    2008-07-31  792  	/* Executable files are not allowed under /proc/sys/ */
f696a3659fc4b3 Miklos Szeredi    2008-07-31  793  	if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))
f696a3659fc4b3 Miklos Szeredi    2008-07-31  794  		return -EACCES;
f696a3659fc4b3 Miklos Szeredi    2008-07-31  795  
f696a3659fc4b3 Miklos Szeredi    2008-07-31  796  	head = grab_header(inode);
9043476f726802 Al Viro           2008-07-15  797  	if (IS_ERR(head))
9043476f726802 Al Viro           2008-07-15  798  		return PTR_ERR(head);
77b14db502cb85 Eric W. Biederman 2007-02-14  799  
f696a3659fc4b3 Miklos Szeredi    2008-07-31  800  	table = PROC_I(inode)->sysctl_entry;
9043476f726802 Al Viro           2008-07-15  801  	if (!table) /* global root - r-xr-xr-x */
9043476f726802 Al Viro           2008-07-15  802  		error = mask & MAY_WRITE ? -EACCES : 0;
9043476f726802 Al Viro           2008-07-15  803  	else /* Use the permissions on the sysctl table entry */
73f7ef435934e9 Eric W. Biederman 2012-11-16  804  		error = sysctl_perm(head, table, mask & ~MAY_NOT_BLOCK);
9043476f726802 Al Viro           2008-07-15  805  
77b14db502cb85 Eric W. Biederman 2007-02-14  806  	sysctl_head_finish(head);
77b14db502cb85 Eric W. Biederman 2007-02-14  807  	return error;
77b14db502cb85 Eric W. Biederman 2007-02-14  808  }
77b14db502cb85 Eric W. Biederman 2007-02-14  809  

:::::: The code at line 602 was first introduced by commit
:::::: 7708bfb1c855f2a076ef71cc21647deea022ebe7 sysctl: merge equal proc_sys_read and proc_sys_write

:::::: TO: Pavel Emelyanov <xemul@openvz.org>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 62548 bytes --]

                 reply	other threads:[~2020-04-14  3:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202004141122.GiPNCOUb%lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild-all@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.