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=1796183336; b=am0CZnFeDJbv70AbybuIJ5N0KY6NUfyGN4NAiw9nAWCT2awRQQerfCs5bDOX1V1cvkl8 lvbuJlDNs5FbrVNoQV0wXoS6kwvUUu5Zg0XJaCdPg3ZqsLa+qGgd8O/VrVRh6U5AHU+6T PT+b/2aKNufhhVKCerFi2Bwqk7oJYeNILg2uNV4krr4O4vkknidV+qqAVYNI7YPemkOLt G8V1o4vfu84zIPiv3hhw2NkUDkZJKi870eR+Xzg7/+LukLrdZp9tJ7+u80bpFFw3WJ+se XNHDK/gZSBFIZ5hDsKd29bQpxy/Mmn4r2AA6PyZzTRc2e7cjiPfE31Ubh4Thg//Z0Gg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796183336; 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=ZQYCuKtrR++OpNYoEJnKaycaVuVMDrSU9DTUyB+A8OM=; b=ZwGTIncPAHc7rdgBKFLCK9wUTd4N2cd8u9Xbwg7aO/TUrHiSPXRRtjTA0PmUgldAZSIC TzgsqC4riOnxDHo6V6/WwxY0Qx6nwYs0NWv7nX0w5RP4wBnYKjJKxSAxmrQfiJqD0ZRZQ LwVxOYDxAgnLswHhXP7hSwHxExRxr3QBE/3UZy3MVboRBTtYEykOZBZQ6ishOSNWKKKtP sw0YK6nmiGalU0pGDqxIm6AX0AgmOFhcoec8y+oBjsC8v9uIo4M9SVwpQB4G4oXArtVC2 hJfgTIlndyGqs65wgOkVLc5K+0FuO1NPNTSZyc+YenhSTIFh12F9hNeSpnPmC02Jk2w== 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=YtRM9FWw; 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 A4F5A606A31A for ; Wed, 2 Dec 2026 03:48:56 +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=YtRM9FWw Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8B8F1F00893; Wed, 2 Dec 2026 03:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796183336; bh=ZQYCuKtrR++OpNYoEJnKaycaVuVMDrSU9DTUyB+A8OM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=YtRM9FWwSvo9/TKmDhEZFXcfNoJnwmFiCd9MuQrROawCgNVPwRbKSWxpsrRmK4ZKh fiXhma6VJAry3ollEFGl2BW1QtKFyR/Y3LnYw3WjeJNAxIjeCGru0RGY7Vd9g6qqkX DV9qxoa4ZMaJm8Ugn5+yY1sVq6mTv7nPvCCgozn896in7JWFTrUhlcJVG5AcM+ScO1 YN8xhVHQrPbVqZJWic5buJ0rymeYaBDmUbBWJBhRtH0AoeAzVPlz7A+xdVtS/yxN65 +cYP5BBBUAffij8RJnGv5jU8eYgpy9faYTaHFsA/EkphhLIEtK9ycA3EKUsxB7iynv Rp9eAVAnlHwpw== Subject: Re: [PATCH can-next v3 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, kuba@kernel.org Date: Wed, 02 Dec 2026 03:48:55 +0000 Message-ID: <179618333533.3142.4629180442411724805@kernel.org> In-Reply-To: <20261130-getsockopt-memcg-isotp-v3-9-21d72c15ad1d@hartkopp.net> References: <20261130-getsockopt-memcg-isotp-v3-9-21d72c15ad1d@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] In isotp_setsockopt_locked() (net/can/isotp.c), the CAN_ISOTP_LL_OPTS handler now always runs `so->ll.tx_flags |=… -- can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS This patch tightens the CAN_ISOTP_LL_OPTS checks so that CAN FD sockets only accept CANFD_BRS and CANFD_FDF in tx_flags. All other flags are rejected with -EINVAL. It also always adds CANFD_FDF to the stored tx_flags for CAN FD, so that getsockopt() reports the flags of the created CAN FD frames. > 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] Could this break a getsockopt()/setsockopt() round trip that worked before? Say an unbound socket is set up with {mtu = CANFD_MTU, tx_dl = 64, tx_flags = 0}. The stored tx_flags now becomes CANFD_FDF (0x04), and isotp_getsockopt() returns it unchanged: net/can/isotp.c:isotp_getsockopt() { ... val.ll = so->ll; ... } If userspace then reads the options, changes only mtu to CAN_MTU and tx_dl to 8, and writes the struct back, the existing classical CAN check in isotp_setsockopt_locked() rejects it: if (ll->mtu == CAN_MTU && (ll->tx_dl > CAN_MAX_DLEN || ll->tx_flags != 0)) return -EINVAL; Before this patch the same sequence succeeded. In addition, code that writes tx_flags = 0 and compares the value it reads back now sees 0x04. can_send() in net/can/af_can.c already sets the marker on every CAN FD frame: cfd->flags |= CANFD_FDF; So storing it in so->ll does not change what goes on the bus. It only changes the value userspace sees. The commit message describes the tightening in terms of CANFD_ESI and undefined flags. Neither it nor the iso15765-2.rst text says that CANFD_FDF has to be cleared before switching an existing configuration back to classical CAN. Would it be better to not store CANFD_FDF in so->ll.tx_flags? Another option is to ignore or mask CANFD_FDF in the CAN_MTU check, so the value returned by getsockopt() is always accepted by setsockopt(). > /* 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/20261130-getsockopt-memcg-isotp-v3-0-21d72c15ad1d%40hartkopp.net