[PATCH v3 0/2] Add wcslen()

Nathan Chancellor posted 2 patches 8 months, 3 weeks ago
include/linux/nls.h       | 19 +------------------
include/linux/nls_types.h | 26 ++++++++++++++++++++++++++
include/linux/string.h    |  2 ++
lib/string.c              | 11 +++++++++++
4 files changed, 40 insertions(+), 18 deletions(-)
[PATCH v3 0/2] Add wcslen()
Posted by Nathan Chancellor 8 months, 3 weeks ago
Hi all,

A recent LLVM change [1] introduces a call to wcslen() in
fs/smb/client/smb2pdu.c through UniStrcat() via
alloc_path_with_tree_prefix(). Similar to the bcmp() and stpcpy()
additions that happened in 5f074f3e192f and 1e1b6d63d634, add wcslen()
to fix the linkage failure.

[1]: https://github.com/llvm/llvm-project/commit/9694844d7e36fd5e01011ab56b64f27b867aa72d

---
Changes in v3:
- During comment shuffle in patch 1, move to standard multi-line comment
  kernel style (Andy). Carry forward Andy's review.
- Move nls_types.h include in string.c in patch 2 to a better place
  alphabetically (Andy).
- Drop 'extern' from wcslen() declaration in string.h, as external linkage
  is the default for functions and the coding style explicitly forbids
  it (Andy).
- Link to v2: https://lore.kernel.org/r/20250326-string-add-wcslen-for-llvm-opt-v2-0-d864ab2cbfe4@kernel.org

Changes in v2:
- Refactor typedefs from nls.h into nls_types.h to make it safe to
  include in string.h, which may be included in many places throughout
  the kernel that may not like the other stuff nls.h brings in:
  https://lore.kernel.org/202503260611.MDurOUhF-lkp@intel.com/
- Drop libstub change due to the above change, as it is no longer
  necessary.
- Move prototype shuffle of patch 2 into the patch that adds wcslen()
  (Andy)
- Use new nls_types.h in string.{c,h}
- Link to v1: https://lore.kernel.org/r/20250325-string-add-wcslen-for-llvm-opt-v1-0-b8f1e2c17888@kernel.org

---
Nathan Chancellor (2):
      include: Move typedefs in nls.h to their own header
      lib/string.c: Add wcslen()

 include/linux/nls.h       | 19 +------------------
 include/linux/nls_types.h | 26 ++++++++++++++++++++++++++
 include/linux/string.h    |  2 ++
 lib/string.c              | 11 +++++++++++
 4 files changed, 40 insertions(+), 18 deletions(-)
---
base-commit: 78ab93c78fb31c5dfe207318aa2b7bd4e41f8dba
change-id: 20250324-string-add-wcslen-for-llvm-opt-705791db92c0

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>
Re: [PATCH v3 0/2] Add wcslen()
Posted by Kees Cook 8 months, 2 weeks ago
On Fri, 28 Mar 2025 12:26:30 -0700, Nathan Chancellor wrote:
> A recent LLVM change [1] introduces a call to wcslen() in
> fs/smb/client/smb2pdu.c through UniStrcat() via
> alloc_path_with_tree_prefix(). Similar to the bcmp() and stpcpy()
> additions that happened in 5f074f3e192f and 1e1b6d63d634, add wcslen()
> to fix the linkage failure.
> 
> [1]: https://github.com/llvm/llvm-project/commit/9694844d7e36fd5e01011ab56b64f27b867aa72d
> 
> [...]

Applied to for-next/hardening, thanks!

[1/2] include: Move typedefs in nls.h to their own header
      https://git.kernel.org/kees/c/21592017d384
[2/2] lib/string.c: Add wcslen()
      https://git.kernel.org/kees/c/61df817d1d1b

Take care,

-- 
Kees Cook