xfrm: zero-initialise km_event in replay-notify to stop stack disclosure
Subsystems (3)
PATCH 1/1 xfrm: zero-initialise km_event in replay-notify to stop stack disclosure
xfrm_replay_notify(), xfrm_replay_notify_bmp() and xfrm_replay_notify_esn() declare a struct km_event on the stack and initialise only its .event and .data.aevent fields, leaving .seq and .portid uninitialised. build_aevent() copies those two fields into the XFRM_MSG_NEWAE netlink message header vianlmsg_put(skb, c->portid, c->seq, ...), and the message is multicast to the XFRMNLGRP_AEVENTS group, so two dwords of uninitialised kernel stack are sent to group listeners on each replay event.
The request-driven paths set these header fields from the requester (xfrm_get_ae() / xfrm_new_ae()); only the kernel-originated replay path leaves them uninitialised. Zero-initialise the event so the header fields are sent as 0, the correct value for a kernel-originated notification.
--- net/xfrm/xfrm_replay.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/xfrm/xfrm_replay.c +3 -3
@@ -40,7 +40,7 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event);void xfrm_replay_notify (struct xfrm_state *x,int event) { -struct km_event c; +struct km_event c = {};/* we send notify messages in case * 1. we updated on of the sequence numbers, and the seqno difference * is at least x->replay_maxdiff, in this case we also update the
@@ -304,7 +304,7 @@ static void xfrm_replay_advance_bmp(struct xfrm_state *x, __be32 net_seq)static void xfrm_replay_notify_bmp (struct xfrm_state *x,int event) { -struct km_event c; +struct km_event c = {};struct xfrm_replay_state_esn *replay_esn = x->replay_esn;struct xfrm_replay_state_esn *preplay_esn = x->preplay_esn;
@@ -356,7 +356,7 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)static void xfrm_replay_notify_esn (struct xfrm_state *x,int event) {u32 seq_diff, oseq_diff; -struct km_event c; +struct km_event c = {};struct xfrm_replay_state_esn *replay_esn = x->replay_esn;struct xfrm_replay_state_esn *preplay_esn = x->preplay_esn;
Signature · 1 line
2.43.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Steffen Klassert
maintainerQuoted 15 lines · Shubham Antil
xfrm_replay_notify(),xfrm_replay_notify_bmp()andxfrm_replay_notify_esn()declare a structkm_eventon the stack and initialise only its .event and .data.aevent fields, leaving .seq and .portid uninitialised.build_aevent()copies those two fields into theXFRM_MSG_NEWAEnetlink message header vianlmsg_put(skb, c->portid, c->seq, ...), and the message is multicast to theXFRMNLGRP_AEVENTSgroup, so two dwords of uninitialised kernel stack are sent to group listeners on each replay event.The request-driven paths set these header fields from the requester (
xfrm_get_ae()/xfrm_new_ae()); only the kernel-originated replay path leaves them uninitialised. Zero-initialise the event so the header fields are sent as 0, the correct value for a kernel-originated notification.
Quoted 3 lines
Reported-by Giovanni Vignone <[email protected]>Assisted-by LLMSigned-off-by Shubham Antil <[email protected]>
As this is a fix, please add a 'Fixes:' tag.
Thanks!