lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260126110712.GJ13967@unreal>
Date: Mon, 26 Jan 2026 13:07:12 +0200
From: Leon Romanovsky <leon@...nel.org>
To: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
	Steffen Klassert <steffen.klassert@...unet.com>
Cc: linux-security-module <linux-security-module@...r.kernel.org>,
	Boris Pismenny <borisp@...lanox.com>,
	"David S. Miller" <davem@...emloft.net>,
	Florian Westphal <fw@...len.de>,
	Kristian Evensen <kristian.evensen@...il.com>,
	Raed Salem <raeds@...lanox.com>, Raed Salem <raeds@...dia.com>,
	Saeed Mahameed <saeedm@...lanox.com>,
	Yossi Kuperman <yossiku@...lanox.com>,
	Network Development <netdev@...r.kernel.org>,
	Aviad Yehezkel <aviadye@...dia.com>,
	Herbert Xu <herbert@...dor.apana.org.au>
Subject: Re: [PATCH] xfrm: force flush upon NETDEV_UNREGISTER event

On Thu, Jan 22, 2026 at 10:07:46PM +0900, Tetsuo Handa wrote:
> On 2026/01/22 20:32, Steffen Klassert wrote:
> > On Thu, Jan 22, 2026 at 08:28:31PM +0900, Tetsuo Handa wrote:
> >> On 2026/01/22 20:15, Steffen Klassert wrote:
> >>> Hm, I'd say we should not try to offload to a device that does
> >>> not support NETIF_F_HW_ESP.
> >>
> >> I was about to post the patch below, but you are suggesting that "do not allow calling
> >> xfrm_dev_state_add()/xfrm_dev_policy_add() if (dev->features & NETIF_F_HW_ESP) == 0" ?
> > 
> > As said, I think this is the correct way to do it. But let's wait
> > on opinions from the hardware people.
> 
> OK. I guess something like below.
> 
>  net/xfrm/xfrm_device.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
> index 52ae0e034d29..19aa61609d24 100644
> --- a/net/xfrm/xfrm_device.c
> +++ b/net/xfrm/xfrm_device.c
> @@ -292,6 +292,13 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
>  		dst_release(dst);
>  	}
>  
> +	if (!(dev->features & NETIF_F_HW_ESP)) {
> +		NL_SET_ERR_MSG(extack, "Device doesn't support offload");
> +		xso->dev = NULL;
> +		dev_put(dev);
> +		return -EINVAL;
> +	}

Steffen, Tetsuo

If by "HW people" you mean me, we always set NETIF_F_HW_ESP when adding
the .xfrm_dev_*_add() callbacks.

  1334 void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv)
  1335 {
  1336         struct mlx5_core_dev *mdev = priv->mdev;
  1337         struct net_device *netdev = priv->netdev;
  1338
  1339         if (!mlx5_ipsec_device_caps(mdev))
  1340                 return;
  1341
  1342         mlx5_core_info(mdev,
  1343                        "mlx5e: IPSec ESP acceleration enabled\n");
  1344
  1345         netdev->xfrmdev_ops = &mlx5e_ipsec_xfrmdev_ops;
  1346         netdev->features |= NETIF_F_HW_ESP;
  1347         netdev->hw_enc_features |= NETIF_F_HW_ESP;

So we are left with two possibilities: either the device registered XFRM
ops without setting NETIF_F_HW_ESP, or netdev->features was modified
without clearing the xfrmdev_ops pointer.

Which device is triggering the syzcaller crash?

Thanks

> +
>  	if (!dev->xfrmdev_ops || !dev->xfrmdev_ops->xdo_dev_state_add) {
>  		xso->dev = NULL;
>  		dev_put(dev);
> @@ -367,7 +374,8 @@ int xfrm_dev_policy_add(struct net *net, struct xfrm_policy *xp,
>  	if (!dev)
>  		return -EINVAL;
>  
> -	if (!dev->xfrmdev_ops || !dev->xfrmdev_ops->xdo_dev_policy_add) {
> +	if (!dev->xfrmdev_ops || !dev->xfrmdev_ops->xdo_dev_policy_add ||
> +	    !(dev->features & NETIF_F_HW_ESP)) {
>  		xdo->dev = NULL;
>  		dev_put(dev);
>  		NL_SET_ERR_MSG(extack, "Policy offload is not supported");
> 
> 
> 
> On 2026/01/22 20:15, Steffen Klassert wrote:
> >> But I have a question regarding security_xfrm_state_delete()/security_xfrm_policy_delete().
> >>
> >> xfrm_dev_state_flush_secctx_check() calls security_xfrm_state_delete() which can make
> >> xfrm_dev_state_flush() no-op by returning an error value.
> >> xfrm_dev_policy_flush_secctx_check() calls security_xfrm_policy_delete() which can make
> >> xfrm_dev_policy_flush() no-op by returning an error value.
> >>
> >> Since xfrm_dev_state_flush()/xfrm_dev_policy_flush() are called by NETDEV_UNREGISTER
> >> event (which is a signal for releasing all resources that prevent "struct net_device"
> >> references from dropping), making xfrm_dev_state_flush()/xfrm_dev_policy_flush() no-op (by
> >> allowing security_xfrm_state_delete()/security_xfrm_policy_delete() to return an error) is
> >> a denial-of-service bug.
> > 
> > This means that the calling task doesn't have the permission to delete the
> > state, some LSM has a policy the does not grant this permission.
> 
> But NETDEV_UNREGISTER event can fire without explicit request from a user.
> Roughly speaking, current behavior is that
> 
>   while (security_xfrm_state_delete() != 0) {
>     schedule_timeout_uninterruptible(10 * HZ);
>     pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n",
>              dev->name, netdev_refcnt_read(dev));
>   }
>   while (security_xfrm_policy_delete() != 0) {
>     schedule_timeout_uninterruptible(10 * HZ);
>     pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n",
>              dev->name, netdev_refcnt_read(dev));
>   }
> 
> might be executed upon e.g. termination of a userspace process.
> 
> > 
> >>
> >> Therefore, I wonder what are security_xfrm_state_delete() and security_xfrm_policy_delete()
> >> for. Can I kill xfrm_dev_state_flush_secctx_check() and xfrm_dev_policy_flush_secctx_check() ?
> > 
> > This might violate a LSM policy then.
> 
> But LSM policy that results in system hung upon automatic cleanup logic is so stupid.
> I want to kill xfrm_dev_state_flush_secctx_check() and xfrm_dev_policy_flush_secctx_check()
> in order to eliminate possibility of system hung.
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ