xfrm: clear trailing padding in build_polexpire()
Subsystems (4)
PATCH v3 1/1 xfrm: clear trailing padding in build_polexpire()
build_expire() clears the trailing padding bytes of struct xfrm_user_expire after setting the hard field via memset_after(), but the analogous function build_polexpire() does not do this for struct xfrm_user_polexpire.
The padding bytes after the __u8 hard field are left uninitialized from the heap allocation, and are then sent to userspace via netlink multicast to XFRMNLGRP_EXPIRE listeners, leaking kernel heap memory contents.
Add the missing memset_after() call, matching build_expire().
---
v3:
- fix Fixes tag to cite the commit that introduced the bug
(was: e3e5fc1698ae which fixed the related build_expire() function)
v2: https://lore.kernel.org/netdev/[email protected]/
- add Fixes tag and Cc stable (requested by Steffen Klassert)
v1: https://lore.kernel.org/netdev/[email protected]/
net/xfrm/xfrm_user.c | 2 ++ 1 file changed, 2 insertions(+)
net/xfrm/xfrm_user.c +2 -0
@@ -3948,6 +3948,8 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp,return err; } upe->hard = !!hard; +/* clear the padding bytes */ +memset_after (upe,0 , hard);nlmsg_end (skb, nlh);return 0 ;
Signature · 1 line
2.50.1
Quoted 15 lines · Yasuaki Torimaru
build_expire()clears the trailing padding bytes of structxfrm_user_expireafter setting the hard field viamemset_after(), but the analogous functionbuild_polexpire()does not do this for structxfrm_user_polexpire.The padding bytes after the
__u8hard field are left uninitialized from the heap allocation, and are then sent to userspace via netlink multicast toXFRMNLGRP_EXPIRElisteners, leaking kernel heap memory contents.Add the missing
memset_after()call, matchingbuild_expire().Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Yasuaki Torimaru <[email protected]>
Quoted 7 lines
---
v3:
- fix Fixes tag to cite the commit that introduced the bug
(was:e3e5fc1698aewhich fixed the relatedbuild_expire()function)
v2: https://lore.kernel.org/netdev/[email protected]/
- add Fixes tag and Cc stable (requested by Steffen Klassert)
v1: https://lore.kernel.org/netdev/[email protected]/
Thanks for the updates.
Quoted 10 lines · Yasuaki Torimaru
build_expire()clears the trailing padding bytes of structxfrm_user_expireafter setting the hard field viamemset_after(), but the analogous functionbuild_polexpire()does not do this for structxfrm_user_polexpire.The padding bytes after the
__u8hard field are left uninitialized from the heap allocation, and are then sent to userspace via netlink multicast toXFRMNLGRP_EXPIRElisteners, leaking kernel heap memory contents.
Quoted 5 lines
Add the missing
memset_after()call, matchingbuild_expire().Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Yasuaki Torimaru <[email protected]>
Quoted 10 lines · Yasuaki Torimaru
build_expire()clears the trailing padding bytes of structxfrm_user_expireafter setting the hard field viamemset_after(), but the analogous functionbuild_polexpire()does not do this for structxfrm_user_polexpire.The padding bytes after the
__u8hard field are left uninitialized from the heap allocation, and are then sent to userspace via netlink multicast toXFRMNLGRP_EXPIRElisteners, leaking kernel heap memory contents.
Quoted 5 lines
Add the missing
memset_after()call, matchingbuild_expire().Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Yasuaki Torimaru <[email protected]>
Applied to the ipsec tree, thanks Yasuaki!