From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34013363C60 for ; Tue, 14 Jul 2026 10:44:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784025873; cv=none; b=SxVdrlyPBatgJSoMI1YJo8ZOb/KrryeUYb+wv8Y+6Qp/1r2hR/27SHpxhH/Mepsk2RCF85CQV7QEdOpx3U+mFurg81v0ARNDzvkm6yuVkuTcmL7TXz1lmu0jba0/9T7sgtUcqtVtCrboGo/GM7KSJ66m+TE0+rSFpfStiSzq8Rk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784025873; c=relaxed/simple; bh=NN3OKzggappJDbMnDbGndDb7y/W3Yg+z6voMr2oWN+0=; h=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Date: Message-Id; b=diAAAy0KFivJ0j1d96HagumLvfUxvmiZwrib7pHwrXs/Gd9IvnZIoTV4si0S4higfC9Vd8nKFF8oqUTMQo1NFqrocoNnaG03iMp/Bo9dNvZK33DP3139cNHYgSjiwdEC2H7mk8AKxv5iwiyB3pgQ+iiN0iWB1qRaTaMlW6QeFtQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XPK5VGCz; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XPK5VGCz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65C751F000E9; Tue, 14 Jul 2026 10:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784025871; bh=6Cinaoutr2BaBRixXnDzp+jpH5uqQR7Q2fgmSCnn5CE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=XPK5VGCzm+N3tjV+3USEMbC4/2vwJNcPLMW2ak82+3WPwoLGiM5GaM2degaDBCwTa SLthf8jidQdBXdi3Al/FVLlJo0MXyvsRpkiKkZNJJ3d3vQV8EvgcYg0cuz6ljAaz9s OXxiGJMV2aQV4qP1F/Lbx34fLdQsuCVuaQeBa5CCiHRCDW1OzIYk1wuWC+4WejZQZh llvY9eMAUExeXmPM8eiesFBQXyM8xssaQunxlmtzJcHR4Z3TqW2hfc45X/okTYzlO2 8WGNdjOyvQ+plhVny/CsCCXM5AB72WaZDllA4icbFlhHH4tUGDEElhIUPb4LdAiaPI mOkq172y2Y4EQ== From: sashiko-bot@kernel.org Subject: Re: [PATCH v13 09/11] can: bcm: fix stale rx/tx ops after device removal Reply-To: sashiko-reviews@lists.linux.dev To: "Oliver Hartkopp" Cc: "Marc Kleine-Budde" , "Oliver Hartkopp" , "Oleksij Rempel" , linux-can@vger.kernel.org, "Vincent Mailhol" In-Reply-To: <20260714-bcm_fixes-v13-9-fd667c61099a@hartkopp.net> References: <20260714-bcm_fixes-v13-0-fd667c61099a@hartkopp.net> <20260714-bcm_fixes-v13-9-fd667c61099a@hartkopp.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 14 Jul 2026 10:44:30 +0000 Message-Id: <20260714104431.65C751F000E9@smtp.kernel.org> Precedence: bulk X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: Pre-existing issues: - [High] Unprotected concurrent access to op->rx_stamp and op->rx_ifindex i= n bcm_rx_handler causes data races and torn 64-bit reads on 32-bit architec= tures. -- --- Patch [9]: [PATCH v13 09/11] can: bcm: fix stale rx/tx ops after device= removal --- commit 7ac0666664aa8f0bbda8367494a6678c948d2082 Author: Oliver Hartkopp can: bcm: fix stale rx/tx ops after device removal This commit fixes issues where an RX_SETUP update could silently skip registering if a concurrent NETDEV_UNREGISTER occurred. It also ensures that cyclic transmissions are stopped when a device is removed. Link: https://lore.kernel.org/linux-can/20260708094536.DDF821F00A3A@smtp.ke= rnel.org/ Link: https://lore.kernel.org/linux-can/20260708154039.347ED1F000E9@smtp.ke= rnel.org/ > diff --git a/net/can/bcm.c b/net/can/bcm.c > index 5660165cdf0eb..10dd99ecce70e 100644 > --- a/net/can/bcm.c > +++ b/net/can/bcm.c [ ... ] > @@ -1483,18 +1495,32 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_= head, struct msghdr *msg, > err =3D -ENODEV; > } > =20 > - } else > + } else { > err =3D can_rx_register(sock_net(sk), NULL, op->can_id, > REGMASK(op->can_id), > bcm_rx_handler, op, "bcm", sk); > + } [Severity: High] This is a pre-existing issue, but is there a data race when bcm_rx_handler() accesses op->rx_stamp and op->rx_ifindex? When a BCM socket is bound to ifindex 0 (all CAN devices), multiple CAN frames arriving simultaneously on different CAN interfaces trigger bcm_rx_handler() concurrently. The handler unconditionally writes to op->rx_stamp and op->rx_ifindex outside of op->bcm_rx_update_lock: net/can/bcm.c:bcm_rx_handler() { ... /* save rx timestamp */ op->rx_stamp =3D skb->tstamp; /* save originator for recvfrom() */ op->rx_ifindex =3D skb->dev->ifindex; ... } These fields are then read in bcm_send_to_user(), sometimes locklessly (e.g. when called from bcm_rx_timeout_handler()): net/can/bcm.c:bcm_send_to_user() { ... /* restore rx timestamp */ skb->tstamp =3D op->rx_stamp; ... addr->can_ifindex =3D op->rx_ifindex; ... } Does this cause torn 64-bit reads of op->rx_stamp on 32-bit architectures, and can the interface index be logically swapped with that of a concurrent frame? [ ... ] --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260714-bcm_fixes-= v13-0-fd667c61099a@hartkopp.net?part=3D9