Article View: linux.kernel.netdev
Article #5600Re: [PATCH net-next 10/11] can: replace ARPHRD_CAN type checks with can_get_ml_priv()
From: netdev-bot+sashiko
Date: Tue, 20 Oct 2026 17:11
Date: Tue, 20 Oct 2026 17:11
126 lines
12348 bytes
12348 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message is inaccurate about where the crash happens.
Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but isotp_bind()
in net/can/isotp.c still ignores the return value of bothβ¦
--
can: replace ARPHRD_CAN type checks with can_get_ml_priv()
This patch replaces the remaining dev->type == ARPHRD_CAN checks in
af_can, bcm, gw, isotp and raw with can_get_ml_priv(). The TUNSETLINK
ioctl can switch a TUN/TAP device to ARPHRD_CAN while dev->ml_priv stays
NULL, and such a device passes the old type checks.
Link: https://patch.msgid.link/20261012164802.94113-1-socketcan@hartkopp.net
Link: https://patch.msgid.link/20261019152741.54854-5-socketcan@hartkopp.net
> The TUNSETLINK ioctl allows a down TUN/TAP device to set its hardware
> type to ARPHRD_CAN while dev->ml_priv remains NULL. Such a repurposed
> netdevice passes the ARPHRD_CAN checks and triggers a NULL pointer
> dereference when CAN filters are created and when they are removed,
> e.g. by the CAN protocols' netdevice notifier handlers.
[Severity: Low]
Is the "when CAN filters are created" part accurate for this tree?
Commit 8aa59e3559494 ("can: af_can: fix NULL pointer dereference in
can_rx_register()") already made can_rx_register() reject devices
without ml_priv:
if (dev && (dev->type != ARPHRD_CAN || !can_get_ml_priv(dev)))
return -ENODEV;
raw, bcm, gw (through cgw_register_filter()) and isotp all create filters
through can_rx_register(). So creating a filter can't reach the NULL
ml_priv.
The only dereference left seems to be on removal. can_rx_unregister()
checked only dev->type, and then can_dev_rcv_lists_find() does:
struct can_ml_priv *can_ml = can_get_ml_priv(dev);
return &can_ml->dev_rcv_lists;
The spin_lock_bh() on dev_rcv_lists->lock then goes through a near-NULL
pointer.
The path that actually gets there looks like isotp. isotp_bind() ignores
the -ENODEV from both can_rx_register() calls and sets so->bound = 1
anyway. Later, unregistering the filters crashes:
isotp_bind()
can_rx_register() -> -ENODEV, ignored
so->bound = 1
isotp_release() or isotp_notify(NETDEV_UNREGISTER)
can_rx_unregister()
can_dev_rcv_lists_find()
spin_lock_bh(&dev_rcv_lists->lock)
The code change itself looks correct. Could the commit message describe
the crash on removal and the isotp path instead? That would show stable
backporters which code is affected.
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index 64ff203a37f4..5e1c3971ebfc 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
[ ... ]
> @@ -1618,7 +1619,7 @@ static int isotp_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int l
> err = -ENODEV;
> goto out;
> }
> - if (dev->type != ARPHRD_CAN) {
> + if (!can_get_ml_priv(dev)) {
> err = -ENODEV;
> goto out_put_dev;
> }
[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch.
Further down in isotp_bind(), the return values of both can_rx_register()
calls are still ignored:
if (isotp_register_rxid(so))
can_rx_register(net, dev, rx_id, SINGLE_MASK(rx_id),
isotp_rcv, sk, sock_i_ino(sk), sk);
...
can_rx_register(net, dev, tx_id, SINGLE_MASK(tx_id),
isotp_rcv_echo, sk, sock_i_ino(sk), sk);
/* switch to new settings */
...
so->bound = 1;
The new can_get_ml_priv() check rules out the -ENODEV cases. However,
can_rx_register() can still return -ENOMEM:
rcv = kmem_cache_alloc(rcv_cache, GFP_KERNEL);
if (!rcv)
return -ENOMEM;
In that case, does bind() report success even though the socket has no RX
receiver, no echo receiver, or neither? RX frames would be dropped without
any error, and isotp TX would wait for echo frames that never arrive.
A later isotp_release() or isotp_notify() for NETDEV_UNREGISTER would
only print "receive list entry not found" from can_rx_unregister(). It
would not crash.
Other CAN protocols handle this: raw_enable_filters() rolls back on error,
and bcm_rx_setup() checks err. Should isotp_bind() check these results and
unwind too? The last patch in this series ("can: protect the receive lists
with a per-device lock") still leaves both calls unchecked.
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261019170834.1727150-2-mkl%40pengutronix.de
Technical Details
Message-ID:
<179251627911.3135.5362969890074772101@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349413-linux-kernel-netdev=dewy.ruReferences:
<20261019170834.1727150-11-mkl@pengutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349413-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 10/11] can: replace ARPHRD_CAN type checks with can_get_ml_priv() Date: Tue, 20 Oct 2026 17:11:19 +0000 Organization: Usenet Network Message-ID: <179251627911.3135.5362969890074772101@kernel.org> References: <20261019170834.1727150-11-mkl@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3904821"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:EWLM1wl7Un3lm7lD8Ngky2zHMCs= sha256:D4FxTCJ7B2+TQmYdejr37iuyePURC9Xgk4AgkbVrGaU= sha1:R1uLUn0XWR8Z8TvqxtDOLIKhI/U= sha256:trA/6parC4ivvsLU4w7jasOpHXg/KsjdihLgVSTz3UU= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 35553110D91; Tue, 20 Oct 2026 20:14:45 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.829 X-Spam-Status: No, score=-3.829 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.329, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SZPgMBa4HrYD; Tue, 20 Oct 2026 20:14:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-349413-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id BB3CA110D67; Tue, 20 Oct 2026 20:14:33 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 6636F60675A; Tue, 20 Oct 2026 17:11:53 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792516311; b=5bnVgzLocOT7F6bNqDG/ZxpKZXiQfFHCURzO/sCDq7d3t93cYNHE3kshbXfwfNDc0YVj QGSDAOBWz0l1rSlwUgbpYkrqyTbBkSmnEVO6/eXxCppaSpmtTYF7A+LafIgiuaKHnx6nJ BcxEl4o0+EPL4nEm2mPbyVH+5kbzfr+KR4rxmcV1MKYiqFGHOX7ex6BLXgp/UWeNl7x7/ u7i6dks1h4FKTggTfKajUaf0hsdMZLdgEfjHvCx2LJnzxyIVFRbVhusCMm2TPgrRvqU82 SdVnC6POuCREJoiDrdX2PGks2hvDhxzj0XH/BB8AeAjjg4XF1iciQqzHK246/Zszm3w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792516311; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=XNNuCN/U6izbmBVvP629yRqSP6xtDUjEail1X7p38hc=; b=sz1J/o+7C+mRAoCD2J7eOpXAtqFxBvdzigfpPQs7QzvS7V5ZhVD385ZFDymp1VeojRqy VfD1wg63oxSJD+4upmdNF6MWgJAv3vascUIjKyEXGjCbEPa6RNLL9dgmEIOozHyLxGELp 45AYkcoxL5EpSTASDQys4u9+xGaqGRVRkzPENaOHKnXZbTN7mGliAnrNwUqOdGJcGe8DI RGw0ys7O2us2jfjylbtbqrwoAZFJ51eEthmGiXEAUp+rwjrwRIDTAkW4AO63E7rmACLha ZLZUcreLda3z8vFCbvqmQ111Rgr7Q7skEpJqY89MrsKdryoq9/Qcs6VfMEAba2bRk2A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AIa0nnUa; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0386060A2625; Tue, 20 Oct 2026 17:11:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AIa0nnUa X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792516300; b=Db0YHVSCHNhO5RlXHTPNI1uT7Qx6QOd362Ygm7jrJtk+NlNo00JrEAUbhr+nbIolBq6G rNDR9jakxWCeu5aQHQHHeEL5OzmGDDRKPULmh7DER0gn0tKiTqaxEV7EgXv3pyApf9PfF WHIaW1H7aRb6Amxw4kelb0Bs5Y4Du2tDpugy7tS1nQI8D7PNCcgxYHM3bXAt5s6Iw0V2B zT2/u6ooLYeDZWkA3V19C/A9l60cHS4n4SeeA1C6F499EOEIYg2CvWKtXQUKh6EN0sQCy GN7wjhM1jcmcdgjgWlIIh9O96qupNUhBGpzbejZM/hGW4dKFEbz2sjO6O55PbN0Cvng== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792516300; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=XNNuCN/U6izbmBVvP629yRqSP6xtDUjEail1X7p38hc=; b=e0kfsRoRfCdPRRwS332gRRqihYmkVrqEWNcvhQhUVEAuNFfPtVtOnGa3+QqOl0Lgbvel J111Ewbva2+gpbN5qYFt5ZljQJ7T5mtRkIkie+huZRm1zgRIRN78BkW2s6J2WJ81hl8TP aNaRpX/iarotkQUBUI6wBSDYvthJdiJv+Ud8CzAsFIZsrucAXas22Zw1UvVqgjX8SW04W 05K78tpfCzcegriFCaSGlEQT25966dcqCifvKiwjzzz8bCUpfS7Dt5qqXoXL+C+K5nP2I Ej2oEBBWF1JzOum/vEZWHW5nNfWB3qn1uWlDFQBIvgnLobRgh1ZBnzd/Aa/1ebNM+Fw== X-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=AIa0nnUa; arc=none smtp.remote-ip=100.103.45.18 X-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 C3E16606A325; Tue, 20 Oct 2026 17:11:39 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E298C1F000C9; Tue, 20 Oct 2026 17:11:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792516299; bh=XNNuCN/U6izbmBVvP629yRqSP6xtDUjEail1X7p38hc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=AIa0nnUaTNjCk4cIRx+AkEi4jLLZ57Qf0ViSOMKTRIMdooH1Vky3uiDTta6xfOW4x BVkQRXeK3R1aeCrBTgKo2nQak80wa5W7ZHXUF09k62mYS5GyisQD48yYvJu+PkiFQ9 MNmFzX/F/6av1OECw9Iyp4kGoVMQxS8VmtQ6qcTrtN9A7jC53gaMrsjf+DXG4mcgSt juuQ7y8yX4dDjvzi3i2hiUbFPl/TDIjvc8UYhzzGmG5ceB4oaqksMyULyYaYOOmQKP pDprqmhdBXFPk0pIs8hrE2dgqQTpdLSi1ghLcqLy9sXk6xP/rlZFIJ+foQ0uX9eq6b VSaOSPHWGoMsw== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, 1579567540@qq.com, stable@vger.kernel.org, mailhol@kernel.org X-In-Reply-To: <20261019170834.1727150-11-mkl@pengutronix.de> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list