Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp440377pxt; Fri, 6 Aug 2021 05:53:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVUsC+2JchUI3H2Ff1apb5AiAB6zWZVAZqNaizxdwievd0vifpk5VLM2VDrpTrVOD1ahvd X-Received: by 2002:a92:6f0a:: with SMTP id k10mr528444ilc.105.1628254388688; Fri, 06 Aug 2021 05:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628254388; cv=none; d=google.com; s=arc-20160816; b=KHhfNuPxg+Io3w5mBdML6VBWwVFM9ntUxFqUu+7NT4lb8fxBn3ztaCRpv2PzPR59M2 cUTo5AuWiC1g4npvb10s4aiXGCDIEqp4zotv211dpcX7UaAQDrC7iljPigR67lg51UIF Vc+NCIpYkK/Zlb6Zo7uOmzW0rjfQtPrlWOKWUtIrFNOsgzEXZwGGFpzKwRbgtUorNM7i ytD24URACKtTJML5Opj5R7GgC1udHvc1GJFjFfvQ9tRBEUr2lkswLAsQSr4KdHXR1yul gxfzj4qsZdd9xK1odq6oXHM0vbe8QQnKkso1j71HHz5sswsav8EPeDGg9yymGUWt0fAJ WjzA== 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=GE+4NKpwwY0wxfENgSEF4H+YcAxfBgqz0Z+8tFb8rD8=; b=VLJHWMqectovTCXOMov3SXaBltErlNhck3wavDdzNIBeKLwKGayEnWRmS/uKgmwe/R wcMYepUZ0TQS4CaqRXsJ7rnThz9Cm1mnkTB/Iir5IVpPuGCCYpf8ydmlFkZ7gE+S9r1y ZhO9Z1d4g1CGlEDzL4+EguudL6BJl3DZGpvfPI+8tULJzrfOFjbF+b+wo0SCh1T4eMvP ypIuxyDVKtxZzGc0rT7IkqgKPiOah9D+OfUBvSyQRqu1A22uwhdUqAdyX1UDHjwK9poR IPm6NqKwZ9bIjnPwHqfuyvvpaOFzz2z76tDkVWfLLRYZE3pimlDVlzioIRDsN65dXA0d 9KDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DIM028Qy; 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 w4si8528146ioa.95.2021.08.06.05.52.56; Fri, 06 Aug 2021 05:53:08 -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=DIM028Qy; 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 S244165AbhHFITY (ORCPT + 99 others); Fri, 6 Aug 2021 04:19:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:47072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244028AbhHFIQo (ORCPT ); Fri, 6 Aug 2021 04:16:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C32FC611C9; Fri, 6 Aug 2021 08:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628237789; bh=XSP1N50eCmVZBmkrGtseVsGl1gL12EnJ4xSd7B0/GUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DIM028Qyk5rg+sUmgSirjE+fUqA4P77Q8aQBuuTQolczG2x4m/I0lfj1RkfaoE+jc mMdiM2pKbUt/9B+REcZXUu+E6jBNuJgZkArhSJhqlP/eNCgHHTeiFGGeos68wDZDCp ZrdnFrnwPanZXaCHxhCqzSUqXd0ivX5BLBxHSfdY= 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.19 06/16] net: Fix zero-copy head len calculation. Date: Fri, 6 Aug 2021 10:14:57 +0200 Message-Id: <20210806081111.349183528@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806081111.144943357@linuxfoundation.org> References: <20210806081111.144943357@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 ea9684bcc2e8..e1daab49b0eb 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2705,8 +2705,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