Skip to content

kstrtox: introduce memparse_safe()

Qu Wenruo linux-btrfs lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 5 repliesIn review
  2. v34 patches 8 repliesSuperseded
  3. v24 patches 10 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v13 patches8 repliesSuperseded

Changes in v4 from the cover letter

- Extra test cases for supported but not enabled suffixes

- Comments update for memparse_safe() function

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4kstrtox: always skip the leading "0x" even if no more valid charsarch/x86/boot/string.c lib/kstrtox.c+2 -20 replies
2/4kstrtox: introduce a safer version of memparse()include/linux/kernel.h include/linux/kstrtox.h lib/cmdline.c +1 more+124 -23 replies
3/4kstrtox: add unit tests for memparse_safe()lib/test-kstrtox.c+244 -00 replies
4/4btrfs: migrate to the newer memparse_safe() helperfs/btrfs/ioctl.c fs/btrfs/super.c fs/btrfs/sysfs.c+24 -51 reply

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchDavid Disseldorp
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/4] kstrtox: introduce memparse_safe()

[CHANGELOG]
v4:
- Extra test cases for supported but not enabled suffixes

- Comments update for memparse_safe() function

v3:
- Fix the 32bit pointer pattern in the test case
The old pointer pattern for 32 bit systems is in fact 40 bits, which would still lead to sparse warning.
The newer pattern is using UINTPTR_MAX to trim the pattern, then converted to a pointer, which should not cause any trimmed bits and make sparse happy.

v2:
- Make _parse_integer_fixup_radix() to always treat "0x" as hex This is to make sure invalid strings like "0x" or "0xG" to fail as expected for memparse_safe().
Or they would only parse the first 0, then leaving "x" for caller to handle.

- Update the test case to include above failure cases This including:
* "0x", just hex prefix without any suffix/follow up chars
* "0xK", just hex prefix and a stray suffix
* "0xY", hex prefix with an invalid char

- Fix a bug in btrfs' conversion to memparse_safe() Where I forgot to delete the old memparse() line.

- Fix a compiler warning on m68K
On that platform, a pointer (32 bits) is smaller than unsigned long long (64 bits), which can cause static checker to warn.

Qu Wenruo (4):
kstrtox: always skip the leading "0x" even if no more valid chars
kstrtox: introduce a safer version of memparse()
kstrtox: add unit tests for memparse_safe()
btrfs: migrate to the newer memparse_safe() helper

 arch/x86/boot/string.c  |   2 +-
 fs/btrfs/ioctl.c        |   6 +-
 fs/btrfs/super.c        |   9 +-
 fs/btrfs/sysfs.c        |  14 ++-
 include/linux/kernel.h  |   8 +-
 include/linux/kstrtox.h |  15 +++
 lib/cmdline.c           |   4 +-
 lib/kstrtox.c           | 101 ++++++++++++++++-
 lib/test-kstrtox.c      | 244 ++++++++++++++++++++++++++++++++++++++++
 9 files changed, 394 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0