Skip to contentSkip to conversation

net: netlink_getname, packet_getname -- use DECLARE_SOCKADDR guard

PATCH Applied Cyrill Gorcunov 2 participants 2 messages Nov 8, 2009 – Nov 11, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: netlink_getname, packet_getname -- use DECLARE_SOCKADDR guard

Use guard DECLARE_SOCKADDR in a few more places which allow us to catch if the structure copied back is too big.

---

Please review, comments are welcome!

 net/netlink/af_netlink.c |    2 +-
 net/packet/af_packet.c   |    2 +-
 net/unix/af_unix.c       |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
net/netlink/af_netlink.c +1 -1
Index: linux-2.6.git/net/netlink/af_netlink.c
=====================================================================
@@ -707,7 +707,7 @@ static int netlink_getname(struct socket
 {
 	struct sock *sk = sock->sk;
 	struct netlink_sock *nlk = nlk_sk(sk);
-	struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
+	DECLARE_SOCKADDR(struct sockaddr_nl *, nladdr, addr);
 
 	nladdr->nl_family = AF_NETLINK;
 	nladdr->nl_pad = 0;
net/packet/af_packet.c +1 -1
Index: linux-2.6.git/net/packet/af_packet.c
=====================================================================
@@ -1532,7 +1532,7 @@ static int packet_getname(struct socket 
 	struct net_device *dev;
 	struct sock *sk = sock->sk;
 	struct packet_sock *po = pkt_sk(sk);
-	struct sockaddr_ll *sll = (struct sockaddr_ll *)uaddr;
+	DECLARE_SOCKADDR(struct sockaddr_ll *, sll, uaddr);
 
 	if (peer)
 		return -EOPNOTSUPP;
net/unix/af_unix.c +1 -1
Index: linux-2.6.git/net/unix/af_unix.c
=====================================================================
@@ -1258,7 +1258,7 @@ static int unix_getname(struct socket *s
 {
 	struct sock *sk = sock->sk;
 	struct unix_sock *u;
-	struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
+	DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, uaddr);
 	int err = 0;
 
 	if (peer) {