aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/skbuff.h2
-rw-r--r--include/net/bluetooth/bluetooth.h14
-rw-r--r--include/net/sock.h23
-rw-r--r--net/bluetooth/af_bluetooth.c3
-rw-r--r--net/bluetooth/hci_core.c12
-rw-r--r--net/bluetooth/hci_event.c4
-rw-r--r--net/bluetooth/hci_request.c6
-rw-r--r--net/bluetooth/hci_sock.c2
-rw-r--r--net/can/bcm.c2
-rw-r--r--net/can/raw.c6
-rw-r--r--net/core/sock.c2
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/tcp.c3
-rw-r--r--net/ipv6/af_inet6.c2
-rw-r--r--net/packet/af_packet.c35
-rw-r--r--net/rxrpc/ar-recvmsg.c2
-rw-r--r--net/sctp/protocol.c3
-rw-r--r--net/socket.c4
18 files changed, 79 insertions, 48 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index d898b32dedcc..bba1330757c0 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -492,7 +492,6 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
492 * @napi_id: id of the NAPI struct this skb came from 492 * @napi_id: id of the NAPI struct this skb came from
493 * @secmark: security marking 493 * @secmark: security marking
494 * @mark: Generic packet mark 494 * @mark: Generic packet mark
495 * @dropcount: total number of sk_receive_queue overflows
496 * @vlan_proto: vlan encapsulation protocol 495 * @vlan_proto: vlan encapsulation protocol
497 * @vlan_tci: vlan tag control information 496 * @vlan_tci: vlan tag control information
498 * @inner_protocol: Protocol (encapsulation) 497 * @inner_protocol: Protocol (encapsulation)
@@ -641,7 +640,6 @@ struct sk_buff {
641#endif 640#endif
642 union { 641 union {
643 __u32 mark; 642 __u32 mark;
644 __u32 dropcount;
645 __u32 reserved_tailroom; 643 __u32 reserved_tailroom;
646 }; 644 };
647 645
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index e00455aab18c..4500bf88ff55 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -275,21 +275,17 @@ struct hci_dev;
275 275
276typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode); 276typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
277 277
278struct hci_req_ctrl {
279 bool start;
280 u8 event;
281 hci_req_complete_t complete;
282};
283
284struct bt_skb_cb { 278struct bt_skb_cb {
285 __u8 pkt_type; 279 __u8 pkt_type;
286 __u8 incoming; 280 __u8 force_active;
287 __u16 opcode; 281 __u16 opcode;
288 __u16 expect; 282 __u16 expect;
289 __u8 force_active; 283 __u8 incoming:1;
284 __u8 req_start:1;
285 u8 req_event;
286 hci_req_complete_t req_complete;
290 struct l2cap_chan *chan; 287 struct l2cap_chan *chan;
291 struct l2cap_ctrl control; 288 struct l2cap_ctrl control;
292 struct hci_req_ctrl req;
293 bdaddr_t bdaddr; 289 bdaddr_t bdaddr;
294 __le16 psm; 290 __le16 psm;
295}; 291};
diff --git a/include/net/sock.h b/include/net/sock.h
index ab186b1d31ff..38369d3580a1 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2078,6 +2078,29 @@ static inline int sock_intr_errno(long timeo)
2078 return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR; 2078 return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR;
2079} 2079}
2080 2080
2081struct sock_skb_cb {
2082 u32 dropcount;
2083};
2084
2085/* Store sock_skb_cb at the end of skb->cb[] so protocol families
2086 * using skb->cb[] would keep using it directly and utilize its
2087 * alignement guarantee.
2088 */
2089#define SOCK_SKB_CB_OFFSET ((FIELD_SIZEOF(struct sk_buff, cb) - \
2090 sizeof(struct sock_skb_cb)))
2091
2092#define SOCK_SKB_CB(__skb) ((struct sock_skb_cb *)((__skb)->cb + \
2093 SOCK_SKB_CB_OFFSET))
2094
2095#define sock_skb_cb_check_size(size) \
2096 BUILD_BUG_ON((size) > SOCK_SKB_CB_OFFSET)
2097
2098static inline void
2099sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
2100{
2101 SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
2102}
2103
2081void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, 2104void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
2082 struct sk_buff *skb); 2105 struct sk_buff *skb);
2083void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, 2106void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index ce22e0cfa923..4b904c97a068 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -711,10 +711,9 @@ EXPORT_SYMBOL_GPL(bt_debugfs);
711 711
712static int __init bt_init(void) 712static int __init bt_init(void)
713{ 713{
714 struct sk_buff *skb;
715 int err; 714 int err;
716 715
717 BUILD_BUG_ON(sizeof(struct bt_skb_cb) > sizeof(skb->cb)); 716 sock_skb_cb_check_size(sizeof(struct bt_skb_cb));
718 717
719 BT_INFO("Core ver %s", VERSION); 718 BT_INFO("Core ver %s", VERSION);
720 719
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3322d3f4c85a..80f40e859d7d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3517,7 +3517,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
3517 /* Stand-alone HCI commands must be flagged as 3517 /* Stand-alone HCI commands must be flagged as
3518 * single-command requests. 3518 * single-command requests.
3519 */ 3519 */
3520 bt_cb(skb)->req.start = true; 3520 bt_cb(skb)->req_start = 1;
3521 3521
3522 skb_queue_tail(&hdev->cmd_q, skb); 3522 skb_queue_tail(&hdev->cmd_q, skb);
3523 queue_work(hdev->workqueue, &hdev->cmd_work); 3523 queue_work(hdev->workqueue, &hdev->cmd_work);
@@ -4195,7 +4195,7 @@ static bool hci_req_is_complete(struct hci_dev *hdev)
4195 if (!skb) 4195 if (!skb)
4196 return true; 4196 return true;
4197 4197
4198 return bt_cb(skb)->req.start; 4198 return bt_cb(skb)->req_start;
4199} 4199}
4200 4200
4201static void hci_resend_last(struct hci_dev *hdev) 4201static void hci_resend_last(struct hci_dev *hdev)
@@ -4255,14 +4255,14 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status)
4255 * command queue (hdev->cmd_q). 4255 * command queue (hdev->cmd_q).
4256 */ 4256 */
4257 if (hdev->sent_cmd) { 4257 if (hdev->sent_cmd) {
4258 req_complete = bt_cb(hdev->sent_cmd)->req.complete; 4258 req_complete = bt_cb(hdev->sent_cmd)->req_complete;
4259 4259
4260 if (req_complete) { 4260 if (req_complete) {
4261 /* We must set the complete callback to NULL to 4261 /* We must set the complete callback to NULL to
4262 * avoid calling the callback more than once if 4262 * avoid calling the callback more than once if
4263 * this function gets called again. 4263 * this function gets called again.
4264 */ 4264 */
4265 bt_cb(hdev->sent_cmd)->req.complete = NULL; 4265 bt_cb(hdev->sent_cmd)->req_complete = NULL;
4266 4266
4267 goto call_complete; 4267 goto call_complete;
4268 } 4268 }
@@ -4271,12 +4271,12 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status)
4271 /* Remove all pending commands belonging to this request */ 4271 /* Remove all pending commands belonging to this request */
4272 spin_lock_irqsave(&hdev->cmd_q.lock, flags); 4272 spin_lock_irqsave(&hdev->cmd_q.lock, flags);
4273 while ((skb = __skb_dequeue(&hdev->cmd_q))) { 4273 while ((skb = __skb_dequeue(&hdev->cmd_q))) {
4274 if (bt_cb(skb)->req.start) { 4274 if (bt_cb(skb)->req_start) {
4275 __skb_queue_head(&hdev->cmd_q, skb); 4275 __skb_queue_head(&hdev->cmd_q, skb);
4276 break; 4276 break;
4277 } 4277 }
4278 4278
4279 req_complete = bt_cb(skb)->req.complete; 4279 req_complete = bt_cb(skb)->req_complete;
4280 kfree_skb(skb); 4280 kfree_skb(skb);
4281 } 4281 }
4282 spin_unlock_irqrestore(&hdev->cmd_q.lock, flags); 4282 spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index a3fb094822b6..8e8c4334c379 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3106,7 +3106,7 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
3106 cancel_delayed_work(&hdev->cmd_timer); 3106 cancel_delayed_work(&hdev->cmd_timer);
3107 3107
3108 if (ev->status || 3108 if (ev->status ||
3109 (hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->req.event)) 3109 (hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->req_event))
3110 hci_req_cmd_complete(hdev, opcode, ev->status); 3110 hci_req_cmd_complete(hdev, opcode, ev->status);
3111 3111
3112 if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) { 3112 if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
@@ -5039,7 +5039,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
5039 5039
5040 skb_pull(skb, HCI_EVENT_HDR_SIZE); 5040 skb_pull(skb, HCI_EVENT_HDR_SIZE);
5041 5041
5042 if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->req.event == event) { 5042 if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->req_event == event) {
5043 struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; 5043 struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data;
5044 u16 opcode = __le16_to_cpu(cmd_hdr->opcode); 5044 u16 opcode = __le16_to_cpu(cmd_hdr->opcode);
5045 5045
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index b59f92c6df0c..f857e765e081 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -55,7 +55,7 @@ int hci_req_run(struct hci_request *req, hci_req_complete_t complete)
55 return -ENODATA; 55 return -ENODATA;
56 56
57 skb = skb_peek_tail(&req->cmd_q); 57 skb = skb_peek_tail(&req->cmd_q);
58 bt_cb(skb)->req.complete = complete; 58 bt_cb(skb)->req_complete = complete;
59 59
60 spin_lock_irqsave(&hdev->cmd_q.lock, flags); 60 spin_lock_irqsave(&hdev->cmd_q.lock, flags);
61 skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q); 61 skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q);
@@ -116,9 +116,9 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
116 } 116 }
117 117
118 if (skb_queue_empty(&req->cmd_q)) 118 if (skb_queue_empty(&req->cmd_q))
119 bt_cb(skb)->req.start = true; 119 bt_cb(skb)->req_start = 1;
120 120
121 bt_cb(skb)->req.event = event; 121 bt_cb(skb)->req_event = event;
122 122
123 skb_queue_tail(&req->cmd_q, skb); 123 skb_queue_tail(&req->cmd_q, skb);
124} 124}
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 1d65c5be7c82..37198fb99ffe 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -965,7 +965,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
965 /* Stand-alone HCI commands must be flagged as 965 /* Stand-alone HCI commands must be flagged as
966 * single-command requests. 966 * single-command requests.
967 */ 967 */
968 bt_cb(skb)->req.start = true; 968 bt_cb(skb)->req_start = 1;
969 969
970 skb_queue_tail(&hdev->cmd_q, skb); 970 skb_queue_tail(&hdev->cmd_q, skb);
971 queue_work(hdev->workqueue, &hdev->cmd_work); 971 queue_work(hdev->workqueue, &hdev->cmd_work);
diff --git a/net/can/bcm.c b/net/can/bcm.c
index ee9ffd956552..d559f922326d 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -328,7 +328,7 @@ static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
328 * containing the interface index. 328 * containing the interface index.
329 */ 329 */
330 330
331 BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct sockaddr_can)); 331 sock_skb_cb_check_size(sizeof(struct sockaddr_can));
332 addr = (struct sockaddr_can *)skb->cb; 332 addr = (struct sockaddr_can *)skb->cb;
333 memset(addr, 0, sizeof(*addr)); 333 memset(addr, 0, sizeof(*addr));
334 addr->can_family = AF_CAN; 334 addr->can_family = AF_CAN;
diff --git a/net/can/raw.c b/net/can/raw.c
index 00c13ef23661..94601b7ff0a3 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -95,8 +95,8 @@ struct raw_sock {
95 */ 95 */
96static inline unsigned int *raw_flags(struct sk_buff *skb) 96static inline unsigned int *raw_flags(struct sk_buff *skb)
97{ 97{
98 BUILD_BUG_ON(sizeof(skb->cb) <= (sizeof(struct sockaddr_can) + 98 sock_skb_cb_check_size(sizeof(struct sockaddr_can) +
99 sizeof(unsigned int))); 99 sizeof(unsigned int));
100 100
101 /* return pointer after struct sockaddr_can */ 101 /* return pointer after struct sockaddr_can */
102 return (unsigned int *)(&((struct sockaddr_can *)skb->cb)[1]); 102 return (unsigned int *)(&((struct sockaddr_can *)skb->cb)[1]);
@@ -135,7 +135,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
135 * containing the interface index. 135 * containing the interface index.
136 */ 136 */
137 137
138 BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct sockaddr_can)); 138 sock_skb_cb_check_size(sizeof(struct sockaddr_can));
139 addr = (struct sockaddr_can *)skb->cb; 139 addr = (struct sockaddr_can *)skb->cb;
140 memset(addr, 0, sizeof(*addr)); 140 memset(addr, 0, sizeof(*addr));
141 addr->can_family = AF_CAN; 141 addr->can_family = AF_CAN;
diff --git a/net/core/sock.c b/net/core/sock.c
index 93c8b20c91e4..9c74fc8f0e32 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -466,7 +466,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
466 skb_dst_force(skb); 466 skb_dst_force(skb);
467 467
468 spin_lock_irqsave(&list->lock, flags); 468 spin_lock_irqsave(&list->lock, flags);
469 skb->dropcount = atomic_read(&sk->sk_drops); 469 sock_skb_set_dropcount(sk, skb);
470 __skb_queue_tail(list, skb); 470 __skb_queue_tail(list, skb);
471 spin_unlock_irqrestore(&list->lock, flags); 471 spin_unlock_irqrestore(&list->lock, flags);
472 472
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index d2e49baaff63..4ce954cc94a4 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1675,7 +1675,7 @@ static int __init inet_init(void)
1675 struct list_head *r; 1675 struct list_head *r;
1676 int rc = -EINVAL; 1676 int rc = -EINVAL;
1677 1677
1678 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb)); 1678 sock_skb_cb_check_size(sizeof(struct inet_skb_parm));
1679 1679
1680 rc = proto_register(&tcp_prot, 1); 1680 rc = proto_register(&tcp_prot, 1);
1681 if (rc) 1681 if (rc)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 9d72a0fcd928..4b57ea8dabc7 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3005,12 +3005,11 @@ static void __init tcp_init_mem(void)
3005 3005
3006void __init tcp_init(void) 3006void __init tcp_init(void)
3007{ 3007{
3008 struct sk_buff *skb = NULL;
3009 unsigned long limit; 3008 unsigned long limit;
3010 int max_rshare, max_wshare, cnt; 3009 int max_rshare, max_wshare, cnt;
3011 unsigned int i; 3010 unsigned int i;
3012 3011
3013 BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb)); 3012 sock_skb_cb_check_size(sizeof(struct tcp_skb_cb));
3014 3013
3015 percpu_counter_init(&tcp_sockets_allocated, 0, GFP_KERNEL); 3014 percpu_counter_init(&tcp_sockets_allocated, 0, GFP_KERNEL);
3016 percpu_counter_init(&tcp_orphan_count, 0, GFP_KERNEL); 3015 percpu_counter_init(&tcp_orphan_count, 0, GFP_KERNEL);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index e8c4400f23e9..6bafcc2c79e3 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -824,7 +824,7 @@ static int __init inet6_init(void)
824 struct list_head *r; 824 struct list_head *r;
825 int err = 0; 825 int err = 0;
826 826
827 BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb)); 827 sock_skb_cb_check_size(sizeof(struct inet6_skb_parm));
828 828
829 /* Register the socket-side information for inet6_create. */ 829 /* Register the socket-side information for inet6_create. */
830 for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r) 830 for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 9c28cec1a083..9db83693d736 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -216,10 +216,16 @@ static void prb_fill_vlan_info(struct tpacket_kbdq_core *,
216static void packet_flush_mclist(struct sock *sk); 216static void packet_flush_mclist(struct sock *sk);
217 217
218struct packet_skb_cb { 218struct packet_skb_cb {
219 unsigned int origlen;
220 union { 219 union {
221 struct sockaddr_pkt pkt; 220 struct sockaddr_pkt pkt;
222 struct sockaddr_ll ll; 221 union {
222 /* Trick: alias skb original length with
223 * ll.sll_family and ll.protocol in order
224 * to save room.
225 */
226 unsigned int origlen;
227 struct sockaddr_ll ll;
228 };
223 } sa; 229 } sa;
224}; 230};
225 231
@@ -1810,13 +1816,10 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
1810 skb = nskb; 1816 skb = nskb;
1811 } 1817 }
1812 1818
1813 BUILD_BUG_ON(sizeof(*PACKET_SKB_CB(skb)) + MAX_ADDR_LEN - 8 > 1819 sock_skb_cb_check_size(sizeof(*PACKET_SKB_CB(skb)) + MAX_ADDR_LEN - 8);
1814 sizeof(skb->cb));
1815 1820
1816 sll = &PACKET_SKB_CB(skb)->sa.ll; 1821 sll = &PACKET_SKB_CB(skb)->sa.ll;
1817 sll->sll_family = AF_PACKET;
1818 sll->sll_hatype = dev->type; 1822 sll->sll_hatype = dev->type;
1819 sll->sll_protocol = skb->protocol;
1820 sll->sll_pkttype = skb->pkt_type; 1823 sll->sll_pkttype = skb->pkt_type;
1821 if (unlikely(po->origdev)) 1824 if (unlikely(po->origdev))
1822 sll->sll_ifindex = orig_dev->ifindex; 1825 sll->sll_ifindex = orig_dev->ifindex;
@@ -1825,7 +1828,10 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
1825 1828
1826 sll->sll_halen = dev_parse_header(skb, sll->sll_addr); 1829 sll->sll_halen = dev_parse_header(skb, sll->sll_addr);
1827 1830
1828 PACKET_SKB_CB(skb)->origlen = skb->len; 1831 /* sll->sll_family and sll->sll_protocol are set in packet_recvmsg().
1832 * Use their space for storing the original skb length.
1833 */
1834 PACKET_SKB_CB(skb)->sa.origlen = skb->len;
1829 1835
1830 if (pskb_trim(skb, snaplen)) 1836 if (pskb_trim(skb, snaplen))
1831 goto drop_n_acct; 1837 goto drop_n_acct;
@@ -1839,7 +1845,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
1839 1845
1840 spin_lock(&sk->sk_receive_queue.lock); 1846 spin_lock(&sk->sk_receive_queue.lock);
1841 po->stats.stats1.tp_packets++; 1847 po->stats.stats1.tp_packets++;
1842 skb->dropcount = atomic_read(&sk->sk_drops); 1848 sock_skb_set_dropcount(sk, skb);
1843 __skb_queue_tail(&sk->sk_receive_queue, skb); 1849 __skb_queue_tail(&sk->sk_receive_queue, skb);
1844 spin_unlock(&sk->sk_receive_queue.lock); 1850 spin_unlock(&sk->sk_receive_queue.lock);
1845 sk->sk_data_ready(sk); 1851 sk->sk_data_ready(sk);
@@ -2883,6 +2889,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
2883 struct sk_buff *skb; 2889 struct sk_buff *skb;
2884 int copied, err; 2890 int copied, err;
2885 int vnet_hdr_len = 0; 2891 int vnet_hdr_len = 0;
2892 unsigned int origlen = 0;
2886 2893
2887 err = -EINVAL; 2894 err = -EINVAL;
2888 if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT|MSG_ERRQUEUE)) 2895 if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT|MSG_ERRQUEUE))
@@ -2982,6 +2989,15 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
2982 if (err) 2989 if (err)
2983 goto out_free; 2990 goto out_free;
2984 2991
2992 if (sock->type != SOCK_PACKET) {
2993 struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll;
2994
2995 /* Original length was stored in sockaddr_ll fields */
2996 origlen = PACKET_SKB_CB(skb)->sa.origlen;
2997 sll->sll_family = AF_PACKET;
2998 sll->sll_protocol = skb->protocol;
2999 }
3000
2985 sock_recv_ts_and_drops(msg, sk, skb); 3001 sock_recv_ts_and_drops(msg, sk, skb);
2986 3002
2987 if (msg->msg_name) { 3003 if (msg->msg_name) {
@@ -2993,6 +3009,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
2993 msg->msg_namelen = sizeof(struct sockaddr_pkt); 3009 msg->msg_namelen = sizeof(struct sockaddr_pkt);
2994 } else { 3010 } else {
2995 struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll; 3011 struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll;
3012
2996 msg->msg_namelen = sll->sll_halen + 3013 msg->msg_namelen = sll->sll_halen +
2997 offsetof(struct sockaddr_ll, sll_addr); 3014 offsetof(struct sockaddr_ll, sll_addr);
2998 } 3015 }
@@ -3006,7 +3023,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
3006 aux.tp_status = TP_STATUS_USER; 3023 aux.tp_status = TP_STATUS_USER;
3007 if (skb->ip_summed == CHECKSUM_PARTIAL) 3024 if (skb->ip_summed == CHECKSUM_PARTIAL)
3008 aux.tp_status |= TP_STATUS_CSUMNOTREADY; 3025 aux.tp_status |= TP_STATUS_CSUMNOTREADY;
3009 aux.tp_len = PACKET_SKB_CB(skb)->origlen; 3026 aux.tp_len = origlen;
3010 aux.tp_snaplen = skb->len; 3027 aux.tp_snaplen = skb->len;
3011 aux.tp_mac = 0; 3028 aux.tp_mac = 0;
3012 aux.tp_net = skb_network_offset(skb); 3029 aux.tp_net = skb_network_offset(skb);
diff --git a/net/rxrpc/ar-recvmsg.c b/net/rxrpc/ar-recvmsg.c
index 4575485ad1b4..d58ba702bd2c 100644
--- a/net/rxrpc/ar-recvmsg.c
+++ b/net/rxrpc/ar-recvmsg.c
@@ -150,7 +150,7 @@ int rxrpc_recvmsg(struct kiocb *iocb, struct socket *sock,
150 &call->conn->trans->peer->srx, len); 150 &call->conn->trans->peer->srx, len);
151 msg->msg_namelen = len; 151 msg->msg_namelen = len;
152 } 152 }
153 sock_recv_ts_and_drops(msg, &rx->sk, skb); 153 sock_recv_timestamp(msg, &rx->sk, skb);
154 } 154 }
155 155
156 /* receive the message */ 156 /* receive the message */
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 8f34b27d5775..53b7acde9aa3 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1322,8 +1322,7 @@ static __init int sctp_init(void)
1322 int max_share; 1322 int max_share;
1323 int order; 1323 int order;
1324 1324
1325 BUILD_BUG_ON(sizeof(struct sctp_ulpevent) > 1325 sock_skb_cb_check_size(sizeof(struct sctp_ulpevent));
1326 sizeof(((struct sk_buff *) 0)->cb));
1327 1326
1328 /* Allocate bind_bucket and chunk caches. */ 1327 /* Allocate bind_bucket and chunk caches. */
1329 status = -ENOBUFS; 1328 status = -ENOBUFS;
diff --git a/net/socket.c b/net/socket.c
index bbedbfcb42c2..b78cf601a021 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -731,9 +731,9 @@ EXPORT_SYMBOL_GPL(__sock_recv_wifi_status);
731static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, 731static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk,
732 struct sk_buff *skb) 732 struct sk_buff *skb)
733{ 733{
734 if (sock_flag(sk, SOCK_RXQ_OVFL) && skb && skb->dropcount) 734 if (sock_flag(sk, SOCK_RXQ_OVFL) && skb && SOCK_SKB_CB(skb)->dropcount)
735 put_cmsg(msg, SOL_SOCKET, SO_RXQ_OVFL, 735 put_cmsg(msg, SOL_SOCKET, SO_RXQ_OVFL,
736 sizeof(__u32), &skb->dropcount); 736 sizeof(__u32), &SOCK_SKB_CB(skb)->dropcount);
737} 737}
738 738
739void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, 739void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,