]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2016 08:27:40 +0000 (10:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2016 08:27:40 +0000 (10:27 +0200)
added patches:
lib-add-on-off-support-to-kstrtobool.patch
lib-move-strtobool-to-kstrtobool.patch
lib-update-single-char-callers-of-strtobool.patch

queue-4.4/lib-add-on-off-support-to-kstrtobool.patch [new file with mode: 0644]
queue-4.4/lib-move-strtobool-to-kstrtobool.patch [new file with mode: 0644]
queue-4.4/lib-update-single-char-callers-of-strtobool.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/lib-add-on-off-support-to-kstrtobool.patch b/queue-4.4/lib-add-on-off-support-to-kstrtobool.patch
new file mode 100644 (file)
index 0000000..f8515a3
--- /dev/null
@@ -0,0 +1,67 @@
+From a81a5a17d44b26521fb1199f8ccf27f4af337a67 Mon Sep 17 00:00:00 2001
+From: Kees Cook <keescook@chromium.org>
+Date: Thu, 17 Mar 2016 14:22:57 -0700
+Subject: lib: add "on"/"off" support to kstrtobool
+
+From: Kees Cook <keescook@chromium.org>
+
+commit a81a5a17d44b26521fb1199f8ccf27f4af337a67 upstream.
+
+Add support for "on" and "off" when converting to boolean.
+
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Cc: Amitkumar Karwar <akarwar@marvell.com>
+Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
+Cc: Daniel Borkmann <daniel@iogearbox.net>
+Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
+Cc: Joe Perches <joe@perches.com>
+Cc: Kalle Valo <kvalo@codeaurora.org>
+Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Cc: Michael Ellerman <mpe@ellerman.id.au>
+Cc: Nishant Sarmukadam <nishants@marvell.com>
+Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
+Cc: Steve French <sfrench@samba.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ lib/kstrtox.c |   20 +++++++++++++++++---
+ 1 file changed, 17 insertions(+), 3 deletions(-)
+
+--- a/lib/kstrtox.c
++++ b/lib/kstrtox.c
+@@ -326,9 +326,9 @@ EXPORT_SYMBOL(kstrtos8);
+  * @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.
++ * This routine returns 0 iff the first character is one of 'Yy1Nn0', or
++ * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL.  Value
++ * pointed to by res is updated upon finding a match.
+  */
+ int kstrtobool(const char *s, bool *res)
+ {
+@@ -346,6 +346,20 @@ int kstrtobool(const char *s, bool *res)
+       case '0':
+               *res = false;
+               return 0;
++      case 'o':
++      case 'O':
++              switch (s[1]) {
++              case 'n':
++              case 'N':
++                      *res = true;
++                      return 0;
++              case 'f':
++              case 'F':
++                      *res = false;
++                      return 0;
++              default:
++                      break;
++              }
+       default:
+               break;
+       }
diff --git a/queue-4.4/lib-move-strtobool-to-kstrtobool.patch b/queue-4.4/lib-move-strtobool-to-kstrtobool.patch
new file mode 100644 (file)
index 0000000..ebf9d42
--- /dev/null
@@ -0,0 +1,166 @@
+From ef951599074ba4fad2d0efa0a977129b41e6d203 Mon Sep 17 00:00:00 2001
+From: Kees Cook <keescook@chromium.org>
+Date: Thu, 17 Mar 2016 14:22:50 -0700
+Subject: lib: move strtobool() to kstrtobool()
+
+From: Kees Cook <keescook@chromium.org>
+
+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.
+
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Cc: Joe Perches <joe@perches.com>
+Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
+Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
+Cc: Daniel Borkmann <daniel@iogearbox.net>
+Cc: Amitkumar Karwar <akarwar@marvell.com>
+Cc: Nishant Sarmukadam <nishants@marvell.com>
+Cc: Kalle Valo <kvalo@codeaurora.org>
+Cc: Steve French <sfrench@samba.org>
+Cc: Michael Ellerman <mpe@ellerman.id.au>
+Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
+Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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(-)
+
+--- a/include/linux/kernel.h
++++ b/include/linux/kernel.h
+@@ -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)
+ {
+--- a/include/linux/string.h
++++ b/include/linux/string.h
+@@ -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);
+--- a/lib/kstrtox.c
++++ b/lib/kstrtox.c
+@@ -321,6 +321,56 @@ int kstrtos8(const char *s, unsigned int
+ }
+ EXPORT_SYMBOL(kstrtos8);
++/**
++ * kstrtobool - 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 kstrtobool(const char *s, bool *res)
++{
++      if (!s)
++              return -EINVAL;
++
++      switch (s[0]) {
++      case 'y':
++      case 'Y':
++      case '1':
++              *res = true;
++              return 0;
++      case 'n':
++      case 'N':
++      case '0':
++              *res = false;
++              return 0;
++      default:
++              break;
++      }
++
++      return -EINVAL;
++}
++EXPORT_SYMBOL(kstrtobool);
++
++/*
++ * Since "base" would be a nonsense argument, this open-codes the
++ * _from_user helper instead of using the helper macro below.
++ */
++int kstrtobool_from_user(const char __user *s, size_t count, bool *res)
++{
++      /* Longest string needed to differentiate, newline, terminator */
++      char buf[4];
++
++      count = min(count, sizeof(buf) - 1);
++      if (copy_from_user(buf, s, count))
++              return -EFAULT;
++      buf[count] = '\0';
++      return kstrtobool(buf, res);
++}
++EXPORT_SYMBOL(kstrtobool_from_user);
++
+ #define kstrto_from_user(f, g, type)                                  \
+ int f(const char __user *s, size_t count, unsigned int base, type *res)       \
+ {                                                                     \
+--- a/lib/string.c
++++ b/lib/string.c
+@@ -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
diff --git a/queue-4.4/lib-update-single-char-callers-of-strtobool.patch b/queue-4.4/lib-update-single-char-callers-of-strtobool.patch
new file mode 100644 (file)
index 0000000..c92e274
--- /dev/null
@@ -0,0 +1,227 @@
+From 1404297ebf76fd91a41de215fc8c94c2619e5fdb Mon Sep 17 00:00:00 2001
+From: Kees Cook <keescook@chromium.org>
+Date: Thu, 17 Mar 2016 14:22:54 -0700
+Subject: lib: update single-char callers of strtobool()
+
+From: Kees Cook <keescook@chromium.org>
+
+commit 1404297ebf76fd91a41de215fc8c94c2619e5fdb upstream.
+
+Some callers of strtobool() were passing a pointer to unterminated
+strings.  In preparation of adding multi-character processing to
+kstrtobool(), update the callers to not pass single-character pointers,
+and switch to using the new kstrtobool_from_user() helper where
+possible.
+
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Cc: Amitkumar Karwar <akarwar@marvell.com>
+Cc: Nishant Sarmukadam <nishants@marvell.com>
+Cc: Kalle Valo <kvalo@codeaurora.org>
+Cc: Steve French <sfrench@samba.org>
+Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
+Cc: Daniel Borkmann <daniel@iogearbox.net>
+Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
+Cc: Joe Perches <joe@perches.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Cc: Michael Ellerman <mpe@ellerman.id.au>
+Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+[removed mwifiex driver change as it was correct and not needed for 4.4.y]
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/cifs/cifs_debug.c |   56 ++++++++++++---------------------------------------
+ fs/cifs/cifs_debug.h |    2 -
+ fs/cifs/cifsfs.c     |    6 ++---
+ fs/cifs/cifsglob.h   |    4 +--
+ 4 files changed, 20 insertions(+), 48 deletions(-)
+
+--- a/fs/cifs/cifs_debug.c
++++ b/fs/cifs/cifs_debug.c
+@@ -255,7 +255,6 @@ static const struct file_operations cifs
+ static ssize_t cifs_stats_proc_write(struct file *file,
+               const char __user *buffer, size_t count, loff_t *ppos)
+ {
+-      char c;
+       bool bv;
+       int rc;
+       struct list_head *tmp1, *tmp2, *tmp3;
+@@ -263,11 +262,8 @@ static ssize_t cifs_stats_proc_write(str
+       struct cifs_ses *ses;
+       struct cifs_tcon *tcon;
+-      rc = get_user(c, buffer);
+-      if (rc)
+-              return rc;
+-
+-      if (strtobool(&c, &bv) == 0) {
++      rc = kstrtobool_from_user(buffer, count, &bv);
++      if (rc == 0) {
+ #ifdef CONFIG_CIFS_STATS2
+               atomic_set(&totBufAllocCount, 0);
+               atomic_set(&totSmBufAllocCount, 0);
+@@ -290,6 +286,8 @@ static ssize_t cifs_stats_proc_write(str
+                       }
+               }
+               spin_unlock(&cifs_tcp_ses_lock);
++      } else {
++              return rc;
+       }
+       return count;
+@@ -433,17 +431,17 @@ static int cifsFYI_proc_open(struct inod
+ static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
+               size_t count, loff_t *ppos)
+ {
+-      char c;
++      char c[2] = { '\0' };
+       bool bv;
+       int rc;
+-      rc = get_user(c, buffer);
++      rc = get_user(c[0], buffer);
+       if (rc)
+               return rc;
+-      if (strtobool(&c, &bv) == 0)
++      if (strtobool(c, &bv) == 0)
+               cifsFYI = bv;
+-      else if ((c > '1') && (c <= '9'))
+-              cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
++      else if ((c[0] > '1') && (c[0] <= '9'))
++              cifsFYI = (int) (c[0] - '0'); /* see cifs_debug.h for meanings */
+       return count;
+ }
+@@ -471,20 +469,12 @@ static int cifs_linux_ext_proc_open(stru
+ static ssize_t cifs_linux_ext_proc_write(struct file *file,
+               const char __user *buffer, size_t count, loff_t *ppos)
+ {
+-      char c;
+-      bool bv;
+       int rc;
+-      rc = get_user(c, buffer);
++      rc = kstrtobool_from_user(buffer, count, &linuxExtEnabled);
+       if (rc)
+               return rc;
+-      rc = strtobool(&c, &bv);
+-      if (rc)
+-              return rc;
+-
+-      linuxExtEnabled = bv;
+-
+       return count;
+ }
+@@ -511,20 +501,12 @@ static int cifs_lookup_cache_proc_open(s
+ static ssize_t cifs_lookup_cache_proc_write(struct file *file,
+               const char __user *buffer, size_t count, loff_t *ppos)
+ {
+-      char c;
+-      bool bv;
+       int rc;
+-      rc = get_user(c, buffer);
++      rc = kstrtobool_from_user(buffer, count, &lookupCacheEnabled);
+       if (rc)
+               return rc;
+-      rc = strtobool(&c, &bv);
+-      if (rc)
+-              return rc;
+-
+-      lookupCacheEnabled = bv;
+-
+       return count;
+ }
+@@ -551,20 +533,12 @@ static int traceSMB_proc_open(struct ino
+ static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
+               size_t count, loff_t *ppos)
+ {
+-      char c;
+-      bool bv;
+       int rc;
+-      rc = get_user(c, buffer);
++      rc = kstrtobool_from_user(buffer, count, &traceSMB);
+       if (rc)
+               return rc;
+-      rc = strtobool(&c, &bv);
+-      if (rc)
+-              return rc;
+-
+-      traceSMB = bv;
+-
+       return count;
+ }
+@@ -622,7 +596,6 @@ static ssize_t cifs_security_flags_proc_
+       int rc;
+       unsigned int flags;
+       char flags_string[12];
+-      char c;
+       bool bv;
+       if ((count < 1) || (count > 11))
+@@ -635,11 +608,10 @@ static ssize_t cifs_security_flags_proc_
+       if (count < 3) {
+               /* single char or single char followed by null */
+-              c = flags_string[0];
+-              if (strtobool(&c, &bv) == 0) {
++              if (strtobool(flags_string, &bv) == 0) {
+                       global_secflags = bv ? CIFSSEC_MAX : CIFSSEC_DEF;
+                       return count;
+-              } else if (!isdigit(c)) {
++              } else if (!isdigit(flags_string[0])) {
+                       cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",
+                                       flags_string);
+                       return -EINVAL;
+--- a/fs/cifs/cifs_debug.h
++++ b/fs/cifs/cifs_debug.h
+@@ -25,7 +25,7 @@
+ void cifs_dump_mem(char *label, void *data, int length);
+ void cifs_dump_detail(void *);
+ void cifs_dump_mids(struct TCP_Server_Info *);
+-extern int traceSMB;          /* flag which enables the function below */
++extern bool traceSMB;         /* flag which enables the function below */
+ void dump_smb(void *, int);
+ #define CIFS_INFO     0x01
+ #define CIFS_RC               0x02
+--- a/fs/cifs/cifsfs.c
++++ b/fs/cifs/cifsfs.c
+@@ -54,10 +54,10 @@
+ #endif
+ int cifsFYI = 0;
+-int traceSMB = 0;
++bool traceSMB;
+ bool enable_oplocks = true;
+-unsigned int linuxExtEnabled = 1;
+-unsigned int lookupCacheEnabled = 1;
++bool linuxExtEnabled = true;
++bool lookupCacheEnabled = true;
+ unsigned int global_secflags = CIFSSEC_DEF;
+ /* unsigned int ntlmv2_support = 0; */
+ unsigned int sign_CIFS_PDUs = 1;
+--- a/fs/cifs/cifsglob.h
++++ b/fs/cifs/cifsglob.h
+@@ -1588,11 +1588,11 @@ GLOBAL_EXTERN atomic_t midCount;
+ /* Misc globals */
+ GLOBAL_EXTERN bool enable_oplocks; /* enable or disable oplocks */
+-GLOBAL_EXTERN unsigned int lookupCacheEnabled;
++GLOBAL_EXTERN bool lookupCacheEnabled;
+ GLOBAL_EXTERN unsigned int global_secflags;   /* if on, session setup sent
+                               with more secure ntlmssp2 challenge/resp */
+ GLOBAL_EXTERN unsigned int sign_CIFS_PDUs;  /* enable smb packet signing */
+-GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
++GLOBAL_EXTERN bool linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
+ GLOBAL_EXTERN unsigned int CIFSMaxBufSize;  /* max size not including hdr */
+ GLOBAL_EXTERN unsigned int cifs_min_rcv;    /* min size of big ntwrk buf pool */
+ GLOBAL_EXTERN unsigned int cifs_min_small;  /* min size of small buf pool */
index d54d00945bc5096b7a14bb48830e071850e07be5..1519eb2b1f509b85394720d4083c0919359244fe 100644 (file)
@@ -51,6 +51,9 @@ cx231xx-fix-gpios-for-pixelview-sbtvd-hybrid.patch
 alsa-hda-fix-a-failure-of-micmute-led-when-having-multi-adcs.patch
 mips-fix-mabi-64-build-of-vdso.lds.patch
 mips-ptrace-fix-regs_return_value-for-kernel-context.patch
+lib-move-strtobool-to-kstrtobool.patch
+lib-update-single-char-callers-of-strtobool.patch
+lib-add-on-off-support-to-kstrtobool.patch
 input-i8042-skip-selftest-on-asus-laptops.patch
 input-elantech-force-needed-quirks-on-fujitsu-h760.patch
 input-elantech-add-fujitsu-lifebook-e556-to-force-crc_enabled.patch