2022-09-30 08:04:25

by kernel test robot

[permalink] [raw]
Subject: [ebiederm-user-namespace:unpriv-ipc-sysctls-for-v6.1 1/3] ipc/ipc_sysctl.c:228:14: error: implicit declaration of function 'current_euid' is invalid in C99

tree: https://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git unpriv-ipc-sysctls-for-v6.1
head: 7608b6a72ed04607cc832248cbd52fb5e68bd42c
commit: 54e1011bd95a49d8e68feb3aa4d29cc8a6d9a4a3 [1/3] sysctl: Allow change system v ipc sysctls inside ipc namespace
config: x86_64-randconfig-a016-20220926
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git/commit/?id=54e1011bd95a49d8e68feb3aa4d29cc8a6d9a4a3
git remote add ebiederm-user-namespace https://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git
git fetch --no-tags ebiederm-user-namespace unpriv-ipc-sysctls-for-v6.1
git checkout 54e1011bd95a49d8e68feb3aa4d29cc8a6d9a4a3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> ipc/ipc_sysctl.c:228:14: error: implicit declaration of function 'current_euid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (uid_eq(current_euid(), ns_root_uid))
^
ipc/ipc_sysctl.c:228:14: note: did you mean 'current_work'?
include/linux/workqueue.h:467:28: note: 'current_work' declared here
extern struct work_struct *current_work(void);
^
>> ipc/ipc_sysctl.c:228:14: error: passing 'int' to parameter of incompatible type 'kuid_t'
if (uid_eq(current_euid(), ns_root_uid))
^~~~~~~~~~~~~~
include/linux/uidgid.h:61:34: note: passing argument to parameter 'left' here
static inline bool uid_eq(kuid_t left, kuid_t right)
^
>> ipc/ipc_sysctl.c:231:12: error: implicit declaration of function 'in_egroup_p' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
else if (in_egroup_p(ns_root_gid))
^
3 errors generated.


vim +/current_euid +228 ipc/ipc_sysctl.c

206
207 static int ipc_permissions(struct ctl_table_header *head, struct ctl_table *table)
208 {
209 int mode = table->mode;
210
211 #ifdef CONFIG_CHECKPOINT_RESTORE
212 struct ipc_namespace *ns =
213 container_of(head->set, struct ipc_namespace, ipc_set);
214
215 if (((table->data == &ns->ids[IPC_SEM_IDS].next_id) ||
216 (table->data == &ns->ids[IPC_MSG_IDS].next_id) ||
217 (table->data == &ns->ids[IPC_SHM_IDS].next_id)) &&
218 checkpoint_restore_ns_capable(ns->user_ns))
219 mode = 0666;
220 else
221 #endif
222 {
223 kuid_t ns_root_uid;
224 kgid_t ns_root_gid;
225
226 ipc_set_ownership(head, table, &ns_root_uid, &ns_root_gid);
227
> 228 if (uid_eq(current_euid(), ns_root_uid))
229 mode >>= 6;
230
> 231 else if (in_egroup_p(ns_root_gid))
232 mode >>= 3;
233 }
234
235 mode &= 7;
236
237 return (mode << 6) | (mode << 3) | mode;
238 }
239

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (3.52 kB)
config (153.14 kB)
Download all attachments

2022-09-30 18:08:01

by Eric W. Biederman

[permalink] [raw]
Subject: [PATCH] ipc/ipc_sysctl: Add missing include of linux/cred.h


The kernel test robot recently reported[1][2] that in configurations
without CONFIG_COMPAT set the recent changes to ipc_permissions would
result in code that would not compile, as definitions present in
linux/cred.h were missing.

Include linux/cred.h explicitly in ipc/ipc_sysctl.c so that it builds
in all kernel configurations.

[1] https://lkml.kernel.org/r/[email protected]
[2] https://lkml.kernel.org/r/[email protected]
Reported-by: kernel test robot <[email protected]>
Fixes: 54e1011bd95a ("sysctl: Allow change system v ipc sysctls inside ipc namespace")
Signed-off-by: "Eric W. Biederman" <[email protected]>
---

I have corrected the build error by adding the following patch
to the topic branch.

ipc/ipc_sysctl.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
index 31282e0a630d..29c1d3ae2a5c 100644
--- a/ipc/ipc_sysctl.c
+++ b/ipc/ipc_sysctl.c
@@ -14,6 +14,7 @@
#include <linux/ipc_namespace.h>
#include <linux/msg.h>
#include <linux/slab.h>
+#include <linux/cred.h>
#include "util.h"

static int proc_ipc_dointvec_minmax_orphans(struct ctl_table *table, int write,
--
2.35.3

Eric