Skip to contentSkip to conversation

xfrm_user: fix info leak in build_mapping()

PATCH In review Greg Kroah-Hartman 3 participants 11 messages Apr 6 – Apr 11

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

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_t1000

---
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
index 8a854fa9567d..1bb8d05561df 100644
@@ -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
maintainer
#1 lore raw
Quoted 15 lines · On Mon, 6 Apr 2026 17:33:03 +0200 Greg Kroah-Hartman wrote:

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.

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_t1000
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
index 8a854fa9567d..1bb8d05561df 100644
@@ -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;
maintainer
#2 lore raw
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 and nlmsg_append is only used once ;)

#3 lore raw
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 and nlmsg_append is 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

maintainer
#4 lore raw
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 and nlmsg_append is 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 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.

#5 lore raw
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 and nlmsg_append is 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 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 :)

maintainer
#6 lore raw
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 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)

#7 lore raw
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!

maintainer
#8 lore raw
In reply to Jakub Kicinski
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)

I have them already in my ipsec testing branch, will be merged today.

Thanks!

maintainer
#9 lore raw
In reply to Jakub Kicinski
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)

Both patches are now applied to the ipsec tree. Thanks a lot!

#10 lore raw
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!