Skip to content

Commit 4bffc66

Browse files
edumazetdavem330
authored andcommitted
net: remove unsafe skb_insert()
I do not see how one can effectively use skb_insert() without holding some kind of lock. Otherwise other cpus could have changed the list right before we have a chance of acquiring list->lock. Only existing user is in drivers/infiniband/hw/nes/nes_mgt.c and this one probably meant to use __skb_insert() since it appears nesqp->pau_list is protected by nesqp->pau_lock. This looks like nesqp->pau_lock could be removed, since nesqp->pau_list.lock could be used instead. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Faisal Latif <faisal.latif@intel.com> Cc: Doug Ledford <dledford@redhat.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: linux-rdma <linux-rdma@vger.kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 40b1c81 commit 4bffc66

File tree

3 files changed

+2
-26
lines changed

3 files changed

+2
-26
lines changed

drivers/infiniband/hw/nes/nes_mgt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,14 @@ static void queue_fpdus(struct sk_buff *skb, struct nes_vnic *nesvnic, struct ne
551551

552552
/* Queue skb by sequence number */
553553
if (skb_queue_len(&nesqp->pau_list) == 0) {
554-
skb_queue_head(&nesqp->pau_list, skb);
554+
__skb_queue_head(&nesqp->pau_list, skb);
555555
} else {
556556
skb_queue_walk(&nesqp->pau_list, tmpskb) {
557557
cb = (struct nes_rskb_cb *)&tmpskb->cb[0];
558558
if (before(seqnum, cb->seqnum))
559559
break;
560560
}
561-
skb_insert(tmpskb, skb, &nesqp->pau_list);
561+
__skb_insert(skb, tmpskb->prev, tmpskb, &nesqp->pau_list);
562562
}
563563
if (nesqp->pau_state == PAU_READY)
564564
process_it = true;

include/linux/skbuff.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,8 +1749,6 @@ static inline void skb_queue_head_init_class(struct sk_buff_head *list,
17491749
* The "__skb_xxxx()" functions are the non-atomic ones that
17501750
* can only be called with interrupts disabled.
17511751
*/
1752-
void skb_insert(struct sk_buff *old, struct sk_buff *newsk,
1753-
struct sk_buff_head *list);
17541752
static inline void __skb_insert(struct sk_buff *newsk,
17551753
struct sk_buff *prev, struct sk_buff *next,
17561754
struct sk_buff_head *list)

net/core/skbuff.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,28 +2990,6 @@ void skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head
29902990
}
29912991
EXPORT_SYMBOL(skb_append);
29922992

2993-
/**
2994-
* skb_insert - insert a buffer
2995-
* @old: buffer to insert before
2996-
* @newsk: buffer to insert
2997-
* @list: list to use
2998-
*
2999-
* Place a packet before a given packet in a list. The list locks are
3000-
* taken and this function is atomic with respect to other list locked
3001-
* calls.
3002-
*
3003-
* A buffer cannot be placed on two lists at the same time.
3004-
*/
3005-
void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list)
3006-
{
3007-
unsigned long flags;
3008-
3009-
spin_lock_irqsave(&list->lock, flags);
3010-
__skb_insert(newsk, old->prev, old, list);
3011-
spin_unlock_irqrestore(&list->lock, flags);
3012-
}
3013-
EXPORT_SYMBOL(skb_insert);
3014-
30152993
static inline void skb_split_inside_header(struct sk_buff *skb,
30162994
struct sk_buff* skb1,
30172995
const u32 len, const int pos)

0 commit comments

Comments
 (0)