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=1796070307; b=pTmpOShQ7TWYM+Gkaazl7BH8u7q/rBBC3CfnCs7dLuktW4YSEYVXzXV8hErHnwgjBICw SXUcbxOh47oBZV/3VvUM4/BwsoiJ+Hw7+fARBZkkPULBE8zToA4BWWENIzf6YHfFDfyhI MvM+5wAQDQF4NhkEB8PRtePpoxZ+4fSfkWBmuOL0FBOr6HjSbgneHHWQCI4M7XsE618Wj WwTM19ClQA9tGY5em+5Gz0Kvrr1k7lr8r7X2AgQ/OqgvH3HF9uYTj4PbvSw6N8WLF/62m Dd49XbW2fbwNIQUe/Lr4QhoT8MffjR9WDhXlkuKfqrmdwi9U+QccYh4KaIMT187pnNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796070307; 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=+mwSuw2p+PCW2+WFOg39PAINaZYkPfHBBP8lkPLScI0=; b=Y6SzgU4iTVxhTmx/dJbiquGnx7ibhs4cPn1ipxiY1LoZUyW/RAwaLJq5mkCq5TjhovKS 3RN0MSU76hgk8Nzr731Y2jxyIk95ztFRnmMNiNDezhOe4ohyCvcUkfGE+EeFDe9sKOdyZ ASi+4QxVyJO0pXrHiFqb/OCBZnyRzePMVHKcwZQh5xh4gJox68w9jWILu0z+6JgU3ne7G xpELc3oE8Nt9nNeRWGES7QrO0cBsUvOFnymml5w3Vn5//ftSIlVfSRjletVhc6kSdbER9 7tHyaj0gmQcirlgh2a0Ewe/2e9x5rT6Yjs9XueRHz9SDw9w2CBaXbwN5SlanwoSK8oQ== 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=EXiBlyOo; 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 9F198606A31A for ; Mon, 30 Nov 2026 20:25:07 +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=EXiBlyOo Received: by smtp.kernel.org (Postfix) with ESMTPSA id E40491F000C1; Mon, 30 Nov 2026 20:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796070307; bh=+mwSuw2p+PCW2+WFOg39PAINaZYkPfHBBP8lkPLScI0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=EXiBlyOoxwkwOw6Ba9aib0FNQUXwMFKjXZeQjNKeyqDn/HrKXsjOMLPnz2W2NKM8P XOPdalBIxX2xaAV91IUNMPUb8RcBIWSBD7nmKqhxZFoDkrjwk9EEJuHqXUAd09s7iA usHAYrxZgGKF/xuqrcl9DBApmGdl/oT4duSlOS+pDdh+WAvpZRDouajDTIKaa47uka vY1WE84LJUTpxN+VnYIjbutreN+y2vo//CeyAwVEq0FcP1Gp6srJZBlyWjAbocRDFp z5hsyW5/XmJEBvd1hqZZcbuYuAOXoJ7r5REsFobHsRKBihnorK1Ijqk82YPS2Q3kcC 6RMWNSGa6aQAg== Subject: Re: [PATCH can-next v2 08/22] 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: Mon, 30 Nov 2026 20:25:06 +0000 Message-ID: <179607030647.3142.13865631701044654929@kernel.org> In-Reply-To: <20261128-getsockopt-memcg-isotp-v2-8-034ba95e17a4@hartkopp.net> References: <20261128-getsockopt-memcg-isotp-v2-8-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] In isotp_setsockopt_locked() (net/can/isotp.c), the CAN_ISOTP_LL_OPTS handler now stores tx_flags with CANFD_FDF ORed in… -- can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS For CAN FD, this commit limits the CAN_ISOTP_LL_OPTS tx_flags to CANFD_BRS and CANFD_FDF. Any other flag now gets -EINVAL. For CAN FD it also ORs CANFD_FDF into the stored tx_flags, so that getsockopt() returns the flags of the created frames, and it documents the accepted flags. > diff --git a/net/can/isotp.c b/net/can/isotp.c > index ce541e57d1979..ea3790a855827 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] Does storing CANFD_FDF here break a read-modify-write of CAN_ISOTP_LL_OPTS when switching back to classical CAN? isotp_getsockopt() returns so->ll unchanged: case CAN_ISOTP_LL_OPTS: len = min_t(int, len, sizeof(struct can_isotp_ll_options)); val.ll = so->ll; break; The CAN CC check in isotp_setsockopt_locked() still requires tx_flags to be exactly 0: if (ll->mtu == CAN_MTU && (ll->tx_dl > CAN_MAX_DLEN || ll->tx_flags != 0)) return -EINVAL; So on an unbound socket this sequence now fails: setsockopt(LL_OPTS, {mtu=CANFD_MTU, tx_dl=64, tx_flags=0}) getsockopt(LL_OPTS) -> tx_flags = CANFD_FDF change only mtu=CAN_MTU and tx_dl=8, then write it back setsockopt(LL_OPTS, {mtu=CAN_MTU, tx_dl=8, tx_flags=CANFD_FDF}) -> -EINVAL Before this patch the stored tx_flags stayed 0, so the same sequence succeeded. A stored CANFD_BRS already had to be cleared before switching to CAN_MTU. That means only the CAN FD without BRS case behaves differently now. The commit message says "The CAN frames on the bus are not changed by this". It does not mention that the tx_flags value returned by getsockopt() is no longer accepted for CAN_MTU. Would it make sense to mask CANFD_FDF in the CAN_MTU check? Another option is to add CANFD_FDF only in isotp_getsockopt() and not store it in so->ll. > /* 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/20261128-getsockopt-memcg-isotp-v2-0-034ba95e17a4%40hartkopp.net