From patchwork Sun Nov 25 23:49:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 10697197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82E821750 for ; Sun, 25 Nov 2018 23:49:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 686A529736 for ; Sun, 25 Nov 2018 23:49:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C3202986D; Sun, 25 Nov 2018 23:49:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C866729736 for ; Sun, 25 Nov 2018 23:49:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726060AbeKZKlj (ORCPT ); Mon, 26 Nov 2018 05:41:39 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:32962 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbeKZKlj (ORCPT ); Mon, 26 Nov 2018 05:41:39 -0500 Received: by mail-pl1-f196.google.com with SMTP id z23so12959598plo.0 for ; Sun, 25 Nov 2018 15:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gpWI/VklA+JVgjIL5f7F3l3OJ7PtjNWH9DOdxwLPrrk=; b=ug2CWq7anjeoKfoo5AuBz2KMf4ZosnNng1/EqM7wPZotE3ziBak0msJ6F0L5xemF1/ ZImATIYPT9hVy2FJjFuSXbiotP8ypmpodbYmm2VYXiVQ6acncrobhH2OkYzLQaC81Ez+ vsYTZ+Jk8pciSnow2LCy9QgyIz7+9JaVY/Wff6ZmquXF65Wzlml4kPtwG5xeiC2eyzKO YMgTytcQnOxTPK2fOu93yJYfeMRuNU0fi/kYueKwkkJswyD2XS+w1KHfY54GD2p2m7SE KbydXSUIcIQyAmtsIBR/L9F9TsFMX+wh5PmdX0Vrb4PBrc75TpKXb9bJf1FTiPbGsIoV AJRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gpWI/VklA+JVgjIL5f7F3l3OJ7PtjNWH9DOdxwLPrrk=; b=RMiR//bQOGoXiEA8UJ1mIBu5SjhqQ0afhPBYnu95yLUvKAyxLBa8Z+/NMzQ9cOtgW9 HLf4P9HDVBxskRBhEU7qgcrdeL6xUa4I3WQ8lWpdHMz3T49W+pKm5eF/ZWpXw12j0AwA RFJZzs96zaHZEa7Lk6+eiPE4+N7V9txez3oMLdfuerbfreI/dvnJt5DaPcVOZFa3Wo8W Mlee17Vjme3UOFM7rP2y/Ju65Dnu0QETj0Rn9BhD2Hq6NbwX4M8K3AEyP4Igx8SCNgOK QIYkEkei5IPJhvRM3bC9QaFddpMLb90SlRIOy/P0Fle3ReKSHSXYhgWUvx1aF5X8HcG4 SLzA== X-Gm-Message-State: AA+aEWawgO/AUE5JyR6INYa/feKg7s29TCYuV5KMJLy12LCxAJIsFIt0 KfgfM+yHn6ykR2awumP/KD1iyA== X-Google-Smtp-Source: AFSGD/WyPmcyBE6J0ZRcu6B7g00pGd7M6KQen4/R0ogtnAE8vgLD+G3M6r/IxdcpiF2aZ4lUQXX3JA== X-Received: by 2002:a17:902:bf49:: with SMTP id u9mr24869676pls.4.1543189760361; Sun, 25 Nov 2018 15:49:20 -0800 (PST) Received: from localhost ([2620:15c:2c4:201:f5a:7eca:440a:3ead]) by smtp.gmail.com with ESMTPSA id h129sm15203104pfb.110.2018.11.25.15.49.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Nov 2018 15:49:18 -0800 (PST) From: Eric Dumazet To: "David S . Miller" Cc: netdev , Eric Dumazet , Eric Dumazet , Faisal Latif , Doug Ledford , Jason Gunthorpe , linux-rdma Subject: [PATCH v2 net-next] net: remove unsafe skb_insert() Date: Sun, 25 Nov 2018 15:49:14 -0800 Message-Id: <20181125234914.227078-1-edumazet@google.com> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Faisal Latif Cc: Doug Ledford Cc: Jason Gunthorpe Cc: linux-rdma --- drivers/infiniband/hw/nes/nes_mgt.c | 4 ++-- include/linux/skbuff.h | 2 -- net/core/skbuff.c | 22 ---------------------- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c index fc0c191014e908eea32d752f3499295ef143aa0a..cc4dce5c3e5f6d99fc44fcde7334e70ac7a33002 100644 --- a/drivers/infiniband/hw/nes/nes_mgt.c +++ b/drivers/infiniband/hw/nes/nes_mgt.c @@ -551,14 +551,14 @@ static void queue_fpdus(struct sk_buff *skb, struct nes_vnic *nesvnic, struct ne /* Queue skb by sequence number */ if (skb_queue_len(&nesqp->pau_list) == 0) { - skb_queue_head(&nesqp->pau_list, skb); + __skb_queue_head(&nesqp->pau_list, skb); } else { skb_queue_walk(&nesqp->pau_list, tmpskb) { cb = (struct nes_rskb_cb *)&tmpskb->cb[0]; if (before(seqnum, cb->seqnum)) break; } - skb_insert(tmpskb, skb, &nesqp->pau_list); + __skb_insert(skb, tmpskb->prev, tmpskb, &nesqp->pau_list); } if (nesqp->pau_state == PAU_READY) process_it = true; diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f17a7452ac7bf47ef4bcf89840bba165cee6f50a..73902acf2b71c8800d81b744a936a7420f33b459 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1749,8 +1749,6 @@ static inline void skb_queue_head_init_class(struct sk_buff_head *list, * The "__skb_xxxx()" functions are the non-atomic ones that * can only be called with interrupts disabled. */ -void skb_insert(struct sk_buff *old, struct sk_buff *newsk, - struct sk_buff_head *list); static inline void __skb_insert(struct sk_buff *newsk, struct sk_buff *prev, struct sk_buff *next, struct sk_buff_head *list) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9a8a72cefe9b94d3821b9cc5ba5bba647ae51267..02cd7ae3d0fb26ef0a8b006390154fdefd0d292f 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2990,28 +2990,6 @@ void skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head } EXPORT_SYMBOL(skb_append); -/** - * skb_insert - insert a buffer - * @old: buffer to insert before - * @newsk: buffer to insert - * @list: list to use - * - * Place a packet before a given packet in a list. The list locks are - * taken and this function is atomic with respect to other list locked - * calls. - * - * A buffer cannot be placed on two lists at the same time. - */ -void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list) -{ - unsigned long flags; - - spin_lock_irqsave(&list->lock, flags); - __skb_insert(newsk, old->prev, old, list); - spin_unlock_irqrestore(&list->lock, flags); -} -EXPORT_SYMBOL(skb_insert); - static inline void skb_split_inside_header(struct sk_buff *skb, struct sk_buff* skb1, const u32 len, const int pos)