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=1796278531; b=YEo5rC82kPIk8abB4E+PiW5Pe3Oo9bnRJfEgwmJEYHxOHPiVo5t3c/ncR3y3TN9sCAl5 SyTz62qxnJDv4G3cQb4bMSaZEii+bB4a5HAtZu1qJk6lJHPEpOIF8ycfZ6/DjJHXGzEfE gZwOBoVl4Kd03BeptuhEVsXdSF9BwLVNGW5p192QXKLWNuILezX2RbU9t2TkNoHmMbaD5 iH2J8ed+Jm4dIkopqqM5lxT9tleVloAkHg5VRE4t33d+q8IQNa/W06ReVSqKmlDLf4xQO 7LslNy9NLnJfpGllYe7p+lSqDHGUwwM6e6a3Yu7mlrzhiNUNtlu67/NHZwuwXzaZgAQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796278531; 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=eWqRhVCU/P85p0IID72Y8yM2eir1QpHjAkNUx5eagN8=; b=QEIjybozYS6FxEU4XV2/yjx8P3btgQJOBnTA5hW8Fa+TSvJmzBXuW3zBLSYrb80aqaj+ 4izTibpHGWNxtSwKmKTiYEt3ox1TGFU+OTixI/8BACmzGSGTohAeiKv80RtXJm2VXShS7 52ors34iH4tS3t+Vwf7ffQfO9Itv6JpiyzkJjjtZfZzCmIz7BQO4aGNL0z84NkJVeS5kX eYDNujwXsioB5FRMEmtf12wwliRmqXUiypM7+3LFHVqnnR3p8ibrR+NSqMCP2w9vLJNYr a7IfhjrIJxkxAJYR2w6YKoz+QVtoKV4R8Rx1tCb8YK2DO3+6cXMBh811lEjMc26w2Sg== 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=RWbHfhzq; 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 D45C8606A322 for ; Thu, 3 Dec 2026 06:15:31 +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=RWbHfhzq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1562E1F00893; Thu, 3 Dec 2026 06:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796278531; bh=eWqRhVCU/P85p0IID72Y8yM2eir1QpHjAkNUx5eagN8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=RWbHfhzqmwDyqNX6Ib7fPhoR9a0EbDzkS7N7+fkXCJUTHGSQWwunZE4S09Vsl9CXN NHV7qH3eDKIf13i9UMJpnc3zTJXrmDkyPQT23o/N6ztSBly236Xw/bDV91zyZ3b6Cw HPF4P4wLWpqdWSvxIgkWfwWjUEBU4ATNcAWcqhAF9inZPynsg2k8EGPq/Q/FksPKSW es+rtwu48HX7lem4eUALuP+frA71oVzUi2WWKcUwiy28oyQ+FUHQBc8iV+TvJJI8VQ RJditsyeYT9oKxWlHXDog+/o0gOIcHTPAVld86qxGQTQnMiJ3/ZKs1M6KJiCNZqhu+ SzvU06sTrWKAQ== Subject: Re: [PATCH can-next v4 09/23] can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS From: netdev-bot+sashiko@kernel.org To: socketcan@hartkopp.net Cc: linux-can@vger.kernel.org, mkl@pengutronix.de, sashiko-bot@kernel.org, zihanx@nebusec.ai, o.rempel@pengutronix.de, yewentian395@gmail.com, kuba@kernel.org Date: Thu, 03 Dec 2026 06:15:30 +0000 Message-ID: <179627853066.3142.11128687057743464854@kernel.org> In-Reply-To: <20261201-getsockopt-memcg-isotp-v4-9-97261be8e38e@hartkopp.net> References: <20261201-getsockopt-memcg-isotp-v4-9-97261be8e38e@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 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 1 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] In isotp_setsockopt_locked() (net/can/isotp.c), CANFD_FDF is now ORed into the stored so->ll.tx_flags whenever ll.mtu == CANFD_MTU. - [Low] The comment this patch adds to the tx_flags field of struct can_isotp_ll_options in include/uapi/linux/can/isotp.h reads 'only… -- can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS This commit restricts the CAN FD tx_flags in CAN_ISOTP_LL_OPTS to CANFD_BRS and CANFD_FDF, and rejects every other bit with -EINVAL. It also ORs CANFD_FDF into the stored tx_flags for CAN FD, so getsockopt() returns the flags of the created CAN FD frames. The isotp.h and iso15765-2.rst documentation is updated to match. [ ... ] > diff --git a/include/uapi/linux/can/isotp.h b/include/uapi/linux/can/isotp.h > index a2e5aa6f9e82d..eb8b5298f7a5b 100644 > --- a/include/uapi/linux/can/isotp.h > +++ b/include/uapi/linux/can/isotp.h > @@ -119,6 +119,8 @@ struct can_isotp_ll_options { > > __u8 tx_flags; /* set into struct canfd_frame.flags */ > /* at frame creation: e.g. CANFD_BRS */ > + /* only CANFD_BRS and CANFD_FDF allowed */ > + /* CANFD_FDF is always set for CAN FD */ [Severity: Low] This isn't a bug, but should this uAPI comment also mention the mtu dependency? isotp_setsockopt_locked() only accepts these bits when mtu == CANFD_MTU. With mtu == CAN_MTU any non-zero tx_flags still fails: if (ll->mtu == CAN_MTU && (ll->tx_dl > CAN_MAX_DLEN || ll->tx_flags != 0)) return -EINVAL; So a call like setsockopt(CAN_ISOTP_LL_OPTS, {mtu=CAN_MTU, tx_dl=8, tx_flags=CANFD_BRS}) returns -EINVAL, although the header says CANFD_BRS is allowed. The iso15765-2.rst text added by this patch gets it right ("has to be 0 for classical CAN frames"). Only the exported header leaves that out. > /* Obsolete when the BRS flag is fixed */ > /* by the CAN netdriver configuration */ > }; > diff --git a/net/can/isotp.c b/net/can/isotp.c > index aa7bfed15500e..992e8d016e9d4 100644 > --- a/net/can/isotp.c > +++ b/net/can/isotp.c > @@ -1796,8 +1796,17 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname, > (ll->tx_dl > CAN_MAX_DLEN || ll->tx_flags != 0)) > return -EINVAL; > > + /* only CANFD_BRS (and the CANFD_FDF marker) for CAN FD frames */ > + if (ll->mtu == CANFD_MTU && > + (ll->tx_flags & ~(CANFD_BRS | CANFD_FDF))) > + return -EINVAL; > + > memcpy(&so->ll, ll, sizeof(*ll)); > > + /* CAN FD frames are always marked with CANFD_FDF */ > + if (so->ll.mtu == CANFD_MTU) > + so->ll.tx_flags |= CANFD_FDF; [Severity: Medium] Can this break a get/modify/set of the LL options when switching back to classical CAN? isotp_getsockopt() returns the stored options unchanged: case CAN_ISOTP_LL_OPTS: len = min_t(int, len, sizeof(struct can_isotp_ll_options)); val.ll = so->ll; Userspace now sees CANFD_FDF in tx_flags even when it never set that bit. Take this sequence on an unbound socket: setsockopt(CAN_ISOTP_LL_OPTS, {mtu=CANFD_MTU, tx_dl=8, tx_flags=0}) getsockopt(CAN_ISOTP_LL_OPTS) -> tx_flags == CANFD_FDF set mtu = CAN_MTU in the returned struct setsockopt(CAN_ISOTP_LL_OPTS) -> -EINVAL The last call hits the unchanged CAN_MTU check above: if (ll->mtu == CAN_MTU && (ll->tx_dl > CAN_MAX_DLEN || ll->tx_flags != 0)) return -EINVAL; Before this patch, getsockopt() returned exactly what was written (tx_flags=0), so the same sequence worked. Every step happens before bind, and ISO-TP sockets need no capability. The commit message says getsockopt() now returns "the flags of the created CAN FD frames" and that "The CAN frames on the bus are not changed by this". It doesn't say that this round trip can now be rejected. The CAN core already sets the marker at send time in af_can.c: cfd->flags |= CANFD_FDF; So keeping CANFD_FDF out of the stored so->ll.tx_flags would not change any frame on the bus. The same code is still there at the end of the series, after "can: isotp: introduce CAN_ISOTP_MIN_TX_DL". > + > /* set ll_dl for tx path to similar place as for rx */ > so->tx.ll_dl = ll->tx_dl; > break; -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-getsockopt-memcg-isotp-v4-0-97261be8e38e%40hartkopp.net