Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2057499pxb; Mon, 12 Apr 2021 13:11:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZxMWI7aM5F7Pzg5qXa2fyQcOF6+EBvc5jwoHmn+Bw78FCqu2r2Z6qKadZqSPadROtA/nc X-Received: by 2002:a05:6a00:148e:b029:250:5556:c7b3 with SMTP id v14-20020a056a00148eb02902505556c7b3mr272368pfu.77.1618258294342; Mon, 12 Apr 2021 13:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618258294; cv=none; d=google.com; s=arc-20160816; b=DBWtoAmxHPdyW4sd570ai5foIOCmuyVX9/jSo0bCi5LUXnamm3Snb0hxszd4zUjPKu fD7qOR9AoFOXjhEFAmejkSI0p23N929336xU/k/WZiyYg4HvHPusfEJtGx92AIm0DSBk qXl1EzBRjS9GGq//lHjtfF0bTIJpVmKzjCXF3noWznSHg2u8xvRcLOf5yUVNmkeRCuh8 pbSkByHuIIiKTWQGOTqy34m8EHa65dxZsjBpjx1BBSwOpWT/0B+9FsGmGtcHArNxgD24 xkt93kyUoCIxLRZPTD2Bsad6SKqYsIsDw/OtE1gUCPF0bFbqhGGDVOhHOrEt2qYIKxb9 64eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9PalwABfN/rJltgfMLONpP3LBK/boDR9ptZpLoLEXMo=; b=azD5OtlKQpWPuZQziCv4bHYF0TjIKdI+s0Y5U2ngHNhkZgRGtvzX+8dYKCMzjcdCga 9dbFAm/iv5ALy9u4OMWj/SH1HViGehNmPdNmrxFOwo02RvMRn6zkupDkBaqRK373QtKF +8+0wkptqiiys0fU/6fOSe7shvWkIDEF5U9a3L61CeCNjKI+ClVP/P3H5/gTwO0btmkh /T3diMwqT7eo/v23TCckDnqrrvPhPWyUfNPNEuzdee4LIPbdVpOpYOKfrqc4QjcwBLR4 aQ+Zw9ieTac9WhRuG5cP745jWEo5JuFhdRXShx41F4Ra8jUvkzaOEO4t1CrFZUfj59go YBLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="AOpkaG/b"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g199si14831400pfb.104.2021.04.12.13.11.21; Mon, 12 Apr 2021 13:11:34 -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=@linuxfoundation.org header.s=korg header.b="AOpkaG/b"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238412AbhDLIyB (ORCPT + 99 others); Mon, 12 Apr 2021 04:54:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:40892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238264AbhDLItS (ORCPT ); Mon, 12 Apr 2021 04:49:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7CC816128A; Mon, 12 Apr 2021 08:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217308; bh=4cSzsEVemC/UV8DH69wccv8vc2Pq2VJ3z7LdQ636hWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AOpkaG/brn/WPv760Xyis8ffczFmgvALP74M1w5jpKfiZ9es3/tHLrY8iFa3bxpHG LlObIhCYVzos3W6C0QcqsUDXp70VYCeGZwiR9tEh0hTP8cDVRFhJaLk2FarJ9TsdIg uTlKYqgg/3ryojxQb0w8Tu+UEHaf4yVnpqMuKSYg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steffen Klassert , Sasha Levin Subject: [PATCH 5.4 052/111] xfrm: Fix NULL pointer dereference on policy lookup Date: Mon, 12 Apr 2021 10:40:30 +0200 Message-Id: <20210412084005.999865658@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084004.200986670@linuxfoundation.org> References: <20210412084004.200986670@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steffen Klassert [ Upstream commit b1e3a5607034aa0a481c6f69a6893049406665fb ] When xfrm interfaces are used in combination with namespaces and ESP offload, we get a dst_entry NULL pointer dereference. This is because we don't have a dst_entry attached in the ESP offloading case and we need to do a policy lookup before the namespace transition. Fix this by expicit checking of skb_dst(skb) before accessing it. Fixes: f203b76d78092 ("xfrm: Add virtual xfrm interfaces") Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- include/net/xfrm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index c00b9ae71ae4..614f19bbad74 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1098,7 +1098,7 @@ static inline int __xfrm_policy_check2(struct sock *sk, int dir, return __xfrm_policy_check(sk, ndir, skb, family); return (!net->xfrm.policy_count[dir] && !secpath_exists(skb)) || - (skb_dst(skb)->flags & DST_NOPOLICY) || + (skb_dst(skb) && (skb_dst(skb)->flags & DST_NOPOLICY)) || __xfrm_policy_check(sk, ndir, skb, family); } -- 2.30.2