linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Fedor Pchelkin <pchelkin@ispras.ru>
Cc: Robin van der Gracht <robin@protonic.nl>,
	Oleksij Rempel <linux@rempel-privat.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Elenita Hinds <ecathinds@gmail.com>,
	Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Alexey Khoroshilov <khoroshilov@ispras.ru>
Subject: Re: [PATCH] can: j1939: Remove unnecessary WARN_ON_ONCE in j1939_sk_queue_activate_next_locked()
Date: Wed, 20 Jul 2022 21:13:57 +0200	[thread overview]
Message-ID: <20220720191357.GB5600@pengutronix.de> (raw)
In-Reply-To: <20220720110645.519601-1-pchelkin@ispras.ru>

Hi Fedor,

On Wed, Jul 20, 2022 at 02:06:45PM +0300, Fedor Pchelkin wrote:
> 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?

yes.

> 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.

No. It is not typical use case and most probably it will create
problems. Are you working on some system where this use case is valid?

> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
> 
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>
> ---
>  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 {
> -- 
> 2.25.1
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2022-07-20 19:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 11:06 [PATCH] can: j1939: Remove unnecessary WARN_ON_ONCE in j1939_sk_queue_activate_next_locked() Fedor Pchelkin
2022-07-20 19:13 ` Oleksij Rempel [this message]
2022-07-28 16:14   ` Fedor Pchelkin
2022-07-28 16:34     ` [PATCH] can: j1939: Replace WARN_ON_ONCE with pr_warn_once() " Fedor Pchelkin
2022-07-28 16:58       ` Oleksij Rempel
2022-07-29 14:06         ` [PATCH v2] can: j1939: Replace WARN_ON_ONCE with netdev_warn_once() " Fedor Pchelkin
2022-07-29 14:26           ` Oleksij Rempel
2022-07-29 14:36             ` Fedor Pchelkin
2022-08-08  8:06               ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220720191357.GB5600@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=dev.kurt@vandijck-laurijssen.be \
    --cc=ecathinds@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=khoroshilov@ispras.ru \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pchelkin@ispras.ru \
    --cc=robin@protonic.nl \
    --cc=socketcan@hartkopp.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).