Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3924981imb; Wed, 6 Mar 2019 00:34:26 -0800 (PST) X-Google-Smtp-Source: APXvYqz1ABfZmV7iiXXHmNCXMsZ8/tADdruA9I817lra578qUV5Z9lEyRad81bk9TLDgxoXtwBAS X-Received: by 2002:a65:510c:: with SMTP id f12mr5389973pgq.40.1551861266252; Wed, 06 Mar 2019 00:34:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551861266; cv=none; d=google.com; s=arc-20160816; b=Bkr+IOzCeq7EZhNtn0Wz9iomxV1H8AD5J+CSwzIIoqUJs9YKmwQ5NaSOxPoC12KyQ3 yc8owL+XEP5rm1XGTPk1wOopuVjZE2cs+MzYM8aMXE3XDbYE3BxyZU/B+gA5L7TXG6Y+ JrQZbQq5iejiV7MEC3OXe8V9vwyX3lHiOfwWXuM0nYYlZZV+LKhsrK7ByxE/EgqZ1IxX hhN0w60mzlhIPQTe8S6BWgf7Hr6XXI+aed1+oL8xL7eNwgb9E7Fi24ygaS19cQB/Vk6x PMuGo/VO6j4xSb4nNzBVeE7VQ5J0H7frP5ztjxw334cMhNu5kpQy1FV0fnuDJhdym2Yf 0UFw== 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=EKe7pYqO/S8mQt2aBQbI8hgJrHk8UMFItsNlWCpshp8=; b=Oc81F9t2jniRRI+prcN8Dd8k09Ip8sF23FEKhxxJkxFLukYGXuFmEiql4vYCl7IE8v NsgJu9jgucZekPT3egBKi6wFGfE15VL+MuPXBQ+z4y/zStIAJJ/DqYEdBam6FJYTZWzV jrW1qKS/9hFX9URC0QTzrTTInfxyWmkQytEzkVD+Ub89rW/CZheP1E6pIzlshy+2hea1 Kvn8Oj1+Njb0KuntdaaaNCxSXvPBQIcziqS9ZO/8P8jPxVwmaRZHLmojwAXj95OWT8nB l42ehDnpcz58iYq6NXp6r8SvZZ3lJLr7xp31llEq2G0EGtc/0KzumkMXgFcLFhvLiG2d mmMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r0eBxBnA; 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 r24si909786pgv.333.2019.03.06.00.34.10; Wed, 06 Mar 2019 00:34:26 -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=r0eBxBnA; 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 S1729439AbfCFHdO (ORCPT + 99 others); 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-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-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. 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; } } -- 2.17.1