From: Pranav Tyagi <pranav.tyagi03@gmail.com>
To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
keescook@chromium.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linux.dev
Cc: Pranav Tyagi <pranav.tyagi03@gmail.com>
Subject: [PATCH] net: randomize layout of struct net_device
Date: Mon, 2 Jun 2025 19:29:32 +0530 [thread overview]
Message-ID: <20250602135932.464194-1-pranav.tyagi03@gmail.com> (raw)
Add __randomize_layout to struct net_device to support structure layout
randomization if CONFIG_RANDSTRUCT is enabled else the macro expands to
do nothing. This enhances kernel protection by making it harder to
predict the memory layout of this structure.
Link: https://github.com/KSPP/linux/issues/188
Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>
---
include/linux/netdevice.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7ea022750e4e..0caff664ef3a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2077,7 +2077,11 @@ enum netdev_reg_state {
* moves out.
*/
+#ifdef CONFIG_RANDSTRUCT
+struct __randomize_layout net_device {
+#else
struct net_device {
+#endif
/* Cacheline organization can be found documented in
* Documentation/networking/net_cachelines/net_device.rst.
* Please update the document when adding new fields.
--
2.49.0
next reply other threads:[~2025-06-02 13:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-02 13:59 Pranav Tyagi [this message]
2025-06-02 14:07 ` [PATCH] net: randomize layout of struct net_device Kees Cook
2025-06-02 14:22 ` Pranav Tyagi
2025-06-02 14:43 ` Pranav Tyagi
2025-06-02 14:07 ` Greg KH
2025-06-06 15:04 ` Pranav Tyagi
2025-06-02 14:46 ` Andrew Lunn
2025-06-02 18:03 ` Kees Cook
2025-06-02 19:06 ` Andrew Lunn
2025-06-06 14:55 ` Pranav Tyagi
2025-06-06 15:42 ` Eric Dumazet
2025-06-06 19:46 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250602135932.464194-1-pranav.tyagi03@gmail.com \
--to=pranav.tyagi03@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox