Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4455932imb; Wed, 6 Mar 2019 13:58:18 -0800 (PST) X-Google-Smtp-Source: APXvYqzBb9fMrc6jMWGUmtISwt8HKRy+lNNqHxYW8vA6nhvC0entHXg5Lv3ugGwgC2SGr8r68gY1 X-Received: by 2002:a17:902:2a89:: with SMTP id j9mr9506139plb.28.1551909498425; Wed, 06 Mar 2019 13:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551909498; cv=none; d=google.com; s=arc-20160816; b=x+PAi+4q6Anm0AwpRrQg45MsJlbPOv/NhuYUHUIR3Fppn1HHzwTPRH0QKNhBZxyTZa 5VMU+4YSUCs3lEVBr9s2Mixyh77QYet/jFV1NW+EM/OtYqqcrlKkGHT8vfBefFr+w+g2 LiIwdryNZ5LBrsgTg0BBqpQi/NIZfU+Lc0t3FJGxD6qhwGUvjTcl1WcZ3ttkSQbiUtJ0 +HpdkcnVCKWDS79cMfkDOTN2tyvfaYA4u7Wg5wDXReIlvFWbmC4bbMhO76E6uG4uFjzH W7VJUDRmFTdLgAvE5w8D2/ZVsRtXY8kxGxOTMwkpqod74Fu8atRXy/2iIJ8u+LWN0Br/ MVeg== 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=doWDRphVEnglfL89Tp64Jf1WtVGQTVDfI9OaD8Of7NU=; b=tnhjQa99tfXDNShZ6bDxlSg7ArXspEwRFCCQ4HN3NbrVXNL/rP0BXqJ/UV/4VvZLRc 9robokglBDDzW9dQkFa0qn0S7m9BlMm2qUHkbsbbJqyi7H6T2k6nkeNfa22jAPyRGwej ZO+O543xp3YrShZH/5KbsKNIwQMTWsJZJPc73A+6+YhS761r82mvXGdmRvKjQqot0jxi JwMpsLbVlZcZ2Ucad7XarmZveILbxfSUYgTGOy64z63hPkPBIxTBkbiUGQm+t3AeELGA Ya76UJZIML0y8SjVyZ/7lAVSnUsNtuzBQKiMenTwaWYJxE5zj8j5AamVM5UqXej8/hF3 GmVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ic1ityeu; 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 x12si2260311pga.127.2019.03.06.13.58.02; Wed, 06 Mar 2019 13:58:18 -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=Ic1ityeu; 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 S1726375AbfCFV4G (ORCPT + 99 others); Wed, 6 Mar 2019 16:56:06 -0500 Received: from mail-pf1-f181.google.com ([209.85.210.181]:43111 "EHLO mail-pf1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbfCFV4G (ORCPT ); Wed, 6 Mar 2019 16:56:06 -0500 Received: by mail-pf1-f181.google.com with SMTP id q17so9678377pfh.10; Wed, 06 Mar 2019 13:56:05 -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=doWDRphVEnglfL89Tp64Jf1WtVGQTVDfI9OaD8Of7NU=; b=Ic1ityeu8FGyas3S1s7YKTfa8d2Uajg74ls5CfH7I9pZCjKz6m4Sjjiawhj294msfY 5anLh5n+hRe47dm435+IoXcJNAm90rsNUHKcrWaQYoegGwVqG2DyiM3xiqNhm3iWuQqV T2A2Fyt9K6VlcHAeb1aGg/iIGB9hDVB9kFWNKRR0FQckNJJm7yuZPyDwr1C33UHpcYs0 GyzqIZ87JniF3KOvP4QgWWdKNgJJVEyeZ/ouP5trpIQVS3RkDmmWtEjKCgVXrbNAHEyn dDnnvI0xeYLmDNz8CIXjP3U1OdKV2yqYt5q9FofsQcrdSYJl03Lu5dLe/zUvhDVVsB6N dPUQ== 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=doWDRphVEnglfL89Tp64Jf1WtVGQTVDfI9OaD8Of7NU=; b=Lz8UqYLV+Kh8QV3DRsAHcsjfQzjRCYKGEiONU7pKWPEt8DFe8o7hU5SuQlME0uoVFg JQ/zLxN61TBfzenYh9qdyVRriQid3tJSW/FdUISoarZxbvLOHmTbRf675lh1A1407Lcv Zr26tILAYhF9Q66+lVsGGa2KX64xM6aCNUqPHERmhMQHCqEBaChUjv1q+hADG6RnmF6R TMnILIe2XhIbNh7ldKcNaM3VnQ6vHaKTDtBsndjpLvcPR6wo5pRP5MtpTz5/2l460Qqi LwP3juXfZp+z22gI2x5jFS5hShyG1tzFtP4/7/HzCskyokab5nXLAmPQ9kUBKGlwMG3k NUFw== X-Gm-Message-State: APjAAAV+nhsil35oSOvqq2i0+DxmQLpUG12E6QWQJ6tNC2kQ7lSYN8sM /FmnZVvafqexb1afJ0R5nqBhWmsb84g= X-Received: by 2002:a62:4793:: with SMTP id p19mr9621486pfi.76.1551909364694; Wed, 06 Mar 2019 13:56:04 -0800 (PST) Received: from myunghoj-Precision-5530 ([118.220.181.225]) by smtp.gmail.com with ESMTPSA id n18sm8575334pfh.93.2019.03.06.13.56.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Mar 2019 13:56:04 -0800 (PST) Date: Thu, 7 Mar 2019 06:55:59 +0900 From: Myungho Jung To: Steffen Klassert Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] xfrm: Reset secpath in xfrm failure Message-ID: <20190306215556.GA6104@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. net/ipv4/esp4_offload.c | 9 +++++++-- net/ipv6/esp6_offload.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c index 8756e0e790d2..7329e40c73f6 100644 --- a/net/ipv4/esp4_offload.c +++ b/net/ipv4/esp4_offload.c @@ -51,14 +51,18 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head, if (!sp) goto out; - if (sp->len == XFRM_MAX_DEPTH) + if (sp->len == XFRM_MAX_DEPTH) { + secpath_reset(skb); goto out; + } x = xfrm_state_lookup(dev_net(skb->dev), skb->mark, (xfrm_address_t *)&ip_hdr(skb)->daddr, spi, IPPROTO_ESP, AF_INET); - if (!x) + if (!x) { + secpath_reset(skb); goto out; + } sp->xvec[sp->len++] = x; sp->olen++; @@ -66,6 +70,7 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head, xo = xfrm_offload(skb); if (!xo) { xfrm_state_put(x); + secpath_reset(skb); goto out; } } diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c index d46b4eb645c2..399c688d192e 100644 --- a/net/ipv6/esp6_offload.c +++ b/net/ipv6/esp6_offload.c @@ -73,14 +73,18 @@ static struct sk_buff *esp6_gro_receive(struct list_head *head, if (!sp) goto out; - if (sp->len == XFRM_MAX_DEPTH) + if (sp->len == XFRM_MAX_DEPTH) { + secpath_reset(skb); goto out; + } x = xfrm_state_lookup(dev_net(skb->dev), skb->mark, (xfrm_address_t *)&ipv6_hdr(skb)->daddr, spi, IPPROTO_ESP, AF_INET6); - if (!x) + if (!x) { + secpath_reset(skb); goto out; + } sp->xvec[sp->len++] = x; sp->olen++; @@ -88,6 +92,7 @@ static struct sk_buff *esp6_gro_receive(struct list_head *head, xo = xfrm_offload(skb); if (!xo) { xfrm_state_put(x); + secpath_reset(skb); goto out; } } -- 2.17.1