From patchwork Mon Nov 22 10:33:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dichtel X-Patchwork-Id: 12631559 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23FDDC4332F for ; Mon, 22 Nov 2021 10:33:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236321AbhKVKg3 (ORCPT ); Mon, 22 Nov 2021 05:36:29 -0500 Received: from host.78.145.23.62.rev.coltfrance.com ([62.23.145.78]:56900 "EHLO smtpservice.6wind.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236258AbhKVKg2 (ORCPT ); Mon, 22 Nov 2021 05:36:28 -0500 Received: from bretzel (bretzel.dev.6wind.com [10.17.1.57]) by smtpservice.6wind.com (Postfix) with ESMTPS id 480A160015; Mon, 22 Nov 2021 11:33:20 +0100 (CET) Received: from dichtel by bretzel with local (Exim 4.92) (envelope-from ) id 1mp6dU-0000Li-4i; Mon, 22 Nov 2021 11:33:20 +0100 From: Nicolas Dichtel To: steffen.klassert@secunet.com Cc: davem@davemloft.net, herbert@gondor.apana.org.au, kuba@kernel.org, antony.antony@secunet.com, netdev@vger.kernel.org, Nicolas Dichtel , stable@vger.kernel.org Subject: [PATCH ipsec] xfrm: fix dflt policy check when there is no policy configured Date: Mon, 22 Nov 2021 11:33:13 +0100 Message-Id: <20211122103313.1331-1-nicolas.dichtel@6wind.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When there is no policy configured on the system, the default policy is checked in xfrm_route_forward. However, it was done with the wrong direction (XFRM_POLICY_FWD instead of XFRM_POLICY_OUT). The default policy for XFRM_POLICY_FWD was checked just before, with a call to xfrm[46]_policy_check(). CC: stable@vger.kernel.org Fixes: 2d151d39073a ("xfrm: Add possibility to set the default to block if we have no policy") Signed-off-by: Nicolas Dichtel --- 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 2308210793a0..55e574511af5 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1162,7 +1162,7 @@ static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) { struct net *net = dev_net(skb->dev); - if (xfrm_default_allow(net, XFRM_POLICY_FWD)) + if (xfrm_default_allow(net, XFRM_POLICY_OUT)) return !net->xfrm.policy_count[XFRM_POLICY_OUT] || (skb_dst(skb)->flags & DST_NOXFRM) || __xfrm_route_forward(skb, family);