From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2245E31715F; Fri, 8 May 2026 21:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778275266; cv=none; b=Ky0drbaOqVVdWsppktqfLniMmsV0eQCijv2sfgqzS9Iq9epnYP9sOt3ViObuYXvMtco8fsKgTzGu5t1rH+Z5k0vxRwSCxm3ee5VfaPC4Pn6y4JIDix3XMkjXeVdgvZhjCZXN2DEEXHi4eiFSbD/znOFWmfKOu9N3lFAyaJbOGlg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778275266; c=relaxed/simple; bh=/4xLVTYRRJmOtJBRufc46FWoiGaSuJOkh/bI92mmbZ0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DN8dRy2+sQk4elETAmlxKLVAFX36P3Sqvq1D7y+36LBwEPEsRn12u69n1IzC1Edv3msbByVDCMXGkwb9YWFR8aqq+xnysSHRfq51OpxXKThWYyB6YWraNosMThey7JqcXzcaGBDCYtkZN0lx2y7hLzzTrbf8VxlrmGokOGA3k8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hgJevPmx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hgJevPmx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 252A6C2BCB0; Fri, 8 May 2026 21:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778275265; bh=/4xLVTYRRJmOtJBRufc46FWoiGaSuJOkh/bI92mmbZ0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hgJevPmx3gxDzL+KNlNmrujQDe7HQ4xEn2AndsI+qvlXYJGXMmhqT9E9hmG+TOmuO E0EPqd84ewmcqxQ7UMtozzuj95tsnTAeWmAqH0ZE+pgJ9ZWSVDLYb81hzycY7GYAIE o6udnN3/UGBpsvbeQQBKVq1AwNxBIlzpCvaCH5Fv0BDDInulX//JR2Hki4QJrZoJFR i+ukNsb+kMk9lOsLb9fQkVoTkgTEgTXigW3JCtJKerFnY8nKOn5a8uwuWCsaudblPu TolfU5JF4ejNc60rSuc7yP6cyYwE9s4e/ZYU+jSX+5q2iHeDzMJ58woXulso8SS/DZ 9itUvskTX9Fgg== Date: Sat, 9 May 2026 00:21:01 +0300 From: Jarkko Sakkinen To: Thorsten Blum Cc: David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Kees Cook , "Gustavo A. R. Silva" , Tim Bird , keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH net-next v3 1/2] keys, dns: drop unused upayload->data NUL terminator Message-ID: References: <20260427114422.313356-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260427114422.313356-3-thorsten.blum@linux.dev> On Mon, Apr 27, 2026 at 01:44:23PM +0200, Thorsten Blum wrote: > ->data includes an extra NUL terminator despite never being used as a C > string and only accessing ->datalen bytes. Remove the redundant NUL > terminator and allocate one byte less in dns_resolver_preparse(). > > Signed-off-by: Thorsten Blum Never being used where? Let me go this through. I read this from the documentation: /* * Preparse instantiation data for a dns_resolver key. * * For normal hostname lookups, the data must be a NUL-terminated string, with * the NUL char accounted in datalen. So what is confusing here for me is that should upayload, which is original data with options and '\0'. So my question is which is the regression here: 1. Incorrect length. Then the fix would be simply setting length as 'result_len + 1', which aligns also with the snippet of documentation I pasted. 2. Unnecessary '\0'. If there is an issue, your commit is lacking fixes tag and cc tag to the author of potentially failing commit. > --- > Changes in v3: > - Update commit message > - v2: https://lore.kernel.org/lkml/20260409225703.158552-4-thorsten.blum@linux.dev/ > > Changes in v2: > - No changes in patch 1/2 > - v1: https://lore.kernel.org/lkml/20260406175810.1018681-3-thorsten.blum@linux.dev/ > --- > net/dns_resolver/dns_key.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c > index c3c8c3240ef9..451247864a63 100644 > --- a/net/dns_resolver/dns_key.c > +++ b/net/dns_resolver/dns_key.c > @@ -203,7 +203,7 @@ dns_resolver_preparse(struct key_preparsed_payload *prep) > kdebug("store result"); > prep->quotalen = result_len; > > - upayload = kmalloc_flex(*upayload, data, result_len + 1); > + upayload = kmalloc_flex(*upayload, data, result_len); > if (!upayload) { > kleave(" = -ENOMEM"); > return -ENOMEM; > @@ -211,7 +211,6 @@ dns_resolver_preparse(struct key_preparsed_payload *prep) > > upayload->datalen = result_len; > memcpy(upayload->data, data, result_len); > - upayload->data[result_len] = '\0'; > > prep->payload.data[dns_key_data] = upayload; > kleave(" = 0"); BR, Jarkko