netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ipsec v2] Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process"
@ 2022-05-23 20:05 Michal Kubecek
  2022-05-26  6:53 ` Steffen Klassert
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Kubecek @ 2022-05-23 20:05 UTC (permalink / raw)
  To: Steffen Klassert, netdev
  Cc: Jiasheng Jiang, Florian Fainelli, Herbert Xu, David S. Miller,
	Jakub Kicinski, Eric Dumazet, Paolo Abeni, linux-kernel

This reverts commit 4dc2a5a8f6754492180741facf2a8787f2c415d7.

A non-zero return value from pfkey_broadcast() does not necessarily mean
an error occurred as this function returns -ESRCH when no registered
listener received the message. In particular, a call with
BROADCAST_PROMISC_ONLY flag and null one_sk argument can never return
zero so that this commit in fact prevents processing any PF_KEY message.
One visible effect is that racoon daemon fails to find encryption
algorithms like aes and refuses to start.

Excluding -ESRCH return value would fix this but it's not obvious that
we really want to bail out here and most other callers of
pfkey_broadcast() also ignore the return value. Also, as pointed out by
Steffen Klassert, PF_KEY is kind of deprecated and newer userspace code
should use netlink instead so that we should only disturb the code for
really important fixes.

v2: add a comment explaining why is the return value ignored

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 net/key/af_key.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/key/af_key.c b/net/key/af_key.c
index 339d95df19d3..d93bde657359 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2826,10 +2826,12 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb
 	void *ext_hdrs[SADB_EXT_MAX];
 	int err;
 
-	err = pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
-			      BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
-	if (err)
-		return err;
+	/* Non-zero return value of pfkey_broadcast() does not always signal
+	 * an error and even on an actual error we may still want to process
+	 * the message so rather ignore the return value.
+	 */
+	pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
+			BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
 
 	memset(ext_hdrs, 0, sizeof(ext_hdrs));
 	err = parse_exthdrs(skb, hdr, ext_hdrs);
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH ipsec v2] Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process"
  2022-05-23 20:05 [PATCH ipsec v2] Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process" Michal Kubecek
@ 2022-05-26  6:53 ` Steffen Klassert
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2022-05-26  6:53 UTC (permalink / raw)
  To: Michal Kubecek
  Cc: netdev, Jiasheng Jiang, Florian Fainelli, Herbert Xu,
	David S. Miller, Jakub Kicinski, Eric Dumazet, Paolo Abeni,
	linux-kernel

On Mon, May 23, 2022 at 10:05:24PM +0200, Michal Kubecek wrote:
> This reverts commit 4dc2a5a8f6754492180741facf2a8787f2c415d7.
> 
> A non-zero return value from pfkey_broadcast() does not necessarily mean
> an error occurred as this function returns -ESRCH when no registered
> listener received the message. In particular, a call with
> BROADCAST_PROMISC_ONLY flag and null one_sk argument can never return
> zero so that this commit in fact prevents processing any PF_KEY message.
> One visible effect is that racoon daemon fails to find encryption
> algorithms like aes and refuses to start.
> 
> Excluding -ESRCH return value would fix this but it's not obvious that
> we really want to bail out here and most other callers of
> pfkey_broadcast() also ignore the return value. Also, as pointed out by
> Steffen Klassert, PF_KEY is kind of deprecated and newer userspace code
> should use netlink instead so that we should only disturb the code for
> really important fixes.
> 
> v2: add a comment explaining why is the return value ignored
> 
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>

Applied, thanks Michal!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-26  6:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 20:05 [PATCH ipsec v2] Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process" Michal Kubecek
2022-05-26  6:53 ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).