* [linux-next:master 3417/14198] drivers/misc/lkdtm/cfi.c:100:27: sparse: sparse: Using plain integer as NULL pointer
@ 2022-05-28 2:15 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-05-28 2:15 UTC (permalink / raw)
To: Kees Cook; +Cc: kbuild-all, Linux Memory Management List, Dan Li
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: d3fde8ff50ab265749704bd7fbcf70d35235421f
commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [3417/14198] lkdtm: Add CFI_BACKWARD to test ROP mitigations
config: arc-randconfig-s031-20220527 (https://download.01.org/0day-ci/archive/20220528/202205281038.F1GyW2IY-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-14-g5a0004b5-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arc SHELL=/bin/bash drivers/misc/lkdtm/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/misc/lkdtm/cfi.c:100:27: sparse: sparse: Using plain integer as NULL pointer
drivers/misc/lkdtm/cfi.c:72:13: sparse: sparse: non size-preserving pointer to integer cast
drivers/misc/lkdtm/cfi.c:72:13: sparse: sparse: non size-preserving integer to pointer cast
drivers/misc/lkdtm/cfi.c:87:13: sparse: sparse: non size-preserving pointer to integer cast
drivers/misc/lkdtm/cfi.c:87:13: sparse: sparse: non size-preserving integer to pointer cast
vim +100 drivers/misc/lkdtm/cfi.c
96
97 static void lkdtm_CFI_BACKWARD(void)
98 {
99 /* Use calculated gotos to keep labels addressable. */
> 100 void *labels[] = {0, &&normal, &&redirected, &&check_normal, &&check_redirected};
101
102 pr_info("Attempting unchecked stack return address redirection ...\n");
103
104 /* Always false */
105 if (force_check) {
106 /*
107 * Prepare to call with NULLs to avoid parameters being treated as
108 * constants in -02.
109 */
110 set_return_addr_unchecked(NULL, NULL);
111 set_return_addr(NULL, NULL);
112 if (force_check)
113 goto *labels[1];
114 if (force_check)
115 goto *labels[2];
116 if (force_check)
117 goto *labels[3];
118 if (force_check)
119 goto *labels[4];
120 return;
121 }
122
123 /*
124 * Use fallthrough switch case to keep basic block ordering between
125 * set_return_addr*() and the label after it.
126 */
127 switch (force_check) {
128 case 0:
129 set_return_addr_unchecked(&&normal, &&redirected);
130 fallthrough;
131 case 1:
132 normal:
133 /* Always true */
134 if (!force_check) {
135 pr_err("FAIL: stack return address manipulation failed!\n");
136 /* If we can't redirect "normally", we can't test mitigations. */
137 return;
138 }
139 break;
140 default:
141 redirected:
142 pr_info("ok: redirected stack return address.\n");
143 break;
144 }
145
146 pr_info("Attempting checked stack return address redirection ...\n");
147
148 switch (force_check) {
149 case 0:
150 set_return_addr(&&check_normal, &&check_redirected);
151 fallthrough;
152 case 1:
153 check_normal:
154 /* Always true */
155 if (!force_check) {
156 pr_info("ok: control flow unchanged.\n");
157 return;
158 }
159
160 check_redirected:
161 pr_err("FAIL: stack return address was redirected!\n");
162 break;
163 }
164
165 if (IS_ENABLED(CONFIG_ARM64_PTR_AUTH_KERNEL)) {
166 pr_expected_config(CONFIG_ARM64_PTR_AUTH_KERNEL);
167 return;
168 }
169 if (IS_ENABLED(CONFIG_SHADOW_CALL_STACK)) {
170 pr_expected_config(CONFIG_SHADOW_CALL_STACK);
171 return;
172 }
173 pr_warn("This is probably expected, since this %s was built *without* %s=y nor %s=y\n",
174 lkdtm_kernel_info,
175 "CONFIG_ARM64_PTR_AUTH_KERNEL", "CONFIG_SHADOW_CALL_STACK");
176 }
177
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-28 2:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-28 2:15 [linux-next:master 3417/14198] drivers/misc/lkdtm/cfi.c:100:27: sparse: sparse: Using plain integer as NULL pointer kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox