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] [day] [month] [year] [list]
Message-ID: <ZQNS0qzJVrRRgNLO@smile.fi.intel.com>
Date:   Thu, 14 Sep 2023 21:37:07 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH v1 1/1] lib/string_helpers: Don't copy a tail in
 kstrdup_and_replace() if 'new' is \0

On Wed, Sep 13, 2023 at 12:45:57PM +0300, Andy Shevchenko wrote:
> The kstrdup_and_replace() takes two characters, old and new, to replace
> former with latter after the copying of the original string. But in case
> when new is a NUL, there is no point to copy the rest of the string,
> the contract with the callers is that that the function returns a
> NUL-terminated string and not a buffer of the size filled with a given
> data. With this we can optimize the memory consumption by copying only
> meaningful part of the original string and drop the rest.

Thinking about this more, I self NAK this.
If the caller knows the size of the original message it can be handy to make
a copy and replace all occurrences of old by NUL. This will be an optimized
implementation of strsep(str, "$OLD").

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ