[selinuxproject-selinux:stable-5.15 1/1] kernel/params.c:103:27: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers

From: kernel test robot
Date: Thu Sep 16 2021 - 08:17:09 EST


tree: https://github.com/SELinuxProject/selinux-kernel stable-5.15
head: c491f0a471580712a4254adece400c3ebb3d8e44
commit: c491f0a471580712a4254adece400c3ebb3d8e44 [1/1] lockdown,selinux: fix wrong subject in some SELinux lockdown checks
config: arm-buildonly-randconfig-r005-20210916 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c8b3d7d6d6de37af68b2f379d0e37304f78e115f)
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
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/SELinuxProject/selinux-kernel/commit/c491f0a471580712a4254adece400c3ebb3d8e44
git remote add selinuxproject-selinux https://github.com/SELinuxProject/selinux-kernel
git fetch --no-tags selinuxproject-selinux stable-5.15
git checkout c491f0a471580712a4254adece400c3ebb3d8e44
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

>> kernel/params.c:103:27: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
security_locked_down(current_cred(), LOCKDOWN_MODULE_PARAMETERS))
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> fs/debugfs/inode.c:51:30: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
ret = security_locked_down(current_cred(), LOCKDOWN_DEBUGFS);
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> fs/debugfs/file.c:157:27: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
if (security_locked_down(current_cred(), LOCKDOWN_DEBUGFS))
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> drivers/char/mem.c:620:28: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
rc = security_locked_down(current_cred(), LOCKDOWN_DEV_MEM);
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> drivers/pcmcia/cistpl.c:1580:31: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
error = security_locked_down(current_cred(), LOCKDOWN_PCMCIA_CIS);
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> drivers/tty/serial/serial_core.c:843:33: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
retval = security_locked_down(current_cred(), LOCKDOWN_TIOCSSERIAL);
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> kernel/trace/ring_buffer.c:5883:27: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
if (security_locked_down(current_cred(), LOCKDOWN_TRACEFS)) {
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> kernel/trace/trace.c:489:29: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
ret = security_locked_down(current_cred(), LOCKDOWN_TRACEFS);
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
kernel/trace/trace.c:2074:27: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
if (security_locked_down(current_cred(), LOCKDOWN_TRACEFS)) {
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
kernel/trace/trace.c:9530:27: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
if (security_locked_down(current_cred(), LOCKDOWN_TRACEFS)) {
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
kernel/trace/trace.c:9992:27: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
if (security_locked_down(current_cred(), LOCKDOWN_TRACEFS)) {
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
4 errors generated.
--
>> kernel/trace/trace_stat.c:239:29: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
ret = security_locked_down(current_cred(), LOCKDOWN_TRACEFS);
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> kernel/trace/trace_printk.c:365:29: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
ret = security_locked_down(current_cred(), LOCKDOWN_TRACEFS);
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
--
>> kernel/trace/trace_events.c:2133:29: error: passing 'typeof (*((current_thread_info()->task)->cred)) *' (aka 'const struct cred *') to parameter of type 'struct cred *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
ret = security_locked_down(current_cred(), LOCKDOWN_TRACEFS);
^~~~~~~~~~~~~~
include/linux/cred.h:299:2: note: expanded from macro 'current_cred'
rcu_dereference_protected(current->cred, 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:587:2: note: expanded from macro 'rcu_dereference_protected'
__rcu_dereference_protected((p), (c), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:394:50: note: expanded from macro '__rcu_dereference_protected'
#define __rcu_dereference_protected(p, c, space) \
^
include/linux/security.h:1347:53: note: passing argument to parameter 'cred' here
static inline int security_locked_down(struct cred *cred, enum lockdown_reason what)
^
1 error generated.
..


vim +103 kernel/params.c

99
100 static bool param_check_unsafe(const struct kernel_param *kp)
101 {
102 if (kp->flags & KERNEL_PARAM_FL_HWPARAM &&
> 103 security_locked_down(current_cred(), LOCKDOWN_MODULE_PARAMETERS))
104 return false;
105
106 if (kp->flags & KERNEL_PARAM_FL_UNSAFE) {
107 pr_notice("Setting dangerous option %s - tainting kernel\n",
108 kp->name);
109 add_taint(TAINT_USER, LOCKDEP_STILL_OK);
110 }
111
112 return true;
113 }
114

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

Attachment: .config.gz
Description: application/gzip