All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH
@ 2023-07-23  7:41 Lin Ma
  2023-07-25 11:35 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lin Ma @ 2023-07-23  7:41 UTC (permalink / raw)
  To: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel
  Cc: Lin Ma

The previous commit 4e484b3e969b ("xfrm: rate limit SA mapping change
message to user space") added one additional attribute named
XFRMA_MTIMER_THRESH and described its type at compat_policy
(net/xfrm/xfrm_compat.c).

However, the author forgot to also describe the nla_policy at
xfrma_policy (net/xfrm/xfrm_user.c). Hence, this suppose NLA_U32 (4
bytes) value can be faked as empty (0 bytes) by a malicious user, which
leads to 4 bytes overflow read and heap information leak when parsing
nlattrs.

To exploit this, one malicious user can spray the SLUB objects and then
leverage this 4 bytes OOB read to leak the heap data into
x->mapping_maxage (see xfrm_update_ae_params(...)), and leak it to
userspace via copy_to_user_state_extra(...).

The above bug is assigned CVE-2023-3773. To fix it, this commit just 
completes the nla_policy description for XFRMA_MTIMER_THRESH, which 
enforces the length check and avoids such OOB read.

Fixes: 4e484b3e969b ("xfrm: rate limit SA mapping change message to user space")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
 net/xfrm/xfrm_user.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index c34a2a06ca94..ab0e73c1e352 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -3035,6 +3035,7 @@ const struct nla_policy xfrma_policy[XFRMA_MAX+1] = {
 	[XFRMA_SET_MARK]	= { .type = NLA_U32 },
 	[XFRMA_SET_MARK_MASK]	= { .type = NLA_U32 },
 	[XFRMA_IF_ID]		= { .type = NLA_U32 },
+	[XFRMA_MTIMER_THRESH]   = { .type = NLA_U32 },
 };
 EXPORT_SYMBOL_GPL(xfrma_policy);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH
  2023-07-23  7:41 [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH Lin Ma
@ 2023-07-25 11:35 ` Simon Horman
  2023-07-26 11:55 ` Leon Romanovsky
  2023-08-01 10:00 ` Steffen Klassert
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2023-07-25 11:35 UTC (permalink / raw)
  To: Lin Ma
  Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

On Sun, Jul 23, 2023 at 03:41:10PM +0800, Lin Ma wrote:
> The previous commit 4e484b3e969b ("xfrm: rate limit SA mapping change
> message to user space") added one additional attribute named
> XFRMA_MTIMER_THRESH and described its type at compat_policy
> (net/xfrm/xfrm_compat.c).
> 
> However, the author forgot to also describe the nla_policy at
> xfrma_policy (net/xfrm/xfrm_user.c). Hence, this suppose NLA_U32 (4
> bytes) value can be faked as empty (0 bytes) by a malicious user, which
> leads to 4 bytes overflow read and heap information leak when parsing
> nlattrs.
> 
> To exploit this, one malicious user can spray the SLUB objects and then
> leverage this 4 bytes OOB read to leak the heap data into
> x->mapping_maxage (see xfrm_update_ae_params(...)), and leak it to
> userspace via copy_to_user_state_extra(...).
> 
> The above bug is assigned CVE-2023-3773. To fix it, this commit just 
> completes the nla_policy description for XFRMA_MTIMER_THRESH, which 
> enforces the length check and avoids such OOB read.
> 
> Fixes: 4e484b3e969b ("xfrm: rate limit SA mapping change message to user space")
> Signed-off-by: Lin Ma <linma@zju.edu.cn>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH
  2023-07-23  7:41 [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH Lin Ma
  2023-07-25 11:35 ` Simon Horman
@ 2023-07-26 11:55 ` Leon Romanovsky
  2023-07-26 13:32   ` Lin Ma
  2023-08-01 10:00 ` Steffen Klassert
  2 siblings, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2023-07-26 11:55 UTC (permalink / raw)
  To: Lin Ma
  Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

On Sun, Jul 23, 2023 at 03:41:10PM +0800, Lin Ma wrote:
> The previous commit 4e484b3e969b ("xfrm: rate limit SA mapping change
> message to user space") added one additional attribute named
> XFRMA_MTIMER_THRESH and described its type at compat_policy
> (net/xfrm/xfrm_compat.c).
> 
> However, the author forgot to also describe the nla_policy at
> xfrma_policy (net/xfrm/xfrm_user.c). Hence, this suppose NLA_U32 (4
> bytes) value can be faked as empty (0 bytes) by a malicious user, which
> leads to 4 bytes overflow read and heap information leak when parsing
> nlattrs.
> 
> To exploit this, one malicious user can spray the SLUB objects and then
> leverage this 4 bytes OOB read to leak the heap data into
> x->mapping_maxage (see xfrm_update_ae_params(...)), and leak it to
> userspace via copy_to_user_state_extra(...).
> 
> The above bug is assigned CVE-2023-3773. 

This CVE is a joke, you need to be root to execute this attack.

Anyway change is ok.
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH
  2023-07-26 11:55 ` Leon Romanovsky
@ 2023-07-26 13:32   ` Lin Ma
  2023-07-30 10:52     ` Leon Romanovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Lin Ma @ 2023-07-26 13:32 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

Hello Leon,

> 
> This CVE is a joke, you need to be root to execute this attack.
> 

Not really, this call routine only checks

  if (!netlink_net_capable(skb, CAP_NET_ADMIN))
    return -EPERM;

and any users in most vendor kernel can create a network namespace to
get such privilege and trigger this bug.

> Anyway change is ok.
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

Regards
Lin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH
  2023-07-26 13:32   ` Lin Ma
@ 2023-07-30 10:52     ` Leon Romanovsky
  0 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2023-07-30 10:52 UTC (permalink / raw)
  To: Lin Ma
  Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

On Wed, Jul 26, 2023 at 09:32:43PM +0800, Lin Ma wrote:
> Hello Leon,
> 
> > 
> > This CVE is a joke, you need to be root to execute this attack.
> > 
> 
> Not really, this call routine only checks
> 
>   if (!netlink_net_capable(skb, CAP_NET_ADMIN))
>     return -EPERM;
> 
> and any users in most vendor kernel can create a network namespace to
> get such privilege and trigger this bug.

ok, fair enough.

> 
> > Anyway change is ok.
> > Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> 
> Regards
> Lin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH
  2023-07-23  7:41 [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH Lin Ma
  2023-07-25 11:35 ` Simon Horman
  2023-07-26 11:55 ` Leon Romanovsky
@ 2023-08-01 10:00 ` Steffen Klassert
  2 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2023-08-01 10:00 UTC (permalink / raw)
  To: Lin Ma; +Cc: herbert, davem, edumazet, kuba, pabeni, netdev, linux-kernel

On Sun, Jul 23, 2023 at 03:41:10PM +0800, Lin Ma wrote:
> The previous commit 4e484b3e969b ("xfrm: rate limit SA mapping change
> message to user space") added one additional attribute named
> XFRMA_MTIMER_THRESH and described its type at compat_policy
> (net/xfrm/xfrm_compat.c).
> 
> However, the author forgot to also describe the nla_policy at
> xfrma_policy (net/xfrm/xfrm_user.c). Hence, this suppose NLA_U32 (4
> bytes) value can be faked as empty (0 bytes) by a malicious user, which
> leads to 4 bytes overflow read and heap information leak when parsing
> nlattrs.
> 
> To exploit this, one malicious user can spray the SLUB objects and then
> leverage this 4 bytes OOB read to leak the heap data into
> x->mapping_maxage (see xfrm_update_ae_params(...)), and leak it to
> userspace via copy_to_user_state_extra(...).
> 
> The above bug is assigned CVE-2023-3773. To fix it, this commit just 
> completes the nla_policy description for XFRMA_MTIMER_THRESH, which 
> enforces the length check and avoids such OOB read.
> 
> Fixes: 4e484b3e969b ("xfrm: rate limit SA mapping change message to user space")
> Signed-off-by: Lin Ma <linma@zju.edu.cn>

Also applied, thanks Lin!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-01 10:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-23  7:41 [PATCH v1] xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH Lin Ma
2023-07-25 11:35 ` Simon Horman
2023-07-26 11:55 ` Leon Romanovsky
2023-07-26 13:32   ` Lin Ma
2023-07-30 10:52     ` Leon Romanovsky
2023-08-01 10:00 ` Steffen Klassert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.