From nobody Fri Jun 12 09:47:24 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 296E0237713 for ; Mon, 13 Apr 2026 11:20:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776079250; cv=none; b=WLKKcmnt+qM5LtB0U3fgAoCTeXDNDCYDezF5zduOIIALksSdfAlQVxlXjafNDf4omQ4JncHP6bm1v3rxX8rtNaQVVEbS9MYjx4gpZIPQa1rnMvVPyKXtInZX9EKLcYtffAOjP8G4kYX1Vot95eu+1znRiRXc2x8nyduIj8zCfNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776079250; c=relaxed/simple; bh=R5urYhnoHecl+KVX4m8FZXgsJfZf3ZpUYspi2EHPFBo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ttUrmSqfCj8/EOURVhec2oDIzRRkIXBDbTG1vmx9E5qcrL5I5t8jvJ6TaHXW00gDHXiIWGwToxrkWbrM5gpaWyR/Fd820WqDR2psAmV7lJ9q7sus/lKuOv5/+8WbF8LNd5N1qnmav5y+5AWX5QAPhZSFsK8VDtWnrPMOmjlAimw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dH1w5m0/; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dH1w5m0/" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-82418b0178cso2096828b3a.1 for ; Mon, 13 Apr 2026 04:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776079247; x=1776684047; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iQ7f9KI9JqtBNgCC6+8bgvZa6CW8q9FixqdbvIgHfKA=; b=dH1w5m0/WlAoZqvADSMi1fTBWlr7hchAIJlgpfCiiMuqLTucEhlMLKpbMXa15uJQJq 2Tz79GD8D2or5W65WoFY+OHew59Se6fEm7aeHj5uCUvneffTU+0mn0GDaivxMbCSLFyM 7wsb9n6E4SHVQZTPAnB6ig7iEkePBU1uPr2Ie89U1qk0tZ8PeMn8cK7203+VHVJskavb 2EZgekwIdmpqb1OeDPFbg9bXjG3ZWaBhvP77HldYwnquWlcGcSkmJWKtZ4bmP25mI/Gi Ak3Rzjrj1qT6rOSGcvcVKOoMK9HEVb2VQ2R2w9RGU8109NRgB0nH6NjNx4aWlpIAM5Pj Mo+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776079247; x=1776684047; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iQ7f9KI9JqtBNgCC6+8bgvZa6CW8q9FixqdbvIgHfKA=; b=Tk7+uhVyzfzNtf7qr34s+SbYLH9iBhzDuhXd+ZZIsATnIOzT2g53DAHpdsMhkQd5W4 WTFgnR3fYXU8E72cZwj18g5ghDwy8YPZlXiuVyl4R1eWAMt4QO0rQV5mi2iOUNjVUJmF hiBFtm321b90dept2c3nJRGlklGd1QFch8t8Sq2i4dHqDxAyfICNxRt/wmYyyYsicVIU BAIT3wtWaxS1hK6ZZ0lo13mOExLJbgmYuldz/AMDkdM5KF7wNinpy7aNUxjHnpse0qUM ZSy2vJWWsL8shvaU6lk1QZl+ObGUxafHAzxhJjd5jcdzZqlLg4rjGdsskn+c76LEtxMY 6QXA== X-Forwarded-Encrypted: i=1; AFNElJ8+btEqCYYmeL2xPn/TWOUO7AMcIqzejXNZdQalqzNa6O02Se7v+4PS1jmB7wjun0bHIajPOpzqeZ19e0U=@vger.kernel.org X-Gm-Message-State: AOJu0YzciZQMT9Dew0OeYWJwWxmTuML0PwhE4upidnU1t4BYAqvEUf0r lQp1zoLPZESy5zgFg1R8x7e3b5oFohJu7/8EKgFjX+/oS9tufUxFIiBs X-Gm-Gg: AeBDiev6IG6acGfEODieJgUgt6ffFWFonduff/EdT1thn5SaJfJdNO33/5yfxIr3avb wS3XI/rubxpjFi20P4xUjOdSC0wJCgT/i8p9lIISS6RT6TLG73TbP5oTMWZ2mIqev68KVyAhYVG 7UeFHITEHhs188IKMkGKh9rJV7r8GAz5kNIjbqGqHuBanmVcHVfgSYK3hHQ9nVDaS6oN09YubOr puTdluuOyyjxyL6mgwqJ5xvuP/Tj3+MxBWtKyUA7PlFT4TzrS0PwEeymV2NWNI6Lk5ebJpx2vFs C6DaVG6Mhw54IVl9xK1dClvVdKTz1BqKXf3UjbuqoMkkIXmLr11F86O0H9U0KnjsDqrUupodNo3 oOEwRmnjg6HfMIRDO60NGcRz5V4D/Ypom+YSbyG17UrTJCJ1c1fn2JuLbT3kudboB/vW0hC3sUI TpttBLUrdD7/eXlw== X-Received: by 2002:a05:6a00:1887:b0:829:924c:348a with SMTP id d2e1a72fcca58-82f0c26b71fmr14463158b3a.45.1776079247519; Mon, 13 Apr 2026 04:20:47 -0700 (PDT) Received: from lgs.. ([101.32.189.54]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f0c4df7f5sm13555346b3a.43.2026.04.13.04.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 04:20:47 -0700 (PDT) From: Guangshuo Li To: Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Joshua Hay , Tatyana Nikolova , Madhu Chittim , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Guangshuo Li , stable@vger.kernel.org Subject: [PATCH v2] dpf: fix UAF and double free in idpf_plug_vport_aux_dev() error path Date: Mon, 13 Apr 2026 19:20:30 +0800 Message-ID: <20260413112030.2694563-1-lgs201920130244@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If auxiliary_device_add() fails, idpf_plug_vport_aux_dev() calls auxiliary_device_uninit(adev), whose release callback idpf_vport_adev_release() frees the containing struct iidc_rdma_vport_auxiliary_dev. The current error path then accesses adev->id and later frees iadev again, which may lead to a use-after-free and double free. The issue was identified by a static analysis tool I developed and confirmed by manual review. Fix it by storing the allocated auxiliary device id in a local variable and avoiding direct freeing of iadev after auxiliary_device_uninit(). Fixes: be91128c579c ("idpf: implement RDMA vport auxiliary dev create, init= , and destroy") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li --- v2: - note that the issue was identified by my static analysis tool - and confirmed by manual review drivers/net/ethernet/intel/idpf/idpf_idc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf_idc.c b/drivers/net/ether= net/intel/idpf/idpf_idc.c index 6dad0593f7f2..2a18907643fc 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_idc.c +++ b/drivers/net/ethernet/intel/idpf/idpf_idc.c @@ -59,6 +59,7 @@ static int idpf_plug_vport_aux_dev(struct iidc_rdma_core_= dev_info *cdev_info, char name[IDPF_IDC_MAX_ADEV_NAME_LEN]; struct auxiliary_device *adev; int ret; + int adev_id; =20 iadev =3D kzalloc(sizeof(*iadev), GFP_KERNEL); if (!iadev) @@ -74,11 +75,14 @@ static int idpf_plug_vport_aux_dev(struct iidc_rdma_cor= e_dev_info *cdev_info, goto err_ida_alloc; } adev->id =3D ret; + adev->id =3D adev_id; adev->dev.release =3D idpf_vport_adev_release; adev->dev.parent =3D &cdev_info->pdev->dev; sprintf(name, "%04x.rdma.vdev", cdev_info->pdev->vendor); adev->name =3D name; =20 + /* iadev is owned by the auxiliary device */ + iadev =3D NULL; ret =3D auxiliary_device_init(adev); if (ret) goto err_aux_dev_init; @@ -92,7 +96,7 @@ static int idpf_plug_vport_aux_dev(struct iidc_rdma_core_= dev_info *cdev_info, err_aux_dev_add: auxiliary_device_uninit(adev); err_aux_dev_init: - ida_free(&idpf_idc_ida, adev->id); + ida_free(&idpf_idc_ida, adev_id); err_ida_alloc: vdev_info->adev =3D NULL; kfree(iadev); --=20 2.43.0