lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH4c4jKm9ewfL3G7SAGokzGT3VpLaKWQrbrxcLAnb-G8_MUjSA@mail.gmail.com>
Date: Fri, 11 Apr 2025 01:29:29 +0530
From: Pranav Tyagi <pranav.tyagi03@...il.com>
To: "Nelson, Shannon" <shannon.nelson@....com>
Cc: davem@...emloft.net, dsahern@...nel.org, edumazet@...gle.com, 
	kuba@...nel.org, pabeni@...hat.com, horms@...nel.org, 
	skhan@...uxfoundation.org, netdev@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-kernel-mentees@...ts.linux.dev
Subject: Re: [PATCH] net: ipconfig: replace strncpy with strscpy_pad

On Wed, Apr 9, 2025 at 3:14 AM Nelson, Shannon <shannon.nelson@....com> wrote:
>
> On 4/8/2025 11:57 AM, Pranav Tyagi wrote:
> >
> > Replace the deprecated strncpy() function with strscpy_pad() as the
> > destination buffer is NUL-terminated and requires
> > trailing NUL-padding
> >
> > Signed-off-by: Pranav Tyagi <pranav.tyagi03@...il.com>
>
> There should be a Fixes tag here, and usually we put the 'net' tree
> indicator inside the tag, like this: [PATCH net]
>
>
> > ---
> >   net/ipv4/ipconfig.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
> > index c56b6fe6f0d7..7c238d19328f 100644
> > --- a/net/ipv4/ipconfig.c
> > +++ b/net/ipv4/ipconfig.c
> > @@ -1690,7 +1690,7 @@ static int __init ic_proto_name(char *name)
> >                          *v = 0;
> >                          if (kstrtou8(client_id, 0, dhcp_client_identifier))
> >                                  pr_debug("DHCP: Invalid client identifier type\n");
> > -                       strncpy(dhcp_client_identifier + 1, v + 1, 251);
> > +                       strscpy_pad(dhcp_client_identifier + 1, v + 1, 251);
>
> The strncpy() action, as well as the memcpy() into
> dhcp_client_identifier elsewhere, are not padding to the end, so I think
> this only needs to be null-terminated, not fully padded.  If full
> padding is needed, please let us know why.
>
> sln
>
> >                          *v = ',';
> >                  }
> >                  return 1;
> > --
> > 2.49.0
> >
> >
>

My initial assumption was on the fact that dhcp_client_identifier
is directly used in DHCP packet construction
and may be parsed byte-wise. But on going through the code again
I see that it does not require to be fully padded.
Would strscpy() suffice? as it ensures null-termination and
does not fully pad the buffer.

Regards
Pranav Tyagi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ