Hi Casey,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.0-rc7]
[cannot apply to pcmoore-audit/next pcmoore-selinux/next zohar-integrity/next-integrity
next-20220927]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url:
https://github.com/intel-lab-lkp/linux/commits/Casey-Schaufler/LSM-Identi...
base:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
46452d3786a82bd732ba73fb308ae5cbe4e1e591
config: s390-defconfig
compiler: s390-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://github.com/intel-lab-lkp/linux/commit/6f957bc7939d85848cbe2a2a1c1...
git remote add linux-review
https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review
Casey-Schaufler/LSM-Identify-modules-by-more-than-name/20220928-045406
git checkout 6f957bc7939d85848cbe2a2a1c1007e344629ae0
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir
ARCH=s390 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
security/lsm_syscalls.c:51: warning: expecting prototype for lsm_self_attr(). Prototype
was for sys_lsm_self_attr() instead
> security/lsm_syscalls.c:175: warning: expecting prototype for
lsm_module_list(). Prototype was for sys_lsm_module_list() instead
vim +175 security/lsm_syscalls.c
33
34 /**
35 * lsm_self_attr - Return current task's security module attributes
36 * @ctx: the LSM contexts
37 * @size: size of @ctx, updated on return
38 * @flags: reserved for future use, must be zero
39 *
40 * Returns the calling task's LSM contexts. On success this
41 * function returns the number of @ctx array elements. This value
42 * may be zero if there are no LSM contexts assigned. If @size is
43 * insufficient to contain the return data -E2BIG is returned and
44 * @size is set to the minimum required size. In all other cases
45 * a negative value indicating the error is returned.
46 */
47 SYSCALL_DEFINE3(lsm_self_attr,
48 struct lsm_ctx __user *, ctx,
49 size_t __user *, size,
50 int, flags)
51 {
52 struct lsm_ctx *final = NULL;
53 struct lsm_ctx *interum;
54 struct lsm_ctx *ip;
55 void *curr;
56 char **interum_ctx;
57 char *cp;
58 size_t total_size = 0;
59 int count = 0;
60 int attr;
61 int len;
62 int rc = 0;
63 int i;
64
65 interum = kzalloc(ARRAY_SIZE(lsm_attr_names) * lsm_id *
66 sizeof(*interum), GFP_KERNEL);
67 if (interum == NULL)
68 return -ENOMEM;
69 ip = interum;
70
71 interum_ctx = kzalloc(ARRAY_SIZE(lsm_attr_names) * lsm_id *
72 sizeof(*interum_ctx), GFP_KERNEL);
73 if (interum_ctx == NULL) {
74 kfree(interum);
75 return -ENOMEM;
76 }
77
78 for (attr = 0; attr < ARRAY_SIZE(lsm_attr_names); attr++) {
79 for (i = 0; i < lsm_id; i++) {
80 if ((lsm_idlist[i]->features &
81 lsm_attr_names[attr].feature) == 0)
82 continue;
83
84 len = security_getprocattr(current, lsm_idlist[i]->id,
85 lsm_attr_names[attr].name,
86 &cp);
87 if (len <= 0)
88 continue;
89
90 ip->id = lsm_idlist[i]->id;
91 ip->flags = lsm_attr_names[attr].feature;
92 /* space for terminating \0 is allocated below */
93 ip->ctx_len = len + 1;
94 interum_ctx[count] = cp;
95 /*
96 * Security modules have been inconsistent about
97 * including the \0 terminator in the size. The
98 * context len has been adjusted to ensure there
99 * is one.
100 * At least one security module adds a \n at the
101 * end of a context to make it look nicer. Change
102 * that to a \0 so that user space doesn't have to
103 * work around it. Because of this meddling it is
104 * safe to assume that lsm_ctx.name is terminated
105 * and that strlen(lsm_ctx.name) < lsm.ctx_len.
106 */
107 total_size += sizeof(*interum) + ip->ctx_len;
108 cp = strnchr(cp, len, '\n');
109 if (cp != NULL)
110 *cp = '\0';
111 ip++;
112 count++;
113 }
114 }
115
116 if (count == 0)
117 goto free_out;
118
119 final = kzalloc(total_size, GFP_KERNEL);
120 if (final == NULL) {
121 rc = -ENOMEM;
122 goto free_out;
123 }
124
125 curr = final;
126 ip = interum;
127 for (i = 0; i < count; i++) {
128 memcpy(curr, ip, sizeof(*interum));
129 curr += sizeof(*interum);
130 memcpy(curr, interum_ctx[i], ip->ctx_len);
131 curr += ip->ctx_len;
132 ip++;
133 }
134
135 if (get_user(len, size)) {
136 rc = -EFAULT;
137 goto free_out;
138 }
139 if (total_size > len) {
140 rc = -ERANGE;
141 goto free_out;
142 }
143 if (copy_to_user(ctx, final, total_size) != 0 ||
144 put_user(total_size, size) != 0)
145 rc = -EFAULT;
146 else
147 rc = count;
148
149 free_out:
150 for (i = 0; i < count; i++)
151 kfree(interum_ctx[i]);
152 kfree(interum_ctx);
153 kfree(interum);
154 kfree(final);
155 return rc;
156 }
157
158 /**
159 * lsm_module_list - Return a list of the active security modules
160 * @ids: the LSM module ids
161 * @size: size of @ids, updated on return
162 * @flags: reserved for future use, must be zero
163 *
164 * Returns a list of the active LSM ids. On success this function
165 * returns the number of @ids array elements. This value may be zero
166 * if there are no LSMs active. If @size is insufficient to contain
167 * the return data -E2BIG is returned and @size is set to the minimum
168 * required size. In all other cases a negative value indicating the
169 * error is returned.
170 */
171 SYSCALL_DEFINE3(lsm_module_list,
172 unsigned int __user *, ids,
173 size_t __user *, size,
174 int, flags)
175 {
--
0-DAY CI Kernel Test Service
https://01.org/lkp