[PATCH]: fanotify_event_metadata is not sufficiently aligned
From: Blair Barnett
Date: Mon Feb 07 2022 - 00:54:59 EST
While running fanotify LTP tests, we ran into several tests that
exhibited unaligned access faults (our processor that we are developing
has strict alignment of 8 bytes and does no hW or SW fix-up for
unaligned accesses). So here is a patch against the 5.15.13 kernel that
I want to propose to fix this problem. Testing on other architectures
(ARM and x86) passes.
I am not subscribed to this email list, so please CC and reply to
bbarnett@xxxxxxxxxxx.
Thank you,
Blair
From d358cbc008ebfe2aed50256074e97209bdf035f8 Mon Sep 17 00:00:00 2001
From: Blair Barnett <bbarnett@xxxxxxxxxxx>
Date: Sun, 6 Feb 2022 21:03:31 -0800
Subject: [PATCH] Since struct fanotify_event_metadata contains an element
"mask" that is aligned on __aligned_u64, it's best to align the
structure on
this size, rather than the current 4B
This fix resolves an unaligned access fault in many of the
fanotify LTP tests
---
fs/notify/fanotify/fanotify_user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/notify/fanotify/fanotify_user.c
b/fs/notify/fanotify/fanotify_user.c
index 6facdf476255..f028332738c5 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -109,7 +109,7 @@ struct kmem_cache *fanotify_fid_event_cachep
__read_mostly;
struct kmem_cache *fanotify_path_event_cachep __read_mostly;
struct kmem_cache *fanotify_perm_event_cachep __read_mostly;
-#define FANOTIFY_EVENT_ALIGN 4
+#define FANOTIFY_EVENT_ALIGN sizeof(__aligned_u64)
#define FANOTIFY_FID_INFO_HDR_LEN \
(sizeof(struct fanotify_event_info_fid) + sizeof(struct
file_handle))
#define FANOTIFY_PIDFD_INFO_HDR_LEN \
--
2.33.0