Skip to content

Commit

Permalink
can: isotp: isotp_setsockopt(): block setsockopt on bound sockets
Browse files Browse the repository at this point in the history
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: e057dd3 ("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>
Link: https://lore.kernel.org/r/20201204133508.742120-3-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Oliver Hartkopp authored and Jakub Kicinski committed Dec 9, 2020
1 parent 72d05c0 commit 323a391
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/can/isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 323a391

Please sign in to comment.