Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2129992pxb; Mon, 12 Apr 2021 15:27:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2nIk+DEVytMk3kvQMsSwLsmBSoG/kLf0Wxa9lKbGBzIp2dM6upSnYgNzzdQ3mCHRu+4jj X-Received: by 2002:a17:90b:4a8a:: with SMTP id lp10mr1385733pjb.27.1618266451372; Mon, 12 Apr 2021 15:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618266451; cv=none; d=google.com; s=arc-20160816; b=ostE+2AiV/kQ4u7pyzCM2danuGkFGmePR4fMbGAt9Dk6QuC7bUhS1JihTEEey94Ck7 8Ea+4520nG6MseiO2wUk5oWGDgHaIPS/2f14CA6pUp0fX1o1Js5vaRMRmEnPGp06hGv2 FSAnm/ZCvjEuz9Fjd74GwGh7OqRntf2uSQ7uIVY8bdZ4j5t2rYckBKjIcOcoK7T6WnHX rW33L5sVsoCJUz/VJvmactgd9RoyAFBsQT4E1ZCAIRHol0gmK37TixkVDnLTiX+SWi8n LRzOrRK5afymJQLUy84gGfOxeJ+HpMUOG5O0Dai/zg9UAoCdWOfed1E6I1nGkRJxdGzF 95cw== 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=i4mYMdrfCC5cLTr37ncKxc2srfGi5CLCBLVYvi8IuRQ=; b=FK3i5ENqAm+WMecQ5APfkXGGKxth1WCQO/fIgKpCuJ6Vn3ymsERXNjDRuOyUdzcx0X 4FCpJWsxGVqKeQtplQnUcDQfv8QQSzSnuzX4TNdUxP4Ppaw93l8ARqZUXS2yqV6CiUbs AcSXdyWbtDhNAizy3z6cOqK+h/2w8bdNuEm34/vSFUW9xIOZzsM5Vm0ajNVxojMksX5m MlT4jAU+v5qIFrwBcpqUqMZiNQB8UsvKnIsSiioKOKDMAO4g+BOFbJztwQqkeIsVTEPI ncBgGClHl1+bMKSXICxPldJ7QNeTTBZBzN3kVQwat9c0lMB+jE2umeKi/3UyvDqD3rMS CgmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JCqCK5ug; 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 f7si9444696pln.381.2021.04.12.15.27.19; Mon, 12 Apr 2021 15:27:31 -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=JCqCK5ug; 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 S242956AbhDLJbR (ORCPT + 99 others); Mon, 12 Apr 2021 05:31:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:34436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239245AbhDLJHE (ORCPT ); Mon, 12 Apr 2021 05:07:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7F51361263; Mon, 12 Apr 2021 09:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618218215; bh=2sIrRiXC24IZ3c+sMIwarCIiK0yziEiQgeC2Jk0JQKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCqCK5ugq+pQRNqMn0N1AtjrM/Y6I5pzRczSOuZZjTryHSeQgaX4cWuDyuFh0QQrP 0WoUQ98dUxHXahRL/y4OR+iULgnlyDQukuHFojqwdzjA1qJmUyornJZrZQQdM5uUpI roQMQqM0Pxw+peAhaMtBpQfO8sVdg2RkR7M/WKgs= 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.11 114/210] xfrm: Fix NULL pointer dereference on policy lookup Date: Mon, 12 Apr 2021 10:40:19 +0200 Message-Id: <20210412084019.804329665@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@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 bfbc7810df94..c58a6d4eb610 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1097,7 +1097,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