diff mbox series

[ipsec] xfrm: fix dflt policy check when there is no policy configured

Message ID 20211122103313.1331-1-nicolas.dichtel@6wind.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [ipsec] xfrm: fix dflt policy check when there is no policy configured | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 250 this patch: 250
netdev/cc_maintainers fail 1 blamed authors not CCed: christian.langrock@secunet.com; 1 maintainers not CCed: christian.langrock@secunet.com
netdev/build_clang success Errors and warnings before: 41 this patch: 41
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 242 this patch: 242
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Nicolas Dichtel Nov. 22, 2021, 10:33 a.m. UTC
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 <nicolas.dichtel@6wind.com>
---
 include/net/xfrm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Antony Antony Nov. 25, 2021, 6:57 a.m. UTC | #1
Hi Nicolas,

On Mon, Nov 22, 2021 at 11:33:13 +0100, Nicolas Dichtel wrote:
> 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).

How can I reproduce this? 
I tried adding fwd block and no policy and that blocked the forwarded traffic.
I ran into another issue with fwd block and and tunnel. I will double check. Next week.
Nicolas Dichtel Nov. 25, 2021, 8:23 a.m. UTC | #2
Le 25/11/2021 à 07:57, Antony Antony a écrit :
> Hi Nicolas,
Hi Antony,

> 
> On Mon, Nov 22, 2021 at 11:33:13 +0100, Nicolas Dichtel wrote:
>> 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).
> 
> How can I reproduce this? 
> I tried adding fwd block and no policy and that blocked the forwarded traffic.
> I ran into another issue with fwd block and and tunnel. I will double check. Next week.
> 
With the out default policy set to 'block' and no out policy configured, the
packets are forwarded. After my patch, packets are blocked:

$ ip xfrm policy getdefault
Default policies:
 in:  accept
 fwd: accept
 out: block
$ ip xfrm policy
$


Regards,
Nicolas
Steffen Klassert Nov. 25, 2021, 9:30 a.m. UTC | #3
On Mon, Nov 22, 2021 at 11:33:13AM +0100, Nicolas Dichtel wrote:
> 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 <nicolas.dichtel@6wind.com>

Applied, thanks Nicolas!
diff mbox series

Patch

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);