All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/1] Call forget_syscall() if different than execve*()
@ 2022-05-09 15:19 ` Francis Laniel
  0 siblings, 0 replies; 16+ messages in thread
From: Francis Laniel @ 2022-05-09 15:19 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-trace-devel, Francis Laniel, Catalin Marinas, Will Deacon,
	Peter Collingbourne, Mark Brown, Mark Rutland, Daniel Kiss,
	Kees Cook, linux-kernel

Hi.


First, I hope you are fine and the same for your relatives.

With this contribution, I enabled using syscalls:sys_exit_execve and
syscalls:sys_exit_execveat as tracepoints on arm64.
Indeed, before this contribution, the above tracepoint would not print their
information as syscall number was set to -1 by calling forget_syscall().

Now, forget_syscall() is called only if previous syscall number was different
than __NR_execve and __NR_execveat.
I tested it by compiling a kernel for arm64 and running it within a VM:
# Perf was compiled with linux kernel source.
root@vm-arm64:~# perf record -ag -e 'syscalls:sys_exit_execve' -e 'syscalls:sys_enter_execve' &
[1] 263
root@vm-arm64:~# ls
perf.data  share
root@vm-arm64:~# fg
perf record -ag -e 'syscalls:sys_exit_execve' -e 'syscalls:sys_enter_execve'
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.061 MB perf.data (2 samples) ]
root@vm-arm64:~# perf script
bash   264 [000]    66.220187: syscalls:sys_enter_execve: filename: 0xaaab05d9d
...
# Below line does not appear with this patch.
ls   264 [000]    66.226848:  syscalls:sys_exit_execve: 0x0
...

Nonetheless, this contribution is not perfect, hence I marked it as RFC.
First, I am not really sure if this is safe to not call forget_syscall() all the
time, even though I did not have problem while testing it.
Then, by including <asm-generic/unistd.h> to the modified file I ended with
some warnings at compile time:

So, if you see any way to improve this contribution, feel free to share!

Francis Laniel (1):
  arm64: Forget syscall if different from execve*()

 arch/arm64/include/asm/processor.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)


Best regards and thank you in advance.
-- 
2.25.1


^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [RFC PATCH v1 1/1] arm64: Forget syscall if different from execve*()
@ 2022-05-12 23:03 kernel test robot
  0 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2022-05-12 23:03 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220509151958.441240-2-flaniel@linux.microsoft.com>
References: <20220509151958.441240-2-flaniel@linux.microsoft.com>
TO: Francis Laniel <flaniel@linux.microsoft.com>

Hi Francis,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on arm/for-next kvmarm/next soc/for-next xilinx-xlnx/master v5.18-rc6]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Francis-Laniel/Call-forget_syscall-if-different-than-execve/20220509-232317
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: arm64-randconfig-s031-20220512 (https://download.01.org/0day-ci/archive/20220513/202205130641.D99Zoljr-lkp(a)intel.com/config)
compiler: aarch64-linux-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-dirty
        # https://github.com/intel-lab-lkp/linux/commit/305717b29c76677b4f8a33adaa9fa36a9edbc35b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Francis-Laniel/Call-forget_syscall-if-different-than-execve/20220509-232317
        git checkout 305717b29c76677b4f8a33adaa9fa36a9edbc35b
        # 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=arm64 SHELL=/bin/bash arch/arm64/kernel/

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


sparse warnings: (new ones prefixed by >>)
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:13:9: sparse: sparse: preprocessor token __NR_restart_syscall redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
>> include/uapi/asm-generic/unistd.h:416:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:15:9: sparse: sparse: preprocessor token __NR_exit redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:306:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:19:9: sparse: sparse: preprocessor token __NR_read redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:205:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:21:9: sparse: sparse: preprocessor token __NR_write redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:207:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:25:9: sparse: sparse: preprocessor token __NR_close redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:185:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:35:9: sparse: sparse: preprocessor token __NR_execve redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:642:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:37:9: sparse: sparse: preprocessor token __NR_chdir redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:169:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:51:9: sparse: sparse: preprocessor token __NR_lseek redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:908:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:53:9: sparse: sparse: preprocessor token __NR_getpid redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:521:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:55:9: sparse: sparse: preprocessor token __NR_mount redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:142:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:59:9: sparse: sparse: preprocessor token __NR_setuid redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:458:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:61:9: sparse: sparse: preprocessor token __NR_getuid redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:525:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:65:9: sparse: sparse: preprocessor token __NR_ptrace redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:385:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:85:9: sparse: sparse: preprocessor token __NR_sync redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:257:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:87:9: sparse: sparse: preprocessor token __NR_kill redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:418:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:95:9: sparse: sparse: preprocessor token __NR_dup redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:93:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:99:9: sparse: sparse: preprocessor token __NR_times redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:472:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:103:9: sparse: sparse: preprocessor token __NR_brk redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:624:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:105:9: sparse: sparse: preprocessor token __NR_setgid redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:454:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:107:9: sparse: sparse: preprocessor token __NR_getgid redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:529:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:111:9: sparse: sparse: preprocessor token __NR_geteuid redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:527:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:113:9: sparse: sparse: preprocessor token __NR_getegid redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:531:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:115:9: sparse: sparse: preprocessor token __NR_acct redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:292:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:117:9: sparse: sparse: preprocessor token __NR_umount2 redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:140:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:121:9: sparse: sparse: preprocessor token __NR_ioctl redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:109:9: sparse: this was the original definition
   arch/arm64/kernel/sys32.c: note: in included file:
   arch/arm64/include/asm/unistd32.h:123:9: sparse: sparse: preprocessor token __NR_fcntl redefined
   arch/arm64/kernel/sys32.c: note: in included file (through arch/arm64/include/asm/processor.h, include/linux/rcupdate.h, include/linux/rculist.h, ...):
   include/uapi/asm-generic/unistd.h:903:9: sparse: this was the original definition

vim +416 include/uapi/asm-generic/unistd.h

8a1ab3155c2ac7 David Howells 2012-10-04  414  
8a1ab3155c2ac7 David Howells 2012-10-04  415  /* kernel/signal.c */
8a1ab3155c2ac7 David Howells 2012-10-04 @416  #define __NR_restart_syscall 128
8a1ab3155c2ac7 David Howells 2012-10-04  417  __SYSCALL(__NR_restart_syscall, sys_restart_syscall)
8a1ab3155c2ac7 David Howells 2012-10-04  418  #define __NR_kill 129
8a1ab3155c2ac7 David Howells 2012-10-04  419  __SYSCALL(__NR_kill, sys_kill)
8a1ab3155c2ac7 David Howells 2012-10-04  420  #define __NR_tkill 130
8a1ab3155c2ac7 David Howells 2012-10-04  421  __SYSCALL(__NR_tkill, sys_tkill)
8a1ab3155c2ac7 David Howells 2012-10-04  422  #define __NR_tgkill 131
8a1ab3155c2ac7 David Howells 2012-10-04  423  __SYSCALL(__NR_tgkill, sys_tgkill)
8a1ab3155c2ac7 David Howells 2012-10-04  424  #define __NR_sigaltstack 132
8a1ab3155c2ac7 David Howells 2012-10-04  425  __SC_COMP(__NR_sigaltstack, sys_sigaltstack, compat_sys_sigaltstack)
8a1ab3155c2ac7 David Howells 2012-10-04  426  #define __NR_rt_sigsuspend 133
8a1ab3155c2ac7 David Howells 2012-10-04  427  __SC_COMP(__NR_rt_sigsuspend, sys_rt_sigsuspend, compat_sys_rt_sigsuspend)
8a1ab3155c2ac7 David Howells 2012-10-04  428  #define __NR_rt_sigaction 134
8a1ab3155c2ac7 David Howells 2012-10-04  429  __SC_COMP(__NR_rt_sigaction, sys_rt_sigaction, compat_sys_rt_sigaction)
8a1ab3155c2ac7 David Howells 2012-10-04  430  #define __NR_rt_sigprocmask 135
03e275959850f5 Al Viro       2012-12-25  431  __SC_COMP(__NR_rt_sigprocmask, sys_rt_sigprocmask, compat_sys_rt_sigprocmask)
8a1ab3155c2ac7 David Howells 2012-10-04  432  #define __NR_rt_sigpending 136
03e275959850f5 Al Viro       2012-12-25  433  __SC_COMP(__NR_rt_sigpending, sys_rt_sigpending, compat_sys_rt_sigpending)
c8ce48f06503ee Arnd Bergmann 2019-02-18  434  #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
8a1ab3155c2ac7 David Howells 2012-10-04  435  #define __NR_rt_sigtimedwait 137
00bf25d693e7f6 Arnd Bergmann 2019-01-01  436  __SC_COMP_3264(__NR_rt_sigtimedwait, sys_rt_sigtimedwait_time32, \
00bf25d693e7f6 Arnd Bergmann 2019-01-01  437  	  sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time32)
c8ce48f06503ee Arnd Bergmann 2019-02-18  438  #endif
8a1ab3155c2ac7 David Howells 2012-10-04  439  #define __NR_rt_sigqueueinfo 138
8a1ab3155c2ac7 David Howells 2012-10-04  440  __SC_COMP(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo, \
8a1ab3155c2ac7 David Howells 2012-10-04  441  	  compat_sys_rt_sigqueueinfo)
8a1ab3155c2ac7 David Howells 2012-10-04  442  #define __NR_rt_sigreturn 139
8a1ab3155c2ac7 David Howells 2012-10-04  443  __SC_COMP(__NR_rt_sigreturn, sys_rt_sigreturn, compat_sys_rt_sigreturn)
8a1ab3155c2ac7 David Howells 2012-10-04  444  

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-05-18 13:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-09 15:19 [RFC PATCH v1 0/1] Call forget_syscall() if different than execve*() Francis Laniel
2022-05-09 15:19 ` Francis Laniel
2022-05-09 15:19 ` [RFC PATCH v1 1/1] arm64: Forget syscall if different from execve*() Francis Laniel
2022-05-09 15:19   ` Francis Laniel
2022-05-10 10:59   ` Will Deacon
2022-05-10 10:59     ` Will Deacon
2022-05-10 14:00     ` Francis Laniel
2022-05-10 14:00       ` Francis Laniel
2022-05-10 14:03       ` Will Deacon
2022-05-10 14:03         ` Will Deacon
2022-05-10 14:12         ` Francis Laniel
2022-05-10 14:12           ` Francis Laniel
2022-05-18 13:32         ` Catalin Marinas
2022-05-18 13:32           ` Catalin Marinas
2022-05-10 13:33   ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-05-12 23:03 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.