Skip to content

Commit

Permalink
fix fanotify syscall check on compat kernel
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
hdeller authored and metan-ucw committed Apr 17, 2014
1 parent 04afb02 commit 5d08e16
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions testcases/kernel/syscalls/fanotify/fanotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,27 @@
#ifndef __FANOTIFY_H__
#define __FANOTIFY_H__

#include <stdint.h>
#include <endian.h>
#include "lapi/abisize.h"
#include "linux_syscall_numbers.h"

/* fanotify(7) wrappers */

#define myfanotify_init(flags, event_f_flags) \
syscall(__NR_fanotify_init, flags, event_f_flags)

#define myfanotify_mark(fd, flags, mask, dfd, pathname) \
syscall(__NR_fanotify_mark, fd, flags, mask, dfd, pathname)
long myfanotify_mark(int fd, unsigned int flags, uint64_t mask,
int dfd, const char *pathname)
{
#if LTP_USE_64_ABI
return ltp_syscall(__NR_fanotify_mark, fd, flags, mask, dfd, pathname);
#else
return ltp_syscall(__NR_fanotify_mark, fd, flags,
__LONG_LONG_PAIR((unsigned long) (mask >> 32),
(unsigned long) mask),
dfd, (unsigned long) pathname);
#endif
}

#endif /* __FANOTIFY_H__ */

0 comments on commit 5d08e16

Please sign in to comment.