From: Thorsten Blum <thorsten.blum@linux.dev>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Tim Bird <tim.bird@sony.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] keys, dns: drop unused upayload->data NUL terminator
Date: Mon, 13 Apr 2026 02:31:46 +0200 [thread overview]
Message-ID: <adw5cvtPfx1SWQq9@linux.dev> (raw)
In-Reply-To: <20260412170508.1f33a371@kernel.org>
On Sun, Apr 12, 2026 at 05:05:08PM -0700, Jakub Kicinski wrote:
> On Mon, 13 Apr 2026 01:04:54 +0200 Thorsten Blum wrote:
> > On Sun, Apr 12, 2026 at 02:10:04PM -0700, Jakub Kicinski wrote:
> > > On Fri, 10 Apr 2026 00:57:02 +0200 Thorsten Blum wrote:
> > > > In dns_resolver_preparse(), do not NUL-terminate ->data and allocate one
> > > > byte less. The NUL terminator is never used and only ->datalen bytes are
> > > > accessed.
> > >
> > > I can't see where this is used at all.
> > > Please write better commit messages, there's no way this 1 byte
> > > is worth the amount of time I wasted trying to review this :/
> >
> > The point of patch 1/2 is not the removed NUL terminator itself, but to
> > prepare for patch 2/2, which adds __counted_by() and requires ->datalen
> > to match the number of elements in ->data.
> >
> > Currently, that is not the case because ->data includes an extra NUL
> > despite never being used as a C string. Removing the unused terminator
> > makes the length match the allocation size and allows adding the
> > __counted_by() annotation.
> >
> > I can fold this into the __counted_by() patch if you prefer.
>
> I understand that part, but I don't get where the data from which
> the terminating character is removed, is used. Only other access
> I saw was freeing it, the rest of the callback seem to looking
> at the error, not the data..
->data and ->datalen are used in multiple places.
For example, in dns_query() in net/dns_resolver/dns_query.c:
upayload = user_key_payload_locked(rkey);
len = upayload->datalen;
if (_result) {
ret = -ENOMEM;
*_result = kmemdup_nul(upayload->data, len, GFP_KERNEL);
if (!*_result)
goto put;
}
In cifs_set_cifscreds() in fs/smb/client/connect.c:
/* find first : in payload */
payload = upayload->data;
delim = strnchr(payload, upayload->datalen, ':');
next prev parent reply other threads:[~2026-04-13 0:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 22:57 [PATCH net-next v2 1/2] keys, dns: drop unused upayload->data NUL terminator Thorsten Blum
2026-04-09 22:57 ` [PATCH net-next v2 2/2] KEYS: annotate struct user_key_payload with __counted_by Thorsten Blum
2026-04-15 2:25 ` Jarkko Sakkinen
2026-04-12 21:10 ` [PATCH net-next v2 1/2] keys, dns: drop unused upayload->data NUL terminator Jakub Kicinski
2026-04-12 23:04 ` Thorsten Blum
2026-04-13 0:05 ` Jakub Kicinski
2026-04-13 0:31 ` Thorsten Blum [this message]
2026-04-13 18:00 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adw5cvtPfx1SWQq9@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tim.bird@sony.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox