Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4576771imb; Wed, 6 Mar 2019 17:23:51 -0800 (PST) X-Google-Smtp-Source: APXvYqwcOTrdvlgCZvxSM5rq+LW2mJ0lUccwTdVxqvqaB6lb6EXTfk1IjcSaICuIsFfWEEjZoNGG X-Received: by 2002:a17:902:be02:: with SMTP id r2mr10250897pls.209.1551921831196; Wed, 06 Mar 2019 17:23:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551921831; cv=none; d=google.com; s=arc-20160816; b=EV/Pz7Vv4lxb8CAx2PA8mt3b0mcF3LTyE0t/BdtC5V854ltQHM+9WP+F3UwHqiEzuo wK0ZtVbAU+MxV/UUo5RqyoiiufENZhPuHS0YJ8quWpBSqkyAGiLw6WVyQ2qruiFOYgYC wlYSWisUwxYwx3EZCc7BOLU5wFOx8o7D6iJCB++oKB8LN6gaanVIg7lZL7Hg8g9G3dPT nJlR2yriYDe4Z4Qs+KoMcCZpDYjz5qye+CNhe/hYCC/KK3bGhnHOgERXmaeo7Cn5EUMh eDUEIfsiQ0O+bsll8v2wLsCvBWLFjPX6ug5+Oo5kZkKaXZkz+a7OEwggl2ijM1gAn0up 7WiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=D/ikJmjPRlqttyYOieOaynrl7E2wzKJZmRmqccnju3M=; b=mmKoX5Kfz2HBQ7sRgcyV0pAc4cnWbCW7NYmnecnCUEQvPLUq89rT4sVeiJ2ZC9M/2T ouVXZ4jBhRh1OnvFvsG+w8zUebCL0hnYUBbzHSB7JcRB4kBDByCHUNV5urU68QwTGKb2 i0adLKQGpeCLHe7HXIvUoRVpPzd3Ru0W0vQdfV/sU/4Tt+IzMXJXfTq8PViwDdR18ekg lq0jGa6FccCPdwRwiCn6ilcwV42E1aJ9/CeP3JqOd+t31wZtfWHJzrHtavzsF5K98171 +nPGQWKl1UVV8SYnFATqFrABqyT6pUGMgvIdAay/hxvpgYfGT7CkKhrYBC1BXUEs39K9 DW0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ledg+69o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b125si3099528pfb.242.2019.03.06.17.23.35; Wed, 06 Mar 2019 17:23:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ledg+69o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbfCGBXP (ORCPT + 99 others); Wed, 6 Mar 2019 20:23:15 -0500 Received: from mail-pf1-f179.google.com ([209.85.210.179]:38733 "EHLO mail-pf1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727045AbfCGBXP (ORCPT ); Wed, 6 Mar 2019 20:23:15 -0500 Received: by mail-pf1-f179.google.com with SMTP id n125so10059095pfn.5; Wed, 06 Mar 2019 17:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=D/ikJmjPRlqttyYOieOaynrl7E2wzKJZmRmqccnju3M=; b=ledg+69oES59FyPXjLuGUURYI61Ik1N0r9QvckTkJHNnw9JWXbr4U4ch4uYs4B0bhS +MHSMIOZscmzJU2sdk/l3XFskolt9P4ZOOvTZFdCnCi2cugF/zGDQ56hI5yu+qEdjXvJ KK3qn8Up1P9M+JIeil5Sn7ooKboa1YMr4OuggdSeqZhEqD0wr5ET8luDBnxk9BRh2PUW GEjj3YalmFsc1UZLO9EATuXaXo8ScdNiN8ztmFNli/lIIoSUhyDsJRSOzRESAFladmNo 01ZI7dQ+a3x7SvkpssxmU+E+qM/jch+5hYlvicgqitiPTmhHwJcUnBilp3L1ChYuKwJY J6qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=D/ikJmjPRlqttyYOieOaynrl7E2wzKJZmRmqccnju3M=; b=YRALULRovfzyoNDOXjzK0GqLveTA2HBZirxFXXg5YXihzmwZWKwwTsmvzvej3eKvcW AQp54YxFIYZR0wGlcYeDfy8JR9Kwx8JTnkzP8+aj+xu7nD7FV9C7+Y3/qMVwIIZow4f8 5ibqDgxqGdwR5f79va5lRpFGZoOkPSF7tivXJvL4Oo9NMhPxRqWk6Z5Yrx1+r5WP9qDa z8/Jm3TOBvsrTgYSqaPyWwLWmK+HVp04gOxlBinbfCFZ5e66dAPbUuL4+7DK+JCjvEjq 7k2s58srxia04pP78IjU/IYWC/EXcxeMPKcND8faWR2mLe/jsBMggCbNXBmusEBJTPb+ XsCQ== X-Gm-Message-State: APjAAAUAVUCEaILdzg0JvCmCFCS0SAff8q/6Iy9RSvdIxdoXqhw5L7tj deRrLlZJKCJGe3uxJ5baxzI= X-Received: by 2002:a63:6bc9:: with SMTP id g192mr8985221pgc.198.1551921793732; Wed, 06 Mar 2019 17:23:13 -0800 (PST) Received: from myunghoj-Precision-5530 ([118.220.181.225]) by smtp.gmail.com with ESMTPSA id f125sm5652772pfc.91.2019.03.06.17.23.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Mar 2019 17:23:13 -0800 (PST) Date: Thu, 7 Mar 2019 10:23:08 +0900 From: Myungho Jung To: Steffen Klassert Cc: Eric Dumazet , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] xfrm: Reset secpath in xfrm failure Message-ID: <20190307012305.GA8305@myunghoj-Precision-5530> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In esp4_gro_receive() and esp6_gro_receive(), secpath can be allocated without adding xfrm state to xvec. Then, sp->xvec[sp->len - 1] would fail and result in dereferencing invalid pointer in esp4_gso_segment() and esp6_gso_segment(). Reset secpath if xfrm function returns error. Fixes: 7785bba299a8 ("esp: Add a software GRO codepath") Reported-by: syzbot+b69368fd933c6c592f4c@syzkaller.appspotmail.com Signed-off-by: Myungho Jung --- Changes in v2: - Add fixes tag. Changes in v3: - Add out_reset label to remove duplicate secpath_reset() calls. net/ipv4/esp4_offload.c | 8 +++++--- net/ipv6/esp6_offload.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c index 8756e0e790d2..d3170a8001b2 100644 --- a/net/ipv4/esp4_offload.c +++ b/net/ipv4/esp4_offload.c @@ -52,13 +52,13 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head, goto out; if (sp->len == XFRM_MAX_DEPTH) - goto out; + goto out_reset; x = xfrm_state_lookup(dev_net(skb->dev), skb->mark, (xfrm_address_t *)&ip_hdr(skb)->daddr, spi, IPPROTO_ESP, AF_INET); if (!x) - goto out; + goto out_reset; sp->xvec[sp->len++] = x; sp->olen++; @@ -66,7 +66,7 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head, xo = xfrm_offload(skb); if (!xo) { xfrm_state_put(x); - goto out; + goto out_reset; } } @@ -82,6 +82,8 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head, xfrm_input(skb, IPPROTO_ESP, spi, -2); return ERR_PTR(-EINPROGRESS); +out_reset: + secpath_reset(skb); out: skb_push(skb, offset); NAPI_GRO_CB(skb)->same_flow = 0; diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c index d46b4eb645c2..cb99f6fb79b7 100644 --- a/net/ipv6/esp6_offload.c +++ b/net/ipv6/esp6_offload.c @@ -74,13 +74,13 @@ static struct sk_buff *esp6_gro_receive(struct list_head *head, goto out; if (sp->len == XFRM_MAX_DEPTH) - goto out; + goto out_reset; x = xfrm_state_lookup(dev_net(skb->dev), skb->mark, (xfrm_address_t *)&ipv6_hdr(skb)->daddr, spi, IPPROTO_ESP, AF_INET6); if (!x) - goto out; + goto out_reset; sp->xvec[sp->len++] = x; sp->olen++; @@ -88,7 +88,7 @@ static struct sk_buff *esp6_gro_receive(struct list_head *head, xo = xfrm_offload(skb); if (!xo) { xfrm_state_put(x); - goto out; + goto out_reset; } } @@ -109,6 +109,8 @@ static struct sk_buff *esp6_gro_receive(struct list_head *head, xfrm_input(skb, IPPROTO_ESP, spi, -2); return ERR_PTR(-EINPROGRESS); +out_reset: + secpath_reset(skb); out: skb_push(skb, offset); NAPI_GRO_CB(skb)->same_flow = 0; -- 2.17.1