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-next>] [day] [month] [year] [list]
Message-Id: <1470863097-21138-1-git-send-email-mmayer@broadcom.com>
Date:	Wed, 10 Aug 2016 14:04:50 -0700
From:	Markus Mayer <mmayer@...adcom.com>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Al Viro <viro@...iv.linux.org.uk>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Chris Metcalf <cmetcalf@...hip.com>,
	Kees Cook <keescook@...omium.org>
Cc:	Markus Mayer <mmayer@...adcom.com>,
	dri-devel@...ts.freedesktop.org, nouveau@...ts.freedesktop.org,
	linux-acpi@...r.kernel.org, speakup@...ux-speakup.org,
	devel@...verdev.osuosl.org, linux-scsi@...r.kernel.org,
	target-devel@...r.kernel.org, linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH v5 0/7] lib: string: add functions to case-convert strings

This series introduces a family of generic string case conversion
functions. This kind of functionality is needed in several places in
the kernel. Right now, everybody seems to be implementing their own
copy of this functionality.

Based on the discussion of the previous version of this series[1] and
the use cases found in the kernel, it does look like having several
flavours of case conversion functions is beneficial. The use cases fall
into three categories:
    - copying a string and converting the case while specifying a
      maximum length to mimic strlcpy()
    - copying a string and converting the case without specifying a
      length to mimic strcpy()
    - converting the case of a string in-place (i.e. modifying the
      string that was passed in)

Consequently, I am proposing these new functions:
    int strlcpytoupper(char *dst, const char *src, size_t len);
    int strlcpytolower(char *dst, const char *src, size_t len);
    void strcpytoupper(char *dst, const char *src);
    void strcpytolower(char *dst, const char *src);
    void strtoupper(char *s);
    void strtolower(char *s);

Several drivers are being modified to make use of the functions above.
Another driver that also makes use of this functionality will be
submitted upstream shortly, which prompted this whole exercise.

The changes made here have been compile-tested, but not tried out, due
to lack of required hardware.

Changes since v4:
  - rebased on 4.8-rc1; this only affects patch 6/7 (gk104) and only the
    patch context, not the patch itself
  - added an ACK to patch 4/7 (speakup)
  - added an ACK to patch 7/7 (power_supply)

Changes since v3:
  - strlcpytoupper() and strlcpytolower() return length of destination
    or -E2BIG (see [2])
  - we use ~(size_t)0 instead of -1 to copy strings of arbitrary length
    in strcpyto*() and strto*()
  - A few ACKs added

Changes since v2:
  - use strlcpy() semantics not strncpy() semantics, i.e. guarantee
    NULL termination
  - as a result strncpyto<upper|lower> are now called
    strlcpyto<upper|lower>
  - make functions void
  - use len == -1 (SIZE_MAX) as no-limit indicator rather then len == 0
  - change PATCH 2/7 to match strlcpy() semantics
  - change PATCH 4/7 to match strlcpy() semantics

Changes since v1:
  - expanded strtolower() into a family of functions that cover use
    cases when a length argument is or isn't required and that support
    copying the string into a new buffer or changing it in-place 
  - changed the function semantics to return a pointer to the
    terminating '\0' character of the modified string
  - added strtoupper() functionality mirroring the above
  - dropped the ACPICA patch, since that code is OS independent and
    can't rely on a Linux library function (see [3])
  - Added two new patches replacing strtoupper() implementations

[1] https://lkml.org/lkml/2016/6/30/727
[2] https://lkml.org/lkml/2016/7/10/4
[3] https://lkml.org/lkml/2016/7/1/9

Markus Mayer (7):
  lib: string: add functions to case-convert strings
  drm/nouveau/core: make use of new strlcpytolower() function
  ACPI / device_sysfs: make use of new strtolower() function
  staging: speakup: replace spk_strlwr() with strlcpytolower()
  iscsi-target: replace iscsi_initiatorname_tolower() with strtolower()
  drm/nouveau/fifo/gk104: make use of new strcpytoupper() function
  power_supply: make use of new strcpytoupper() function

 drivers/acpi/device_sysfs.c                      |  4 +--
 drivers/gpu/drm/nouveau/nvkm/core/firmware.c     |  9 +----
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c |  5 +--
 drivers/power/power_supply_sysfs.c               | 13 +++----
 drivers/staging/speakup/kobjects.c               |  3 +-
 drivers/staging/speakup/main.c                   |  3 +-
 drivers/staging/speakup/speakup.h                |  1 -
 drivers/staging/speakup/varhandlers.c            | 12 -------
 drivers/target/iscsi/iscsi_target_nego.c         | 17 +--------
 include/linux/string.h                           | 40 +++++++++++++++++++++
 lib/string.c                                     | 46 ++++++++++++++++++++++++
 11 files changed, 98 insertions(+), 55 deletions(-)

-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ