From: Oliver Hartkopp <socketcan@hartkopp.net>
To: mkl@pengutronix.de, kuba@kernel.org, davem@davemloft.net,
netdev@vger.kernel.org, linux-can@vger.kernel.org
Cc: Oliver Hartkopp <socketcan@hartkopp.net>, Thomas Wagner <thwa1@web.de>
Subject: [PATCH 1/2] can-isotp: block setsockopt on bound sockets
Date: Thu, 3 Dec 2020 15:06:03 +0100 [thread overview]
Message-ID: <20201203140604.25488-2-socketcan@hartkopp.net> (raw)
In-Reply-To: <20201203140604.25488-1-socketcan@hartkopp.net>
The isotp socket can be widely configured in its behaviour regarding
addressing types, fill-ups, receive pattern tests and link layer length.
Usually all these settings need to be fixed before bind() and can not
be changed afterwards.
This patch adds a check to enforce the common usage pattern.
Fixes: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol")
Tested-by: Thomas Wagner <thwa1@web.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
net/can/isotp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/can/isotp.c b/net/can/isotp.c
index d78ab13bd8be..26bdc3c20b7e 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1155,10 +1155,13 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname,
int ret = 0;
if (level != SOL_CAN_ISOTP)
return -EINVAL;
+ if (so->bound)
+ return -EISCONN;
+
switch (optname) {
case CAN_ISOTP_OPTS:
if (optlen != sizeof(struct can_isotp_options))
return -EINVAL;
--
2.29.2
next prev parent reply other threads:[~2020-12-03 14:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 14:06 [PATCH 0/2] can-isotp fix and functional addressing Oliver Hartkopp
2020-12-03 14:06 ` Oliver Hartkopp [this message]
2020-12-03 14:06 ` [PATCH 2/2] can-isotp: add SF_BROADCAST support for " Oliver Hartkopp
2020-12-03 14:25 ` [PATCH 0/2] can-isotp fix and " 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=20201203140604.25488-2-socketcan@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=thwa1@web.de \
/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).