From: Simon Horman <horms@kernel.org>
To: Hui Peng <benquike@gmail.com>
Cc: robin@protonic.nl, o.rempel@pengutronix.de, mkl@pengutronix.de,
mailhol@kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, kernel@pengutronix.de,
socketcan@hartkopp.net, linux-can@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] can: j1939: return 0 instead of user value in j1939_sk_setsockopt_flag()
Date: Tue, 22 Sep 2026 13:20:39 +0100 [thread overview]
Message-ID: <20260922122039.GE13925@horms.kernel.org> (raw)
In-Reply-To: <20260919213632.3313825-1-benquike@gmail.com>
On Sat, Sep 19, 2026 at 09:36:32PM +0000, Hui Peng wrote:
> In `j1939_sk_setsockopt_flag()`, after copying the integer option value
> `tmp` from userspace and updating `jsk->state`, the function returns
> `tmp` instead of `0`.
>
> If a caller passes a negative integer (e.g., `-1`) to enable
> `SO_J1939_BROADCAST` or `SO_J1939_PROMISC`, `if (tmp)` sets `jsk->state
> |= flag` and then returns the negative value as an error code from
> `setsockopt()`. If a caller passes a positive non-zero integer (e.g.,
> `1`), `setsockopt()` violates POSIX by returning `1` instead of `0`.
>
> Return `0` on success in `j1939_sk_setsockopt_flag()`.
>
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@gmail.com>
I agree that the problem described exists, and that your patch addresses it. That the but was introduced in the cited commit. And that the corrected
behaviour matches that described in Documentation/networking/j1939.rst
for SO_J1939_ERRQUEUE and SO_J1939_PROMISC, the two users of
j1939_sk_setsockopt_flag().
"The acceptable value size for this option is ``sizeof(int)``, and the
value is only differentiated between `0` and non-zero."
Reviewed-by: Simon Horman <horms@kernel.org>
prev parent reply other threads:[~2026-09-22 12:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 21:36 Hui Peng
2026-09-22 12:20 ` Simon Horman [this message]
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=20260922122039.GE13925@horms.kernel.org \
--to=horms@kernel.org \
--cc=benquike@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--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
all inboxes | Powered by JetHome®