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 <[email protected]>
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/[email protected]/ > > Changes in v2: > - No changes in patch 1/2 > - v1: > https://lore.kernel.org/lkml/[email protected]/ > --- > 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

