All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
	kernel@pengutronix.de, Oliver Hartkopp <socketcan@hartkopp.net>,
	Thomas Wagner <thwa1@web.de>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [net 2/3] can: isotp: isotp_setsockopt(): block setsockopt on bound sockets
Date: Fri,  4 Dec 2020 14:35:07 +0100	[thread overview]
Message-ID: <20201204133508.742120-3-mkl@pengutronix.de> (raw)
In-Reply-To: <20201204133508.742120-1-mkl@pengutronix.de>

From: Oliver Hartkopp <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")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Tested-by: Thomas Wagner <thwa1@web.de>
Link: https://lore.kernel.org/r/20201203140604.25488-2-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 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
@@ -1157,6 +1157,9 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname,
 	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))
-- 
2.29.2



  parent reply	other threads:[~2020-12-04 13:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-04 13:35 pull-request: can 2020-12-04 Marc Kleine-Budde
2020-12-04 13:35 ` [net 1/3] can: softing: softing_netdev_open(): fix error handling Marc Kleine-Budde
2020-12-04 13:35 ` Marc Kleine-Budde [this message]
2020-12-04 13:35 ` [net 3/3] can: isotp: add SF_BROADCAST support for functional addressing Marc Kleine-Budde
2020-12-05  3:44   ` Jakub Kicinski
2020-12-05 11:26     ` Oliver Hartkopp
2020-12-05 20:24       ` Marc Kleine-Budde
2020-12-05 20:33         ` Jakub Kicinski
2020-12-05 20:56           ` Marc Kleine-Budde
2020-12-05 21:09             ` Jakub Kicinski
2020-12-05 21:20               ` Marc Kleine-Budde
2020-12-08 12:54               ` Oliver Hartkopp
2020-12-08 18:07                 ` Jakub Kicinski
2020-12-09  7:45                   ` Marc Kleine-Budde
2020-12-10  8:18                     ` Oliver Hartkopp
2020-12-10  9:55                       ` 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=20201204133508.742120-3-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.