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=1796070309; b=ub0VvfW/kwhW7QMFGTYCopsZSFjMfnReheB2tK8qlhGm0cRkeqY+XPvklUeMiQqu2d6I KznPBSOXnag6ib3xHGnesJrrTaggDgAkGy+XL05FASbwLgy5xK5X+eZT256TJA0UQFml0 pQMYOtXOHq9pCZMhKuqUXScDh+rVqEmEo7Y703Nz5K3x0JrGI99WvgTrxXlh2tuktIRQE 0LZM26gnSzB4ced0jqY1M/bb+V975mKuEWaCibW72aEobJ2xxJM3NRCJRgpiIfZOI/SUX cReyE0pFpfqapeK2QtTBFsJU4iGddjVzxvz85+VmjimPOULTqIsBYkLH/E0j5d2YVsg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796070309; 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=q4jBewew/R/MwH9fN94zFGE9fzu7QAME3cUXqxVhi3Y=; b=AgK7Ps7CUzkae3uKAcoTLHHuys2XsZJ4C3IpWIFQUsn/1YQvAIkaoT7nw3YH2kI7sJiv OcD/g8rRBDb0RMWt+mZmxpOLaTDJJXkwVEUW9vxPh7XuLZKD9arI1/Jc9VJ42NRNxvSS9 aMpUa45c7F47A0JKih5B5cZoYsTPMjvBNNvZjgyO23m0uLoGnbmmjPI+rYIWa+zesaZJT KTZi3x5nWYhyMKYB9Kci+Ti5TgTd3sPFvEaGdqdQBENkfFpTLWAe1OnRWFdQR/f6s9Kcd VOflzuTLon7EJXhTNDQxKgVuKbBSCHiYlesnW4Luu9H2A6t5ZY+TuHY+SVdCBjOtksg== 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=CJ5gxgKA; 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 E75B1606A32A for ; Mon, 30 Nov 2026 20:25:08 +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=CJ5gxgKA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CD531F00896; Mon, 30 Nov 2026 20:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796070308; bh=q4jBewew/R/MwH9fN94zFGE9fzu7QAME3cUXqxVhi3Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=CJ5gxgKA79bbYTBUWvY9QZgpAJlwoSS2PrfW1+9qUpIZuJzlTnBRW/o6CsAcuF7mb wGX6CxBS7QblQtcAcXNVln5JjF4dzdzEMruZJ6bAXymccXIcO0jcYfDixxnvcTYIwu CxFUDSZQHW5Tdx1baVY9SZBP0HLvPEMnrHOmrAwRCIX+iqHhOZgnvhY8pMwz0I7iIU VtPjPYr5MTCkgP0lapRKsTg8FofZPC4tW2+8ddSvBwBT91i1W2hnon8BPieTE2m/HW QTFwbiOPkBmuywhRGO9Kf9ApqLH7xtRSJhHyNUHBns/N8048uWuTeEPy3x4FgBixeq JWaf5p0LyslWg== Subject: Re: [PATCH can-next v2 11/22] can: isotp: drop frames without N_PCI From: netdev-bot+sashiko@kernel.org To: socketcan@hartkopp.net Cc: linux-can@vger.kernel.org, mkl@pengutronix.de, kuba@kernel.org Date: Mon, 30 Nov 2026 20:25:08 +0000 Message-ID: <179607030811.3142.10779302114478643996@kernel.org> In-Reply-To: <20261128-getsockopt-memcg-isotp-v2-11-034ba95e17a4@hartkopp.net> References: <20261128-getsockopt-memcg-isotp-v2-11-034ba95e17a4@hartkopp.net> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The patch only partly removes the symptom its commit message describes. -- can: isotp: drop frames without N_PCI This patch adds a length check to isotp_rcv() so that CAN frames with CAN_DL < ae + N_PCI_SZ are dropped. Previously the AE and N_PCI bytes were read beyond CAN_DL. A zero-filled CAN_DL 0 frame was then handled as an SF with SF_DL 0, which ended an ongoing reception. > diff --git a/net/can/isotp.c b/net/can/isotp.c > index b237b1fb9d99c..798c1b4c6f6ae 100644 > --- a/net/can/isotp.c > +++ b/net/can/isotp.c > @@ -775,6 +775,10 @@ static void isotp_rcv(struct sk_buff *skb, void *data) > > cf = (struct canfd_frame *)skb->data; > > + /* frames without N_PCI (and AE) are no N_PDUs */ > + if (cf->len < ae + N_PCI_SZ) > + return; > + [Severity: Medium] This new check closes the read beyond CAN_DL. Can an invalid SF still end an ongoing reception, though? A frame one byte longer, with CAN_DL = ae + 1 and N_PCI byte 0x00, passes this check. It then goes into isotp_rcv_sf() with SF_DL 0. isotp_rcv_sf() resets the rx state before it checks the length: net/can/isotp.c:isotp_rcv_sf() { ... hrtimer_cancel(&so->rxtimer); WRITE_ONCE(so->rx.state, ISOTP_IDLE); if (!len || len > cf->len - pcilen) return 1; ... } So the zero-filled frame from the commit message, with its length byte raised by one, still ends a reception in ISOTP_WAIT_DATA. The same happens for any SF with SF_DL > CAN_DL - pcilen. It also happens for a CAN FD SF with CAN_DL > 8, the SF_DL escape value 0, and a real SF_DL that is 0 or too large. isotp_rcv_ff() uses the same order: net/can/isotp.c:isotp_rcv_ff() { ... hrtimer_cancel(&so->rxtimer); WRITE_ONCE(so->rx.state, ISOTP_IDLE); /* get the used sender LL_DL from the (first) CAN frame data length */ so->rx.ll_dl = padlen(cf->len); /* the first frame has to use the entire frame up to LL_DL length */ if (cf->len != so->rx.ll_dl) return 1; ... } padlen() maps 0..8 to 8, so an FF with CAN_DL 2..7 is rejected only after rx.state has been reset and rx.ll_dl overwritten. None of these paths set sk_err. The partial PDU is dropped silently, and the following CFs are ignored because rx.state is no longer ISOTP_WAIT_DATA. The SF handling in isotp_rcv() is also inconsistent. An FD SF with CAN_DL > 8 and SF_DL != 0 is ignored without touching the rx state, but the invalid SFs above end the reception: if (cf->len <= CAN_MAX_DLEN) { isotp_rcv_sf(sk, cf, SF_PCI_SZ4 + ae, skb, sf_dl); } else { if (can_is_canfd_skb(skb)) { ... if (sf_dl == 0) isotp_rcv_sf(sk, cf, SF_PCI_SZ8 + ae, skb, cf->data[SF_PCI_SZ4 + ae]); isotp_rcv_cf() checks the frame first and only then changes state: /* stop the rx timeout only for valid CFs (checked above) */ hrtimer_cancel(&so->rxtimer); The problem is still there at the end of the series. isotp_rcv_sf() and isotp_rcv_ff() still reset the state first. The later patches "can: isotp: drop FF frames with invalid length extension" and "can: isotp: check the minimum FF_DL" add more return paths after that reset. Their commit messages say these frames "shall be ignored according to ISO 15765-2:2016". As written, those invalid FFs abort an ongoing reception instead of being ignored. Would it make sense to validate SF_DL, the FF CAN_DL and FF_DL before cancelling rxtimer and setting rx.state to ISOTP_IDLE? The new N_PCI length check would still be needed in addition to that. > /* if enabled: check reception of my configured extended address */ > if (ae && cf->data[0] != so->opt.rx_ext_address) > return; -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261128-getsockopt-memcg-isotp-v2-0-034ba95e17a4%40hartkopp.net