Re: [PATCH] can: j1939: Remove unnecessary WARN_ON_ONCE in j1939_sk_queue_activate_next_locked()

From: Fedor Pchelkin
Date: Thu Jul 28 2022 - 12:15:17 EST


Hello Oleksij,

I'm sorry for late answering.

On 20.07.2022 22:13, Oleksij Rempel wrote:
Are you working on some system where this use case is valid?

No, we are fuzzing the kernel and analyzing different warnings and
crashes.

On 20.07.2022 22:13, Oleksij Rempel wrote:
> yes

Well, there is a long story about where and for which purposes the
kernel warning macros should be correctly used and, overall,
WARN_ON_ONCE is not intended for user-space notification.

Linus Torvalds wrote:
> WARN_ON() should only be used for "This cannot happen, but if it does,
> I want to know how we got here".
>
> So if that j1939 thing is something that can be triggered by a user,
> then the backtrace should be reported to the driver maintainer, and
> then either
>
> (a) the WARN_ON_ONCE() should just be removed ("ok, this can happen,
> we understand why it can happen, and it's fine")
>
> (b) the problem the WARN_ON_ONCE() reports about should be made
> impossible some way
>
> (c) it might be downgraded to a pr_warn() if people really want to
> tell user space that "guys, you're doing something wrong" and it's
> considered a useful warning.

So WARN_ON_ONCE should be replaced with a more gentle variant - I think
pr_warn_once would suit this case. I've prepared a new patch for that,
it will follow this email.

Could you also look at the patch - [PATCH] can: j1939: fix memory leak of skbs - which I sent you on 08.07.2022, please?