lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 21 Nov 2023 16:21:26 +0800 From: kernel test robot <lkp@...el.com> To: David Howells <dhowells@...hat.com> Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org Subject: fs/proc/proc_net.c:130: warning: Function parameter or member 'state_size' not described in 'proc_create_net_data_write' Hi David, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 98b1cc82c4affc16f5598d4fa14b1858671b2263 commit: 564def71765caf65040f926c0783b9c27cc6c087 proc: Add a way to make network proc files writable date: 6 years ago config: x86_64-buildonly-randconfig-001-20231012 (https://download.01.org/0day-ci/archive/20231121/202311211605.jYnwq7JO-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231121/202311211605.jYnwq7JO-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@...el.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311211605.jYnwq7JO-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from arch/x86/include/asm/bug.h:83, from include/linux/bug.h:5, from include/linux/thread_info.h:12, from arch/x86/include/asm/preempt.h:7, from include/linux/preempt.h:81, from include/linux/rcupdate.h:40, from include/linux/rculist.h:11, from include/linux/pid.h:5, from include/linux/sched.h:14, from include/linux/uaccess.h:5, from fs/proc/proc_net.c:11: fs/proc/proc_net.c: In function 'seq_open_net': fs/proc/proc_net.c:47:33: warning: comparison is always false due to limited range of data type [-Wtype-limits] 47 | WARN_ON_ONCE(state_size < sizeof(*p)); | ^ include/asm-generic/bug.h:69:32: note: in definition of macro 'WARN_ON_ONCE' 69 | int __ret_warn_on = !!(condition); \ | ^~~~~~~~~ >> fs/proc/proc_net.c:130: warning: Function parameter or member 'state_size' not described in 'proc_create_net_data_write' vim +130 fs/proc/proc_net.c > 11 #include <linux/uaccess.h> 12 13 #include <linux/errno.h> 14 #include <linux/time.h> 15 #include <linux/proc_fs.h> 16 #include <linux/stat.h> 17 #include <linux/slab.h> 18 #include <linux/init.h> 19 #include <linux/sched.h> 20 #include <linux/sched/task.h> 21 #include <linux/module.h> 22 #include <linux/bitops.h> 23 #include <linux/mount.h> 24 #include <linux/nsproxy.h> 25 #include <linux/uidgid.h> 26 #include <net/net_namespace.h> 27 #include <linux/seq_file.h> 28 29 #include "internal.h" 30 31 static inline struct net *PDE_NET(struct proc_dir_entry *pde) 32 { 33 return pde->parent->data; 34 } 35 36 static struct net *get_proc_net(const struct inode *inode) 37 { 38 return maybe_get_net(PDE_NET(PDE(inode))); 39 } 40 41 static int seq_open_net(struct inode *inode, struct file *file) 42 { 43 unsigned int state_size = PDE(inode)->state_size; 44 struct seq_net_private *p; 45 struct net *net; 46 47 WARN_ON_ONCE(state_size < sizeof(*p)); 48 49 if (file->f_mode & FMODE_WRITE && !PDE(inode)->write) 50 return -EACCES; 51 52 net = get_proc_net(inode); 53 if (!net) 54 return -ENXIO; 55 56 p = __seq_open_private(file, PDE(inode)->seq_ops, state_size); 57 if (!p) { 58 put_net(net); 59 return -ENOMEM; 60 } 61 #ifdef CONFIG_NET_NS 62 p->net = net; 63 #endif 64 return 0; 65 } 66 67 static int seq_release_net(struct inode *ino, struct file *f) 68 { 69 struct seq_file *seq = f->private_data; 70 71 put_net(seq_file_net(seq)); 72 seq_release_private(ino, f); 73 return 0; 74 } 75 76 static const struct file_operations proc_net_seq_fops = { 77 .open = seq_open_net, 78 .read = seq_read, 79 .write = proc_simple_write, 80 .llseek = seq_lseek, 81 .release = seq_release_net, 82 }; 83 84 struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode, 85 struct proc_dir_entry *parent, const struct seq_operations *ops, 86 unsigned int state_size, void *data) 87 { 88 struct proc_dir_entry *p; 89 90 p = proc_create_reg(name, mode, &parent, data); 91 if (!p) 92 return NULL; 93 p->proc_fops = &proc_net_seq_fops; 94 p->seq_ops = ops; 95 p->state_size = state_size; 96 return proc_register(parent, p); 97 } 98 EXPORT_SYMBOL_GPL(proc_create_net_data); 99 100 /** 101 * proc_create_net_data_write - Create a writable net_ns-specific proc file 102 * @name: The name of the file. 103 * @mode: The file's access mode. 104 * @parent: The parent directory in which to create. 105 * @ops: The seq_file ops with which to read the file. 106 * @write: The write method which which to 'modify' the file. 107 * @data: Data for retrieval by PDE_DATA(). 108 * 109 * Create a network namespaced proc file in the @parent directory with the 110 * specified @name and @mode that allows reading of a file that displays a 111 * series of elements and also provides for the file accepting writes that have 112 * some arbitrary effect. 113 * 114 * The functions in the @ops table are used to iterate over items to be 115 * presented and extract the readable content using the seq_file interface. 116 * 117 * The @write function is called with the data copied into a kernel space 118 * scratch buffer and has a NUL appended for convenience. The buffer may be 119 * modified by the @write function. @write should return 0 on success. 120 * 121 * The @data value is accessible from the @show and @write functions by calling 122 * PDE_DATA() on the file inode. The network namespace must be accessed by 123 * calling seq_file_net() on the seq_file struct. 124 */ 125 struct proc_dir_entry *proc_create_net_data_write(const char *name, umode_t mode, 126 struct proc_dir_entry *parent, 127 const struct seq_operations *ops, 128 proc_write_t write, 129 unsigned int state_size, void *data) > 130 { 131 struct proc_dir_entry *p; 132 133 p = proc_create_reg(name, mode, &parent, data); 134 if (!p) 135 return NULL; 136 p->proc_fops = &proc_net_seq_fops; 137 p->seq_ops = ops; 138 p->state_size = state_size; 139 p->write = write; 140 return proc_register(parent, p); 141 } 142 EXPORT_SYMBOL_GPL(proc_create_net_data_write); 143 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists