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=1796401440; b=T8SPxNIUcYzvIxVVFQJkP/xSLZ/r2Uj4ALQS3cNCLTTleDocU6L/wFnyq9pcNg1O3la1 3MCQ78RczqzXl+tOWkLBgKAG5lMKFTfxX/oBN7C10s5wPScDBLoevu4Mw7DEWN12bm6/V Wr0kCFRCfnhkNvpz5ptEKenrZS2rnQJsnFFBdHi/2T/f5/CtbrhtpfHsx46qaxE8mnh5J BJHdD91Nu2nl+ZlNjldIz//aX/I31uU8Vt1mxj/wxZ75v6cKzXmknMLoCHZXA51jpdS1H EVRhK1fYKPqLZn1BIh4RD3JttB51pjG4xeevwVJtz2r0+0t4conzsO4Y9BjLXCtk5jA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401440; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=LTl8iNTWCdH366I1g0P4orUFcEo5Pc11SGdsefzZcQA=; b=ACoAWNijXv7Vpk5lUqIBxGINmFQ/lv/3iov1VckLdqyW8zgbr378ZbZ9VDiwet4yb25+ fH62uBHqkZQi6regOO3HiNafSCyxJyXQViVNdeJw9xVX+EGiWglDunf687Pd9AmcyL3U+ TR+YLAofQskhkC+CX9gYvcDvD6LqTG7sLTbonCkEHPpCWQeqJAhO1COG8lvSUWxc5erWI ffMFyg/e6+HGUJbX5Rx9vM4ZvCj7Id6U+FRdH6q9xZtY/dpwt3fRa7kg517kkHZD+33J/ /aSfuFFYlbYlTih1gQK2/z5Ab/T6cl03Q5qGZQAV/YvDT2qsKVu7mpUGsvyj7K/bVKQ== 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=ILtX2dm5; 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 BEDAC606A322 for ; Fri, 4 Dec 2026 16:24:00 +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=ILtX2dm5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC7BD1F00897; Fri, 4 Dec 2026 16:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796401440; bh=LTl8iNTWCdH366I1g0P4orUFcEo5Pc11SGdsefzZcQA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ILtX2dm5VC3wvrD7Rx/2oSIt8aL/f6biguM3QzZMoh4cQZktVgF/3y7J5mMmo360O w2jb+nQ8q6vHLeywpqRXIrgFa2zQ6x8MhwG4l3/3coXN8y6y106iUgbPQnBIU/BHkp K9DMXJ3OmhdQj3RP/KPSlF0Hl3NR+xuL+Qd6oMHjsKjAqfU0CPNLuJUt2i+8XQoiJ4 2uqskGcpCLV8dDytnlBcvoM8ScmWVZOJFf0rvsoH/dwTaya6f+BY1NGRMZFZ/iSqfO x+BELU/rfbK5tE00G8/UW1C+9TRgOBevv/P67N5XxQzTMwgAycFAFEx3w+S8jft0Sz DFHKVLDNLhvLg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v16 5/5] can: j1939: fix possibility of list corruption in __j1939_ecu_release() Reply-To: sashiko-reviews@lists.linux.dev To: "Tetsuo Handa" , linux-can@vger.kernel.org Cc: "Marc Kleine-Budde" , "Oliver Hartkopp" , "Vincent Mailhol" , "Oleksij Rempel" In-Reply-To: <006957f0-5a7b-4e2a-85ec-f0a08a0ad471@I-love.SAKURA.ne.jp> References: <02d9f333-d774-4cec-9d12-cb181395fd8a@I-love.SAKURA.ne.jp> <006957f0-5a7b-4e2a-85ec-f0a08a0ad471@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 16:23:59 +0000 X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] can: j1939: O(N^2) zombie scan and lock fan-out from deferred ECU list_del() -- commit 75cc65689af4612193f82d163f25817aea7da880 Author: Tetsuo Handa can: j1939: fix possibility of list corruption in __j1939_ecu_release() This commit defers list_del(&ecu->list) from __j1939_ecu_release() to __j1939_ecu_release_work() under write_lock_bh(&priv->lock), and updates j1939_ecu lookup and reference-taking helpers to skip zero-refcount entries. > diff --git a/net/can/j1939/bus.c b/net/can/j1939/bus.c > index b8e517c6ad1ce..a9dc565e34c22 100644 > --- a/net/can/j1939/bus.c > +++ b/net/can/j1939/bus.c > @@ -28,6 +28,9 @@ static void __j1939_ecu_release_work(struct work_struct= *work) > struct j1939_ecu *ecu =3D container_of(work, struct j1939_ecu, release_= work); > struct j1939_priv *priv =3D ecu->priv; > =20 > + write_lock_bh(&priv->lock); > + list_del(&ecu->list); > + write_unlock_bh(&priv->lock); > /* There can't be any ref on this ECU because __j1939_ecu_release() > * was already called. But we need to make sure that > * j1939_ecu_timer_handler() is no longer running before kfree(). > @@ -42,7 +45,6 @@ static void __j1939_ecu_release(struct kref *kref) > { > struct j1939_ecu *ecu =3D container_of(kref, struct j1939_ecu, kref); > =20 > - list_del(&ecu->list); > INIT_WORK(&ecu->release_work, __j1939_ecu_release_work); > queue_work(j1939_wq, &ecu->release_work); > } [Severity: Medium] Can deferring list_del(&ecu->list) to j1939_wq cause O(n^2) scans over priv->ecus under priv->lock? j1939_ecu_create_locked() appends new entries with list_add_tail(), so zero-refcount entries accumulate at the head of priv->ecus ahead of live ones whenever create/release churn outpaces the workqueue. During an address-claim burst in softirq, j1939_ac_process() alternating unicast and idle 0xfe claims preempts j1939_wq. Lookup paths such as j1939_ecu_get_by_name_locked() and j1939_ecu_find_by_name_locked() then scan past all dead entries under priv->lock, starving the cleanup worker. Separately, j1939_ecu_unmap_all() previously unlinked up to 254 mapped entries inside one write_lock_bh(&priv->lock) critical section, but now schedules up to 254 work items that each re-acquire write_lock_bh(), increasing contention with j1939_can_recv() readers. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/02d9f333-d774-4cec-= 9d12-cb181395fd8a@I-love.SAKURA.ne.jp?part=3D5