Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b49fe362 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

ipoib: validate struct ipoib_cb size



To catch future errors sooner.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 25711786
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -131,6 +131,12 @@ struct ipoib_cb {
	u8			hwaddr[INFINIBAND_ALEN];
};

static inline struct ipoib_cb *ipoib_skb_cb(const struct sk_buff *skb)
{
	BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct ipoib_cb));
	return (struct ipoib_cb *)skb->cb;
}

/* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */
struct ipoib_mcast {
	struct ib_sa_mcmember_rec mcmember;
+2 −2
Original line number Diff line number Diff line
@@ -716,7 +716,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
	struct ipoib_dev_priv *priv = netdev_priv(dev);
	struct ipoib_neigh *neigh;
	struct ipoib_cb *cb = (struct ipoib_cb *) skb->cb;
	struct ipoib_cb *cb = ipoib_skb_cb(skb);
	struct ipoib_header *header;
	unsigned long flags;

@@ -813,7 +813,7 @@ static int ipoib_hard_header(struct sk_buff *skb,
			     const void *daddr, const void *saddr, unsigned len)
{
	struct ipoib_header *header;
	struct ipoib_cb *cb = (struct ipoib_cb *) skb->cb;
	struct ipoib_cb *cb = ipoib_skb_cb(skb);

	header = (struct ipoib_header *) skb_push(skb, sizeof *header);