Skip to content

Commit 5d08e16

Browse files
hdellermetan-ucw
authored andcommitted
fix fanotify syscall check on compat kernel
The fanotify[0-5] testcases use the myfanotify_mark() wrapper for the fanotify_mark() syscall. But the #define does not take into account, that the mask field is actually of type _u64 where we need to split the hi and low word in the syscall on a 32bit arch. The attached patch converts the #define to a inline function where the compiler will help to convert the given values to the correct types (e.g. unsigned long). Bug found and tested on the parisc/hppa (32bit userspace with 64bit kernel) arch. Signed-off-by: Helge Deller <[email protected]> Signed-off-by: Cyril Hrubis <[email protected]>
1 parent 04afb02 commit 5d08e16

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

testcases/kernel/syscalls/fanotify/fanotify.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,27 @@
2828
#ifndef __FANOTIFY_H__
2929
#define __FANOTIFY_H__
3030

31+
#include <stdint.h>
32+
#include <endian.h>
33+
#include "lapi/abisize.h"
34+
#include "linux_syscall_numbers.h"
35+
3136
/* fanotify(7) wrappers */
3237

3338
#define myfanotify_init(flags, event_f_flags) \
3439
syscall(__NR_fanotify_init, flags, event_f_flags)
3540

36-
#define myfanotify_mark(fd, flags, mask, dfd, pathname) \
37-
syscall(__NR_fanotify_mark, fd, flags, mask, dfd, pathname)
41+
long myfanotify_mark(int fd, unsigned int flags, uint64_t mask,
42+
int dfd, const char *pathname)
43+
{
44+
#if LTP_USE_64_ABI
45+
return ltp_syscall(__NR_fanotify_mark, fd, flags, mask, dfd, pathname);
46+
#else
47+
return ltp_syscall(__NR_fanotify_mark, fd, flags,
48+
__LONG_LONG_PAIR((unsigned long) (mask >> 32),
49+
(unsigned long) mask),
50+
dfd, (unsigned long) pathname);
51+
#endif
52+
}
3853

3954
#endif /* __FANOTIFY_H__ */

0 commit comments

Comments
 (0)