aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/net.h3
-rw-r--r--include/linux/socket.h3
-rw-r--r--net/ipv4/af_inet.c2
3 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/net.h b/include/linux/net.h
index b42bb60fe92f..4da9d571b053 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -199,6 +199,9 @@ struct proto_ops {
199 struct pipe_inode_info *pipe, size_t len, unsigned int flags); 199 struct pipe_inode_info *pipe, size_t len, unsigned int flags);
200}; 200};
201 201
202#define DECLARE_SOCKADDR(type, dst, src) \
203 type dst = ({ __sockaddr_check_size(sizeof(*dst)); (type) src; })
204
202struct net_proto_family { 205struct net_proto_family {
203 int family; 206 int family;
204 int (*create)(struct net *net, struct socket *sock, int protocol); 207 int (*create)(struct net *net, struct socket *sock, int protocol);
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 59966f12990c..7b3aae2052a6 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -24,6 +24,9 @@ struct __kernel_sockaddr_storage {
24#include <linux/types.h> /* pid_t */ 24#include <linux/types.h> /* pid_t */
25#include <linux/compiler.h> /* __user */ 25#include <linux/compiler.h> /* __user */
26 26
27#define __sockaddr_check_size(size) \
28 BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage)))
29
27#ifdef __KERNEL__ 30#ifdef __KERNEL__
28# ifdef CONFIG_PROC_FS 31# ifdef CONFIG_PROC_FS
29struct seq_file; 32struct seq_file;
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 04a14b1600ac..538e84d0bcba 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -685,7 +685,7 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
685{ 685{
686 struct sock *sk = sock->sk; 686 struct sock *sk = sock->sk;
687 struct inet_sock *inet = inet_sk(sk); 687 struct inet_sock *inet = inet_sk(sk);
688 struct sockaddr_in *sin = (struct sockaddr_in *)uaddr; 688 DECLARE_SOCKADDR(struct sockaddr_in *, sin, uaddr);
689 689
690 sin->sin_family = AF_INET; 690 sin->sin_family = AF_INET;
691 if (peer) { 691 if (peer) {