* [PATCH] net: ipv4: ipmr: Prevent information leak in ipmr_sk_ioctl()
@ 2025-12-27 7:37 Alper Ak
2025-12-30 19:35 ` Willem de Bruijn
0 siblings, 1 reply; 2+ messages in thread
From: Alper Ak @ 2025-12-27 7:37 UTC (permalink / raw)
To: davem, dsahern, edumazet, kuba
Cc: Alper Ak, Paolo Abeni, Simon Horman, Kuniyuki Iwashima,
Breno Leitao, Willem de Bruijn, netdev, linux-kernel
struct sioc_vif_req has a padding hole after the vifi field due to
alignment requirements. These padding bytes were uninitialized,
potentially leaking kernel stack memory to userspace when the
struct is copied via sock_ioctl_inout().
Reported by Smatch:
net/ipv4/ipmr.c:1575 ipmr_sk_ioctl() warn: check that 'buffer'
doesn't leak information (struct has a hole after 'vifi')
Fixes: e1d001fa5b47 ("net: ioctl: Use kernel memory on protocol ioctl callbacks")
Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
---
net/ipv4/ipmr.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index ca9eaee4c2ef..18441fbe7ed7 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1571,6 +1571,7 @@ int ipmr_sk_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
/* These userspace buffers will be consumed by ipmr_ioctl() */
case SIOCGETVIFCNT: {
struct sioc_vif_req buffer;
+ memset(&buffer, 0, sizeof(buffer));
return sock_ioctl_inout(sk, cmd, arg, &buffer,
sizeof(buffer));
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] net: ipv4: ipmr: Prevent information leak in ipmr_sk_ioctl()
2025-12-27 7:37 [PATCH] net: ipv4: ipmr: Prevent information leak in ipmr_sk_ioctl() Alper Ak
@ 2025-12-30 19:35 ` Willem de Bruijn
0 siblings, 0 replies; 2+ messages in thread
From: Willem de Bruijn @ 2025-12-30 19:35 UTC (permalink / raw)
To: Alper Ak, davem, dsahern, edumazet, kuba
Cc: Alper Ak, Paolo Abeni, Simon Horman, Kuniyuki Iwashima,
Breno Leitao, Willem de Bruijn, netdev, linux-kernel
Alper Ak wrote:
> struct sioc_vif_req has a padding hole after the vifi field due to
> alignment requirements. These padding bytes were uninitialized,
> potentially leaking kernel stack memory to userspace when the
> struct is copied via sock_ioctl_inout().
>
> Reported by Smatch:
> net/ipv4/ipmr.c:1575 ipmr_sk_ioctl() warn: check that 'buffer'
> doesn't leak information (struct has a hole after 'vifi')
>
> Fixes: e1d001fa5b47 ("net: ioctl: Use kernel memory on protocol ioctl callbacks")
The commit mentions other similar cases. If this is a concern for
sioc_vif_req, then it likely would alos be for sioc_mif_req6, which
similarly has a hole.
> Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
> ---
> net/ipv4/ipmr.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
> index ca9eaee4c2ef..18441fbe7ed7 100644
> --- a/net/ipv4/ipmr.c
> +++ b/net/ipv4/ipmr.c
> @@ -1571,6 +1571,7 @@ int ipmr_sk_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
> /* These userspace buffers will be consumed by ipmr_ioctl() */
> case SIOCGETVIFCNT: {
> struct sioc_vif_req buffer;
> + memset(&buffer, 0, sizeof(buffer));
>
> return sock_ioctl_inout(sk, cmd, arg, &buffer,
> sizeof(buffer));
sock_ioctl_inout copies the whole struct from userspace, calls a
domain specific callback and then copies the whole struct back:
if (copy_from_user(karg, arg, size))
return -EFAULT;
ret = READ_ONCE(sk->sk_prot)->ioctl(sk, cmd, karg);
if (ret)
return ret;
if (copy_to_user(arg, karg, size))
return -EFAULT;
As a result every byte of the memset will be overwritten with the
copy_from_user.
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-30 19:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-27 7:37 [PATCH] net: ipv4: ipmr: Prevent information leak in ipmr_sk_ioctl() Alper Ak
2025-12-30 19:35 ` Willem de Bruijn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).