Re: [PATCH v3 3/5] kernel hacking: new config NO_AUTO_INLINE to disable compiler auto-inline optimizations

kbuild test robot
2018-05-06T06:15:21Z

[-- Attachment #1: Type: text/plain, Size: 18596 bytes --]

Hi Changbin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.17-rc3 next-20180504]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/changbin-du-intel-com/kernel-hacking-GCC-optimization-for-better-debug-experience-Og/20180506-110946
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

arch/x86/entry/vsyscall/vsyscall_64.c: In function 'emulate_vsyscall':
>> arch/x86/entry/vsyscall/vsyscall_64.c:127:19: warning: 'syscall_nr' may be used uninitialized in this function [-Wmaybe-uninitialized]
int vsyscall_nr, syscall_nr, tmp;
^~~~~~~~~~

vim +/syscall_nr +127 arch/x86/entry/vsyscall/vsyscall_64.c

4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 122
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 123 bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 124 {
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 125 struct task_struct *tsk;
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 126 unsigned long caller;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 @127 int vsyscall_nr, syscall_nr, tmp;
2a53ccbc arch/x86/entry/vsyscall/vsyscall_64.c Ingo Molnar 2016-07-15 128 int prev_sig_on_uaccess_err;
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 129 long ret;
fa697140 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-05 130 unsigned long orig_dx;
7460ed28 arch/x86_64/kernel/vsyscall.c John Stultz 2007-02-16 131
c9712944 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-07-13 132 /*
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 133 * No point in checking CS -- the only way to get here is a user mode
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 134 * trap to a high address, which means that we're in 64-bit user code.
c9712944 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-07-13 135 */
7460ed28 arch/x86_64/kernel/vsyscall.c John Stultz 2007-02-16 136
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 137 WARN_ON_ONCE(address != regs->ip);
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 138
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 139 if (vsyscall_mode == NONE) {
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 140 warn_bad_vsyscall(KERN_INFO, regs,
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 141 "vsyscall attempted with vsyscall=none");
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 142 return false;
c9712944 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-07-13 143 }
7460ed28 arch/x86_64/kernel/vsyscall.c John Stultz 2007-02-16 144
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 145 vsyscall_nr = addr_to_vsyscall_nr(address);
c149a665 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-03 146
c149a665 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-03 147 trace_emulate_vsyscall(vsyscall_nr);
c149a665 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-03 148
c9712944 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-07-13 149 if (vsyscall_nr < 0) {
c9712944 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-07-13 150 warn_bad_vsyscall(KERN_WARNING, regs,
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 151 "misaligned vsyscall (exploit attempt or buggy program) -- look up the vsyscall kernel parameter if you need a workaround");
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 152 goto sigsegv;
7460ed28 arch/x86_64/kernel/vsyscall.c John Stultz 2007-02-16 153 }
7460ed28 arch/x86_64/kernel/vsyscall.c John Stultz 2007-02-16 154
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 155 if (get_user(caller, (unsigned long __user *)regs->sp) != 0) {
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 156 warn_bad_vsyscall(KERN_WARNING, regs,
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 157 "vsyscall with bad stack (exploit attempt?)");
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 158 goto sigsegv;
^1da177e arch/x86_64/kernel/vsyscall.c Linus Torvalds 2005-04-16 159 }
^1da177e arch/x86_64/kernel/vsyscall.c Linus Torvalds 2005-04-16 160
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 161 tsk = current;
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 162
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 163 /*
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 164 * Check for access_ok violations and find the syscall nr.
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 165 *
46ed99d1 arch/x86/kernel/vsyscall_64.c Emil Goode 2012-04-01 166 * NULL is a valid user pointer (in the access_ok sense) on 32-bit and
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 167 * 64-bit, so we don't need to special-case it here. For all the
46ed99d1 arch/x86/kernel/vsyscall_64.c Emil Goode 2012-04-01 168 * vsyscalls, NULL means "don't write anything" not "write it at
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 169 * address 0".
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 170 */
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 171 switch (vsyscall_nr) {
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 172 case 0:
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 173 if (!write_ok_or_segv(regs->di, sizeof(struct timeval)) ||
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 174 !write_ok_or_segv(regs->si, sizeof(struct timezone))) {
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 175 ret = -EFAULT;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 176 goto check_fault;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 177 }
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 178
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 179 syscall_nr = __NR_gettimeofday;
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 180 break;
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 181
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 182 case 1:
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 183 if (!write_ok_or_segv(regs->di, sizeof(time_t))) {
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 184 ret = -EFAULT;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 185 goto check_fault;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 186 }
5651721e arch/x86/kernel/vsyscall_64.c Will Drewry 2012-07-13 187
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 188 syscall_nr = __NR_time;
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 189 break;
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 190
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 191 case 2:
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 192 if (!write_ok_or_segv(regs->di, sizeof(unsigned)) ||
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 193 !write_ok_or_segv(regs->si, sizeof(unsigned))) {
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 194 ret = -EFAULT;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 195 goto check_fault;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 196 }
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 197
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 198 syscall_nr = __NR_getcpu;
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 199 break;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 200 }
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 201
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 202 /*
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 203 * Handle seccomp. regs->ip must be the original value.
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 204 * See seccomp_send_sigsys and Documentation/prctl/seccomp_filter.txt.
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 205 *
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 206 * We could optimize the seccomp disabled case, but performance
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 207 * here doesn't matter.
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 208 */
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 209 regs->orig_ax = syscall_nr;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 210 regs->ax = -ENOSYS;
2f275de5 arch/x86/entry/vsyscall/vsyscall_64.c Andy Lutomirski 2016-05-27 211 tmp = secure_computing(NULL);
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 212 if ((!tmp && regs->orig_ax != syscall_nr) || regs->ip != address) {
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 213 warn_bad_vsyscall(KERN_DEBUG, regs,
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 214 "seccomp tried to change syscall nr or ip");
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 215 do_exit(SIGSYS);
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 216 }
26893107 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2014-11-04 217 regs->orig_ax = -1;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 218 if (tmp)
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 219 goto do_ret; /* skip requested */
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 220
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 221 /*
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 222 * With a real vsyscall, page faults cause SIGSEGV. We want to
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 223 * preserve that behavior to make writing exploits harder.
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 224 */
2a53ccbc arch/x86/entry/vsyscall/vsyscall_64.c Ingo Molnar 2016-07-15 225 prev_sig_on_uaccess_err = current->thread.sig_on_uaccess_err;
2a53ccbc arch/x86/entry/vsyscall/vsyscall_64.c Ingo Molnar 2016-07-15 226 current->thread.sig_on_uaccess_err = 1;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 227
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 228 ret = -EFAULT;
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 229 switch (vsyscall_nr) {
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 230 case 0:
fa697140 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-05 231 /* this decodes regs->di and regs->si on its own */
d5a00528 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-09 232 ret = __x64_sys_gettimeofday(regs);
5651721e arch/x86/kernel/vsyscall_64.c Will Drewry 2012-07-13 233 break;
5651721e arch/x86/kernel/vsyscall_64.c Will Drewry 2012-07-13 234
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 235 case 1:
fa697140 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-05 236 /* this decodes regs->di on its own */
d5a00528 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-09 237 ret = __x64_sys_time(regs);
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 238 break;
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 239
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 240 case 2:
fa697140 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-05 241 /* while we could clobber regs->dx, we didn't in the past... */
fa697140 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-05 242 orig_dx = regs->dx;
fa697140 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-05 243 regs->dx = 0;
fa697140 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-05 244 /* this decodes regs->di, regs->si and regs->dx on its own */
d5a00528 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-09 245 ret = __x64_sys_getcpu(regs);
fa697140 arch/x86/entry/vsyscall/vsyscall_64.c Dominik Brodowski 2018-04-05 246 regs->dx = orig_dx;
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 247 break;
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 248 }
8c73626a arch/x86/kernel/vsyscall_64.c John Stultz 2010-07-13 249
2a53ccbc arch/x86/entry/vsyscall/vsyscall_64.c Ingo Molnar 2016-07-15 250 current->thread.sig_on_uaccess_err = prev_sig_on_uaccess_err;
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 251
87b526d3 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2012-10-01 252 check_fault:
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 253 if (ret == -EFAULT) {
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 254 /* Bad news -- userspace fed a bad pointer to a vsyscall. */
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 255 warn_bad_vsyscall(KERN_INFO, regs,
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 256 "vsyscall fault (exploit attempt?)");
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 257
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 258 /*
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 259 * If we failed to generate a signal for any reason,
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 260 * generate one here. (This should be impossible.)
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 261 */
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 262 if (WARN_ON_ONCE(!sigismember(&tsk->pending.signal, SIGBUS) &&
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 263 !sigismember(&tsk->pending.signal, SIGSEGV)))
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 264 goto sigsegv;
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 265
4fc34901 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-11-07 266 return true; /* Don't emulate the ret. */
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 267 }
8c73626a arch/x86/kernel/vsyscall_64.c John Stultz 2010-07-13 268
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 269 regs->ax = ret;
8c73626a arch/x86/kernel/vsyscall_64.c John Stultz 2010-07-13 270
5651721e arch/x86/kernel/vsyscall_64.c Will Drewry 2012-07-13 271 do_ret:
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 272 /* Emulate a ret instruction. */
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 273 regs->ip = caller;
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 274 regs->sp += 8;
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 275 return true;
c08c8205 arch/x86_64/kernel/vsyscall.c Vojtech Pavlik 2006-09-26 276
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 277 sigsegv:
5cec93c2 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-06-05 278 force_sig(SIGSEGV, current);
3ae36655 arch/x86/kernel/vsyscall_64.c Andy Lutomirski 2011-08-10 279 return true;
^1da177e arch/x86_64/kernel/vsyscall.c Linus Torvalds 2005-04-16 280 }
^1da177e arch/x86_64/kernel/vsyscall.c Linus Torvalds 2005-04-16 281

:::::: The code at line 127 was first introduced by commit
:::::: 87b526d349b04c31d7b3a40b434eb3f825d22305 seccomp: Make syscall skipping and nr changes more consistent

:::::: TO: Andy Lutomirski <luto@amacapital.net>
:::::: CC: James Morris <james.l.morris@oracle.com>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 63105 bytes --]