[PATCH v1 15/25] j1939: socket: check broadcast on connect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Oleksij Rempel <linux@xxxxxxxxxxxxxxxx>

Signed-off-by: Oleksij Rempel <linux@xxxxxxxxxxxxxxxx>
---
 net/can/j1939/socket.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index 2d44db653020..01d1edc76cac 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -360,6 +360,14 @@ static int j1939_sk_connect(struct socket *sock, struct sockaddr *uaddr,
 		goto out_release_sock;
 	}
 
+	if (!addr->can_addr.j1939.name &&
+	    addr->can_addr.j1939.addr == J1939_NO_ADDR &&
+	    !sock_flag(&jsk->sk, SOCK_BROADCAST)) {
+		/* broadcast, but SO_BROADCAST not set */
+		ret = -EACCES;
+		goto out_release_sock;
+	}
+
 	jsk->addr.dst_name = addr->can_addr.j1939.name;
 	jsk->addr.da = addr->can_addr.j1939.addr;
 
-- 
2.20.1




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux