Bug 379966 - WARNING: unhandled amd64-linux syscall: 313 (finit_module)
Summary: WARNING: unhandled amd64-linux syscall: 313 (finit_module)
Status: CONFIRMED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.13 SVN
Platform: Debian stable Linux
: NOR minor
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-18 08:58 UTC by Bartosz Golaszewski
Modified: 2017-05-22 07:53 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
add wrapper for finit_module() (1.80 KB, patch)
2017-05-19 08:06 UTC, Bartosz Golaszewski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bartosz Golaszewski 2017-05-18 08:58:58 UTC
There's no such syscall on x86_64. Seems to be triggered when the process tries to check the state of a loadable kernel module:

rt_sigprocmask(SIG_SETMASK, [], ~[ILL TRAP BUS FPE KILL SEGV STOP], 8) = 0
open("/sys/module/gpio_mockup/initstate", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
rt_sigprocmask(SIG_SETMASK, ~[ILL TRAP BUS FPE KILL SEGV STOP], NULL, 8) = 0
gettid()                                = 6324
read(65530, "Z", 1)                     = 1
stat("/sys/module/gpio_mockup", 0xffefff220) = -1 ENOENT (No such file or directory)
getpid()                                = 6324
write(65529, "--6324-- WARNING: unhandled sysc"..., 41--6324-- WARNING: unhandled syscall: 313
) = 41

In order to reproduce:
1. Clone https://github.com/brgl/libgpiod
2. Build the test suite (refer to README)
3. Run the test suite under memcheck (must run tests/.libs/gpiod-test, not the libtool wrapper in tests/)
Comment 1 Mark Wielaard 2017-05-18 10:12:42 UTC
That is the finit_module which loads a kernel module from a file descriptor.
Comment 2 Bartosz Golaszewski 2017-05-18 10:28:00 UTC
Right, I checked the wrong file. It's in /usr/include/x86_64-linux-gnu/asm/unistd_64.h on Debian.

I'll try to create a wrapper for this syscall.
Comment 3 Tom Hughes 2017-05-18 10:34:43 UTC
Sure there is - it's finit_module.
Comment 4 Bartosz Golaszewski 2017-05-18 10:39:30 UTC
Hmm... it's already there in ./coregrind/m_syswrap/syswrap-amd64-linux.c but it's commented out:

835 //   LIN__(__NR_finit_module,      sys_ni_syscall),       // 313

Does it mean that it just doesn't have a wrapper in valgrind or some other reason?
Comment 5 Ivo Raisr 2017-05-18 10:43:42 UTC
It means the syscall wrapper needs a careful review w.r.t. kernel sources and ideally also a test case.
Comment 6 Bartosz Golaszewski 2017-05-19 08:06:29 UTC
Created attachment 105623 [details]
add wrapper for finit_module()

There was no wrapper - only the basic definitions. I wrote the wrapper and it fixes the issue on my setup. Patch attached.
Comment 7 Julian Seward 2017-05-22 07:53:27 UTC
(In reply to Bartosz Golaszewski from comment #6)
Committed, r16403.  Thanks for the patch.