Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] net/dns_resolver: consolidate namelen checks in dns_query
@ 2026-05-25  9:54 Thorsten Blum
  2026-05-27 12:03 ` Simon Horman
  2026-05-28  0:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-05-25  9:54 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Amir Goldstein, Tim Bird, Christian Brauner
  Cc: Thorsten Blum, netdev, linux-kernel

Consolidate the namelen checks and return -EINVAL early if needed. Drop
the namelen == 0 check since it is covered by namelen < 3.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 net/dns_resolver/dns_query.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c
index e1c09d7b8200..c250d82cad96 100644
--- a/net/dns_resolver/dns_query.c
+++ b/net/dns_resolver/dns_query.c
@@ -73,7 +73,7 @@ int dns_query(struct net *net,
 	kenter("%s,%*.*s,%zu,%s",
 	       type, (int)namelen, (int)namelen, name, namelen, options);
 
-	if (!name || namelen == 0)
+	if (!name || namelen < 3 || namelen > 255)
 		return -EINVAL;
 
 	/* construct the query key description as "[<type>:]<name>" */
@@ -86,8 +86,6 @@ int dns_query(struct net *net,
 		desclen += typelen + 1;
 	}
 
-	if (namelen < 3 || namelen > 255)
-		return -EINVAL;
 	desclen += namelen + 1;
 
 	desc = kmalloc(desclen, GFP_KERNEL);

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

* Re: [PATCH net-next] net/dns_resolver: consolidate namelen checks in dns_query
  2026-05-25  9:54 [PATCH net-next] net/dns_resolver: consolidate namelen checks in dns_query Thorsten Blum
@ 2026-05-27 12:03 ` Simon Horman
  2026-05-28  0:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-05-27 12:03 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Amir Goldstein, Tim Bird, Christian Brauner, netdev, linux-kernel

On Mon, May 25, 2026 at 11:54:01AM +0200, Thorsten Blum wrote:
> Consolidate the namelen checks and return -EINVAL early if needed. Drop
> the namelen == 0 check since it is covered by namelen < 3.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next] net/dns_resolver: consolidate namelen checks in dns_query
  2026-05-25  9:54 [PATCH net-next] net/dns_resolver: consolidate namelen checks in dns_query Thorsten Blum
  2026-05-27 12:03 ` Simon Horman
@ 2026-05-28  0:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-05-28  0:10 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: davem, edumazet, kuba, pabeni, horms, amir73il, tim.bird, brauner,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 25 May 2026 11:54:01 +0200 you wrote:
> Consolidate the namelen checks and return -EINVAL early if needed. Drop
> the namelen == 0 check since it is covered by namelen < 3.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  net/dns_resolver/dns_query.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Here is the summary with links:
  - [net-next] net/dns_resolver: consolidate namelen checks in dns_query
    https://git.kernel.org/netdev/net-next/c/f289c0664f64

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-05-28  0:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25  9:54 [PATCH net-next] net/dns_resolver: consolidate namelen checks in dns_query Thorsten Blum
2026-05-27 12:03 ` Simon Horman
2026-05-28  0:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox