xfrm_user: fix info leak in build_mapping()
Subsystems (3)
PATCH 1/1 xfrm_user: fix info leak in build_mapping()
struct xfrm_usersa_id has a one-byte padding hole after the proto field, which ends up never getting set to zero before copying out to userspace. Fix that up by zeroing out the whole structure before setting individual variables.
---
Note, I think this is correct, as I don't think a new skb has it's fields pre-zeroed out, or am I totally wrong here?
net/xfrm/xfrm_user.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_user.c +1 -0
@@ -4165,6 +4165,7 @@ static int build_mapping(struct sk_buff *skb, struct xfrm_state *x, um =nlmsg_data (nlh); +memset (&um->id,0 ,sizeof (um->id));memcpy (&um->id.daddr, &x->id.daddr,sizeof (um->id.daddr)); um->id.spi = x->id.spi; um->id.family = x->props.family;
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerQuoted 15 lines · On Mon, 6 Apr 2026 17:33:03 +0200 Greg Kroah-Hartman wrote:
struct
xfrm_usersa_idhas a one-byte padding hole after the proto field, which ends up never getting set to zero before copying out to userspace. Fix that up by zeroing out the whole structure before setting individual variables.Fixes 3a2dfbe8acb1 ("xfrm: Notify changes in UDP encapsulation via netlink")Cc Steffen Klassert <[email protected]>Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Assisted-by gregkh_clanker_t1000Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 3 lines
---
Note, I think this is correct, as I don't think a new skb has it's fields pre-zeroed out, or am I totally wrong here?
You're right, skb owner is responsible for clearing after put. Tho, Netlink is not as perf critical as real networking, I wish we at least had a helper which reserves the space and clears it :/ This is not the first or the second time we hit this sort of a bug.
Quoted 12 lines
net/xfrm/xfrm_user.c +1
-0@@ -4165,6 +4165,7 @@ static int build_mapping(struct sk_buff *skb, struct xfrm_state *x, um =nlmsg_data (nlh); +memset (&um->id,0 ,sizeof (um->id));memcpy (&um->id.daddr, &x->id.daddr,sizeof (um->id.daddr)); um->id.spi = x->id.spi; um->id.family = x->props.family;
Jakub Kicinski
maintainerQuoted 7 lines · On Mon, 6 Apr 2026 08:54:49 -0700 Jakub Kicinski wrote:
Quoted 2 lines
Note, I think this is correct, as I don't think a new skb has it's fields pre-zeroed out, or am I totally wrong here?
You're right, skb owner is responsible for clearing after put. Tho, Netlink is not as perf critical as real networking, I wish we at least had a helper which reserves the space and clears it :/ This is not the first or the second time we hit this sort of a bug.
We could make nlmsg_append() do that. Mostly because I don't have a better idea for a name and nlmsg_append is only used once ;)
Quoted 11 lines · Jakub Kicinski
Quoted 7 lines · On Mon, 6 Apr 2026 08:54:49 -0700 Jakub Kicinski wrote:
Quoted 2 lines
Note, I think this is correct, as I don't think a new skb has it's fields pre-zeroed out, or am I totally wrong here?
You're right, skb owner is responsible for clearing after put. Tho, Netlink is not as perf critical as real networking, I wish we at least had a helper which reserves the space and clears it :/ This is not the first or the second time we hit this sort of a bug.
We could make
nlmsg_append()do that. Mostly because I don't have a better idea for a name andnlmsg_appendis only used once ;)
As shown in my other patch:
https://lore.kernel.org/r/2026040621-poison-gristle-aaa3@gregkh
we need this in at least 2 places, don't know if it's worth doing it for all messages?
I guess nlmsg_append() would work? It tries to do some zeroing out for alignment for some reason...
Want me to do that? I don't have a way to test any of this, I just found it using some static code analysis tools that looked at holes in structures.
thanks,
greg k-h
Jakub Kicinski
maintainerQuoted 7 lines · On Mon, 6 Apr 2026 18:08:27 +0200 Greg Kroah-Hartman wrote:
Quoted 6 lines · Jakub Kicinski
Quoted 4 lines · On Mon, 6 Apr 2026 08:54:49 -0700 Jakub Kicinski wrote:
You're right, skb owner is responsible for clearing after put. Tho, Netlink is not as perf critical as real networking, I wish we at least had a helper which reserves the space and clears it :/ This is not the first or the second time we hit this sort of a bug.
Quoted 7 lines
Quoted 2 lines
We could make
nlmsg_append()do that. Mostly because I don't have a better idea for a name andnlmsg_appendis only used once ;)As shown in my other patch:
https://lore.kernel.org/r/2026040621-poison-gristle-aaa3@gregkhwe need this in at least 2 places, don't know if it's worth doing it for all messages?
I was thinking -- add the helper so that we can use it in places we're touching anyway. No need to mess with correct existing code.
Quoted 6 lines
I guess
nlmsg_append()would work? It tries to do some zeroing out for alignment for some reason...Want me to do that? I don't have a way to test any of this, I just found it using some static code analysis tools that looked at holes in structures.
Do you have any more Netlink leaks in the queue? If you do let's do it, if you don't we can wait until the next victi^w patch to arrive.
Quoted 22 lines · Jakub Kicinski
Quoted 7 lines · On Mon, 6 Apr 2026 18:08:27 +0200 Greg Kroah-Hartman wrote:
Quoted 6 lines · Jakub Kicinski
Quoted 4 lines · On Mon, 6 Apr 2026 08:54:49 -0700 Jakub Kicinski wrote:
You're right, skb owner is responsible for clearing after put. Tho, Netlink is not as perf critical as real networking, I wish we at least had a helper which reserves the space and clears it :/ This is not the first or the second time we hit this sort of a bug.
Quoted 7 lines
Quoted 2 lines
We could make
nlmsg_append()do that. Mostly because I don't have a better idea for a name andnlmsg_appendis only used once ;)As shown in my other patch:
https://lore.kernel.org/r/2026040621-poison-gristle-aaa3@gregkhwe need this in at least 2 places, don't know if it's worth doing it for all messages?
I was thinking -- add the helper so that we can use it in places we're touching anyway. No need to mess with correct existing code.
Quoted 3 lines
I guess
nlmsg_append()would work? It tries to do some zeroing out for alignment for some reason...
Quoted 6 lines
Quoted 3 lines
Want me to do that? I don't have a way to test any of this, I just found it using some static code analysis tools that looked at holes in structures.
Do you have any more Netlink leaks in the queue? If you do let's do it, if you don't we can wait until the next victi^w patch to arrive.
I do not have any more, sorry. So is it worth it for just these 2? Your call :)
Jakub Kicinski
maintainerQuoted 7 lines · On Tue, 7 Apr 2026 07:51:15 +0200 Greg Kroah-Hartman wrote:
Quoted 7 lines
Quoted 6 lines
I guess
nlmsg_append()would work? It tries to do some zeroing out for alignment for some reason...Want me to do that? I don't have a way to test any of this, I just found it using some static code analysis tools that looked at holes in structures.
Quoted 5 lines
Quoted 2 lines
Do you have any more Netlink leaks in the queue? If you do let's do it, if you don't we can wait until the next victi^w patch to arrive.
I do not have any more, sorry. So is it worth it for just these 2? Your call :)
These are fine. I would have applied but I think Steffen will take them via the ipsec tree first (LMK if that's not the plan, Steffen)
Quoted 8 lines · Jakub Kicinski
Quoted 7 lines · On Tue, 7 Apr 2026 07:51:15 +0200 Greg Kroah-Hartman wrote:
Quoted 7 lines
Quoted 6 lines
I guess
nlmsg_append()would work? It tries to do some zeroing out for alignment for some reason...Want me to do that? I don't have a way to test any of this, I just found it using some static code analysis tools that looked at holes in structures.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Do you have any more Netlink leaks in the queue? If you do let's do it, if you don't we can wait until the next victi^w patch to arrive.
I do not have any more, sorry. So is it worth it for just these 2? Your call :)
These are fine. I would have applied but I think Steffen will take them via the ipsec tree first (LMK if that's not the plan, Steffen)
Thanks!
Steffen Klassert
maintainerQuoted 8 lines · Jakub Kicinski
Quoted 7 lines · On Tue, 7 Apr 2026 07:51:15 +0200 Greg Kroah-Hartman wrote:
Quoted 7 lines
Quoted 6 lines
I guess
nlmsg_append()would work? It tries to do some zeroing out for alignment for some reason...Want me to do that? I don't have a way to test any of this, I just found it using some static code analysis tools that looked at holes in structures.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Do you have any more Netlink leaks in the queue? If you do let's do it, if you don't we can wait until the next victi^w patch to arrive.
I do not have any more, sorry. So is it worth it for just these 2? Your call :)
These are fine. I would have applied but I think Steffen will take them via the ipsec tree first (LMK if that's not the plan, Steffen)
I have them already in my ipsec testing branch, will be merged today.
Thanks!
Steffen Klassert
maintainerQuoted 8 lines · Jakub Kicinski
Quoted 7 lines · On Tue, 7 Apr 2026 07:51:15 +0200 Greg Kroah-Hartman wrote:
Quoted 7 lines
Quoted 6 lines
I guess
nlmsg_append()would work? It tries to do some zeroing out for alignment for some reason...Want me to do that? I don't have a way to test any of this, I just found it using some static code analysis tools that looked at holes in structures.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Do you have any more Netlink leaks in the queue? If you do let's do it, if you don't we can wait until the next victi^w patch to arrive.
I do not have any more, sorry. So is it worth it for just these 2? Your call :)
These are fine. I would have applied but I think Steffen will take them via the ipsec tree first (LMK if that's not the plan, Steffen)
Both patches are now applied to the ipsec tree. Thanks a lot!
Quoted 12 lines · Steffen Klassert
Quoted 11 lines · Jakub Kicinski
Quoted 10 lines · On Tue, 7 Apr 2026 07:51:15 +0200 Greg Kroah-Hartman wrote:
Quoted 9 lines
Quoted 6 lines
I guess
nlmsg_append()would work? It tries to do some zeroing out for alignment for some reason...Want me to do that? I don't have a way to test any of this, I just found it using some static code analysis tools that looked at holes in structures.
Do you have any more Netlink leaks in the queue? If you do let's do it, if you don't we can wait until the next victi^w patch to arrive.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I do not have any more, sorry. So is it worth it for just these 2? Your call :)
These are fine. I would have applied but I think Steffen will take them via the ipsec tree first (LMK if that's not the plan, Steffen)
Both patches are now applied to the ipsec tree. Thanks a lot!
Wonderful, thanks!