Hi all,

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%23618562

MIPS ABI enforces that 64bit arguments should be 64bit-aligned, and the
third argument of syscall(__NR_fanotify_mark, ...) is 64bit and not
64bit-aligned on 32bit mips platform, thus extra padding is inserted before
it. The syscall function doesn't know the prototype of
fanotify_mark, so the padding will be passed into kernel as valid argument.



-- 
Regards,

- cee1
From 35cc334cd9254638901b5316bdbffb208f572e73 Mon Sep 17 00:00:00 2001
From: cee1 <fykc...@gmail.com>
Date: Thu, 14 Apr 2011 10:28:42 +0800
Subject: [PATCH 1/2] Fix broken syscall(__NR_fanotify_mark... on 32bit mips.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%23618562
MIPS ABI enforces that 64bit arguments should be 64bit-aligned, and the
third argument of syscall(__NR_fanotify_mark, ...) is 64bit and not
64bit-aligned on 32bit mips platform, thus extra padding is inserted
before it. The syscall function doesn't know the prototype of
fanotify_mark, so the padding will be passed into kernel as valid
argument.

The same problem also exists on powerpc and arm.
---
 src/missing.h |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/missing.h b/src/missing.h
index 35e209f..b367831 100644
--- a/src/missing.h
+++ b/src/missing.h
@@ -125,7 +125,12 @@ static inline int fanotify_init(unsigned int flags, unsigned int event_f_flags)
 
 static inline int fanotify_mark(int fanotify_fd, unsigned int flags, uint64_t mask,
                                 int dfd, const char *pathname) {
-        return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname);
+        if (sizeof(void *) == 4)
+                return syscall(__NR_fanotify_mark, fanotify_fd, flags,
+                               *((uint32_t *) &mask), *((uint32_t *) &mask + 1),
+                               dfd, pathname);
+        else /* 64bit */
+                return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname);
 }
 
 #ifndef BTRFS_IOCTL_MAGIC
-- 
1.7.4.1

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to