* [PATCH] compat: make block_device_operations tests grsec compatible
@ 2025-11-10 12:59 Mathias Krause
2025-11-18 10:50 ` Christoph Böhmwalder
0 siblings, 1 reply; 2+ messages in thread
From: Mathias Krause @ 2025-11-10 12:59 UTC (permalink / raw)
To: Philipp Reisner, Lars Ellenberg, Christoph Böhmwalder
Cc: Mathias Krause, drbd-dev
The grsecurity patch enforces that instances of certain types are always
constified, with the help of a compiler plugin. One of these types is
'struct block_device_operations'. Code that tries to modify a such-typed
object will cause compiler errors, leading to wrong results for the
kernel compatibility tests.
Change these tests to do direct type compare tests instead of trying to
modify the object, making them compatible with grsecurity kernels.
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
---
.../tests/block_device_operations_open_takes_gendisk.c | 10 +++-------
.../tests/have_blk_qc_t_submit_bio.c | 6 +++++-
drbd/drbd-kernel-compat/tests/have_void_submit_bio.c | 6 +++++-
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c b/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c
index d5f20fd569fb..9d77f16d09d8 100644
--- a/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c
+++ b/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c
@@ -5,13 +5,9 @@
# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
#endif
-int foo_open(struct gendisk *disk, unsigned int mode)
-{
- return 0;
-}
+int foo_open(struct gendisk *disk, unsigned int mode);
-void foo(void)
+void foo(struct block_device_operations *ops)
{
- struct block_device_operations ops;
- BUILD_BUG_ON(!(__same_type(ops.open, &foo_open)));
+ BUILD_BUG_ON(!(__same_type(ops->open, &foo_open)));
}
diff --git a/drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c b/drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c
index d7f2310dfbbd..d3e6dd792ff1 100644
--- a/drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c
+++ b/drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c
@@ -2,9 +2,13 @@
#include <linux/blkdev.h>
+#ifndef __same_type
+# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
+#endif
+
blk_qc_t submit(struct bio *bio);
void foo(struct block_device_operations *ops)
{
- ops->submit_bio = submit;
+ BUILD_BUG_ON(!(__same_type(ops->submit_bio, &submit)));
}
diff --git a/drbd/drbd-kernel-compat/tests/have_void_submit_bio.c b/drbd/drbd-kernel-compat/tests/have_void_submit_bio.c
index c638faf020e1..09b56a658a46 100644
--- a/drbd/drbd-kernel-compat/tests/have_void_submit_bio.c
+++ b/drbd/drbd-kernel-compat/tests/have_void_submit_bio.c
@@ -2,9 +2,13 @@
#include <linux/blkdev.h>
+#ifndef __same_type
+# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
+#endif
+
void submit(struct bio *bio);
void foo(struct block_device_operations *ops)
{
- ops->submit_bio = submit;
+ BUILD_BUG_ON(!(__same_type(ops->submit_bio, &submit)));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-18 10:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 12:59 [PATCH] compat: make block_device_operations tests grsec compatible Mathias Krause
2025-11-18 10:50 ` Christoph Böhmwalder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox