Skip to contentSkip to conversation

Patch "lib: move strtobool() to kstrtobool()" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Oct 26, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

lib: move strtobool() to kstrtobool()

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
lib-move-strtobool-to-kstrtobool.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From ef951599074ba4fad2d0efa0a977129b41e6d203 Mon Sep 17 00:00:00 2001

From: Kees Cook <[email protected]>
Date: Thu, 17 Mar 2016 14:22:50 -0700
Subject: lib: move strtobool() to kstrtobool()

From: Kees Cook <[email protected]>

commit ef951599074ba4fad2d0efa0a977129b41e6d203 upstream.

Create the kstrtobool_from_user() helper and move strtobool() logic into the new kstrtobool() (matching all the other kstrto* functions). Provides an inline wrapper for existing strtobool() callers.

Cc Joe Perches <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Rasmus Villemoes <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Amitkumar Karwar <[email protected]>
Cc Nishant Sarmukadam <[email protected]>
Cc Kalle Valo <[email protected]>
Cc Steve French <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Martin Schwidefsky <[email protected]>
---
 include/linux/kernel.h |    2 +
 include/linux/string.h |    6 ++++-
 lib/kstrtox.c          |   50 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/string.c           |   29 ----------------------------
 4 files changed, 57 insertions(+), 30 deletions(-)
include/linux/kernel.h +2 -0
@@ -356,6 +356,7 @@ int __must_check kstrtou16(const char *s
 int __must_check kstrtos16(const char *s, unsigned int base, s16 *res);
 int __must_check kstrtou8(const char *s, unsigned int base, u8 *res);
 int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);
+int __must_check kstrtobool(const char *s, bool *res);
 
 int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res);
 int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res);
@@ -367,6 +368,7 @@ int __must_check kstrtou16_from_user(con
 int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res);
 int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res);
 int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
+int __must_check kstrtobool_from_user(const char __user *s, size_t count, bool *res);
 
 static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
 {
include/linux/string.h +5 -1
@@ -127,7 +127,11 @@ extern char **argv_split(gfp_t gfp, cons
 extern void argv_free(char **argv);
 
 extern bool sysfs_streq(const char *s1, const char *s2);
-extern int strtobool(const char *s, bool *res);
+extern int kstrtobool(const char *s, bool *res);
+static inline int strtobool(const char *s, bool *res)
+{
+	return kstrtobool(s, res);
+}
 
 #ifdef CONFIG_BINARY_PRINTF
 int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
lib/kstrtox.c +50 -0

56 lines not on this page · raw message

lib/string.c +0 -29
@@ -630,35 +630,6 @@ bool sysfs_streq(const char *s1, const c
 }
 EXPORT_SYMBOL(sysfs_streq);
 
-/**
- * strtobool - convert common user inputs into boolean values
- * @s: input string
- * @res: result
- *
- * This routine returns 0 iff the first character is one of 'Yy1Nn0'.
- * Otherwise it will return -EINVAL.  Value pointed to by res is
- * updated upon finding a match.
- */
-int strtobool(const char *s, bool *res)
-{
-	switch (s[0]) {
-	case 'y':
-	case 'Y':
-	case '1':
-		*res = true;
-		break;
-	case 'n':
-	case 'N':
-	case '0':
-		*res = false;
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-EXPORT_SYMBOL(strtobool);
-
 #ifndef __HAVE_ARCH_MEMSET
 /**
  * memset - Fill a region of memory with the given value

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/ovl-fix-info-leak-in-ovl_lookup_temp.patch queue-4.4/lib-update-single-char-callers-of-strtobool.patch queue-4.4/pstore-ram-use-memcpy_toio-instead-of-memcpy.patch queue-4.4/pstore-core-drop-cmpxchg-based-updates.patch queue-4.4/pstore-ramoops-fixup-driver-removal.patch queue-4.4/lib-add-on-off-support-to-kstrtobool.patch queue-4.4/pstore-ram-use-memcpy_fromio-to-save-old-buffer.patch queue-4.4/lib-move-strtobool-to-kstrtobool.patch