Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2024127pxa; Mon, 3 Aug 2020 05:40:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXbHy6WcfazajpMXduc8Ym4+aNLKMSLB2bb3a9d3PqikL3r3CeSCJ+SytwwKlBOhRi5F0U X-Received: by 2002:a05:6402:1855:: with SMTP id v21mr5533957edy.355.1596458417582; Mon, 03 Aug 2020 05:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596458417; cv=none; d=google.com; s=arc-20160816; b=zQWzWurIobX1DA8UOg7UY4jzDD5UraoQU30GYtbsYUkDHcFx2P/pw3RkzzTjvZWLUU DPrGGueRzLbtl2G6OHNLbDuAwF2KBD5ZEKB+/4gAC1hsJz1SzHhPaz7D7SH0tm7+opqM wSpJ6qPE9FkrpIqGjkwPvzl4Dc81RMAewgQRoFrSSVlWPBtEJEib7ZzCck+zOcXmd4LK QonnHBrr0YKLHNbczZY7wmxL6SXByDUJtsMnpQsg5IbQPcV/CMdb2ueMfG2xUD11MrzC qmgWUyczQb45IHoU+i+iGUbNLL1su78zuxo3E06+LSKJneW/q/Z2Trzs6Zu21/ZQe6zH 7T3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rkBocA2O8oYgdzht0uTgG2Z4aWAcz19+XEXJCNVh5Qk=; b=oBK2VECRdLjK0JGHRAXTbztkrCqBH/9I/LY8mhgQeiFRDNLd/Y45rHJq6wEdEmuAO5 W7BTyOoLoIQITrONEtj+z/CwwMdBz4+bIUPJITqu/UBNlXBdiJstR01kg34OvfVyfDdD jei7UqHx/7qfAqsAmLai8qLzj2evFHW7Mq1JEwgi2beIvQR707F+0sYzVbRVXKp37omR 2Y+yUdpXnE66uIiIZ1n2ktx+s0/C2ekAEBNo4lNzHu2rc9RAbExCNqf8POP6SdLqj7Lb lL796hXNoQD3mXnQXP2qfkMf+eaVISi+D9+7qR5NWBpko0akjeO8Eh9U2F1ddu2GAmPl PlCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lGuJTfJB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si10547795edl.399.2020.08.03.05.39.55; Mon, 03 Aug 2020 05:40:17 -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=@kernel.org header.s=default header.b=lGuJTfJB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729420AbgHCMdW (ORCPT + 99 others); Mon, 3 Aug 2020 08:33:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:33114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728539AbgHCMdR (ORCPT ); Mon, 3 Aug 2020 08:33:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2FD0D2054F; Mon, 3 Aug 2020 12:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596457995; bh=yi2SbEtLnpkfz+2kpqX+tuBL/mzKRqOf3TWT5F77Vno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGuJTfJBKkvFsCl1oFb27MdocfjXOzdamVTyJ+4rJttJ4l9PVk4UwcDAS+l4vrmv6 dulAbOFCN7Wlx5YtLuJI6ND5LlpUxkLlhoGWHl8zTk0TfY86u/jyhzOFgKYSGV/esV 3aVbu47jujn7sL2yw33ng0lwYDZLLgkV+UFc1iD0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steffen Klassert , Sasha Levin Subject: [PATCH 4.19 27/56] xfrm: Fix crash when the hold queue is used. Date: Mon, 3 Aug 2020 14:19:42 +0200 Message-Id: <20200803121851.669728405@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200803121850.306734207@linuxfoundation.org> References: <20200803121850.306734207@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steffen Klassert [ Upstream commit 101dde4207f1daa1fda57d714814a03835dccc3f ] The commits "xfrm: Move dst->path into struct xfrm_dst" and "net: Create and use new helper xfrm_dst_child()." changed xfrm bundle handling under the assumption that xdst->path and dst->child are not a NULL pointer only if dst->xfrm is not a NULL pointer. That is true with one exception. If the xfrm hold queue is used to wait until a SA is installed by the key manager, we create a dummy bundle without a valid dst->xfrm pointer. The current xfrm bundle handling crashes in that case. Fix this by extending the NULL check of dst->xfrm with a test of the DST_XFRM_QUEUE flag. Fixes: 0f6c480f23f4 ("xfrm: Move dst->path into struct xfrm_dst") Fixes: b92cf4aab8e6 ("net: Create and use new helper xfrm_dst_child().") Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- include/net/xfrm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index f087c8d125b8f..3a0b5de742e9b 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1016,7 +1016,7 @@ struct xfrm_dst { static inline struct dst_entry *xfrm_dst_path(const struct dst_entry *dst) { #ifdef CONFIG_XFRM - if (dst->xfrm) { + if (dst->xfrm || (dst->flags & DST_XFRM_QUEUE)) { const struct xfrm_dst *xdst = (const struct xfrm_dst *) dst; return xdst->path; @@ -1028,7 +1028,7 @@ static inline struct dst_entry *xfrm_dst_path(const struct dst_entry *dst) static inline struct dst_entry *xfrm_dst_child(const struct dst_entry *dst) { #ifdef CONFIG_XFRM - if (dst->xfrm) { + if (dst->xfrm || (dst->flags & DST_XFRM_QUEUE)) { struct xfrm_dst *xdst = (struct xfrm_dst *) dst; return xdst->child; } -- 2.25.1