From patchwork Tue Dec 6 07:10:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhouyi Zhou X-Patchwork-Id: 9462067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94EEA60236 for ; Tue, 6 Dec 2016 07:10:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8081F27CF9 for ; Tue, 6 Dec 2016 07:10:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7295B28113; Tue, 6 Dec 2016 07:10:54 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 F0C5D27CF9 for ; Tue, 6 Dec 2016 07:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752096AbcLFHKw (ORCPT ); Tue, 6 Dec 2016 02:10:52 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33646 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751058AbcLFHKv (ORCPT ); Tue, 6 Dec 2016 02:10:51 -0500 Received: by mail-pg0-f65.google.com with SMTP id 3so18981418pgd.0; Mon, 05 Dec 2016 23:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=kxQ6j11yz6Zv8UmgPVSq48/P96t7wKkP+b8zrwQEwEM=; b=Sti9pdWOwhRu8ISK0kNYuvdYzudAqPPTGjK5dVt6Yb3uzbCob0NzIgzwXxO3Mgermq z0jFJjXAe/S1GQZ+l5C0utqsr+BKUkvcV7ALJWeFgmEDrVvzELnmic/dej9XAAyrU83w qfJtkjYPzR5eA37pB/pwTM9QTgHkUsEgQkg2xDefyvfHW6OvlPJcQbHITMe2PCjIt6W1 HfNeedqTwuTutfz5W5EL3le2KrcZKuOPWQiiMyH5a5PMyv9MstPMKUscvX8NbZ0j2Ctk cTeZdAwasEzS5RvB2DUfQ4uMOufrjGGx+Y6AJbY9VcKvGDBGi5GRfRNSI7zR4f3QBrC6 ROCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kxQ6j11yz6Zv8UmgPVSq48/P96t7wKkP+b8zrwQEwEM=; b=OdMZJ2kjts+cyl0oJOShf8rZYz51k876IaaC38pnGt2h8xAL0C8lqFApds/NATD0Rz 2JaXS/St2+s5jnO5p6KZz3WtFJVE4e1vYs2UAEagQHxx0ulSzGv4VxU46zqnuAIAmPmV wEMRuZdVT4QYomWRrdshXM3fH/37QSOQE54hytwZbwgP0MSAbij6D2KcVn4J2jfadI3P PEh79ykC6UeftyRYJex1HJ064HgBP2XLbsw0T36uVUosMad6Vb+7QdGf5UxGXb5PqR3P sBOBNPQOJIrXymjMwLwgvvHm+GWMa+RQdawl8oCnfJDTXz7po79tO23W+CgdKePKd0I4 HVRg== X-Gm-Message-State: AKaTC02eze2Id3ju4v9mBgO5rLfmUtU2uUWzqE7LZbRFGuYK3dhxD6s84ob/VKvcLT2wZA== X-Received: by 10.99.120.13 with SMTP id t13mr106625469pgc.17.1481008250091; Mon, 05 Dec 2016 23:10:50 -0800 (PST) Received: from localhost.localdomain ([124.16.128.66]) by smtp.gmail.com with ESMTPSA id a7sm31978202pfl.87.2016.12.05.23.10.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Dec 2016 23:10:49 -0800 (PST) From: Zhouyi Zhou To: , , , , , QLogic-Storage-Upstream@qlogic.com, , , , , , , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, fcoe-devel@open-fcoe.org, tipc-discussion@lists.sourceforge.net Cc: Zhouyi Zhou Subject: [PATCH] net: return value of skb_linearize should be handled in Linux kernel Date: Tue, 6 Dec 2016 15:10:33 +0800 Message-Id: <1481008233-16777-1-git-send-email-zhouzhouyi@gmail.com> X-Mailer: git-send-email 1.9.1 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 kmalloc_reserve may fail to allocate memory inside skb_linearize, which means skb_linearize's return value should not be ignored. Following patch correct the uses of skb_linearize. Compiled in x86_64 Signed-off-by: Zhouyi Zhou Reviewed-by: Yuval Shaia --- drivers/infiniband/hw/nes/nes_nic.c | 5 +++-- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 6 +++++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +-- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 7 +++++-- drivers/scsi/fcoe/fcoe.c | 5 ++++- net/tipc/link.c | 3 ++- net/tipc/name_distr.c | 5 ++++- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c index 2b27d13..69372ea 100644 --- a/drivers/infiniband/hw/nes/nes_nic.c +++ b/drivers/infiniband/hw/nes/nes_nic.c @@ -662,10 +662,11 @@ static int nes_netdev_start_xmit(struct sk_buff *skb, struct net_device *netdev) nesnic->sq_head &= nesnic->sq_size-1; } } else { - nesvnic->linearized_skbs++; hoffset = skb_transport_header(skb) - skb->data; nhoffset = skb_network_header(skb) - skb->data; - skb_linearize(skb); + if (skb_linearize(skb)) + return NETDEV_TX_BUSY; + nesvnic->linearized_skbs++; skb_set_transport_header(skb, hoffset); skb_set_network_header(skb, nhoffset); if (!nes_nic_send(skb, netdev)) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index 2a653ec..ab787cb 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -490,7 +490,11 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, */ if ((fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA) && (fctl & FC_FC_END_SEQ)) { - skb_linearize(skb); + int err = 0; + + err = skb_linearize(skb); + if (err) + return err; crc = (struct fcoe_crc_eof *)skb_put(skb, sizeof(*crc)); crc->fcoe_eof = FC_EOF_T; } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index fee1f29..4926d48 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -2173,8 +2173,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, total_rx_bytes += ddp_bytes; total_rx_packets += DIV_ROUND_UP(ddp_bytes, mss); - } - if (!ddp_bytes) { + } else { dev_kfree_skb_any(skb); continue; } diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index f9ddb61..197d02e 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -542,8 +542,11 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) return; } - if (skb_is_nonlinear(skb)) - skb_linearize(skb); + if (skb_linearize(skb)) { + kfree_skb(skb); + return; + } + mac = eth_hdr(skb)->h_source; dest_mac = eth_hdr(skb)->h_dest; diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 9bd41a3..f691b97 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1685,7 +1685,10 @@ static void fcoe_recv_frame(struct sk_buff *skb) skb->dev ? skb->dev->name : ""); port = lport_priv(lport); - skb_linearize(skb); /* check for skb_is_nonlinear is within skb_linearize */ + if (skb_linearize(skb)) { + kfree_skb(skb); + return; + } /* * Frame length checks and setting up the header pointers diff --git a/net/tipc/link.c b/net/tipc/link.c index bda89bf..077c570 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -1446,7 +1446,8 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, if (tipc_own_addr(l->net) > msg_prevnode(hdr)) l->net_plane = msg_net_plane(hdr); - skb_linearize(skb); + if (skb_linearize(skb)) + goto exit; hdr = buf_msg(skb); data = msg_data(hdr); diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index c1cfd92..4e05d2a 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c @@ -356,7 +356,10 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *inputq) spin_lock_bh(&tn->nametbl_lock); for (skb = skb_dequeue(inputq); skb; skb = skb_dequeue(inputq)) { - skb_linearize(skb); + if (skb_linearize(skb)) { + kfree_skb(skb); + continue; + } msg = buf_msg(skb); mtype = msg_type(msg); item = (struct distr_item *)msg_data(msg);