Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp450794pxt; Fri, 6 Aug 2021 06:05:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+dizwwPzF2Zuf3YwnvLVPgsbbcMfyrv2JPh/Mm1xCIFAY/JLasjMVKhgHdi+zYAKCMXgK X-Received: by 2002:a50:d4cf:: with SMTP id e15mr12773004edj.2.1628255133283; Fri, 06 Aug 2021 06:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628255133; cv=none; d=google.com; s=arc-20160816; b=O17zx+ANdyi8LNmDVI8Bahk+mLYCkwnx1OTYc2VaHMHEU5FwMTi56La5iFTuE02P3P 32GEgUxL26Gfl2tUT38j8MXwUZNfX7Keuy1noyaDuXPJU/5g9Q+SeNK0z5qg963smn+U uBXHRc69K4Zycnyw9tyDyP0C0/bQu0TA9g1xx4ZLvfEN4YW6tTBvJ93J5XiyCjCdpjRc 8tewhetIq4V9jOFwv3dUAMZgoqr3R1fPO4SfPSgVMMBPuCSrQiP4XiT+pXIR5GLhEVY3 cYHwpwdgUWOTJHf/q3HU63ls5AFAsvUbrzK0swH/++v5Ob3CvLToY8egMCUDsAdnX6ZY ccxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HT+Jbrl+EhxxIA8KjLJ1p5rklRzDXzXCjbgJFXs3QYs=; b=PISysJx9GjJRo1MdHRUkcTskR3gVk1XeOHHeET7+HWcoWjlv8thQKgztuzaPesoWi3 raveb3odrV1KJTAmTSdWHoGWD/kYxmXF1I2XK+Vv2BGAiiUZ5N+ZnJuJzWp07RsFo9/n 8w5fQRkZnUYaYpbk30Q3yYmfVW2yrjI0ZklW02sy0wRjrXETlIJE/QYtQWDUfd2kkKda qSKec1LmOopjaz8qGt0gP/Tj9USssAkEgKVmjX3wbezIoggp5n2UZyw6pnmvs9p/7bHS OARsNurjJ7VcrBpwBO6UEk38C5tihCb8eip6IymywWt0Jc15H0vpCTEGcPaFNW78ASzH og2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VbbSRjQG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si9497246ejj.676.2021.08.06.06.05.03; Fri, 06 Aug 2021 06:05:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VbbSRjQG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243881AbhHFIQF (ORCPT + 99 others); Fri, 6 Aug 2021 04:16:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:45206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243851AbhHFIP3 (ORCPT ); Fri, 6 Aug 2021 04:15:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 381C2611F2; Fri, 6 Aug 2021 08:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628237713; bh=lRH3ZJEzy7Ok8b2XgvXIowhje5ZHe/MDQkvbr++q7s8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VbbSRjQGMlq4zeI6uDdyGaZCQbFScg72qF7CRV6MJBMEr4xABDn8t/j3iXCzEjYD1 7VcMzEaMZsKuVbqZP1iyecudZAu2tOlsy5o3oYnoPEjGKFJh4pw0Bs01pfu2495HYw spqFdI9TCOoQ21h711yoKj8f8T5sIr9kZBTAH/m4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pravin B Shelar , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 4/7] net: Fix zero-copy head len calculation. Date: Fri, 6 Aug 2021 10:14:43 +0200 Message-Id: <20210806081109.462710839@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806081109.324409899@linuxfoundation.org> References: <20210806081109.324409899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pravin B Shelar [ Upstream commit a17ad0961706244dce48ec941f7e476a38c0e727 ] In some cases skb head could be locked and entire header data is pulled from skb. When skb_zerocopy() called in such cases, following BUG is triggered. This patch fixes it by copying entire skb in such cases. This could be optimized incase this is performance bottleneck. ---8<--- kernel BUG at net/core/skbuff.c:2961! invalid opcode: 0000 [#1] SMP PTI CPU: 2 PID: 0 Comm: swapper/2 Tainted: G OE 5.4.0-77-generic #86-Ubuntu Hardware name: OpenStack Foundation OpenStack Nova, BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:skb_zerocopy+0x37a/0x3a0 RSP: 0018:ffffbcc70013ca38 EFLAGS: 00010246 Call Trace: queue_userspace_packet+0x2af/0x5e0 [openvswitch] ovs_dp_upcall+0x3d/0x60 [openvswitch] ovs_dp_process_packet+0x125/0x150 [openvswitch] ovs_vport_receive+0x77/0xd0 [openvswitch] netdev_port_receive+0x87/0x130 [openvswitch] netdev_frame_hook+0x4b/0x60 [openvswitch] __netif_receive_skb_core+0x2b4/0xc90 __netif_receive_skb_one_core+0x3f/0xa0 __netif_receive_skb+0x18/0x60 process_backlog+0xa9/0x160 net_rx_action+0x142/0x390 __do_softirq+0xe1/0x2d6 irq_exit+0xae/0xb0 do_IRQ+0x5a/0xf0 common_interrupt+0xf/0xf Code that triggered BUG: int skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen) { int i, j = 0; int plen = 0; /* length of skb->head fragment */ int ret; struct page *page; unsigned int offset; BUG_ON(!from->head_frag && !hlen); Signed-off-by: Pravin B Shelar Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/skbuff.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 076444dac96d..0e34f5ad6216 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2288,8 +2288,11 @@ skb_zerocopy_headlen(const struct sk_buff *from) if (!from->head_frag || skb_headlen(from) < L1_CACHE_BYTES || - skb_shinfo(from)->nr_frags >= MAX_SKB_FRAGS) + skb_shinfo(from)->nr_frags >= MAX_SKB_FRAGS) { hlen = skb_headlen(from); + if (!hlen) + hlen = from->len; + } if (skb_has_frag_list(from)) hlen = from->len; -- 2.30.2