Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp270288pxt; Fri, 6 Aug 2021 01:21:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyt9av/6ItInMht1T6vR8GtkAJhGwJlHV6Xc2xWKJYui8xeffXio3RIyGBBzcLmYW5OUTdD X-Received: by 2002:a05:6402:1d90:: with SMTP id dk16mr11488321edb.94.1628238105184; Fri, 06 Aug 2021 01:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628238105; cv=none; d=google.com; s=arc-20160816; b=twGSJ/TdUM9+Kp+VzRpv1dcx8PO2szt7ubR3InNtVd8ey7YIIvrtiSALsTCGieqdDD jhV7y/nLCxmkULHnltv8TvqfHY5QX8lm/BiqYFI8AIW/j6WPNVenwMjxPSenLksTOJ87 U57/NZ/OXSSNy1YOViJMw7CINzWVsGdesitZ0L4/ZQp8Qvh/FbuwX2KJXojzDUrAVuKa USOK+VkcYP4xw1OBO/2Q1y+3RMSyyePbFeUuAuziMkljbBZ/HFoEnEzXa0S0xmlRe08H EQQBvnGGbSNK2Inx2NO7CmGMtqC33Hb5CQsr3fUyl8ImHvyxJTZJKvSDTaOF8X6CUD+M E7hA== 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=SGPc3HRJm1HLlA9Wh97PIp+npZ1yYmrRj64Z5EGW+GE=; b=P+WQ4QGZLHww2Zf6OcUN87WDRmmcPOjGE0T5sITbPErlYBzyfiAq5XP6RYHyZPfloR 7K58lO3VAsoThaJVtdH1l96vhsz1EPN15dQUJUwK5yPToEGcvmXIhozQgvFVex50l6Nl Ggb1V3ykovxjiWVEvB2LfXpdtW5IzH0984BIqEYLyBtu4z+yat7lzrUjI95DOzXyP5rm U4Hcw1R9Of1hxyLlV6y7+lxk9qswg4E/TCmfy48m6Owkm6xBUTxSMMkORWVJPuQrGuUf qne5NkuukutXlD5ca2OijjQLjIlu3uhrDeu1v9hGqbhhdihyOcxU75RipU78dJOQQc+L CDOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kg4PLzfW; 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 h20si8199979edv.555.2021.08.06.01.21.21; Fri, 06 Aug 2021 01:21:45 -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=kg4PLzfW; 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 S243812AbhHFIPW (ORCPT + 99 others); Fri, 6 Aug 2021 04:15:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:44596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243727AbhHFIPH (ORCPT ); Fri, 6 Aug 2021 04:15:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4BC03611B0; Fri, 6 Aug 2021 08:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628237692; bh=AKWERcjtrAvwWQy4q8XKeRbtEAr4BgA0Qm2Sbx46Vao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kg4PLzfWXcopBMFURw20XPQ2BlGq1EgxSe4fvFsUTNHoSvVG6i+UDHEOjo6Lk+ut9 H10E2iuGiVk4tuaQxsXnPMaqBiedgJ2w0vOrAvNPw7jmwV8sMuHB1Ph3+kDTzoZlLi ovoYqAVLPhaVxCooTV48dU2XmTgSAg40/C5PLJC8= 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.4 4/6] net: Fix zero-copy head len calculation. Date: Fri, 6 Aug 2021 10:14:36 +0200 Message-Id: <20210806081109.080645847@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806081108.939164003@linuxfoundation.org> References: <20210806081108.939164003@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 7665154c85c2..58989a5ba362 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2243,8 +2243,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