Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2478396pxb; Mon, 19 Apr 2021 06:43:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy5SVs+e5ev3h+EH0ND84lVcir2KyVqy/C23w45YF61Fgpshq6YcoaVD7Nu3iW/d4rEVJg X-Received: by 2002:a62:187:0:b029:241:fc67:d41f with SMTP id 129-20020a6201870000b0290241fc67d41fmr19865496pfb.55.1618839823628; Mon, 19 Apr 2021 06:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618839823; cv=none; d=google.com; s=arc-20160816; b=JnliOhPmkUNntu6ah0ksrKZOqbpVdIxvBIEUmbzZnXI+hUPTOCt89gzukq8uapgvxA UprPf+KA4I/6FY6cNJPVYAbmgcRHKvD+N39/x33iKn4Vm7wkt233bKSTu3bUbNsqjmkI PDtmfrbqBRtwWTHPMiu445zFD0dq/YM3Okw9DXz2bUd+V2hOX2qw+YXcEctYj+COND6S OfReOf6AF4Kzfz+nU900amc5YcgResrLrtMCZYAhKyfGm9gpa0BxjzlQOIv4TW7diOkS lzLraxxfC9LnJq0J5TWgrjaAUYpyowC0SLEbF8lwN7LfQ5wmAxnsxPQGBj5bDhmCSBfV yWEA== 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=6SC0aElv6OHtDUcalHtR6+HV55/2giRfYe/Mzu9trR4=; b=bWOZTAMkQQ4BEHpe8snOssJnHgJH/QYuFA+gsuJrau2pHHsoF8cbxec4gld+atLEYr Nf6JlFYkMLJQzKdUQY0vvKblK3Y+rz/U00WqY2BhZhWMvpA9c1k1tuIzlWsQAIlndv6b eF/gOr8AWVX9+GviQEceNZzULIUYnDHBcNZz5RK0OsGCaVsbL6C6U7Ju6dOWo8IY0GGS NLWeEY9EpWa0mcOpZlvKWYqklUz2/r0Fc+pppn3tBdhnH5hJBYvafouMs/PUtBlcvLTG MkrFkjY/MoVhV50OXQM0o5c++rnkSHRS+0trXmzPlzFZc46R47R+AEf3vIdeSuq2PIEx Pkhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QT4nu6tx; 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 c20si17258949pfb.45.2021.04.19.06.43.31; Mon, 19 Apr 2021 06:43:43 -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=QT4nu6tx; 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 S242713AbhDSNjc (ORCPT + 99 others); Mon, 19 Apr 2021 09:39:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:34814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241591AbhDSN0Q (ORCPT ); Mon, 19 Apr 2021 09:26:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95C98613EA; Mon, 19 Apr 2021 13:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838478; bh=2B1jNMZRBIspioCBuupPZPsxhTTj13ZGj5FxM4gSjF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QT4nu6txxNNq8EL26RNqUIrJOif1UZhrH6/RtAWPgselJBsNmTvbVYQS8XWfL7wd4 LwhzORfuiLFn/XUdmzhPIisxS/4SXy1XFqH59zEq9RA8A6siULnTmKygSgnaANyUXR khnrywftdxs/jxhTpSGglhf0RgFni+r3lCyK0T5w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Guenter Roeck , Xuan Zhuo , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" Subject: [PATCH 5.4 63/73] gro: ensure frag0 meets IP header alignment Date: Mon, 19 Apr 2021 15:06:54 +0200 Message-Id: <20210419130525.870105431@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130523.802169214@linuxfoundation.org> References: <20210419130523.802169214@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: Eric Dumazet commit 38ec4944b593fd90c5ef42aaaa53e66ae5769d04 upstream. After commit 0f6925b3e8da ("virtio_net: Do not pull payload in skb->head") Guenter Roeck reported one failure in his tests using sh architecture. After much debugging, we have been able to spot silent unaligned accesses in inet_gro_receive() The issue at hand is that upper networking stacks assume their header is word-aligned. Low level drivers are supposed to reserve NET_IP_ALIGN bytes before the Ethernet header to make that happen. This patch hardens skb_gro_reset_offset() to not allow frag0 fast-path if the fragment is not properly aligned. Some arches like x86, arm64 and powerpc do not care and define NET_IP_ALIGN as 0, this extra check will be a NOP for them. Note that if frag0 is not used, GRO will call pskb_may_pull() as many times as needed to pull network and transport headers. Fixes: 0f6925b3e8da ("virtio_net: Do not pull payload in skb->head") Fixes: 78a478d0efd9 ("gro: Inline skb_gro_header and cache frag0 virtual address") Signed-off-by: Eric Dumazet Reported-by: Guenter Roeck Cc: Xuan Zhuo Cc: "Michael S. Tsirkin" Cc: Jason Wang Acked-by: Michael S. Tsirkin Tested-by: Guenter Roeck Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5406,7 +5406,8 @@ static void skb_gro_reset_offset(struct if (skb_mac_header(skb) == skb_tail_pointer(skb) && pinfo->nr_frags && - !PageHighMem(skb_frag_page(frag0))) { + !PageHighMem(skb_frag_page(frag0)) && + (!NET_IP_ALIGN || !(skb_frag_off(frag0) & 3))) { NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0); NAPI_GRO_CB(skb)->frag0_len = min_t(unsigned int, skb_frag_size(frag0),