commit b43515feceb7e77a36d823939c7d8c479af74d57
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Tue Nov 20 18:06:08 2018 +0000

    Linux 3.16.61

commit fcacdc9acee6785718ab240befb7e3cbc4f23498
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Mon Mar 19 09:29:02 2018 +0100

    perf tools: Fix python extension build for gcc 8
    
    commit b7a313d84e853049062011d78cb04b6decd12f5c upstream.
    
    The gcc 8 compiler won't compile the python extension code with the
    following errors (one example):
    
      python.c:830:15: error: cast between incompatible  function types from              \
      ‘PyObject * (*)(struct pyrf_evsel *, PyObject *, PyObject *)’                       \
      uct _object * (*)(struct pyrf_evsel *, struct _object *, struct _object *)’} to     \
      ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _objeuct \
      _object *)’} [-Werror=cast-function-type]
         .ml_meth  = (PyCFunction)pyrf_evsel__open,
    
    The problem with the PyMethodDef::ml_meth callback is that its type is
    determined based on the PyMethodDef::ml_flags value, which we set as
    METH_VARARGS | METH_KEYWORDS.
    
    That indicates that the callback is expecting an extra PyObject* arg, and is
    actually PyCFunctionWithKeywords type, but the base PyMethodDef::ml_meth type
    stays PyCFunction.
    
    Previous gccs did not find this, gcc8 now does. Fixing this by silencing this
    warning for python.c build.
    
    Commiter notes:
    
    Do not do that for CC=clang, as it breaks the build in some clang
    versions, like the ones in fedora up to fedora27:
    
      fedora:25:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option]
      fedora:26:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option]
      fedora:27:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option]
      #
    
    those have:
    
      clang version 3.9.1 (tags/RELEASE_391/final)
    
    The one in rawhide accepts that:
    
      clang version 6.0.0 (tags/RELEASE_600/final)
    
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
    Link: http://lkml.kernel.org/r/20180319082902.4518-2-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3a69d5c30060d46bbee7b7cc95d90dc4033bdafb
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Wed Feb 8 17:01:46 2017 -0300

    perf thread_map: Correctly size buffer used with dirent->dt_name
    
    commit bdf23a9a190d7ecea092fd5c4aabb7d4bd0a9980 upstream.
    
    The size of dirent->dt_name is NAME_MAX + 1, but the size for the 'path'
    buffer is hard coded at 256, which may truncate it because we also
    prepend "/proc/", so that all that into account and thank gcc 7 for this
    warning:
    
      /git/linux/tools/perf/util/thread_map.c: In function 'thread_map__new_by_uid':
      /git/linux/tools/perf/util/thread_map.c:119:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 250 [-Werror=format-truncation=]
         snprintf(path, sizeof(path), "/proc/%s", dirent->d_name);
                                             ^~
      In file included from /usr/include/stdio.h:939:0,
                       from /git/linux/tools/perf/util/thread_map.c:5:
      /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 7 and 262 bytes into a destination of size 256
         return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              __bos (__s), __fmt, __va_arg_pack ());
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-csy0r8zrvz5efccgd4k12c82@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1bb764801ffa0812c4a12dc6604695aef2f8c389
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Wed Mar 30 16:51:17 2016 -0300

    perf trace: Do not process PERF_RECORD_LOST twice
    
    commit 3ed5ca2efff70e9f589087c2013789572901112d upstream.
    
    We catch this record to provide a visual indication that events are
    getting lost, then call the default method to allow extra logging shared
    with the other tools to take place.
    
    This extra logging was done twice because we were continuing to the
    "default" clause where machine__process_event() will end up calling
    machine__process_lost_event() again, fix it.
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-wus2zlhw3qo24ye84ewu4aqw@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c7300e913ca5b87d5e081a0c535fba822a38ad12
Author: Eric Engestrom <eric.engestrom@imgtec.com>
Date:   Mon Apr 25 10:47:54 2016 +0100

    perf tools: Remove duplicate const qualifier
    
    commit 3b556bced46aa6b1873da7faa18eff235e896adc upstream.
    
    Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/r/1461577678-29517-1-git-send-email-eric.engestrom@imgtec.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8a751953268cceac32e30124627d447504eda53b
Author: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Date:   Tue Feb 6 15:37:52 2018 -0800

    tools/lib/subcmd/pager.c: do not alias select() params
    
    commit ad343a98e74e85aa91d844310e797f96fee6983b upstream.
    
    Use a separate fd set for select()-s exception fds param to fix the
    following gcc warning:
    
      pager.c:36:12: error: passing argument 2 to restrict-qualified parameter aliases with argument 4 [-Werror=restrict]
        select(1, &in, NULL, &in, NULL);
                  ^~~        ~~~
    
    Link: http://lkml.kernel.org/r/20180101105626.7168-1-sergey.senozhatsky@gmail.com
    Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d380aea841c4e47747f882107f89580ba7ed5cb7
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Tue Jun 10 16:00:18 2014 -0300

    perf trace: Fix up fd -> pathname resolution
    
    commit cdcd1e6bd8a92f8353fc2f37003c6eae2d1e6903 upstream.
    
    There was a brown paper bag bug in the patch that introduced a reference
    implementation on using 'perf probe' made wannabe tracepoints that broke fd ->
    pathname resolution, fix it:
    
      [root@zoo ~]# perf probe 'vfs_getname=getname_flags:65 pathname=result->name:string'
      Added new event:
        probe:vfs_getname    (on getname_flags:65 with pathname=result->name:string)
    
      You can now use it in all perf tools, such as:
    
            perf record -e probe:vfs_getname -aR sleep 1
    
      [root@zoo ~]
    
    Before:
    
      [acme@zoo linux]$ trace touch -e open,fstat /tmp/b
         1.159 ( 0.007 ms): open(filename: 0x7fd73f2fe088, flags: CLOEXEC                         ) = 3
         1.163 ( 0.002 ms): fstat(fd: 3, statbuf: 0x7fff1b25e610                                  ) = 0
         1.192 ( 0.009 ms): open(filename: 0x7fd73f4fedb8, flags: CLOEXEC                         ) = 3
         1.201 ( 0.002 ms): fstat(fd: 3, statbuf: 0x7fff1b25e660                                  ) = 0
         1.501 ( 0.013 ms): open(filename: 0x7fd73f0a1610, flags: CLOEXEC                         ) = 3
         1.505 ( 0.002 ms): fstat(fd: 3, statbuf: 0x7fd73f2ddb60                                  ) = 0
         1.581 ( 0.011 ms): open(filename: 0x7fff1b2603da, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: 438) = 3
      [acme@zoo linux]$
    
    After:
    
      [acme@zoo linux]$ trace touch -e open,fstat,dup2,mmap,close /tmp/b
         1.105 ( 0.004 ms): mmap(len: 4096, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS, fd: -1    ) = 0x2fbf000
         1.136 ( 0.008 ms): open(filename: 0x7f8902dbc088, flags: CLOEXEC                         ) = 3
         1.140 ( 0.002 ms): fstat(fd: 3</etc/ld.so.cache>, statbuf: 0x7fff19889ef0                ) = 0
         1.146 ( 0.004 ms): mmap(len: 86079, prot: READ, flags: PRIVATE, fd: 3</etc/ld.so.cache>  ) = 0x2fa9000
         1.149 ( 0.001 ms): close(fd: 3</etc/ld.so.cache>                                         ) = 0
         1.170 ( 0.010 ms): open(filename: 0x7f8902fbcdb8, flags: CLOEXEC                         ) = 3
         1.178 ( 0.002 ms): fstat(fd: 3</lib64/libc.so.6>, statbuf: 0x7fff19889f40                ) = 0
         1.188 ( 0.006 ms): mmap(len: 3924576, prot: EXEC|READ, flags: PRIVATE|DENYWRITE, fd: 3</lib64/libc.so.6>) = 0x29e2000
         1.207 ( 0.007 ms): mmap(addr: 0x7f8902d96000, len: 24576, prot: READ|WRITE, flags: PRIVATE|DENYWRITE|FIXED, fd: 3</lib64/libc.so.6>, off: 1785856) = 0x2d96000
         1.217 ( 0.004 ms): mmap(addr: 0x7f8902d9c000, len: 16992, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS|FIXED, fd: -1) = 0x2d9c000
         1.228 ( 0.002 ms): close(fd: 3</lib64/libc.so.6>                                         ) = 0
         1.243 ( 0.003 ms): mmap(len: 4096, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS, fd: -1    ) = 0x2fa8000
         1.250 ( 0.003 ms): mmap(len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS, fd: -1    ) = 0x2fa6000
         1.452 ( 0.010 ms): open(filename: 0x7f8902b5f610, flags: CLOEXEC                         ) = 3
         1.455 ( 0.002 ms): fstat(fd: 3</usr/lib/locale/locale-archive>, statbuf: 0x7f8902d9bb60  ) = 0
         1.461 ( 0.004 ms): mmap(len: 106070960, prot: READ, flags: PRIVATE, fd: 3</usr/lib/locale/locale-archive>) = 0xfc4b9000
         1.469 ( 0.002 ms): close(fd: 3</usr/lib/locale/locale-archive>                           ) = 0
         1.528 ( 0.010 ms): open(filename: 0x7fff1988c3da, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: 438) = 3
         1.532 ( 0.002 ms): dup2(oldfd: 3</tmp/b>                                                 ) = 0
         1.535 ( 0.001 ms): close(fd: 3</tmp/b>                                                   ) = 0
         1.544 ( 0.001 ms): close(                                                                ) = 0
         1.555 ( 0.001 ms): close(fd: 1                                                           ) = 0
         1.558 ( 0.001 ms): close(fd: 2                                                           ) = 0
      [acme@zoo linux]$
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Don Zickus <dzickus@redhat.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Link: http://lkml.kernel.org/n/tip-vcm22xpjxc3j4hbyuzjzf7ik@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b9229b2c893a53d73ba40cac4873f1b15d024e53
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Mon Mar 19 09:29:01 2018 +0100

    perf tools: Fix snprint warnings for gcc 8
    
    commit 77f18153c080855e1c3fb520ca31a4e61530121d upstream.
    
    With gcc 8 we get new set of snprintf() warnings that breaks the
    compilation, one example:
    
      tests/mem.c: In function ‘check’:
      tests/mem.c:19:48: error: ‘%s’ directive output may be truncated writing \
            up to 99 bytes into a region of size 89 [-Werror=format-truncation=]
        snprintf(failure, sizeof failure, "unexpected %s", out);
    
    The gcc docs says:
    
     To avoid the warning either use a bigger buffer or handle the
     function's return value which indicates whether or not its output
     has been truncated.
    
    Given that all these warnings are harmless, because the code either
    properly fails due to uncomplete file path or we don't care for
    truncated output at all, I'm changing all those snprintf() calls to
    scnprintf(), which actually 'checks' for the snprint return value so the
    gcc stays silent.
    
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
    Link: http://lkml.kernel.org/r/20180319082902.4518-1-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    [bwh: Backported to 3.16: Drop changes in tools/perf/tests/mem.c]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit edf17dc9f7754c154e5495a152e781f8937b5eda
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Wed Feb 8 17:01:46 2017 -0300

    perf top: Use __fallthrough
    
    commit 7b0214b702ad8e124e039a317beeebb3f020d125 upstream.
    
    The implicit fall through case label here is intended, so let us inform
    that to gcc >= 7:
    
        CC       /tmp/build/perf/builtin-top.o
      builtin-top.c: In function 'display_thread':
      builtin-top.c:644:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
          if (errno == EINTR)
             ^
      builtin-top.c:647:3: note: here
         default:
       ^~~~~~~
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-lmcfnnyx9ic0m6j0aud98p4e@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3a1127babd5fa52e9e2f34e949765c93e7e3f108
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Wed Feb 8 17:01:46 2017 -0300

    tools include: Add a __fallthrough statement
    
    commit b5bf1733d6a391c4e90ea8f8468d83023be74a2a upstream.
    
    For cases where implicit fall through case labels are intended,
    to let us inform that to gcc >= 7:
    
        CC       /tmp/build/perf/util/string.o
      util/string.c: In function 'perf_atoll':
      util/string.c:22:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
          if (*p)
             ^
      util/string.c:24:3: note: here
         case '\0':
         ^~~~
    
    So we introduce:
    
      #define __fallthrough __attribute__ ((fallthrough))
    
    And use it in such cases.
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Cc: William Cohen <wcohen@redhat.com>
    Link: http://lkml.kernel.org/n/tip-qnpig0xfop4hwv6k4mv1wts5@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 850e2d6ec515e296960e4b24af880d0cb1bf4b82
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Fri Apr 8 11:53:02 2016 -0300

    perf tools: Use readdir() instead of deprecated readdir_r()
    
    commit bfc279f3d233150ff260e9e93012e14f86810648 upstream.
    
    The readdir() function is thread safe as long as just one thread uses a
    DIR, which is the case when parsing tracepoint event definitions, to
    avoid breaking the build with glibc-2.23.90 (upcoming 2.24), use it
    instead of readdir_r().
    
    See: http://man7.org/linux/man-pages/man3/readdir.3.html
    
    "However, in modern implementations (including the glibc implementation),
    concurrent calls to readdir() that specify different directory streams
    are thread-safe.  In cases where multiple threads must read from the
    same directory stream, using readdir() with external synchronization is
    still preferable to the use of the deprecated readdir_r(3) function."
    
    Noticed while building on a Fedora Rawhide docker container.
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-wddn49r6bz6wq4ee3dxbl7lo@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 18bb810577ead97d17a4c51705d53f88c19c93d7
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Fri Apr 8 11:32:15 2016 -0300

    perf tools: Use readdir() instead of deprecated readdir_r()
    
    commit 7093b4c963cc4e344e490c774924a180602a7092 upstream.
    
    The readdir() function is thread safe as long as just one thread uses a
    DIR, which is the case when synthesizing events for pre-existing threads
    by traversing /proc, so, to avoid breaking the build with glibc-2.23.90
    (upcoming 2.24), use it instead of readdir_r().
    
    See: http://man7.org/linux/man-pages/man3/readdir.3.html
    
    "However, in modern implementations (including the glibc implementation),
    concurrent calls to readdir() that specify different directory streams
    are thread-safe.  In cases where multiple threads must read from the
    same directory stream, using readdir() with external synchronization is
    still preferable to the use of the deprecated readdir_r(3) function."
    
    Noticed while building on a Fedora Rawhide docker container.
    
       CC       /tmp/build/perf/util/event.o
      util/event.c: In function '__event__synthesize_thread':
      util/event.c:466:2: error: 'readdir_r' is deprecated [-Werror=deprecated-declarations]
        while (!readdir_r(tasks, &dirent, &next) && next) {
        ^~~~~
      In file included from /usr/include/features.h:368:0,
                       from /usr/include/stdint.h:25,
                       from /usr/lib/gcc/x86_64-redhat-linux/6.0.0/include/stdint.h:9,
                       from /git/linux/tools/include/linux/types.h:6,
                       from util/event.c:1:
      /usr/include/dirent.h:189:12: note: declared here
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-i1vj7nyjp2p750rirxgrfd3c@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8f7cfa5be5a15f7e299eece39f67b09a46345477
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Fri Apr 8 11:31:24 2016 -0300

    perf thread_map: Use readdir() instead of deprecated readdir_r()
    
    commit 3354cf71104de49326d19d2f9bdb1f66eea52ef4 upstream.
    
    The readdir() function is thread safe as long as just one thread uses a
    DIR, which is the case in thread_map, so, to avoid breaking the build
    with glibc-2.23.90 (upcoming 2.24), use it instead of readdir_r().
    
    See: http://man7.org/linux/man-pages/man3/readdir.3.html
    
    "However, in modern implementations (including the glibc implementation),
    concurrent calls to readdir() that specify different directory streams
    are thread-safe.  In cases where multiple threads must read from the
    same directory stream, using readdir() with external synchronization is
    still preferable to the use of the deprecated readdir_r(3) function."
    
    Noticed while building on a Fedora Rawhide docker container.
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-del8h2a0f40z75j4r42l96l0@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d7c288316164259002f6bf7441b12dd215f956ab
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Fri Apr 8 11:25:59 2016 -0300

    perf script: Use readdir() instead of deprecated readdir_r()
    
    commit a5e8e825bd1704c488bf6a46936aaf3b9f203d6a upstream.
    
    The readdir() function is thread safe as long as just one thread uses a
    DIR, which is the case in 'perf script', so, to avoid breaking the build
    with glibc-2.23.90 (upcoming 2.24), use it instead of readdir_r().
    
    See: http://man7.org/linux/man-pages/man3/readdir.3.html
    
    "However, in modern implementations (including the glibc implementation),
    concurrent calls to readdir() that specify different directory streams
    are thread-safe.  In cases where multiple threads must read from the
    same directory stream, using readdir() with external synchronization is
    still preferable to the use of the deprecated readdir_r(3) function."
    
    Noticed while building on a Fedora Rawhide docker container.
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-mt3xz7n2hl49ni2vx7kuq74g@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c1aa68beb463250fc67e20c4059505fe9061c585
Author: Chanho Park <chanho61.park@samsung.com>
Date:   Fri Sep 12 11:10:17 2014 +0900

    perf tools: define _DEFAULT_SOURCE for glibc_2.20
    
    commit 512fe365373b9c95a70b4b6357503ee74d27214f upstream.
    
    _BSD_SOURCE was deprecated in favour of _DEFAULT_SOURCE since glibc
    2.20[1]. To avoid build warning on glibc2.20, _DEFAULT_SOURCE should
    also be defined.
    
    [1]: https://sourceware.org/glibc/wiki/Release/2.20
    
    Signed-off-by: Chanho Park <chanho61.park@samsung.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Link: http://lkml.kernel.org/r/1410487817-13403-1-git-send-email-chanho61.park@samsung.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a2aa2595e4cc0fb8ed38da4ff28265c6e12e930d
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Thu Jul 7 18:28:43 2016 -0300

    perf tools: Move syscall number fallbacks from perf-sys.h to tools/arch/x86/include/asm/
    
    commit cec07f53c398f22576df77052c4777dc13f14962 upstream.
    
    And remove the empty tools/arch/x86/include/asm/unistd_{32,64}.h files
    introduced by eae7a755ee81 ("perf tools, x86: Build perf on older
    user-space as well").
    
    This way we get closer to mirroring the kernel for cases where __NR_
    can't be found for some include path/_GNU_SOURCE/whatever scenario.
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-kpj6m3mbjw82kg6krk2z529e@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    [bwh: Backported to 3.16:
     - Also remove the deleted headers from LIB_H in Makefile.perf
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5c0de9c2283c44e7ad79933cb87b320f6349039a
Author: Tushar Behera <tushar.b@samsung.com>
Date:   Tue Jun 17 16:38:50 2014 +0530

    usb: misc: usb3503: Update error code in print message
    
    commit ec5734c41bee2ee7c938a8f34853d31cada7e67a upstream.
    
    'err' is uninitialized, rather print the error code directly.
    
    This also fixes following warning.
    drivers/usb/misc/usb3503.c: In function ‘usb3503_probe’:
    drivers/usb/misc/usb3503.c:195:11: warning: ‘err’ may be used uninitialized
    in this function [-Wmaybe-uninitialized]
        dev_err(dev, "unable to request refclk (%d)\n", err);
    
    Signed-off-by: Tushar Behera <tushar.b@samsung.com>
    Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7f26d46a35604177346aa338a11b6ce73637325c
Author: zhong jiang <zhongjiang@huawei.com>
Date:   Fri Aug 3 20:37:32 2018 +0800

    sched/topology: Make local variables static
    
    commit ace8031099f91480799b5929b4cccf2dcacc5136 upstream.
    
    Fix the following warnings:
    
      kernel/sched/topology.c:10:15: warning: symbol 'sched_domains_tmpmask' was not declared. Should it be static?
      kernel/sched/topology.c:11:15: warning: symbol 'sched_domains_tmpmask2' was not declared. Should it be static?
    
    Signed-off-by: zhong jiang <zhongjiang@huawei.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/1533299852-26941-1-git-send-email-zhongjiang@huawei.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    [bwh: Backported to 3.16: adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9dabb3a0055ed66d84a492b536a35cecf8c5af70
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sun Nov 11 01:02:49 2018 +0000

    x86/apic: Fix build failure with X86_IO_APIC disabled
    
    My backport of commit 2e63ad4bd5dd "x86/apic: Do not init irq
    remapping if ioapic is disabled" added an unconditional use of
    skip_ioapic_setup.  Enabling X86_LOCAL_APIC but not X86_IO_APIC
    results in a build failure.
    
    This configuration was made impossible by commit b1da1e715d4f
    "x86/Kconfig: Simplify X86_IO_APIC dependencies", but that seems to
    depend on additional changes that aren't suitable for stable.
    
    The function that was changed, enable_IR_x2apic(), is only used in
    64-bit configurations where CONFIG_X86_IO_APIC is always enabled.  So
    extend the #ifdef CONFIG_X86_64 section to include this function.
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 16d44afca3872baa1ff5f506afc525c90aa8b798
Author: Markos Chandras <markos.chandras@imgtec.com>
Date:   Thu Apr 16 11:05:59 2015 +0100

    MIPS: asmmacro: Ensure 64-bit FP registers are used with MSA
    
    commit 2bd7bc254ab1f45269db6dd7957d63b713817408 upstream.
    
    This silences warnings like the following one when building with the
    latest binutils:
    
    arch/mips/kernel/genex.S: Assembler messages:
    arch/mips/kernel/genex.S:438: Warning: the `msa' extension requires 64-bit FPRs
    
    [ralf@linux-mips.org: Markos says binutils 2.25 and some 2.24 snapshots
    are affected.]
    
    Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
    Reviewed-by: James Hogan <james.hogan@imgtec.com>
    Cc: Paul Burton <paul.burton@imgtec.com>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/9745/
    Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d590e094293144e5efc61aa70a3089b026171e86
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Thu Nov 12 15:41:08 2015 +0100

    arm64: use linux/types.h in kvm.h
    
    commit d19279154b3fff9adff96b54d1a77dfb8f01e3da upstream.
    
    We should always use linux/types.h instead of asm/types.h for
    consistency, and Kbuild actually warns about it:
    
    ./usr/include/asm/kvm.h:35: include of <linux/types.h> is preferred over <asm/types.h>
    
    This patch does as Kbuild asks us.
    
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4424bfaaab49485b51ca78bde79b7c157718b951
Author: Geoff Levand <geoff@infradead.org>
Date:   Tue Feb 17 13:45:50 2015 -0800

    kexec: Fix make headers_check
    
    commit 9dc5c05f45ca8101025046cda7f8aca8835204f2 upstream.
    
    Remove the unneded declaration for a kexec_load() routine.
    
    Fixes errors like these when running 'make headers_check':
    
    include/uapi/linux/kexec.h: userspace cannot reference function or variable defined in the kernel
    
    Paul said:
    
    : The kexec_load declaration isn't very useful for userspace, see the patch
    : I submitted in http://lkml.kernel.org/r/1389791824.17407.9.camel@x220 .
    : And After my attempt the export of that declaration has also been
    : discussed in
    : http://lkml.kernel.org/r/115373b6ac68ee7a305975896e1c4971e8e51d4c.1408731991.git.geoff@infradead.org
    :
    : In that last discussion no one has been able to point to an actual user of
    : it.  So, as far as I can tell, no one actually uses it.  Which makes
    : sense, because including this header by itself doesn't give one access to
    : a useful definition of kexec_load.  So why bother with the declaration?
    
    Signed-off-by: Geoff Levand <geoff@infradead.org>
    Acked-by: Paul Bolle <pebolle@tiscali.nl>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Vivek Goyal <vgoyal@redhat.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Maximilian Attems <max@stro.at>
    Cc: Michal Marek <mmarek@suse.cz>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 674dbb248deb18fe5fbdf57a06218d1544da852e
Author: Jiri Slaby <jslaby@suse.cz>
Date:   Fri Oct 14 11:23:09 2016 +0200

    p54: memset(0) whole array
    
    commit 6f17581788206444cbbcdbc107498f85e9765e3d upstream.
    
    gcc 7 complains:
    drivers/net/wireless/intersil/p54/fwio.c: In function 'p54_scan':
    drivers/net/wireless/intersil/p54/fwio.c:491:4: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
    
    Fix that by passing the correct size to memset.
    
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Cc: Christian Lamparter <chunkeey@googlemail.com>
    Cc: Kalle Valo <kvalo@codeaurora.org>
    Cc: linux-wireless@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Acked-by: Christian Lamparter <chunkeey@googlemail.com>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 21c7e5a39da0922a81f33cefad0a239bcfe897ac
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Thu May 11 08:46:44 2017 -0300

    ir-core: fix gcc-7 warning on bool arithmetic
    
    commit bd7e31bbade02bc1e92aa00d5cf2cee2da66838a upstream.
    
    gcc-7 suggests that an expression using a bitwise not and a bitmask
    on a 'bool' variable is better written using boolean logic:
    
    drivers/media/rc/imon.c: In function 'imon_incoming_scancode':
    drivers/media/rc/imon.c:1725:22: error: '~' on a boolean expression [-Werror=bool-operation]
        ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1;
                          ^
    drivers/media/rc/imon.c:1725:22: note: did you mean to use logical not?
    
    I agree.
    
    Fixes: 21677cfc562a ("V4L/DVB: ir-core: add imon driver")
    
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b916ecc8d56cd4a90bfb2e8802afe8209c24a624
Author: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Date:   Sun Jun 22 20:50:40 2014 +0200

    net/wireless/brcm80211/brcmfmac: Make return type and name reflect actual semantics
    
    commit e843bb199ba58ce5d1364d4c82fcf6975f08eec2 upstream.
    
    Applying ++ to a bool is equivalent to setting it true, regardless of
    its initial value (bools are not uint1_t). Hence the function
    wl_get_vif_state_all can only ever return true/false. The only in-tree
    caller uses its return value as a boolean. So update its return type,
    and since the list traversal and bit testing have no side effects,
    just return true immediately. Its return value tells if any vif is in
    the specified state, so also rename it to brcmf_get_vif_state_any.
    
    Reviewed-by: Arend van Spriel<arend@broadcom.com>
    Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
    Signed-off-by: John W. Linville <linville@tuxdriver.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 492e260fbde25d10a5f1f0ae07bfaae2140c1571
Author: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Date:   Fri Mar 20 12:34:10 2015 +0100

    clk: si5351: Constify clock names and struct regmap_config
    
    commit 8234caed27f7bce141c9fb1f7e76c91a2a66d248 upstream.
    
    The regmap_config struct may be const because it is not modified by the
    driver and regmap_init() accepts pointer to const.
    
    Replace doubled const in the arrays of clock names with proper const
    pointer to const data. This fixes the warnings:
    
    drivers/clk/clk-si5351.c:71:25: warning: duplicate const
    drivers/clk/clk-si5351.c:74:25: warning: duplicate const
    drivers/clk/clk-si5351.c:77:25: warning: duplicate const
    drivers/clk/clk-si5351.c:80:25: warning: duplicate const
    
    Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
    Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
    Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ffd2a7537f0c298483a3845cea3c1b2ae6eb841e
Author: Markos Chandras <markos.chandras@imgtec.com>
Date:   Tue Nov 18 15:02:32 2014 +0000

    MIPS: asm: compiler: Add new macros to set ISA and arch asm annotations
    
    commit be5136988e25ae0dc8379fcb937efc63d87aba9e upstream.
    
    There are certain places where the code uses .set mips32 or .set mips64
    or .set arch=r4000. In preparation of MIPS R6 support, and in order to
    use as less #ifdefs as possible, we define new macros to set similar
    annotations for MIPS R6.
    
    Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
    [bwh: Backported to 3.16: We don't support MIPS R6 but I have applied a
     commit that uses MIPS_ISA_LEVEL_RAW.  Add the R2 definitions only.]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e0ab903d9f1814a80a306b7432a696171c846de7
Author: Ben Hutchings <ben.hutchings@codethink.co.uk>
Date:   Sun Nov 11 02:00:51 2018 +0000

    iio: iio-trig-periodic-rtc: Free trigger resource correctly
    
    This is based on upstream commit 10e840dfb0b7, which did not touch the
    iio-trig-periodic-rtc driver because it has been removed upstream.
    
    The following explanation comes from that commit:
    
        These stand-alone trigger drivers were using iio_trigger_put()
        where they should have been using iio_trigger_free().  The
        iio_trigger_put() adds a module_put which is bad since they
        never did a module_get.
    
        In the sysfs driver, module_get/put's are used as triggers are
        added & removed. This extra module_put() occurs on an error path
        in the probe routine (probably rare).
    
        In the bfin-timer & interrupt trigger drivers, the module resources
        are not explicitly managed, so it's doing a put on something that
        was never get'd.  It occurs on the probe error path and on the
        remove path (not so rare).
    
        Tested with the sysfs trigger driver.
        The bfin & interrupt drivers were build tested & inspected only.
    
    This was build tested only.
    
    Cc: Alison Schofield <amsfield22@gmail.com>
    Cc: Jonathan Cameron <jic23@kernel.org>
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 15382b8ce2b8e194eb4bf1e68868e05d4e75e886
Author: Wanpeng Li <wanpeng.li@hotmail.com>
Date:   Wed Dec 13 10:46:40 2017 +0100

    KVM: x86: fix escape of guest dr6 to the host
    
    commit efdab992813fb2ed825745625b83c05032e9cda2 upstream.
    
    syzkaller reported:
    
       WARNING: CPU: 0 PID: 12927 at arch/x86/kernel/traps.c:780 do_debug+0x222/0x250
       CPU: 0 PID: 12927 Comm: syz-executor Tainted: G           OE    4.15.0-rc2+ #16
       RIP: 0010:do_debug+0x222/0x250
       Call Trace:
        <#DB>
        debug+0x3e/0x70
       RIP: 0010:copy_user_enhanced_fast_string+0x10/0x20
        </#DB>
        _copy_from_user+0x5b/0x90
        SyS_timer_create+0x33/0x80
        entry_SYSCALL_64_fastpath+0x23/0x9a
    
    The testcase sets a watchpoint (with perf_event_open) on a buffer that is
    passed to timer_create() as the struct sigevent argument.  In timer_create(),
    copy_from_user()'s rep movsb triggers the BP.  The testcase also sets
    the debug registers for the guest.
    
    However, KVM only restores host debug registers when the host has active
    watchpoints, which triggers a race condition when running the testcase with
    multiple threads.  The guest's DR6.BS bit can escape to the host before
    another thread invokes timer_create(), and do_debug() complains.
    
    The fix is to respect do_debug()'s dr6 invariant when leaving KVM.
    
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Radim Krčmář <rkrcmar@redhat.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Reviewed-by: David Hildenbrand <david@redhat.com>
    Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 30b372c7f2d70e8374866dae72922824cf4760bd
Author: Martin Liska <mliska@suse.cz>
Date:   Fri May 12 15:46:35 2017 -0700

    gcov: support GCC 7.1
    
    commit 05384213436ab690c46d9dfec706b80ef8d671ab upstream.
    
    Starting from GCC 7.1, __gcov_exit is a new symbol expected to be
    implemented in a profiling runtime.
    
    [akpm@linux-foundation.org: coding-style fixes]
    [mliska@suse.cz: v2]
      Link: http://lkml.kernel.org/r/e63a3c59-0149-c97e-4084-20ca8f146b26@suse.cz
    Link: http://lkml.kernel.org/r/8c4084fa-3885-29fe-5fc4-0d4ca199c785@suse.cz
    Signed-off-by: Martin Liska <mliska@suse.cz>
    Acked-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit de1cc8da418a9594113bdb783931f74129adeb96
Author: Florian Meier <Florian.Meier@informatik.uni-erlangen.de>
Date:   Thu Jul 14 12:07:26 2016 -0700

    gcov: add support for gcc version >= 6
    
    commit d02038f972538b93011d78c068f44514fbde0a8c upstream.
    
    Link: http://lkml.kernel.org/r/20160701130914.GA23225@styxhp
    Signed-off-by: Florian Meier <Florian.Meier@informatik.uni-erlangen.de>
    Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
    Tested-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9edea8e1138776f436808a3dce22c9dd275246e1
Author: Lorenzo Stoakes <lstoakes@gmail.com>
Date:   Tue Jun 30 14:57:49 2015 -0700

    gcov: add support for GCC 5.1
    
    commit 3e44c471a2dab210f7e9b1e5f7d4d54d52df59eb upstream.
    
    Fix kernel gcov support for GCC 5.1.  Similar to commit a992bf836f9
    ("gcov: add support for GCC 4.9"), this patch takes into account the
    existence of a new gcov counter (see gcc's gcc/gcov-counter.def.)
    
    Firstly, it increments GCOV_COUNTERS (to 10), which makes the data
    structure struct gcov_info compatible with GCC 5.1.
    
    Secondly, a corresponding counter function __gcov_merge_icall_topn (Top N
    value tracking for indirect calls) is included in base.c with the other
    gcov counters unused for kernel profiling.
    
    Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
    Cc: Andrey Ryabinin <a.ryabinin@samsung.com>
    Cc: Yuan Pengfei <coolypf@qq.com>
    Tested-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
    Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6fa8179fc923d0aa66d365320eea5f8f79b18844
Author: Shuah Khan <shuahkh@osg.samsung.com>
Date:   Fri Dec 15 10:05:15 2017 -0700

    usbip: stub_rx: fix static checker warning on unnecessary checks
    
    commit 10c90120930628e8b959bf58d4a0aaef3ae5d945 upstream.
    
    Fix the following static checker warnings:
    
    The patch c6688ef9f297: "usbip: fix stub_rx: harden CMD_SUBMIT path
    to handle malicious input" from Dec 7, 2017, leads to the following
    static checker warning:
    
        drivers/usb/usbip/stub_rx.c:346 get_pipe()
        warn: impossible condition
    '(pdu->u.cmd_submit.transfer_buffer_length > ((~0 >> 1))) =>
    (s32min-s32max > s32max)'
        drivers/usb/usbip/stub_rx.c:486 stub_recv_cmd_submit()
        warn: always true condition
    '(pdu->u.cmd_submit.transfer_buffer_length <= ((~0 >> 1))) =>
    (s32min-s32max <= s32max)'
    
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0a1454aceefae531ee3d54aa764edb6cad938159
Author: Tomasz Kramkowski <tk@the-tk.com>
Date:   Tue Mar 14 13:29:13 2017 +0000

    HID: clamp input to logical range if no null state
    
    commit c3883fe06488a483658ba5d849b70e49bee15e7c upstream.
    
    This patch fixes an issue in drivers/hid/hid-input.c where values
    outside of the logical range are not clamped when "null state" bit of
    the input control is not set.
    
    This was discussed on the lists [1] and this change stems from the fact
    due to the ambiguity of the HID specification it might be appropriate to
    follow Microsoft's own interpretation of the specification. As noted in
    Microsoft's documentation [2] in the section titled "Required HID usages
    for digitizers" it is noted that values reported outside the logical
    range "will be considered as invalid data and the value will be changed
    to the nearest boundary value (logical min/max)."
    
    This patch fixes an issue where the (1292:4745) Innomedia INNEX
    GENESIS/ATARI reports out of range values for its X and Y axis of the
    DPad which, due to the null state bit being unset, are forwarded to
    userspace as is. Now these values will get clamped to the logical range
    before being forwarded to userspace. This device was also used to test
    this patch.
    
    This patch expands on commit 3f3752705dbd ("HID: reject input outside
    logical range only if null state is set").
    
    [1]: http://lkml.kernel.org/r/20170307131036.GA853@gaia.local
    [2]: https://msdn.microsoft.com/en-us/library/windows/hardware/dn672278(v=vs.85).asp
    
    Signed-off-by: Tomasz Kramkowski <tk@the-tk.com>
    Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4628582178bf13565593c9ff432cdaf90864e5e5
Author: Valtteri Heikkilä <rnd@nic.fi>
Date:   Tue Feb 14 23:14:32 2017 +0000

    HID: reject input outside logical range only if null state is set
    
    commit 3f3752705dbd50b66b66ad7b4d54fe33d2f746ed upstream.
    
    This patch fixes an issue in drivers/hid/hid-input.c where USB HID
    control null state flag is not checked upon rejecting inputs outside
    logical minimum-maximum range. The check should be made according to USB
    HID specification 1.11, section 6.2.2.5, p.31. The fix will resolve
    issues with some game controllers, such as:
    https://bugzilla.kernel.org/show_bug.cgi?id=68621
    
    [tk@the-tk.com: shortened and fixed spelling in commit message]
    Signed-off-by: Valtteri Heikkilä <rnd@nic.fi>
    Signed-off-by: Tomasz Kramkowski <tk@the-tk.com>
    Acked-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d4de72aae6f0cb27a863cb5a2292a6d2ae680ce1
Author: Tomasz Kramkowski <tk@the-tk.com>
Date:   Tue Feb 14 23:14:33 2017 +0000

    HID: usbhid: add quirk for innomedia INNEX GENESIS/ATARI adapter
    
    commit 9547837bdccb4af127528b36a73377150658b4ac upstream.
    
    The (1292:4745) Innomedia INNEX GENESIS/ATARI adapter needs
    HID_QUIRK_MULTI_INPUT to split the device up into two controllers
    instead of inputs from both being merged into one.
    
    Signed-off-by: Tomasz Kramkowski <tk@the-tk.com>
    Acked-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3bec3abfec171bcd4831b0869c597ff2e9600abc
Author: Nathan Sullivan <nathan.sullivan@ni.com>
Date:   Mon Aug 15 17:20:14 2016 -0500

    leds: do not overflow sysfs buffer in led_trigger_show
    
    commit 3b9b95363c45365d606ad4bbba16acca75fdf6d3 upstream.
    
    Per the documentation, use scnprintf instead of sprintf to ensure there
    is never more than PAGE_SIZE bytes of trigger names put into the
    buffer.
    
    Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
    Signed-off-by: Zach Brown <zach.brown@ni.com>
    Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 116d8eebbd21c3f011240d3f3f9195c6ed0c42f6
Author: Andy Lutomirski <luto@kernel.org>
Date:   Fri Sep 30 10:58:57 2016 -0700

    fs/proc: Stop trying to report thread stacks
    
    commit b18cb64ead400c01bf1580eeba330ace51f8087d upstream.
    
    This reverts more of:
    
      b76437579d13 ("procfs: mark thread stack correctly in proc/<pid>/maps")
    
    ... which was partially reverted by:
    
      65376df58217 ("proc: revert /proc/<pid>/maps [stack:TID] annotation")
    
    Originally, /proc/PID/task/TID/maps was the same as /proc/TID/maps.
    
    In current kernels, /proc/PID/maps (or /proc/TID/maps even for
    threads) shows "[stack]" for VMAs in the mm's stack address range.
    
    In contrast, /proc/PID/task/TID/maps uses KSTK_ESP to guess the
    target thread's stack's VMA.  This is racy, probably returns garbage
    and, on arches with CONFIG_TASK_INFO_IN_THREAD=y, is also crash-prone:
    KSTK_ESP is not safe to use on tasks that aren't known to be running
    ordinary process-context kernel code.
    
    This patch removes the difference and just shows "[stack]" for VMAs
    in the mm's stack range.  This is IMO much more sensible -- the
    actual "stack" address really is treated specially by the VM code,
    and the current thread stack isn't even well-defined for programs
    that frequently switch stacks on their own.
    
    Reported-by: Jann Horn <jann@thejh.net>
    Signed-off-by: Andy Lutomirski <luto@kernel.org>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Linux API <linux-api@vger.kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Tycho Andersen <tycho.andersen@canonical.com>
    Link: http://lkml.kernel.org/r/3e678474ec14e0a0ec34c611016753eea2e1b8ba.1475257877.git.luto@kernel.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    [bwh: Backported to 3.16: Squash in the earlier commits 58cb65487e92
     "proc/maps: make vm_is_stack() logic namespace-friendly" and
     65376df58217 "proc: revert /proc/<pid>/maps [stack:TID] annotation",
     which would introduce build failures if applied separately.]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7a71d994ade5062ec16b64aaa5842d29db4f1700
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Wed Nov 23 17:04:00 2016 -0500

    dm bufio: drop the lock when doing GFP_NOIO allocation
    
    commit 41c73a49df31151f4ff868f28fe4f129f113fa2c upstream.
    
    If the first allocation attempt using GFP_NOWAIT fails, drop the lock
    and retry using GFP_NOIO allocation (lock is dropped because the
    allocation can take some time).
    
    Note that we won't do GFP_NOIO allocation when we loop for the second
    time, because the lock shouldn't be dropped between __wait_for_free_buffer
    and __get_unclaimed_buffer.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Cc: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 89b0a68f419d75298d8a0003ab993786c9dc99ae
Author: Douglas Anderson <dianders@chromium.org>
Date:   Thu Nov 17 11:24:20 2016 -0800

    dm bufio: avoid sleeping while holding the dm_bufio lock
    
    commit 9ea61cac0b1ad0c09022f39fd97e9b99a2cfc2dc upstream.
    
    We've seen in-field reports showing _lots_ (18 in one case, 41 in
    another) of tasks all sitting there blocked on:
    
      mutex_lock+0x4c/0x68
      dm_bufio_shrink_count+0x38/0x78
      shrink_slab.part.54.constprop.65+0x100/0x464
      shrink_zone+0xa8/0x198
    
    In the two cases analyzed, we see one task that looks like this:
    
      Workqueue: kverityd verity_prefetch_io
    
      __switch_to+0x9c/0xa8
      __schedule+0x440/0x6d8
      schedule+0x94/0xb4
      schedule_timeout+0x204/0x27c
      schedule_timeout_uninterruptible+0x44/0x50
      wait_iff_congested+0x9c/0x1f0
      shrink_inactive_list+0x3a0/0x4cc
      shrink_lruvec+0x418/0x5cc
      shrink_zone+0x88/0x198
      try_to_free_pages+0x51c/0x588
      __alloc_pages_nodemask+0x648/0xa88
      __get_free_pages+0x34/0x7c
      alloc_buffer+0xa4/0x144
      __bufio_new+0x84/0x278
      dm_bufio_prefetch+0x9c/0x154
      verity_prefetch_io+0xe8/0x10c
      process_one_work+0x240/0x424
      worker_thread+0x2fc/0x424
      kthread+0x10c/0x114
    
    ...and that looks to be the one holding the mutex.
    
    The problem has been reproduced on fairly easily:
    0. Be running Chrome OS w/ verity enabled on the root filesystem
    1. Pick test patch: http://crosreview.com/412360
    2. Install launchBalloons.sh and balloon.arm from
         http://crbug.com/468342
       ...that's just a memory stress test app.
    3. On a 4GB rk3399 machine, run
         nice ./launchBalloons.sh 4 900 100000
       ...that tries to eat 4 * 900 MB of memory and keep accessing.
    4. Login to the Chrome web browser and restore many tabs
    
    With that, I've seen printouts like:
      DOUG: long bufio 90758 ms
    ...and stack trace always show's we're in dm_bufio_prefetch().
    
    The problem is that we try to allocate memory with GFP_NOIO while
    we're holding the dm_bufio lock.  Instead we should be using
    GFP_NOWAIT.  Using GFP_NOIO can cause us to sleep while holding the
    lock and that causes the above problems.
    
    The current behavior explained by David Rientjes:
    
      It will still try reclaim initially because __GFP_WAIT (or
      __GFP_KSWAPD_RECLAIM) is set by GFP_NOIO.  This is the cause of
      contention on dm_bufio_lock() that the thread holds.  You want to
      pass GFP_NOWAIT instead of GFP_NOIO to alloc_buffer() when holding a
      mutex that can be contended by a concurrent slab shrinker (if
      count_objects didn't use a trylock, this pattern would trivially
      deadlock).
    
    This change significantly increases responsiveness of the system while
    in this state.  It makes a real difference because it unblocks kswapd.
    In the bug report analyzed, kswapd was hung:
    
       kswapd0         D ffffffc000204fd8     0    72      2 0x00000000
       Call trace:
       [<ffffffc000204fd8>] __switch_to+0x9c/0xa8
       [<ffffffc00090b794>] __schedule+0x440/0x6d8
       [<ffffffc00090bac0>] schedule+0x94/0xb4
       [<ffffffc00090be44>] schedule_preempt_disabled+0x28/0x44
       [<ffffffc00090d900>] __mutex_lock_slowpath+0x120/0x1ac
       [<ffffffc00090d9d8>] mutex_lock+0x4c/0x68
       [<ffffffc000708e7c>] dm_bufio_shrink_count+0x38/0x78
       [<ffffffc00030b268>] shrink_slab.part.54.constprop.65+0x100/0x464
       [<ffffffc00030dbd8>] shrink_zone+0xa8/0x198
       [<ffffffc00030e578>] balance_pgdat+0x328/0x508
       [<ffffffc00030eb7c>] kswapd+0x424/0x51c
       [<ffffffc00023f06c>] kthread+0x10c/0x114
       [<ffffffc000203dd0>] ret_from_fork+0x10/0x40
    
    By unblocking kswapd memory pressure should be reduced.
    
    Suggested-by: David Rientjes <rientjes@google.com>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Douglas Anderson <dianders@chromium.org>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Cc: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4552db4687e93d379f7be755591d4aa730b5de46
Author: Jeff Layton <jlayton@redhat.com>
Date:   Thu Jan 12 14:42:38 2017 -0500

    ceph: fix endianness of getattr mask in ceph_d_revalidate
    
    commit 1097680d759918ce4a8705381c0ab2ed7bd60cf1 upstream.
    
    sparse says:
    
        fs/ceph/dir.c:1248:50: warning: incorrect type in assignment (different base types)
        fs/ceph/dir.c:1248:50:    expected restricted __le32 [usertype] mask
        fs/ceph/dir.c:1248:50:    got int [signed] [assigned] mask
    
    Fixes: 200fd27c8fa2 ("ceph: use lookup request to revalidate dentry")
    Signed-off-by: Jeff Layton <jlayton@redhat.com>
    Reviewed-by: Sage Weil <sage@redhat.com>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Cc: Bryan Henderson <bryanh@giraffe-data.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b72d88983415d962b86071ac0ea9695e7c2df8e3
Author: Jeff Layton <jlayton@redhat.com>
Date:   Wed Nov 30 15:56:46 2016 -0500

    ceph: don't set req->r_locked_dir in ceph_d_revalidate
    
    commit c3f4688a08fd86f1bf8e055724c84b7a40a09733 upstream.
    
    This function sets req->r_locked_dir which is supposed to indicate to
    ceph_fill_trace that the parent's i_rwsem is locked for write.
    Unfortunately, there is no guarantee that the dir will be locked when
    d_revalidate is called, so we really don't want ceph_fill_trace to do
    any dcache manipulation from this context. Clear req->r_locked_dir since
    it's clearly not safe to do that.
    
    What we really want to know with d_revalidate is whether the dentry
    still points to the same inode. ceph_fill_trace installs a pointer to
    the inode in req->r_target_inode, so we can just compare that to
    d_inode(dentry) to see if it's the same one after the lookup.
    
    Also, since we aren't generally interested in the parent here, we can
    switch to using a GETATTR to hint that to the MDS, which also means that
    we only need to reserve one cap.
    
    Finally, just remove the d_unhashed check. That's really outside the
    purview of a filesystem's d_revalidate. If the thing became unhashed
    while we're checking it, then that's up to the VFS to handle anyway.
    
    Fixes: 200fd27c8fa2 ("ceph: use lookup request to revalidate dentry")
    Link: http://tracker.ceph.com/issues/18041
    Reported-by: Donatas Abraitis <donatas.abraitis@gmail.com>
    Signed-off-by: Jeff Layton <jlayton@redhat.com>
    Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Cc: Bryan Henderson <bryanh@giraffe-data.com>
    [bwh: Backported to 3.16: s/d_really_is_(positive|negative)/d_is_\1/ since
     we don't have to consider overlayfs]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f7fc399651168440fe7ee7ff47c38c56a96479a1
Author: Yan, Zheng <zyan@redhat.com>
Date:   Thu Mar 17 14:41:59 2016 +0800

    ceph: use lookup request to revalidate dentry
    
    commit 200fd27c8fa2ba8bb4529033967b69a7cbfa2c2e upstream.
    
    If dentry has no lease, ceph_d_revalidate() previously return 0.
    This causes VFS to invalidate the dentry and create a new dentry
    for later lookup. Invalidating a dentry also detach any underneath
    mount points. So mount point inside cephfs can disapear mystically
    (even the mount point is not modified by other hosts).
    
    The fix is using lookup request to revalidate dentry without lease.
    This can partly solve the mount points disapear issue (as long as
    the mount point is not modified by other hosts)
    
    Signed-off-by: Yan, Zheng <zyan@redhat.com>
    Cc: Bryan Henderson <bryanh@giraffe-data.com>
    [bwh: Backported to 3.16: Add the ceph_security_xattr_wanted() function]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d90e62136a54ca743c2e4b3cfe4beb784c06673f
Author: Yan, Zheng <zyan@redhat.com>
Date:   Thu Sep 18 16:11:12 2014 +0800

    ceph: fix llistxattr on symlink
    
    commit 0abb43dcacb52145aa265f82c914375d59dfe2da upstream.
    
    only regular file and directory have vxattrs.
    
    Signed-off-by: Yan, Zheng <zyan@redhat.com>
    Cc: Bryan Henderson <bryanh@giraffe-data.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a37099499a019538386ef53ca1485cafa6095e0b
Author: Sakari Ailus <sakari.ailus@linux.intel.com>
Date:   Tue Sep 11 05:32:37 2018 -0400

    media: v4l: event: Prevent freeing event subscriptions while accessed
    
    commit ad608fbcf166fec809e402d548761768f602702c upstream.
    
    The event subscriptions are added to the subscribed event list while
    holding a spinlock, but that lock is subsequently released while still
    accessing the subscription object. This makes it possible to unsubscribe
    the event --- and freeing the subscription object's memory --- while
    the subscription object is simultaneously accessed.
    
    Prevent this by adding a mutex to serialise the event subscription and
    unsubscription. This also gives a guarantee to the callback ops that the
    add op has returned before the del op is called.
    
    This change also results in making the elems field less special:
    subscriptions are only added to the event list once they are fully
    initialised.
    
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
    Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Fixes: c3b5b0241f62 ("V4L/DVB: V4L: Events: Add backend")
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 318e55a2b683f213e87b36689e6e362284373168
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu Mar 5 14:26:37 2015 +0300

    ALSA: msnd: add some missing curly braces
    
    commit 096a020a9ef5c947577d3b57199bfc9b7e686b49 upstream.
    
    There were some curly braces intended here.
    
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 49694567f25efe5525469bfe5b0356f8edb67599
Author: Juergen Gross <jgross@suse.com>
Date:   Thu Aug 9 16:42:16 2018 +0200

    xen/netfront: don't cache skb_shinfo()
    
    commit d472b3a6cf63cd31cae1ed61930f07e6cd6671b5 upstream.
    
    skb_shinfo() can change when calling __pskb_pull_tail(): Don't cache
    its return value.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Wei Liu <wei.liu2@citrix.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c29c4ebd93e047cf3f578adf0e75dc090c90d567
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Thu Aug 9 10:15:54 2018 -0400

    make sure that __dentry_kill() always invalidates d_seq, unhashed or not
    
    commit 4c0d7cd5c8416b1ef41534d19163cb07ffaa03ab upstream.
    
    RCU pathwalk relies upon the assumption that anything that changes
    ->d_inode of a dentry will invalidate its ->d_seq.  That's almost
    true - the one exception is that the final dput() of already unhashed
    dentry does *not* touch ->d_seq at all.  Unhashing does, though,
    so for anything we'd found by RCU dcache lookup we are fine.
    Unfortunately, we can *start* with an unhashed dentry or jump into
    it.
    
    We could try and be careful in the (few) places where that could
    happen.  Or we could just make the final dput() invalidate the damn
    thing, unhashed or not.  The latter is much simpler and easier to
    backport, so let's do it that way.
    
    Reported-by: "Dae R. Jeong" <threeearcat@gmail.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d7a300190970b02642899586d4233cf339f78bf5
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Sun May 29 20:13:30 2016 -0400

    unify dentry_iput() and dentry_unlink_inode()
    
    commit 550dce01dd606c88a837138aa448ccd367fb0cbb upstream.
    
    There is a lot of duplication between dentry_unlink_inode() and dentry_iput().
    The only real difference is that dentry_unlink_inode() bumps ->d_seq and
    dentry_iput() doesn't.  The argument of the latter is known to have been
    unhashed, so anybody who might've found it in RCU lookup would already be
    doomed to a ->d_seq mismatch.  And we want to avoid pointless smp_rmb() there.
    
    This patch makes dentry_unlink_inode() bump ->d_seq only for hashed dentries.
    It's safe (d_delete() calls that sucker only if we are holding the only
    reference to dentry, so rehash is not going to happen) and it allows
    to use dentry_unlink_inode() in __dentry_kill() and get rid of dentry_iput().
    
    The interesting question here is profiling; it *is* a hot path, and extra
    conditional jumps in there might or might not be painful.
    
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b9bc5b0a642e114c35bc70b9cd94c605ca5d1b8c
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Feb 29 12:12:46 2016 -0500

    use ->d_seq to get coherency between ->d_inode and ->d_flags
    
    commit a528aca7f359f4b0b1d72ae406097e491a5ba9ea upstream.
    
    Games with ordering and barriers are way too brittle.  Just
    bump ->d_seq before and after updating ->d_inode and ->d_flags
    type bits, so that verifying ->d_seq would guarantee they are
    coherent.
    
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d0058dcb67af4f0810bd2bfb1432b2697ecd24f8
Author: David Howells <dhowells@redhat.com>
Date:   Thu Mar 5 14:09:22 2015 +0000

    VFS: Impose ordering on accesses of d_inode and d_flags
    
    commit 4bf46a272647d89e780126b52eda04737defd9f4 upstream.
    
    Impose ordering on accesses of d_inode and d_flags to avoid the need to do
    this:
    
            if (!dentry->d_inode || d_is_negative(dentry)) {
    
    when this:
    
            if (d_is_negative(dentry)) {
    
    should suffice.
    
    This check is especially problematic if a dentry can have its type field set
    to something other than DENTRY_MISS_TYPE when d_inode is NULL (as in
    unionmount).
    
    What we really need to do is stick a write barrier between setting d_inode and
    setting d_flags and a read barrier between reading d_flags and reading
    d_inode.
    
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    [bwh: Backported to 3.16:
     - Use ACCESS_ONCE() instead of {READ,WRITE}_ONCE()
     - There's no DCACHE_FALLTHRU flag]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7a49bf4347ee0d287edd5f64518ec7774ec22c82
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Thu Aug 9 17:51:32 2018 -0400

    fix __legitimize_mnt()/mntput() race
    
    commit 119e1ef80ecfe0d1deb6378d4ab41f5b71519de1 upstream.
    
    __legitimize_mnt() has two problems - one is that in case of success
    the check of mount_lock is not ordered wrt preceding increment of
    refcount, making it possible to have successful __legitimize_mnt()
    on one CPU just before the otherwise final mntpu() on another,
    with __legitimize_mnt() not seeing mntput() taking the lock and
    mntput() not seeing the increment done by __legitimize_mnt().
    Solved by a pair of barriers.
    
    Another is that failure of __legitimize_mnt() on the second
    read_seqretry() leaves us with reference that'll need to be
    dropped by caller; however, if that races with final mntput()
    we can end up with caller dropping rcu_read_lock() and doing
    mntput() to release that reference - with the first mntput()
    having freed the damn thing just as rcu_read_lock() had been
    dropped.  Solution: in "do mntput() yourself" failure case
    grab mount_lock, check if MNT_DOOMED has been set by racing
    final mntput() that has missed our increment and if it has -
    undo the increment and treat that as "failure, caller doesn't
    need to drop anything" case.
    
    It's not easy to hit - the final mntput() has to come right
    after the first read_seqretry() in __legitimize_mnt() *and*
    manage to miss the increment done by __legitimize_mnt() before
    the second read_seqretry() in there.  The things that are almost
    impossible to hit on bare hardware are not impossible on SMP
    KVM, though...
    
    Reported-by: Oleg Nesterov <oleg@redhat.com>
    Fixes: 48a066e72d97 ("RCU'd vsfmounts")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    [bwh: Backported to 3.16: __legitimize_mnt() has not been split out
     from legitimize_mnt().  Adjust the added return statement and
     comments accordingly.]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7515631532abcd49deb6f31c19b60869cb27080e
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Thu Aug 9 17:21:17 2018 -0400

    fix mntput/mntput race
    
    commit 9ea0a46ca2c318fcc449c1e6b62a7230a17888f1 upstream.
    
    mntput_no_expire() does the calculation of total refcount under mount_lock;
    unfortunately, the decrement (as well as all increments) are done outside
    of it, leading to false positives in the "are we dropping the last reference"
    test.  Consider the following situation:
            * mnt is a lazy-umounted mount, kept alive by two opened files.  One
    of those files gets closed.  Total refcount of mnt is 2.  On CPU 42
    mntput(mnt) (called from __fput()) drops one reference, decrementing component
            * After it has looked at component #0, the process on CPU 0 does
    mntget(), incrementing component #0, gets preempted and gets to run again -
    on CPU 69.  There it does mntput(), which drops the reference (component #69)
    and proceeds to spin on mount_lock.
            * On CPU 42 our first mntput() finishes counting.  It observes the
    decrement of component #69, but not the increment of component #0.  As the
    result, the total it gets is not 1 as it should've been - it's 0.  At which
    point we decide that vfsmount needs to be killed and proceed to free it and
    shut the filesystem down.  However, there's still another opened file
    on that filesystem, with reference to (now freed) vfsmount, etc. and we are
    screwed.
    
    It's not a wide race, but it can be reproduced with artificial slowdown of
    the mnt_get_count() loop, and it should be easier to hit on SMP KVM setups.
    
    Fix consists of moving the refcount decrement under mount_lock; the tricky
    part is that we want (and can) keep the fast case (i.e. mount that still
    has non-NULL ->mnt_ns) entirely out of mount_lock.  All places that zero
    mnt->mnt_ns are dropping some reference to mnt and they call synchronize_rcu()
    before that mntput().  IOW, if mntput() observes (under rcu_read_lock())
    a non-NULL ->mnt_ns, it is guaranteed that there is another reference yet to
    be dropped.
    
    Reported-by: Jann Horn <jannh@google.com>
    Tested-by: Jann Horn <jannh@google.com>
    Fixes: 48a066e72d97 ("RCU'd vsfmounts")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    [bwh: Backported to 3.16: Use ACCESS_ONCE() instead of READ_ONCE()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 074c5dba19b523c02581822f8cace583792d78b3
Author: Alexey Kodanev <alexey.kodanev@oracle.com>
Date:   Tue Aug 7 20:03:57 2018 +0300

    dccp: fix undefined behavior with 'cwnd' shift in ccid2_cwnd_restart()
    
    commit 61ef4b07fcdc30535889990cf4229766502561cf upstream.
    
    The shift of 'cwnd' with '(now - hc->tx_lsndtime) / hc->tx_rto' value
    can lead to undefined behavior [1].
    
    In order to fix this use a gradual shift of the window with a 'while'
    loop, similar to what tcp_cwnd_restart() is doing.
    
    When comparing delta and RTO there is a minor difference between TCP
    and DCCP, the last one also invokes dccp_cwnd_restart() and reduces
    'cwnd' if delta equals RTO. That case is preserved in this change.
    
    [1]:
    [40850.963623] UBSAN: Undefined behaviour in net/dccp/ccids/ccid2.c:237:7
    [40851.043858] shift exponent 67 is too large for 32-bit type 'unsigned int'
    [40851.127163] CPU: 3 PID: 15940 Comm: netstress Tainted: G        W   E     4.18.0-rc7.x86_64 #1
    ...
    [40851.377176] Call Trace:
    [40851.408503]  dump_stack+0xf1/0x17b
    [40851.451331]  ? show_regs_print_info+0x5/0x5
    [40851.503555]  ubsan_epilogue+0x9/0x7c
    [40851.548363]  __ubsan_handle_shift_out_of_bounds+0x25b/0x2b4
    [40851.617109]  ? __ubsan_handle_load_invalid_value+0x18f/0x18f
    [40851.686796]  ? xfrm4_output_finish+0x80/0x80
    [40851.739827]  ? lock_downgrade+0x6d0/0x6d0
    [40851.789744]  ? xfrm4_prepare_output+0x160/0x160
    [40851.845912]  ? ip_queue_xmit+0x810/0x1db0
    [40851.895845]  ? ccid2_hc_tx_packet_sent+0xd36/0x10a0 [dccp]
    [40851.963530]  ccid2_hc_tx_packet_sent+0xd36/0x10a0 [dccp]
    [40852.029063]  dccp_xmit_packet+0x1d3/0x720 [dccp]
    [40852.086254]  dccp_write_xmit+0x116/0x1d0 [dccp]
    [40852.142412]  dccp_sendmsg+0x428/0xb20 [dccp]
    [40852.195454]  ? inet_dccp_listen+0x200/0x200 [dccp]
    [40852.254833]  ? sched_clock+0x5/0x10
    [40852.298508]  ? sched_clock+0x5/0x10
    [40852.342194]  ? inet_create+0xdf0/0xdf0
    [40852.388988]  sock_sendmsg+0xd9/0x160
    ...
    
    Fixes: 113ced1f52e5 ("dccp ccid-2: Perform congestion-window validation")
    Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 89c59d6cd7b6bf71e7a997ef7ab4249f1d3ed27f
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date:   Mon Aug 6 11:06:02 2018 -0700

    vsock: split dwork to avoid reinitializations
    
    commit 455f05ecd2b219e9a216050796d30c830d9bc393 upstream.
    
    syzbot reported that we reinitialize an active delayed
    work in vsock_stream_connect():
    
            ODEBUG: init active (active state 0) object type: timer_list hint:
            delayed_work_timer_fn+0x0/0x90 kernel/workqueue.c:1414
            WARNING: CPU: 1 PID: 11518 at lib/debugobjects.c:329
            debug_print_object+0x16a/0x210 lib/debugobjects.c:326
    
    The pattern is apparently wrong, we should only initialize
    the dealyed work once and could repeatly schedule it. So we
    have to move out the initializations to allocation side.
    And to avoid confusion, we can split the shared dwork
    into two, instead of re-using the same one.
    
    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Reported-by: <syzbot+8a9b1bd330476a4f3db6@syzkaller.appspotmail.com>
    Cc: Andy king <acking@vmware.com>
    Cc: Stefan Hajnoczi <stefanha@redhat.com>
    Cc: Jorgen Hansen <jhansen@vmware.com>
    Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit df30a1f5f12c7689a226f7e10245cce8f37c81dc
Author: Willem de Bruijn <willemb@google.com>
Date:   Mon Aug 6 10:38:34 2018 -0400

    packet: refine ring v3 block size test to hold one frame
    
    commit 4576cd469d980317c4edd9173f8b694aa71ea3a3 upstream.
    
    TPACKET_V3 stores variable length frames in fixed length blocks.
    Blocks must be able to store a block header, optional private space
    and at least one minimum sized frame.
    
    Frames, even for a zero snaplen packet, store metadata headers and
    optional reserved space.
    
    In the block size bounds check, ensure that the frame of the
    chosen configuration fits. This includes sockaddr_ll and optional
    tp_reserve.
    
    Syzbot was able to construct a ring with insuffient room for the
    sockaddr_ll in the header of a zero-length frame, triggering an
    out-of-bounds write in dev_parse_header.
    
    Convert the comparison to less than, as zero is a valid snap len.
    This matches the test for minimum tp_frame_size immediately below.
    
    Fixes: f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation.")
    Fixes: eb73190f4fbe ("net/packet: refine check for priv area size")
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Willem de Bruijn <willemb@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit aa60dca6b21c8328221d824e643b8fe00089d69c
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Aug 6 09:03:58 2018 -0400

    root dentries need RCU-delayed freeing
    
    commit 90bad5e05bcdb0308cfa3d3a60f5c0b9c8e2efb3 upstream.
    
    Since mountpoint crossing can happen without leaving lazy mode,
    root dentries do need the same protection against having their
    memory freed without RCU delay as everything else in the tree.
    
    It's partially hidden by RCU delay between detaching from the
    mount tree and dropping the vfsmount reference, but the starting
    point of pathwalk can be on an already detached mount, in which
    case umount-caused RCU delay has already passed by the time the
    lazy pathwalk grabs rcu_read_lock().  If the starting point
    happens to be at the root of that vfsmount *and* that vfsmount
    covers the entire filesystem, we get trouble.
    
    Fixes: 48a066e72d97 ("RCU'd vsfmounts")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 74749cf4ec01c4b0b40801931985ffd312df77b8
Author: Dmitry Safonov <dima@arista.com>
Date:   Sun Aug 5 01:35:53 2018 +0100

    netlink: Don't shift on 64 for ngroups
    
    commit 91874ecf32e41b5d86a4cb9d60e0bee50d828058 upstream.
    
    It's legal to have 64 groups for netlink_sock.
    
    As user-supplied nladdr->nl_groups is __u32, it's possible to subscribe
    only to first 32 groups.
    
    The check for correctness of .bind() userspace supplied parameter
    is done by applying mask made from ngroups shift. Which broke Android
    as they have 64 groups and the shift for mask resulted in an overflow.
    
    Fixes: 61f4b23769f0 ("netlink: Don't shift with UB on nlk->ngroups")
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: Steffen Klassert <steffen.klassert@secunet.com>
    Cc: netdev@vger.kernel.org
    Reported-and-Tested-by: Nathan Chancellor <natechancellor@gmail.com>
    Signed-off-by: Dmitry Safonov <dima@arista.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ba4072018f125dff8d729bd736e19b5ad11ce072
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Fri Aug 3 17:00:11 2018 +0200

    l2tp: fix missing refcount drop in pppol2tp_tunnel_ioctl()
    
    commit f664e37dcc525768280cb94321424a09beb1c992 upstream.
    
    If 'session' is not NULL and is not a PPP pseudo-wire, then we fail to
    drop the reference taken by l2tp_session_get().
    
    Fixes: ecd012e45ab5 ("l2tp: filter out non-PPP sessions in pppol2tp_tunnel_ioctl()")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: Also call session->deref in both cases]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f5281f836701b95b782804a97baf5e0702bcb6d3
Author: Bart Van Assche <bart.vanassche@wdc.com>
Date:   Thu Aug 2 10:44:42 2018 -0700

    scsi: sr: Avoid that opening a CD-ROM hangs with runtime power management enabled
    
    commit 1214fd7b497400d200e3f4e64e2338b303a20949 upstream.
    
    Surround scsi_execute() calls with scsi_autopm_get_device() and
    scsi_autopm_put_device(). Note: removing sr_mutex protection from the
    scsi_cd_get() and scsi_cd_put() calls is safe because the purpose of
    sr_mutex is to serialize cdrom_*() calls.
    
    This patch avoids that complaints similar to the following appear in the
    kernel log if runtime power management is enabled:
    
    INFO: task systemd-udevd:650 blocked for more than 120 seconds.
         Not tainted 4.18.0-rc7-dbg+ #1
    "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    systemd-udevd   D28176   650    513 0x00000104
    Call Trace:
    __schedule+0x444/0xfe0
    schedule+0x4e/0xe0
    schedule_preempt_disabled+0x18/0x30
    __mutex_lock+0x41c/0xc70
    mutex_lock_nested+0x1b/0x20
    __blkdev_get+0x106/0x970
    blkdev_get+0x22c/0x5a0
    blkdev_open+0xe9/0x100
    do_dentry_open.isra.19+0x33e/0x570
    vfs_open+0x7c/0xd0
    path_openat+0x6e3/0x1120
    do_filp_open+0x11c/0x1c0
    do_sys_open+0x208/0x2d0
    __x64_sys_openat+0x59/0x70
    do_syscall_64+0x77/0x230
    entry_SYSCALL_64_after_hwframe+0x49/0xbe
    
    Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
    Cc: Maurizio Lombardi <mlombard@redhat.com>
    Cc: Johannes Thumshirn <jthumshirn@suse.de>
    Cc: Alan Stern <stern@rowland.harvard.edu>
    Tested-by: Johannes Thumshirn <jthumshirn@suse.de>
    Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    [bwh: Backported to 3.16:
     - Update one extra "goto out" in sr_block_ioctl() and delete the unused
       label
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b9867dc88fc9eb30d522226cda8248a28b0190f6
Author: Anna-Maria Gleixner <anna-maria@linutronix.de>
Date:   Tue Jul 31 18:13:58 2018 +0200

    nohz: Fix local_timer_softirq_pending()
    
    commit 80d20d35af1edd632a5e7a3b9c0ab7ceff92769e upstream.
    
    local_timer_softirq_pending() checks whether the timer softirq is
    pending with: local_softirq_pending() & TIMER_SOFTIRQ.
    
    This is wrong because TIMER_SOFTIRQ is the softirq number and not a
    bitmask. So the test checks for the wrong bit.
    
    Use BIT(TIMER_SOFTIRQ) instead.
    
    Fixes: 5d62c183f9e9 ("nohz: Prevent a timer interrupt storm in tick_nohz_stop_sched_tick()")
    Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Reviewed-by: Daniel Bristot de Oliveira <bristot@redhat.com>
    Acked-by: Frederic Weisbecker <frederic@kernel.org>
    Cc: bigeasy@linutronix.de
    Cc: peterz@infradead.org
    Link: https://lkml.kernel.org/r/20180731161358.29472-1-anna-maria@linutronix.de
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 26772d7a93703ef0458b8b8891f316bd15386bfc
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Mon Jul 30 14:27:15 2018 -0700

    squashfs: more metadata hardening
    
    commit d512584780d3e6a7cacb2f482834849453d444a1 upstream.
    
    Anatoly reports another squashfs fuzzing issue, where the decompression
    parameters themselves are in a compressed block.
    
    This causes squashfs_read_data() to be called in order to read the
    decompression options before the decompression stream having been set
    up, making squashfs go sideways.
    
    Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
    Acked-by: Phillip Lougher <phillip.lougher@gmail.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 853d59debb492d6b5bd9751bdb2e9e0119c137a6
Author: Dmitry Safonov <dima@arista.com>
Date:   Mon Jul 30 18:32:36 2018 +0100

    netlink: Don't shift with UB on nlk->ngroups
    
    commit 61f4b23769f0cc72ae62c9a81cf08f0397d40da8 upstream.
    
    On i386 nlk->ngroups might be 32 or 0. Which leads to UB, resulting in
    hang during boot.
    Check for 0 ngroups and use (unsigned long long) as a type to shift.
    
    Fixes: 7acf9d4237c4 ("netlink: Do not subscribe to non-existent groups").
    Reported-by: kernel test robot <rong.a.chen@intel.com>
    Signed-off-by: Dmitry Safonov <dima@arista.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a7bfa34a431f949e76c460ace85c5357a8c75206
Author: Dmitry Safonov <dima@arista.com>
Date:   Fri Jul 27 16:54:44 2018 +0100

    netlink: Do not subscribe to non-existent groups
    
    commit 7acf9d4237c46894e0fa0492dd96314a41742e84 upstream.
    
    Make ABI more strict about subscribing to group > ngroups.
    Code doesn't check for that and it looks bogus.
    (one can subscribe to non-existing group)
    Still, it's possible to bind() to all possible groups with (-1)
    
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: Steffen Klassert <steffen.klassert@secunet.com>
    Cc: netdev@vger.kernel.org
    Signed-off-by: Dmitry Safonov <dima@arista.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0a620f8d2501f295f4139d75f38b5298bdab4304
Author: Jiang Biao <jiang.biao2@zte.com.cn>
Date:   Wed Jul 18 10:29:28 2018 +0800

    virtio_balloon: fix another race between migration and ballooning
    
    commit 89da619bc18d79bca5304724c11d4ba3b67ce2c6 upstream.
    
    Kernel panic when with high memory pressure, calltrace looks like,
    
    PID: 21439 TASK: ffff881be3afedd0 CPU: 16 COMMAND: "java"
     #0 [ffff881ec7ed7630] machine_kexec at ffffffff81059beb
     #1 [ffff881ec7ed7690] __crash_kexec at ffffffff81105942
     #2 [ffff881ec7ed7760] crash_kexec at ffffffff81105a30
     #3 [ffff881ec7ed7778] oops_end at ffffffff816902c8
     #4 [ffff881ec7ed77a0] no_context at ffffffff8167ff46
     #5 [ffff881ec7ed77f0] __bad_area_nosemaphore at ffffffff8167ffdc
     #6 [ffff881ec7ed7838] __node_set at ffffffff81680300
     #7 [ffff881ec7ed7860] __do_page_fault at ffffffff8169320f
     #8 [ffff881ec7ed78c0] do_page_fault at ffffffff816932b5
     #9 [ffff881ec7ed78f0] page_fault at ffffffff8168f4c8
        [exception RIP: _raw_spin_lock_irqsave+47]
        RIP: ffffffff8168edef RSP: ffff881ec7ed79a8 RFLAGS: 00010046
        RAX: 0000000000000246 RBX: ffffea0019740d00 RCX: ffff881ec7ed7fd8
        RDX: 0000000000020000 RSI: 0000000000000016 RDI: 0000000000000008
        RBP: ffff881ec7ed79a8 R8: 0000000000000246 R9: 000000000001a098
        R10: ffff88107ffda000 R11: 0000000000000000 R12: 0000000000000000
        R13: 0000000000000008 R14: ffff881ec7ed7a80 R15: ffff881be3afedd0
        ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
    
    It happens in the pagefault and results in double pagefault
    during compacting pages when memory allocation fails.
    
    Analysed the vmcore, the page leads to second pagefault is corrupted
    with _mapcount=-256, but private=0.
    
    It's caused by the race between migration and ballooning, and lock
    missing in virtballoon_migratepage() of virtio_balloon driver.
    This patch fix the bug.
    
    Fixes: e22504296d4f64f ("virtio_balloon: introduce migration primitives to balloon pages")
    Signed-off-by: Jiang Biao <jiang.biao2@zte.com.cn>
    Signed-off-by: Huang Chong <huang.chong@zte.com.cn>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0df8731c9960e20531470e101dca0c646497eba3
Author: Anton Vasilyev <vasilyev@ispras.ru>
Date:   Fri Jul 27 18:50:42 2018 +0300

    can: ems_usb: Fix memory leak on ems_usb_disconnect()
    
    commit 72c05f32f4a5055c9c8fe889bb6903ec959c0aad upstream.
    
    ems_usb_probe() allocates memory for dev->tx_msg_buffer, but there
    is no its deallocation in ems_usb_disconnect().
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 85087c2072b50965d89bd29f5a022e7bceffe586
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Jul 29 12:44:46 2018 -0700

    squashfs: be more careful about metadata corruption
    
    commit 01cfb7937a9af2abb1136c7e89fbf3fd92952956 upstream.
    
    Anatoly Trosinenko reports that a corrupted squashfs image can cause a
    kernel oops.  It turns out that squashfs can end up being confused about
    negative fragment lengths.
    
    The regular squashfs_read_data() does check for negative lengths, but
    squashfs_read_metadata() did not, and the fragment size code just
    blindly trusted the on-disk value.  Fix both the fragment parsing and
    the metadata reading code.
    
    Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Phillip Lougher <phillip@squashfs.org.uk>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7c87b7607627ca03b47f98c72e139ad03eb2491c
Author: Jeremy Cline <jcline@redhat.com>
Date:   Fri Jul 27 22:43:01 2018 +0000

    net: socket: fix potential spectre v1 gadget in socketcall
    
    commit c8e8cd579bb4265651df8223730105341e61a2d1 upstream.
    
    'call' is a user-controlled value, so sanitize the array index after the
    bounds check to avoid speculating past the bounds of the 'nargs' array.
    
    Found with the help of Smatch:
    
    net/socket.c:2508 __do_sys_socketcall() warn: potential spectre issue
    'nargs' [r] (local cap)
    
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Signed-off-by: Jeremy Cline <jcline@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2550beed441dc9894ff10e510006acd93e98b6b3
Author: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date:   Fri Jul 27 18:15:46 2018 +0200

    ipv4: remove BUG_ON() from fib_compute_spec_dst
    
    commit 9fc12023d6f51551d6ca9ed7e02ecc19d79caf17 upstream.
    
    Remove BUG_ON() from fib_compute_spec_dst routine and check
    in_dev pointer during flowi4 data structure initialization.
    fib_compute_spec_dst routine can be run concurrently with device removal
    where ip_ptr net_device pointer is set to NULL. This can happen
    if userspace enables pkt info on UDP rx socket and the device
    is removed while traffic is flowing
    
    Fixes: 35ebf65e851c ("ipv4: Create and use fib_compute_spec_dst() helper")
    Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 47775c787614269e0e6e6d9d39d773ef65e324d0
Author: Snild Dolkow <snild@sony.com>
Date:   Thu Jul 26 09:15:39 2018 +0200

    kthread, tracing: Don't expose half-written comm when creating kthreads
    
    commit 3e536e222f2930534c252c1cc7ae799c725c5ff9 upstream.
    
    There is a window for racing when printing directly to task->comm,
    allowing other threads to see a non-terminated string. The vsnprintf
    function fills the buffer, counts the truncated chars, then finally
    writes the \0 at the end.
    
            creator                     other
            vsnprintf:
              fill (not terminated)
              count the rest            trace_sched_waking(p):
              ...                         memcpy(comm, p->comm, TASK_COMM_LEN)
              write \0
    
    The consequences depend on how 'other' uses the string. In our case,
    it was copied into the tracing system's saved cmdlines, a buffer of
    adjacent TASK_COMM_LEN-byte buffers (note the 'n' where 0 should be):
    
            crash-arm64> x/1024s savedcmd->saved_cmdlines | grep 'evenk'
            0xffffffd5b3818640:     "irq/497-pwr_evenkworker/u16:12"
    
    ...and a strcpy out of there would cause stack corruption:
    
            [224761.522292] Kernel panic - not syncing: stack-protector:
                Kernel stack is corrupted in: ffffff9bf9783c78
    
            crash-arm64> kbt | grep 'comm\|trace_print_context'
            #6  0xffffff9bf9783c78 in trace_print_context+0x18c(+396)
                  comm (char [16]) =  "irq/497-pwr_even"
    
            crash-arm64> rd 0xffffffd4d0e17d14 8
            ffffffd4d0e17d14:  2f71726900000000 5f7277702d373934   ....irq/497-pwr_
            ffffffd4d0e17d24:  726f776b6e657665 3a3631752f72656b   evenkworker/u16:
            ffffffd4d0e17d34:  f9780248ff003231 cede60e0ffffff9b   12..H.x......`..
            ffffffd4d0e17d44:  cede60c8ffffffd4 00000fffffffffd4   .....`..........
    
    The workaround in e09e28671 (use strlcpy in __trace_find_cmdline) was
    likely needed because of this same bug.
    
    Solved by vsnprintf:ing to a local buffer, then using set_task_comm().
    This way, there won't be a window where comm is not terminated.
    
    Link: http://lkml.kernel.org/r/20180726071539.188015-1-snild@sony.com
    
    Fixes: bc0c38d139ec7 ("ftrace: latency tracer infrastructure")
    Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Snild Dolkow <snild@sony.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9f6f9db5c98642ab70098d08e87f106fff5deb78
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Wed Jul 25 22:28:56 2018 -0400

    tracing: Quiet gcc warning about maybe unused link variable
    
    commit 2519c1bbe38d7acacc9aacba303ca6f97482ed53 upstream.
    
    Commit 57ea2a34adf4 ("tracing/kprobes: Fix trace_probe flags on
    enable_trace_kprobe() failure") added an if statement that depends on another
    if statement that gcc doesn't see will initialize the "link" variable and
    gives the warning:
    
     "warning: 'link' may be used uninitialized in this function"
    
    It is really a false positive, but to quiet the warning, and also to make
    sure that it never actually is used uninitialized, initialize the "link"
    variable to NULL and add an if (!WARN_ON_ONCE(!link)) where the compiler
    thinks it could be used uninitialized.
    
    Fixes: 57ea2a34adf4 ("tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure")
    Reported-by: kbuild test robot <lkp@intel.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 23b5d9e43e4ad9d634b9d6628ca225458d7cb7fd
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Wed Jul 25 16:02:06 2018 -0400

    tracing: Fix possible double free in event_enable_trigger_func()
    
    commit 15cc78644d0075e76d59476a4467e7143860f660 upstream.
    
    There was a case that triggered a double free in event_trigger_callback()
    due to the called reg() function freeing the trigger_data and then it
    getting freed again by the error return by the caller. The solution there
    was to up the trigger_data ref count.
    
    Code inspection found that event_enable_trigger_func() has the same issue,
    but is not as easy to trigger (requires harder to trigger failures). It
    needs to be solved slightly different as it needs more to clean up when the
    reg() function fails.
    
    Link: http://lkml.kernel.org/r/20180725124008.7008e586@gandalf.local.home
    
    Fixes: 7862ad1846e99 ("tracing: Add 'enable_event' and 'disable_event' event trigger commands")
    Reivewed-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3c7ac123f97ce3bdb23cb777aa0ac21e1bba1317
Author: Artem Savkov <asavkov@redhat.com>
Date:   Wed Jul 25 16:20:38 2018 +0200

    tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
    
    commit 57ea2a34adf40f3a6e88409aafcf803b8945619a upstream.
    
    If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe
    it returns an error, but does not unset the tp flags it set previously.
    This results in a probe being considered enabled and failures like being
    unable to remove the probe through kprobe_events file since probes_open()
    expects every probe to be disabled.
    
    Link: http://lkml.kernel.org/r/20180725102826.8300-1-asavkov@redhat.com
    Link: http://lkml.kernel.org/r/20180725142038.4765-1-asavkov@redhat.com
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Fixes: 41a7dd420c57 ("tracing/kprobes: Support ftrace_event_file base multibuffer")
    Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
    Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Signed-off-by: Artem Savkov <asavkov@redhat.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1535bebc3767d4799f7727a300642e47460ac9bb
Author: Masami Hiramatsu <mhiramat@kernel.org>
Date:   Sat Jul 14 01:28:15 2018 +0900

    ring_buffer: tracing: Inherit the tracing setting to next ring buffer
    
    commit 73c8d8945505acdcbae137c2e00a1232e0be709f upstream.
    
    Maintain the tracing on/off setting of the ring_buffer when switching
    to the trace buffer snapshot.
    
    Taking a snapshot is done by swapping the backup ring buffer
    (max_tr_buffer). But since the tracing on/off setting is defined
    by the ring buffer, when swapping it, the tracing on/off setting
    can also be changed. This causes a strange result like below:
    
      /sys/kernel/debug/tracing # cat tracing_on
      1
      /sys/kernel/debug/tracing # echo 0 > tracing_on
      /sys/kernel/debug/tracing # cat tracing_on
      0
      /sys/kernel/debug/tracing # echo 1 > snapshot
      /sys/kernel/debug/tracing # cat tracing_on
      1
      /sys/kernel/debug/tracing # echo 1 > snapshot
      /sys/kernel/debug/tracing # cat tracing_on
      0
    
    We don't touch tracing_on, but snapshot changes tracing_on
    setting each time. This is an anomaly, because user doesn't know
    that each "ring_buffer" stores its own tracing-enable state and
    the snapshot is done by swapping ring buffers.
    
    Link: http://lkml.kernel.org/r/153149929558.11274.11730609978254724394.stgit@devbox
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
    Cc: Hiraku Toyooka <hiraku.toyooka@cybertrust.co.jp>
    Fixes: debdd57f5145 ("tracing: Make a snapshot feature available from userspace")
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
    [ Updated commit log and comment in the code ]
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 282dc3764d8953b59c7527a214525034102521e9
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Tue Jul 24 19:13:31 2018 -0400

    tracing: Fix double free of event_trigger_data
    
    commit 1863c387259b629e4ebfb255495f67cd06aa229b upstream.
    
    Running the following:
    
     # cd /sys/kernel/debug/tracing
     # echo 500000 > buffer_size_kb
    [ Or some other number that takes up most of memory ]
     # echo snapshot > events/sched/sched_switch/trigger
    
    Triggers the following bug:
    
     ------------[ cut here ]------------
     kernel BUG at mm/slub.c:296!
     invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC PTI
     CPU: 6 PID: 6878 Comm: bash Not tainted 4.18.0-rc6-test+ #1066
     Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
     RIP: 0010:kfree+0x16c/0x180
     Code: 05 41 0f b6 72 51 5b 5d 41 5c 4c 89 d7 e9 ac b3 f8 ff 48 89 d9 48 89 da 41 b8 01 00 00 00 5b 5d 41 5c 4c 89 d6 e9 f4 f3 ff ff <0f> 0b 0f 0b 48 8b 3d d9 d8 f9 00 e9 c1 fe ff ff 0f 1f 40 00 0f 1f
     RSP: 0018:ffffb654436d3d88 EFLAGS: 00010246
     RAX: ffff91a9d50f3d80 RBX: ffff91a9d50f3d80 RCX: ffff91a9d50f3d80
     RDX: 00000000000006a4 RSI: ffff91a9de5a60e0 RDI: ffff91a9d9803500
     RBP: ffffffff8d267c80 R08: 00000000000260e0 R09: ffffffff8c1a56be
     R10: fffff0d404543cc0 R11: 0000000000000389 R12: ffffffff8c1a56be
     R13: ffff91a9d9930e18 R14: ffff91a98c0c2890 R15: ffffffff8d267d00
     FS:  00007f363ea64700(0000) GS:ffff91a9de580000(0000) knlGS:0000000000000000
     CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
     CR2: 000055c1cacc8e10 CR3: 00000000d9b46003 CR4: 00000000001606e0
     Call Trace:
      event_trigger_callback+0xee/0x1d0
      event_trigger_write+0xfc/0x1a0
      __vfs_write+0x33/0x190
      ? handle_mm_fault+0x115/0x230
      ? _cond_resched+0x16/0x40
      vfs_write+0xb0/0x190
      ksys_write+0x52/0xc0
      do_syscall_64+0x5a/0x160
      entry_SYSCALL_64_after_hwframe+0x49/0xbe
     RIP: 0033:0x7f363e16ab50
     Code: 73 01 c3 48 8b 0d 38 83 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 79 db 2c 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 1e e3 01 00 48 89 04 24
     RSP: 002b:00007fff9a4c6378 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
     RAX: ffffffffffffffda RBX: 0000000000000009 RCX: 00007f363e16ab50
     RDX: 0000000000000009 RSI: 000055c1cacc8e10 RDI: 0000000000000001
     RBP: 000055c1cacc8e10 R08: 00007f363e435740 R09: 00007f363ea64700
     R10: 0000000000000073 R11: 0000000000000246 R12: 0000000000000009
     R13: 0000000000000001 R14: 00007f363e4345e0 R15: 00007f363e4303c0
     Modules linked in: ip6table_filter ip6_tables snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_seq snd_seq_device i915 snd_pcm snd_timer i2c_i801 snd soundcore i2c_algo_bit drm_kms_helper
    86_pkg_temp_thermal video kvm_intel kvm irqbypass wmi e1000e
     ---[ end trace d301afa879ddfa25 ]---
    
    The cause is because the register_snapshot_trigger() call failed to
    allocate the snapshot buffer, and then called unregister_trigger()
    which freed the data that was passed to it. Then on return to the
    function that called register_snapshot_trigger(), as it sees it
    failed to register, it frees the trigger_data again and causes
    a double free.
    
    By calling event_trigger_init() on the trigger_data (which only ups
    the reference counter for it), and then event_trigger_free() afterward,
    the trigger_data would not get freed by the registering trigger function
    as it would only up and lower the ref count for it. If the register
    trigger function fails, then the event_trigger_free() called after it
    will free the trigger data normally.
    
    Link: http://lkml.kernel.org/r/20180724191331.738eb819@gandalf.local.home
    
    Cc: stable@vger.kerne.org
    Fixes: 93e31ffbf417 ("tracing: Add 'snapshot' event trigger command")
    Reported-by: Masami Hiramatsu <mhiramat@kernel.org>
    Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b1f5b8b5e8bd36e83a0def7843f9d4da95652051
Author: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
Date:   Thu Jun 21 13:25:53 2018 -0700

    cachefiles: Wait rather than BUG'ing on "Unexpected object collision"
    
    commit c2412ac45a8f8f1cd582723c1a139608694d410d upstream.
    
    If we meet a conflicting object that is marked FSCACHE_OBJECT_IS_LIVE in
    the active object tree, we have been emitting a BUG after logging
    information about it and the new object.
    
    Instead, we should wait for the CACHEFILES_OBJECT_ACTIVE flag to be cleared
    on the old object (or return an error).  The ACTIVE flag should be cleared
    after it has been removed from the active object tree.  A timeout of 60s is
    used in the wait, so we shouldn't be able to get stuck there.
    
    Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem")
    Signed-off-by: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d5c40366eaa95f4bfc521be52554aee8ac911035
Author: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
Date:   Thu Jun 21 13:25:53 2018 -0700

    cachefiles: Fix missing clear of the CACHEFILES_OBJECT_ACTIVE flag
    
    commit 5ce83d4bb7d8e11e8c1c687d09f4b5ae67ef3ce3 upstream.
    
    In cachefiles_mark_object_active(), the new object is marked active and
    then we try to add it to the active object tree.  If a conflicting object
    is already present, we want to wait for that to go away.  After the wait,
    we go round again and try to re-mark the object as being active - but it's
    already marked active from the first time we went through and a BUG is
    issued.
    
    Fix this by clearing the CACHEFILES_OBJECT_ACTIVE flag before we try again.
    
    Analysis from Kiran Kumar Modukuri:
    
    [Impact]
    Oops during heavy NFS + FSCache + Cachefiles
    
    CacheFiles: Error: Overlong wait for old active object to go away.
    
    BUG: unable to handle kernel NULL pointer dereference at 0000000000000002
    
    CacheFiles: Error: Object already active kernel BUG at
    fs/cachefiles/namei.c:163!
    
    [Cause]
    In a heavily loaded system with big files being read and truncated, an
    fscache object for a cookie is being dropped and a new object being
    looked. The new object being looked for has to wait for the old object
    to go away before the new object is moved to active state.
    
    [Fix]
    Clear the flag 'CACHEFILES_OBJECT_ACTIVE' for the new object when
    retrying the object lookup.
    
    [Testcase]
    Have run ~100 hours of NFS stress tests and have not seen this bug recur.
    
    [Regression Potential]
     - Limited to fscache/cachefiles.
    
    Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem")
    Signed-off-by: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 02bd6bec37caffece87cd44e9e42c6d4dae394ec
Author: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
Date:   Thu Jun 21 13:31:44 2018 -0700

    fscache: Fix reference overput in fscache_attach_object() error handling
    
    commit f29507ce66701084c39aeb1b0ae71690cbff3554 upstream.
    
    When a cookie is allocated that causes fscache_object structs to be
    allocated, those objects are initialised with the cookie pointer, but
    aren't blessed with a ref on that cookie unless the attachment is
    successfully completed in fscache_attach_object().
    
    If attachment fails because the parent object was dying or there was a
    collision, fscache_attach_object() returns without incrementing the cookie
    counter - but upon failure of this function, the object is released which
    then puts the cookie, whether or not a ref was taken on the cookie.
    
    Fix this by taking a ref on the cookie when it is assigned in
    fscache_object_init(), even when we're creating a root object.
    
    
    Analysis from Kiran Kumar:
    
    This bug has been seen in 4.4.0-124-generic #148-Ubuntu kernel
    
    BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1776277
    
    fscache cookie ref count updated incorrectly during fscache object
    allocation resulting in following Oops.
    
    kernel BUG at /build/linux-Y09MKI/linux-4.4.0/fs/fscache/internal.h:321!
    kernel BUG at /build/linux-Y09MKI/linux-4.4.0/fs/fscache/cookie.c:639!
    
    [Cause]
    Two threads are trying to do operate on a cookie and two objects.
    
    (1) One thread tries to unmount the filesystem and in process goes over a
        huge list of objects marking them dead and deleting the objects.
        cookie->usage is also decremented in following path:
    
          nfs_fscache_release_super_cookie
           -> __fscache_relinquish_cookie
            ->__fscache_cookie_put
            ->BUG_ON(atomic_read(&cookie->usage) <= 0);
    
    (2) A second thread tries to lookup an object for reading data in following
        path:
    
        fscache_alloc_object
        1) cachefiles_alloc_object
            -> fscache_object_init
               -> assign cookie, but usage not bumped.
        2) fscache_attach_object -> fails in cant_attach_object because the
             cookie's backing object or cookie's->parent object are going away
        3) fscache_put_object
            -> cachefiles_put_object
              ->fscache_object_destroy
                ->fscache_cookie_put
                   ->BUG_ON(atomic_read(&cookie->usage) <= 0);
    
    [NOTE from dhowells] It's unclear as to the circumstances in which (2) can
    take place, given that thread (1) is in nfs_kill_super(), however a
    conflicting NFS mount with slightly different parameters that creates a
    different superblock would do it.  A backtrace from Kiran seems to show
    that this is a possibility:
    
        kernel BUG at/build/linux-Y09MKI/linux-4.4.0/fs/fscache/cookie.c:639!
        ...
        RIP: __fscache_cookie_put+0x3a/0x40 [fscache]
        Call Trace:
         __fscache_relinquish_cookie+0x87/0x120 [fscache]
         nfs_fscache_release_super_cookie+0x2d/0xb0 [nfs]
         nfs_kill_super+0x29/0x40 [nfs]
         deactivate_locked_super+0x48/0x80
         deactivate_super+0x5c/0x60
         cleanup_mnt+0x3f/0x90
         __cleanup_mnt+0x12/0x20
         task_work_run+0x86/0xb0
         exit_to_usermode_loop+0xc2/0xd0
         syscall_return_slowpath+0x4e/0x60
         int_ret_from_sys_call+0x25/0x9f
    
    [Fix] Bump up the cookie usage in fscache_object_init, when it is first
    being assigned a cookie atomically such that the cookie is added and bumped
    up if its refcount is not zero.  Remove the assignment in
    fscache_attach_object().
    
    [Testcase]
    I have run ~100 hours of NFS stress tests and not seen this bug recur.
    
    [Regression Potential]
     - Limited to fscache/cachefiles.
    
    Fixes: ccc4fc3d11e9 ("FS-Cache: Implement the cookie management part of the netfs API")
    Signed-off-by: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    [bwh: Backported to 3.16: Keep using atomic_inc() instead of
     fscache_cookie_get()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7572f53e24e65260c949a6a7495bd562ef013d77
Author: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
Date:   Tue Jul 18 16:25:49 2017 -0700

    cachefiles: Fix refcounting bug in backing-file read monitoring
    
    commit 934140ab028713a61de8bca58c05332416d037d1 upstream.
    
    cachefiles_read_waiter() has the right to access a 'monitor' object by
    virtue of being called under the waitqueue lock for one of the pages in its
    purview.  However, it has no ref on that monitor object or on the
    associated operation.
    
    What it is allowed to do is to move the monitor object to the operation's
    to_do list, but once it drops the work_lock, it's actually no longer
    permitted to access that object.  However, it is trying to enqueue the
    retrieval operation for processing - but it can only do this via a pointer
    in the monitor object, something it shouldn't be doing.
    
    If it doesn't enqueue the operation, the operation may not get processed.
    If the order is flipped so that the enqueue is first, then it's possible
    for the work processor to look at the to_do list before the monitor is
    enqueued upon it.
    
    Fix this by getting a ref on the operation so that we can trust that it
    will still be there once we've added the monitor to the to_do list and
    dropped the work_lock.  The op can then be enqueued after the lock is
    dropped.
    
    The bug can manifest in one of a couple of ways.  The first manifestation
    looks like:
    
     FS-Cache:
     FS-Cache: Assertion failed
     FS-Cache: 6 == 5 is false
     ------------[ cut here ]------------
     kernel BUG at fs/fscache/operation.c:494!
     RIP: 0010:fscache_put_operation+0x1e3/0x1f0
     ...
     fscache_op_work_func+0x26/0x50
     process_one_work+0x131/0x290
     worker_thread+0x45/0x360
     kthread+0xf8/0x130
     ? create_worker+0x190/0x190
     ? kthread_cancel_work_sync+0x10/0x10
     ret_from_fork+0x1f/0x30
    
    This is due to the operation being in the DEAD state (6) rather than
    INITIALISED, COMPLETE or CANCELLED (5) because it's already passed through
    fscache_put_operation().
    
    The bug can also manifest like the following:
    
     kernel BUG at fs/fscache/operation.c:69!
     ...
        [exception RIP: fscache_enqueue_operation+246]
     ...
     #7 [ffff883fff083c10] fscache_enqueue_operation at ffffffffa0b793c6
     #8 [ffff883fff083c28] cachefiles_read_waiter at ffffffffa0b15a48
     #9 [ffff883fff083c48] __wake_up_common at ffffffff810af028
    
    I'm not entirely certain as to which is line 69 in Lei's kernel, so I'm not
    entirely clear which assertion failed.
    
    Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem")
    Reported-by: Lei Xue <carmark.dlut@gmail.com>
    Reported-by: Vegard Nossum <vegard.nossum@gmail.com>
    Reported-by: Anthony DeRobertis <aderobertis@metrics.net>
    Reported-by: NeilBrown <neilb@suse.com>
    Reported-by: Daniel Axtens <dja@axtens.net>
    Reported-by: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reviewed-by: Daniel Axtens <dja@axtens.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7f72cb725cc87fed90d7f468e47c9d1449e4f59d
Author: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
Date:   Wed Jul 25 14:31:20 2018 +0100

    fscache: Allow cancelled operations to be enqueued
    
    commit d0eb06afe712b7b103b6361f40a9a0c638524669 upstream.
    
    Alter the state-check assertion in fscache_enqueue_operation() to allow
    cancelled operations to be given processing time so they can be cleaned up.
    
    Also fix a debugging statement that was requiring such operations to have
    an object assigned.
    
    Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem")
    Reported-by: Kiran Kumar Modukuri <kiran.modukuri@gmail.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7b1bcbf91a24f21f2d9c54a1812337471d819896
Author: Jack Morgenstein <jackm@dev.mellanox.co.il>
Date:   Tue Jul 24 14:27:55 2018 +0300

    net/mlx4_core: Save the qpn from the input modifier in RST2INIT wrapper
    
    commit 958c696f5a7274d9447a458ad7aa70719b29a50a upstream.
    
    Function mlx4_RST2INIT_QP_wrapper saved the qp number passed in the qp
    context, rather than the one passed in the input modifier.
    
    However, the qp number in the qp context is not defined as a
    required parameter by the FW. Therefore, drivers may choose to not
    specify the qp number in the qp context for the reset-to-init transition.
    
    Thus, we must save the qp number passed in the command input modifier --
    which is always present. (This saved qp number is used as the input
    modifier for command 2RST_QP when a slave's qp's are destroyed).
    
    Fixes: c82e9aa0a8bc ("mlx4_core: resource tracking for HCA resources used by guests")
    Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
    Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f5437a2262a164b5fab4de29f3d38c15cd1ebad3
Author: Anssi Hannula <anssi.hannula@bitwise.fi>
Date:   Mon Feb 26 14:39:59 2018 +0200

    can: xilinx_can: fix incorrect clear of non-processed interrupts
    
    commit 2f4f0f338cf453bfcdbcf089e177c16f35f023c8 upstream.
    
    xcan_interrupt() clears ERROR|RXOFLV|BSOFF|ARBLST interrupts if any of
    them is asserted. This does not take into account that some of them
    could have been asserted between interrupt status read and interrupt
    clear, therefore clearing them without handling them.
    
    Fix the code to only clear those interrupts that it knows are asserted
    and therefore going to be processed in xcan_err_interrupt().
    
    Fixes: b1201e44f50b ("can: xilinx CAN controller support")
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Cc: Michal Simek <michal.simek@xilinx.com>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f51771e322b96dd8fdcdfcc9314e7cd2f9eebf94
Author: Anssi Hannula <anssi.hannula@bitwise.fi>
Date:   Mon Feb 26 14:27:13 2018 +0200

    can: xilinx_can: fix RX overflow interrupt not being enabled
    
    commit 83997997252f5d3fc7f04abc24a89600c2b504ab upstream.
    
    RX overflow interrupt (RXOFLW) is disabled even though xcan_interrupt()
    processes it. This means that an RX overflow interrupt will only be
    processed when another interrupt gets asserted (e.g. for RX/TX).
    
    Fix that by enabling the RXOFLW interrupt.
    
    Fixes: b1201e44f50b ("can: xilinx CAN controller support")
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Cc: Michal Simek <michal.simek@xilinx.com>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5a2565c48ca547b373d7574069fc5ed5c9bbf8b4
Author: Anssi Hannula <anssi.hannula@bitwise.fi>
Date:   Thu Feb 23 14:50:03 2017 +0200

    can: xilinx_can: keep only 1-2 frames in TX FIFO to fix TX accounting
    
    commit 620050d9c2be15c47017ba95efe59e0832e99a56 upstream.
    
    The xilinx_can driver assumes that the TXOK interrupt only clears after
    it has been acknowledged as many times as there have been successfully
    sent frames.
    
    However, the documentation does not mention such behavior, instead
    saying just that the interrupt is cleared when the clear bit is set.
    
    Similarly, testing seems to also suggest that it is immediately cleared
    regardless of the amount of frames having been sent. Performing some
    heavy TX load and then going back to idle has the tx_head drifting
    further away from tx_tail over time, steadily reducing the amount of
    frames the driver keeps in the TX FIFO (but not to zero, as the TXOK
    interrupt always frees up space for 1 frame from the driver's
    perspective, so frames continue to be sent) and delaying the local echo
    frames.
    
    The TX FIFO tracking is also otherwise buggy as it does not account for
    TX FIFO being cleared after software resets, causing
      BUG!, TX FIFO full when queue awake!
    messages to be output.
    
    There does not seem to be any way to accurately track the state of the
    TX FIFO for local echo support while using the full TX FIFO.
    
    The Zynq version of the HW (but not the soft-AXI version) has watermark
    programming support and with it an additional TX-FIFO-empty interrupt
    bit.
    
    Modify the driver to only put 1 frame into TX FIFO at a time on soft-AXI
    and 2 frames at a time on Zynq. On Zynq the TXFEMP interrupt bit is used
    to detect whether 1 or 2 frames have been sent at interrupt processing
    time.
    
    Tested with the integrated CAN on Zynq-7000 SoC. The 1-frame-FIFO mode
    was also tested.
    
    An alternative way to solve this would be to drop local echo support but
    keep using the full TX FIFO.
    
    v2: Add FIFO space check before TX queue wake with locking to
    synchronize with queue stop. This avoids waking the queue when xmit()
    had just filled it.
    
    v3: Keep local echo support and reduce the amount of frames in FIFO
    instead as suggested by Marc Kleine-Budde.
    
    Fixes: b1201e44f50b ("can: xilinx CAN controller support")
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fe2d9180e1448f311660cae251bf29dc34b9a60b
Author: Anssi Hannula <anssi.hannula@bitwise.fi>
Date:   Wed Feb 8 13:13:40 2017 +0200

    can: xilinx_can: fix recovery from error states not being propagated
    
    commit 877e0b75947e2c7acf5624331bb17ceb093c98ae upstream.
    
    The xilinx_can driver contains no mechanism for propagating recovery
    from CAN_STATE_ERROR_WARNING and CAN_STATE_ERROR_PASSIVE.
    
    Add such a mechanism by factoring the handling of
    XCAN_STATE_ERROR_PASSIVE and XCAN_STATE_ERROR_WARNING out of
    xcan_err_interrupt and checking for recovery after RX and TX if the
    interface is in one of those states.
    
    Tested with the integrated CAN on Zynq-7000 SoC.
    
    Fixes: b1201e44f50b ("can: xilinx CAN controller support")
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0e40f0d74a46b1f67f0aa43e9cab7dd6cdf04a3a
Author: Anssi Hannula <anssi.hannula@bitwise.fi>
Date:   Tue Feb 7 17:01:14 2017 +0200

    can: xilinx_can: fix RX loop if RXNEMP is asserted without RXOK
    
    commit 32852c561bffd613d4ed7ec464b1e03e1b7b6c5c upstream.
    
    If the device gets into a state where RXNEMP (RX FIFO not empty)
    interrupt is asserted without RXOK (new frame received successfully)
    interrupt being asserted, xcan_rx_poll() will continue to try to clear
    RXNEMP without actually reading frames from RX FIFO. If the RX FIFO is
    not empty, the interrupt will not be cleared and napi_schedule() will
    just be called again.
    
    This situation can occur when:
    
    (a) xcan_rx() returns without reading RX FIFO due to an error condition.
    The code tries to clear both RXOK and RXNEMP but RXNEMP will not clear
    due to a frame still being in the FIFO. The frame will never be read
    from the FIFO as RXOK is no longer set.
    
    (b) A frame is received between xcan_rx_poll() reading interrupt status
    and clearing RXOK. RXOK will be cleared, but RXNEMP will again remain
    set as the new message is still in the FIFO.
    
    I'm able to trigger case (b) by flooding the bus with frames under load.
    
    There does not seem to be any benefit in using both RXNEMP and RXOK in
    the way the driver does, and the polling example in the reference manual
    (UG585 v1.10 18.3.7 Read Messages from RxFIFO) also says that either
    RXOK or RXNEMP can be used for detecting incoming messages.
    
    Fix the issue and simplify the RX processing by only using RXNEMP
    without RXOK.
    
    Tested with the integrated CAN on Zynq-7000 SoC.
    
    Fixes: b1201e44f50b ("can: xilinx CAN controller support")
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bd13da7bf306a8f7f085f93f0b58ecf58f8b32d7
Author: Anssi Hannula <anssi.hannula@bitwise.fi>
Date:   Tue Feb 7 13:23:04 2017 +0200

    can: xilinx_can: fix device dropping off bus on RX overrun
    
    commit 2574fe54515ed3487405de329e4e9f13d7098c10 upstream.
    
    The xilinx_can driver performs a software reset when an RX overrun is
    detected. This causes the device to enter Configuration mode where no
    messages are received or transmitted.
    
    The documentation does not mention any need to perform a reset on an RX
    overrun, and testing by inducing an RX overflow also indicated that the
    device continues to work just fine without a reset.
    
    Remove the software reset.
    
    Tested with the integrated CAN on Zynq-7000 SoC.
    
    Fixes: b1201e44f50b ("can: xilinx CAN controller support")
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 68010e8cb63aade281151fd3dd3d0367b52957f1
Author: Andri Yngvason <andri.yngvason@marel.com>
Date:   Wed Dec 3 17:54:13 2014 +0000

    can: dev: Consolidate and unify state change handling
    
    commit bac78aabcfece0c493b2ad824c68fbdc20448cbc upstream.
    
    The handling of can error states is different between platforms.
    This is an attempt to correct that problem.
    
    I've moved this handling into a generic function for changing the
    error state. This ensures that error state changes are handled
    the same way everywhere (where this function is used).
    
    This new mechanism also adds reverse state transitioning in error
    frames, i.e. the user will be notified through the socket interface
    when the state goes down.
    
    Signed-off-by: Andri Yngvason <andri.yngvason@marel.com>
    Acked-by: Wolfgang Grandegger <wg@grandegger.com>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 38c76fc7a5f338bb65565dd8cca86d3776828644
Author: Nicholas Mc Guire <hofrat@osadl.org>
Date:   Mon Jul 9 21:16:40 2018 +0200

    can: mpc5xxx_can: check of_iomap return before use
    
    commit b5c1a23b17e563b656cc9bb76ce5323b997d90e8 upstream.
    
    of_iomap() can return NULL so that return needs to be checked and NULL
    treated as failure. While at it also take care of the missing
    of_node_put() in the error path.
    
    Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
    Fixes: commit afa17a500a36 ("net/can: add driver for mscan family & mpc52xx_mscan")
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b44a55b9526c75b181b5b6389fbbb9c01cc0828e
Author: Fabian Frederick <fabf@skynet.be>
Date:   Tue Mar 17 19:40:24 2015 +0100

    can: constify of_device_id array
    
    commit 486e957033623656298a07c39a8bf2fd81db285b upstream.
    
    of_device_id is always used as const.
    (See driver.of_match_table and open firmware functions)
    
    Signed-off-by: Fabian Frederick <fabf@skynet.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d3763e2d4fc365a437d99865ff55eab64024819c
Author: Florian Westphal <fw@strlen.de>
Date:   Fri Jul 20 19:30:57 2018 +0200

    atl1c: reserve min skb headroom
    
    commit 6e56830776828d8ca9897fc4429eeab47c3bb432 upstream.
    
    Got crash report with following backtrace:
    BUG: unable to handle kernel paging request at ffff8801869daffe
    RIP: 0010:[<ffffffff816429c4>]  [<ffffffff816429c4>] ip6_finish_output2+0x394/0x4c0
    RSP: 0018:ffff880186c83a98  EFLAGS: 00010283
    RAX: ffff8801869db00e ...
      [<ffffffff81644cdc>] ip6_finish_output+0x8c/0xf0
      [<ffffffff81644d97>] ip6_output+0x57/0x100
      [<ffffffff81643dc9>] ip6_forward+0x4b9/0x840
      [<ffffffff81645566>] ip6_rcv_finish+0x66/0xc0
      [<ffffffff81645db9>] ipv6_rcv+0x319/0x530
      [<ffffffff815892ac>] netif_receive_skb+0x1c/0x70
      [<ffffffffc0060bec>] atl1c_clean+0x1ec/0x310 [atl1c]
      ...
    
    The bad access is in neigh_hh_output(), at skb->data - 16 (HH_DATA_MOD).
    atl1c driver provided skb with no headroom, so 14 bytes (ethernet
    header) got pulled, but then 16 are copied.
    
    Reserve NET_SKB_PAD bytes headroom, like netdev_alloc_skb().
    
    Compile tested only; I lack hardware.
    
    Fixes: 7b7017642199 ("atl1c: Fix misuse of netdev_alloc_skb in refilling rx ring")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 841092b44ffdb5c82e71ec2c4c7507a53b52220b
Author: Hangbin Liu <liuhangbin@gmail.com>
Date:   Fri Jul 20 14:04:27 2018 +0800

    multicast: do not restore deleted record source filter mode to new one
    
    commit 08d3ffcc0cfaba36f6b86fd568cc3bc773061fa6 upstream.
    
    There are two scenarios that we will restore deleted records. The first is
    when device down and up(or unmap/remap). In this scenario the new filter
    mode is same with previous one. Because we get it from in_dev->mc_list and
    we do not touch it during device down and up.
    
    The other scenario is when a new socket join a group which was just delete
    and not finish sending status reports. In this scenario, we should use the
    current filter mode instead of restore old one. Here are 4 cases in total.
    
    old_socket        new_socket       before_fix       after_fix
      IN(A)             IN(A)           ALLOW(A)         ALLOW(A)
      IN(A)             EX( )           TO_IN( )         TO_EX( )
      EX( )             IN(A)           TO_EX( )         ALLOW(A)
      EX( )             EX( )           TO_EX( )         TO_EX( )
    
    Fixes: 24803f38a5c0b (igmp: do not remove igmp souce list info when set link down)
    Fixes: 1666d49e1d416 (mld: do not remove mld souce list info when set link down)
    Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7113a9af08c596c62e819857c9f9a39f7de0403e
Author: YueHaibing <yuehaibing@huawei.com>
Date:   Thu Jul 19 10:27:13 2018 +0800

    net: caif: Add a missing rcu_read_unlock() in caif_flow_cb
    
    commit 64119e05f7b31e83e2555f6782e6cdc8f81c63f4 upstream.
    
    Add a missing rcu_read_unlock in the error path
    
    Fixes: c95567c80352 ("caif: added check for potential null return")
    Signed-off-by: YueHaibing <yuehaibing@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6dfc16f3e123dbde67078f75effb6999515ab196
Author: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Date:   Fri Jul 20 17:53:42 2018 -0700

    fat: fix memory allocation failure handling of match_strdup()
    
    commit 35033ab988c396ad7bce3b6d24060c16a9066db8 upstream.
    
    In parse_options(), if match_strdup() failed, parse_options() leaves
    opts->iocharset in unexpected state (i.e.  still pointing the freed
    string).  And this can be the cause of double free.
    
    To fix, this initialize opts->iocharset always when freeing.
    
    Link: http://lkml.kernel.org/r/8736wp9dzc.fsf@mail.parknet.co.jp
    Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
    Reported-by: syzbot+90b8e10515ae88228a92@syzkaller.appspotmail.com
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7543d5f59043f2b11272e0e9b5570cdb00c9c712
Author: Bin Liu <b-liu@ti.com>
Date:   Thu Jul 19 14:39:37 2018 -0500

    usb: core: handle hub C_PORT_OVER_CURRENT condition
    
    commit 249a32b7eeb3edb6897dd38f89651a62163ac4ed upstream.
    
    Based on USB2.0 Spec Section 11.12.5,
    
      "If a hub has per-port power switching and per-port current limiting,
      an over-current on one port may still cause the power on another port
      to fall below specific minimums. In this case, the affected port is
      placed in the Power-Off state and C_PORT_OVER_CURRENT is set for the
      port, but PORT_OVER_CURRENT is not set."
    
    so let's check C_PORT_OVER_CURRENT too for over current condition.
    
    Fixes: 08d1dec6f405 ("usb:hub set hub->change_bits when over-current happens")
    Tested-by: Alessandro Antenucci <antenucci@korg.it>
    Signed-off-by: Bin Liu <b-liu@ti.com>
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c31684f79b13c022b7664e72e292aeb7e32e42f6
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Fri Jul 13 16:12:32 2018 +0800

    crypto: padlock-aes - Fix Nano workaround data corruption
    
    commit 46d8c4b28652d35dc6cfb5adf7f54e102fc04384 upstream.
    
    This was detected by the self-test thanks to Ard's chunking patch.
    
    I finally got around to testing this out on my ancient Via box.  It
    turns out that the workaround got the assembly wrong and we end up
    doing count + initial cycles of the loop instead of just count.
    
    This obviously causes corruption, either by overwriting the source
    that is yet to be processed, or writing over the end of the buffer.
    
    On CPUs that don't require the workaround only ECB is affected.
    On Nano CPUs both ECB and CBC are affected.
    
    This patch fixes it by doing the subtraction prior to the assembly.
    
    Fixes: a76c1c23d0c3 ("crypto: padlock-aes - work around Nano CPU...")
    Reported-by: Jamie Heilman <jamie@audible.transient.net>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 20630b28cd94972ad2e3c54b70d78029a247cdcf
Author: Anil Gurumurthy <anil.gurumurthy@cavium.com>
Date:   Wed Jul 18 14:29:55 2018 -0700

    scsi: qla2xxx: Return error when TMF returns
    
    commit b4146c4929ef61d5afca011474d59d0918a0cd82 upstream.
    
    Propagate the task management completion status properly to avoid
    unnecessary waits for commands to complete.
    
    Fixes: faef62d13463 ("[SCSI] qla2xxx: Fix Task Management command asynchronous handling")
    Signed-off-by: Anil Gurumurthy <anil.gurumurthy@cavium.com>
    Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1f2546f3f9480e742c3f6a417fd8a27fdbdc1984
Author: Quinn Tran <quinn.tran@cavium.com>
Date:   Wed Jul 18 14:29:54 2018 -0700

    scsi: qla2xxx: Fix ISP recovery on unload
    
    commit b08abbd9f5996309f021684f9ca74da30dcca36a upstream.
    
    During unload process, the chip can encounter problem where a FW dump would
    be captured. For this case, the full reset sequence will be skip to bring
    the chip back to full operational state.
    
    Fixes: e315cd28b9ef ("[SCSI] qla2xxx: Code changes for qla data structure refactoring")
    Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
    Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8c85151ca8255073fe040da54aa8b7b43feb2469
Author: Gustavo A. R. Silva <gustavo@embeddedor.com>
Date:   Mon Jul 16 20:59:58 2018 -0500

    net: cxgb3_main: fix potential Spectre v1
    
    commit 676bcfece19f83621e905aa55b5ed2d45cc4f2d3 upstream.
    
    t.qset_idx can be indirectly controlled by user-space, hence leading to
    a potential exploitation of the Spectre variant 1 vulnerability.
    
    This issue was detected with the help of Smatch:
    
    drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c:2286 cxgb_extension_ioctl()
    warn: potential spectre issue 'adapter->msix_info'
    
    Fix this by sanitizing t.qset_idx before using it to index
    adapter->msix_info
    
    Notice that given that speculation windows are large, the policy is
    to kill the speculation on the first load and not worry if it can be
    completed with a dependent load/store [1].
    
    [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
    
    Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 28806e65c87dc0a214d94b8755d118ce5b39511f
Author: Chen-Yu Tsai <wens@csie.org>
Date:   Wed Jul 18 17:24:35 2018 +0000

    Input: i8042 - add Lenovo LaVie Z to the i8042 reset list
    
    commit 384cf4285b34e08917e3e66603382f2b0c4f6e1b upstream.
    
    The Lenovo LaVie Z laptop requires i8042 to be reset in order to
    consistently detect its Elantech touchpad. The nomux and kbdreset
    quirks are not sufficient.
    
    It's possible the other LaVie Z models from NEC require this as well.
    
    Signed-off-by: Chen-Yu Tsai <wens@csie.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 69dc1b84785e8586309a4d6b38d20dd2533c6435
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Tue Feb 28 17:14:41 2017 -0800

    Input: i8042 - add TUXEDO BU1406 (N24_25BU) to the nomux list
    
    commit a4c2a13129f7c5bcf81704c06851601593303fd5 upstream.
    
    TUXEDO BU1406 does not implement active multiplexing mode properly,
    and takes around 550 ms in i8042_set_mux_mode(). Given that the
    device does not have external AUX port, there is no downside in
    disabling the MUX mode.
    
    Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
    Suggested-by: Vojtech Pavlik <vojtech@suse.cz>
    Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b3bf19a8b9f7ed00723b41725776a587b3fb0ee5
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Sat Jul 14 23:55:57 2018 -0400

    random: mix rdrand with entropy sent in from userspace
    
    commit 81e69df38e2911b642ec121dec319fad2a4782f3 upstream.
    
    Fedora has integrated the jitter entropy daemon to work around slow
    boot problems, especially on VM's that don't support virtio-rng:
    
        https://bugzilla.redhat.com/show_bug.cgi?id=1572944
    
    It's understandable why they did this, but the Jitter entropy daemon
    works fundamentally on the principle: "the CPU microarchitecture is
    **so** complicated and we can't figure it out, so it *must* be
    random".  Yes, it uses statistical tests to "prove" it is secure, but
    AES_ENCRYPT(NSA_KEY, COUNTER++) will also pass statistical tests with
    flying colors.
    
    So if RDRAND is available, mix it into entropy submitted from
    userspace.  It can't hurt, and if you believe the NSA has backdoored
    RDRAND, then they probably have enough details about the Intel
    microarchitecture that they can reverse engineer how the Jitter
    entropy daemon affects the microarchitecture, and attack its output
    stream.  And if RDRAND is in fact an honest DRNG, it will immeasurably
    improve on what the Jitter entropy daemon might produce.
    
    This also provides some protection against someone who is able to read
    or set the entropy seed file.
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4ffd9246a83cfa23488e3a7c578f0d7a08b5a3be
Author: Dewet Thibaut <thibaut.dewet@nokia.com>
Date:   Mon Jul 16 10:49:27 2018 +0200

    x86/MCE: Remove min interval polling limitation
    
    commit fbdb328c6bae0a7c78d75734a738b66b86dffc96 upstream.
    
    commit b3b7c4795c ("x86/MCE: Serialize sysfs changes") introduced a min
    interval limitation when setting the check interval for polled MCEs.
    However, the logic is that 0 disables polling for corrected MCEs, see
    Documentation/x86/x86_64/machinecheck. The limitation prevents disabling.
    
    Remove this limitation and allow the value 0 to disable polling again.
    
    Fixes: b3b7c4795c ("x86/MCE: Serialize sysfs changes")
    Signed-off-by: Dewet Thibaut <thibaut.dewet@nokia.com>
    Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
    [ Massage commit message. ]
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: linux-edac <linux-edac@vger.kernel.org>
    Link: http://lkml.kernel.org/r/20180716084927.24869-1-alexander.sverdlin@nokia.com
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a610b0d828065c3430dc66165ff004f53a34235a
Author: Joshua Frkuska <joshua_frkuska@mentor.com>
Date:   Thu Jun 21 17:22:48 2018 +0200

    usb: gadget: u_audio: update hw_ptr in iso_complete after data copied
    
    commit 6b37bd78d30c890e575a1bda22978d1d2a233362 upstream.
    
    In u_audio_iso_complete, the runtime hw_ptr is updated before the
    data is actually copied over to/from the buffer/dma area. When
    ALSA uses this hw_ptr, the data may not actually be available to
    be used. This causes trash/stale audio to play/record. This
    patch updates the hw_ptr after the data has been copied to avoid
    this.
    
    Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")
    Signed-off-by: Joshua Frkuska <joshua_frkuska@mentor.com>
    Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
    Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
    [bwh: Backported to 3.16:
     - Don't use a local hw_ptr variable
     - Adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2e6e6a426feae534740f4dc0dead805bb71e702f
Author: Eric Biggers <ebiggers@google.com>
Date:   Wed Jul 11 10:46:29 2018 -0700

    KEYS: DNS: fix parsing multiple options
    
    commit c604cb767049b78b3075497b80ebb8fd530ea2cc upstream.
    
    My recent fix for dns_resolver_preparse() printing very long strings was
    incomplete, as shown by syzbot which still managed to hit the
    WARN_ONCE() in set_precision() by adding a crafted "dns_resolver" key:
    
        precision 50001 too large
        WARNING: CPU: 7 PID: 864 at lib/vsprintf.c:2164 vsnprintf+0x48a/0x5a0
    
    The bug this time isn't just a printing bug, but also a logical error
    when multiple options ("#"-separated strings) are given in the key
    payload.  Specifically, when separating an option string into name and
    value, if there is no value then the name is incorrectly considered to
    end at the end of the key payload, rather than the end of the current
    option.  This bypasses validation of the option length, and also means
    that specifying multiple options is broken -- which presumably has gone
    unnoticed as there is currently only one valid option anyway.
    
    A similar problem also applied to option values, as the kstrtoul() when
    parsing the "dnserror" option will read past the end of the current
    option and into the next option.
    
    Fix these bugs by correctly computing the length of the option name and
    by copying the option value, null-terminated, into a temporary buffer.
    
    Reproducer for the WARN_ONCE() that syzbot hit:
    
        perl -e 'print "#A#", "\0" x 50000' | keyctl padd dns_resolver desc @s
    
    Reproducer for "dnserror" option being parsed incorrectly (expected
    behavior is to fail when seeing the unknown option "foo", actual
    behavior was to read the dnserror value as "1#foo" and fail there):
    
        perl -e 'print "#dnserror=1#foo\0"' | keyctl padd dns_resolver desc @s
    
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Fixes: 4a2d789267e0 ("DNS: If the DNS server returns an error, allow that to be cached [ver #2]")
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dd154bcf20e35d1291698139d0535123012fb483
Author: Ville Syrjälä <ville.syrjala@linux.intel.com>
Date:   Mon Jul 9 16:35:34 2018 +0300

    x86/apm: Don't access __preempt_count with zeroed fs
    
    commit 6f6060a5c9cc76fdbc22748264e6aa3779ec2427 upstream.
    
    APM_DO_POP_SEGS does not restore fs/gs which were zeroed by
    APM_DO_ZERO_SEGS. Trying to access __preempt_count with
    zeroed fs doesn't really work.
    
    Move the ibrs call outside the APM_DO_SAVE_SEGS/APM_DO_RESTORE_SEGS
    invocations so that fs is actually restored before calling
    preempt_enable().
    
    Fixes the following sort of oopses:
    [    0.313581] general protection fault: 0000 [#1] PREEMPT SMP
    [    0.313803] Modules linked in:
    [    0.314040] CPU: 0 PID: 268 Comm: kapmd Not tainted 4.16.0-rc1-triton-bisect-00090-gdd84441a7971 #19
    [    0.316161] EIP: __apm_bios_call_simple+0xc8/0x170
    [    0.316161] EFLAGS: 00210016 CPU: 0
    [    0.316161] EAX: 00000102 EBX: 00000000 ECX: 00000102 EDX: 00000000
    [    0.316161] ESI: 0000530e EDI: dea95f64 EBP: dea95f18 ESP: dea95ef0
    [    0.316161]  DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
    [    0.316161] CR0: 80050033 CR2: 00000000 CR3: 015d3000 CR4: 000006d0
    [    0.316161] Call Trace:
    [    0.316161]  ? cpumask_weight.constprop.15+0x20/0x20
    [    0.316161]  on_cpu0+0x44/0x70
    [    0.316161]  apm+0x54e/0x720
    [    0.316161]  ? __switch_to_asm+0x26/0x40
    [    0.316161]  ? __schedule+0x17d/0x590
    [    0.316161]  kthread+0xc0/0xf0
    [    0.316161]  ? proc_apm_show+0x150/0x150
    [    0.316161]  ? kthread_create_worker_on_cpu+0x20/0x20
    [    0.316161]  ret_from_fork+0x2e/0x38
    [    0.316161] Code: da 8e c2 8e e2 8e ea 57 55 2e ff 1d e0 bb 5d b1 0f 92 c3 5d 5f 07 1f 89 47 0c 90 8d b4 26 00 00 00 00 90 8d b4 26 00 00 00 00 90 <64> ff 0d 84 16 5c b1 74 7f 8b 45 dc 8e e0 8b 45 d8 8e e8 8b 45
    [    0.316161] EIP: __apm_bios_call_simple+0xc8/0x170 SS:ESP: 0068:dea95ef0
    [    0.316161] ---[ end trace 656253db2deaa12c ]---
    
    Fixes: dd84441a7971 ("x86/speculation: Use IBRS if available before calling into firmware")
    Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc:  David Woodhouse <dwmw@amazon.co.uk>
    Cc:  "H. Peter Anvin" <hpa@zytor.com>
    Cc:  x86@kernel.org
    Cc: David Woodhouse <dwmw@amazon.co.uk>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Link: https://lkml.kernel.org/r/20180709133534.5963-1-ville.syrjala@linux.intel.com
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a7233dbfa3e4e2c7a43e53a51fed043d19876d55
Author: Paul Burton <paul.burton@mips.com>
Date:   Thu Jul 12 09:33:04 2018 -0700

    MIPS: Fix off-by-one in pci_resource_to_user()
    
    commit 38c0a74fe06da3be133cae3fb7bde6a9438e698b upstream.
    
    The MIPS implementation of pci_resource_to_user() introduced in v3.12 by
    commit 4c2924b725fb ("MIPS: PCI: Use pci_resource_to_user to map pci
    memory space properly") incorrectly sets *end to the address of the
    byte after the resource, rather than the last byte of the resource.
    
    This results in userland seeing resources as a byte larger than they
    actually are, for example a 32 byte BAR will be reported by a tool such
    as lspci as being 33 bytes in size:
    
        Region 2: I/O ports at 1000 [disabled] [size=33]
    
    Correct this by subtracting one from the calculated end address,
    reporting the correct address to userland.
    
    Signed-off-by: Paul Burton <paul.burton@mips.com>
    Reported-by: Rui Wang <rui.wang@windriver.com>
    Fixes: 4c2924b725fb ("MIPS: PCI: Use pci_resource_to_user to map pci memory space properly")
    Cc: James Hogan <jhogan@kernel.org>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: Wolfgang Grandegger <wg@grandegger.com>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/19829/
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5ee66ed12240ea231303db320b306ce022619993
Author: Nicholas Mc Guire <hofrat@osadl.org>
Date:   Sat Jul 14 14:32:12 2018 +0200

    drm: re-enable error handling
    
    commit d530b5f1ca0bb66958a2b714bebe40a1248b9c15 upstream.
    
    drm_legacy_ctxbitmap_next() returns idr_alloc() which can return
    -ENOMEM, -EINVAL or -ENOSPC none of which are -1 . but the call sites
    of drm_legacy_ctxbitmap_next() seem to be assuming that the error case
    would be -1 (original return of drm_ctxbitmap_next() prior to 2.6.23
    was actually -1). Thus reenable error handling by checking for < 0.
    
    Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
    Fixes: 62968144e673 ("drm: convert drm context code to use Linux idr")
    Signed-off-by: Sean Paul <seanpaul@chromium.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/1531571532-22733-1-git-send-email-hofrat@osadl.org
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8a99cb8273f1fa128a09a18b73c8dc612e77836a
Author: Lyude Paul <lyude@redhat.com>
Date:   Thu Jul 12 13:02:54 2018 -0400

    drm/nouveau: Remove bogus crtc check in pmops_runtime_idle
    
    commit 68fe23a626b67b56c912c496ea43ed537ea9708f upstream.
    
    This both uses the legacy modesetting structures in a racy manner, and
    additionally also doesn't even check the right variable (enabled != the
    CRTC is actually turned on for atomic).
    
    This fixes issues on my P50 regarding the dedicated GPU not entering
    runtime suspend.
    
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
    [bwh: Backported to 3.16:
     - Preserve local variables that are still needed
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1d79a06ea8883a87bf2b942c468e8bf99a15ebc5
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Jul 3 15:30:56 2018 +0300

    drm/nouveau/gem: off by one bugs in nouveau_gem_pushbuf_reloc_apply()
    
    commit 7f073d011f93e92d4d225526b9ab6b8b0bbd6613 upstream.
    
    The bo array has req->nr_buffers elements so the > should be >= so we
    don't read beyond the end of the array.
    
    Fixes: a1606a9596e5 ("drm/nouveau: new gem pushbuf interface, bump to 0.0.16")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ecfbd29954bbed06e5f02b1b188ea26a6a608a8c
Author: Lubomir Rintel <lkundrak@v3.sk>
Date:   Tue Jul 10 08:28:49 2018 +0200

    usb: cdc_acm: Add quirk for Castles VEGA3000
    
    commit 1445cbe476fc3dd09c0b380b206526a49403c071 upstream.
    
    The device (a POS terminal) implements CDC ACM, but has not union
    descriptor.
    
    Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
    Acked-by: Oliver Neukum <oneukum@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ca469c0d8b6d5023d8db29f45034dffb76f4a7b8
Author: Eric Biggers <ebiggers@google.com>
Date:   Fri Jul 13 16:59:27 2018 -0700

    reiserfs: fix buffer overflow with long warning messages
    
    commit fe10e398e860955bac4d28ec031b701d358465e4 upstream.
    
    ReiserFS prepares log messages into a 1024-byte buffer with no bounds
    checks.  Long messages, such as the "unknown mount option" warning when
    userspace passes a crafted mount options string, overflow this buffer.
    This causes KASAN to report a global-out-of-bounds write.
    
    Fix it by truncating messages to the buffer size.
    
    Link: http://lkml.kernel.org/r/20180707203621.30922-1-ebiggers3@gmail.com
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reported-by: syzbot+b890b3335a4d8c608963@syzkaller.appspotmail.com
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit aa727d5b1c8d03f747fb6630b57fa286654b5b2a
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Wed Nov 7 20:57:03 2018 +0000

    string: drop __must_check from strscpy()
    
    This was done as part of commit 08a77676f9c5 upstream, from which
    the following description is taken:
    
    > strlcpy() is worse than strlcpy() because it unconditionally runs
    > strlen() on the source string, and the only reason we switched to
    > strlcpy() here was because it was lacking __must_check, which doesn't
    > reflect any material differences between the two function.  It's just
    > that someone added __must_check to strscpy() and not to strlcpy().
    >
    > These basic string copy operations are used in variety of ways, and
    > one of not-so-uncommon use cases is safely handling truncated copies,
    > where the caller naturally doesn't care about the return value.  The
    > __must_check doesn't match the actual use cases and forces users to
    > opt for inferior variants which lack __must_check by happenstance or
    > spread ugly (void) casts.
    
    Cc: Tejun Heo <tj@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit edeea512d7873b6b2e32fed524756f6eb1fffea2
Author: Michal Hocko <mhocko@suse.com>
Date:   Fri Jul 13 16:59:20 2018 -0700

    mm: do not bug_on on incorrect length in __mm_populate()
    
    commit bb177a732c4369bb58a1fe1df8f552b6f0f7db5f upstream.
    
    syzbot has noticed that a specially crafted library can easily hit
    VM_BUG_ON in __mm_populate
    
      kernel BUG at mm/gup.c:1242!
      invalid opcode: 0000 [#1] SMP
      CPU: 2 PID: 9667 Comm: a.out Not tainted 4.18.0-rc3 #644
      Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
      RIP: 0010:__mm_populate+0x1e2/0x1f0
      Code: 55 d0 65 48 33 14 25 28 00 00 00 89 d8 75 21 48 83 c4 20 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 75 18 f1 ff 0f 0b e8 6e 18 f1 ff <0f> 0b 31 db eb c9 e8 93 06 e0 ff 0f 1f 00 55 48 89 e5 53 48 89 fb
      Call Trace:
         vm_brk_flags+0xc3/0x100
         vm_brk+0x1f/0x30
         load_elf_library+0x281/0x2e0
         __ia32_sys_uselib+0x170/0x1e0
         do_fast_syscall_32+0xca/0x420
         entry_SYSENTER_compat+0x70/0x7f
    
    The reason is that the length of the new brk is not page aligned when we
    try to populate the it.  There is no reason to bug on that though.
    do_brk_flags already aligns the length properly so the mapping is
    expanded as it should.  All we need is to tell mm_populate about it.
    Besides that there is absolutely no reason to to bug_on in the first
    place.  The worst thing that could happen is that the last page wouldn't
    get populated and that is far from putting system into an inconsistent
    state.
    
    Fix the issue by moving the length sanitization code from do_brk_flags
    up to vm_brk_flags.  The only other caller of do_brk_flags is brk
    syscall entry and it makes sure to provide the proper length so t here
    is no need for sanitation and so we can use do_brk_flags without it.
    
    Also remove the bogus BUG_ONs.
    
    [osalvador@techadventures.net: fix up vm_brk_flags s@request@len@]
    Link: http://lkml.kernel.org/r/20180706090217.GI32658@dhcp22.suse.cz
    Signed-off-by: Michal Hocko <mhocko@suse.com>
    Reported-by: syzbot <syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com>
    Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Reviewed-by: Oscar Salvador <osalvador@suse.de>
    Cc: Zi Yan <zi.yan@cs.rutgers.edu>
    Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Michael S. Tsirkin <mst@redhat.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16:
     - There is no do_brk_flags() function; update do_brk()
     - do_brk(), vm_brk() return the address on success
     - Adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 464ff51af9da2148a2c20938825d9b2b2adeb734
Author: Oscar Salvador <osalvador@suse.de>
Date:   Fri Jul 13 16:59:13 2018 -0700

    fs, elf: make sure to page align bss in load_elf_library
    
    commit 24962af7e1041b7e50c1bc71d8d10dc678c556b5 upstream.
    
    The current code does not make sure to page align bss before calling
    vm_brk(), and this can lead to a VM_BUG_ON() in __mm_populate() due to
    the requested lenght not being correctly aligned.
    
    Let us make sure to align it properly.
    
    Kees: only applicable to CONFIG_USELIB kernels: 32-bit and configured
    for libc5.
    
    Link: http://lkml.kernel.org/r/20180705145539.9627-1-osalvador@techadventures.net
    Signed-off-by: Oscar Salvador <osalvador@suse.de>
    Reported-by: syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com
    Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
    Acked-by: Kees Cook <keescook@chromium.org>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 403935326e58c6dd72fddc3a3850aa9d037ad598
Author: Kees Cook <keescook@chromium.org>
Date:   Tue Aug 2 14:04:54 2016 -0700

    mm: refuse wrapped vm_brk requests
    
    commit ba093a6d9397da8eafcfbaa7d95bd34255da39a0 upstream.
    
    The vm_brk() alignment calculations should refuse to overflow.  The ELF
    loader depending on this, but it has been fixed now.  No other unsafe
    callers have been found.
    
    Link: http://lkml.kernel.org/r/1468014494-25291-3-git-send-email-keescook@chromium.org
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Reported-by: Hector Marco-Gisbert <hecmargi@upv.es>
    Cc: Ismael Ripoll Ripoll <iripoll@upv.es>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Chen Gang <gang.chen.5i5j@gmail.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Konstantin Khlebnikov <koct9i@gmail.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c3c98dfdf85843f97e6290fd7758d27581769d88
Author: Kees Cook <keescook@chromium.org>
Date:   Tue Aug 2 14:04:51 2016 -0700

    binfmt_elf: fix calculations for bss padding
    
    commit 0036d1f7eb95bcc52977f15507f00dd07018e7e2 upstream.
    
    A double-bug exists in the bss calculation code, where an overflow can
    happen in the "last_bss - elf_bss" calculation, but vm_brk internally
    aligns the argument, underflowing it, wrapping back around safe.  We
    shouldn't depend on these bugs staying in sync, so this cleans up the
    bss padding handling to avoid the overflow.
    
    This moves the bss padzero() before the last_bss > elf_bss case, since
    the zero-filling of the ELF_PAGE should have nothing to do with the
    relationship of last_bss and elf_bss: any trailing portion should be
    zeroed, and a zero size is already handled by padzero().
    
    Then it handles the math on elf_bss vs last_bss correctly.  These need
    to both be ELF_PAGE aligned to get the comparison correct, since that's
    the expected granularity of the mappings.  Since elf_bss already had
    alignment-based padding happen in padzero(), the "start" of the new
    vm_brk() should be moved forward as done in the original code.  However,
    since the "end" of the vm_brk() area will already become PAGE_ALIGNed in
    vm_brk() then last_bss should get aligned here to avoid hiding it as a
    side-effect.
    
    Additionally makes a cosmetic change to the initial last_bss calculation
    so it's easier to read in comparison to the load_addr calculation above
    it (i.e.  the only difference is p_filesz vs p_memsz).
    
    Link: http://lkml.kernel.org/r/1468014494-25291-2-git-send-email-keescook@chromium.org
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Reported-by: Hector Marco-Gisbert <hecmargi@upv.es>
    Cc: Ismael Ripoll Ripoll <iripoll@upv.es>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Chen Gang <gang.chen.5i5j@gmail.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Konstantin Khlebnikov <koct9i@gmail.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit be09b3258a79919f65bd3f2221cf233e6bf3aa9a
Author: Michal Hocko <mhocko@suse.com>
Date:   Mon May 23 16:25:39 2016 -0700

    mm, elf: handle vm_brk error
    
    commit ecc2bc8ac03884266cf73f8a2a42b911465b2fbc upstream.
    
    load_elf_library doesn't handle vm_brk failure although nothing really
    indicates it cannot do that because the function is allowed to fail due
    to vm_mmap failures already.  This might be not a problem now but later
    patch will make vm_brk killable (resp.  mmap_sem for write waiting will
    become killable) and so the failure will be more probable.
    
    Signed-off-by: Michal Hocko <mhocko@suse.com>
    Acked-by: Vlastimil Babka <vbabka@suse.cz>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 02d0034a92e79cfd68c50922b302b04a6c10c2d0
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu Jul 12 15:23:45 2018 +0300

    qlogic: check kstrtoul() for errors
    
    commit 5fc853cc01c68f84984ecc2d5fd777ecad78240f upstream.
    
    We accidentally left out the error handling for kstrtoul().
    
    Fixes: a520030e326a ("qlcnic: Implement flash sysfs callback for 83xx adapter")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 76362a5df859330d6a74e69f207e25484704cc13
Author: Stefano Brivio <sbrivio@redhat.com>
Date:   Fri Jul 13 13:21:07 2018 +0200

    skbuff: Unconditionally copy pfmemalloc in __skb_clone()
    
    commit e78bfb0751d4e312699106ba7efbed2bab1a53ca upstream.
    
    Commit 8b7008620b84 ("net: Don't copy pfmemalloc flag in
    __copy_skb_header()") introduced a different handling for the
    pfmemalloc flag in copy and clone paths.
    
    In __skb_clone(), now, the flag is set only if it was set in the
    original skb, but not cleared if it wasn't. This is wrong and
    might lead to socket buffers being flagged with pfmemalloc even
    if the skb data wasn't allocated from pfmemalloc reserves. Copy
    the flag instead of ORing it.
    
    Reported-by: Sabrina Dubroca <sd@queasysnail.net>
    Fixes: 8b7008620b84 ("net: Don't copy pfmemalloc flag in __copy_skb_header()")
    Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
    Tested-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: We didn't set the pfmemalloc flag in either copy
     or clone path until now]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fea01489f7fbe2bb232076af4ce536d1056681d7
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Thu Jul 12 19:08:05 2018 -0400

    ext4: check for allocation block validity with block group locked
    
    commit 8d5a803c6a6ce4ec258e31f76059ea5153ba46ef upstream.
    
    With commit 044e6e3d74a3: "ext4: don't update checksum of new
    initialized bitmaps" the buffer valid bit will get set without
    actually setting up the checksum for the allocation bitmap, since the
    checksum will get calculated once we actually allocate an inode or
    block.
    
    If we are doing this, then we need to (re-)check the verified bit
    after we take the block group lock.  Otherwise, we could race with
    another process reading and verifying the bitmap, which would then
    complain about the checksum being invalid.
    
    https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1780137
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 459c5a2c2069bc730f0b1e88775cbda1e3d19e5c
Author: Kamal Heib <kamalheib1@gmail.com>
Date:   Tue Jul 10 11:56:50 2018 +0300

    RDMA/mlx5: Fix memory leak in mlx5_ib_create_srq() error path
    
    commit d63c46734c545ad0488761059004a65c46efdde3 upstream.
    
    Fix memory leak in the error path of mlx5_ib_create_srq() by making sure
    to free the allocated srq.
    
    Fixes: c2b37f76485f ("IB/mlx5: Fix integer overflows in mlx5_ib_create_srq")
    Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
    Acked-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2387ae5715a7393f0e2830fd0969e1d86b378492
Author: Vineet Gupta <vgupta@synopsys.com>
Date:   Wed Jul 11 10:42:20 2018 -0700

    ARC: mm: allow mprotect to make stack mappings executable
    
    commit 93312b6da4df31e4102ce5420e6217135a16c7ea upstream.
    
    mprotect(EXEC) was failing for stack mappings as default vm flags was
    missing MAYEXEC.
    
    This was triggered by glibc test suite nptl/tst-execstack testcase
    
    What is surprising is that despite running LTP for years on, we didn't
    catch this issue as it lacks a directed test case.
    
    gcc dejagnu tests with nested functions also requiring exec stack work
    fine though because they rely on the GNU_STACK segment spit out by
    compiler and handled in kernel elf loader.
    
    This glibc case is different as the stack is non exec to begin with and
    a dlopen of shared lib with GNU_STACK segment triggers the exec stack
    proceedings using a mprotect(PROT_EXEC) which was broken.
    
    Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 328f7f7ff66535e9554015e8e53ac26e9f1952c7
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Tue Jul 10 01:07:43 2018 -0400

    ext4: fix inline data updates with checksums enabled
    
    commit 362eca70b53389bddf3143fe20f53dcce2cfdf61 upstream.
    
    The inline data code was updating the raw inode directly; this is
    problematic since if metadata checksums are enabled,
    ext4_mark_inode_dirty() must be called to update the inode's checksum.
    In addition, the jbd2 layer requires that get_write_access() be called
    before the metadata buffer is modified.  Fix both of these problems.
    
    https://bugzilla.kernel.org/show_bug.cgi?id=200443
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a3e56ccf2a07017c11d24db19f9d03930c28ebed
Author: Alexey Brodkin <abrodkin@synopsys.com>
Date:   Thu Jun 28 16:59:14 2018 -0700

    ARC: Fix CONFIG_SWAP
    
    commit 6e3761145a9ba3ce267c330b6bff51cf6a057b06 upstream.
    
    swap was broken on ARC due to silly copy-paste issue.
    
    We encode offset from swapcache page in __swp_entry() as (off << 13) but
    were not decoding back in __swp_offset() as (off >> 13) - it was still
    (off << 13).
    
    This finally fixes swap usage on ARC.
    
    | # mkswap /dev/sda2
    |
    | # swapon -a -e /dev/sda2
    | Adding 500728k swap on /dev/sda2.  Priority:-2 extents:1 across:500728k
    |
    | # free
    |              total       used       free     shared    buffers     cached
    | Mem:        765104      13456     751648       4736          8       4736
    | -/+ buffers/cache:       8712     756392
    | Swap:       500728          0     500728
    
    Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
    Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 21dc0fd20c4f70786e055babc6d414b1b425c1d9
Author: Gustavo A. R. Silva <gustavo@embeddedor.com>
Date:   Fri Jun 29 17:08:44 2018 -0500

    HID: hiddev: fix potential Spectre v1
    
    commit 4f65245f2d178b9cba48350620d76faa4a098841 upstream.
    
    uref->field_index, uref->usage_index, finfo.field_index and cinfo.index can be
    indirectly controlled by user-space, hence leading to a potential exploitation
    of the Spectre variant 1 vulnerability.
    
    This issue was detected with the help of Smatch:
    
    drivers/hid/usbhid/hiddev.c:473 hiddev_ioctl_usage() warn: potential spectre issue 'report->field' (local cap)
    drivers/hid/usbhid/hiddev.c:477 hiddev_ioctl_usage() warn: potential spectre issue 'field->usage' (local cap)
    drivers/hid/usbhid/hiddev.c:757 hiddev_ioctl() warn: potential spectre issue 'report->field' (local cap)
    drivers/hid/usbhid/hiddev.c:801 hiddev_ioctl() warn: potential spectre issue 'hid->collection' (local cap)
    
    Fix this by sanitizing such structure fields before using them to index
    report->field, field->usage and hid->collection
    
    Notice that given that speculation windows are large, the policy is
    to kill the speculation on the first load and not worry if it can be
    completed with a dependent load/store [1].
    
    [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
    
    Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7da9d6ccf7ca05f745a25140c70ac65ca893713f
Author: Stefan Agner <stefan@agner.ch>
Date:   Wed Jul 4 17:07:45 2018 +0200

    mmc: sdhci-esdhc-imx: allow 1.8V modes without 100/200MHz pinctrl states
    
    commit 92748beac07c471d995fbec642b63572dc01b3dc upstream.
    
    If pinctrl nodes for 100/200MHz are missing, the controller should
    not select any mode which need signal frequencies 100MHz or higher.
    To prevent such speed modes the driver currently uses the quirk flag
    SDHCI_QUIRK2_NO_1_8_V. This works nicely for SD cards since 1.8V
    signaling is required for all faster modes and slower modes use 3.3V
    signaling only.
    
    However, there are eMMC modes which use 1.8V signaling and run below
    100MHz, e.g. DDR52 at 1.8V. With using SDHCI_QUIRK2_NO_1_8_V this
    mode is prevented. When using a fixed 1.8V regulator as vqmmc-supply
    the stack has no valid mode to use. In this tenuous situation the
    kernel continuously prints voltage switching errors:
      mmc1: Switching to 3.3V signalling voltage failed
    
    Avoid using SDHCI_QUIRK2_NO_1_8_V and prevent faster modes by
    altering the SDHCI capability register. With that the stack is able
    to select 1.8V modes even if no faster pinctrl states are available:
      # cat /sys/kernel/debug/mmc1/ios
      ...
      timing spec:    8 (mmc DDR52)
      signal voltage: 1 (1.80 V)
      ...
    
    Link: http://lkml.kernel.org/r/20180628081331.13051-1-stefan@agner.ch
    Signed-off-by: Stefan Agner <stefan@agner.ch>
    Fixes: ad93220de7da ("mmc: sdhci-esdhc-imx: change pinctrl state according
    to uhs mode")
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    [bwh: Backported to 3.16:
     - There is no SDHCI_SUPPORT_HS400 flag to clear
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 232b41dd73642036b97f144f83e3129746997e31
Author: Jann Horn <jannh@google.com>
Date:   Sat Jul 7 04:16:33 2018 +0200

    ibmasm: don't write out of bounds in read handler
    
    commit a0341fc1981a950c1e902ab901e98f60e0e243f3 upstream.
    
    This read handler had a lot of custom logic and wrote outside the bounds of
    the provided buffer. This could lead to kernel and userspace memory
    corruption. Just use simple_read_from_buffer() with a stack buffer.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Jann Horn <jannh@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 779ed68af5bd09cb80c1dde36af353c8da18ba8c
Author: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Date:   Wed Jul 4 11:12:40 2018 +0300

    sh_eth: fix invalid context bug while changing link options by ethtool
    
    commit 5cb3f52a11e18628fc4bee76dd14b1f0b76349de upstream.
    
    The change fixes sleep in atomic context bug, which is encountered
    every time when link settings are changed by ethtool.
    
    Since commit 35b5f6b1a82b ("PHYLIB: Locking fixes for PHY I/O
    potentially sleeping") phy_start_aneg() function utilizes a mutex
    to serialize changes to phy state, however that helper function is
    called in atomic context under a grabbed spinlock, because
    phy_start_aneg() is called by phy_ethtool_ksettings_set() and by
    replaced phy_ethtool_sset() helpers from phylib.
    
    Now duplex mode setting is enforced in sh_eth_adjust_link() only,
    also now RX/TX is disabled when link is put down or modifications
    to E-MAC registers ECMR and GECMR are expected for both cases of
    checked and ignored link status pin state from E-MAC interrupt handler.
    
    For reference the change is a partial rework of commit 1e1b812bbe10
    ("sh_eth: fix handling of no LINK signal").
    
    Fixes: dc19e4e5e02f ("sh: sh_eth: Add support ethtool")
    Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
    Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16:
     - Keep using phy_ethtool_sset()
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 258a719a02bf6a26cbf7a03e95bcb7a612884408
Author: Nico Sneck <snecknico@gmail.com>
Date:   Mon Jul 2 19:26:07 2018 +0300

    usb: quirks: add delay quirks for Corsair Strafe
    
    commit bba57eddadda936c94b5dccf73787cb9e159d0a5 upstream.
    
    Corsair Strafe appears to suffer from the same issues
    as the Corsair Strafe RGB.
    Apply the same quirks (control message delay and init delay)
    that the RGB version has to 1b1c:1b15.
    
    With these quirks in place the keyboard works correctly upon
    booting the system, and no longer requires reattaching the device.
    
    Signed-off-by: Nico Sneck <snecknico@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 31330d438db7c3fa5be06d9585583997c32f04ed
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Jul 4 12:48:53 2018 +0300

    xhci: xhci-mem: off by one in xhci_stream_id_to_ring()
    
    commit 313db3d6488bb03b61b99de9dbca061f1fd838e1 upstream.
    
    The > should be >= here so that we don't read one element beyond the end
    of the ep->stream_info->stream_rings[] array.
    
    Fixes: e9df17eb1408 ("USB: xhci: Correct assumptions about number of rings per endpoint.")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f5d54bc7627a76c136056cb1463ae8ff1609beb0
Author: Johan Hovold <johan@kernel.org>
Date:   Wed Jul 4 17:02:17 2018 +0200

    USB: serial: mos7840: fix status-register error handling
    
    commit 794744abfffef8b1f3c0c8a4896177d6d13d653d upstream.
    
    Add missing transfer-length sanity check to the status-register
    completion handler to avoid leaking bits of uninitialised slab data to
    user space.
    
    Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1535741c720cab8689f30cb8c1a91e9420b113d1
Author: Johan Hovold <johan@kernel.org>
Date:   Wed Jul 4 17:02:16 2018 +0200

    USB: serial: keyspan_pda: fix modem-status error handling
    
    commit 01b3cdfca263a17554f7b249d20a247b2a751521 upstream.
    
    Fix broken modem-status error handling which could lead to bits of slab
    data leaking to user space.
    
    Fixes: 3b36a8fd6777 ("usb: fix uninitialized variable warning in keyspan_pda")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9633d2d5f2a8ac9165f85a86b44c9359ba957f44
Author: Stefano Brivio <sbrivio@redhat.com>
Date:   Thu Jul 5 15:10:02 2018 +0200

    cifs: Fix stack out-of-bounds in smb{2,3}_create_lease_buf()
    
    commit 729c0c9dd55204f0c9a823ac8a7bfa83d36c7e78 upstream.
    
    smb{2,3}_create_lease_buf() store a lease key in the lease
    context for later usage on a lease break.
    
    In most paths, the key is currently sourced from data that
    happens to be on the stack near local variables for oplock in
    SMB2_open() callers, e.g. from open_shroot(), whereas
    smb2_open_file() properly allocates space on its stack for it.
    
    The address of those local variables holding the oplock is then
    passed to create_lease_buf handlers via SMB2_open(), and 16
    bytes near oplock are used. This causes a stack out-of-bounds
    access as reported by KASAN on SMB2.1 and SMB3 mounts (first
    out-of-bounds access is shown here):
    
    [  111.528823] BUG: KASAN: stack-out-of-bounds in smb3_create_lease_buf+0x399/0x3b0 [cifs]
    [  111.530815] Read of size 8 at addr ffff88010829f249 by task mount.cifs/985
    [  111.532838] CPU: 3 PID: 985 Comm: mount.cifs Not tainted 4.18.0-rc3+ #91
    [  111.534656] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
    [  111.536838] Call Trace:
    [  111.537528]  dump_stack+0xc2/0x16b
    [  111.540890]  print_address_description+0x6a/0x270
    [  111.542185]  kasan_report+0x258/0x380
    [  111.544701]  smb3_create_lease_buf+0x399/0x3b0 [cifs]
    [  111.546134]  SMB2_open+0x1ef8/0x4b70 [cifs]
    [  111.575883]  open_shroot+0x339/0x550 [cifs]
    [  111.591969]  smb3_qfs_tcon+0x32c/0x1e60 [cifs]
    [  111.617405]  cifs_mount+0x4f3/0x2fc0 [cifs]
    [  111.674332]  cifs_smb3_do_mount+0x263/0xf10 [cifs]
    [  111.677915]  mount_fs+0x55/0x2b0
    [  111.679504]  vfs_kern_mount.part.22+0xaa/0x430
    [  111.684511]  do_mount+0xc40/0x2660
    [  111.698301]  ksys_mount+0x80/0xd0
    [  111.701541]  do_syscall_64+0x14e/0x4b0
    [  111.711807]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [  111.713665] RIP: 0033:0x7f372385b5fa
    [  111.715311] Code: 48 8b 0d 99 78 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 66 78 2c 00 f7 d8 64 89 01 48
    [  111.720330] RSP: 002b:00007ffff27049d8 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
    [  111.722601] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f372385b5fa
    [  111.724842] RDX: 000055c2ecdc73b2 RSI: 000055c2ecdc73f9 RDI: 00007ffff270580f
    [  111.727083] RBP: 00007ffff2705804 R08: 000055c2ee976060 R09: 0000000000001000
    [  111.729319] R10: 0000000000000000 R11: 0000000000000206 R12: 00007f3723f4d000
    [  111.731615] R13: 000055c2ee976060 R14: 00007f3723f4f90f R15: 0000000000000000
    
    [  111.735448] The buggy address belongs to the page:
    [  111.737420] page:ffffea000420a7c0 count:0 mapcount:0 mapping:0000000000000000 index:0x0
    [  111.739890] flags: 0x17ffffc0000000()
    [  111.741750] raw: 0017ffffc0000000 0000000000000000 dead000000000200 0000000000000000
    [  111.744216] raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
    [  111.746679] page dumped because: kasan: bad access detected
    
    [  111.750482] Memory state around the buggy address:
    [  111.752562]  ffff88010829f100: 00 f2 f2 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00
    [  111.754991]  ffff88010829f180: 00 00 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00
    [  111.757401] >ffff88010829f200: 00 00 00 00 00 f1 f1 f1 f1 01 f2 f2 f2 f2 f2 f2
    [  111.759801]                                               ^
    [  111.762034]  ffff88010829f280: f2 02 f2 f2 f2 f2 f2 f2 f2 00 00 00 00 00 00 00
    [  111.764486]  ffff88010829f300: f2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    [  111.766913] ==================================================================
    
    Lease keys are however already generated and stored in fid data
    on open and create paths: pass them down to the lease context
    creation handlers and use them.
    
    Suggested-by: Aurélien Aptel <aaptel@suse.com>
    Reviewed-by: Aurelien Aptel <aaptel@suse.com>
    Fixes: b8c32dbb0deb ("CIFS: Request SMB2.1 leases")
    Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ca33665a3154eae9b8f995a3ca56f0499b8fb81b
Author: Ronnie Sahlberg <lsahlber@redhat.com>
Date:   Thu Apr 26 08:10:18 2018 -0600

    cifs: store the leaseKey in the fid on SMB2_open
    
    commit 96164ab2d880c9539989bea68d4790f6fd619b1f upstream.
    
    In SMB2_open(), if we got a lease we need to store this in the fid structure
    or else we will never be able to map a lease break back to which file/fid
    it applies to.
    
    Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
    Signed-off-by: Steve French <smfrench@gmail.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 89eb260588f2fb94e99702c3bfbf622eb0f6c0a2
Author: Paulo Alcantara <paulo@paulo.ac>
Date:   Thu Jul 5 13:46:34 2018 -0300

    cifs: Fix infinite loop when using hard mount option
    
    commit 7ffbe65578b44fafdef577a360eb0583929f7c6e upstream.
    
    For every request we send, whether it is SMB1 or SMB2+, we attempt to
    reconnect tcon (cifs_reconnect_tcon or smb2_reconnect) before carrying
    out the request.
    
    So, while server->tcpStatus != CifsNeedReconnect, we wait for the
    reconnection to succeed on wait_event_interruptible_timeout(). If it
    returns, that means that either the condition was evaluated to true, or
    timeout elapsed, or it was interrupted by a signal.
    
    Since we're not handling the case where the process woke up due to a
    received signal (-ERESTARTSYS), the next call to
    wait_event_interruptible_timeout() will _always_ fail and we end up
    looping forever inside either cifs_reconnect_tcon() or smb2_reconnect().
    
    Here's an example of how to trigger that:
    
    $ mount.cifs //foo/share /mnt/test -o
    username=foo,password=foo,vers=1.0,hard
    
    (break connection to server before executing bellow cmd)
    $ stat -f /mnt/test & sleep 140
    [1] 2511
    
    $ ps -aux -q 2511
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root      2511  0.0  0.0  12892  1008 pts/0    S    12:24   0:00 stat -f
    /mnt/test
    
    $ kill -9 2511
    
    (wait for a while; process is stuck in the kernel)
    $ ps -aux -q 2511
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root      2511 83.2  0.0  12892  1008 pts/0    R    12:24  30:01 stat -f
    /mnt/test
    
    By using 'hard' mount point means that cifs.ko will keep retrying
    indefinitely, however we must allow the process to be killed otherwise
    it would hang the system.
    
    Signed-off-by: Paulo Alcantara <palcantara@suse.de>
    Reviewed-by: Aurelien Aptel <aaptel@suse.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ce7fd37bd70c21ed7bd7d4a7897f24500f30b70d
Author: Lars Persson <lars.persson@axis.com>
Date:   Mon Jun 25 14:05:25 2018 +0200

    cifs: Fix use after free of a mid_q_entry
    
    commit 696e420bb2a6624478105651d5368d45b502b324 upstream.
    
    With protocol version 2.0 mounts we have seen crashes with corrupt mid
    entries. Either the server->pending_mid_q list becomes corrupt with a
    cyclic reference in one element or a mid object fetched by the
    demultiplexer thread becomes overwritten during use.
    
    Code review identified a race between the demultiplexer thread and the
    request issuing thread. The demultiplexer thread seems to be written
    with the assumption that it is the sole user of the mid object until
    it calls the mid callback which either wakes the issuer task or
    deletes the mid.
    
    This assumption is not true because the issuer task can be woken up
    earlier by a signal. If the demultiplexer thread has proceeded as far
    as setting the mid_state to MID_RESPONSE_RECEIVED then the issuer
    thread will happily end up calling cifs_delete_mid while the
    demultiplexer thread still is using the mid object.
    
    Inserting a delay in the cifs demultiplexer thread widens the race
    window and makes reproduction of the race very easy:
    
                    if (server->large_buf)
                            buf = server->bigbuf;
    
    +               usleep_range(500, 4000);
    
                    server->lstrp = jiffies;
    
    To resolve this I think the proper solution involves putting a
    reference count on the mid object. This patch makes sure that the
    demultiplexer thread holds a reference until it has finished
    processing the transaction.
    
    Signed-off-by: Lars Persson <larper@axis.com>
    Acked-by: Paulo Alcantara <palcantara@suse.de>
    Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    [bwh: Backported to 3.16: Drop redundant assignment to mid_entry]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b82631b4620587cae20c609bff5a42e497fd600c
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Sun Jun 3 16:40:54 2018 +0200

    drm/udl: fix display corruption of the last line
    
    commit 99ec9e77511dea55d81729fc80b6c63a61bfa8e0 upstream.
    
    The displaylink hardware has such a peculiarity that it doesn't render a
    command until next command is received. This produces occasional
    corruption, such as when setting 22x11 font on the console, only the first
    line of the cursor will be blinking if the cursor is located at some
    specific columns.
    
    When we end up with a repeating pixel, the driver has a bug that it leaves
    one uninitialized byte after the command (and this byte is enough to flush
    the command and render it - thus it fixes the screen corruption), however
    whe we end up with a non-repeating pixel, there is no byte appended and
    this results in temporary screen corruption.
    
    This patch fixes the screen corruption by always appending a byte 0xAF at
    the end of URB. It also removes the uninitialized byte.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 55ba0dc413081d516e023e8199b7944d6b4ab235
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Jul 4 12:29:38 2018 +0300

    USB: serial: ch341: fix type promotion bug in ch341_control_in()
    
    commit e33eab9ded328ccc14308afa51b5be7cbe78d30b upstream.
    
    The "r" variable is an int and "bufsize" is an unsigned int so the
    comparison is type promoted to unsigned.  If usb_control_msg() returns a
    negative that is treated as a high positive value and the error handling
    doesn't work.
    
    Fixes: 2d5a9c72d0c4 ("USB: serial: ch341: fix control-message error handling")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9958dc26f233d798e3b4819707c4ed9a9fa7df96
Author: Olli Salonen <olli.salonen@iki.fi>
Date:   Wed Jul 4 14:07:42 2018 +0300

    USB: serial: cp210x: add another USB ID for Qivicon ZigBee stick
    
    commit 367b160fe4717c14a2a978b6f9ffb75a7762d3ed upstream.
    
    There are two versions of the Qivicon Zigbee stick in circulation. This
    adds the second USB ID to the cp210x driver.
    
    Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5887b6f9f7d90b880edb9cae66ffa0cf67cb45e6
Author: Yuiko Oshino <yuiko.oshino@microchip.com>
Date:   Tue Jul 3 11:21:46 2018 -0400

    smsc75xx: Add workaround for gigabit link up hardware errata.
    
    commit d461e3da905332189aad546b2ad9adbe6071c7cc upstream.
    
    In certain conditions, the device may not be able to link in gigabit mode. This software workaround ensures that the device will not enter the failure state.
    
    Fixes: d0cad871703b898a442e4049c532ec39168e5b57 ("SMSC75XX USB 2.0 Gigabit Ethernet Devices")
    Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 054a129859da665daa652c4996e169679f92f5c3
Author: Cannon Matthews <cannonmatthews@google.com>
Date:   Tue Jul 3 17:02:43 2018 -0700

    mm: hugetlb: yield when prepping struct pages
    
    commit 520495fe96d74e05db585fc748351e0504d8f40d upstream.
    
    When booting with very large numbers of gigantic (i.e.  1G) pages, the
    operations in the loop of gather_bootmem_prealloc, and specifically
    prep_compound_gigantic_page, takes a very long time, and can cause a
    softlockup if enough pages are requested at boot.
    
    For example booting with 3844 1G pages requires prepping
    (set_compound_head, init the count) over 1 billion 4K tail pages, which
    takes considerable time.
    
    Add a cond_resched() to the outer loop in gather_bootmem_prealloc() to
    prevent this lockup.
    
    Tested: Booted with softlockup_panic=1 hugepagesz=1G hugepages=3844 and
    no softlockup is reported, and the hugepages are reported as
    successfully setup.
    
    Link: http://lkml.kernel.org/r/20180627214447.260804-1-cannonmatthews@google.com
    Signed-off-by: Cannon Matthews <cannonmatthews@google.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Andres Lagar-Cavilla <andreslc@google.com>
    Cc: Peter Feiner <pfeiner@google.com>
    Cc: Greg Thelen <gthelen@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 24f1c9a039d3eeea629bad569a6c39fe1ac4ba42
Author: Changbin Du <changbin.du@intel.com>
Date:   Wed Jan 31 23:48:49 2018 +0800

    tracing: Fix missing return symbol in function_graph output
    
    commit 1fe4293f4b8de75824935f8d8e9a99c7fc6873da upstream.
    
    The function_graph tracer does not show the interrupt return marker for the
    leaf entry. On leaf entries, we see an unbalanced interrupt marker (the
    interrupt was entered, but nevern left).
    
    Before:
     1)               |  SyS_write() {
     1)               |    __fdget_pos() {
     1)   0.061 us    |      __fget_light();
     1)   0.289 us    |    }
     1)               |    vfs_write() {
     1)   0.049 us    |      rw_verify_area();
     1) + 15.424 us   |      __vfs_write();
     1)   ==========> |
     1)   6.003 us    |      smp_apic_timer_interrupt();
     1)   0.055 us    |      __fsnotify_parent();
     1)   0.073 us    |      fsnotify();
     1) + 23.665 us   |    }
     1) + 24.501 us   |  }
    
    After:
     0)               |  SyS_write() {
     0)               |    __fdget_pos() {
     0)   0.052 us    |      __fget_light();
     0)   0.328 us    |    }
     0)               |    vfs_write() {
     0)   0.057 us    |      rw_verify_area();
     0)               |      __vfs_write() {
     0)   ==========> |
     0)   8.548 us    |      smp_apic_timer_interrupt();
     0)   <========== |
     0) + 36.507 us   |      } /* __vfs_write */
     0)   0.049 us    |      __fsnotify_parent();
     0)   0.066 us    |      fsnotify();
     0) + 50.064 us   |    }
     0) + 50.952 us   |  }
    
    Link: http://lkml.kernel.org/r/1517413729-20411-1-git-send-email-changbin.du@intel.com
    
    Fixes: f8b755ac8e0cc ("tracing/function-graph-tracer: Output arrows signal on hardirq call/return")
    Signed-off-by: Changbin Du <changbin.du@intel.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    [bwh: Backported to 3.16: Propagate return of TRACE_TYPE_PARTIAL_LINE from
     print_graph_irq()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1d4371701796af1af38f1192777efab770468a14
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Sun Jul 1 15:31:54 2018 +0300

    RDMA/uverbs: Don't fail in creation of multiple flows
    
    commit fe48aecb4df837540f13b5216f27ddb306aaf4b9 upstream.
    
    The conversion from offsetof() calculations to sizeof()
    wrongly behaved for missed exact size and in scenario with
    more than one flow.
    
    In such scenario we got "create flow failed, flow 10: 8 bytes
    left from uverb cmd" error, which is wrong because the size of
    kern_spec is exactly 8 bytes, and we were not supposed to fail.
    
    Fixes: 4fae7f170416 ("RDMA/uverbs: Fix slab-out-of-bounds in ib_uverbs_ex_create_flow")
    Reported-by: Ran Rozenstein <ranro@mellanox.com>
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fb59fc09afc3581a863e0d2d4f513075e4b484f0
Author: Tom Lendacky <thomas.lendacky@amd.com>
Date:   Mon Jul 2 16:36:02 2018 -0500

    x86/bugs: Fix the AMD SSBD usage of the SPEC_CTRL MSR
    
    commit 612bc3b3d4be749f73a513a17d9b3ee1330d3487 upstream.
    
    On AMD, the presence of the MSR_SPEC_CTRL feature does not imply that the
    SSBD mitigation support should use the SPEC_CTRL MSR. Other features could
    have caused the MSR_SPEC_CTRL feature to be set, while a different SSBD
    mitigation option is in place.
    
    Update the SSBD support to check for the actual SSBD features that will
    use the SPEC_CTRL MSR.
    
    Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
    Cc: Borislav Petkov <bpetkov@suse.de>
    Cc: David Woodhouse <dwmw@amazon.co.uk>
    Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Fixes: 6ac2f49edb1e ("x86/bugs: Add AMD's SPEC_CTRL MSR usage")
    Link: http://lkml.kernel.org/r/20180702213602.29202.33151.stgit@tlendack-t1.amdoffice.net
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 081e8056784e40a2355e71b2d9aa97a309691117
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Fri Jun 1 10:59:21 2018 -0400

    x86/bugs: Switch the selection of mitigation from CPU vendor to CPU features
    
    commit 108fab4b5c8f12064ef86e02cb0459992affb30f upstream.
    
    Both AMD and Intel can have SPEC_CTRL_MSR for SSBD.
    
    However AMD also has two more other ways of doing it - which
    are !SPEC_CTRL MSR ways.
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: kvm@vger.kernel.org
    Cc: KarimAllah Ahmed <karahmed@amazon.de>
    Cc: andrew.cooper3@citrix.com
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: David Woodhouse <dwmw@amazon.co.uk>
    Link: https://lkml.kernel.org/r/20180601145921.9500-4-konrad.wilk@oracle.com
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a7f6fbb2824be1c04c58cae1f032e85315ae191c
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Fri Jun 1 10:59:20 2018 -0400

    x86/bugs: Add AMD's SPEC_CTRL MSR usage
    
    commit 6ac2f49edb1ef5446089c7c660017732886d62d6 upstream.
    
    The AMD document outlining the SSBD handling
    124441_AMD64_SpeculativeStoreBypassDisable_Whitepaper_final.pdf
    mentions that if CPUID 8000_0008.EBX[24] is set we should be using
    the SPEC_CTRL MSR (0x48) over the VIRT SPEC_CTRL MSR (0xC001_011f)
    for speculative store bypass disable.
    
    This in effect means we should clear the X86_FEATURE_VIRT_SSBD
    flag so that we would prefer the SPEC_CTRL MSR.
    
    See the document titled:
       124441_AMD64_SpeculativeStoreBypassDisable_Whitepaper_final.pdf
    
    A copy of this document is available at
       https://bugzilla.kernel.org/show_bug.cgi?id=199889
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Tom Lendacky <thomas.lendacky@amd.com>
    Cc: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
    Cc: kvm@vger.kernel.org
    Cc: KarimAllah Ahmed <karahmed@amazon.de>
    Cc: andrew.cooper3@citrix.com
    Cc: Joerg Roedel <joro@8bytes.org>
    Cc: Radim Krčmář <rkrcmar@redhat.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: David Woodhouse <dwmw@amazon.co.uk>
    Cc: Kees Cook <keescook@chromium.org>
    Link: https://lkml.kernel.org/r/20180601145921.9500-3-konrad.wilk@oracle.com
    [bwh: Backported to 3.16:
     - The feature bit is in feature word 11
     - Update feature test in guest_cpuid_has_spec_ctrl() instead of
       svm_{get,set}_msr()
     - Adjust filenames, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 47db935ce22f2fd9f04cf2d9608f080905c01450
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Fri Jun 1 10:59:19 2018 -0400

    x86/bugs: Add AMD's variant of SSB_NO
    
    commit 24809860012e0130fbafe536709e08a22b3e959e upstream.
    
    The AMD document outlining the SSBD handling
    124441_AMD64_SpeculativeStoreBypassDisable_Whitepaper_final.pdf
    mentions that the CPUID 8000_0008.EBX[26] will mean that the
    speculative store bypass disable is no longer needed.
    
    A copy of this document is available at:
        https://bugzilla.kernel.org/show_bug.cgi?id=199889
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Tom Lendacky <thomas.lendacky@amd.com>
    Cc: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
    Cc: kvm@vger.kernel.org
    Cc: andrew.cooper3@citrix.com
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: David Woodhouse <dwmw@amazon.co.uk>
    Link: https://lkml.kernel.org/r/20180601145921.9500-2-konrad.wilk@oracle.com
    [bwh: Backported to 3.16:
     - The feature bit is in feature word 11
     - Adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8288c58eca243a35dcd802cb40ddcae63c3225d4
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Wed Nov 7 17:09:42 2018 +0000

    x86/cpufeatures: Hide AMD-specific speculation flags
    
    Hide the AMD_{IBRS,IBPB,STIBP} flag from /proc/cpuinfo.  This was done
    upstream as part of commit e7c587da1252 "x86/speculation: Use
    synthetic bits for IBRS/IBPB/STIBP".  I already backported that commit
    but accidentally dropped this part.
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit eb29ee5a3873134917a760bf9c416da0a089a0be
Author: Xunlei Pang <xlpang@linux.alibaba.com>
Date:   Wed Jun 20 18:18:33 2018 +0800

    sched/fair: Fix bandwidth timer clock drift condition
    
    commit 512ac999d2755d2b7109e996a76b6fb8b888631d upstream.
    
    I noticed that cgroup task groups constantly get throttled even
    if they have low CPU usage, this causes some jitters on the response
    time to some of our business containers when enabling CPU quotas.
    
    It's very simple to reproduce:
    
      mkdir /sys/fs/cgroup/cpu/test
      cd /sys/fs/cgroup/cpu/test
      echo 100000 > cpu.cfs_quota_us
      echo $$ > tasks
    
    then repeat:
    
      cat cpu.stat | grep nr_throttled  # nr_throttled will increase steadily
    
    After some analysis, we found that cfs_rq::runtime_remaining will
    be cleared by expire_cfs_rq_runtime() due to two equal but stale
    "cfs_{b|q}->runtime_expires" after period timer is re-armed.
    
    The current condition to judge clock drift in expire_cfs_rq_runtime()
    is wrong, the two runtime_expires are actually the same when clock
    drift happens, so this condtion can never hit. The orginal design was
    correctly done by this commit:
    
      a9cf55b28610 ("sched: Expire invalid runtime")
    
    ... but was changed to be the current implementation due to its locking bug.
    
    This patch introduces another way, it adds a new field in both structures
    cfs_rq and cfs_bandwidth to record the expiration update sequence, and
    uses them to figure out if clock drift happens (true if they are equal).
    
    Signed-off-by: Xunlei Pang <xlpang@linux.alibaba.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Ben Segall <bsegall@google.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Fixes: 51f2176d74ac ("sched/fair: Fix unlocked reads of some cfs_b->quota/period")
    Link: http://lkml.kernel.org/r/20180620101834.24455-1-xlpang@linux.alibaba.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    [bwh: Backported to 3.16:
     - Drop changes to other member types in struct cfs_bandwidth
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit daecbf45c7db43b71fe439177481c8747d7b3879
Author: Jon Derrick <jonathan.derrick@intel.com>
Date:   Mon Jul 2 18:45:18 2018 -0400

    ext4: check superblock mapped prior to committing
    
    commit a17712c8e4be4fa5404d20e9cd3b2b21eae7bc56 upstream.
    
    This patch attempts to close a hole leading to a BUG seen with hot
    removals during writes [1].
    
    A block device (NVME namespace in this test case) is formatted to EXT4
    without partitions. It's mounted and write I/O is run to a file, then
    the device is hot removed from the slot. The superblock attempts to be
    written to the drive which is no longer present.
    
    The typical chain of events leading to the BUG:
    ext4_commit_super()
      __sync_dirty_buffer()
        submit_bh()
          submit_bh_wbc()
            BUG_ON(!buffer_mapped(bh));
    
    This fix checks for the superblock's buffer head being mapped prior to
    syncing.
    
    [1] https://www.spinics.net/lists/linux-ext4/msg56527.html
    
    Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 56514b4da97ce4992130e4417dd472f364e6da7c
Author: Pranay Kr. Srivastava <pranjas@gmail.com>
Date:   Mon Jul 4 10:24:52 2016 -0400

    ext4: Fix WARN_ON_ONCE in ext4_commit_super()
    
    commit 4743f83990614af6adb09ea7aa3c37b78c4031ab upstream.
    
    If there are racing calls to ext4_commit_super() it's possible for
    another writeback of the superblock to result in the buffer being
    marked with an error after we check if the buffer is marked as having
    a write error and the buffer up-to-date flag is set again.  If that
    happens mark_buffer_dirty() can end up throwing a WARN_ON_ONCE.
    
    Fix this by moving this check to write before we call
    write_buffer_dirty(), and keeping the buffer locked during this whole
    sequence.
    
    Signed-off-by: Pranay Kr. Srivastava <pranjas@gmail.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 299d81e2c0fd60590e9ac2799172ed3f8dfd1e0b
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Sun Jul 1 12:15:46 2018 +0200

    ahci: Disable LPM on Lenovo 50 series laptops with a too old BIOS
    
    commit 240630e61870e62e39a97225048f9945848fa5f5 upstream.
    
    There have been several reports of LPM related hard freezes about once
    a day on multiple Lenovo 50 series models. Strange enough these reports
    where not disk model specific as LPM issues usually are and some users
    with the exact same disk + laptop where seeing them while other users
    where not seeing these issues.
    
    It turns out that enabling LPM triggers a firmware bug somewhere, which
    has been fixed in later BIOS versions.
    
    This commit adds a new ahci_broken_lpm() function and a new ATA_FLAG_NO_LPM
    for dealing with this.
    
    The ahci_broken_lpm() function contains DMI match info for the 4 models
    which are known to be affected by this and the DMI BIOS date field for
    known good BIOS versions. If the BIOS date is older then the one in the
    table LPM will be disabled and a warning will be printed.
    
    Note the BIOS dates are for known good versions, some older versions may
    work too, but we don't know for sure, the table is using dates from BIOS
    versions for which users have confirmed that upgrading to that version
    makes the problem go away.
    
    Unfortunately I've been unable to get hold of the reporter who reported
    that BIOS version 2.35 fixed the problems on the W541 for him. I've been
    able to verify the DMI_SYS_VENDOR and DMI_PRODUCT_VERSION from an older
    dmidecode, but I don't know the exact BIOS date as reported in the DMI.
    Lenovo keeps a changelog with dates in their release notes, but the
    dates there are the release dates not the build dates which are in DMI.
    So I've chosen to set the date to which we compare to one day past the
    release date of the 2.34 BIOS. I plan to fix this with a follow up
    commit once I've the necessary info.
    
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 528f95c4f743881b750048a74c509c18eea90fc9
Author: Julian Wiedmann <jwi@linux.ibm.com>
Date:   Fri Jun 29 19:45:53 2018 +0200

    s390/qeth: don't clobber buffer on async TX completion
    
    commit ce28867fd20c23cd769e78b4d619c4755bf71a1c upstream.
    
    If qeth_qdio_output_handler() detects that a transmit requires async
    completion, it replaces the pending buffer's metadata object
    (qeth_qdio_out_buffer) so that this queue buffer can be re-used while
    the data is pending completion.
    
    Later when the CQ indicates async completion of such a metadata object,
    qeth_qdio_cq_handler() tries to free any data associated with this
    object (since HW has now completed the transfer). By calling
    qeth_clear_output_buffer(), it erronously operates on the queue buffer
    that _previously_ belonged to this transfer ... but which has been
    potentially re-used several times by now.
    This results in double-free's of the buffer's data, and failing
    transmits as the buffer descriptor is scrubbed in mid-air.
    
    The correct way of handling this situation is to
    1. scrub the queue buffer when it is prepared for re-use, and
    2. later obtain the data addresses from the async-completion notifier
       (ie. the AOB), instead of the queue buffer.
    
    All this only affects qeth devices used for af_iucv HiperTransport.
    
    Fixes: 0da9581ddb0f ("qeth: exploit asynchronous delivery of storage blocks")
    Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7d3cf2631f3d06233d30c52b405038809d36a80f
Author: Alexander Potapenko <glider@google.com>
Date:   Thu Jun 14 12:23:09 2018 +0200

    vt: prevent leaking uninitialized data to userspace via /dev/vcs*
    
    commit 21eff69aaaa0e766ca0ce445b477698dc6a9f55a upstream.
    
    KMSAN reported an infoleak when reading from /dev/vcs*:
    
      BUG: KMSAN: kernel-infoleak in vcs_read+0x18ba/0x1cc0
      Call Trace:
      ...
       kmsan_copy_to_user+0x7a/0x160 mm/kmsan/kmsan.c:1253
       copy_to_user ./include/linux/uaccess.h:184
       vcs_read+0x18ba/0x1cc0 drivers/tty/vt/vc_screen.c:352
       __vfs_read+0x1b2/0x9d0 fs/read_write.c:416
       vfs_read+0x36c/0x6b0 fs/read_write.c:452
      ...
      Uninit was created at:
       kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279
       kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:189
       kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:315
       __kmalloc+0x13a/0x350 mm/slub.c:3818
       kmalloc ./include/linux/slab.h:517
       vc_allocate+0x438/0x800 drivers/tty/vt/vt.c:787
       con_install+0x8c/0x640 drivers/tty/vt/vt.c:2880
       tty_driver_install_tty drivers/tty/tty_io.c:1224
       tty_init_dev+0x1b5/0x1020 drivers/tty/tty_io.c:1324
       tty_open_by_driver drivers/tty/tty_io.c:1959
       tty_open+0x17b4/0x2ed0 drivers/tty/tty_io.c:2007
       chrdev_open+0xc25/0xd90 fs/char_dev.c:417
       do_dentry_open+0xccc/0x1440 fs/open.c:794
       vfs_open+0x1b6/0x2f0 fs/open.c:908
      ...
      Bytes 0-79 of 240 are uninitialized
    
    Consistently allocating |vc_screenbuf| with kzalloc() fixes the problem
    
    Reported-by: syzbot+17a8efdf800000@syzkaller.appspotmail.com
    Signed-off-by: Alexander Potapenko <glider@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f6e18da3f626ffe704a21fb8b35248db11cecd37
Author: Jiri Slaby <jslaby@suse.cz>
Date:   Thu Mar 31 10:08:15 2016 +0200

    tty: vt, get rid of weird source code flow
    
    commit 34902b7f2754e6d890feb0cee34187f1bc75c930 upstream.
    
    Some code in vc_allocate is indented by 4 spaces. It is inside a
    condition. Invert the condition and move the code to the first
    indentation level (using \tab). And insert some empty lines to have
    logical code blocks separated.
    
    Then, instead of freeing in an 'if' false branch, use goto-error
    label as fail path.
    
    Maybe better to look at this patch with diff -w -b.
    
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit eeb3f6b0c0303c8332753656b52d0f453aeebbba
Author: Jiri Slaby <jslaby@suse.cz>
Date:   Thu Mar 31 10:08:14 2016 +0200

    tty: vt, remove reduntant check
    
    commit 182846a00f489849c55d113954f0c4a8a286ca39 upstream.
    
    MAX_NR_CONSOLES and MAX_NR_USER_CONSOLES are both 63 since they were
    introduced in 1.1.54. And since vc_allocate does:
    
    if (currcons >= MAX_NR_CONSOLES)
            return -ENXIO;
    
    if (!vc_cons[currcons].d) {
            if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE))
                    return -EPERM;
    }
    
    the second check is pointless. Remove both the check and the macro
    MAX_NR_USER_CONSOLES.
    
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Reported-by: Fugang Duan <fugang.duan@nxp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c778ed9ee3f15c664162e04a91e7e49271085aa0
Author: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date:   Sat May 26 09:53:14 2018 +0900

    n_tty: Access echo_* variables carefully.
    
    commit ebec3f8f5271139df618ebdf8427e24ba102ba94 upstream.
    
    syzbot is reporting stalls at __process_echoes() [1]. This is because
    since ldata->echo_commit < ldata->echo_tail becomes true for some reason,
    the discard loop is serving as almost infinite loop. This patch tries to
    avoid falling into ldata->echo_commit < ldata->echo_tail situation by
    making access to echo_* variables more carefully.
    
    Since reset_buffer_flags() is called without output_lock held, it should
    not touch echo_* variables. And omit a call to reset_buffer_flags() from
    n_tty_open() by using vzalloc().
    
    Since add_echo_byte() is called without output_lock held, it needs memory
    barrier between storing into echo_buf[] and incrementing echo_head counter.
    echo_buf() needs corresponding memory barrier before reading echo_buf[].
    Lack of handling the possibility of not-yet-stored multi-byte operation
    might be the reason of falling into ldata->echo_commit < ldata->echo_tail
    situation, for if I do WARN_ON(ldata->echo_commit == tail + 1) prior to
    echo_buf(ldata, tail + 1), the WARN_ON() fires.
    
    Also, explicitly masking with buffer for the former "while" loop, and
    use ldata->echo_commit > tail for the latter "while" loop.
    
    [1] https://syzkaller.appspot.com/bug?id=17f23b094cd80df750e5b0f8982c521ee6bcbf40
    
    Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Reported-by: syzbot <syzbot+108696293d7a21ab688f@syzkaller.appspotmail.com>
    Cc: Peter Hurley <peter@hurleysoftware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0028a435a36dd2dfddbd1f58490809e89a9106dd
Author: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date:   Sat May 26 09:53:13 2018 +0900

    n_tty: Fix stall at n_tty_receive_char_special().
    
    commit 3d63b7e4ae0dc5e02d28ddd2fa1f945defc68d81 upstream.
    
    syzbot is reporting stalls at n_tty_receive_char_special() [1]. This is
    because comparison is not working as expected since ldata->read_head can
    change at any moment. Mitigate this by explicitly masking with buffer size
    when checking condition for "while" loops.
    
    [1] https://syzkaller.appspot.com/bug?id=3d7481a346958d9469bebbeb0537d5f056bdd6e8
    
    Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Reported-by: syzbot <syzbot+18df353d7540aa6b5467@syzkaller.appspotmail.com>
    Fixes: bc5a5e3f45d04784 ("n_tty: Don't wrap input buffer indices at buffer size")
    Cc: Peter Hurley <peter@hurleysoftware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5dd1f940f866f626c6b21fb8be7d27dcfe7f41aa
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Fri Jun 22 14:15:47 2018 +0300

    dmaengine: k3dma: Off by one in k3_of_dma_simple_xlate()
    
    commit c4c2b7644cc9a41f17a8cc8904efe3f66ae4c7ed upstream.
    
    The d->chans[] array has d->dma_requests elements so the > should be
    >= here.
    
    Fixes: 8e6152bc660e ("dmaengine: Add hisilicon k3 DMA engine driver")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 05a44cf4e4e4631552d2e8a5168f6d3f1fbb341a
Author: Mike Snitzer <snitzer@redhat.com>
Date:   Tue Jun 26 12:04:23 2018 -0400

    dm thin: handle running out of data space vs concurrent discard
    
    commit a685557fbbc3122ed11e8ad3fa63a11ebc5de8c3 upstream.
    
    Discards issued to a DM thin device can complete to userspace (via
    fstrim) _before_ the metadata changes associated with the discards is
    reflected in the thinp superblock (e.g. free blocks).  As such, if a
    user constructs a test that loops repeatedly over these steps, block
    allocation can fail due to discards not having completed yet:
    1) fill thin device via filesystem file
    2) remove file
    3) fstrim
    
    From initial report, here:
    https://www.redhat.com/archives/dm-devel/2018-April/msg00022.html
    
    "The root cause of this issue is that dm-thin will first remove
    mapping and increase corresponding blocks' reference count to prevent
    them from being reused before DISCARD bios get processed by the
    underlying layers. However. increasing blocks' reference count could
    also increase the nr_allocated_this_transaction in struct sm_disk
    which makes smd->old_ll.nr_allocated +
    smd->nr_allocated_this_transaction bigger than smd->old_ll.nr_blocks.
    In this case, alloc_data_block() will never commit metadata to reset
    the begin pointer of struct sm_disk, because sm_disk_get_nr_free()
    always return an underflow value."
    
    While there is room for improvement to the space-map accounting that
    thinp is making use of: the reality is this test is inherently racey and
    will result in the previous iteration's fstrim's discard(s) completing
    vs concurrent block allocation, via dd, in the next iteration of the
    loop.
    
    No amount of space map accounting improvements will be able to allow
    user's to use a block before a discard of that block has completed.
    
    So the best we can really do is allow DM thinp to gracefully handle such
    aggressive use of all the pool's data by degrading the pool into
    out-of-data-space (OODS) mode.  We _should_ get that behaviour already
    (if space map accounting didn't falsely cause alloc_data_block() to
    believe free space was available).. but short of that we handle the
    current reality that dm_pool_alloc_data_block() can return -ENOSPC.
    
    Reported-by: Dennis Yang <dennisyang@qnap.com>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 81a019d61e3ecb0a63c46879b1788c42a1fa46eb
Author: Keerthy <j-keerthy@ti.com>
Date:   Tue Jun 5 15:37:51 2018 +0530

    ARM: dts: da850: Fix interrups property for gpio
    
    commit 3eb1b955cd7ed1e621ace856710006c2a8a7f231 upstream.
    
    The intc #interrupt-cells is equal to 1. Currently gpio
    node has 2 cells per IRQ which is wrong. Remove the additional
    cell for each of the interrupts.
    
    Signed-off-by: Keerthy <j-keerthy@ti.com>
    Fixes: 2e38b946dc54 ("ARM: davinci: da850: add GPIO DT node")
    Signed-off-by: Sekhar Nori <nsekhar@ti.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 92f0b2168a7be51009be1eb8ac78a572f61e8e24
Author: Alex Vesker <valex@mellanox.com>
Date:   Tue Jun 12 16:14:31 2018 +0300

    net/mlx5: Fix command interface race in polling mode
    
    commit d412c31dae053bf30a1bc15582a9990df297a660 upstream.
    
    The command interface can work in two modes: Events and Polling.
    In the general case, each time we invoke a command, a work is
    queued to handle it.
    
    When working in events, the interrupt handler completes the
    command execution. On the other hand, when working in polling
    mode, the work itself completes it.
    
    Due to a bug in the work handler, a command could have been
    completed by the interrupt handler, while the work handler
    hasn't finished yet, causing the it to complete once again
    if the command interface mode was changed from Events to
    polling after the interrupt handler was called.
    
    mlx5_unload_one()
            mlx5_stop_eqs()
                    // Destroy the EQ before cmd EQ
                    ...cmd_work_handler()
                            write_doorbell()
                            --> EVENT_TYPE_CMD
                                    mlx5_cmd_comp_handler() // First free
                                            free_ent(cmd, ent->idx)
                                            complete(&ent->done)
    
            <-- mlx5_stop_eqs //cmd was complete
                    // move to polling before destroying the last cmd EQ
                    mlx5_cmd_use_polling()
                            cmd->mode = POLL;
    
                    --> cmd_work_handler (continues)
                            if (cmd->mode == POLL)
                                    mlx5_cmd_comp_handler() // Double free
    
    The solution is to store the cmd->mode before writing the doorbell.
    
    Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
    Signed-off-by: Alex Vesker <valex@mellanox.com>
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 809f5539138b8625a71108c7dd026f559240ec84
Author: Alex Vesker <valex@mellanox.com>
Date:   Fri May 25 20:25:59 2018 +0300

    net/mlx5: Fix incorrect raw command length parsing
    
    commit 603b7bcff824740500ddfa001d7a7168b0b38542 upstream.
    
    The NULL character was not set correctly for the string containing
    the command length, this caused failures reading the output of the
    command due to a random length. The fix is to initialize the output
    length string.
    
    Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
    Signed-off-by: Alex Vesker <valex@mellanox.com>
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b78fafe4e865f4f0f8345e664cdb4cf170847f4a
Author: Keith Busch <keith.busch@intel.com>
Date:   Tue Jun 26 09:14:58 2018 -0600

    block: Fix transfer when chunk sectors exceeds max
    
    commit 15bfd21fbc5d35834b9ea383dc458a1f0c9e3434 upstream.
    
    A device may have boundary restrictions where the number of sectors
    between boundaries exceeds its max transfer size. In this case, we need
    to cap the max size to the smaller of the two limits.
    
    Reported-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
    Tested-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
    Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Keith Busch <keith.busch@intel.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3f084a4d285d695b2008533f1b28a5538748e174
Author: Jann Horn <jannh@google.com>
Date:   Mon Jun 25 16:25:44 2018 +0200

    scsi: sg: mitigate read/write abuse
    
    commit 26b5b874aff5659a7e26e5b1997e3df2c41fa7fd upstream.
    
    As Al Viro noted in commit 128394eff343 ("sg_write()/bsg_write() is not fit
    to be called under KERNEL_DS"), sg improperly accesses userspace memory
    outside the provided buffer, permitting kernel memory corruption via
    splice().  But it doesn't just do it on ->write(), also on ->read().
    
    As a band-aid, make sure that the ->read() and ->write() handlers can not
    be called in weird contexts (kernel context or credentials different from
    file opener), like for ib_safe_file_access().
    
    If someone needs to use these interfaces from different security contexts,
    a new interface should be written that goes through the ->ioctl() handler.
    
    I've mostly copypasted ib_safe_file_access() over as sg_safe_file_access()
    because I couldn't find a good common header - please tell me if you know a
    better way.
    
    [mkp: s/_safe_/_check_/]
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Jann Horn <jannh@google.com>
    Acked-by: Douglas Gilbert <dgilbert@interlog.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    [bwh: Backported to 3.16: open-code uaccess_kernel()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit affe5a9da5fd146816a32e18fd163f1f9b19de3a
Author: Jeff Layton <jlayton@primarydata.com>
Date:   Tue Jul 15 12:59:36 2014 -0400

    nfsd: silence sparse warning about accessing credentials
    
    commit ae4b884fc6316b3190be19448cea24b020c1cad6 upstream.
    
    sparse says:
    
        fs/nfsd/auth.c:31:38: warning: incorrect type in argument 1 (different address spaces)
        fs/nfsd/auth.c:31:38:    expected struct cred const *cred
        fs/nfsd/auth.c:31:38:    got struct cred const [noderef] <asn:4>*real_cred
    
    Add a new accessor for the ->real_cred and use that to fetch the
    pointer. Accessing current->real_cred directly is actually quite safe
    since we know that they can't go away so this is mostly a cosmetic fixup
    to silence sparse.
    
    Signed-off-by: Jeff Layton <jlayton@primarydata.com>
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1c3646d7fc89a3df21dc7f5dffb6b05155df2b2e
Author: Jann Horn <jannh@google.com>
Date:   Mon Jun 25 17:22:00 2018 +0200

    netfilter: nf_log: don't hold nf_log_mutex during user access
    
    commit ce00bf07cc95a57cd20b208e02b3c2604e532ae8 upstream.
    
    The old code would indefinitely block other users of nf_log_mutex if
    a userspace access in proc_dostring() blocked e.g. due to a userfaultfd
    region. Fix it by moving proc_dostring() out of the locked region.
    
    This is a followup to commit 266d07cb1c9a ("netfilter: nf_log: fix
    sleeping function called from invalid context"), which changed this code
    from using rcu_read_lock() to taking nf_log_mutex.
    
    Fixes: 266d07cb1c9a ("netfilter: nf_log: fix sleeping function calle[...]")
    Signed-off-by: Jann Horn <jannh@google.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6fe01a7b67fa0a78fd9c216097a4fe329a03e4d4
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Sun Jun 24 11:23:53 2018 +0300

    RDMA/uverbs: Fix slab-out-of-bounds in ib_uverbs_ex_create_flow
    
    commit 4fae7f170416f970e5655f7e945ce69286b1c4ff upstream.
    
    The check of cmd.flow_attr.size should check into account the size of the
    reserved field (2 bytes), otherwise user can provide a size which will
    cause a slab-out-of-bounds warning below.
    
    ==================================================================
    BUG: KASAN: slab-out-of-bounds in ib_uverbs_ex_create_flow+0x1740/0x1d00
    Read of size 2 at addr ffff880068dff1a6 by task syz-executor775/269
    
    CPU: 0 PID: 269 Comm: syz-executor775 Not tainted 4.18.0-rc1+ #245
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
    rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014
    Call Trace:
     dump_stack+0xef/0x17e
     print_address_description+0x83/0x3b0
     kasan_report+0x18d/0x4d0
     ib_uverbs_ex_create_flow+0x1740/0x1d00
     ib_uverbs_write+0x923/0x1010
     __vfs_write+0x10d/0x720
     vfs_write+0x1b0/0x550
     ksys_write+0xc6/0x1a0
     do_syscall_64+0xa7/0x590
     entry_SYSCALL_64_after_hwframe+0x49/0xbe
    RIP: 0033:0x433899
    Code: fd ff 48 81 c4 80 00 00 00 e9 f1 fe ff ff 0f 1f 00 48 89 f8 48 89
    f7 48 89 d6 48 89 ca 4d 89 c2 4d
    89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 3b 91 fd ff c3 66
    2e 0f 1f 84 00 00 00 00
    RSP: 002b:00007ffc2724db58 EFLAGS: 00000217 ORIG_RAX: 0000000000000001
    RAX: ffffffffffffffda RBX: 0000000020006880 RCX: 0000000000433899
    RDX: 00000000000000e0 RSI: 0000000020002480 RDI: 0000000000000003
    RBP: 00000000006d7018 R08: 00000000004002f8 R09: 00000000004002f8
    R10: 00000000004002f8 R11: 0000000000000217 R12: 0000000000000000
    
    R13: 000000000040cd20 R14: 000000000040cdb0 R15: 0000000000000006
    
    Allocated by task 269:
     kasan_kmalloc+0xa0/0xd0
     __kmalloc+0x1a9/0x510
     ib_uverbs_ex_create_flow+0x26c/0x1d00
     ib_uverbs_write+0x923/0x1010
     __vfs_write+0x10d/0x720
     vfs_write+0x1b0/0x550
     ksys_write+0xc6/0x1a0
     do_syscall_64+0xa7/0x590
     entry_SYSCALL_64_after_hwframe+0x49/0xbe
    
    Freed by task 0:
     __kasan_slab_free+0x12e/0x180
     kfree+0x159/0x630
     detach_buf+0x559/0x7a0
     virtqueue_get_buf_ctx+0x3cc/0xab0
     virtblk_done+0x1eb/0x3d0
     vring_interrupt+0x16d/0x2b0
     __handle_irq_event_percpu+0x10a/0x980
     handle_irq_event_percpu+0x77/0x190
     handle_irq_event+0xc6/0x1a0
     handle_edge_irq+0x211/0xd80
     handle_irq+0x3d/0x60
     do_IRQ+0x9b/0x220
    
    The buggy address belongs to the object at ffff880068dff180
     which belongs to the cache kmalloc-64 of size 64
    The buggy address is located 38 bytes inside of
     64-byte region [ffff880068dff180, ffff880068dff1c0)
    The buggy address belongs to the page:
    page:ffffea0001a37fc0 count:1 mapcount:0 mapping:ffff88006c401780
    index:0x0
    flags: 0x4000000000000100(slab)
    raw: 4000000000000100 ffffea0001a31100 0000001100000011 ffff88006c401780
    raw: 0000000000000000 00000000802a002a 00000001ffffffff 0000000000000000
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff880068dff080: fb fb fb fb fc fc fc fc fb fb fb fb fb fb fb fb
     ffff880068dff100: fc fc fc fc fb fb fb fb fb fb fb fb fc fc fc fc
    >ffff880068dff180: 00 00 00 00 07 fc fc fc fc fc fc fc fb fb fb fb
                                   ^
     ffff880068dff200: fb fb fb fb fc fc fc fc 00 00 00 00 00 00 fc fc
     ffff880068dff280: fc fc fc fc 00 00 00 00 00 00 00 00 fc fc fc fc
    ==================================================================
    
    Fixes: f88482743872 ("IB/core: clarify overflow/underflow checks on ib_create/destroy_flow")
    Cc: syzkaller <syzkaller@googlegroups.com>
    Reported-by: Noa Osherovich <noaos@mellanox.com>
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 09b4364b421f29ebd86dd1d1841869bedae110ab
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Sun Jun 24 11:23:42 2018 +0300

    RDMA/uverbs: Protect from attempts to create flows on unsupported QP
    
    commit 940efcc8889f0d15567eb07fc9fd69b06e366aa5 upstream.
    
    Flows can be created on UD and RAW_PACKET QP types. Attempts to provide
    other QP types as an input causes to various unpredictable failures.
    
    The reason is that in order to support all various types (e.g. XRC), we
    are supposed to use real_qp handle and not qp handle and expect to
    driver/FW to fail such (XRC) flows. The simpler and safer variant is to
    ban all QP types except UD and RAW_PACKET, instead of relying on
    driver/FW.
    
    Fixes: 436f2ad05a0b ("IB/core: Export ib_create/destroy_flow through uverbs")
    Cc: syzkaller <syzkaller@googlegroups.com>
    Reported-by: Noa Osherovich <noaos@mellanox.com>
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d9399c9778efa8cf9d071b6e8b79214405fe1325
Author: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Date:   Sat May 19 14:23:54 2018 +0200

    X.509: unpack RSA signatureValue field from BIT STRING
    
    commit b65c32ec5a942ab3ada93a048089a938918aba7f upstream.
    
    The signatureValue field of a X.509 certificate is encoded as a BIT STRING.
    For RSA signatures this BIT STRING is of so-called primitive subtype, which
    contains a u8 prefix indicating a count of unused bits in the encoding.
    
    We have to strip this prefix from signature data, just as we already do for
    key data in x509_extract_key_data() function.
    
    This wasn't noticed earlier because this prefix byte is zero for RSA key
    sizes divisible by 8. Since BIT STRING is a big-endian encoding adding zero
    prefixes has no bearing on its value.
    
    The signature length, however was incorrect, which is a problem for RSA
    implementations that need it to be exactly correct (like AMD CCP).
    
    Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
    Fixes: c26fd69fa009 ("X.509: Add a crypto key parser for binary (DER) X.509 certificates")
    Signed-off-by: James Morris <james.morris@microsoft.com>
    [bwh: Backported to 3.16:
     - x509_certificate::sig is a structure, not a pointer
     - public_key_signature::pkey_algo is an enumeration type, not a string]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 78510032d64a9b6c96518453a8de7f1c3b3f5a37
Author: Laura Abbott <labbott@redhat.com>
Date:   Mon Jun 11 11:06:53 2018 -0700

    staging: android: ion: Return an ERR_PTR in ion_map_kernel
    
    commit 0a2bc00341dcfcc793c0dbf4f8d43adf60458b05 upstream.
    
    The expected return value from ion_map_kernel is an ERR_PTR. The error
    path for a vmalloc failure currently just returns NULL, triggering
    a warning in ion_buffer_kmap_get. Encode the vmalloc failure as an ERR_PTR.
    
    Reported-by: syzbot+55b1d9f811650de944c6@syzkaller.appspotmail.com
    Signed-off-by: Laura Abbott <labbott@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 67eed8878fa2f0aeecbeb9d8dae9a2616ac2441a
Author: Florian Westphal <fw@strlen.de>
Date:   Mon Jun 25 14:00:07 2018 +0200

    xfrm: free skb if nlsk pointer is NULL
    
    commit 86126b77dcd551ce223e7293bb55854e3df05646 upstream.
    
    nlmsg_multicast() always frees the skb, so in case we cannot call
    it we must do that ourselves.
    
    Fixes: 21ee543edc0dea ("xfrm: fix race between netns cleanup and state expire notification")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 08e2fceaf88fc286ef2c6d3f97684ff6eba77fe9
Author: Houston Yaroschoff <hstn@4ever3.net>
Date:   Mon Jun 11 12:39:09 2018 +0200

    usb: cdc_acm: Add quirk for Uniden UBC125 scanner
    
    commit 4a762569a2722b8a48066c7bacf0e1dc67d17fa1 upstream.
    
    Uniden UBC125 radio scanner has USB interface which fails to work
    with cdc_acm driver:
      usb 1-1.5: new full-speed USB device number 4 using xhci_hcd
      cdc_acm 1-1.5:1.0: Zero length descriptor references
      cdc_acm: probe of 1-1.5:1.0 failed with error -22
    
    Adding the NO_UNION_NORMAL quirk for the device fixes the issue:
      usb 1-4: new full-speed USB device number 15 using xhci_hcd
      usb 1-4: New USB device found, idVendor=1965, idProduct=0018
      usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
      usb 1-4: Product: UBC125XLT
      usb 1-4: Manufacturer: Uniden Corp.
      usb 1-4: SerialNumber: 0001
      cdc_acm 1-4:1.0: ttyACM0: USB ACM device
    
    `lsusb -v` of the device:
    
      Bus 001 Device 015: ID 1965:0018 Uniden Corporation
      Device Descriptor:
        bLength                18
        bDescriptorType         1
        bcdUSB               2.00
        bDeviceClass            2 Communications
        bDeviceSubClass         0
        bDeviceProtocol         0
        bMaxPacketSize0        64
        idVendor           0x1965 Uniden Corporation
        idProduct          0x0018
        bcdDevice            0.01
        iManufacturer           1 Uniden Corp.
        iProduct                2 UBC125XLT
        iSerial                 3 0001
        bNumConfigurations      1
        Configuration Descriptor:
          bLength                 9
          bDescriptorType         2
          wTotalLength           48
          bNumInterfaces          2
          bConfigurationValue     1
          iConfiguration          0
          bmAttributes         0x80
            (Bus Powered)
          MaxPower              500mA
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        0
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      0 None
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x87  EP 7 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0008  1x 8 bytes
              bInterval              10
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        1
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x81  EP 1 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x02  EP 2 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               0
      Device Status:     0x0000
        (Bus Powered)
    
    Signed-off-by: Houston Yaroschoff <hstn@4ever3.net>
    Acked-by: Oliver Neukum <oneukum@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 88fa5aa1ae0d0861ad719d2d15feca5464a02685
Author: Takashi Iwai <tiwai@suse.de>
Date:   Mon Jun 25 11:09:11 2018 +0200

    ALSA: timer: Fix UBSAN warning at SNDRV_TIMER_IOCTL_NEXT_DEVICE ioctl
    
    commit b41f794f284966fd6ec634111e3b40d241389f96 upstream.
    
    The kernel may spew a WARNING about UBSAN undefined behavior at
    handling ALSA timer ioctl SNDRV_TIMER_IOCTL_NEXT_DEVICE:
    
    UBSAN: Undefined behaviour in sound/core/timer.c:1524:19
    signed integer overflow:
    2147483647 + 1 cannot be represented in type 'int'
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x122/0x1c8 lib/dump_stack.c:113
     ubsan_epilogue+0x12/0x86 lib/ubsan.c:159
     handle_overflow+0x1c2/0x21f lib/ubsan.c:190
     __ubsan_handle_add_overflow+0x2a/0x31 lib/ubsan.c:198
     snd_timer_user_next_device sound/core/timer.c:1524 [inline]
     __snd_timer_user_ioctl+0x204d/0x2520 sound/core/timer.c:1939
     snd_timer_user_ioctl+0x67/0x95 sound/core/timer.c:1994
     ....
    
    It happens only when a value with INT_MAX is passed, as we're
    incrementing it unconditionally.  So the fix is trivial, check the
    value with INT_MAX.  Although the bug itself is fairly harmless, it's
    better to fix it so that fuzzers won't hit this again later.
    
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200213
    Reported-and-tested-by: Team OWL337 <icytxw@gmail.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    [bwh: Backported to 3.16: adjust context, indentation]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 32db44766c20edcb7705ca9693950102987356a5
Author: Tommi Rantala <tommi.t.rantala@nokia.com>
Date:   Thu Jun 21 09:30:47 2018 +0300

    xfrm: fix missing dst_release() after policy blocking lbcast and multicast
    
    commit 8cc88773855f988d6a3bbf102bbd9dd9c828eb81 upstream.
    
    Fix missing dst_release() when local broadcast or multicast traffic is
    xfrm policy blocked.
    
    For IPv4 this results to dst leak: ip_route_output_flow() allocates
    dst_entry via __ip_route_output_key() and passes it to
    xfrm_lookup_route(). xfrm_lookup returns ERR_PTR(-EPERM) that is
    propagated. The dst that was allocated is never released.
    
    IPv4 local broadcast testcase:
     ping -b 192.168.1.255 &
     sleep 1
     ip xfrm policy add src 0.0.0.0/0 dst 192.168.1.255/32 dir out action block
    
    IPv4 multicast testcase:
     ping 224.0.0.1 &
     sleep 1
     ip xfrm policy add src 0.0.0.0/0 dst 224.0.0.1/32 dir out action block
    
    For IPv6 the missing dst_release() causes trouble e.g. when used in netns:
     ip netns add TEST
     ip netns exec TEST ip link set lo up
     ip link add dummy0 type dummy
     ip link set dev dummy0 netns TEST
     ip netns exec TEST ip addr add fd00::1111 dev dummy0
     ip netns exec TEST ip link set dummy0 up
     ip netns exec TEST ping -6 -c 5 ff02::1%dummy0 &
     sleep 1
     ip netns exec TEST ip xfrm policy add src ::/0 dst ff02::1 dir out action block
     wait
     ip netns del TEST
    
    After netns deletion we see:
    [  258.239097] unregister_netdevice: waiting for lo to become free. Usage count = 2
    [  268.279061] unregister_netdevice: waiting for lo to become free. Usage count = 2
    [  278.367018] unregister_netdevice: waiting for lo to become free. Usage count = 2
    [  288.375259] unregister_netdevice: waiting for lo to become free. Usage count = 2
    
    Fixes: ac37e2515c1a ("xfrm: release dst_orig in case of error in xfrm_lookup()")
    Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6d4f790b141a25f7ea8c0f4bd3c806287081a8bb
Author: Linus Lüssing <linus.luessing@c0d3.blue>
Date:   Thu Jun 7 00:46:24 2018 +0200

    batman-adv: Fix multicast TT issues with bogus ROAM flags
    
    commit a44ebeff6bbd6ef50db41b4195fca87b21aefd20 upstream.
    
    When a (broken) node wrongly sends multicast TT entries with a ROAM
    flag then this causes any receiving node to drop all entries for the
    same multicast MAC address announced by other nodes, leading to
    packet loss.
    
    Fix this DoS vector by only storing TT sync flags. For multicast TT
    non-sync'ing flag bits like ROAM are unused so far anyway.
    
    Fixes: 1d8ab8d3c176 ("batman-adv: Modified forwarding behaviour for multicast packets")
    Reported-by: Leonardo Mörlein <me@irrelefant.net>
    Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
    Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ed85c06037ffaa6476482e5013ca728074e40893
Author: Simon Wunderlich <sw@simonwunderlich.de>
Date:   Wed Aug 26 16:33:34 2015 +0200

    batman-adv: unify flags access style in tt global add
    
    commit ad7e2c466d8b0a7056cd248e1df6bb7296e014f7 upstream.
    
    This should slightly improve readability
    
    Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
    Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
    Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b5d931b3fb01ee58e34d986ebdc78df54ddde284
Author: Linus Lüssing <linus.luessing@c0d3.blue>
Date:   Thu Jun 7 00:46:23 2018 +0200

    batman-adv: Avoid storing non-TT-sync flags on singular entries too
    
    commit 4a519b83da16927fb98fd32b0f598e639d1f1859 upstream.
    
    Since commit 54e22f265e87 ("batman-adv: fix TT sync flag inconsistencies")
    TT sync flags and TT non-sync'd flags are supposed to be stored
    separately.
    
    The previous patch missed to apply this separation on a TT entry with
    only a single TT orig entry.
    
    This is a minor fix because with only a single TT orig entry the DDoS
    issue the former patch solves does not apply.
    
    Fixes: 54e22f265e87 ("batman-adv: fix TT sync flag inconsistencies")
    Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5da0088b1d1280742ea51c767a50ee6facabe391
Author: Sven Eckelmann <sven@narfation.org>
Date:   Fri Jun 1 19:24:24 2018 +0200

    batman-adv: Fix debugfs path for renamed softif
    
    commit 6da7be7d24b2921f8215473ba7552796dff05fe1 upstream.
    
    batman-adv is creating special debugfs directories in the init
    net_namespace for each created soft-interface (batadv net_device). But it
    is possible to rename a net_device to a completely different name then the
    original one.
    
    It can therefore happen that a user registers a new batadv net_device with
    the name "bat0". batman-adv is then also adding a new directory under
    $debugfs/batman-adv/ with the name "wlan0".
    
    The user then decides to rename this device to "bat1" and registers a
    different batadv device with the name "bat0". batman-adv will then try to
    create a directory with the name "bat0" under $debugfs/batman-adv/ again.
    But there already exists one with this name under this path and thus this
    fails. batman-adv will detect a problem and rollback the registering of
    this device.
    
    batman-adv must therefore take care of renaming the debugfs directories for
    soft-interfaces whenever it detects such a net_device rename.
    
    Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 450d83da63134ff6b4457348a8b23dd3de67def4
Author: Sven Eckelmann <sven@narfation.org>
Date:   Fri Jun 1 19:24:23 2018 +0200

    batman-adv: Fix debugfs path for renamed hardif
    
    commit 36dc621ceca1be3ec885aeade5fdafbbcc452a6d upstream.
    
    batman-adv is creating special debugfs directories in the init
    net_namespace for each valid hard-interface (net_device). But it is
    possible to rename a net_device to a completely different name then the
    original one.
    
    It can therefore happen that a user registers a new net_device which gets
    the name "wlan0" assigned by default. batman-adv is also adding a new
    directory under $debugfs/batman-adv/ with the name "wlan0".
    
    The user then decides to rename this device to "wl_pri" and registers a
    different device. The kernel may now decide to use the name "wlan0" again
    for this new device. batman-adv will detect it as a valid net_device and
    tries to create a directory with the name "wlan0" under
    $debugfs/batman-adv/. But there already exists one with this name under
    this path and thus this fails. batman-adv will detect a problem and
    rollback the registering of this device.
    
    batman-adv must therefore take care of renaming the debugfs directories
    for hard-interfaces whenever it detects such a net_device rename.
    
    Fixes: 5bc7c1eb44f2 ("batman-adv: add debugfs structure for information per interface")
    Reported-by: John Soros <sorosj@gmail.com>
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1ccc208c7e2a8d8cc8cf8fe1225b4344d2612245
Author: Markus Pargmann <mpa@pengutronix.de>
Date:   Fri Dec 26 12:41:18 2014 +0100

    batman-adv: debugfs, avoid compiling for !DEBUG_FS
    
    commit 9bb218828c8f4fa6587af93e248903c96ce469d0 upstream.
    
    Normally the debugfs framework will return error pointer with -ENODEV
    for function calls when DEBUG_FS is not set.
    
    batman does not notice this error code and continues trying to create
    debugfs files and executes more code. We can avoid this code execution
    by disabling compiling debugfs.c when DEBUG_FS is not set.
    
    Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
    Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 64ddf7a1a21c89f3a1c0a744bcf1ccbe33547685
Author: Hangbin Liu <liuhangbin@gmail.com>
Date:   Thu Jun 21 19:49:36 2018 +0800

    ipv6: mcast: fix unsolicited report interval after receiving querys
    
    commit 6c6da92808442908287fae8ebb0ca041a52469f4 upstream.
    
    After recieving MLD querys, we update idev->mc_maxdelay with max_delay
    from query header. This make the later unsolicited reports have the same
    interval with mc_maxdelay, which means we may send unsolicited reports with
    long interval time instead of default configured interval time.
    
    Also as we will not call ipv6_mc_reset() after device up. This issue will
    be there even after leave the group and join other groups.
    
    Fixes: fc4eba58b4c14 ("ipv6: make unsolicited report intervals configurable for mld")
    Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 81aca22428a6763042cf1bcf7d888ff35f528cb1
Author: Jason Wang <jasowang@redhat.com>
Date:   Thu Jun 21 13:11:31 2018 +0800

    vhost_net: validate sock before trying to put its fd
    
    commit b8f1f65882f07913157c44673af7ec0b308d03eb upstream.
    
    Sock will be NULL if we pass -1 to vhost_net_set_backend(), but when
    we meet errors during ubuf allocation, the code does not check for
    NULL before calling sockfd_put(), this will lead NULL
    dereferencing. Fixing by checking sock pointer before.
    
    Fixes: bab632d69ee4 ("vhost: vhost TX zero-copy support")
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fca8bb1d7fe1ad811cb6affc9e257864d8d88fc0
Author: Geert Uytterhoeven <geert@linux-m68k.org>
Date:   Fri Jun 22 16:33:57 2018 +0200

    time: Make sure jiffies_to_msecs() preserves non-zero time periods
    
    commit abcbcb80cd09cd40f2089d912764e315459b71f7 upstream.
    
    For the common cases where 1000 is a multiple of HZ, or HZ is a multiple of
    1000, jiffies_to_msecs() never returns zero when passed a non-zero time
    period.
    
    However, if HZ > 1000 and not an integer multiple of 1000 (e.g. 1024 or
    1200, as used on alpha and DECstation), jiffies_to_msecs() may return zero
    for small non-zero time periods.  This may break code that relies on
    receiving back a non-zero value.
    
    jiffies_to_usecs() does not need such a fix: one jiffy can only be less
    than one µs if HZ > 1000000, and such large values of HZ are already
    rejected at build time, twice:
    
      - include/linux/jiffies.h does #error if HZ >= 12288,
      - kernel/time/time.c has BUILD_BUG_ON(HZ > USEC_PER_SEC).
    
    Broken since forever.
    
    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Cc: John Stultz <john.stultz@linaro.org>
    Cc: Stephen Boyd <sboyd@kernel.org>
    Cc: linux-alpha@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Link: https://lkml.kernel.org/r/20180622143357.7495-1-geert@linux-m68k.org
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b1f46a545058d7c91b7e6582aa92a73e9cffb174
Author: Borislav Petkov <bp@suse.de>
Date:   Fri Jun 22 11:54:28 2018 +0200

    x86/mce: Do not overwrite MCi_STATUS in mce_no_way_out()
    
    commit 1f74c8a64798e2c488f86efc97e308b85fb7d7aa upstream.
    
    mce_no_way_out() does a quick check during #MC to see whether some of
    the MCEs logged would require the kernel to panic immediately. And it
    passes a struct mce where MCi_STATUS gets written.
    
    However, after having saved a valid status value, the next iteration
    of the loop which goes over the MCA banks on the CPU, overwrites the
    valid status value because we're using struct mce as storage instead of
    a temporary variable.
    
    Which leads to MCE records with an empty status value:
    
      mce: [Hardware Error]: CPU 0: Machine Check Exception: 6 Bank 0: 0000000000000000
      mce: [Hardware Error]: RIP 10:<ffffffffbd42fbd7> {trigger_mce+0x7/0x10}
    
    In order to prevent the loss of the status register value, return
    immediately when severity is a panic one so that we can panic
    immediately with the first fatal MCE logged. This is also the intention
    of this function and not to noodle over the banks while a fatal MCE is
    already logged.
    
    Tony: read the rest of the MCA bank to populate the struct mce fully.
    
    Suggested-by: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lkml.kernel.org/r/20180622095428.626-8-bp@alien8.de
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a58557e381421112e10705dca181364e2f6be494
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri Jun 22 12:17:45 2018 +0200

    ALSA: hda/realtek - Add a quirk for FSC ESPRIMO U9210
    
    commit 275ec0cb946cb75ac8977f662e608fce92f8b8a8 upstream.
    
    Fujitsu Seimens ESPRIMO Mobile U9210 requires the same fixup as H270
    for the correct pin configs.
    
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200107
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9e1e1062a441b8e63cc0847f8a5b06a01327d5bd
Author: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Date:   Wed Jun 6 12:13:30 2018 +0200

    mtd: cfi_cmdset_0002: Avoid walking all chips when unlocking.
    
    commit f1ce87f6080b1dda7e7b1eda3da332add19d87b9 upstream.
    
    cfi_ppb_unlock() walks all flash chips when unlocking sectors,
    avoid walking chips unaffected by the unlock operation.
    
    Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
    Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a6ddc64a964e9519698479846e88e454b028f900
Author: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Date:   Thu Jun 21 13:29:44 2018 -0400

    xen: Remove unnecessary BUG_ON from __unbind_from_irq()
    
    commit eef04c7b3786ff0c9cb1019278b6c6c2ea0ad4ff upstream.
    
    Commit 910f8befdf5b ("xen/pirq: fix error path cleanup when binding
    MSIs") fixed a couple of errors in error cleanup path of
    xen_bind_pirq_msi_to_irq(). This cleanup allowed a call to
    __unbind_from_irq() with an unbound irq, which would result in
    triggering the BUG_ON there.
    
    Since there is really no reason for the BUG_ON (xen_free_irq() can
    operate on unbound irqs) we can remove it.
    
    Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8b865386ca6f961a406957a6a259cea86d29529d
Author: ??? <kt.liao@emc.com.tw>
Date:   Thu Jun 21 17:15:32 2018 -0700

    Input: elantech - fix V4 report decoding for module with middle key
    
    commit e0ae2519ca004a628fa55aeef969c37edce522d3 upstream.
    
    Some touchpad has middle key and it will be indicated in bit 2 of packet[0].
    We need to fix V4 formation's byte mask to prevent error decoding.
    
    Signed-off-by: KT Liao <kt.liao@emc.com.tw>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 298d3d3a67df150444928ac7dc4db7807b09b3a3
Author: Aaron Ma <aaron.ma@canonical.com>
Date:   Thu Jun 21 17:14:01 2018 -0700

    Input: elantech - enable middle button of touchpads on ThinkPad P52
    
    commit 24bb555e6e46d96e2a954aa0295029a81cc9bbaa upstream.
    
    PNPID is better way to identify the type of touchpads.
    Enable middle button support on 2 types of touchpads on Lenovo P52.
    
    Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
    Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f94b853936471041be7991f7a3a14392545ceeee
Author: Ulrik De Bie <ulrik.debie-os@e2big.org>
Date:   Thu Nov 13 17:45:12 2014 -0800

    Input: elantech - report the middle button of the touchpad
    
    commit f386474e12a560e005ec7899e78f51f6bdc3cf41 upstream.
    
    In the past, no elantech was known with 3 touchpad mouse buttons.
    Fujitsu H730 is the first known elantech with a middle button. This commit
    enables this middle button. For backwards compatibility, the Fujitsu is
    detected via DMI, and only for this one 3 buttons will be announced.
    
    Reported-by: Stefan Valouch <stefan@valouch.com>
    Signed-off-by: Ulrik De Bie <ulrik.debie-os@e2big.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dcf5984d04e27acd3d117fa556d185c4c065100c
Author: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Date:   Wed Jun 6 12:13:29 2018 +0200

    mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary
    
    commit 0cd8116f172eed018907303dbff5c112690eeb91 upstream.
    
    The "sector is in requested range" test used to determine whether
    sectors should be re-locked or not is done on a variable that is reset
    everytime we cross a chip boundary, which can lead to some blocks being
    re-locked while the caller expect them to be unlocked.
    Fix the check to make sure this cannot happen.
    
    Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
    Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c977eae347e34fe14e2ece77a0b1cd9a58e0fdfd
Author: Ross Lagerwall <ross.lagerwall@citrix.com>
Date:   Thu Jun 21 14:00:21 2018 +0100

    xen-netfront: Update features after registering netdev
    
    commit 45c8184c1bed1ca8a7f02918552063a00b909bf5 upstream.
    
    Update the features after calling register_netdev() otherwise the
    device features are not set up correctly and it not possible to change
    the MTU of the device. After this change, the features reported by
    ethtool match the device's features before the commit which introduced
    the issue and it is possible to change the device's MTU.
    
    Fixes: f599c64fdf7d ("xen-netfront: Fix race between device setup and open")
    Reported-by: Liam Shepherd <liam@dancer.es>
    Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 146585a66a796b62e883052dfd6ffaad2c05abd1
Author: Ross Lagerwall <ross.lagerwall@citrix.com>
Date:   Thu Jun 21 14:00:20 2018 +0100

    xen-netfront: Fix mismatched rtnl_unlock
    
    commit cb257783c2927b73614b20f915a91ff78aa6f3e8 upstream.
    
    Fixes: f599c64fdf7d ("xen-netfront: Fix race between device setup and open")
    Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fd437f09c25ecf6af30e2c4c5ce876cd30e66c53
Author: Ross Lagerwall <ross.lagerwall@citrix.com>
Date:   Thu Jan 11 09:36:38 2018 +0000

    xen-netfront: Fix race between device setup and open
    
    commit f599c64fdf7d9c108e8717fb04bc41c680120da4 upstream.
    
    When a netfront device is set up it registers a netdev fairly early on,
    before it has set up the queues and is actually usable. A userspace tool
    like NetworkManager will immediately try to open it and access its state
    as soon as it appears. The bug can be reproduced by hotplugging VIFs
    until the VM runs out of grant refs. It registers the netdev but fails
    to set up any queues (since there are no more grant refs). In the
    meantime, NetworkManager opens the device and the kernel crashes trying
    to access the queues (of which there are none).
    
    Fix this in two ways:
    * For initial setup, register the netdev much later, after the queues
    are setup. This avoids the race entirely.
    * During a suspend/resume cycle, the frontend reconnects to the backend
    and the queues are recreated. It is possible (though highly unlikely) to
    race with something opening the device and accessing the queues after
    they have been destroyed but before they have been recreated. Extend the
    region covered by the rtnl semaphore to protect against this race. There
    is a possibility that we fail to recreate the queues so check for this
    in the open function.
    
    Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fefbe65bf51451aaa4f547d2f38303379523d51f
Author: Vitaly Kuznetsov <vkuznets@redhat.com>
Date:   Thu May 11 13:58:06 2017 +0200

    xen-netfront: avoid crashing on resume after a failure in talk_to_netback()
    
    commit d86b5672b1adb98b4cdd6fbf0224bbfb03db6e2e upstream.
    
    Unavoidable crashes in netfront_resume() and netback_changed() after a
    previous fail in talk_to_netback() (e.g. when we fail to read MAC from
    xenstore) were discovered. The failure path in talk_to_netback() does
    unregister/free for netdev but we don't reset drvdata and we try accessing
    it after resume.
    
    Fix the bug by removing the whole xen device completely with
    device_unregister(), this guarantees we won't have any calls into netfront
    after a failure.
    
    Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c14f2074fd091db7d95e912bff17efd595c569fe
Author: Ross Lagerwall <ross.lagerwall@citrix.com>
Date:   Wed Feb 8 10:57:37 2017 +0000

    xen-netfront: Improve error handling during initialization
    
    commit e2e004acc7cbe3c531e752a270a74e95cde3ea48 upstream.
    
    This fixes a crash when running out of grant refs when creating many
    queues across many netdevs.
    
    * If creating queues fails (i.e. there are no grant refs available),
    call xenbus_dev_fatal() to ensure that the xenbus device is set to the
    closed state.
    * If no queues are created, don't call xennet_disconnect_backend as
    netdev->real_num_tx_queues will not have been set correctly.
    * If setup_netfront() fails, ensure that all the queues created are
    cleaned up, not just those that have been set up.
    * If any queues were set up and an error occurs, call
    xennet_destroy_queues() to clean up the napi context.
    * If any fatal error occurs, unregister and destroy the netdev to avoid
    leaving around a half setup network device.
    
    Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 65bbb3b26b5a0452c72861789f76de58fe3bf525
Author: Chas Williams <3chas3@gmail.com>
Date:   Wed Aug 19 19:14:20 2015 -0400

    net/xen-netfront: only clean up queues if present
    
    commit 9a873c71e91cabf4c10fd9bbd8358c22deaf6c9e upstream.
    
    If you simply load and unload the module without starting the interfaces,
    the queues are never created and you get a bad pointer dereference.
    
    Signed-off-by: Chas Williams <3chas3@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d9f6ca6cda4fa1cc549e5ee0bb926f979f292d1f
Author: Li, Liang Z <liang.z.li@intel.com>
Date:   Sat Jun 27 07:17:26 2015 +0800

    xen-netfront: Remove the meaningless code
    
    commit 905726c1c5a3ca620ba7d73c78eddfb91de5ce28 upstream.
    
    The function netif_set_real_num_tx_queues() will return -EINVAL if
    the second parameter < 1, so call this function with the second
    parameter set to 0 is meaningless.
    
    Signed-off-by: Liang Li <liang.z.li@intel.com>
    Reviewed-by: David Vrabel <david.vrabel@citrix.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a07703b41baf5580f1df824dbf36a293ef87f97f
Author: David Vrabel <david.vrabel@citrix.com>
Date:   Wed May 27 15:46:10 2015 +0100

    xen-netfront: properly destroy queues when removing device
    
    commit ad0681185770716523c81b156c44b9804d7b8ed2 upstream.
    
    xennet_remove() freed the queues before freeing the netdevice which
    results in a use-after-free when free_netdev() tries to delete the
    napi instances that have already been freed.
    
    Fix this by fully destroy the queues (which includes deleting the napi
    instances) before freeing the netdevice.
    
    Signed-off-by: David Vrabel <david.vrabel@citrix.com>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: I already backported most of this along with
     the later commit 74470954857c "xen-netfront: Delete rx_refill_timer in
      xennet_disconnect_backend()"; don't move the del_timer_sync() again.]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c65cad893f4d825b360949c75f400b478bfa490b
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Feb 4 14:38:55 2015 +0100

    xen-netfront: Use static attribute groups for sysfs entries
    
    commit 27b917e54bed7156c2b0249969ace34a5f585626 upstream.
    
    Instead of manual calls of device_create_file() and
    device_remove_files(), assign the static attribute groups to netdev
    groups array.  This simplifies the code and avoids the possible
    races.
    
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Acked-by: David Vrabel <david.vrabel@citrix.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5457c80025f2c6955d2f4e8ce879a028bde1cab5
Author: David Vrabel <david.vrabel@citrix.com>
Date:   Tue Jan 13 16:42:42 2015 +0000

    xen-netfront: use different locks for Rx and Tx stats
    
    commit 900e183301b54f8ca17a86d9835e9569090d182a upstream.
    
    In netfront the Rx and Tx path are independent and use different
    locks.  The Tx lock is held with hard irqs disabled, but Rx lock is
    held with only BH disabled.  Since both sides use the same stats lock,
    a deadlock may occur.
    
      [ INFO: possible irq lock inversion dependency detected ]
      3.16.2 #16 Not tainted
      ---------------------------------------------------------
      swapper/0/0 just changed the state of lock:
       (&(&queue->tx_lock)->rlock){-.....}, at: [<c03adec8>]
      xennet_tx_interrupt+0x14/0x34
      but this lock took another, HARDIRQ-unsafe lock in the past:
       (&stat->syncp.seq#2){+.-...}
      and interrupts could create inverse lock ordering between them.
      other info that might help us debug this:
       Possible interrupt unsafe locking scenario:
    
             CPU0                    CPU1
             ----                    ----
        lock(&stat->syncp.seq#2);
                                     local_irq_disable();
                                     lock(&(&queue->tx_lock)->rlock);
                                     lock(&stat->syncp.seq#2);
        <Interrupt>
          lock(&(&queue->tx_lock)->rlock);
    
    Using separate locks for the Rx and Tx stats fixes this deadlock.
    
    Reported-by: Dmitry Piotrovsky <piotrovskydmitry@gmail.com>
    Signed-off-by: David Vrabel <david.vrabel@citrix.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f3b3d90da9b2b045b328f8e7d54690532f9c8482
Author: David Vrabel <david.vrabel@citrix.com>
Date:   Thu Jul 31 17:38:23 2014 +0100

    xen-netfront: release per-queue Tx and Rx resource when disconnecting
    
    commit a5b5dc3ce4df4f05f4d81c7d3c56a7604b242093 upstream.
    
    Since netfront may reconnect to a backend with a different number of
    queues, all per-queue Rx and Tx resources (skbs and grant references)
    should be freed when disconnecting.
    
    Without this fix, the Tx and Rx grant refs are not released and
    netfront will exhaust them after only a few reconnections.  netfront
    will fail to connect when no free grant references are available.
    
    Since all Rx bufs are freed and reallocated instead of reused this
    will add some additional delay to the reconnection but this is
    expected to be small compared to the time taken by any backend hotplug
    scripts etc.
    
    Signed-off-by: David Vrabel <david.vrabel@citrix.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7ba506580f318d9fd1fb7a6183c6dabad721c236
Author: David Vrabel <david.vrabel@citrix.com>
Date:   Thu Jul 31 17:38:22 2014 +0100

    xen-netfront: fix locking in connect error path
    
    commit db8c8ab61a28d7e3eb86d247b342a853263262c3 upstream.
    
    If no queues could be created when connecting to the backend, one of the
    error paths would deadlock.
    
    Signed-off-by: David Vrabel <david.vrabel@citrix.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 16fffb8cd571a2cbf7bc5157fcda7e971238953b
Author: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Date:   Wed Jun 6 12:13:28 2018 +0200

    mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips
    
    commit 5fdfc3dbad099281bf027a353d5786c09408a8e5 upstream.
    
    cfi_ppb_unlock() tries to relock all sectors that were locked before
    unlocking the whole chip.
    This locking used the chip start address + the FULL offset from the
    first flash chip, thereby forming an illegal address. Fix that by using
    the chip offset(adr).
    
    Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
    Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 79b53396b33472676363aa3916859fcc2a8f1ecb
Author: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Date:   Wed Jun 6 12:13:27 2018 +0200

    mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock()
    
    commit f93aa8c4de307069c270b2d81741961162bead6c upstream.
    
    do_ppb_xxlock() fails to add chip->start when querying for lock status
    (and chip_ready test), which caused false status reports.
    Fix that by adding adr += chip->start and adjust call sites
    accordingly.
    
    Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
    Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 901f0645d6bd558d54964a2df9992577967f4bf5
Author: Dan Williams <dan.j.williams@intel.com>
Date:   Thu Jun 7 09:13:48 2018 -0700

    x86/spectre_v1: Disable compiler optimizations over array_index_mask_nospec()
    
    commit eab6870fee877258122a042bfd99ee7908c40280 upstream.
    
    Mark Rutland noticed that GCC optimization passes have the potential to elide
    necessary invocations of the array_index_mask_nospec() instruction sequence,
    so mark the asm() volatile.
    
    Mark explains:
    
    "The volatile will inhibit *some* cases where the compiler could lift the
     array_index_nospec() call out of a branch, e.g. where there are multiple
     invocations of array_index_nospec() with the same arguments:
    
            if (idx < foo) {
                    idx1 = array_idx_nospec(idx, foo)
                    do_something(idx1);
            }
    
            < some other code >
    
            if (idx < foo) {
                    idx2 = array_idx_nospec(idx, foo);
                    do_something_else(idx2);
            }
    
     ... since the compiler can determine that the two invocations yield the same
     result, and reuse the first result (likely the same register as idx was in
     originally) for the second branch, effectively re-writing the above as:
    
            if (idx < foo) {
                    idx = array_idx_nospec(idx, foo);
                    do_something(idx);
            }
    
            < some other code >
    
            if (idx < foo) {
                    do_something_else(idx);
            }
    
     ... if we don't take the first branch, then speculatively take the second, we
     lose the nospec protection.
    
     There's more info on volatile asm in the GCC docs:
    
       https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile
     "
    
    Reported-by: Mark Rutland <mark.rutland@arm.com>
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Acked-by: Mark Rutland <mark.rutland@arm.com>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Fixes: babdde2698d4 ("x86: Implement array_index_mask_nospec")
    Link: https://lkml.kernel.org/lkml/152838798950.14521.4893346294059739135.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1044c1ecff3962d24a16f09afa9adb6ab70a8ce7
Author: Dan Williams <dan.j.williams@intel.com>
Date:   Tue Feb 6 18:22:40 2018 -0800

    x86/speculation: Fix up array_index_nospec_mask() asm constraint
    
    commit be3233fbfcb8f5acb6e3bcd0895c3ef9e100d470 upstream.
    
    Allow the compiler to handle @size as an immediate value or memory
    directly rather than allocating a register.
    
    Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/151797010204.1289.1510000292250184993.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 050faf5b4c2c092f3935d17a8bb77a3bb0001e10
Author: Siarhei Liakh <Siarhei.Liakh@concurrent-rt.com>
Date:   Thu Jun 14 19:36:07 2018 +0000

    x86: Call fixup_exception() before notify_die() in math_error()
    
    commit 3ae6295ccb7cf6d344908209701badbbbb503e40 upstream.
    
    fpu__drop() has an explicit fwait which under some conditions can trigger a
    fixable FPU exception while in kernel. Thus, we should attempt to fixup the
    exception first, and only call notify_die() if the fixup failed just like
    in do_general_protection(). The original call sequence incorrectly triggers
    KDB entry on debug kernels under particular FPU-intensive workloads.
    
    Andy noted, that this makes the whole conditional irq enable thing even
    more inconsistent, but fixing that it outside the scope of this.
    
    Signed-off-by: Siarhei Liakh <siarhei.liakh@concurrent-rt.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Andy Lutomirski <luto@kernel.org>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: "Borislav  Petkov" <bpetkov@suse.de>
    Link: https://lkml.kernel.org/r/DM5PR11MB201156F1CAB2592B07C79A03B17D0@DM5PR11MB2011.namprd11.prod.outlook.com
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ca013e070697468a4b274a206959900bfaf41853
Author: Jan Kara <jack@suse.cz>
Date:   Wed Jun 13 12:09:22 2018 +0200

    udf: Detect incorrect directory size
    
    commit fa65653e575fbd958bdf5fb9c4a71a324e39510d upstream.
    
    Detect when a directory entry is (possibly partially) beyond directory
    size and return EIO in that case since it means the filesystem is
    corrupted. Otherwise directory operations can further corrupt the
    directory and possibly also oops the kernel.
    
    CC: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
    Reported-and-tested-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fa4e46ff5a97bbee5d1d018f1fb9954497f97cf0
Author: Huacai Chen <chenhc@lemote.com>
Date:   Tue Jun 12 17:54:42 2018 +0800

    MIPS: io: Add barrier after register read in inX()
    
    commit 18f3e95b90b28318ef35910d21c39908de672331 upstream.
    
    While a barrier is present in the outX() functions before the register
    write, a similar barrier is missing in the inX() functions after the
    register read. This could allow memory accesses following inX() to
    observe stale data.
    
    This patch is very similar to commit a1cc7034e33d12dc1 ("MIPS: io: Add
    barrier after register read in readX()"). Because war_io_reorder_wmb()
    is both used by writeX() and outX(), if readX() need a barrier then so
    does inX().
    
    Signed-off-by: Huacai Chen <chenhc@lemote.com>
    Patchwork: https://patchwork.linux-mips.org/patch/19516/
    Signed-off-by: Paul Burton <paul.burton@mips.com>
    Cc: James Hogan <james.hogan@mips.com>
    Cc: linux-mips@linux-mips.org
    Cc: Fuxin Zhang <zhangfx@lemote.com>
    Cc: Zhangjin Wu <wuzhangjin@gmail.com>
    Cc: Huacai Chen <chenhuacai@gmail.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8f78b5f0e424c179785677c787842e971b5edc08
Author: David Disseldorp <ddiss@suse.de>
Date:   Tue Jun 19 17:58:24 2018 +0200

    scsi: target: Fix truncated PR-in ReadKeys response
    
    commit 63ce3c384db26494615e3c8972bcd419ed71f4c4 upstream.
    
    SPC5r17 states that the contents of the ADDITIONAL LENGTH field are not
    altered based on the allocation length, so always calculate and pack the
    full key list length even if the list itself is truncated.
    
    According to Maged:
    
      Yes it fixes the "Storage Spaces Persistent Reservation" test in the
      Windows 2016 Server Failover Cluster validation suites when having
      many connections that result in more than 8 registrations. I tested
      your patch on 4.17 with iblock.
    
    This behaviour can be tested using the libiscsi PrinReadKeys.Truncate test.
    
    Signed-off-by: David Disseldorp <ddiss@suse.de>
    Reviewed-by: Mike Christie <mchristi@redhat.com>
    Tested-by: Maged Mokhtar <mmokhtar@petasan.org>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    [bwh: Backported to 3.16: Convert from open-coded put_unaligned_be64()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5da0c1ff04a40742fdb75e7bab0b3ec4fa1c20ca
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon Jun 18 21:35:07 2018 -0700

    xfrm_user: prevent leaking 2 bytes of kernel memory
    
    commit 45c180bc29babbedd6b8c01b975780ef44d9d09c upstream.
    
    struct xfrm_userpolicy_type has two holes, so we should not
    use C99 style initializer.
    
    KMSAN report:
    
    BUG: KMSAN: kernel-infoleak in copyout lib/iov_iter.c:140 [inline]
    BUG: KMSAN: kernel-infoleak in _copy_to_iter+0x1b14/0x2800 lib/iov_iter.c:571
    CPU: 1 PID: 4520 Comm: syz-executor841 Not tainted 4.17.0+ #5
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x185/0x1d0 lib/dump_stack.c:113
     kmsan_report+0x188/0x2a0 mm/kmsan/kmsan.c:1117
     kmsan_internal_check_memory+0x138/0x1f0 mm/kmsan/kmsan.c:1211
     kmsan_copy_to_user+0x7a/0x160 mm/kmsan/kmsan.c:1253
     copyout lib/iov_iter.c:140 [inline]
     _copy_to_iter+0x1b14/0x2800 lib/iov_iter.c:571
     copy_to_iter include/linux/uio.h:106 [inline]
     skb_copy_datagram_iter+0x422/0xfa0 net/core/datagram.c:431
     skb_copy_datagram_msg include/linux/skbuff.h:3268 [inline]
     netlink_recvmsg+0x6f1/0x1900 net/netlink/af_netlink.c:1959
     sock_recvmsg_nosec net/socket.c:802 [inline]
     sock_recvmsg+0x1d6/0x230 net/socket.c:809
     ___sys_recvmsg+0x3fe/0x810 net/socket.c:2279
     __sys_recvmmsg+0x58e/0xe30 net/socket.c:2391
     do_sys_recvmmsg+0x2a6/0x3e0 net/socket.c:2472
     __do_sys_recvmmsg net/socket.c:2485 [inline]
     __se_sys_recvmmsg net/socket.c:2481 [inline]
     __x64_sys_recvmmsg+0x15d/0x1c0 net/socket.c:2481
     do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x446ce9
    RSP: 002b:00007fc307918db8 EFLAGS: 00000293 ORIG_RAX: 000000000000012b
    RAX: ffffffffffffffda RBX: 00000000006dbc24 RCX: 0000000000446ce9
    RDX: 000000000000000a RSI: 0000000020005040 RDI: 0000000000000003
    RBP: 00000000006dbc20 R08: 0000000020004e40 R09: 0000000000000000
    R10: 0000000040000000 R11: 0000000000000293 R12: 0000000000000000
    R13: 00007ffc8d2df32f R14: 00007fc3079199c0 R15: 0000000000000001
    
    Uninit was stored to memory at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
     kmsan_save_stack mm/kmsan/kmsan.c:294 [inline]
     kmsan_internal_chain_origin+0x12b/0x210 mm/kmsan/kmsan.c:685
     kmsan_memcpy_origins+0x11d/0x170 mm/kmsan/kmsan.c:527
     __msan_memcpy+0x109/0x160 mm/kmsan/kmsan_instr.c:413
     __nla_put lib/nlattr.c:569 [inline]
     nla_put+0x276/0x340 lib/nlattr.c:627
     copy_to_user_policy_type net/xfrm/xfrm_user.c:1678 [inline]
     dump_one_policy+0xbe1/0x1090 net/xfrm/xfrm_user.c:1708
     xfrm_policy_walk+0x45a/0xd00 net/xfrm/xfrm_policy.c:1013
     xfrm_dump_policy+0x1c0/0x2a0 net/xfrm/xfrm_user.c:1749
     netlink_dump+0x9b5/0x1550 net/netlink/af_netlink.c:2226
     __netlink_dump_start+0x1131/0x1270 net/netlink/af_netlink.c:2323
     netlink_dump_start include/linux/netlink.h:214 [inline]
     xfrm_user_rcv_msg+0x8a3/0x9b0 net/xfrm/xfrm_user.c:2577
     netlink_rcv_skb+0x37e/0x600 net/netlink/af_netlink.c:2448
     xfrm_netlink_rcv+0xb2/0xf0 net/xfrm/xfrm_user.c:2598
     netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
     netlink_unicast+0x1680/0x1750 net/netlink/af_netlink.c:1336
     netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec8/0x1320 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    Local variable description: ----upt.i@dump_one_policy
    Variable was created at:
     dump_one_policy+0x78/0x1090 net/xfrm/xfrm_user.c:1689
     xfrm_policy_walk+0x45a/0xd00 net/xfrm/xfrm_policy.c:1013
    
    Byte 130 of 137 is uninitialized
    Memory access starts at ffff88019550407f
    
    Fixes: c0144beaeca42 ("[XFRM] netlink: Use nla_put()/NLA_PUT() variantes")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Cc: Steffen Klassert <steffen.klassert@secunet.com>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e9a2aede9f4a599badf35e034b942e5ffffe9c98
Author: Michael Jeanson <mjeanson@efficios.com>
Date:   Thu Jun 14 11:27:42 2018 -0400

    powerpc/e500mc: Set assembler machine type to e500mc
    
    commit 69a8405999aa1c489de4b8d349468f0c2b83f093 upstream.
    
    In binutils 2.26 a new opcode for the "wait" instruction was added for the
    POWER9 and has precedence over the one specific to the e500mc. Commit
    ebf714ff3756 ("powerpc/e500mc: Add support for the wait instruction in
    e500_idle") uses this instruction specifically on the e500mc to work around
    an erratum.
    
    This results in an invalid instruction in idle_e500 when we build for the
    e500mc on bintutils >= 2.26 with the default assembler machine type.
    
    Since multiplatform between e500 and non-e500 is not supported, set the
    assembler machine type globaly when CONFIG_PPC_E500MC=y.
    
    Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
    Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    CC: Paul Mackerras <paulus@samba.org>
    CC: Michael Ellerman <mpe@ellerman.id.au>
    CC: Kumar Gala <galak@kernel.crashing.org>
    CC: Vakul Garg <vakul.garg@nxp.com>
    CC: Scott Wood <swood@redhat.com>
    CC: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    CC: linuxppc-dev@lists.ozlabs.org
    CC: linux-kernel@vger.kernel.org
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3236bfaaa50fb3189ccd476f90e0054a5cd6c2b9
Author: Martin Kaiser <martin@kaiser.cx>
Date:   Mon Jun 18 22:41:03 2018 +0200

    mtd: rawnand: mxc: set spare area size register explicitly
    
    commit 3f77f244d8ec28e3a0a81240ffac7d626390060c upstream.
    
    The v21 version of the NAND flash controller contains a Spare Area Size
    Register (SPAS) at offset 0x10. Its setting defaults to the maximum
    spare area size of 218 bytes. The size that is set in this register is
    used by the controller when it calculates the ECC bytes internally in
    hardware.
    
    Usually, this register is updated from settings in the IIM fuses when
    the system is booting from NAND flash. For other boot media, however,
    the SPAS register remains at the default setting, which may not work for
    the particular flash chip on the board. The same goes for flash chips
    whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
    sector size and 128 bytes spare area size can't be configured in the IIM
    fuses on imx25 systems).
    
    Set the SPAS register explicitly during the preset operation. Derive the
    register value from mtd->oobsize that was detected during probe by
    decoding the flash chip's ID bytes.
    
    While at it, rename the define for the spare area register's offset to
    NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
    different from the register on v21 controllers.
    
    Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset")
    Signed-off-by: Martin Kaiser <martin@kaiser.cx>
    Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 77ece4efbe9d1969cb505a4fc533d5208e3c42a7
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Jun 13 10:11:56 2018 -0700

    netfilter: ipv6: nf_defrag: reduce struct net memory waste
    
    commit 9ce7bc036ae4cfe3393232c86e9e1fea2153c237 upstream.
    
    It is a waste of memory to use a full "struct netns_sysctl_ipv6"
    while only one pointer is really used, considering netns_sysctl_ipv6
    keeps growing.
    
    Also, since "struct netns_frags" has cache line alignment,
    it is better to move the frags_hdr pointer outside, otherwise
    we spend a full cache line for this pointer.
    
    This saves 192 bytes of memory per netns.
    
    Fixes: c038a767cd69 ("ipv6: add a new namespace for nf_conntrack_reasm")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e3f48e287b2eeb2b33484c18c230040c1f74bc92
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Jun 13 09:13:39 2018 -0700

    netfilter: nf_queue: augment nfqa_cfg_policy
    
    commit ba062ebb2cd561d404e0fba8ee4b3f5ebce7cbfc upstream.
    
    Three attributes are currently not verified, thus can trigger KMSAN
    warnings such as :
    
    BUG: KMSAN: uninit-value in __arch_swab32 arch/x86/include/uapi/asm/swab.h:10 [inline]
    BUG: KMSAN: uninit-value in __fswab32 include/uapi/linux/swab.h:59 [inline]
    BUG: KMSAN: uninit-value in nfqnl_recv_config+0x939/0x17d0 net/netfilter/nfnetlink_queue.c:1268
    CPU: 1 PID: 4521 Comm: syz-executor120 Not tainted 4.17.0+ #5
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x185/0x1d0 lib/dump_stack.c:113
     kmsan_report+0x188/0x2a0 mm/kmsan/kmsan.c:1117
     __msan_warning_32+0x70/0xc0 mm/kmsan/kmsan_instr.c:620
     __arch_swab32 arch/x86/include/uapi/asm/swab.h:10 [inline]
     __fswab32 include/uapi/linux/swab.h:59 [inline]
     nfqnl_recv_config+0x939/0x17d0 net/netfilter/nfnetlink_queue.c:1268
     nfnetlink_rcv_msg+0xb2e/0xc80 net/netfilter/nfnetlink.c:212
     netlink_rcv_skb+0x37e/0x600 net/netlink/af_netlink.c:2448
     nfnetlink_rcv+0x2fe/0x680 net/netfilter/nfnetlink.c:513
     netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
     netlink_unicast+0x1680/0x1750 net/netlink/af_netlink.c:1336
     netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec8/0x1320 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x43fd59
    RSP: 002b:00007ffde0e30d28 EFLAGS: 00000213 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043fd59
    RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000003
    RBP: 00000000006ca018 R08: 00000000004002c8 R09: 00000000004002c8
    R10: 00000000004002c8 R11: 0000000000000213 R12: 0000000000401680
    R13: 0000000000401710 R14: 0000000000000000 R15: 0000000000000000
    
    Uninit was created at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
     kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:189
     kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:315
     kmsan_slab_alloc+0x10/0x20 mm/kmsan/kmsan.c:322
     slab_post_alloc_hook mm/slab.h:446 [inline]
     slab_alloc_node mm/slub.c:2753 [inline]
     __kmalloc_node_track_caller+0xb35/0x11b0 mm/slub.c:4395
     __kmalloc_reserve net/core/skbuff.c:138 [inline]
     __alloc_skb+0x2cb/0x9e0 net/core/skbuff.c:206
     alloc_skb include/linux/skbuff.h:988 [inline]
     netlink_alloc_large_skb net/netlink/af_netlink.c:1182 [inline]
     netlink_sendmsg+0x76e/0x1350 net/netlink/af_netlink.c:1876
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec8/0x1320 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Fixes: fdb694a01f1f ("netfilter: Add fail-open support")
    Fixes: 829e17a1a602 ("[NETFILTER]: nfnetlink_queue: allow changing queue length through netlink")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b763ef80c2440bc3800d13d7a033f08c1736f9fc
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Jun 18 10:24:03 2018 +0200

    USB: serial: cp210x: add CESINEL device ids
    
    commit 24160628a34af962ac99f2f58e547ac3c4cbd26f upstream.
    
    Add device ids for CESINEL products.
    
    Reported-by: Carlos Barcala Lara <cabl@cesinel.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0970f183d7907b356b18ba653f97def8ffc23124
Author: Karoly Pados <pados@pados.hu>
Date:   Sat Jun 9 13:26:08 2018 +0200

    USB: serial: cp210x: add Silicon Labs IDs for Windows Update
    
    commit 2f839823382748664b643daa73f41ee0cc01ced6 upstream.
    
    Silicon Labs defines alternative VID/PID pairs for some chips that when
    used will automatically install drivers for Windows users without manual
    intervention. Unfortunately, these IDs are not recognized by the Linux
    module, so using these IDs improves user experience on one platform but
    degrades it on Linux. This patch addresses this problem.
    
    Signed-off-by: Karoly Pados <pados@pados.hu>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9ccc327e6f1d26c611555114c87f40320d501aa9
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Sun Jun 17 18:11:20 2018 -0400

    ext4: add more mount time checks of the superblock
    
    commit bfe0a5f47ada40d7984de67e59a7d3390b9b9ecc upstream.
    
    The kernel's ext4 mount-time checks were more permissive than
    e2fsprogs's libext2fs checks when opening a file system.  The
    superblock is considered too insane for debugfs or e2fsck to operate
    on it, the kernel has no business trying to mount it.
    
    This will make file system fuzzing tools work harder, but the failure
    cases that they find will be more useful and be easier to evaluate.
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 58be2f3a0d44a144ffa6862deb62dedb52ae0bdb
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Fri Jun 15 12:27:16 2018 -0400

    ext4: include the illegal physical block in the bad map ext4_error msg
    
    commit bdbd6ce01a70f02e9373a584d0ae9538dcf0a121 upstream.
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b8d31d678a74ca67821ca31614b9da5d9093698b
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Fri Jun 15 15:39:19 2018 +0200

    l2tp: filter out non-PPP sessions in pppol2tp_tunnel_ioctl()
    
    commit ecd012e45ab5fd76ed57546865897ce35920f56b upstream.
    
    pppol2tp_tunnel_ioctl() can act on an L2TPv3 tunnel, in which case
    'session' may be an Ethernet pseudo-wire.
    
    However, pppol2tp_session_ioctl() expects a PPP pseudo-wire, as it
    assumes l2tp_session_priv() points to a pppol2tp_session structure. For
    an Ethernet pseudo-wire l2tp_session_priv() points to an l2tp_eth_sess
    structure instead, making pppol2tp_session_ioctl() access invalid
    memory.
    
    Fixes: d9e31d17ceba ("l2tp: Add L2TP ethernet pseudowire support")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e38a388dfe52be6972b10793516824bd32734e96
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Fri Jun 15 15:39:17 2018 +0200

    l2tp: reject creation of non-PPP sessions on L2TPv2 tunnels
    
    commit de9bada5d389903f4faf33980e6a95a2911c7e6d upstream.
    
    The /proc/net/pppol2tp handlers (pppol2tp_seq_*()) iterate over all
    L2TPv2 tunnels, and rightfully expect that only PPP sessions can be
    found there. However, l2tp_netlink accepts creating Ethernet sessions
    regardless of the underlying tunnel version.
    
    This confuses pppol2tp_seq_session_show(), which expects that
    l2tp_session_priv() returns a pppol2tp_session structure. When the
    session is an Ethernet pseudo-wire, a struct l2tp_eth_sess is returned
    instead. This leads to invalid memory access when
    pppol2tp_session_get_sock() later tries to dereference ps->sk.
    
    Fixes: d9e31d17ceba ("l2tp: Add L2TP ethernet pseudowire support")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f69083b11904b579e5cf42df731358bd7460cef5
Author: Sven Eckelmann <sven@narfation.org>
Date:   Wed Jun 6 10:53:55 2018 +0200

    cfg80211: initialize sinfo in cfg80211_get_station
    
    commit 3c12d0486856b9eb89c2a9ac336713cba90813e3 upstream.
    
    Most of the implementations behind cfg80211_get_station will not initialize
    sinfo to zero before manipulating it. For example, the member "filled",
    which indicates the filled in parts of this struct, is often only modified
    by enabling certain bits in the bitfield while keeping the remaining bits
    in their original state. A caller without a preinitialized sinfo.filled can
    then no longer decide which parts of sinfo were filled in by
    cfg80211_get_station (or actually the underlying implementations).
    
    cfg80211_get_station must therefore take care that sinfo is initialized to
    zero. Otherwise, the caller may tries to read information which was not
    filled in and which must therefore also be considered uninitialized. In
    batadv_v_elp_get_throughput's case, an invalid "random" expected throughput
    may be stored for this neighbor and thus the B.A.T.M.A.N V algorithm may
    switch to non-optimal neighbors for certain destinations.
    
    Fixes: 7406353d43c8 ("cfg80211: implement cfg80211_get_station cfg80211 API")
    Reported-by: Thomas Lauer <holminateur@gmail.com>
    Reported-by: Marcel Schmidt <ff.z-casparistrasse@mailbox.org>
    Cc: b.a.t.m.a.n@lists.open-mesh.org
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit eb5c0ad960754c92db9bfc1661ff81b3e88f9492
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Wed Jun 13 15:09:21 2018 +0200

    l2tp: clean up stale tunnel or session in pppol2tp_connect's error path
    
    commit bda06be2158c7aa7e41b15500c4d3840369c19a6 upstream.
    
    pppol2tp_connect() may create a tunnel or a session. Remove them in
    case of error.
    
    Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3df74949e931e79bcc0342ea3dc8fd1aaa84d475
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Wed Jun 13 15:09:20 2018 +0200

    l2tp: prevent pppol2tp_connect() from creating kernel sockets
    
    commit 3e1bc8bf974e2d4e7beb842a4c801c2542eff3bd upstream.
    
    If 'fd' is negative, l2tp_tunnel_create() creates a tunnel socket using
    the configuration passed in 'tcfg'. Currently, pppol2tp_connect() sets
    the relevant fields to zero, tricking l2tp_tunnel_create() into setting
    up an unusable kernel socket.
    
    We can't set 'tcfg' with the required fields because there's no way to
    get them from the current connect() parameters. So let's restrict
    kernel sockets creation to the netlink API, which is the original use
    case.
    
    Fixes: 789a4a2c61d8 ("l2tp: Add support for static unmanaged L2TPv3 tunnels")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d506e9f339a0bc3219fcf3e951d7374b4a8b1c0b
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Wed Jun 13 15:09:19 2018 +0200

    l2tp: only accept PPP sessions in pppol2tp_connect()
    
    commit 7ac6ab1f8a38ba7f8d97f95475bb6a2575db4658 upstream.
    
    l2tp_session_priv() returns a struct pppol2tp_session pointer only for
    PPPoL2TP sessions. In particular, if the session is an L2TP_PWTYPE_ETH
    pseudo-wire, l2tp_session_priv() returns a pointer to an l2tp_eth_sess
    structure, which is much smaller than struct pppol2tp_session. This
    leads to invalid memory dereference when trying to lock ps->sk_lock.
    
    Fixes: d9e31d17ceba ("l2tp: Add L2TP ethernet pseudowire support")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7e5c95677f0843213e132e4b76c645f489277034
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Wed Jun 13 15:09:18 2018 +0200

    l2tp: fix pseudo-wire type for sessions created by pppol2tp_connect()
    
    commit 90904ff5f958a215cc3d26f957a46e80fa178470 upstream.
    
    Define cfg.pw_type so that the new session is created with its .pwtype
    field properly set (L2TP_PWTYPE_PPP).
    
    Not setting the pseudo-wire type had several annoying effects:
    
      * Invalid value returned in the L2TP_ATTR_PW_TYPE attribute when
        dumping sessions with the netlink API.
    
      * Impossibility to delete the session using the netlink API (because
        l2tp_nl_cmd_session_delete() gets the deletion callback function
        from an array indexed by the session's pseudo-wire type).
    
    Also, there are several cases where we should check a session's
    pseudo-wire type. For example, pppol2tp_connect() should refuse to
    connect a session that is not PPPoL2TP, but that requires the session's
    .pwtype field to be properly set.
    
    Fixes: f7faffa3ff8e ("l2tp: Add L2TPv3 protocol support")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9b7a14031b86e563299032ccfc1ed3d2aec65e6b
Author: Daniel Jordan <daniel.m.jordan@oracle.com>
Date:   Thu Jun 14 15:26:21 2018 -0700

    mm/swapfile.c: fix swap_count comment about nonexistent SWAP_HAS_CONT
    
    commit 955c97f0859abef698e77f5697f5c4008303abb9 upstream.
    
    Commit 570a335b8e22 ("swap_info: swap count continuations") introduces
    COUNT_CONTINUED but refers to it incorrectly as SWAP_HAS_CONT in a
    comment in swap_count.  Fix it.
    
    Link: http://lkml.kernel.org/r/20180612175919.30413-1-daniel.m.jordan@oracle.com
    Fixes: 570a335b8e22 ("swap_info: swap count continuations")
    Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Cc: Hugh Dickins <hughd@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 33334548ea4e37c570ca85cdf4c9abb098084743
Author: Jia He <jia.he@hxt-semitech.com>
Date:   Thu Jun 14 15:26:14 2018 -0700

    mm/ksm.c: ignore STABLE_FLAG of rmap_item->address in rmap_walk_ksm()
    
    commit 1105a2fc022f3c7482e32faf516e8bc44095f778 upstream.
    
    In our armv8a server(QDF2400), I noticed lots of WARN_ON caused by
    PAGE_SIZE unaligned for rmap_item->address under memory pressure
    tests(start 20 guests and run memhog in the host).
    
      WARNING: CPU: 4 PID: 4641 at virt/kvm/arm/mmu.c:1826 kvm_age_hva_handler+0xc0/0xc8
      CPU: 4 PID: 4641 Comm: memhog Tainted: G        W 4.17.0-rc3+ #8
      Call trace:
       kvm_age_hva_handler+0xc0/0xc8
       handle_hva_to_gpa+0xa8/0xe0
       kvm_age_hva+0x4c/0xe8
       kvm_mmu_notifier_clear_flush_young+0x54/0x98
       __mmu_notifier_clear_flush_young+0x6c/0xa0
       page_referenced_one+0x154/0x1d8
       rmap_walk_ksm+0x12c/0x1d0
       rmap_walk+0x94/0xa0
       page_referenced+0x194/0x1b0
       shrink_page_list+0x674/0xc28
       shrink_inactive_list+0x26c/0x5b8
       shrink_node_memcg+0x35c/0x620
       shrink_node+0x100/0x430
       do_try_to_free_pages+0xe0/0x3a8
       try_to_free_pages+0xe4/0x230
       __alloc_pages_nodemask+0x564/0xdc0
       alloc_pages_vma+0x90/0x228
       do_anonymous_page+0xc8/0x4d0
       __handle_mm_fault+0x4a0/0x508
       handle_mm_fault+0xf8/0x1b0
       do_page_fault+0x218/0x4b8
       do_translation_fault+0x90/0xa0
       do_mem_abort+0x68/0xf0
       el0_da+0x24/0x28
    
    In rmap_walk_ksm, the rmap_item->address might still have the
    STABLE_FLAG, then the start and end in handle_hva_to_gpa might not be
    PAGE_SIZE aligned.  Thus it will cause exceptions in handle_hva_to_gpa
    on arm64.
    
    This patch fixes it by ignoring (not removing) the low bits of address
    when doing rmap_walk_ksm.
    
    IMO, it should be backported to stable tree.  the storm of WARN_ONs is
    very easy for me to reproduce.  More than that, I watched a panic (not
    reproducible) as follows:
    
      page:ffff7fe003742d80 count:-4871 mapcount:-2126053375 mapping: (null) index:0x0
      flags: 0x1fffc00000000000()
      raw: 1fffc00000000000 0000000000000000 0000000000000000 ffffecf981470000
      raw: dead000000000100 dead000000000200 ffff8017c001c000 0000000000000000
      page dumped because: nonzero _refcount
      CPU: 29 PID: 18323 Comm: qemu-kvm Tainted: G W 4.14.15-5.hxt.aarch64 #1
      Hardware name: <snip for confidential issues>
      Call trace:
        dump_backtrace+0x0/0x22c
        show_stack+0x24/0x2c
        dump_stack+0x8c/0xb0
        bad_page+0xf4/0x154
        free_pages_check_bad+0x90/0x9c
        free_pcppages_bulk+0x464/0x518
        free_hot_cold_page+0x22c/0x300
        __put_page+0x54/0x60
        unmap_stage2_range+0x170/0x2b4
        kvm_unmap_hva_handler+0x30/0x40
        handle_hva_to_gpa+0xb0/0xec
        kvm_unmap_hva_range+0x5c/0xd0
    
    I even injected a fault on purpose in kvm_unmap_hva_range by seting
    size=size-0x200, the call trace is similar as above.  So I thought the
    panic is similarly caused by the root cause of WARN_ON.
    
    Andrea said:
    
    : It looks a straightforward safe fix, on x86 hva_to_gfn_memslot would
    : zap those bits and hide the misalignment caused by the low metadata
    : bits being erroneously left set in the address, but the arm code
    : notices when that's the last page in the memslot and the hva_end is
    : getting aligned and the size is below one page.
    :
    : I think the problem triggers in the addr += PAGE_SIZE of
    : unmap_stage2_ptes that never matches end because end is aligned but
    : addr is not.
    :
    :       } while (pte++, addr += PAGE_SIZE, addr != end);
    :
    : x86 again only works on hva_start/hva_end after converting it to
    : gfn_start/end and that being in pfn units the bits are zapped before
    : they risk to cause trouble.
    
    Jia He said:
    
    : I've tested by myself in arm64 server (QDF2400,46 cpus,96G mem) Without
    : this patch, the WARN_ON is very easy for reproducing.  After this patch, I
    : have run the same benchmarch for a whole day without any WARN_ONs
    
    Link: http://lkml.kernel.org/r/1525403506-6750-1-git-send-email-hejianet@gmail.com
    Signed-off-by: Jia He <jia.he@hxt-semitech.com>
    Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>
    Tested-by: Jia He <hejianet@gmail.com>
    Cc: Suzuki K Poulose <Suzuki.Poulose@arm.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
    Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
    Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b7715f434f46bcc36517d89d0fc9f4c8f80b57ef
Author: Andrea Arcangeli <aarcange@redhat.com>
Date:   Thu Nov 5 18:49:07 2015 -0800

    ksm: add cond_resched() to the rmap_walks
    
    commit ad12695f177c3403a64348b42718faf9727fe358 upstream.
    
    While at it add it to the file and anon walks too.
    
    Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
    Acked-by: Hugh Dickins <hughd@google.com>
    Cc: Petr Holasek <pholasek@redhat.com>
    Acked-by: Davidlohr Bueso <dbueso@suse.de>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a58e2a7a577dad00014fc9e4427a4d0e7997c81a
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Nov 20 11:45:47 2017 +0100

    backlight: as3711_bl: Fix Device Tree node leaks
    
    commit d5318d302e7cf6583ec85a2a8bfbb3a3910ae372 upstream.
    
    Two framebuffer device-node names were looked up during probe, but were
    only used as flags to indicate the presence of two framebuffer device.
    
    Drop the unused framebuffer name along with a likewise unused device
    pointer from the driver data, and update the platform data to pass in
    booleans instead of the framebuffer strings. This allows us do drop the
    node references acquired during probe, which would otherwise leak.
    
    Note that there are no other in-kernel users of the modified
    platform-data fields.
    
    Fixes: 59eb2b5e57ea ("drivers/video/backlight/as3711_bl.c: add OF support")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5928795ffeafa3d2c3132918347afe2bf44f5f80
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Nov 20 11:45:46 2017 +0100

    backlight: tps65217_bl: Fix Device Tree node lookup
    
    commit 2b12dfa124dbadf391cb9a616aaa6b056823bf75 upstream.
    
    Fix child-node lookup during probe, which ended up searching the whole
    device tree depth-first starting at the parent rather than just matching
    on its children.
    
    This would only cause trouble if the child node is missing while there
    is an unrelated node named "backlight" elsewhere in the tree.
    
    Fixes: eebfdc17cc6c ("backlight: Add TPS65217 WLED driver")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4e2bf1cf0815f74523f5c618d57f592f1ce73a50
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Nov 20 11:45:45 2017 +0100

    backlight: max8925_bl: Fix Device Tree node lookup
    
    commit d1cc0ec3da23e44c23712579515494b374f111c9 upstream.
    
    Fix child-node lookup during probe, which ended up searching the whole
    device tree depth-first starting at the parent rather than just matching
    on its children.
    
    To make things worse, the parent mfd node was also prematurely freed,
    while the child backlight node was leaked.
    
    Fixes: 47ec340cb8e2 ("mfd: max8925: Support dt for backlight")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4c71797e9094b7256f8fa5229723ebadebd82923
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Nov 20 11:45:44 2017 +0100

    backlight: as3711_bl: Fix Device Tree node lookup
    
    commit 4a9c8bb2aca5b5a2a15744333729745dd9903562 upstream.
    
    Fix child-node lookup during probe, which ended up searching the whole
    device tree depth-first starting at the parent rather than just matching
    on its children.
    
    To make things worse, the parent mfd node was also prematurely freed.
    
    Fixes: 59eb2b5e57ea ("drivers/video/backlight/as3711_bl.c: add OF support")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2399cf5799a0027a0a7f72f70d30ba4d3a1c3c53
Author: Davide Caratti <dcaratti@redhat.com>
Date:   Fri Jun 8 05:02:31 2018 +0200

    net/sched: act_simple: fix parsing of TCA_DEF_DATA
    
    commit 8d499533e0bc02d44283dbdab03142b599b8ba16 upstream.
    
    use nla_strlcpy() to avoid copying data beyond the length of TCA_DEF_DATA
    netlink attribute, in case it is less than SIMP_MAX_DATA and it does not
    end with '\0' character.
    
    v2: fix errors in the commit message, thanks Hangbin Liu
    
    Fixes: fa1b1cff3d06 ("net_cls_act: Make act_simple use of netlink policy.")
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
    Reviewed-by: Simon Horman <simon.horman@netronome.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 770e086ea7887427376cbb9fe93a5391224aba12
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Fri Jun 8 18:08:12 2018 +0200

    video/omap: add module license tags
    
    commit 1bde9f2cf142b726412fa5b0e3cb557ff46952b0 upstream.
    
    I got a bunch of warnings in a randconfig build:
    
    WARNING: modpost: missing MODULE_LICENSE() in drivers/video/fbdev/omap/lcd_ams_delta.o
    WARNING: modpost: missing MODULE_LICENSE() in drivers/video/fbdev/omap/lcd_inn1510.o
    WARNING: modpost: missing MODULE_LICENSE() in drivers/video/fbdev/omap/lcd_palmte.o
    WARNING: modpost: missing MODULE_LICENSE() in drivers/video/fbdev/omap/lcd_palmtt.o
    
    These come from an earlier patch of mine that turned all display drivers
    into separate modules. The fix is to add a MODULE_LICENSE tag. Since I'm
    doing that, adding a description and author field also makes sense. I
    went by the authors listed in the comment at the top of each file, but
    removed Imre's Nokia email address that I assume is not valid any more,
    since Imre is working at Intel these days.
    
    Fixes: 81c44c2b2ce3 ("video/omap: fix modular build")
    Cc: Imre Deak <imre.deak@intel.com>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    [b.zolnierkie: minor fixups]
    Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 496792b19307015543580ed920045d53123a651c
Author: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Date:   Thu Jun 7 17:11:01 2018 -0700

    fs/binfmt_misc.c: do not allow offset overflow
    
    commit 5cc41e099504b77014358b58567c5ea6293dd220 upstream.
    
    WHen registering a new binfmt_misc handler, it is possible to overflow
    the offset to get a negative value, which might crash the system, or
    possibly leak kernel data.
    
    Here is a crash log when 2500000000 was used as an offset:
    
      BUG: unable to handle kernel paging request at ffff989cfd6edca0
      IP: load_misc_binary+0x22b/0x470 [binfmt_misc]
      PGD 1ef3e067 P4D 1ef3e067 PUD 0
      Oops: 0000 [#1] SMP NOPTI
      Modules linked in: binfmt_misc kvm_intel ppdev kvm irqbypass joydev input_leds serio_raw mac_hid parport_pc qemu_fw_cfg parpy
      CPU: 0 PID: 2499 Comm: bash Not tainted 4.15.0-22-generic #24-Ubuntu
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.1-1 04/01/2014
      RIP: 0010:load_misc_binary+0x22b/0x470 [binfmt_misc]
      Call Trace:
        search_binary_handler+0x97/0x1d0
        do_execveat_common.isra.34+0x667/0x810
        SyS_execve+0x31/0x40
        do_syscall_64+0x73/0x130
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    
    Use kstrtoint instead of simple_strtoul.  It will work as the code
    already set the delimiter byte to '\0' and we only do it when the field
    is not empty.
    
    Tested with offsets -1, 2500000000, UINT_MAX and INT_MAX.  Also tested
    with examples documented at Documentation/admin-guide/binfmt-misc.rst
    and other registrations from packages on Ubuntu.
    
    Link: http://lkml.kernel.org/r/20180529135648.14254-1-cascardo@canonical.com
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16:
     - Error label is "Einval"
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bdf9beaa8987d69ad3c8c45e656a9f2fb1916cb1
Author: Vlastimil Babka <vbabka@suse.cz>
Date:   Thu Jun 7 17:09:29 2018 -0700

    mm, page_alloc: do not break __GFP_THISNODE by zonelist reset
    
    commit 7810e6781e0fcbca78b91cf65053f895bf59e85f upstream.
    
    In __alloc_pages_slowpath() we reset zonelist and preferred_zoneref for
    allocations that can ignore memory policies.  The zonelist is obtained
    from current CPU's node.  This is a problem for __GFP_THISNODE
    allocations that want to allocate on a different node, e.g.  because the
    allocating thread has been migrated to a different CPU.
    
    This has been observed to break SLAB in our 4.4-based kernel, because
    there it relies on __GFP_THISNODE working as intended.  If a slab page
    is put on wrong node's list, then further list manipulations may corrupt
    the list because page_to_nid() is used to determine which node's
    list_lock should be locked and thus we may take a wrong lock and race.
    
    Current SLAB implementation seems to be immune by luck thanks to commit
    511e3a058812 ("mm/slab: make cache_grow() handle the page allocated on
    arbitrary node") but there may be others assuming that __GFP_THISNODE
    works as promised.
    
    We can fix it by simply removing the zonelist reset completely.  There
    is actually no reason to reset it, because memory policies and cpusets
    don't affect the zonelist choice in the first place.  This was different
    when commit 183f6371aac2 ("mm: ignore mempolicies when using
    ALLOC_NO_WATERMARK") introduced the code, as mempolicies provided their
    own restricted zonelists.
    
    We might consider this for 4.17 although I don't know if there's
    anything currently broken.
    
    SLAB is currently not affected, but in kernels older than 4.7 that don't
    yet have 511e3a058812 ("mm/slab: make cache_grow() handle the page
    allocated on arbitrary node") it is.  That's at least 4.4 LTS.  Older
    ones I'll have to check.
    
    So stable backports should be more important, but will have to be
    reviewed carefully, as the code went through many changes.  BTW I think
    that also the ac->preferred_zoneref reset is currently useless if we
    don't also reset ac->nodemask from a mempolicy to NULL first (which we
    probably should for the OOM victims etc?), but I would leave that for a
    separate patch.
    
    Link: http://lkml.kernel.org/r/20180525130853.13915-1-vbabka@suse.cz
    Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
    Fixes: 183f6371aac2 ("mm: ignore mempolicies when using ALLOC_NO_WATERMARK")
    Acked-by: Mel Gorman <mgorman@techsingularity.net>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16: Resetting the zonelist may still be useful here,
     so keep doing it if __GFP_THISNODE is not used.]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit eea979e3cc47b369a8495fb26d960c4ddf05b067
Author: Huang Ying <ying.huang@intel.com>
Date:   Thu Jun 7 17:07:39 2018 -0700

    mm: /proc/pid/pagemap: hide swap entries from unprivileged users
    
    commit ab6ecf247a9321e3180e021a6a60164dee53ab2e upstream.
    
    In commit ab676b7d6fbf ("pagemap: do not leak physical addresses to
    non-privileged userspace"), the /proc/PID/pagemap is restricted to be
    readable only by CAP_SYS_ADMIN to address some security issue.
    
    In commit 1c90308e7a77 ("pagemap: hide physical addresses from
    non-privileged users"), the restriction is relieved to make
    /proc/PID/pagemap readable, but hide the physical addresses for
    non-privileged users.
    
    But the swap entries are readable for non-privileged users too.  This
    has some security issues.  For example, for page under migrating, the
    swap entry has physical address information.  So, in this patch, the
    swap entries are hided for non-privileged users too.
    
    Link: http://lkml.kernel.org/r/20180508012745.7238-1-ying.huang@intel.com
    Fixes: 1c90308e7a77 ("pagemap: hide physical addresses from non-privileged users")
    Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
    Suggested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
    Cc: Andrei Vagin <avagin@openvz.org>
    Cc: Jerome Glisse <jglisse@redhat.com>
    Cc: Daniel Colascione <dancol@google.com>
    Cc: Zi Yan <zi.yan@cs.rutgers.edu>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16:
     - Only PTEs can be swap entries
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c73b1c6fd684ae6500ad3f434e0ab673a037f6ac
Author: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Date:   Tue Sep 8 15:00:07 2015 -0700

    pagemap: hide physical addresses from non-privileged users
    
    commit 1c90308e7a77af6742a97d1021cca923b23b7f0d upstream.
    
    This patch makes pagemap readable for normal users and hides physical
    addresses from them.  For some use-cases PFN isn't required at all.
    
    See http://lkml.kernel.org/r/1425935472-17949-1-git-send-email-kirill@shutemov.name
    
    Fixes: ab676b7d6fbf ("pagemap: do not leak physical addresses to non-privileged userspace")
    Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
    Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    Reviewed-by: Mark Williamson <mwilliamson@undo-software.com>
    Tested-by:  Mark Williamson <mwilliamson@undo-software.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.16:
     - Add the same check in the places where we look up a PFN
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c27e7b0df93a02e1b5525ba769bbb0b51c4f3ecf
Author: Julia Lawall <Julia.Lawall@lip6.fr>
Date:   Wed Jun 6 15:03:22 2018 +0200

    bnx2x: use the right constant
    
    commit dd612f18a49b63af8b3a5f572d999bdb197385bc upstream.
    
    Nearby code that also tests port suggests that the P0 constant should be
    used when port is zero.
    
    The semantic match that finds this problem is as follows:
    (http://coccinelle.lip6.fr/)
    
    // <smpl>
    @@
    expression e,e1;
    @@
    
    * e ? e1 : e1
    // </smpl>
    
    Fixes: 6c3218c6f7e5 ("bnx2x: Adjust ETS to 578xx")
    Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e94254219fdd11447e7cb50d82cb1642d779aee5
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Thu Apr 26 14:10:24 2018 +0200

    ACPI / LPSS: Add missing prv_offset setting for byt/cht PWM devices
    
    commit fdcb613d49321b5bf5d5a1bd0fba8e7c241dcc70 upstream.
    
    The LPSS PWM device on on Bay Trail and Cherry Trail devices has a set
    of private registers at offset 0x800, the current lpss_device_desc for
    them already sets the LPSS_SAVE_CTX flag to have these saved/restored
    over device-suspend, but the current lpss_device_desc was not setting
    the prv_offset field, leading to the regular device registers getting
    saved/restored instead.
    
    This is causing the PWM controller to no longer work, resulting in a black
    screen,  after a suspend/resume on systems where the firmware clears the
    APB clock and reset bits at offset 0x804.
    
    This commit fixes this by properly setting prv_offset to 0x800 for
    the PWM devices.
    
    Fixes: e1c748179754 ("ACPI / LPSS: Add Intel BayTrail ACPI mode PWM")
    Fixes: 1bfbd8eb8a7f ("ACPI / LPSS: Add ACPI IDs for Intel Braswell")
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Acked-by: Rafael J . Wysocki <rjw@rjwysocki.net>
    Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
    [bwh: Backported to 3.16:
     - Drop changes for Braswell
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3e73a2e0259e504ebd33905a6cbfc59d29c0ace0
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Thu Apr 26 14:10:23 2018 +0200

    pwm: lpss: platform: Save/restore the ctrl register over a suspend/resume
    
    commit 1d375b58c12f08d8570b30b865def4734517f04f upstream.
    
    On some devices the contents of the ctrl register get lost over a
    suspend/resume and the PWM comes back up disabled after the resume.
    
    This is seen on some Bay Trail devices with the PWM in ACPI enumerated
    mode, so it shows up as a platform device instead of a PCI device.
    
    If we still think it is enabled and then try to change the duty-cycle
    after this, we end up with a "PWM_SW_UPDATE was not cleared" error and
    the PWM is stuck in that state from then on.
    
    This commit adds suspend and resume pm callbacks to the pwm-lpss-platform
    code, which save/restore the ctrl register over a suspend/resume, fixing
    this.
    
    Note that:
    
    1) There is no need to do this over a runtime suspend, since we
    only runtime suspend when disabled and then we properly set the enable
    bit and reprogram the timings when we re-enable the PWM.
    
    2) This may be happening on more systems then we realize, but has been
    covered up sofar by a bug in the acpi-lpss.c code which was save/restoring
    the regular device registers instead of the lpss private registers due to
    lpss_device_desc.prv_offset not being set. This is fixed by a later patch
    in this series.
    
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
    [bwh: Backported to 3.16:
     - pwm-lpss is a single module, so make the new functions static
     - Only one PWM per chip is supported; remove the npwm assertion and loops
     - Adjust filenames, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5384204cadd2df766a33b7f583863007f12a21f0
Author: Himanshu Madhani <himanshu.madhani@cavium.com>
Date:   Sun Jun 3 22:09:53 2018 -0700

    scsi: qla2xxx: Fix setting lower transfer speed if GPSC fails
    
    commit 413c2f33489b134e3cc65d9c3ff7861e8fdfe899 upstream.
    
    This patch prevents driver from setting lower default speed of 1 GB/sec,
    if the switch does not support Get Port Speed Capabilities (GPSC)
    command. Setting this default speed results into much lower write
    performance for large sequential WRITE.  This patch modifies driver to
    check for gpsc_supported flags and prevents driver from issuing
    MBC_SET_PORT_PARAM (001Ah) to set default speed of 1 GB/sec. If driver
    does not send this mailbox command, firmware assumes maximum supported
    link speed and will operate at the max speed.
    
    Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
    Reported-by: Eda Zhou <ezhou@redhat.com>
    Reviewed-by: Ewan D. Milne <emilne@redhat.com>
    Tested-by: Ewan D. Milne <emilne@redhat.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1116f02af25e10755754f687aa5d7a56e17aab28
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue Jun 5 09:25:19 2018 -0700

    rtnetlink: validate attributes in do_setlink()
    
    commit 644c7eebbfd59e72982d11ec6cc7d39af12450ae upstream.
    
    It seems that rtnl_group_changelink() can call do_setlink
    while a prior call to validate_linkmsg(dev = NULL, ...) could
    not validate IFLA_ADDRESS / IFLA_BROADCAST
    
    Make sure do_setlink() calls validate_linkmsg() instead
    of letting its callers having this responsibility.
    
    With help from Dmitry Vyukov, thanks a lot !
    
    BUG: KMSAN: uninit-value in is_valid_ether_addr include/linux/etherdevice.h:199 [inline]
    BUG: KMSAN: uninit-value in eth_prepare_mac_addr_change net/ethernet/eth.c:275 [inline]
    BUG: KMSAN: uninit-value in eth_mac_addr+0x203/0x2b0 net/ethernet/eth.c:308
    CPU: 1 PID: 8695 Comm: syz-executor3 Not tainted 4.17.0-rc5+ #103
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x185/0x1d0 lib/dump_stack.c:113
     kmsan_report+0x149/0x260 mm/kmsan/kmsan.c:1084
     __msan_warning_32+0x6e/0xc0 mm/kmsan/kmsan_instr.c:686
     is_valid_ether_addr include/linux/etherdevice.h:199 [inline]
     eth_prepare_mac_addr_change net/ethernet/eth.c:275 [inline]
     eth_mac_addr+0x203/0x2b0 net/ethernet/eth.c:308
     dev_set_mac_address+0x261/0x530 net/core/dev.c:7157
     do_setlink+0xbc3/0x5fc0 net/core/rtnetlink.c:2317
     rtnl_group_changelink net/core/rtnetlink.c:2824 [inline]
     rtnl_newlink+0x1fe9/0x37a0 net/core/rtnetlink.c:2976
     rtnetlink_rcv_msg+0xa32/0x1560 net/core/rtnetlink.c:4646
     netlink_rcv_skb+0x378/0x600 net/netlink/af_netlink.c:2448
     rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:4664
     netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
     netlink_unicast+0x1678/0x1750 net/netlink/af_netlink.c:1336
     netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x455a09
    RSP: 002b:00007fc07480ec68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 00007fc07480f6d4 RCX: 0000000000455a09
    RDX: 0000000000000000 RSI: 00000000200003c0 RDI: 0000000000000014
    RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
    R13: 00000000000005d0 R14: 00000000006fdc20 R15: 0000000000000000
    
    Uninit was stored to memory at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
     kmsan_save_stack mm/kmsan/kmsan.c:294 [inline]
     kmsan_internal_chain_origin+0x12b/0x210 mm/kmsan/kmsan.c:685
     kmsan_memcpy_origins+0x11d/0x170 mm/kmsan/kmsan.c:527
     __msan_memcpy+0x109/0x160 mm/kmsan/kmsan_instr.c:478
     do_setlink+0xb84/0x5fc0 net/core/rtnetlink.c:2315
     rtnl_group_changelink net/core/rtnetlink.c:2824 [inline]
     rtnl_newlink+0x1fe9/0x37a0 net/core/rtnetlink.c:2976
     rtnetlink_rcv_msg+0xa32/0x1560 net/core/rtnetlink.c:4646
     netlink_rcv_skb+0x378/0x600 net/netlink/af_netlink.c:2448
     rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:4664
     netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
     netlink_unicast+0x1678/0x1750 net/netlink/af_netlink.c:1336
     netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    Uninit was created at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
     kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:189
     kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:315
     kmsan_slab_alloc+0x10/0x20 mm/kmsan/kmsan.c:322
     slab_post_alloc_hook mm/slab.h:446 [inline]
     slab_alloc_node mm/slub.c:2753 [inline]
     __kmalloc_node_track_caller+0xb32/0x11b0 mm/slub.c:4395
     __kmalloc_reserve net/core/skbuff.c:138 [inline]
     __alloc_skb+0x2cb/0x9e0 net/core/skbuff.c:206
     alloc_skb include/linux/skbuff.h:988 [inline]
     netlink_alloc_large_skb net/netlink/af_netlink.c:1182 [inline]
     netlink_sendmsg+0x76e/0x1350 net/netlink/af_netlink.c:1876
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Fixes: e7ed828f10bd ("netlink: support setting devgroup parameters")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e4ba1a655fc7131a30ab2b07a2e19ba2cb4f7a66
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue Jun 5 06:06:19 2018 -0700

    net: metrics: add proper netlink validation
    
    commit 5b5e7a0de2bbf2a1afcd9f49e940010e9fb80d53 upstream.
    
    Before using nla_get_u32(), better make sure the attribute
    is of the proper size.
    
    Code recently was changed, but bug has been there from beginning
    of git.
    
    BUG: KMSAN: uninit-value in rtnetlink_put_metrics+0x553/0x960 net/core/rtnetlink.c:746
    CPU: 1 PID: 14139 Comm: syz-executor6 Not tainted 4.17.0-rc5+ #103
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x185/0x1d0 lib/dump_stack.c:113
     kmsan_report+0x149/0x260 mm/kmsan/kmsan.c:1084
     __msan_warning_32+0x6e/0xc0 mm/kmsan/kmsan_instr.c:686
     rtnetlink_put_metrics+0x553/0x960 net/core/rtnetlink.c:746
     fib_dump_info+0xc42/0x2190 net/ipv4/fib_semantics.c:1361
     rtmsg_fib+0x65f/0x8c0 net/ipv4/fib_semantics.c:419
     fib_table_insert+0x2314/0x2b50 net/ipv4/fib_trie.c:1287
     inet_rtm_newroute+0x210/0x340 net/ipv4/fib_frontend.c:779
     rtnetlink_rcv_msg+0xa32/0x1560 net/core/rtnetlink.c:4646
     netlink_rcv_skb+0x378/0x600 net/netlink/af_netlink.c:2448
     rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:4664
     netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
     netlink_unicast+0x1678/0x1750 net/netlink/af_netlink.c:1336
     netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x455a09
    RSP: 002b:00007faae5fd8c68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 00007faae5fd96d4 RCX: 0000000000455a09
    RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000013
    RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
    R13: 00000000000005d0 R14: 00000000006fdc20 R15: 0000000000000000
    
    Uninit was stored to memory at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
     kmsan_save_stack mm/kmsan/kmsan.c:294 [inline]
     kmsan_internal_chain_origin+0x12b/0x210 mm/kmsan/kmsan.c:685
     __msan_chain_origin+0x69/0xc0 mm/kmsan/kmsan_instr.c:529
     fib_convert_metrics net/ipv4/fib_semantics.c:1056 [inline]
     fib_create_info+0x2d46/0x9dc0 net/ipv4/fib_semantics.c:1150
     fib_table_insert+0x3e4/0x2b50 net/ipv4/fib_trie.c:1146
     inet_rtm_newroute+0x210/0x340 net/ipv4/fib_frontend.c:779
     rtnetlink_rcv_msg+0xa32/0x1560 net/core/rtnetlink.c:4646
     netlink_rcv_skb+0x378/0x600 net/netlink/af_netlink.c:2448
     rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:4664
     netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
     netlink_unicast+0x1678/0x1750 net/netlink/af_netlink.c:1336
     netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    Uninit was created at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline]
     kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:189
     kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:315
     kmsan_slab_alloc+0x10/0x20 mm/kmsan/kmsan.c:322
     slab_post_alloc_hook mm/slab.h:446 [inline]
     slab_alloc_node mm/slub.c:2753 [inline]
     __kmalloc_node_track_caller+0xb32/0x11b0 mm/slub.c:4395
     __kmalloc_reserve net/core/skbuff.c:138 [inline]
     __alloc_skb+0x2cb/0x9e0 net/core/skbuff.c:206
     alloc_skb include/linux/skbuff.h:988 [inline]
     netlink_alloc_large_skb net/netlink/af_netlink.c:1182 [inline]
     netlink_sendmsg+0x76e/0x1350 net/netlink/af_netlink.c:1876
     sock_sendmsg_nosec net/socket.c:629 [inline]
     sock_sendmsg net/socket.c:639 [inline]
     ___sys_sendmsg+0xec0/0x1310 net/socket.c:2117
     __sys_sendmsg net/socket.c:2155 [inline]
     __do_sys_sendmsg net/socket.c:2164 [inline]
     __se_sys_sendmsg net/socket.c:2162 [inline]
     __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162
     do_syscall_64+0x152/0x230 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Fixes: a919525ad832 ("net: Move fib_convert_metrics to metrics file")
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Cc: David Ahern <dsahern@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: Metrics are parsed in fib_create_info()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dd778ee293f6a28108ac973bf318e42c08a1987b
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Tue Jun 5 15:01:59 2018 +0200

    ip6mr: only set ip6mr_table from setsockopt when ip6mr_new_table succeeds
    
    commit 848235edb5c93ed086700584c8ff64f6d7fc778d upstream.
    
    Currently, raw6_sk(sk)->ip6mr_table is set unconditionally during
    ip6_mroute_setsockopt(MRT6_TABLE). A subsequent attempt at the same
    setsockopt will fail with -ENOENT, since we haven't actually created
    that table.
    
    A similar fix for ipv4 was included in commit 5e1859fbcc3c ("ipv4: ipmr:
    various fixes and cleanups").
    
    Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d2349408f2f9e3a3a7d72a756f93caf92b365e15
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Mon Jun 4 18:52:19 2018 +0200

    l2tp: fix refcount leakage on PPPoL2TP sockets
    
    commit 3d609342cc04129ff7568e19316ce3d7451a27e8 upstream.
    
    Commit d02ba2a6110c ("l2tp: fix race in pppol2tp_release with session
    object destroy") tried to fix a race condition where a PPPoL2TP socket
    would disappear while the L2TP session was still using it. However, it
    missed the root issue which is that an L2TP session may accept to be
    reconnected if its associated socket has entered the release process.
    
    The tentative fix makes the session hold the socket it is connected to.
    That saves the kernel from crashing, but introduces refcount leakage,
    preventing the socket from completing the release process. Once stalled,
    everything the socket depends on can't be released anymore, including
    the L2TP session and the l2tp_ppp module.
    
    The root issue is that, when releasing a connected PPPoL2TP socket, the
    session's ->sk pointer (RCU-protected) is reset to NULL and we have to
    wait for a grace period before destroying the socket. The socket drops
    the session in its ->sk_destruct callback function, so the session
    will exist until the last reference on the socket is dropped.
    Therefore, there is a time frame where pppol2tp_connect() may accept
    reconnecting a session, as it only checks ->sk to figure out if the
    session is connected. This time frame is shortened by the fact that
    pppol2tp_release() calls l2tp_session_delete(), making the session
    unreachable before resetting ->sk. However, pppol2tp_connect() may
    grab the session before it gets unhashed by l2tp_session_delete(), but
    it may test ->sk after the later got reset. The race is not so hard to
    trigger and syzbot found a pretty reliable reproducer:
    https://syzkaller.appspot.com/bug?id=418578d2a4389074524e04d641eacb091961b2cf
    
    Before d02ba2a6110c, another race could let pppol2tp_release()
    overwrite the ->__sk pointer of an L2TP session, thus tricking
    pppol2tp_put_sk() into calling sock_put() on a socket that is different
    than the one for which pppol2tp_release() was originally called. To get
    there, we had to trigger the race described above, therefore having one
    PPPoL2TP socket being released, while the session it is connected to is
    reconnecting to a different PPPoL2TP socket. When releasing this new
    socket fast enough, pppol2tp_release() overwrites the session's
    ->__sk pointer with the address of the new socket, before the first
    pppol2tp_put_sk() call gets scheduled. Then the pppol2tp_put_sk() call
    invoked by the original socket will sock_put() the new socket,
    potentially dropping its last reference. When the second
    pppol2tp_put_sk() finally runs, its socket has already been freed.
    
    With d02ba2a6110c, the session takes a reference on both sockets.
    Furthermore, the session's ->sk pointer is reset in the
    pppol2tp_session_close() callback function rather than in
    pppol2tp_release(). Therefore, ->__sk can't be overwritten and
    pppol2tp_put_sk() is called only once (l2tp_session_delete() will only
    run pppol2tp_session_close() once, to protect the session against
    concurrent deletion requests). Now pppol2tp_put_sk() will properly
    sock_put() the original socket, but the new socket will remain, as
    l2tp_session_delete() prevented the release process from completing.
    Here, we don't depend on the ->__sk race to trigger the bug. Getting
    into the pppol2tp_connect() race is enough to leak the reference, no
    matter when new socket is released.
    
    So it all boils down to pppol2tp_connect() failing to realise that the
    session has already been connected. This patch drops the unneeded extra
    reference counting (mostly reverting d02ba2a6110c) and checks that
    neither ->sk nor ->__sk is set before allowing a session to be
    connected.
    
    Fixes: d02ba2a6110c ("l2tp: fix race in pppol2tp_release with session object destroy")
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 60f8bcb3ff60241197df546b5074bd10ecb8aa40
Author: Nathan Chancellor <natechancellor@gmail.com>
Date:   Sat Jun 2 09:02:09 2018 -0700

    kconfig: Avoid format overflow warning from GCC 8.1
    
    commit 2ae89c7a82ea9d81a19b4fc2df23bef4b112f24e upstream.
    
    In file included from scripts/kconfig/zconf.tab.c:2485:
    scripts/kconfig/confdata.c: In function ‘conf_write’:
    scripts/kconfig/confdata.c:773:22: warning: ‘%s’ directive writing likely 7 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
      sprintf(newname, "%s%s", dirname, basename);
                          ^~
    scripts/kconfig/confdata.c:773:19: note: assuming directive output of 7 bytes
      sprintf(newname, "%s%s", dirname, basename);
                       ^~~~~~
    scripts/kconfig/confdata.c:773:2: note: ‘sprintf’ output 1 or more bytes (assuming 4104) into a destination of size 4097
      sprintf(newname, "%s%s", dirname, basename);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    scripts/kconfig/confdata.c:776:23: warning: ‘.tmpconfig.’ directive writing 11 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
       sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
                           ^~~~~~~~~~~
    scripts/kconfig/confdata.c:776:3: note: ‘sprintf’ output between 13 and 4119 bytes into a destination of size 4097
       sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Increase the size of tmpname and newname to make GCC happy.
    
    Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
    Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 09f916460041ebc16c78e58cd6aca2af0571bb4e
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Wed May 30 08:19:22 2018 -0400

    branch-check: fix long->int truncation when profiling branches
    
    commit 2026d35741f2c3ece73c11eb7e4a15d7c2df9ebe upstream.
    
    The function __builtin_expect returns long type (see the gcc
    documentation), and so do macros likely and unlikely. Unfortunatelly, when
    CONFIG_PROFILE_ANNOTATED_BRANCHES is selected, the macros likely and
    unlikely expand to __branch_check__ and __branch_check__ truncates the
    long type to int. This unintended truncation may cause bugs in various
    kernel code (we found a bug in dm-writecache because of it), so it's
    better to fix __branch_check__ to return long.
    
    Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1805300818140.24812@file01.intranet.prod.int.rdu2.redhat.com
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Fixes: 1f0d69a9fc815 ("tracing: profile likely and unlikely annotations")
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d67598ec188e82e056598f1da37610357981eed6
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Wed May 30 14:06:42 2018 -0500

    PCI: shpchp: Fix AMD POGO identification
    
    commit bed4e9cfab93a0f3d0144cb919820e6d5c40b8b1 upstream.
    
    The fix for an AMD POGO erratum related to SHPC incorrectly identified the
    device.  The workaround should be applied only for AMD POGO devices, but it
    was instead applied to:
    
      - all AMD bridges, and
      - all devices from any vendor with device ID 0x7458
    
    Fixes: 53044f357448 ("[PATCH] PCI Hotplug: shpchp: AMD POGO errata fix")
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b8821ec4aa6677f70e5cdf93970279ac8811c802
Author: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Date:   Mon Jun 4 15:14:08 2018 +0100

    of: platform: stop accessing invalid dev in of_platform_device_destroy
    
    commit 522811e944ed9b36806faa019faec10f9d259cca upstream.
    
    Immediately after the platform_device_unregister() the device will be
    cleaned up. Accessing the freed pointer immediately after that will
    crash the system.
    
    Found this bug when kernel is built with CONFIG_PAGE_POISONING and testing
    loading/unloading audio drivers in a loop on Qcom platforms.
    
    Fix this by moving of_node_clear_flag() just before the unregister calls.
    
    Below is the crash trace:
    
    Unable to handle kernel paging request at virtual address 6b6b6b6b6b6c03
    Mem abort info:
      ESR = 0x96000021
      Exception class = DABT (current EL), IL = 32 bits
      SET = 0, FnV = 0
      EA = 0, S1PTW = 0
    Data abort info:
      ISV = 0, ISS = 0x00000021
      CM = 0, WnR = 0
    [006b6b6b6b6b6c03] address between user and kernel address ranges
    Internal error: Oops: 96000021 [#1] PREEMPT SMP
    Modules linked in:
    CPU: 2 PID: 1784 Comm: sh Tainted: G        W         4.17.0-rc7-02230-ge3a63a7ef641-dirty #204
    Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
    pstate: 80000005 (Nzcv daif -PAN -UAO)
    pc : clear_bit+0x18/0x2c
    lr : of_platform_device_destroy+0x64/0xb8
    sp : ffff00000c9c3930
    x29: ffff00000c9c3930 x28: ffff80003d39b200
    x27: ffff000008bb1000 x26: 0000000000000040
    x25: 0000000000000124 x24: ffff80003a9a3080
    x23: 0000000000000060 x22: ffff00000939f518
    x21: ffff80003aa79e98 x20: ffff80003aa3dae0
    x19: ffff80003aa3c890 x18: ffff800009feb794
    x17: 0000000000000000 x16: 0000000000000000
    x15: ffff800009feb790 x14: 0000000000000000
    x13: ffff80003a058778 x12: ffff80003a058728
    x11: ffff80003a058750 x10: 0000000000000000
    x9 : 0000000000000006 x8 : ffff80003a825988
    x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000001
    x5 : 0000000000000000 x4 : 0000000000000001
    x3 : 0000000000000008 x2 : 0000000000000001
    x1 : 6b6b6b6b6b6b6c03 x0 : 0000000000000000
    Process sh (pid: 1784, stack limit = 0x        (ptrval))
    Call trace:
     clear_bit+0x18/0x2c
     q6afe_remove+0x20/0x38
     apr_device_remove+0x30/0x70
     device_release_driver_internal+0x170/0x208
     device_release_driver+0x14/0x20
     bus_remove_device+0xcc/0x150
     device_del+0x10c/0x310
     device_unregister+0x1c/0x70
     apr_remove_device+0xc/0x18
     device_for_each_child+0x50/0x80
     apr_remove+0x18/0x20
     rpmsg_dev_remove+0x38/0x68
     device_release_driver_internal+0x170/0x208
     device_release_driver+0x14/0x20
     bus_remove_device+0xcc/0x150
     device_del+0x10c/0x310
     device_unregister+0x1c/0x70
     qcom_smd_remove_device+0xc/0x18
     device_for_each_child+0x50/0x80
     qcom_smd_unregister_edge+0x3c/0x70
     smd_subdev_remove+0x18/0x28
     rproc_stop+0x48/0xd8
     rproc_shutdown+0x60/0xe8
     state_store+0xbc/0xf8
     dev_attr_store+0x18/0x28
     sysfs_kf_write+0x3c/0x50
     kernfs_fop_write+0x118/0x1e0
     __vfs_write+0x18/0x110
     vfs_write+0xa4/0x1a8
     ksys_write+0x48/0xb0
     sys_write+0xc/0x18
     el0_svc_naked+0x30/0x34
    Code: d2800022 8b400c21 f9800031 9ac32043 (c85f7c22)
    ---[ end trace 32020935775616a2 ]---
    
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Signed-off-by: Rob Herring <robh@kernel.org>
    [bwh: Backported to 3.16: There's no OF_POPULATED_BUS flag]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e8f022fd94c99f3c07532f9b1a426aad02167ffa
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Jun 1 09:23:02 2018 -0700

    net/packet: refine check for priv area size
    
    commit eb73190f4fbeedf762394e92d6a4ec9ace684c88 upstream.
    
    syzbot was able to trick af_packet again [1]
    
    Various commits tried to address the problem in the past,
    but failed to take into account V3 header size.
    
    [1]
    
    tpacket_rcv: packet too big, clamped from 72 to 4294967224. macoff=96
    BUG: KASAN: use-after-free in prb_run_all_ft_ops net/packet/af_packet.c:1016 [inline]
    BUG: KASAN: use-after-free in prb_fill_curr_block.isra.59+0x4e5/0x5c0 net/packet/af_packet.c:1039
    Write of size 2 at addr ffff8801cb62000e by task kworker/1:2/2106
    
    CPU: 1 PID: 2106 Comm: kworker/1:2 Not tainted 4.17.0-rc7+ #77
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Workqueue: ipv6_addrconf addrconf_dad_work
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x1b9/0x294 lib/dump_stack.c:113
     print_address_description+0x6c/0x20b mm/kasan/report.c:256
     kasan_report_error mm/kasan/report.c:354 [inline]
     kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
     __asan_report_store2_noabort+0x17/0x20 mm/kasan/report.c:436
     prb_run_all_ft_ops net/packet/af_packet.c:1016 [inline]
     prb_fill_curr_block.isra.59+0x4e5/0x5c0 net/packet/af_packet.c:1039
     __packet_lookup_frame_in_block net/packet/af_packet.c:1094 [inline]
     packet_current_rx_frame net/packet/af_packet.c:1117 [inline]
     tpacket_rcv+0x1866/0x3340 net/packet/af_packet.c:2282
     dev_queue_xmit_nit+0x891/0xb90 net/core/dev.c:2018
     xmit_one net/core/dev.c:3049 [inline]
     dev_hard_start_xmit+0x16b/0xc10 net/core/dev.c:3069
     __dev_queue_xmit+0x2724/0x34c0 net/core/dev.c:3584
     dev_queue_xmit+0x17/0x20 net/core/dev.c:3617
     neigh_resolve_output+0x679/0xad0 net/core/neighbour.c:1358
     neigh_output include/net/neighbour.h:482 [inline]
     ip6_finish_output2+0xc9c/0x2810 net/ipv6/ip6_output.c:120
     ip6_finish_output+0x5fe/0xbc0 net/ipv6/ip6_output.c:154
     NF_HOOK_COND include/linux/netfilter.h:277 [inline]
     ip6_output+0x227/0x9b0 net/ipv6/ip6_output.c:171
     dst_output include/net/dst.h:444 [inline]
     NF_HOOK include/linux/netfilter.h:288 [inline]
     ndisc_send_skb+0x100d/0x1570 net/ipv6/ndisc.c:491
     ndisc_send_ns+0x3c1/0x8d0 net/ipv6/ndisc.c:633
     addrconf_dad_work+0xbef/0x1340 net/ipv6/addrconf.c:4033
     process_one_work+0xc1e/0x1b50 kernel/workqueue.c:2145
     worker_thread+0x1cc/0x1440 kernel/workqueue.c:2279
     kthread+0x345/0x410 kernel/kthread.c:240
     ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
    
    The buggy address belongs to the page:
    page:ffffea00072d8800 count:0 mapcount:-127 mapping:0000000000000000 index:0xffff8801cb620e80
    flags: 0x2fffc0000000000()
    raw: 02fffc0000000000 0000000000000000 ffff8801cb620e80 00000000ffffff80
    raw: ffffea00072e3820 ffffea0007132d20 0000000000000002 0000000000000000
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff8801cb61ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     ffff8801cb61ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    >ffff8801cb620000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                          ^
     ffff8801cb620080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
     ffff8801cb620100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
    
    Fixes: 2b6867c2ce76 ("net/packet: fix overflow in check for priv area size")
    Fixes: dc808110bb62 ("packet: handle too big packets for PACKET_V3")
    Fixes: f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation.")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c58686b3704088c2f62136fbf3aa7cd19cee52e8
Author: Max Gurtovoy <maxg@mellanox.com>
Date:   Thu May 31 11:05:23 2018 +0300

    IB/isert: fix T10-pi check mask setting
    
    commit 0e12af84cdd3056460f928adc164f9e87f4b303b upstream.
    
    A copy/paste bug (probably) caused setting of an app_tag check mask
    in case where a ref_tag check was needed.
    
    Fixes: 38a2d0d429f1 ("IB/isert: convert to the generic RDMA READ/WRITE API")
    Fixes: 9e961ae73c2c ("IB/isert: Support T10-PI protected transactions")
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c0c1975eacb1da432c904f214519cae0aa62137c
Author: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Date:   Mon Jun 4 12:13:26 2018 +0100

    ASoC: dapm: delete dapm_kcontrol_data paths list before freeing it
    
    commit ff2faf1289c1f81b5b26b9451dd1c2006aac8db8 upstream.
    
    dapm_kcontrol_data is freed as part of dapm_kcontrol_free(), leaving the
    paths pointer dangling in the list.
    
    This leads to system crash when we try to unload and reload sound card.
    I hit this bug during ADSP crash/reboot test case on Dragon board DB410c.
    
    Without this patch, on SLAB Poisoning enabled build, kernel crashes with
    "BUG kmalloc-128 (Tainted: G        W        ): Poison overwritten"
    
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 35de64ab2673a8e6268a400c4e8f3fef06b01104
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Wed May 30 18:48:04 2018 +0530

    powerpc/mm/hash: Add missing isync prior to kernel stack SLB switch
    
    commit 91d06971881f71d945910de128658038513d1b24 upstream.
    
    Currently we do not have an isync, or any other context synchronizing
    instruction prior to the slbie/slbmte in _switch() that updates the
    SLB entry for the kernel stack.
    
    However that is not correct as outlined in the ISA.
    
    From Power ISA Version 3.0B, Book III, Chapter 11, page 1133:
    
      "Changing the contents of ... the contents of SLB entries ... can
       have the side effect of altering the context in which data
       addresses and instruction addresses are interpreted, and in which
       instructions are executed and data accesses are performed.
       ...
       These side effects need not occur in program order, and therefore
       may require explicit synchronization by software.
       ...
       The synchronizing instruction before the context-altering
       instruction ensures that all instructions up to and including that
       synchronizing instruction are fetched and executed in the context
       that existed before the alteration."
    
    And page 1136:
    
      "For data accesses, the context synchronizing instruction before the
       slbie, slbieg, slbia, slbmte, tlbie, or tlbiel instruction ensures
       that all preceding instructions that access data storage have
       completed to a point at which they have reported all exceptions
       they will cause."
    
    We're not aware of any bugs caused by this, but it should be fixed
    regardless.
    
    Add the missing isync when updating kernel stack SLB entry.
    
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    [mpe: Flesh out change log with more ISA text & explanation]
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 41ef3c89749ac5718f857f98b39c70e9a1e23777
Author: Matt Turner <mattst88@gmail.com>
Date:   Tue Feb 13 11:12:05 2018 -0800

    x86: msr-index.h: Correct SNB_C1/C3_AUTO_UNDEMOTE defines
    
    commit a00072a24a9f5b88cfc56f2dec6afe8ce3874e60 upstream.
    
    According to the Intel Software Developers' Manual, Vol. 4, Order No.
    335592, these macros have been reversed since they were added in the
    initial turbostat commit. The reversed definitions were presumably
    copied from turbostat.c to this file.
    
    Fixes: 9c63a650bb10 ("tools/power/x86/turbostat: share kernel MSR #defines")
    Signed-off-by: Matt Turner <mattst88@gmail.com>
    Acked-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Len Brown <len.brown@intel.com>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8fb64ba91bcfa8dc365f5bed1f29ffa399b7b2fc
Author: Matt Turner <mattst88@gmail.com>
Date:   Tue Feb 13 11:12:04 2018 -0800

    tools/power turbostat: Correct SNB_C1/C3_AUTO_UNDEMOTE defines
    
    commit e0d34648b4d77ba715e13739d04e7b0692fe5eaa upstream.
    
    According to the Intel Software Developers' Manual, Vol. 4, Order No.
    335592, these macros have been reversed since they were added.
    
    Fixes: 889facbee3e6 ("tools/power turbostat: v3.0: monitor Watts and Temperature")
    Signed-off-by: Matt Turner <mattst88@gmail.com>
    Signed-off-by: Len Brown <len.brown@intel.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 97d070818a05be5ccfc11c733196b60d970cb3cc
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Tue May 29 14:56:14 2018 +0300

    RDMA/mlx4: Discard unknown SQP work requests
    
    commit 6b1ca7ece15e94251d1d0d919f813943e4a58059 upstream.
    
    There is no need to crash the machine if unknown work request was
    received in SQP MAD.
    
    Fixes: 37bfc7c1e83f ("IB/mlx4: SR-IOV multiplex and demultiplex MADs")
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9664b502282899d891d380ad4f2a2c766dc4a8fa
Author: Bo Chen <chenbo@pdx.edu>
Date:   Thu May 31 15:35:18 2018 -0700

    ALSA: hda - Handle kzalloc() failure in snd_hda_attach_pcm_stream()
    
    commit a3aa60d511746bd6c0d0366d4eb90a7998bcde8b upstream.
    
    When 'kzalloc()' fails in 'snd_hda_attach_pcm_stream()', a new pcm instance is
    created without setting its operators via 'snd_pcm_set_ops()'. Following
    operations on the new pcm instance can trigger kernel null pointer dereferences
    and cause kernel oops.
    
    This bug was found with my work on building a gray-box fault-injection tool for
    linux-kernel-module binaries. A kernel null pointer dereference was confirmed
    from line 'substream->ops->open()' in function 'snd_pcm_open_substream()' in
    file 'sound/core/pcm_native.c'.
    
    This patch fixes the bug by calling 'snd_device_free()' in the error handling
    path of 'kzalloc()', which removes the new pcm instance from the snd card before
    returns with an error code.
    
    Signed-off-by: Bo Chen <chenbo@pdx.edu>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e9c925215ddc0f9953a68aff2bc6ada50688bb4f
Author: Dave Wysochanski <dwysocha@redhat.com>
Date:   Tue May 29 17:47:30 2018 -0400

    NFSv4: Fix possible 1-byte stack overflow in nfs_idmap_read_and_verify_message
    
    commit d68894800ec5712d7ddf042356f11e36f87d7f78 upstream.
    
    In nfs_idmap_read_and_verify_message there is an incorrect sprintf '%d'
    that converts the __u32 'im_id' from struct idmap_msg to 'id_str', which
    is a stack char array variable of length NFS_UINT_MAXLEN == 11.
    If a uid or gid value is > 2147483647 = 0x7fffffff, the conversion
    overflows into a negative value, for example:
    crash> p (unsigned) (0x80000000)
    $1 = 2147483648
    crash> p (signed) (0x80000000)
    $2 = -2147483648
    The '-' sign is written to the buffer and this causes a 1 byte overflow
    when the NULL byte is written, which corrupts kernel stack memory.  If
    CONFIG_CC_STACKPROTECTOR_STRONG is set we see a stack-protector panic:
    
    [11558053.616565] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffffa05b8a8c
    [11558053.639063] CPU: 6 PID: 9423 Comm: rpc.idmapd Tainted: G        W      ------------ T 3.10.0-514.el7.x86_64 #1
    [11558053.641990] Hardware name: Red Hat OpenStack Compute, BIOS 1.10.2-3.el7_4.1 04/01/2014
    [11558053.644462]  ffffffff818c7bc0 00000000b1f3aec1 ffff880de0f9bd48 ffffffff81685eac
    [11558053.646430]  ffff880de0f9bdc8 ffffffff8167f2b3 ffffffff00000010 ffff880de0f9bdd8
    [11558053.648313]  ffff880de0f9bd78 00000000b1f3aec1 ffffffff811dcb03 ffffffffa05b8a8c
    [11558053.650107] Call Trace:
    [11558053.651347]  [<ffffffff81685eac>] dump_stack+0x19/0x1b
    [11558053.653013]  [<ffffffff8167f2b3>] panic+0xe3/0x1f2
    [11558053.666240]  [<ffffffff811dcb03>] ? kfree+0x103/0x140
    [11558053.682589]  [<ffffffffa05b8a8c>] ? idmap_pipe_downcall+0x1cc/0x1e0 [nfsv4]
    [11558053.689710]  [<ffffffff810855db>] __stack_chk_fail+0x1b/0x30
    [11558053.691619]  [<ffffffffa05b8a8c>] idmap_pipe_downcall+0x1cc/0x1e0 [nfsv4]
    [11558053.693867]  [<ffffffffa00209d6>] rpc_pipe_write+0x56/0x70 [sunrpc]
    [11558053.695763]  [<ffffffff811fe12d>] vfs_write+0xbd/0x1e0
    [11558053.702236]  [<ffffffff810acccc>] ? task_work_run+0xac/0xe0
    [11558053.704215]  [<ffffffff811fec4f>] SyS_write+0x7f/0xe0
    [11558053.709674]  [<ffffffff816964c9>] system_call_fastpath+0x16/0x1b
    
    Fix this by calling the internally defined nfs_map_numeric_to_string()
    function which properly uses '%u' to convert this __u32.  For consistency,
    also replace the one other place where snprintf is called.
    
    Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
    Reported-by: Stephen Johnston <sjohnsto@redhat.com>
    Fixes: cf4ab538f1516 ("NFSv4: Fix the string length returned by the idmapper")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1ed14063b4d4fb58f4ffe604f02eec10f6ba5dbc
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Thu May 31 13:21:07 2018 +0200

    libata: Drop SanDisk SD7UB3Q*G1001 NOLPM quirk
    
    commit 2cfce3a86b64b53f0a70e92a6a659c720c319b45 upstream.
    
    Commit 184add2ca23c ("libata: Apply NOLPM quirk for SanDisk
    SD7UB3Q*G1001 SSDs") disabled LPM for SanDisk SD7UB3Q*G1001 SSDs.
    
    This has lead to several reports of users of that SSD where LPM
    was working fine and who know have a significantly increased idle
    power consumption on their laptops.
    
    Likely there is another problem on the T450s from the original
    reporter which gets exposed by the uncore reaching deeper sleep
    states (higher PC-states) due to LPM being enabled. The problem as
    reported, a hardfreeze about once a day, already did not sound like
    it would be caused by LPM and the reports of the SSD working fine
    confirm this. The original reporter is ok with dropping the quirk.
    
    A X250 user has reported the same hard freeze problem and for him
    the problem went away after unrelated updates, I suspect some GPU
    driver stack changes fixed things.
    
    TL;DR: The original reporters problem were triggered by LPM but not
    an LPM issue, so drop the quirk for the SSD in question.
    
    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1583207
    Cc: Richard W.M. Jones <rjones@redhat.com>
    Cc: Lorenzo Dalrio <lorenzo.dalrio@gmail.com>
    Reported-by: Lorenzo Dalrio <lorenzo.dalrio@gmail.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Acked-by: "Richard W.M. Jones" <rjones@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a9d417e85323a22add91a28a95302ef6dbe1fc6b
Author: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date:   Tue May 1 13:12:14 2018 +0900

    fuse: don't keep dead fuse_conn at fuse_fill_super().
    
    commit 543b8f8662fe6d21f19958b666ab0051af9db21a upstream.
    
    syzbot is reporting use-after-free at fuse_kill_sb_blk() [1].
    Since sb->s_fs_info field is not cleared after fc was released by
    fuse_conn_put() when initialization failed, fuse_kill_sb_blk() finds
    already released fc and tries to hold the lock. Fix this by clearing
    sb->s_fs_info field after calling fuse_conn_put().
    
    [1] https://syzkaller.appspot.com/bug?id=a07a680ed0a9290585ca424546860464dd9658db
    
    Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Reported-by: syzbot <syzbot+ec3986119086fe4eec97@syzkaller.appspotmail.com>
    Fixes: 3b463ae0c626 ("fuse: invalidation reverse calls")
    Cc: John Muir <john@jmuir.com>
    Cc: Csaba Henk <csaba@gluster.com>
    Cc: Anand Avati <avati@redhat.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e9f7cee0ecc079a91511b13599ea7c486344292d
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Thu May 31 12:26:10 2018 +0200

    fuse: fix control dir setup and teardown
    
    commit 6becdb601bae2a043d7fb9762c4d48699528ea6e upstream.
    
    syzbot is reporting NULL pointer dereference at fuse_ctl_remove_conn() [1].
    Since fc->ctl_ndents is incremented by fuse_ctl_add_conn() when new_inode()
    failed, fuse_ctl_remove_conn() reaches an inode-less dentry and tries to
    clear d_inode(dentry)->i_private field.
    
    Fix by only adding the dentry to the array after being fully set up.
    
    When tearing down the control directory, do d_invalidate() on it to get rid
    of any mounts that might have been added.
    
    [1] https://syzkaller.appspot.com/bug?id=f396d863067238959c91c0b7cfc10b163638cac6
    Reported-by: syzbot <syzbot+32c236387d66c4516827@syzkaller.appspotmail.com>
    Fixes: bafa96541b25 ("[PATCH] fuse: add control filesystem")
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b1b0891405b7e95138810ef562801c032faa68ca
Author: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
Date:   Wed May 30 18:32:29 2018 +0900

    mtd: cfi_cmdset_0002: Change erase functions to check chip good only
    
    commit 79ca484b613041ca223f74b34608bb6f5221724b upstream.
    
    Currently the functions use to check both chip ready and good.
    But the chip ready is not enough to check the operation status.
    So change this to check the chip good instead of this.
    About the retry functions to make sure the error handling remain it.
    
    Signed-off-by: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
    Reviewed-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
    Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
    Cc: Brian Norris <computersforpeace@gmail.com>
    Cc: David Woodhouse <dwmw2@infradead.org>
    Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
    Cc: Marek Vasut <marek.vasut@gmail.com>
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
    Cc: linux-mtd@lists.infradead.org
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b3252c30b4971085f362e9d2a7697454bcbfe339
Author: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
Date:   Wed May 30 18:32:28 2018 +0900

    mtd: cfi_cmdset_0002: Change erase functions to retry for error
    
    commit 45f75b8a919a4255f52df454f1ffdee0e42443b2 upstream.
    
    For the word write functions it is retried for error.
    But it is not implemented to retry for the erase functions.
    To make sure for the erase functions change to retry as same.
    
    This is needed to prevent the flash erase error caused only once.
    It was caused by the error case of chip_good() in the do_erase_oneblock().
    Also it was confirmed on the MACRONIX flash device MX29GL512FHT2I-11G.
    But the error issue behavior is not able to reproduce at this moment.
    The flash controller is parallel Flash interface integrated on BCM53003.
    
    Signed-off-by: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
    Reviewed-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
    Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
    Cc: Brian Norris <computersforpeace@gmail.com>
    Cc: David Woodhouse <dwmw2@infradead.org>
    Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
    Cc: Marek Vasut <marek.vasut@gmail.com>
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
    Cc: linux-mtd@lists.infradead.org
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e4dd76b28d490bcda9ef4cd83dbc4aa104ea5ee4
Author: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
Date:   Wed May 30 18:32:27 2018 +0900

    mtd: cfi_cmdset_0002: Change definition naming to retry write operation
    
    commit 85a82e28b023de9b259a86824afbd6ba07bd6475 upstream.
    
    The definition can be used for other program and erase operations also.
    So change the naming to MAX_RETRIES from MAX_WORD_RETRIES.
    
    Signed-off-by: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
    Reviewed-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
    Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
    Cc: Brian Norris <computersforpeace@gmail.com>
    Cc: David Woodhouse <dwmw2@infradead.org>
    Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
    Cc: Marek Vasut <marek.vasut@gmail.com>
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
    Cc: linux-mtd@lists.infradead.org
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6d0ca495f08bffd54ea7e0e8e93c29a40ee5a128
Author: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
Date:   Wed May 30 18:32:26 2018 +0900

    mtd: cfi_cmdset_0002: Change write buffer to check correct value
    
    commit dfeae1073583dc35c33b32150e18b7048bbb37e6 upstream.
    
    For the word write it is checked if the chip has the correct value.
    But it is not checked for the write buffer as only checked if ready.
    To make sure for the write buffer change to check the value.
    
    It is enough as this patch is only checking the last written word.
    Since it is described by data sheets to check the operation status.
    
    Signed-off-by: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
    Reviewed-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
    Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
    Cc: Brian Norris <computersforpeace@gmail.com>
    Cc: David Woodhouse <dwmw2@infradead.org>
    Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
    Cc: Marek Vasut <marek.vasut@gmail.com>
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
    Cc: linux-mtd@lists.infradead.org
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0bcdb35ecf5bacdd037427a5d27ac7b51512938f
Author: Tadeusz Struk <tadeusz.struk@intel.com>
Date:   Tue May 22 14:37:18 2018 -0700

    tpm: fix race condition in tpm_common_write()
    
    commit 3ab2011ea368ec3433ad49e1b9e1c7b70d2e65df upstream.
    
    There is a race condition in tpm_common_write function allowing
    two threads on the same /dev/tpm<N>, or two different applications
    on the same /dev/tpmrm<N> to overwrite each other commands/responses.
    Fixed this by taking the priv->buffer_mutex early in the function.
    
    Also converted the priv->data_pending from atomic to a regular size_t
    type. There is no need for it to be atomic since it is only touched
    under the protection of the priv->buffer_mutex.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
    Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    [bwh: Backported to 3.16: adjust filenames, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a110acf809054fc5a9af2c7981cf378bd2f59be9
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue May 29 12:13:24 2018 +0300

    libata: zpodd: small read overflow in eject_tray()
    
    commit 18c9a99bce2a57dfd7e881658703b5d7469cc7b9 upstream.
    
    We read from the cdb[] buffer in ata_exec_internal_sg().  It has to be
    ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes.
    
    Fixes: 213342053db5 ("libata: handle power transition of ODD")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 20131c163e5d7375d9c0784c722366e16d4e7937
Author: Colin Ian King <colin.king@canonical.com>
Date:   Wed Sep 6 09:56:29 2017 +0100

    libata: zpodd: make arrays cdb static, reduces object code size
    
    commit 795ef788145ed2fa023efdf11e8d5d7bedc21462 upstream.
    
    Don't populate the arrays cdb on the stack, instead make them static.
    Makes the object code smaller by 230 bytes:
    
    Before:
       text    data     bss     dec     hex filename
       3797     240       0    4037     fc5 drivers/ata/libata-zpodd.o
    
    After:
       text    data     bss     dec     hex filename
       3407     400       0    3807     edf drivers/ata/libata-zpodd.o
    
    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2e87f20d0341df4f8fb713243bd59bffa234ea2e
Author: ming_qian <ming_qian@realsil.com.cn>
Date:   Tue May 8 22:13:08 2018 -0400

    media: uvcvideo: Support realtek's UVC 1.5 device
    
    commit f620d1d7afc7db57ab59f35000752840c91f67e7 upstream.
    
    media: uvcvideo: Support UVC 1.5 video probe & commit controls
    
    The length of UVC 1.5 video control is 48, and it is 34 for UVC 1.1.
    Change it to 48 for UVC 1.5 device, and the UVC 1.5 device can be
    recognized.
    
    More changes to the driver are needed for full UVC 1.5 compatibility.
    However, at least the UVC 1.5 Realtek RTS5847/RTS5852 cameras have been
    reported to work well.
    
    [laurent.pinchart@ideasonboard.com: Factor out code to helper function, update size checks]
    
    Signed-off-by: ming_qian <ming_qian@realsil.com.cn>
    Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Tested-by: Ana Guerrero Lopez <ana.guerrero@collabora.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7be3d7334c443c0b97f09aaf02bc785b933ba9b5
Author: Omar Sandoval <osandov@fb.com>
Date:   Fri May 11 13:13:40 2018 -0700

    Btrfs: reserve space for O_TMPFILE orphan item deletion
    
    commit 399b0bbf5f680797d3599fa14f16706ffc470145 upstream.
    
    btrfs_link() calls btrfs_orphan_del() if it's linking an O_TMPFILE but
    it doesn't reserve space to do so. Even before the removal of the
    orphan_block_rsv it wasn't using it.
    
    Fixes: ef3b9af50bfa ("Btrfs: implement inode_operations callback tmpfile")
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: Omar Sandoval <osandov@fb.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 72bfa437a54ef3cd46afedec7376b5b9cab787a9
Author: Omar Sandoval <osandov@fb.com>
Date:   Fri May 11 13:13:35 2018 -0700

    Btrfs: don't return ino to ino cache if inode item removal fails
    
    commit c08db7d8d295a4f3a10faaca376de011afff7950 upstream.
    
    In btrfs_evict_inode(), if btrfs_truncate_inode_items() fails, the inode
    item will still be in the tree but we still return the ino to the ino
    cache. That will blow up later when someone tries to allocate that ino,
    so don't return it to the cache.
    
    Fixes: 581bb050941b ("Btrfs: Cache free inode numbers in memory")
    Reviewed-by: Josef Bacik <jbacik@fb.com>
    Signed-off-by: Omar Sandoval <osandov@fb.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    [bwh: Backported to 3.16:
     - Pass inode, not btrfs_inode, to btrfs_orphan_del()
     - Pass btrfs_root, not btrfs_fs_info, to btrfs_free_block_rsv()
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c43320eb30c1f753a83d851ddb428f1c677eff32
Author: Omar Sandoval <osandov@fb.com>
Date:   Fri May 11 13:13:31 2018 -0700

    Btrfs: don't BUG_ON() in btrfs_truncate_inode_items()
    
    commit 0552210997badb6a60740a26ff9d976a416510f0 upstream.
    
    btrfs_free_extent() can fail because of ENOMEM. There's no reason to
    panic here, we can just abort the transaction.
    
    Fixes: f4b9aa8d3b87 ("btrfs_truncate")
    Reviewed-by: Nikolay Borisov <nborisov@suse.com>
    Signed-off-by: Omar Sandoval <osandov@fb.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    [bwh: Backported to 3.16:
     - Also pass root to btrfs_abort_transaction()
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3b04e7a639ca236baca5761bd3be26d1d38448ff
Author: Jan Kara <jack@suse.cz>
Date:   Fri May 25 12:51:25 2018 -0400

    ext4: fix fencepost error in check for inode count overflow during resize
    
    commit 4f2f76f751433908364ccff82f437a57d0e6e9b7 upstream.
    
    ext4_resize_fs() has an off-by-one bug when checking whether growing of
    a filesystem will not overflow inode count. As a result it allows a
    filesystem with 8192 inodes per group to grow to 64TB which overflows
    inode count to 0 and makes filesystem unusable. Fix it.
    
    Fixes: 3f8a6411fbada1fa482276591e037f3b1adcf55b
    Reported-by: Jaco Kroon <jaco@uls.co.za>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fe367341a3568bc1fec136c3b50c78905736fd6e
Author: Song Liu <songliubraving@fb.com>
Date:   Thu May 3 12:47:16 2018 -0700

    perf/core: Fix group scheduling with mixed hw and sw events
    
    commit a1150c202207cc8501bebc45b63c264f91959260 upstream.
    
    When hw and sw events are mixed in the same group, they are all attached
    to the hw perf_event_context. This sometimes requires moving group of
    perf_event to a different context.
    
    We found a bug in how the kernel handles this, for example if we do:
    
       perf stat -e '{faults,ref-cycles,faults}'  -I 1000
    
         1.005591180              1,297      faults
         1.005591180        457,476,576      ref-cycles
         1.005591180    <not supported>      faults
    
    First, sw event "faults" is attached to the sw context, and becomes the
    group leader. Then, hw event "ref-cycles" is attached, so both events
    are moved to the hw context. Last, another sw "faults" tries to attach,
    but it fails because of mismatch between the new target ctx (from sw
    pmu) and the group_leader's ctx (hw context, same as ref-cycles).
    
    The broken condition is:
       group_leader is sw event;
       group_leader is on hw context;
       add a sw event to the group.
    
    Fix this scenario by checking group_leader's context (instead of just
    event type). If group_leader is on hw context, use the ->pmu of this
    context to look up context for the new event.
    
    Signed-off-by: Song Liu <songliubraving@fb.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: <kernel-team@fb.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Vince Weaver <vincent.weaver@maine.edu>
    Fixes: b04243ef7006 ("perf: Complete software pmu grouping")
    Link: http://lkml.kernel.org/r/20180503194716.162815-1-songliubraving@fb.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 36c54cf87f0bb6a535c9aa29f94d21a33cbbba53
Author: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Date:   Mon May 21 20:18:07 2018 +0900

    usb: gadget: function: printer: avoid wrong list handling in printer_write()
    
    commit 4a014a7339f441b0851ce012f469c0fadac61c81 upstream.
    
    When printer_write() calls usb_ep_queue(), a udc driver (e.g.
    renesas_usbhs driver) may call usb_gadget_giveback_request() in
    the udc .queue ops immediately. Then, printer_write() calls
    list_add(&req->list, &dev->tx_reqs_active) wrongly. After that,
    if we do unbind the printer driver, WARN_ON() happens in
    printer_func_unbind() because the list entry is not removed.
    
    So, this patch moves list_add(&req->list, &dev->tx_reqs_active)
    calling before usb_ep_queue().
    
    Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b6207330bc4d4d16dcf350ccd7e26dc9c47b4460
Author: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Date:   Wed Sep 13 15:31:33 2017 +0900

    usb: gadget: function: printer: avoid spinlock recursion
    
    commit 9ada8c582088d32bd5c071c17213bc6edf37443a upstream.
    
    If usb_gadget_giveback_request() is called in usb_ep_queue(),
    this printer_write() is possible to cause spinlock recursion. So,
    this patch adds spin_unlock() before calls usb_ep_queue() to avoid it.
    
    Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7ef091768df9d4da21c78e4bd8a00d002adde23a
Author: Mike Marciniszyn <mike.marciniszyn@intel.com>
Date:   Fri May 18 17:07:01 2018 -0700

    IB/qib: Fix DMA api warning with debug kernel
    
    commit 0252f73334f9ef68868e4684200bea3565a4fcee upstream.
    
    The following error occurs in a debug build when running MPI PSM:
    
    [  307.415911] WARNING: CPU: 4 PID: 23867 at lib/dma-debug.c:1158
    check_unmap+0x4ee/0xa20
    [  307.455661] ib_qib 0000:05:00.0: DMA-API: device driver failed to check map
    error[device address=0x00000000df82b000] [size=4096 bytes] [mapped as page]
    [  307.517494] Modules linked in:
    [  307.531584]  ib_isert iscsi_target_mod ib_srpt target_core_mod rpcrdma
    sunrpc ib_srp scsi_transport_srp scsi_tgt ib_iser libiscsi ib_ipoib
    scsi_transport_iscsi rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm
    ib_qib intel_powerclamp coretemp rdmavt intel_rapl iosf_mbi kvm_intel kvm
    irqbypass crc32_pclmul ghash_clmulni_intel ipmi_ssif ib_core aesni_intel sg
    ipmi_si lrw gf128mul dca glue_helper ipmi_devintf iTCO_wdt gpio_ich hpwdt
    iTCO_vendor_support ablk_helper hpilo acpi_power_meter cryptd ipmi_msghandler
    ie31200_edac shpchp pcc_cpufreq lpc_ich pcspkr ip_tables xfs libcrc32c sd_mod
    crc_t10dif crct10dif_generic mgag200 i2c_algo_bit drm_kms_helper syscopyarea
    sysfillrect sysimgblt fb_sys_fops ttm ahci crct10dif_pclmul crct10dif_common
    drm crc32c_intel libahci tg3 libata serio_raw ptp i2c_core
    [  307.846113]  pps_core dm_mirror dm_region_hash dm_log dm_mod
    [  307.866505] CPU: 4 PID: 23867 Comm: mpitests-IMB-MP Kdump: loaded Not
    tainted 3.10.0-862.el7.x86_64.debug #1
    [  307.911178] Hardware name: HP ProLiant DL320e Gen8, BIOS J05 11/09/2013
    [  307.944206] Call Trace:
    [  307.956973]  [<ffffffffbd9e915b>] dump_stack+0x19/0x1b
    [  307.982201]  [<ffffffffbd2a2f58>] __warn+0xd8/0x100
    [  308.005999]  [<ffffffffbd2a2fdf>] warn_slowpath_fmt+0x5f/0x80
    [  308.034260]  [<ffffffffbd5f667e>] check_unmap+0x4ee/0xa20
    [  308.060801]  [<ffffffffbd41acaa>] ? page_add_file_rmap+0x2a/0x1d0
    [  308.090689]  [<ffffffffbd5f6c4d>] debug_dma_unmap_page+0x9d/0xb0
    [  308.120155]  [<ffffffffbd4082e0>] ? might_fault+0xa0/0xb0
    [  308.146656]  [<ffffffffc07761a5>] qib_tid_free.isra.14+0x215/0x2a0 [ib_qib]
    [  308.180739]  [<ffffffffc0776bf4>] qib_write+0x894/0x1280 [ib_qib]
    [  308.210733]  [<ffffffffbd540b00>] ? __inode_security_revalidate+0x70/0x80
    [  308.244837]  [<ffffffffbd53c2b7>] ? security_file_permission+0x27/0xb0
    [  308.266025] qib_ib0.8006: multicast join failed for
    ff12:401b:8006:0000:0000:0000:ffff:ffff, status -22
    [  308.323421]  [<ffffffffbd46f5d3>] vfs_write+0xc3/0x1f0
    [  308.347077]  [<ffffffffbd492a5c>] ? fget_light+0xfc/0x510
    [  308.372533]  [<ffffffffbd47045a>] SyS_write+0x8a/0x100
    [  308.396456]  [<ffffffffbd9ff355>] system_call_fastpath+0x1c/0x21
    
    The code calls a qib_map_page() which has never correctly tested for a
    mapping error.
    
    Fix by testing for pci_dma_mapping_error() in all cases and properly
    handling the failure in the caller.
    
    Additionally, streamline qib_map_page() arguments to satisfy just
    the single caller.
    
    Reviewed-by: Alex Estrin <alex.estrin@intel.com>
    Tested-by: Don Dutile <ddutile@redhat.com>
    Reviewed-by: Don Dutile <ddutile@redhat.com>
    Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
    Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 91044d053e823dbf3964c5b88b17b1743488f046
Author: Alex Estrin <alex.estrin@intel.com>
Date:   Tue May 15 18:31:39 2018 -0700

    IB/isert: Fix for lib/dma_debug check_sync warning
    
    commit 763b69654bfb88ea3230d015e7d755ee8339f8ee upstream.
    
    The following error message occurs on a target host in a debug build
    during session login:
    
    [ 3524.411874] WARNING: CPU: 5 PID: 12063 at lib/dma-debug.c:1207 check_sync+0x4ec/0x5b0
    [ 3524.421057] infiniband hfi1_0: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x0000000000000000] [size=76 bytes]
    ......snip .....
    
    [ 3524.535846] CPU: 5 PID: 12063 Comm: iscsi_np Kdump: loaded Not tainted 3.10.0-862.el7.x86_64.debug #1
    [ 3524.546764] Hardware name: Dell Inc. PowerEdge R430/03XKDV, BIOS 1.2.6 06/08/2015
    [ 3524.555740] Call Trace:
    [ 3524.559102]  [<ffffffffa5fe915b>] dump_stack+0x19/0x1b
    [ 3524.565477]  [<ffffffffa58a2f58>] __warn+0xd8/0x100
    [ 3524.571557]  [<ffffffffa58a2fdf>] warn_slowpath_fmt+0x5f/0x80
    [ 3524.578610]  [<ffffffffa5bf5b8c>] check_sync+0x4ec/0x5b0
    [ 3524.585177]  [<ffffffffa58efc3f>] ? set_cpus_allowed_ptr+0x5f/0x1c0
    [ 3524.592812]  [<ffffffffa5bf5cd0>] debug_dma_sync_single_for_cpu+0x80/0x90
    [ 3524.601029]  [<ffffffffa586add3>] ? x2apic_send_IPI_mask+0x13/0x20
    [ 3524.608574]  [<ffffffffa585ee1b>] ? native_smp_send_reschedule+0x5b/0x80
    [ 3524.616699]  [<ffffffffa58e9b76>] ? resched_curr+0xf6/0x140
    [ 3524.623567]  [<ffffffffc0879af0>] isert_create_send_desc.isra.26+0xe0/0x110 [ib_isert]
    [ 3524.633060]  [<ffffffffc087af95>] isert_put_login_tx+0x55/0x8b0 [ib_isert]
    [ 3524.641383]  [<ffffffffa58ef114>] ? try_to_wake_up+0x1a4/0x430
    [ 3524.648561]  [<ffffffffc098cfed>] iscsi_target_do_tx_login_io+0xdd/0x230 [iscsi_target_mod]
    [ 3524.658557]  [<ffffffffc098d827>] iscsi_target_do_login+0x1a7/0x600 [iscsi_target_mod]
    [ 3524.668084]  [<ffffffffa59f9bc9>] ? kstrdup+0x49/0x60
    [ 3524.674420]  [<ffffffffc098e976>] iscsi_target_start_negotiation+0x56/0xc0 [iscsi_target_mod]
    [ 3524.684656]  [<ffffffffc098c2ee>] __iscsi_target_login_thread+0x90e/0x1070 [iscsi_target_mod]
    [ 3524.694901]  [<ffffffffc098ca50>] ? __iscsi_target_login_thread+0x1070/0x1070 [iscsi_target_mod]
    [ 3524.705446]  [<ffffffffc098ca50>] ? __iscsi_target_login_thread+0x1070/0x1070 [iscsi_target_mod]
    [ 3524.715976]  [<ffffffffc098ca78>] iscsi_target_login_thread+0x28/0x60 [iscsi_target_mod]
    [ 3524.725739]  [<ffffffffa58d60ff>] kthread+0xef/0x100
    [ 3524.732007]  [<ffffffffa58d6010>] ? insert_kthread_work+0x80/0x80
    [ 3524.739540]  [<ffffffffa5fff1b7>] ret_from_fork_nospec_begin+0x21/0x21
    [ 3524.747558]  [<ffffffffa58d6010>] ? insert_kthread_work+0x80/0x80
    [ 3524.755088] ---[ end trace 23f8bf9238bd1ed8 ]---
    [ 3595.510822] iSCSI/iqn.1994-05.com.redhat:537fa56299: Unsupported SCSI Opcode 0xa3, sending CHECK_CONDITION.
    
    The code calls dma_sync on login_tx_desc->dma_addr prior to initializing it
    with dma-mapped address.
    login_tx_desc is a part of iser_conn structure and is used only once
    during login negotiation, so the issue is fixed by eliminating
    dma_sync call for this buffer using a special case routine.
    
    Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
    Reviewed-by: Don Dutile <ddutile@redhat.com>
    Signed-off-by: Alex Estrin <alex.estrin@intel.com>
    Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    [bwh: Backported to 3.16:
     - Parameters to isert_create_send_desc() are not redundant; forward them
       all to __isert_create_send_desc()
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 089b803b8a74ce3c9d16f8d9e1be6de82f7a8723
Author: Michael Schmitz <schmitzmic@gmail.com>
Date:   Mon May 14 23:10:53 2018 +1200

    m68k/mm: Adjust VM area to be unmapped by gap size for __iounmap()
    
    commit 3f90f9ef2dda316d64e420d5d51ba369587ccc55 upstream.
    
    If 020/030 support is enabled, get_io_area() leaves an IO_SIZE gap
    between mappings which is added to the vm_struct representing the
    mapping.  __ioremap() uses the actual requested size (after alignment),
    while __iounmap() is passed the size from the vm_struct.
    
    On 020/030, early termination descriptors are used to set up mappings of
    extent 'size', which are validated on unmapping. The unmapped gap of
    size IO_SIZE defeats the sanity check of the pmd tables, causing
    __iounmap() to loop forever on 030.
    
    On 040/060, unmapping of page table entries does not check for a valid
    mapping, so the umapping loop always completes there.
    
    Adjust size to be unmapped by the gap that had been added in the
    vm_struct prior.
    
    This fixes the hang in atari_platform_init() reported a long time ago,
    and a similar one reported by Finn recently (addressed by removing
    ioremap() use from the SWIM driver.
    
    Tested on my Falcon in 030 mode - untested but should work the same on
    040/060 (the extra page tables cleared there would never have been set
    up anyway).
    
    Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
    [geert: Minor commit description improvements]
    [geert: This was fixed in 2.4.23, but not in 2.5.x]
    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1474ad318dbe0d8c18e663b88845740c468eb31c
Author: Mika Westerberg <mika.westerberg@linux.intel.com>
Date:   Wed May 23 17:14:39 2018 -0500

    PCI: pciehp: Clear Presence Detect and Data Link Layer Status Changed on resume
    
    commit 13c65840feab8109194f9490c9870587173cb29d upstream.
    
    After a suspend/resume cycle the Presence Detect or Data Link Layer Status
    Changed bits might be set.  If we don't clear them those events will not
    fire anymore and nothing happens for instance when a device is now
    hot-unplugged.
    
    Fix this by clearing those bits in a newly introduced function
    pcie_reenable_notification().  This should be fine because immediately
    after, we check if the adapter is still present by reading directly from
    the status register.
    
    Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 922cbdb5e8112cc3f4178b14d1aba837afd51279
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Tue May 22 17:14:07 2018 -0400

    ext4: bubble errors from ext4_find_inline_data_nolock() up to ext4_iget()
    
    commit eb9b5f01c33adebc31cbc236c02695f605b0e417 upstream.
    
    If ext4_find_inline_data_nolock() returns an error it needs to get
    reflected up to ext4_iget().  In order to fix this,
    ext4_iget_extra_inode() needs to return an error (and not return
    void).
    
    This is related to "ext4: do not allow external inodes for inline
    data" (which fixes CVE-2018-11412) in that in the errors=continue
    case, it would be useful to for userspace to receive an error
    indicating that file system is corrupted.
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4cd2e66c8443d3fcdd8dd45d941dad3ad2e2c758
Author: Eric Biggers <ebiggers@google.com>
Date:   Thu Dec 1 14:51:58 2016 -0500

    ext4: don't read out of bounds when checking for in-inode xattrs
    
    commit 290ab230016f187c3551d8380ea742889276d03a upstream.
    
    With i_extra_isize equal to or close to the available space, it was
    possible for us to read past the end of the inode when trying to detect
    or validate in-inode xattrs.  Fix this by checking for the needed extra
    space first.
    
    This patch shouldn't have any noticeable effect on
    non-corrupted/non-malicious filesystems.
    
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit af636c8e6002231c86aef96b5d501498988f63b5
Author: Eric Biggers <ebiggers@google.com>
Date:   Sat Oct 15 09:39:31 2016 -0400

    ext4: correct endianness conversion in __xattr_check_inode()
    
    commit 199625098a18a5522b424dea9b122b254c022fc5 upstream.
    
    It should be cpu_to_le32(), not le32_to_cpu().  No change in behavior.
    
    Found with sparse, and this was the only endianness warning in fs/ext4/.
    
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ee0e34157db3b6589d105a0cbbdf61ba36ff5fce
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Tue Mar 22 16:13:15 2016 -0400

    ext4: check if in-inode xattr is corrupted in ext4_expand_extra_isize_ea()
    
    commit 9e92f48c34eb2b9af9d12f892e2fe1fce5e8ce35 upstream.
    
    We aren't checking to see if the in-inode extended attribute is
    corrupted before we try to expand the inode's extra isize fields.
    
    This can lead to potential crashes caused by the BUG_ON() check in
    ext4_xattr_shift_entries().
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [bwh: Backported to 3.16: s/EFSCORRUPTED/EIO/]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d5a25fcf0e6a8c17e0d6ed310a16a9c3a5559db9
Author: Corey Minyard <cminyard@mvista.com>
Date:   Tue May 22 08:14:51 2018 -0500

    ipmi:bt: Set the timeout before doing a capabilities check
    
    commit fe50a7d0393a552e4539da2d31261a59d6415950 upstream.
    
    There was one place where the timeout value for an operation was
    not being set, if a capabilities request was done from idle.  Move
    the timeout value setting to before where that change might be
    requested.
    
    IMHO the cause here is the invisible returns in the macros.  Maybe
    that's a job for later, though.
    
    Reported-by: Nordmark Claes <Claes.Nordmark@tieto.com>
    Signed-off-by: Corey Minyard <cminyard@mvista.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f19286cfebfb5d0c78318b27606b645920c2c5aa
Author: Stefan M Schaeckeler <sschaeck@cisco.com>
Date:   Mon May 21 16:26:14 2018 -0700

    of: unittest: for strings, account for trailing \0 in property length field
    
    commit 3b9cf7905fe3ab35ab437b5072c883e609d3498d upstream.
    
    For strings, account for trailing \0 in property length field:
    
    This is consistent with how dtc builds string properties.
    
    Function __of_prop_dup() would misbehave on such properties as it duplicates
    properties based on the property length field creating new string values
    without trailing \0s.
    
    Signed-off-by: Stefan M Schaeckeler <sschaeck@cisco.com>
    Reviewed-by: Frank Rowand <frank.rowand@sony.com>
    Tested-by: Frank Rowand <frank.rowand@sony.com>
    Signed-off-by: Rob Herring <robh@kernel.org>
    [bwh: Backported to 3.16: s/unittest/selftest/]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ab4a2c3f0510ae1f3a964a92768b234570a4093e
Author: Doug Ledford <dledford@redhat.com>
Date:   Fri May 18 11:36:09 2018 -0400

    RDMA/ipoib: Update paths on CLIENT_REREG/SM_CHANGE events
    
    commit fa9391dbad4b868512ed22a7e41765f881a8a935 upstream.
    
    We do a light flush on CLIENT_REREG and SM_CHANGE events.  This goes
    through and marks paths invalid. But we weren't always checking for this
    validity when we needed to, and so we could keep using a path marked
    invalid.  What's more, once we establish a path with a valid ah, we put
    a pointer to the ah in the neigh struct directly, so even if we mark the
    path as invalid, as long as the neigh has a direct pointer to the ah, it
    keeps using the old, outdated ah.
    
    To fix this we do several things.
    
    1) Put the valid flag in the ah instead of the path struct, so when we
    put the ah pointer directly in the neigh struct, we can easily check the
    validity of the ah on send events.
    2) Check the neigh->ah and neigh->ah->valid elements in the needed
    places, and if we have an ah, but it's invalid, then invoke a refresh of
    the ah.
    3) Fix the various places that check for path, but didn't check for
    path->valid (now path->ah && path->ah->valid).
    
    Reported-by: Evgenii Smirnov <evgenii.smirnov@profitbricks.com>
    Fixes: ee1e2c82c245 ("IPoIB: Refresh paths instead of flushing them on SM change events")
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    [bwh: Backported to 3.16:
     - s/phdr->hwaddr/cb->hdwaddr/
     - s/ipoib_priv/netdev_priv/
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 02b24d2693e389938d0db4d9b894069e5bd994d2
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri May 18 12:14:32 2018 +0200

    ALSA: hda/conexant - Add fixup for HP Z2 G4 workstation
    
    commit f16041df4c360eccacfe90f96673b37829e4c959 upstream.
    
    HP Z2 G4 requires the same workaround as other HP machines that have
    no mic-pin detection.
    
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fd8ec700984cb32d36b9f693a2c0b6ae311e2999
Author: Boris Brezillon <boris.brezillon@bootlin.com>
Date:   Sun May 13 16:02:12 2018 +0200

    m68k: Implement ndelay() as an inline function to force type checking/casting
    
    commit d8441ba80c55aad435e4b98fe0d7ad5d21e46bf9 upstream.
    
    ndelay() is supposed to take an unsigned long, but if you define
    ndelay() as a macro and the caller pass an unsigned long long instead
    of an unsigned long, the unsigned long long to unsigned long cast is
    not done and we end up with an "undefined reference to `__udivdi3'"
    error at link time.
    
    Fix that by making ndelay() an inline function and then defining dummy
    ndelay() macro that redirects to the ndelay() function (it's how most
    archs do to implement ndelay()).
    
    Fixes: c8ee038bd148 ("m68k: Implement ndelay() based on the existing udelay() logic")
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    [geert: Remove comment now it is no longer a macro]
    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ec9c1eee213a777ffb78dff6f403f5eda63fcc00
Author: Florian Fainelli <f.fainelli@gmail.com>
Date:   Mon May 21 11:45:54 2018 -0700

    net: ethernet: davinci_emac: Fix printing of base address
    
    commit 5a04e8f81a4f55ce1c2b7b525744a187c99ba302 upstream.
    
    Use %pa which is the correct formatter to print a physical address,
    instead of %p which is just a pointer.
    
    Fixes: a6286ee630f6 ("net: Add TI DaVinci EMAC driver")
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c13e9cc7bf73430c9deb2ad8e050bd61fef45564
Author: Michael Neuling <mikey@neuling.org>
Date:   Thu May 17 15:37:15 2018 +1000

    powerpc/ptrace: Fix setting 512B aligned breakpoints with PTRACE_SET_DEBUGREG
    
    commit 4f7c06e26ec9cf7fe9f0c54dc90079b6a4f4b2c3 upstream.
    
    In commit e2a800beaca1 ("powerpc/hw_brk: Fix off by one error when
    validating DAWR region end") we fixed setting the DAWR end point to
    its max value via PPC_PTRACE_SETHWDEBUG. Unfortunately we broke
    PTRACE_SET_DEBUGREG when setting a 512 byte aligned breakpoint.
    
    PTRACE_SET_DEBUGREG currently sets the length of the breakpoint to
    zero (memset() in hw_breakpoint_init()). This worked with
    arch_validate_hwbkpt_settings() before the above patch was applied but
    is now broken if the breakpoint is 512byte aligned.
    
    This sets the length of the breakpoint to 8 bytes when using
    PTRACE_SET_DEBUGREG.
    
    Fixes: e2a800beaca1 ("powerpc/hw_brk: Fix off by one error when validating DAWR region end")
    Signed-off-by: Michael Neuling <mikey@neuling.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5a31ed11c5d4d1ac617039817ce1d59f8dfe40e1
Author: Michael Neuling <mikey@neuling.org>
Date:   Thu May 17 15:37:14 2018 +1000

    powerpc/ptrace: Fix enforcement of DAWR constraints
    
    commit cd6ef7eebf171bfcba7dc2df719c2a4958775040 upstream.
    
    Back when we first introduced the DAWR, in commit 4ae7ebe9522a
    ("powerpc: Change hardware breakpoint to allow longer ranges"), we
    screwed up the constraint making it a 1024 byte boundary rather than a
    512. This makes the check overly permissive. Fortunately GDB is the
    only real user and it always did they right thing, so we never
    noticed.
    
    This fixes the constraint to 512 bytes.
    
    Fixes: 4ae7ebe9522a ("powerpc: Change hardware breakpoint to allow longer ranges")
    Signed-off-by: Michael Neuling <mikey@neuling.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d6a0144b344591bcd480d8407bc5d88949a0caf3
Author: David Rivshin <DRivshin@allworx.com>
Date:   Wed Apr 25 21:15:01 2018 +0100

    ARM: 8764/1: kgdb: fix NUMREGBYTES so that gdb_regs[] is the correct size
    
    commit 76ed0b803a2ab793a1b27d1dfe0de7955282cd34 upstream.
    
    NUMREGBYTES (which is used as the size for gdb_regs[]) is incorrectly
    based on DBG_MAX_REG_NUM instead of GDB_MAX_REGS. DBG_MAX_REG_NUM
    is the number of total registers, while GDB_MAX_REGS is the number
    of 'unsigned longs' it takes to serialize those registers. Since
    FP registers require 3 'unsigned longs' each, DBG_MAX_REG_NUM is
    smaller than GDB_MAX_REGS.
    
    This causes GDB 8.0 give the following error on connect:
    "Truncated register 19 in remote 'g' packet"
    
    This also causes the register serialization/deserialization logic
    to overflow gdb_regs[], overwriting whatever follows.
    
    Fixes: 834b2964b7ab ("kgdb,arm: fix register dump")
    Signed-off-by: David Rivshin <drivshin@allworx.com>
    Acked-by: Rabin Vincent <rabin@rab.in>
    Tested-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9eef0a47ad5fa43ea9500befb72645743ad17a94
Author: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
Date:   Thu May 10 13:45:58 2018 +0200

    scsi: qlogicpti: Fix an error handling path in 'qpti_sbus_probe()'
    
    commit 51b910c3c70986a5a0a84eea11cb8e904e37ba8b upstream.
    
    The 'free_irq()' call is not at the right place in the error handling
    path.  The changed order has been introduced in commit 3d4253d9afab
    ("[SCSI] qlogicpti: Convert to new SBUS device framework.")
    
    Fixes: 3d4253d9afab ("[SCSI] qlogicpti: Convert to new SBUS device framework.")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d20bd909b2025e3e2e804c2d5f00a72df7cb0c14
Author: Steffen Maier <maier@linux.ibm.com>
Date:   Thu May 17 19:14:49 2018 +0200

    scsi: zfcp: fix missing REC trigger trace on enqueue without ERP thread
    
    commit 6a76550841d412330bd86aed3238d1888ba70f0e upstream.
    
    Example trace record formatted with zfcpdbf from s390-tools:
    
    Timestamp      : ...
    Area           : REC
    Subarea        : 00
    Level          : 1
    Exception      : -
    CPU ID         : ..
    Caller         : 0x...
    Record ID      : 1                      ZFCP_DBF_REC_TRIG
    Tag            : .......
    LUN            : 0x...
    WWPN           : 0x...
    D_ID           : 0x...
    Adapter status : 0x...
    Port status    : 0x...
    LUN status     : 0x...
    Ready count    : 0x...
    Running count  : 0x...
    ERP want       : 0x0.                   ZFCP_ERP_ACTION_REOPEN_...
    ERP need       : 0xc0                   ZFCP_ERP_ACTION_NONE
    
    Signed-off-by: Steffen Maier <maier@linux.ibm.com>
    Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bf39fa41468bb0609266a796d84c7c5b90744bb5
Author: Steffen Maier <maier@linux.ibm.com>
Date:   Thu May 17 19:14:48 2018 +0200

    scsi: zfcp: fix missing REC trigger trace for all objects in ERP_FAILED
    
    commit 8c3d20aada70042a39c6a6625be037c1472ca610 upstream.
    
    That other commit introduced an inconsistency because it would trace on
    ERP_FAILED for all callers of port forced reopen triggers (not just
    terminate_rport_io), but it would not trace on ERP_FAILED for all callers of
    other ERP triggers such as adapter, port regular, LUN.
    
    Therefore, generalize that other commit. zfcp_erp_action_enqueue() already
    had two early outs which re-used the one zfcp_dbf_rec_trig() call.  All ERP
    trigger functions finally run through zfcp_erp_action_enqueue().  So move
    the special handling for ZFCP_STATUS_COMMON_ERP_FAILED into
    zfcp_erp_action_enqueue() and add another early out with new trace marker
    for pseudo ERP need in this case. This removes all early returns from all
    ERP trigger functions so we always end up at zfcp_dbf_rec_trig().
    
    Example trace record formatted with zfcpdbf from s390-tools:
    
    Timestamp      : ...
    Area           : REC
    Subarea        : 00
    Level          : 1
    Exception      : -
    CPU ID         : ..
    Caller         : 0x...
    Record ID      : 1                      ZFCP_DBF_REC_TRIG
    Tag            : .......
    LUN            : 0x...
    WWPN           : 0x...
    D_ID           : 0x...
    Adapter status : 0x...
    Port status    : 0x...
    LUN status     : 0x...
    Ready count    : 0x...
    Running count  : 0x...
    ERP want       : 0x0.                   ZFCP_ERP_ACTION_REOPEN_...
    ERP need       : 0xe0                   ZFCP_ERP_ACTION_FAILED
    
    Signed-off-by: Steffen Maier <maier@linux.ibm.com>
    Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 36541945a6149d58ced47e9f22e515ee2262e38d
Author: Steffen Maier <maier@linux.ibm.com>
Date:   Thu May 17 19:14:47 2018 +0200

    scsi: zfcp: fix missing REC trigger trace on terminate_rport_io for ERP_FAILED
    
    commit d70aab55924b44f213fec2b900b095430b33eec6 upstream.
    
    For problem determination we always want to see when we were invoked on the
    terminate_rport_io callback whether we perform something or not.
    
    Temporal event sequence of interest with a long fast_io_fail_tmo of 27 sec:
    
    loose remote port
    
    t   workqueue
    [s] zfcp_q_<dev>       IRQ                 zfcperp<dev>
    
    === ================== =================== ============================
    
      0                    recv RSCN
                           q p.test_link_work
        block rport
         start fast_io_fail_tmo
        send ADISC ELS
      4                    recv ADISC fail
                           block zfcp_port
                                               port forced reopen
                                               send open port
     12                    recv open port fail
                                               q p.gid_pn_work
                                               zfcp_erp_wakeup
                                               (zfcp_erp_wait would return)
        GID_PN fail
    
    Before this point, we got a SCSI trace with tag "sctrpi1" on fast_io_fail,
    e.g. with the typical 5 sec setting.
    
        port.status |= ERP_FAILED
    
    If fast_io_fail_tmo triggers after this point, we missed a SCSI trace.
    
        workqueue
        fc_dl_<host>
        ==================
     27 fc_timeout_fail_rport_io
        fc_terminate_rport_io
        zfcp_scsi_terminate_rport_io
        zfcp_erp_port_forced_reopen
        _zfcp_erp_port_forced_reopen
         if (port.status & ERP_FAILED)
          return;
    
    Therefore, write a trace before above early return.
    
    Example trace record formatted with zfcpdbf from s390-tools:
    
    Timestamp      : ...
    Area           : REC
    Subarea        : 00
    Level          : 1
    Exception      : -
    CPU ID         : ..
    Caller         : 0x...
    Record ID      : 1                      ZFCP_DBF_REC_TRIG
    Tag            : sctrpi1                SCSI terminate rport I/O
    LUN            : 0xffffffffffffffff                     none (invalid)
    WWPN           : 0x<wwpn>
    D_ID           : 0x<n_port_id>
    Adapter status : 0x...
    Port status    : 0x...
    LUN status     : 0x00000000                             none (invalid)
    Ready count    : 0x...
    Running count  : 0x...
    ERP want       : 0x03                   ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
    ERP need       : 0xe0                   ZFCP_ERP_ACTION_FAILED
    
    Signed-off-by: Steffen Maier <maier@linux.ibm.com>
    Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 60df8584420239c9fb1f054ef4e2c802a5ca6d41
Author: Steffen Maier <maier@linux.ibm.com>
Date:   Thu May 17 19:14:46 2018 +0200

    scsi: zfcp: fix missing REC trigger trace on terminate_rport_io early return
    
    commit 96d9270499471545048ed8a6d7f425a49762283d upstream.
    
    get_device() and its internally used kobject_get() only return NULL if they
    get passed NULL as argument. zfcp_get_port_by_wwpn() loops over
    adapter->port_list so the iteration variable port is always non-NULL.
    Struct device is embedded in struct zfcp_port so &port->dev is always
    non-NULL. This is the argument to get_device().  However, if we get an
    fc_rport in terminate_rport_io() for which we cannot find a match within
    zfcp_get_port_by_wwpn(), the latter can return NULL.  v2.6.30 commit
    70932935b61e ("[SCSI] zfcp: Fix oops when port disappears") introduced an
    early return without adding a trace record for this case.  Even if we don't
    need recovery in this case, for debugging we should still see that our
    callback was invoked originally by scsi_transport_fc.
    
    Example trace record formatted with zfcpdbf from s390-tools:
    
    Timestamp      : ...
    Area           : REC
    Subarea        : 00
    Level          : 1
    Exception      : -
    CPU ID         : ..
    Caller         : 0x...
    Record ID      : 1
    Tag            : sctrpin        SCSI terminate rport I/O, no zfcp port
    LUN            : 0xffffffffffffffff                     none (invalid)
    WWPN           : 0x<wwpn>               WWPN
    D_ID           : 0x<n_port_id>          N_Port-ID
    Adapter status : 0x...
    Port status    : 0xffffffff             unknown (-1)
    LUN status     : 0x00000000                             none (invalid)
    Ready count    : 0x...
    Running count  : 0x...
    ERP want       : 0x03                   ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
    ERP need       : 0xc0                   ZFCP_ERP_ACTION_NONE
    
    Signed-off-by: Steffen Maier <maier@linux.ibm.com>
    Fixes: 70932935b61e ("[SCSI] zfcp: Fix oops when port disappears")
    Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a3cdff7c87e04a17109b6bb3125950c36c7e5049
Author: Steffen Maier <maier@linux.ibm.com>
Date:   Thu May 17 19:14:45 2018 +0200

    scsi: zfcp: fix misleading REC trigger trace where erp_action setup failed
    
    commit 512857a795cbbda5980efa4cdb3c0b6602330408 upstream.
    
    If a SCSI device is deleted during scsi_eh host reset, we cannot get a
    reference to the SCSI device anymore since scsi_device_get returns !=0 by
    design. Assuming the recovery of adapter and port(s) was successful,
    zfcp_erp_strategy_followup_success() attempts to trigger a LUN reset for the
    half-gone SCSI device. Unfortunately, it causes the following confusing
    trace record which states that zfcp will do a LUN recovery as "ERP need" is
    ZFCP_ERP_ACTION_REOPEN_LUN == 1 and equals "ERP want".
    
    Old example trace record formatted with zfcpdbf from s390-tools:
    
    Tag:           : ersfs_3 ERP, trigger, unit reopen, port reopen succeeded
    LUN            : 0x<FCP_LUN>
    WWPN           : 0x<WWPN>
    D_ID           : 0x<N_Port-ID>
    Adapter status : 0x5400050b
    Port status    : 0x54000001
    LUN status     : 0x40000000     ZFCP_STATUS_COMMON_RUNNING
                                    but not ZFCP_STATUS_COMMON_UNBLOCKED as it
                                    was closed on close part of adapter reopen
    ERP want       : 0x01
    ERP need       : 0x01           misleading
    
    However, zfcp_erp_setup_act() returns NULL as it cannot get the reference.
    Hence, zfcp_erp_action_enqueue() takes an early goto out and _NO_ recovery
    actually happens.
    
    We always do want the recovery trigger trace record even if no erp_action
    could be enqueued as in this case. For other cases where we did not enqueue
    an erp_action, 'need' has always been zero to indicate this. In order to
    indicate above goto out, introduce an eyecatcher "flag" to mark the "ERP
    need" as 'not needed' but still keep the information which erp_action type,
    that zfcp_erp_required_act() had decided upon, is needed.  0xc_ is chosen to
    be visibly different from 0x0_ in "ERP want".
    
    New example trace record formatted with zfcpdbf from s390-tools:
    
    Tag:           : ersfs_3 ERP, trigger, unit reopen, port reopen succeeded
    LUN            : 0x<FCP_LUN>
    WWPN           : 0x<WWPN>
    D_ID           : 0x<N_Port-ID>
    Adapter status : 0x5400050b
    Port status    : 0x54000001
    LUN status     : 0x40000000
    ERP want       : 0x01
    ERP need       : 0xc1           would need LUN ERP, but no action set up
                       ^
    
    Before v2.6.38 commit ae0904f60fab ("[SCSI] zfcp: Redesign of the debug
    tracing for recovery actions.") we could detect this case because the
    "erp_action" field in the trace was NULL. The rework removed erp_action as
    argument and field from the trace.
    
    This patch here is for tracing. A fix to allow LUN recovery in the case at
    hand is a topic for a separate patch.
    
    See also commit fdbd1c5e27da ("[SCSI] zfcp: Allow running unit/LUN shutdown
    without acquiring reference") for a similar case and background info.
    
    Signed-off-by: Steffen Maier <maier@linux.ibm.com>
    Fixes: ae0904f60fab ("[SCSI] zfcp: Redesign of the debug tracing for recovery actions.")
    Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f6f0862f7474f32c5bc29f75582351093e107bab
Author: Steffen Maier <maier@linux.ibm.com>
Date:   Thu May 17 19:14:44 2018 +0200

    scsi: zfcp: fix missing SCSI trace for retry of abort / scsi_eh TMF
    
    commit 81979ae63e872ef650a7197f6ce6590059d37172 upstream.
    
    We already have a SCSI trace for the end of abort and scsi_eh TMF. Due to
    zfcp_erp_wait() and fc_block_scsi_eh() time can pass between the start of
    our eh callback and an actual send/recv of an abort / TMF request.  In order
    to see the temporal sequence including any abort / TMF send retries, add a
    trace before the above two blocking functions.  This supports problem
    determination with scsi_eh and parallel zfcp ERP.
    
    No need to explicitly trace the beginning of our eh callback, since we
    typically can send an abort / TMF and see its HBA response (in the worst
    case, it's a pseudo response on dismiss all of adapter recovery, e.g. due to
    an FSF request timeout [fsrth_1] of the abort / TMF). If we cannot send, we
    now get a trace record for the first "abrt_wt" or "[lt]r_wait" which denotes
    almost the beginning of the callback.
    
    No need to explicitly trace the wakeup after the above two blocking
    functions because the next retry loop causes another trace in any case and
    that is sufficient.
    
    Example trace records formatted with zfcpdbf from s390-tools:
    
    Timestamp      : ...
    Area           : SCSI
    Subarea        : 00
    Level          : 1
    Exception      : -
    CPU ID         : ..
    Caller         : 0x...
    Record ID      : 1
    Tag            : abrt_wt        abort, before zfcp_erp_wait()
    Request ID     : 0x0000000000000000                     none (invalid)
    SCSI ID        : 0x<scsi_id>
    SCSI LUN       : 0x<scsi_lun>
    SCSI LUN high  : 0x<scsi_lun_high>
    SCSI result    : 0x<scsi_result_of_cmd_to_be_aborted>
    SCSI retries   : 0x<retries_of_cmd_to_be_aborted>
    SCSI allowed   : 0x<allowed_retries_of_cmd_to_be_aborted>
    SCSI scribble  : 0x<req_id_of_cmd_to_be_aborted>
    SCSI opcode    : <CDB_of_cmd_to_be_aborted>
    FCP rsp inf cod: 0x..                                   none (invalid)
    FCP rsp IU     : ...                                    none (invalid)
    
    Timestamp      : ...
    Area           : SCSI
    Subarea        : 00
    Level          : 1
    Exception      : -
    CPU ID         : ..
    Caller         : 0x...
    Record ID      : 1
    Tag            : lr_wait        LUN reset, before zfcp_erp_wait()
    Request ID     : 0x0000000000000000                     none (invalid)
    SCSI ID        : 0x<scsi_id>
    SCSI LUN       : 0x<scsi_lun>
    SCSI LUN high  : 0x<scsi_lun_high>
    SCSI result    : 0x...                                  unrelated
    SCSI retries   : 0x..                                   unrelated
    SCSI allowed   : 0x..                                   unrelated
    SCSI scribble  : 0x...                                  unrelated
    SCSI opcode    : ...                                    unrelated
    FCP rsp inf cod: 0x..                                   none (invalid)
    FCP rsp IU     : ...                                    none (invalid)
    
    Signed-off-by: Steffen Maier <maier@linux.ibm.com>
    Fixes: 63caf367e1c9 ("[SCSI] zfcp: Improve reliability of SCSI eh handlers in zfcp")
    Fixes: af4de36d911a ("[SCSI] zfcp: Block scsi_eh thread for rport state BLOCKED")
    Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bfc1d9495b3c8ad5dfeb42966ab9c083a6d01119
Author: Steffen Maier <maier@linux.ibm.com>
Date:   Thu May 17 19:14:43 2018 +0200

    scsi: zfcp: fix missing SCSI trace for result of eh_host_reset_handler
    
    commit df30781699f53e4fd4c494c6f7dd16e3d5c21d30 upstream.
    
    For problem determination we need to see whether and why we were successful
    or not. This allows deduction of scsi_eh escalation.
    
    Example trace record formatted with zfcpdbf from s390-tools:
    
    Timestamp      : ...
    Area           : SCSI
    Subarea        : 00
    Level          : 1
    Exception      : -
    CPU ID         : ..
    Caller         : 0x...
    Record ID      : 1
    Tag            : schrh_r        SCSI host reset handler result
    Request ID     : 0x0000000000000000                     none (invalid)
    SCSI ID        : 0xffffffff                             none (invalid)
    SCSI LUN       : 0xffffffff                             none (invalid)
    SCSI LUN high  : 0xffffffff                             none (invalid)
    SCSI result    : 0x00002002     field re-used for midlayer value: SUCCESS
                                    or in other cases: 0x2009 == FAST_IO_FAIL
    SCSI retries   : 0xff                                   none (invalid)
    SCSI allowed   : 0xff                                   none (invalid)
    SCSI scribble  : 0xffffffffffffffff                     none (invalid)
    SCSI opcode    : ffffffff ffffffff ffffffff ffffffff    none (invalid)
    FCP rsp inf cod: 0xff                                   none (invalid)
    FCP rsp IU     : 00000000 00000000 00000000 00000000    none (invalid)
                     00000000 00000000
    
    v2.6.35 commit a1dbfddd02d2 ("[SCSI] zfcp: Pass return code from
    fc_block_scsi_eh to scsi eh") introduced the first return with something
    other than the previously hardcoded single SUCCESS return path.
    
    Signed-off-by: Steffen Maier <maier@linux.ibm.com>
    Fixes: a1dbfddd02d2 ("[SCSI] zfcp: Pass return code from fc_block_scsi_eh to scsi eh")
    Reviewed-by: Jens Remus <jremus@linux.ibm.com>
    Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    [bwh: Backported to 3.16: Drop assignment to zfcp_dbf_scsi::scsi_lun_64_hi
     which doesn't exist here]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 25bf6e783610a9eca54a5e007825298e2eee68ba
Author: Colin Ian King <colin.king@canonical.com>
Date:   Wed Apr 25 11:04:21 2018 -0400

    media: smiapp: fix timeout checking in smiapp_read_nvm
    
    commit 7a2148dfda8001c983f0effd9afd8a7fa58e99c4 upstream.
    
    The current code decrements the timeout counter i and the end of
    each loop i is incremented, so the check for timeout will always
    be false and hence the timeout mechanism is just a dead code path.
    Potentially, if the RD_READY bit is not set, we could end up in
    an infinite loop.
    
    Fix this so the timeout starts from 1000 and decrements to zero,
    if at the end of the loop i is zero we have a timeout condition.
    
    Detected by CoverityScan, CID#1324008 ("Logically dead code")
    
    Fixes: ccfc97bdb5ae ("[media] smiapp: Add driver")
    
    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 89bfe6fdb301a414d52bbcf93ac0159bd4c5adf6
Author: Takashi Iwai <tiwai@suse.de>
Date:   Tue May 15 20:25:29 2018 +0200

    ALSA: core: Assure control device to be registered at last
    
    commit dc82e52492f684dcd5ed9e4773e72dbf2203d75e upstream.
    
    The commit 289ca025ee1d ("ALSA: Use priority list for managing device
    list") changed the way to register/disconnect/free devices via a
    single priority list.  This helped to make behavior consistent, but it
    also changed a slight behavior change: namely, the control device is
    registered earlier than others, while it was supposed to be the very
    last one.
    
    I've put SNDRV_DEV_CONTROL in the current position as the release of
    ctl elements often conflict with the private ctl elements some PCM or
    other components may create, which often leads to a double-free.
    But, the order of register and disconnect should be indeed fixed as
    expected in the early days: the control device gets registered at
    last, and disconnected at first.
    
    This patch changes the priority list order to move SNDRV_DEV_CONTROL
    as the last guy to assure the register / disconnect order.  Meanwhile,
    for keeping the messy resource release order, manually treat the
    control and lowlevel devices as last freed one.
    
    Additional note:
    The lowlevel device is the device where a card driver creates at
    probe.  And, we still keep the release order control -> lowlevel, as
    there might  be link from a control element back to a lowlevel object.
    
    Fixes: 289ca025ee1d ("ALSA: Use priority list for managing device list")
    Reported-by: Tzung-Bi Shih <tzungbi@google.com>
    Tested-by: Tzung-Bi Shih <tzungbi@google.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 002714448aa33aa9c38f647b3d44e265909ccf39
Author: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Date:   Fri Apr 27 18:02:59 2018 +0200

    regulator: max8998: Fix platform data retrieval.
    
    commit c1472737914fe5246a672fef6e85c9455de8473f upstream.
    
    Since the max8998 MFD driver supports instantiation by DT, platform data
    retrieval is handled in MFD probe and cell drivers should get use
    the pdata field of max8998_dev struct to obtain them.
    
    Fixes: ee999fb3f17f ("mfd: max8998: Add support for Device Tree")
    Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1e5d8ddd278e8b884c5b57a4512ee68457d2c50e
Author: Lee Jones <lee.jones@linaro.org>
Date:   Tue May 1 10:26:59 2018 +0100

    mfd: tps65911-comparator: Fix an off by one bug
    
    commit 1768391c3674b0c6bdc4947121f15fb0c2f47ec4 upstream.
    
    The COMP1 and COMP2 elements are in 0 and 1 respectively so this code is
    accessing the wrong elements and one space beyond the end of the array.
    
    The "id" variable is never COMP (0) so that code can be removed.
    
    Fixes: 6851ad3ab346 ("TPS65911: Comparator: Add comparator driver")
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e93faf323ab6c9b2075e3c076c950a3ec40867d5
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Fri Apr 20 12:21:05 2018 +0300

    mfd: tps65911-comparator: Fix a build error
    
    commit ac1886165cd1201c5793099b6fbad1876bf98dfe upstream.
    
    In 2012, we changed the tps65910 API and fixed most drivers but forgot
    to update this one.
    
    Fixes: 3f7e82759c69 ("mfd: Commonize tps65910 regmap access through header")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 893663d0ab3c4ee1a542fd292a9ef26febc34297
Author: Laura Abbott <labbott@redhat.com>
Date:   Mon May 14 14:35:09 2018 -0700

    staging: android: ion: Switch to pr_warn_once in ion_buffer_destroy
    
    commit 45ad559a29629cb1c64ee636563c69b71524f077 upstream.
    
    Syzbot reported yet another warning with Ion:
    
    WARNING: CPU: 0 PID: 1467 at drivers/staging/android/ion/ion.c:122
    ion_buffer_destroy+0xd4/0x190 drivers/staging/android/ion/ion.c:122
    Kernel panic - not syncing: panic_on_warn set ...
    
    This is catching that a buffer was freed with an existing kernel mapping
    still present. This can be easily be triggered from userspace by calling
    DMA_BUF_SYNC_START without calling DMA_BUF_SYNC_END. Switch to a single
    pr_warn_once to indicate the error without being disruptive.
    
    Reported-by: syzbot+cd8bcd40cb049efa2770@syzkaller.appspotmail.com
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Laura Abbott <labbott@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f6c2bb725ab6cb8fb0b3feacb5a0cf60e7fd4942
Author: Jens Axboe <axboe@kernel.dk>
Date:   Mon May 14 12:17:31 2018 -0600

    sbitmap: fix race in wait batch accounting
    
    commit c854ab5773be1c1a0d3cef0c3a3261f2c48ab7f8 upstream.
    
    If we have multiple callers of sbq_wake_up(), we can end up in a
    situation where the wait_cnt will continually go more and more
    negative. Consider the case where our wake batch is 1, hence
    wait_cnt will start out as 1.
    
    wait_cnt == 1
    
    CPU0                            CPU1
    atomic_dec_return(), cnt == 0
                                    atomic_dec_return(), cnt == -1
                                    cmpxchg(-1, 0) (succeeds)
                                    [wait_cnt now 0]
    cmpxchg(0, 1) (fails)
    
    This ends up with wait_cnt being 0, we'll wakeup immediately
    next time. Going through the same loop as above again, and
    we'll have wait_cnt -1.
    
    For the case where we have a larger wake batch, the only
    difference is that the starting point will be higher. We'll
    still end up with continually smaller batch wakeups, which
    defeats the purpose of the rolling wakeups.
    
    Always reset the wait_cnt to the batch value. Then it doesn't
    matter who wins the race. But ensure that whomever does win
    the race is the one that increments the ws index and wakes up
    our batch count, loser gets to call __sbq_wake_up() again to
    account his wakeups towards the next active wait state index.
    
    Fixes: 6c0ca7ae292a ("sbitmap: fix wakeup hang after sbq resize")
    Reviewed-by: Omar Sandoval <osandov@fb.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    [bwh: Backported to 3.16:
     - Rename almost everything
     - Adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fb24b672da091a3d7ce4672f690d46b5f4284e81
Author: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date:   Mon May 7 19:10:31 2018 +0900

    driver core: Don't ignore class_dir_create_and_add() failure.
    
    commit 84d0c27d6233a9ba0578b20f5a09701eb66cee42 upstream.
    
    syzbot is hitting WARN() at kernfs_add_one() [1].
    This is because kernfs_create_link() is confused by previous device_add()
    call which continued without setting dev->kobj.parent field when
    get_device_parent() failed by memory allocation fault injection.
    Fix this by propagating the error from class_dir_create_and_add() to
    the calllers of get_device_parent().
    
    [1] https://syzkaller.appspot.com/bug?id=fae0fb607989ea744526d1c082a5b8de6529116f
    
    Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Reported-by: syzbot <syzbot+df47f81c226b31d89fb1@syzkaller.appspotmail.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 92cfd9649a8094dc3a4d67390bdee0d3732ff84a
Author: Andrew F. Davis <afd@ti.com>
Date:   Sat Apr 21 18:55:29 2018 -0500

    rpmsg: Correct support for MODULE_DEVICE_TABLE()
    
    commit 5b7d127726de6eed4b900bc3bbb167837690818f upstream.
    
    Due to missing a missing entry in file2alias.c MODULE_DEVICE_TABLE() are
    not generating the proper module aliases. Add the needed entry here.
    
    Fixes: bcabbccabffe ("rpmsg: add virtio-based remote processor messaging bus")
    Reported-by: Suman Anna <s-anna@ti.com>
    Signed-off-by: Andrew F. Davis <afd@ti.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit cdbb1c75d6b220853774683c59297bb1581738fa
Author: Ingo Flaschberger <ingo.flaschberger@gmail.com>
Date:   Tue May 1 16:10:33 2018 +0200

    1wire: family module autoload fails because of upper/lower case mismatch.
    
    commit 065c09563c872e52813a17218c52cd642be1dca6 upstream.
    
    1wire family module autoload fails because of upper/lower
      case mismatch.
    
    Signed-off-by: Ingo Flaschberger <ingo.flaschberger@gmail.com>
    Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 278331e8b1201038493e71ac3c0fb739e1561b16
Author: NeilBrown <neilb@suse.de>
Date:   Wed Nov 19 14:04:20 2014 +1100

    w1: support auto-load of w1_bq27000 module.
    
    commit 4b7e4f8289c1ca60accb6c1baf31984f69bc2771 upstream.
    
    1/ change request_module call to zero-pad single digit
       family numbers.  This appears to be the intention of
       the code, but not what it actually does.
    
       This means that the alias created for W1_FAMILY_SMEM_01
       might actually be useful.
    
    2/ Define a family name for the BQ27000 battery charge monitor.
       Unfortunately this is the same number as W1_FAMILY_SMEM_01
       so if both a compiled on a system, one module might need to
       be blacklisted.
    
    3/ Add a MODULE_ALIAS for the bq27000.
    
    Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
    Signed-off-by: NeilBrown <neilb@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dbb6b49e08c8afee250600276c9af4d297841707
Author: Stefan Potyra <Stefan.Potyra@elektrobit.com>
Date:   Wed May 2 10:55:31 2018 +0200

    w1: mxc_w1: Enable clock before calling clk_get_rate() on it
    
    commit 955bc61328dc0a297fb3baccd84e9d3aee501ed8 upstream.
    
    According to the API, you may only call clk_get_rate() after actually
    enabling it.
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Fixes: a5fd9139f74c ("w1: add 1-wire master driver for i.MX27 / i.MX31")
    Signed-off-by: Stefan Potyra <Stefan.Potyra@elektrobit.com>
    Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 36f8a0505a39304245d4feba89de0c6e15c96bb1
Author: Dave Martin <Dave.Martin@arm.com>
Date:   Thu May 10 18:08:23 2018 +0100

    tty: pl011: Avoid spuriously stuck-off interrupts
    
    commit 4a7e625ce50412a7711efa0f2ef0b96ce3826759 upstream.
    
    Commit 9b96fbacda34 ("serial: PL011: clear pending interrupts")
    clears the RX and receive timeout interrupts on pl011 startup, to
    avoid a screaming-interrupt scenario that can occur when the
    firmware or bootloader leaves these interrupts asserted.
    
    This has been noted as an issue when running Linux on qemu [1].
    
    Unfortunately, the above fix seems to lead to potential
    misbehaviour if the RX FIFO interrupt is asserted _non_ spuriously
    on driver startup, if the RX FIFO is also already full to the
    trigger level.
    
    Clearing the RX FIFO interrupt does not change the FIFO fill level.
    In this scenario, because the interrupt is now clear and because
    the FIFO is already full to the trigger level, no new assertion of
    the RX FIFO interrupt can occur unless the FIFO is drained back
    below the trigger level.  This never occurs because the pl011
    driver is waiting for an RX FIFO interrupt to tell it that there is
    something to read, and does not read the FIFO at all until that
    interrupt occurs.
    
    Thus, simply clearing "spurious" interrupts on startup may be
    misguided, since there is no way to be sure that the interrupts are
    truly spurious, and things can go wrong if they are not.
    
    This patch instead clears the interrupt condition by draining the
    RX FIFO during UART startup, after clearing any potentially
    spurious interrupt.  This should ensure that an interrupt will
    definitely be asserted if the RX FIFO subsequently becomes
    sufficiently full.
    
    The drain is done at the point of enabling interrupts only.  This
    means that it will occur any time the UART is newly opened through
    the tty layer.  It will not apply to polled-mode use of the UART by
    kgdboc: since that scenario cannot use interrupts by design, this
    should not matter.  kgdboc will interact badly with "normal" use of
    the UART in any case: this patch makes no attempt to paper over
    such issues.
    
    This patch does not attempt to address the case where the RX FIFO
    fills faster than it can be drained: that is a pathological
    hardware design problem that is beyond the scope of the driver to
    work around.  As a failsafe, the number of poll iterations for
    draining the FIFO is limited to twice the FIFO size.  This will
    ensure that the kernel at least boots even if it is impossible to
    drain the FIFO for some reason.
    
    [1] [Qemu-devel] [Qemu-arm] [PATCH] pl011: do not put into fifo
    before enabled the interruption
    https://lists.gnu.org/archive/html/qemu-devel/2018-01/msg06446.html
    
    Reported-by: Wei Xu <xuwei5@hisilicon.com>
    Cc: Russell King <linux@armlinux.org.uk>
    Cc: Linus Walleij <linus.walleij@linaro.org>
    Cc: Peter Maydell <peter.maydell@linaro.org>
    Fixes: 9b96fbacda34 ("serial: PL011: clear pending interrupts")
    Signed-off-by: Dave Martin <Dave.Martin@arm.com>
    Tested-by: Wei Xu <xuwei5@hisilicon.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.16:
     - Open-code pl011_read()
     - s/REG_/UART01x_/
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c7aeaa4227002d6b24feb4746d6a342ae0c88a17
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Sun May 13 22:54:44 2018 -0400

    ext4: do not update s_last_mounted of a frozen fs
    
    commit db6516a5e7ddb6dc72d167b920f2f272596ea22d upstream.
    
    If fs is frozen after mount and before the first file open, the
    update of s_last_mounted bypasses freeze protection and prints out
    a WARNING splat:
    
    $ mount /vdf
    $ fsfreeze -f /vdf
    $ cat /vdf/foo
    
    [   31.578555] WARNING: CPU: 1 PID: 1415 at
    fs/ext4/ext4_jbd2.c:53 ext4_journal_check_start+0x48/0x82
    
    [   31.614016] Call Trace:
    [   31.614997]  __ext4_journal_start_sb+0xe4/0x1a4
    [   31.616771]  ? ext4_file_open+0xb6/0x189
    [   31.618094]  ext4_file_open+0xb6/0x189
    
    If fs is frozen, skip s_last_mounted update.
    
    [backport hint: to apply to stable tree, need to apply also patches
     vfs: add the sb_start_intwrite_trylock() helper
     ext4: factor out helper ext4_sample_last_mounted()]
    
    Fixes: bc0b0d6d69ee ("ext4: update the s_last_mounted field in the superblock")
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Jan Kara <jack@suse.cz>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1a1c235b391833f0c2fe0a02592f1b8c3d04eaa8
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Sun May 13 22:40:30 2018 -0400

    vfs: add the sb_start_intwrite_trylock() helper
    
    commit 0c8e3fe35db9b66ae0030849545030ec7c0fc45c upstream.
    
    Needed by ext4 to test frozen fs before updating s_last_mounted.
    
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8efefbfda5240e03418c9bdd3b35956eac9619f9
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Sun May 13 22:44:23 2018 -0400

    ext4: factor out helper ext4_sample_last_mounted()
    
    commit 833a950882d33a7dfc319d5e152fdf35028936eb upstream.
    
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Jan Kara <jack@suse.cz>
    [bwh: Backported to 3.16:
     - Move up declaration of ret in ext4_file_open()
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c07058e4706535e8c7552f29d243b9e3a7dca29b
Author: Lukas Czerner <lczerner@redhat.com>
Date:   Sun May 13 19:28:35 2018 -0400

    ext4: update mtime in ext4_punch_hole even if no blocks are released
    
    commit eee597ac931305eff3d3fd1d61d6aae553bc0984 upstream.
    
    Currently in ext4_punch_hole we're going to skip the mtime update if
    there are no actual blocks to release. However we've actually modified
    the file by zeroing the partial block so the mtime should be updated.
    
    Moreover the sync and datasync handling is skipped as well, which is
    also wrong. Fix it.
    
    Signed-off-by: Lukas Czerner <lczerner@redhat.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reported-by: Joe Habermann <joe.habermann@quantum.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7de063e7ae69391921529ce37731f03938c19555
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Tue Apr 17 00:39:03 2018 +1000

    powerpc/lib: Fix the feature fixup tests to actually work
    
    commit cad0e39023b43d94d5e38dfd55c103e15bdd093d upstream.
    
    The code patching code has always been a bit confused about whether
    it's best to use void *, unsigned int *, char *, etc. to point to
    instructions. In fact in the feature fixups tests we use both unsigned
    int[] and u8[] in different places.
    
    Unfortunately the tests that use unsigned int[] calculate the size of
    the code blocks using subtraction of those unsigned int pointers, and
    then pass the result to memcmp(). This means we're only comparing 1/4
    of the bytes we need to, because we need to multiply by
    sizeof(unsigned int) to get the number of *bytes*.
    
    The result is that the tests do all the patching and then only compare
    some of the resulting code, so patching bugs that only effect that
    last 3/4 of the code could slip through undetected. It turns out that
    hasn't been happening, although one test had a bad expected case (see
    previous commit).
    
    Fix it for now by multiplying the size by 4 in the affected functions.
    
    Fixes: 362e7701fd18 ("powerpc: Add self-tests of the feature fixup code")
    Epic-brown-paper-bag-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4c1ef5a46fd3cb8fe54ceabc1757eea56a201819
Author: Daniel Axtens <dja@axtens.net>
Date:   Wed Jul 12 14:36:07 2017 -0700

    powerpc: make feature-fixup tests fortify-safe
    
    commit c69a48cdb301a18697bc8c9935baf4f32861cf9e upstream.
    
    Testing the fortified string functions[1] would cause a kernel panic on
    boot in test_feature_fixups() due to a buffer overflow in memcmp.
    
    This boils down to things like this:
    
      extern unsigned int ftr_fixup_test1;
      extern unsigned int ftr_fixup_test1_orig;
    
      check(memcmp(&ftr_fixup_test1, &ftr_fixup_test1_orig, size) == 0);
    
    We know that these are asm labels so it is safe to read up to 'size'
    bytes at those addresses.
    
    However, because we have passed the address of a single unsigned int to
    memcmp, the compiler believes the underlying object is in fact a single
    unsigned int.  So if size > sizeof(unsigned int), there will be a panic
    at runtime.
    
    We can fix this by changing the types: instead of calling the asm labels
    unsigned ints, call them unsigned int[]s.  Therefore the size isn't
    incorrectly determined at compile time and we get a regular unsafe
    memcmp and no panic.
    
    [1] http://openwall.com/lists/kernel-hardening/2017/05/09/2
    
    Link: http://lkml.kernel.org/r/1497903987-21002-7-git-send-email-keescook@chromium.org
    Signed-off-by: Daniel Axtens <dja@axtens.net>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
    Tested-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
    Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Daniel Micay <danielmicay@gmail.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0035168323cada6fed717d4eb1415156d300fd65
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Tue Apr 17 00:39:02 2018 +1000

    powerpc/lib: Fix feature fixup test of external branch
    
    commit 32810d91325ec76b8ef4df463f8a0e9baf353322 upstream.
    
    The expected case for this test was wrong, the source of the alternate
    code sequence is:
    
      FTR_SECTION_ELSE
      2:    or      2,2,2
            PPC_LCMPI       r3,1
            beq     3f
            blt     2b
            b       3f
            b       1b
      ALT_FTR_SECTION_END(0, 1)
      3:    or      1,1,1
            or      2,2,2
      4:    or      3,3,3
    
    So when it's patched the '3' label should still be on the 'or 1,1,1',
    and the 4 label is irrelevant and can be removed.
    
    Fixes: 362e7701fd18 ("powerpc: Add self-tests of the feature fixup code")
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4f5cd39a7ee0b918471299284a21d193ba5b9b1a
Author: Evan Green <evgreen@chromium.org>
Date:   Fri Apr 13 13:33:36 2018 -0700

    clk: qcom: Base rcg parent rate off plan frequency
    
    commit c7d2a0eb6c028ba064bfe92d7667977418142c7c upstream.
    
    _freq_tbl_determine_rate uses the pre_div found in the clock plan
    multiplied by the requested rate from the caller to determine the
    best parent rate to set. If the requested rate is not exactly equal
    to the rate that was found in the clock plan, then using the requested
    rate in parent rate calculations is incorrect. For instance, if 150MHz
    was requested, but 200MHz was the match found, and that plan had a
    pre_div of 3, then the parent should be set to 600MHz, not 450MHz.
    
    Signed-off-by: Evan Green <evgreen@chromium.org>
    Fixes: bcd61c0f535a ("clk: qcom: Add support for root clock generators (RCGs)")
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f3ba3c79f8ddca198e76a4350a1fca24d7a78500
Author: Doug Berger <opendmb@gmail.com>
Date:   Wed Apr 25 16:40:30 2018 -0700

    PM / wakeup: Only update last time for active wakeup sources
    
    commit 2ef7c01c0cdb170142058c6d8fe0697aee4e4d7d upstream.
    
    When wakelock support was added, the wakeup_source_add() function
    was updated to set the last_time value of the wakeup source. This
    has the unintended side effect of producing confusing output from
    pm_print_active_wakeup_sources() when a wakeup source is added
    prior to a sleep that is blocked by a different wakeup source.
    
    The function pm_print_active_wakeup_sources() will search for the
    most recently active wakeup source when no active source is found.
    If a wakeup source is added after a different wakeup source blocks
    the system from going to sleep it may have a later last_time value
    than the blocking source and be output as the last active wakeup
    source even if it has never actually been active.
    
    It looks to me like the change to wakeup_source_add() was made to
    prevent the wakelock garbage collection from accidentally dropping
    a wakelock during the narrow window between adding the wakelock to
    the wakelock list in wakelock_lookup_add() and the activation of
    the wakeup source in pm_wake_lock().
    
    This commit changes the behavior so that only the last_time of the
    wakeup source used by a wakelock is initialized prior to adding it
    to the wakeup source list. This preserves the meaning of the
    last_time value as the last time the wakeup source was active and
    allows a wakeup source that has never been active to have a
    last_time value of 0.
    
    Fixes: b86ff9820fd5 (PM / Sleep: Add user space interface for manipulating wakeup sources, v3)
    Signed-off-by: Doug Berger <opendmb@gmail.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 02d035a7c4f6b97a0f07cbd41ae8f268628f9fe7
Author: Thomas Richter <tmricht@linux.ibm.com>
Date:   Tue May 8 10:18:39 2018 +0200

    s390/cpum_sf: Add data entry sizes to sampling trailer entry
    
    commit 77715b7ddb446bd39a06f3376e85f4bb95b29bb8 upstream.
    
    The CPU Measurement sampling facility creates a trailer entry for each
    Sample-Data-Block of stored samples. The trailer entry contains the sizes
    (in bytes) of the stored sampling types:
     - basic-sampling data entry size
     - diagnostic-sampling data entry size
    Both sizes are 2 bytes long.
    
    This patch changes the trailer entry definition to reflect this.
    
    Fixes: fcc77f507333 ("s390/cpum_sf: Atomically reset trailer entry fields of sample-data-blocks")
    Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
    Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3c7f2fc604aa9a4e4bb8d5be6ba32fd592f7d94c
Author: Thomas Richter <tmricht@linux.ibm.com>
Date:   Tue May 8 07:53:39 2018 +0200

    perf: fix invalid bit in diagnostic entry
    
    commit 3c0a83b14ea71fef5ccc93a3bd2de5f892be3194 upstream.
    
    The s390 CPU measurement facility sampling mode supports basic entries
    and diagnostic entries. Each entry has a valid bit to indicate the
    status of the entry as valid or invalid.
    
    This bit is bit 31 in the diagnostic entry, but the bit mask definition
    refers to bit 30.
    
    Fix this by making the reserved field one bit larger.
    
    Fixes: 7e75fc3ff4cf ("s390/cpum_sf: Add raw data sampling to support the diagnostic-sampling function")
    Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
    Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 96cb0b0fffec78ef7812da1766c57dcc3479641d
Author: Scott Mayhew <smayhew@redhat.com>
Date:   Mon May 7 09:01:08 2018 -0400

    nfsd: restrict rd_maxcount to svc_max_payload in nfsd_encode_readdir
    
    commit 9c2ece6ef67e9d376f32823086169b489c422ed0 upstream.
    
    nfsd4_readdir_rsize restricts rd_maxcount to svc_max_payload when
    estimating the size of the readdir reply, but nfsd_encode_readdir
    restricts it to INT_MAX when encoding the reply.  This can result in log
    messages like "kernel: RPC request reserved 32896 but used 1049444".
    
    Restrict rd_dircount similarly (no reason it should be larger than
    svc_max_payload).
    
    Signed-off-by: Scott Mayhew <smayhew@redhat.com>
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9960e579def38fc0846467db403ae587a3706c5c
Author: Tobias Jordan <Tobias.Jordan@elektrobit.com>
Date:   Mon Apr 30 16:30:06 2018 +0200

    spi: pxa2xx: check clk_prepare_enable() return value
    
    commit 62bbc864d1946c715063bd481bff3641fd1324e2 upstream.
    
    clk_prepare_enable() can fail, so its return value should be checked and
    acted upon.
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Fixes: 3343b7a6d2cd ("spi/pxa2xx: convert to the common clk framework")
    Signed-off-by: Tobias Jordan <Tobias.Jordan@elektrobit.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0dfb4c0eb22ca420703a0ff2a2524c0c66d43657
Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Date:   Fri Apr 27 11:53:18 2018 +0530

    powerpc/fadump: Unregister fadump on kexec down path.
    
    commit 722cde76d68e8cc4f3de42e71c82fd40dea4f7b9 upstream.
    
    Unregister fadump on kexec down path otherwise the fadump registration
    in new kexec-ed kernel complains that fadump is already registered.
    This makes new kernel to continue using fadump registered by previous
    kernel which may lead to invalid vmcore generation. Hence this patch
    fixes this issue by un-registering fadump in fadump_cleanup() which is
    called during kexec path so that new kernel can register fadump with
    new valid values.
    
    Fixes: b500afff11f6 ("fadump: Invalidate registration and release reserved memory for general use.")
    Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d30d31ef7aa090243653a69fc0f89f85526c8f08
Author: Dmitry Safonov <dima@arista.com>
Date:   Sat Mar 31 01:33:11 2018 +0100

    iommu/vt-d: Ratelimit each dmar fault printing
    
    commit 6c50d79f66382d78918a768374839d6d1b606d3f upstream.
    
    There is a ratelimit for printing, but it's incremented each time the
    cpu recives dmar fault interrupt. While one interrupt may signal about
    *many* faults.
    So, measuring the impact it turns out that reading/clearing one fault
    takes < 1 usec, and printing info about the fault takes ~170 msec.
    
    Having in mind that maximum number of fault recording registers per
    remapping hardware unit is 256.. IRQ handler may run for (170*256) msec.
    And as fault-serving loop runs without a time limit, during servicing
    new faults may occur..
    
    Ratelimit each fault printing rather than each irq printing.
    
    Fixes: commit c43fce4eebae ("iommu/vt-d: Ratelimit fault handler")
    
    BUG: spinlock lockup suspected on CPU#0, CliShell/9903
     lock: 0xffffffff81a47440, .magic: dead4ead, .owner: kworker/u16:2/8915, .owner_cpu: 6
    CPU: 0 PID: 9903 Comm: CliShell
    Call Trace:$\n'
    [..] dump_stack+0x65/0x83$\n'
    [..] spin_dump+0x8f/0x94$\n'
    [..] do_raw_spin_lock+0x123/0x170$\n'
    [..] _raw_spin_lock_irqsave+0x32/0x3a$\n'
    [..] uart_chars_in_buffer+0x20/0x4d$\n'
    [..] tty_chars_in_buffer+0x18/0x1d$\n'
    [..] n_tty_poll+0x1cb/0x1f2$\n'
    [..] tty_poll+0x5e/0x76$\n'
    [..] do_select+0x363/0x629$\n'
    [..] compat_core_sys_select+0x19e/0x239$\n'
    [..] compat_SyS_select+0x98/0xc0$\n'
    [..] sysenter_dispatch+0x7/0x25$\n'
    [..]
    NMI backtrace for cpu 6
    CPU: 6 PID: 8915 Comm: kworker/u16:2
    Workqueue: dmar_fault dmar_fault_work
    Call Trace:$\n'
    [..] wait_for_xmitr+0x26/0x8f$\n'
    [..] serial8250_console_putchar+0x1c/0x2c$\n'
    [..] uart_console_write+0x40/0x4b$\n'
    [..] serial8250_console_write+0xe6/0x13f$\n'
    [..] call_console_drivers.constprop.13+0xce/0x103$\n'
    [..] console_unlock+0x1f8/0x39b$\n'
    [..] vprintk_emit+0x39e/0x3e6$\n'
    [..] printk+0x4d/0x4f$\n'
    [..] dmar_fault+0x1a8/0x1fc$\n'
    [..] dmar_fault_work+0x15/0x17$\n'
    [..] process_one_work+0x1e8/0x3a9$\n'
    [..] worker_thread+0x25d/0x345$\n'
    [..] kthread+0xea/0xf2$\n'
    [..] ret_from_fork+0x58/0x90$\n'
    
    Cc: Alex Williamson <alex.williamson@redhat.com>
    Cc: David Woodhouse <dwmw2@infradead.org>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Joerg Roedel <joro@8bytes.org>
    Cc: Lu Baolu <baolu.lu@linux.intel.com>
    Cc: iommu@lists.linux-foundation.org
    Signed-off-by: Dmitry Safonov <dima@arista.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5a8511299032d12cbb5d3d3c19f9dd3035c26868
Author: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Date:   Wed May 2 22:48:16 2018 +0900

    ALSA: hda/ca0132: fix build failure when a local macro is defined
    
    commit 8e142e9e628975b0dddd05cf1b095331dff6e2de upstream.
    
    DECLARE_TLV_DB_SCALE (alias of SNDRV_CTL_TLVD_DECLARE_DB_SCALE) is used but
    tlv.h is not included. This causes build failure when local macro is
    defined by comment-out.
    
    This commit fixes the bug. At the same time, the alias macro is replaced
    with a destination macro added at a commit 46e860f76804 ("ALSA: rename
    TLV-related macros so that they're friendly to user applications")
    
    Reported-by: Connor McAdams <conmanx360@gmail.com>
    Fixes: 44f0c9782cc6 ('ALSA: hda/ca0132: Add tuning controls')
    Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c185d150bcb434a3971719cab32013749ee6e9e7
Author: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Date:   Sat Apr 28 22:51:39 2018 +0200

    ASoC: cirrus: i2s: Fix {TX|RX}LinCtrlData setup
    
    commit 5d302ed3cc80564fb835bed5fdba1e1250ecc9e5 upstream.
    
    According to "EP93xx User’s Guide", I2STXLinCtrlData and I2SRXLinCtrlData
    registers actually have different format. The only currently used bit
    (Left_Right_Justify) has different position. Fix this and simplify the
    whole setup taking into account the fact that both registers have zero
    default value.
    
    The practical effect of the above is repaired SND_SOC_DAIFMT_RIGHT_J
    support (currently unused).
    
    Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4f789644f02719d10e9227008da381f2f903b2bb
Author: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Date:   Sat Apr 28 22:51:38 2018 +0200

    ASoC: cirrus: i2s: Fix LRCLK configuration
    
    commit 2d534113be9a2aa532a1ae127a57e83558aed358 upstream.
    
    The bit responsible for LRCLK polarity is i2s_tlrs (0), not i2s_trel (2)
    (refer to "EP93xx User's Guide").
    
    Previously card drivers which specified SND_SOC_DAIFMT_NB_IF actually got
    SND_SOC_DAIFMT_NB_NF, an adaptation is necessary to retain the old
    behavior.
    
    Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 47d0dbf7b97ca07f7c4567b5f12cfa12926afed6
Author: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Date:   Tue Apr 24 18:17:35 2018 -0300

    sctp: fix identification of new acks for SFR-CACC
    
    commit 51446780fc33e45cb790c05a7fa2c5bf7e8bc53b upstream.
    
    It's currently written as:
    
    if (!tchunk->tsn_gap_acked) {   [1]
            tchunk->tsn_gap_acked = 1;
            ...
    }
    
    if (TSN_lte(tsn, sack_ctsn)) {
            if (!tchunk->tsn_gap_acked) {
                    /* SFR-CACC processing */
                    ...
            }
    }
    
    Which causes the SFR-CACC processing on ack reception to never process,
    as tchunk->tsn_gap_acked is always true by then. Block [1] was
    moved to that position by the commit marked below.
    
    This patch fixes it by doing SFR-CACC processing earlier, before
    tsn_gap_acked is set to true.
    
    Fixes: 31b02e154940 ("sctp: Failover transmitted list on transport delete")
    Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Reviewed-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Neil Horman <nhorman@tuxdriver.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 92f5d9d8952fb03ec2d2dc0ed66c7fa21f925772
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Fri Apr 20 09:14:56 2018 -0500

    signal/xtensa: Consistenly use SIGBUS in do_unaligned_user
    
    commit 7de712ccc096b81d23cc0a941cd9b8cb3956605d upstream.
    
    While working on changing this code to use force_sig_fault I
    discovered that do_unaliged_user is sets si_signo to SIGBUS and passes
    SIGSEGV to force_sig_info.  Which is just b0rked.
    
    The code is reporting a SIGBUS error so replace the SIGSEGV with SIGBUS.
    
    Cc: Chris Zankel <chris@zankel.net>
    Cc: Max Filippov <jcmvbkbc@gmail.com>
    Cc: linux-xtensa@linux-xtensa.org
    Acked-by: Max Filippov <jcmvbkbc@gmail.com>
    Fixes: 5a0015d62668 ("[PATCH] xtensa: Architecture support for Tensilica Xtensa Part 3")
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e937477abee0fc0a5afada7074459b06cc39000b
Author: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
Date:   Thu Jan 4 21:43:03 2018 +0300

    usb: do not reset if a low-speed or full-speed device timed out
    
    commit 6e01827ed93947895680fbdad68c072a0f4e2450 upstream.
    
    Some low-speed and full-speed devices (for example, bluetooth)
    do not have time to initialize. For them, ETIMEDOUT is a valid error.
    We need to give them another try. Otherwise, they will
    never be initialized correctly and in dmesg will be messages
    "Bluetooth: hci0 command 0x1002 tx timeout" or similars.
    
    Fixes: 264904ccc33c ("usb: retry reset if a device times out")
    Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 78100750ec132d3cbbaa9ac93611776ea3c9d44e
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu Apr 5 14:17:19 2018 +0300

    mwifiex: pcie: tighten a check in mwifiex_pcie_process_event_ready()
    
    commit 01eca2842874b9a85b7cd1e1b0e5b34a5d53a21f upstream.
    
    If "evt_len" is 1 then we try to memcpy() negative 3 bytes and it would
    cause memory corruption.
    
    Fixes: d930faee141b ("mwifiex: add support for Marvell pcie8766 chipset")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9447dabf5ea263c3a34a8d7c9f4e7b56259a558f
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu Apr 19 13:05:49 2018 +0300

    PCI: ibmphp: Fix use-before-set in get_max_bus_speed()
    
    commit 4051f5ebb11c6ef4b0d3eac2fbbd187c070656c5 upstream.
    
    The "rc" variable is only initialized on the error path.  The caller
    doesn't check the return but, if "rc" is non-zero, then this function is
    basically a no-op.
    
    Fixes: 3749c51ac6c1 ("PCI: Make current and maximum bus speeds part of the PCI core")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit cbdbd77659323e434d505c1329c06cc9efba9ad6
Author: Sean Young <sean@mess.org>
Date:   Sun Apr 8 06:36:40 2018 -0400

    media: rc: mce_kbd decoder: fix stuck keys
    
    commit 63039c29f7a4ce8a8bd165173840543c0098d7b0 upstream.
    
    The MCE Remote sends a 0 scancode when keys are released. If this is not
    received or decoded, then keys can get "stuck"; the keyup event is not
    sent since the input_sync() is missing from the timeout handler.
    
    Signed-off-by: Sean Young <sean@mess.org>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    [bwh: Backported to 3.16: s/raw->mce_kbd\.idev/mce_kbd->idev/]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2b83def15334868b630d0396e174c9ce78fde8be
Author: Kai-Heng Feng <kai.heng.feng@canonical.com>
Date:   Mon Mar 26 02:06:16 2018 -0400

    media: cx231xx: Add support for AverMedia DVD EZMaker 7
    
    commit 29e61d6ef061b012d320327af7dbb3990e75be45 upstream.
    
    User reports AverMedia DVD EZMaker 7 can be driven by VIDEO_GRABBER.
    Add the device to the id_table to make it work.
    
    BugLink: https://bugs.launchpad.net/bugs/1620762
    
    Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Signed-off-by: Hans Verkuil <hansverk@cisco.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b283cad9b54404d00467842cb48f83a6022c3161
Author: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Date:   Thu Apr 19 14:05:21 2018 +1200

    net-next: ax88796: Do not free IRQ in ax_remove() (already freed in ax_close()).
    
    commit 9144c3795c2636351d553e4d0fc5297201182de2 upstream.
    
    This complements the fix in 82533ad9a1c ("net: ethernet: ax88796:
    don't call free_irq without request_irq first") that removed the
    free_irq call in the error path of probe, to also not call free_irq
    when remove is called to revert the effects of probe.
    
    Fixes: 82533ad9a1c (net: ethernet: ax88796: don't call free_irq without request_irq first)
    Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
    Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
    Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3d613ea869e6d05692c55790cd4653c8ac8c4e17
Author: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Date:   Mon Apr 16 17:52:45 2018 +0200

    pinctrl: samsung: Correct EINTG banks order
    
    commit 5cf9a338db94cfd570aa2607bef1b30996f188e3 upstream.
    
    All banks with GPIO interrupts should be at beginning of bank array and
    without any other types of banks between them.  This order is expected
    by exynos_eint_gpio_irq, when doing interrupt group to bank translation.
    Otherwise, kernel NULL pointer dereference would happen when trying to
    handle interrupt, due to wrong bank being looked up.  Observed on
    s5pv210, when trying to handle gpj0 interrupt, where kernel was mapping
    it to gpi bank.
    
    Fixes: 023e06dfa688 ("pinctrl: exynos: add exynos5410 SoC specific data")
    Fixes: 608a26a7bc04 ("pinctrl: Add s5pv210 support to pinctrl-exynos)
    Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
    Reviewed-by: Tomasz Figa <tomasz.figa@gmail.com>
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    [bwh: Backported to 3.16:
     - Drop change to exynos5410_pin_banks0
     - Adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f12d67fe8c48998594d6f4391d64542a3752f04d
Author: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Date:   Wed Apr 11 11:47:32 2018 -0400

    media: v4l2-compat-ioctl32: prevent go past max size
    
    commit ea72fbf588ac9c017224dcdaa2019ff52ca56fee upstream.
    
    As warned by smatch:
            drivers/media/v4l2-core/v4l2-compat-ioctl32.c:879 put_v4l2_ext_controls32() warn: check for integer overflow 'count'
    
    The access_ok() logic should check for too big arrays too.
    
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b178791d107543a994ede9ced5d8b247c8d0551c
Author: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Date:   Thu Apr 5 05:30:52 2018 -0400

    media: dvb_frontend: fix locking issues at dvb_frontend_get_event()
    
    commit 76d81243a487c09619822ef8e7201a756e58a87d upstream.
    
    As warned by smatch:
            drivers/media/dvb-core/dvb_frontend.c:314 dvb_frontend_get_event() warn: inconsistent returns 'sem:&fepriv->sem'.
              Locked on:   line 288
                           line 295
                           line 306
                           line 314
              Unlocked on: line 303
    
    The lock implementation for get event is wrong, as, if an
    interrupt occurs, down_interruptible() will fail, and the
    routine will call up() twice when userspace calls the ioctl
    again.
    
    The bad code is there since when Linux migrated to git, in
    2005.
    
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d4580c867a0b949776bffe15f343e24f88df2f65
Author: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Date:   Thu Apr 5 10:42:48 2018 -0400

    media: omap3isp/isp: remove an unused static var
    
    commit 3f4836beb2ebeb0211d9911d878a267d687e0e6e upstream.
    
    The isp_xclk_init_data const data isn't used anywere.
    
    drivers/media/platform/omap3isp/isp.c:294:35: warning: ‘isp_xclk_init_data’ defined but not used [-Wunused-const-variable=]
     static const struct clk_init_data isp_xclk_init_data = {
                                       ^~~~~~~~~~~~~~~~~~
    
    Fixes: 9b28ee3c9122 ("[media] omap3isp: Use the common clock framework")
    
    Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7ed075be95f1a04211d68614bc6403722974f52f
Author: John Syne <rodrigosiqueiramelo@gmail.com>
Date:   Fri Mar 23 11:25:48 2018 -0300

    staging:iio:ade7854: Fix the wrong number of bits to read
    
    commit 6cef2ab01636b6021044f349df466a97c408ec27 upstream.
    
    Fixes: correctly handle the data size in the read operation for I2C
    
    The function ade7854_i2c_read_reg_32() have to invoke the
    i2c_master_recv() for read 32 bits values, however, the counter is set
    to 3 which means 24 bits. This patch fixes the wrong size of 24 bits, to
    32 bits.
    
    Signed-off-by: John Syne <john3909@gmail.com>
    Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
    Fixes: 8d97a5877 ("staging: iio: meter: new driver for ADE7754 devices")
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9ed19f0929bb01a7a0caf5191a5b931244db3376
Author: John Syne <rodrigosiqueiramelo@gmail.com>
Date:   Fri Mar 23 11:22:10 2018 -0300

    staging:iio:ade7854: Fix error handling on read/write
    
    commit 4297b23d927fa5265378f4a71372ecef3c33023a upstream.
    
    The original code does not correctly handle the error related to I2C
    read and write. This patch fixes the error handling related to all
    read/write functions for I2C.
    
    Signed-off-by: John Syne <john3909@gmail.com>
    Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
    Fixes: 8d97a5877 ("staging: iio: meter: new driver for ADE7754 devices")
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 902df9f02c390435343b67f55ad993b7854efe4e
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Thu Feb 8 15:17:38 2018 +0100

    fuse: atomic_o_trunc should truncate pagecache
    
    commit df0e91d488276086bc07da2e389986cae0048c37 upstream.
    
    Fuse has an "atomic_o_trunc" mode, where userspace filesystem uses the
    O_TRUNC flag in the OPEN request to truncate the file atomically with the
    open.
    
    In this mode there's no need to send a SETATTR request to userspace after
    the open, so fuse_do_setattr() checks this mode and returns.  But this
    misses the important step of truncating the pagecache.
    
    Add the missing parts of truncation to the ATTR_OPEN branch.
    
    Reported-by: Chad Austin <chadaustin@fb.com>
    Fixes: 6ff958edbf39 ("fuse: add atomic open+truncate support")
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 05fcfbf99a76a596ff8849c09afcd770cf9e9b35
Author: Andrew Morton <akpm@linux-foundation.org>
Date:   Mon Oct 13 15:54:22 2014 -0700

    arch/x86/kernel/cpu/common.c: fix unused symbol warning
    
    commit e48510f45107613bf14060eeabd658c49a044242 upstream.
    
    x86_64 allnoconfig:
    
    arch/x86/kernel/cpu/common.c:968: warning: 'syscall32_cpu_init' defined but not used
    
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ingo Molnar <mingo@elte.hu>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fa179e66ab5ee3ff2efd36d7d5cc1afdfd539e62
Author: Prabhakar Lad <prabhakar.csengg@gmail.com>
Date:   Thu Jul 20 04:56:31 2017 -0400

    media: platform: davinci: drop VPFE_CMD_S_CCDC_RAW_PARAMS
    
    commit d75cf0144f150272be806b69b4e62553ba07ea1b upstream.
    
    drop VPFE_CMD_S_CCDC_RAW_PARAMS ioctl from dm355/dm644x following reasons:
    
    - This ioctl was never in public api and was only defined in kernel header.
    - The function set_params constantly mixes up pointers and phys_addr_t
      numbers.
    - This is part of a 'VPFE_CMD_S_CCDC_RAW_PARAMS' ioctl command that is
      described as an 'experimental ioctl that will change in future kernels'.
    - The code to allocate the table never gets called after we copy_from_user
      the user input over the kernel settings, and then compare them
      for inequality.
    - We then go on to use an address provided by user space as both the
      __user pointer for input and pass it through phys_to_virt to come up
      with a kernel pointer to copy the data to. This looks like a trivially
      exploitable root hole.
    
    Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
    Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    [bwh: Backported to 3.16: deleted code was slightly different]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 04eb6a1c2aab2e9e58799f6957b38a21f740b4c0
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Fri Nov 9 02:23:16 2018 +0000

    Revert "mtd: nand: omap2: Fix subpage write"
    
    This reverts commit e7e13fa736726e9860a86e5e1ae19ce162e11b71, which
    was commit 739c64414f01748a36e7d82c8e0611dea94412bd upstream.  It
    doesn't appear to fix a real bug in 3.16, and it results in build
    breakage and/or compiler warnings depending on the kernel
    configuration.
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2c0bdea1de519a2f199c11fd3e933b1f696ac0a8
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Oct 27 07:01:44 2018 +0100

    rtl8723be: Fix misleading indentation
    
    Fix the compiler warning:
    
    drivers/net/wireless/rtlwifi/rtl8723be/hw.c:1132:2: warning: this 'else' clause does not guard...
    
    by reducing indentation of the following statement.  This was fixed
    upstream as part of commit 5c99f04fec93 "rtlwifi: rtl8723be: Update
    driver to match Realtek release of 06/28/14".
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a471e58e8ca3f05ad2067139d2e67fd8c131b8ad
Author: Paul Bolle <pebolle@tiscali.nl>
Date:   Wed Sep 17 21:02:51 2014 +0200

    eeepc-laptop: simplify parse_arg()
    
    commit 95369a73a957ad221f1d6b8f11a63a376f38c544 upstream.
    
    parse_arg() has three possible return values:
        -EINVAL if sscanf(), in short, fails;
        zero if "count" is zero; and
        "count" in all other cases
    
    But "count" will never be zero. See, parse_arg() is called by the
    various store functions. And the callchain of these functions starts
    with sysfs_kf_write(). And that function checks for a zero "count". So
    we can stop checking for a zero "count", drop the "count" argument
    entirely, and transform parse_arg() into a function that returns zero on
    success or a negative error. That, in turn, allows to make those store
    functions just return "count" on success. The net effect is that the
    code becomes a bit easier to understand.
    
    A nice side effect is that this GCC warning is silenced too:
        drivers/platform/x86/eeepc-laptop.c: In function ‘store_sys_acpi’:
        drivers/platform/x86/eeepc-laptop.c:279:10: warning: ‘value’ may be used uninitialized in this function [-Wmaybe-uninitialized]
          int rv, value;
    
    Which is, of course, the reason to have a look at parse_arg().
    
    Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
    Signed-off-by: Darren Hart <dvhart@linux.intel.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 04e57ddf78d9cc78e485f4fa2d337172074d3ee2
Author: Mauro Carvalho Chehab <m.chehab@samsung.com>
Date:   Wed Sep 3 19:16:00 2014 -0300

    drxd_hard: fix bad alignments
    
    commit cea130021448763b15f4b16af184bbab4be118fb upstream.
    
    As reported by cocinelle:
    
    drivers/media/dvb-frontends/drxd_hard.c:2632:3-51: code aligned with following code on line 2633
    
    Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 70e16a622c19400a89960ff5ec84845c87c87259
Author: Mauro Carvalho Chehab <m.chehab@samsung.com>
Date:   Wed Sep 3 19:11:45 2014 -0300

    drxk_hard: fix bad alignments
    
    commit 89fffac802c18caebdf4e91c0785b522c9f6399a upstream.
    
    drivers/media/dvb-frontends/drxk_hard.c:2224:3-22: code aligned with following code on line 2227
    
    Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 195c7ed90f2b0ad742e224425915ec750cd66673
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Oct 27 06:45:38 2018 +0100

    fnic: Fix misleading indentation
    
    Fix the compiler warning:
    
    drivers/scsi/fnic/fnic_fcs.c:104:6: warning: this 'else' clause does not guard...
    
    This was done upstream as part of commit 86001f248e94 "fnic: assign
    FIP_ALL_FCF_MACS to fcoe_all_fcfs".
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 05ae380a6ad3eb1f5a62fef2cf32c04cc086b79e
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Oct 27 06:33:04 2018 +0100

    staging: rtl8192ee: Fix misleading indentation
    
    Fix the compiler warnings:
    
    drivers/staging/rtl8192ee/rtl8192ee/hw.c:524:4: warning: this 'if' clause does not guard...
    drivers/staging/rtl8192ee/rtl8192ee/hw.c:529:5: warning: this 'if' clause does not guard...
    drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.c:2338:2: warning: this 'else' clause does not guard...
    
    by changing the indentation of these statements to match the upstream
    code in drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c and
    drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c.
    
    These were fixed upstream when the driver was removed from staging and
    re-added with some clean-ups.
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bd6f80d92a961f46e0a006e9a90bcd732919e14b
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Oct 27 06:23:12 2018 +0100

    bcmgenet: Delete unused variable
    
    I needed to add a "kdev" variable to bcmgenet_desc_rx() when
    backporting commit 8c4799ac7996 "net: bcmgenet: Utilize correct struct
    device for all DMA operations", but when I later backported commit
    d6707bec5986 "net: bcmgenet: rewrite bcmgenet_rx_refill()" it became
    unused.  Delete it.
    
    There is no corresponding upstream commit because these commits were
    applied in the opposite order and this variable was never introduced.
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d620c46a93dcd06344722ff5cd9df0761a513980
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Oct 27 06:08:51 2018 +0100

    staging: vt6656: Fix misleading indentation
    
    Fix the compiler warnings:
    
    drivers/staging/vt6656/dpc.c:712:5: warning: this 'if' clause does not guard...
    drivers/staging/vt6656/main_usb.c:1101:7: warning: this 'if' clause does not guard...
    
    by reducing indentation of the following statements in
    RXbBulkInProcessData() and reformatting the kstrstr() function to
    kernel coding style.
    
    Both functions have been removed in a later version, so there is no
    corresponding upstream commit.
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit caf92e113d34b2568aed14267b4edc56c7c43e79
Author: Mark Rutland <mark.rutland@arm.com>
Date:   Wed May 3 16:09:34 2017 +0100

    arm64: ensure extension of smp_store_release value
    
    commit 994870bead4ab19087a79492400a5478e2906196 upstream.
    
    When an inline assembly operand's type is narrower than the register it
    is allocated to, the least significant bits of the register (up to the
    operand type's width) are valid, and any other bits are permitted to
    contain any arbitrary value. This aligns with the AAPCS64 parameter
    passing rules.
    
    Our __smp_store_release() implementation does not account for this, and
    implicitly assumes that operands have been zero-extended to the width of
    the type being stored to. Thus, we may store unknown values to memory
    when the value type is narrower than the pointer type (e.g. when storing
    a char to a long).
    
    This patch fixes the issue by casting the value operand to the same
    width as the pointer operand in all cases, which ensures that the value
    is zero-extended as we expect. We use the same union trickery as
    __smp_load_acquire and {READ,WRITE}_ONCE() to avoid GCC complaining that
    pointers are potentially cast to narrower width integers in unreachable
    paths.
    
    A whitespace issue at the top of __smp_store_release() is also
    corrected.
    
    No changes are necessary for __smp_load_acquire(). Load instructions
    implicitly clear any upper bits of the register, and the compiler will
    only consider the least significant bits of the register as valid
    regardless.
    
    Fixes: 47933ad41a86 ("arch: Introduce smp_load_acquire(), smp_store_release()")
    Fixes: 878a84d5a8a1 ("arm64: add missing data types in smp_load_acquire/smp_store_release")
    Acked-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Cc: Matthias Kaehlcke <mka@chromium.org>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    [bwh: The same upstream commit was already backported to 3.16, but we
     didn't have the 1-byte and 2-byte cases then so I dropped that part.
     Now that we do, pick up that part again.]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bd83aaff9841f5be308b77a03679ee9ac22bc5a2
Author: Andre Przywara <andre.przywara@arm.com>
Date:   Mon Apr 20 11:14:19 2015 +0100

    arm64: add missing data types in smp_load_acquire/smp_store_release
    
    commit 878a84d5a8a18a4ab241d40cebb791d6aedf5605 upstream.
    
    Commit 8053871d0f7f ("smp: Fix smp_call_function_single_async()
    locking") introduced a call to smp_load_acquire() with a u16 argument,
    but we only cared about u32 and u64 types in that function so far.
    This resulted in a compiler warning fortunately, pointing at an
    uninitialized use. Due to the implementation structure the compiler
    misses that bug in the smp_store_release(), though.
    Add the u16 and u8 variants using ldarh/stlrh and ldarb/stlrb,
    respectively. Together with the compiletime_assert_atomic_type() check
    this should cover all cases now.
    
    Acked-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Andre Przywara <andre.przywara@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>