From patchwork Sun Nov 25 16:26:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 10696913 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 C88FF15A7 for ; Sun, 25 Nov 2018 16:26:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B205128E3A for ; Sun, 25 Nov 2018 16:26:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A608D28862; Sun, 25 Nov 2018 16:26:32 +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 2F36329216 for ; Sun, 25 Nov 2018 16:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726302AbeKZDRz (ORCPT ); Sun, 25 Nov 2018 22:17:55 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:41844 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbeKZDRz (ORCPT ); Sun, 25 Nov 2018 22:17:55 -0500 Received: by mail-pl1-f195.google.com with SMTP id u6so12683683plm.8 for ; Sun, 25 Nov 2018 08:26:30 -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=J3p662MBEg/HZOoy0jlkdlCHBeOiADM4qpBbU2bU/z4=; b=dNoyPYW1gd2RtDpnZHqaI4p+9832U7Uf2QcJlcrfSxjUrohmZ6H41hzphQYdJhsZPk CbO6h7uahcJ2N150C3cM4WckjSRBpS96PvI8RsKgzhnUvo4Advfin8SMcr7/0KL3S+GM XDLpV0U6InsC1urvnHPgl7ZBgFYsO7Bu/1K9LxvrRqMsthuc3v+kUKGBT+HVOVkdcpSK 4pOgly88djY0M24XNxmoVoHt1ugpbNU13+i1cMB70Os9rhea/VzQIuqFaxrE+dtyxqZ2 4ChyFW6/7OGmH8aYkUiBCPrLMwJYmCQuiyLmx8ySlCxEcrHJDbrJMoxGf/XKIgfq04l9 brKw== 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=J3p662MBEg/HZOoy0jlkdlCHBeOiADM4qpBbU2bU/z4=; b=C+ukLwt7goL4UYSiiNSjBZCKGcmFihUGALcx2L6VcbMKJ6FBq3F8/JKE2w3EFRmF+V zm8+NnmQ5+Jsq1rpo15BRGkK9igmZ+QHBJsJyyVfTefdMwuuvb8ZrovyaR0X/7NmAkk0 a7dlbg65kNBiW3QDQPcOstPB6t3q23MO8AzPL04BDHOYnQLV304DM7IpU30/ybampFLJ aCysWFEjf/almX1GAfKG8zr+rcST7dGSCPvU7iw9GOz31QFOCuYI2lgK3EnnEjj/ez/f A9VCVMwt25vcsitzhR1wK6bDUrIRSTFbqpB3dlUmQz7hpJc5jMgAM9418uuLALBRyBND /d7Q== X-Gm-Message-State: AA+aEWY6ZZ8/ee+HPZX3g/wnF+JodwnDtlyK0V6qZHEcT0gp7hnX+pcG jWGsGHXeBTXaXPou5sq9jY2iVA== X-Google-Smtp-Source: AFSGD/UOpYzdeIt7KfRdUiTQhQK/YuO1yFG6ZCZ6GWUzX9nzRM5SJ9Wc/gVDXWDsIhzaoAgLPfi5og== X-Received: by 2002:a17:902:bcc7:: with SMTP id o7mr3783234pls.281.1543163189506; Sun, 25 Nov 2018 08:26:29 -0800 (PST) Received: from localhost ([2620:15c:2c4:201:f5a:7eca:440a:3ead]) by smtp.gmail.com with ESMTPSA id p15-v6sm101202473pfj.72.2018.11.25.08.26.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Nov 2018 08:26:27 -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 net-next] net: remove unsafe skb_insert() Date: Sun, 25 Nov 2018 08:26:23 -0800 Message-Id: <20181125162623.127762-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..abb54d30d35dd53fa983ee437506933eeba72746 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(tmpskb, skb, &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)