From patchwork Wed Jul 20 11:06:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fedor Pchelkin X-Patchwork-Id: 12923790 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDF6EC43334 for ; Wed, 20 Jul 2022 11:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbiGTLHN (ORCPT ); Wed, 20 Jul 2022 07:07:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiGTLHL (ORCPT ); Wed, 20 Jul 2022 07:07:11 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D1D4B0D7; Wed, 20 Jul 2022 04:07:09 -0700 (PDT) Received: from localhost.localdomain (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id 08A0D40737AC; Wed, 20 Jul 2022 11:07:06 +0000 (UTC) From: Fedor Pchelkin To: Robin van der Gracht , Oleksij Rempel Cc: Fedor Pchelkin , Pengutronix Kernel Team , Oliver Hartkopp , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski , Elenita Hinds , Kurt Van Dijck , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov Subject: [PATCH] can: j1939: Remove unnecessary WARN_ON_ONCE in j1939_sk_queue_activate_next_locked() Date: Wed, 20 Jul 2022 14:06:45 +0300 Message-Id: <20220720110645.519601-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The purpose of WARN_ON_ONCE if the session with the same parameters has already been activated and is currently in active_session_list is not very clear. Is this warning implemented to indicate that userspace is doing something wrong? As far as I can see, there are two lists: active_session_list (which is for the whole device) and sk_session_queue (which is unique for each j1939_sock), and the situation when we have two sessions with the same type, addresses and destinations in two different sk_session_queues (owned by two different sockets) is actually highly probable - one is active and the other is willing to become active but the j1939_session_activate() does not let that happen. It is correct behaviour as I assume. Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol") Signed-off-by: Fedor Pchelkin Signed-off-by: Alexey Khoroshilov --- net/can/j1939/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c index f5ecfdcf57b2..be4b73afa16c 100644 --- a/net/can/j1939/socket.c +++ b/net/can/j1939/socket.c @@ -178,7 +178,7 @@ static void j1939_sk_queue_activate_next_locked(struct j1939_session *session) if (!first) return; - if (WARN_ON_ONCE(j1939_session_activate(first))) { + if (j1939_session_activate(first)) { first->err = -EBUSY; goto activate_next; } else {