aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dichtel <nicolas.dichtel@6wind.com>2016-04-26 04:06:14 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-26 12:00:48 -0400
commit6ed46d1247a595c58b6c04481fa77cf532f45de0 (patch)
tree16ff8cec378c83d80cb395c152af472fa9fdb3de
parent3c6f3714d6a9e051eb84759e4fa5a2f4a3e730c6 (diff)
sock_diag: align nlattr properly when needed
I also fix the value of INET_DIAG_MAX. It's wrong since commit 8f840e47f190 which is only in net-next right now, thus I didn't make a separate patch. Fixes: 8f840e47f190 ("sctp: add the sctp_diag.c file") Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/uapi/linux/inet_diag.h4
-rw-r--r--net/core/sock_diag.c2
-rw-r--r--net/ipv4/inet_diag.c9
-rw-r--r--net/sctp/sctp_diag.c5
4 files changed, 13 insertions, 7 deletions
diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
index f5f3629dd553..a16643705669 100644
--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -115,9 +115,11 @@ enum {
115 INET_DIAG_SKV6ONLY, 115 INET_DIAG_SKV6ONLY,
116 INET_DIAG_LOCALS, 116 INET_DIAG_LOCALS,
117 INET_DIAG_PEERS, 117 INET_DIAG_PEERS,
118 INET_DIAG_PAD,
119 __INET_DIAG_MAX,
118}; 120};
119 121
120#define INET_DIAG_MAX INET_DIAG_SKV6ONLY 122#define INET_DIAG_MAX (__INET_DIAG_MAX - 1)
121 123
122/* INET_DIAG_MEM */ 124/* INET_DIAG_MEM */
123 125
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index ca9e35bbe13c..6b10573cc9fa 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -120,7 +120,7 @@ static size_t sock_diag_nlmsg_size(void)
120{ 120{
121 return NLMSG_ALIGN(sizeof(struct inet_diag_msg) 121 return NLMSG_ALIGN(sizeof(struct inet_diag_msg)
122 + nla_total_size(sizeof(u8)) /* INET_DIAG_PROTOCOL */ 122 + nla_total_size(sizeof(u8)) /* INET_DIAG_PROTOCOL */
123 + nla_total_size(sizeof(struct tcp_info))); /* INET_DIAG_INFO */ 123 + nla_total_size_64bit(sizeof(struct tcp_info))); /* INET_DIAG_INFO */
124} 124}
125 125
126static void sock_diag_broadcast_destroy_work(struct work_struct *work) 126static void sock_diag_broadcast_destroy_work(struct work_struct *work)
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index ad7956fa659a..25af1243649b 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -220,8 +220,9 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
220 } 220 }
221 221
222 if ((ext & (1 << (INET_DIAG_INFO - 1))) && handler->idiag_info_size) { 222 if ((ext & (1 << (INET_DIAG_INFO - 1))) && handler->idiag_info_size) {
223 attr = nla_reserve(skb, INET_DIAG_INFO, 223 attr = nla_reserve_64bit(skb, INET_DIAG_INFO,
224 handler->idiag_info_size); 224 handler->idiag_info_size,
225 INET_DIAG_PAD);
225 if (!attr) 226 if (!attr)
226 goto errout; 227 goto errout;
227 228
@@ -1078,7 +1079,9 @@ int inet_diag_handler_get_info(struct sk_buff *skb, struct sock *sk)
1078 } 1079 }
1079 1080
1080 attr = handler->idiag_info_size 1081 attr = handler->idiag_info_size
1081 ? nla_reserve(skb, INET_DIAG_INFO, handler->idiag_info_size) 1082 ? nla_reserve_64bit(skb, INET_DIAG_INFO,
1083 handler->idiag_info_size,
1084 INET_DIAG_PAD)
1082 : NULL; 1085 : NULL;
1083 if (attr) 1086 if (attr)
1084 info = nla_data(attr); 1087 info = nla_data(attr);
diff --git a/net/sctp/sctp_diag.c b/net/sctp/sctp_diag.c
index bb2d8d9608e9..84829fff3bc9 100644
--- a/net/sctp/sctp_diag.c
+++ b/net/sctp/sctp_diag.c
@@ -161,8 +161,9 @@ static int inet_sctp_diag_fill(struct sock *sk, struct sctp_association *asoc,
161 if (ext & (1 << (INET_DIAG_INFO - 1))) { 161 if (ext & (1 << (INET_DIAG_INFO - 1))) {
162 struct nlattr *attr; 162 struct nlattr *attr;
163 163
164 attr = nla_reserve(skb, INET_DIAG_INFO, 164 attr = nla_reserve_64bit(skb, INET_DIAG_INFO,
165 sizeof(struct sctp_info)); 165 sizeof(struct sctp_info),
166 INET_DIAG_PAD);
166 if (!attr) 167 if (!attr)
167 goto errout; 168 goto errout;
168 169