From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796113544; b=PIBXqPbTi5Qrct2TBZOJ/bTOCyTQ8IHtOTDpCQ1y/i37uKPKvLOdj6oNpccIcn+l/XBG rTEraP5vJQfTBWn89xVJotEsi0tGzGrpUuxUZfB2R+/4qpSshuje5ksMxOgqk1WP194kb CL3uSNUIHl5LCaAti6kMjdYqdiEbdhkRuKyPLJx+6WKaIIJbJB64e/gcOjxQWgB2FC/6M bTdbbNayAqbDvnZxzl5JjAzKY9tS7RAqEv0gfDvxOdRi6ThmlM+wVrbcPLGrJa0LeywMa htlhMVJT7YeXlNS+XYRO+qcuizZz2L67qFZF4p4AfKRRcbClGKPlGnDUYnCzBhHt8mQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796113544; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=CRRa9Rbzush1xohs+csLp8ek6ZVLZeNp1B2Yl//nQrQ=; b=JriJrm+56gJSKc4rtgYXiKF0s1wHwYzwRZMVuVEyEiPtIfcG2cJbFGVYsMLoDrpn0Hlz SLVGKhA5CwLNscfAMgc3qCB4uIgIlYiVJagYVfz2M9K3KEaj5lReJ7wTwQMobuNjs1h4r BDvVcJxUkGoBwzHBysRKf87tpiPXZYIbI+dMxV1csEuXadHmi/DiABFwS9wcI/a8GOvdM cs+XpBHktcMnBLN8CsNfjpTME3S04bmMCeAMphE4LBaVwqU+ixtPG4ribXRxk5+kFyKnr O99xEJyiiBiV/96b/VNyiB8YNTYB36DaYs+VMyMMdDXxm98L8XtUbMTVHSlIQG5dgkA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ntX97ZVd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D36B9606A33E for ; Tue, 1 Dec 2026 08:25:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ntX97ZVd Received: by smtp.kernel.org (Postfix) with ESMTPSA id B92581F00897; Tue, 1 Dec 2026 08:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796113543; bh=CRRa9Rbzush1xohs+csLp8ek6ZVLZeNp1B2Yl//nQrQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ntX97ZVdpSVn/3bc/aYS6gYGWum5dJHWo5yLRLfMETE0Uc6hljY+wJ1kzpxwlONY2 oQlS5bGQJWNoZqBPtIOHXu1EA/QB2VxUl/cWszx5W47hlsIDoiYuLPJVjaelAnd38V WkX5Ej1gdXv37Z9kywbzkX2Zc9t5ET4SBWpotEBWZVY2iAOmJkMXu8ZPjEa/HUWCvz MkZA8l1W3jqfcoYI4nMZf0Jh5rPVZCkBvbNUhD4z2KvidjD4RR/+8RPq15lTRH7nG4 atZwmNWcrL+wOn7DAsDymbeW7f1aDWIaljC8YUW4BvDWlE7yL7Q6pRTXSTVGdXONCn obmRCiV7hRx6Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH can-next] can: gs_usb: gs_usb_probe(): fix return value check of gs_make_candev() Reply-To: sashiko-reviews@lists.linux.dev To: "Marc Kleine-Budde" Cc: linux-can@vger.kernel.org, "Oliver Hartkopp" , "Vincent Mailhol" , "Oleksij Rempel" In-Reply-To: <20261201-b4-gs-usb_fix-return-value-check-v1-1-693511dd12b0@pengutronix.de> References: <20261201-b4-gs-usb_fix-return-value-check-v1-1-693511dd12b0@pengutronix.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 08:25:43 +0000 X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] can: gs_usb: null pointer dereference in gs_can_open() [1] -- commit 38a9a7eebd4d3c343441a0677697277ff22f57cd Author: Marc Kleine-Budde can: gs_usb: gs_usb_probe(): fix return value check of gs_make_candev() This commit changes gs_usb_probe() to use IS_ERR() instead of IS_ERR_OR_NULL() when checking the return value of gs_make_candev(). > diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c > index 15f28833f2deb..d1a7c37a72a19 100644 > --- a/drivers/net/can/usb/gs_usb.c > +++ b/drivers/net/can/usb/gs_usb.c > @@ -1589,7 +1589,7 @@ static int gs_usb_probe(struct usb_interface *intf, > unsigned int hf_size_rx =3D 0; > =20 > parent->canch[i] =3D gs_make_candev(i, intf, &dconf); > - if (IS_ERR_OR_NULL(parent->canch[i])) { > + if (IS_ERR(parent->canch[i])) { > /* save error code to return later */ > rc =3D PTR_ERR(parent->canch[i]); > =20 [Severity: Critical] This problem wasn't introduced by this patch, but can gs_can_open() race with gs_usb_probe() and dereference a NULL dev->parent [1]? gs_make_candev() calls register_candev(), which exposes the network interface to userspace before gs_usb_probe() finishes initializing parent->canch[i]->parent and parent->hf_size_rx: drivers/net/can/usb/gs_usb.c:gs_usb_probe() { ... for (i =3D 0; i < icount; i++) { unsigned int hf_size_rx =3D 0; parent->canch[i] =3D gs_make_candev(i, intf, &dconf); if (IS_ERR(parent->canch[i])) { ... } parent->canch[i]->parent =3D parent; ... parent->hf_size_rx =3D max(parent->hf_size_rx, hf_size_rx); } } If userspace brings the interface up as soon as register_candev() returns, gs_can_open() runs before those fields are populated: CPU0 CPU1 gs_usb_probe() gs_make_candev() register_candev() gs_can_open() parent =3D dev->parent; if (!parent->active_channels) <-- NULL pointer dereference parent->canch[i]->parent =3D parent; parent->hf_size_rx =3D ... If gs_can_open() instead runs after dev->parent is assigned but before parent->hf_size_rx is computed, kmalloc(dev->parent->hf_size_rx, GFP_KERNEL) returns ZERO_SIZE_PTR and passes it to usb_fill_bulk_urb() as the RX DMA buffer. [1] https://sashiko.dev/#/bug/linux-be54de7d-0b75-408c-b3ee-dd90c9756857 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-b4-gs-usb_= fix-return-value-check-v1-1-693511dd12b0@pengutronix.de?part=3D1