From patchwork Wed Mar 6 07:33:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Myungho Jung X-Patchwork-Id: 1052161 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="r0eBxBnA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44DlqM5qhZz9s9T for ; Wed, 6 Mar 2019 18:33:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729431AbfCFHdO (ORCPT ); Wed, 6 Mar 2019 02:33:14 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:41521 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728863AbfCFHdO (ORCPT ); Wed, 6 Mar 2019 02:33:14 -0500 Received: by mail-pg1-f194.google.com with SMTP id k11so6684380pgb.8; Tue, 05 Mar 2019 23:33:13 -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=EKe7pYqO/S8mQt2aBQbI8hgJrHk8UMFItsNlWCpshp8=; b=r0eBxBnAmtMaR6ZSRocFqVi8/UsQNjQ61lvDTYFu6ZL7uZJIMO+w+ZNzddHJGW0rFa TCiJ3YO407Qs4ziSiISiUIvIEsLxLLOO4PbowYrq12dm1EkUsZRNEx/WzNEdUm1En5dm suIF/ogCsaO4wCyeGEyOkZt55bL7l4/L/0Y99aI//IP0JOM3hgwiZP+eTDJZgGLQiGLh k5oKKHKtW5GX49Jhj/iVZ2wHXp3DdmXqaQV2jIoNAGrXmUszKYckhAE4dfzDs9bsYLSR sgv8+G9Iav74iUCLBmVT6ge/1XksSVpnrvUJwatz4TZ0eJ8TUcd7AW/cDn5bZwhvL+1x OzoA== 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=EKe7pYqO/S8mQt2aBQbI8hgJrHk8UMFItsNlWCpshp8=; b=ua5RPus4vDTY9TGUaTMGRs0eJb8BgJCLl+IgIQWv6pxNhiRKCeeemv4dsKrrfPzn5C vm9yV8wU8Gz7ENqnAdceos8P+Q06Bnn5U3m80FqpgAwZoUk8LlcSTR2j7cx2iDrFOA7Z Ke4htC7JttSWgUVRFV4K+qHhoGXYD1tsglwbjB2jB1Mk8FsA4O7Q/ejQPvSRbdMv+wQ5 e5o6etlZLVWMv55wmUdKecf/WNPHeRl5dc6z2FQ7h6dry4KPcBKTvAmHsojK1QPttN9f WVhXvnU5hZXFBbG9o3ocBxt122SsdoWr4+NNzaUGyPQ3iZPmBxr7k9I0m2bIaalBiRkx iDvQ== X-Gm-Message-State: APjAAAUcD6t+FcqCFZWFkBwhkle9PDqyWcLaMCfpMwirRD/+9hRys6op 40gd4Kzo7T5JkXxPrOQgBL4MAE588v4= X-Google-Smtp-Source: APXvYqwsauFknoaispgp9PoM4InjOXvPSgmWK7q82wbWmRYcd2beZ9URiILzyBHSjLIZ7muJfi+N6A== X-Received: by 2002:a62:a10c:: with SMTP id b12mr5888992pff.234.1551857593169; Tue, 05 Mar 2019 23:33:13 -0800 (PST) Received: from myunghoj-Precision-5530 ([118.220.181.225]) by smtp.gmail.com with ESMTPSA id l28sm3159823pfi.186.2019.03.05.23.33.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2019 23:33:12 -0800 (PST) Date: Wed, 6 Mar 2019 16:33:08 +0900 From: Myungho Jung To: Steffen Klassert Cc: "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] xfrm: Reset secpath in xfrm failure Message-ID: <20190306073304.GA22426@myunghoj-Precision-5530> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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. Reported-by: syzbot+b69368fd933c6c592f4c@syzkaller.appspotmail.com Signed-off-by: Myungho Jung --- 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; } }