diff options
author | Eric Dumazet <edumazet@google.com> | 2014-09-18 14:00:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-22 14:29:55 -0400 |
commit | b49fe36208b45f76dfbcfcd3afd952a33fa9f5ce (patch) | |
tree | 817fda679469c34681c145c0191e90474348e7b4 /drivers/infiniband | |
parent | 257117862634d89de33fec74858b1a0ba5ab444b (diff) |
ipoib: validate struct ipoib_cb size
To catch future errors sooner.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib.h | 6 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index 3edce617c31b..d7562beb5423 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h | |||
@@ -131,6 +131,12 @@ struct ipoib_cb { | |||
131 | u8 hwaddr[INFINIBAND_ALEN]; | 131 | u8 hwaddr[INFINIBAND_ALEN]; |
132 | }; | 132 | }; |
133 | 133 | ||
134 | static inline struct ipoib_cb *ipoib_skb_cb(const struct sk_buff *skb) | ||
135 | { | ||
136 | BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct ipoib_cb)); | ||
137 | return (struct ipoib_cb *)skb->cb; | ||
138 | } | ||
139 | |||
134 | /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ | 140 | /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ |
135 | struct ipoib_mcast { | 141 | struct ipoib_mcast { |
136 | struct ib_sa_mcmember_rec mcmember; | 142 | struct ib_sa_mcmember_rec mcmember; |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 1310acf6bf92..13e6e0431592 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -716,7 +716,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
716 | { | 716 | { |
717 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 717 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
718 | struct ipoib_neigh *neigh; | 718 | struct ipoib_neigh *neigh; |
719 | struct ipoib_cb *cb = (struct ipoib_cb *) skb->cb; | 719 | struct ipoib_cb *cb = ipoib_skb_cb(skb); |
720 | struct ipoib_header *header; | 720 | struct ipoib_header *header; |
721 | unsigned long flags; | 721 | unsigned long flags; |
722 | 722 | ||
@@ -813,7 +813,7 @@ static int ipoib_hard_header(struct sk_buff *skb, | |||
813 | const void *daddr, const void *saddr, unsigned len) | 813 | const void *daddr, const void *saddr, unsigned len) |
814 | { | 814 | { |
815 | struct ipoib_header *header; | 815 | struct ipoib_header *header; |
816 | struct ipoib_cb *cb = (struct ipoib_cb *) skb->cb; | 816 | struct ipoib_cb *cb = ipoib_skb_cb(skb); |
817 | 817 | ||
818 | header = (struct ipoib_header *) skb_push(skb, sizeof *header); | 818 | header = (struct ipoib_header *) skb_push(skb, sizeof *header); |
819 | 819 | ||