Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2470885pxb; Mon, 19 Apr 2021 06:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRLxXnt/PsNzpN1Is5wFD67P7gt9dPw/MSXs0eoryW2RpKzJsgmZpKUeQMHTQelzsSadoF X-Received: by 2002:a17:906:98c1:: with SMTP id zd1mr22133278ejb.447.1618839211256; Mon, 19 Apr 2021 06:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618839211; cv=none; d=google.com; s=arc-20160816; b=dUPSnwznxTCL6s8yMWaY3ueWQMBUifYZmAov1b3MQSMw1BYU+q6MHE979ON0HaNTE6 6YSZ+JSiOmr66kJRznNtJb1xtYIe5hL4QRWREFxQkV3gyxQ+cwOl6zY9uv8vthiUkeUp 7X4QRuybHS4wvGwm1B3G+mq2m2m9U369mUXSzVh3hUgg5Vo/eCmXhhewhYto7cnFa/4L o+xCkJ8ha0fNf7eHBslmCMZKGxClZFJBGaPA1gv4jCLdTJ9QN6ZgvMfMyHY2rTqJX3KL C8922ladYzFqtAPnqdqSGENewU0w774OBxP4EJs1eUU+XhKo6mBFaSouMCG2YgcIiAUK mCDw== 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=bxKPMu4a8TEe0QfKPWoHD+FKA2ViqfFew44Ho7AioSE=; b=QuaRB3YmJnycMdrNs9gmbvBvl0pbtLKr2ZnlN8FlL/T8pPnSIJDkRzw537DCfIAyoG xD7O8BVB3XN2yDrUc4xwMwmqCHqBzBKgIGEAZoUdIjdLdTPRcWdBvz3ZMx8A5B3ls5LH DMSqtsntiIo0RxVUC51f/s7QDwIQQGuOHONRnyCTtc+dgyp1KpfJmBdCRJn4O2ddieM4 v0YvUmfA4DBHXgN51qJrzMdJxIIXTnX0cdHTq4H4YcszwL66DRFS4xgvg3Jz03Nvmvah Pk912tHUUA/64LK7r3y5SOxM/pVarEN4cDQhLiPK+9aN1ODXJeR9IP/fnYrE7qXG4XYn +TWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=df4esQZr; 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 v20si12330857ejf.461.2021.04.19.06.33.06; Mon, 19 Apr 2021 06:33:31 -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=df4esQZr; 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 S242488AbhDSN3R (ORCPT + 99 others); Mon, 19 Apr 2021 09:29:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:55332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241482AbhDSNUk (ORCPT ); Mon, 19 Apr 2021 09:20:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0BA92613F9; Mon, 19 Apr 2021 13:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838215; bh=atu+37rMZinbAqAV0oBEAba3ZAW/aB0sx1YtWbxXwvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=df4esQZrd370VZCKzgblKtB25YvKsQvehB8BiPWF1w6QtjHcDF/cJA3EhzrPnIvW/ wCw2Er+NRwf2bSt7wmdHTydNQ2JW3nmVsKXm2WBCM+2Xh+SBB1Y7SddD/zRBat3P4k FOYQWIthHFXxMdW83sbimuLS9wu8k6VsaxQ+uJ/k= 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.10 085/103] gro: ensure frag0 meets IP header alignment Date: Mon, 19 Apr 2021 15:06:36 +0200 Message-Id: <20210419130530.717244714@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130527.791982064@linuxfoundation.org> References: <20210419130527.791982064@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 @@ -5867,7 +5867,8 @@ static void skb_gro_reset_offset(struct NAPI_GRO_CB(skb)->frag0_len = 0; if (!skb_headlen(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),