1. 09 Oct, 2014 10 commits
  2. 08 Oct, 2014 30 commits
    • Al Viro's avatar
      be careful with nd->inode in path_init() and follow_dotdot_rcu() · 6e3747f1
      Al Viro authored
      commit 4023bfc9 upstream.
      
      in the former we simply check if dentry is still valid after picking
      its ->d_inode; in the latter we fetch ->d_inode in the same places
      where we fetch dentry and its ->d_seq, under the same checks.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      6e3747f1
    • Al Viro's avatar
      don't bugger nd->seq on set_root_rcu() from follow_dotdot_rcu() · 1efec2a1
      Al Viro authored
      commit 7bd88377 upstream.
      
      return the value instead, and have path_init() do the assignment.  Broken by
      "vfs: Fix absolute RCU path walk failures due to uninitialized seq number",
      which was Cc-stable with 2.6.38+ as destination.  This one should go where
      it went.
      
      To avoid dummy value returned in case when root is already set (it would do
      no harm, actually, since the only caller that doesn't ignore the return value
      is guaranteed to have nd->root *not* set, but it's more obvious that way),
      lift the check into callers.  And do the same to set_root(), to keep them
      in sync.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      1efec2a1
    • Guy Martin's avatar
      parisc: Implement new LWS CAS supporting 64 bit operations. · a28866ec
      Guy Martin authored
      commit 89206491 upstream.
      
      The current LWS cas only works correctly for 32bit. The new LWS allows
      for CAS operations of variable size.
      Signed-off-by: default avatarGuy Martin <gmsoft@tuxicoman.be>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      a28866ec
    • Richard Larocque's avatar
      alarmtimer: Lock k_itimer during timer callback · addc3fff
      Richard Larocque authored
      commit 474e941b upstream.
      
      Locks the k_itimer's it_lock member when handling the alarm timer's
      expiry callback.
      
      The regular posix timers defined in posix-timers.c have this lock held
      during timout processing because their callbacks are routed through
      posix_timer_fn().  The alarm timers follow a different path, so they
      ought to grab the lock somewhere else.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Sharvil Nanavati <sharvil@google.com>
      Signed-off-by: default avatarRichard Larocque <rlarocque@google.com>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      addc3fff
    • Richard Larocque's avatar
      alarmtimer: Do not signal SIGEV_NONE timers · 768e06ae
      Richard Larocque authored
      commit 265b81d2 upstream.
      
      Avoids sending a signal to alarm timers created with sigev_notify set to
      SIGEV_NONE by checking for that special case in the timeout callback.
      
      The regular posix timers avoid sending signals to SIGEV_NONE timers by
      not scheduling any callbacks for them in the first place.  Although it
      would be possible to do something similar for alarm timers, it's simpler
      to handle this as a special case in the timeout.
      
      Prior to this patch, the alarm timer would ignore the sigev_notify value
      and try to deliver signals to the process anyway.  Even worse, the
      sanity check for the value of sigev_signo is skipped when SIGEV_NONE was
      specified, so the signal number could be bogus.  If sigev_signo was an
      unitialized value (as it often would be if SIGEV_NONE is used), then
      it's hard to predict which signal will be sent.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Sharvil Nanavati <sharvil@google.com>
      Signed-off-by: default avatarRichard Larocque <rlarocque@google.com>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      768e06ae
    • Richard Larocque's avatar
      alarmtimer: Return relative times in timer_gettime · 99bc8f4e
      Richard Larocque authored
      commit e86fea76 upstream.
      
      Returns the time remaining for an alarm timer, rather than the time at
      which it is scheduled to expire.  If the timer has already expired or it
      is not currently scheduled, the it_value's members are set to zero.
      
      This new behavior matches that of the other posix-timers and the POSIX
      specifications.
      
      This is a change in user-visible behavior, and may break existing
      applications.  Hopefully, few users rely on the old incorrect behavior.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Sharvil Nanavati <sharvil@google.com>
      Signed-off-by: default avatarRichard Larocque <rlarocque@google.com>
      [jstultz: minor style tweak]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      99bc8f4e
    • Andrew Hunter's avatar
      jiffies: Fix timeval conversion to jiffies · d7c27452
      Andrew Hunter authored
      commit d78c9300 upstream.
      
      timeval_to_jiffies tried to round a timeval up to an integral number
      of jiffies, but the logic for doing so was incorrect: intervals
      corresponding to exactly N jiffies would become N+1. This manifested
      itself particularly repeatedly stopping/starting an itimer:
      
      setitimer(ITIMER_PROF, &val, NULL);
      setitimer(ITIMER_PROF, NULL, &val);
      
      would add a full tick to val, _even if it was exactly representable in
      terms of jiffies_ (say, the result of a previous rounding.)  Doing
      this repeatedly would cause unbounded growth in val.  So fix the math.
      
      Here's what was wrong with the conversion: we essentially computed
      (eliding seconds)
      
      jiffies = usec  * (NSEC_PER_USEC/TICK_NSEC)
      
      by using scaling arithmetic, which took the best approximation of
      NSEC_PER_USEC/TICK_NSEC with denominator of 2^USEC_JIFFIE_SC =
      x/(2^USEC_JIFFIE_SC), and computed:
      
      jiffies = (usec * x) >> USEC_JIFFIE_SC
      
      and rounded this calculation up in the intermediate form (since we
      can't necessarily exactly represent TICK_NSEC in usec.) But the
      scaling arithmetic is a (very slight) *over*approximation of the true
      value; that is, instead of dividing by (1 usec/ 1 jiffie), we
      effectively divided by (1 usec/1 jiffie)-epsilon (rounding
      down). This would normally be fine, but we want to round timeouts up,
      and we did so by adding 2^USEC_JIFFIE_SC - 1 before the shift; this
      would be fine if our division was exact, but dividing this by the
      slightly smaller factor was equivalent to adding just _over_ 1 to the
      final result (instead of just _under_ 1, as desired.)
      
      In particular, with HZ=1000, we consistently computed that 10000 usec
      was 11 jiffies; the same was true for any exact multiple of
      TICK_NSEC.
      
      We could possibly still round in the intermediate form, adding
      something less than 2^USEC_JIFFIE_SC - 1, but easier still is to
      convert usec->nsec, round in nanoseconds, and then convert using
      time*spec*_to_jiffies.  This adds one constant multiplication, and is
      not observably slower in microbenchmarks on recent x86 hardware.
      
      Tested: the following program:
      
      int main() {
        struct itimerval zero = {{0, 0}, {0, 0}};
        /* Initially set to 10 ms. */
        struct itimerval initial = zero;
        initial.it_interval.tv_usec = 10000;
        setitimer(ITIMER_PROF, &initial, NULL);
        /* Save and restore several times. */
        for (size_t i = 0; i < 10; ++i) {
          struct itimerval prev;
          setitimer(ITIMER_PROF, &zero, &prev);
          /* on old kernels, this goes up by TICK_USEC every iteration */
          printf("previous value: %ld %ld %ld %ld\n",
                 prev.it_interval.tv_sec, prev.it_interval.tv_usec,
                 prev.it_value.tv_sec, prev.it_value.tv_usec);
          setitimer(ITIMER_PROF, &prev, NULL);
        }
          return 0;
      }
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Reviewed-by: default avatarPaul Turner <pjt@google.com>
      Reported-by: default avatarAaron Jacobs <jacobsa@google.com>
      Signed-off-by: default avatarAndrew Hunter <ahh@google.com>
      [jstultz: Tweaked to apply to 3.17-rc]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      [ kamal: backport to 3.13-stable: kernel/time.c ]
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      d7c27452
    • Thomas Gleixner's avatar
      futex: Unlock hb->lock in futex_wait_requeue_pi() error path · 39aaf94d
      Thomas Gleixner authored
      commit 13c42c2f upstream.
      
      futex_wait_requeue_pi() calls futex_wait_setup(). If
      futex_wait_setup() succeeds it returns with hb->lock held and
      preemption disabled. Now the sanity check after this does:
      
              if (match_futex(&q.key, &key2)) {
      	   	ret = -EINVAL;
      		goto out_put_keys;
      	}
      
      which releases the keys but does not release hb->lock.
      
      So we happily return to user space with hb->lock held and therefor
      preemption disabled.
      
      Unlock hb->lock before taking the exit route.
      Reported-by: default avatarDave "Trinity" Jones <davej@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDarren Hart <dvhart@linux.intel.com>
      Reviewed-by: default avatarDavidlohr Bueso <dave@stgolabs.net>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1409112318500.4178@nanosSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      [ kamal: backport to 3.13-stable: queue_unlock() args ]
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      39aaf94d
    • Y.C. Chen's avatar
      drm/ast: AST2000 cannot be detected correctly · 765709bf
      Y.C. Chen authored
      commit 83502a5d upstream.
      
      Type error and cause AST2000 cannot be detected correctly
      Signed-off-by: default avatarY.C. Chen <yc_chen@aspeedtech.com>
      Reviewed-by: default avatarEgbert Eich <eich@suse.de>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      765709bf
    • Y.C. Chen's avatar
      drm/ast: open key before detect chips · 3ecbb231
      Y.C. Chen authored
      commit 8f372e25 upstream.
      
      Some config settings like 3rd TX chips will not get correctly
      if the extended reg is protected
      Signed-off-by: default avatarY.C. Chen <yc_chen@aspeedtech.com>
      Reviewed-by: default avatarEgbert Eich <eich@suse.de>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      3ecbb231
    • Mathias Nyman's avatar
      xhci: fix oops when xhci resumes from hibernate with hw lpm capable devices · bc82abaa
      Mathias Nyman authored
      commit 96044694 upstream.
      
      Resuming from hibernate (S4) will restart and re-initialize xHC.
      The device contexts are freed and will be re-allocated later during device reset.
      
      Usb core will disable link pm in device resume before device reset, which will
      try to change the max exit latency, accessing the device contexts before they are re-allocated.
      
      There is no need to zero (disable) the max exit latency when disabling hw lpm
      for a freshly re-initialized xHC. So check that device context exists before
      doing anything. The max exit latency will be set again after device reset when usb core
      enables the link pm.
      Reported-by: default avatarImre Deak <imre.deak@intel.com>
      Tested-by: default avatarImre Deak <imre.deak@intel.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      bc82abaa
    • Al Cooper's avatar
      usb: xhci: Fix OOPS in xhci error handling code · b4a8a127
      Al Cooper authored
      commit 0eda06c7 upstream.
      
      The xhci driver will OOPS on resume from S2/S3 if dma_alloc_coherent()
      is out of memory. This is a result of two things:
      1. xhci_mem_cleanup() in xhci-mem.c free's xhci->lpm_command if
      it's not NULL, but doesn't set it to NULL after the free.
      2. xhci_mem_cleanup() is called twice on resume, once for normal
      restart and once from xhci_mem_init() if dma_alloc_coherent() fails,
      resulting in a free of xhci->lpm_command that has already been freed.
      The fix is to set xhci->lpm_command to NULL after freeing it.
      Signed-off-by: default avatarAl Cooper <alcooperx@gmail.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      b4a8a127
    • Mathias Nyman's avatar
      xhci: Fix null pointer dereference if xhci initialization fails · caaeafd7
      Mathias Nyman authored
      commit c207e7c5 upstream.
      
      If xhci initialization fails before the roothub bandwidth
      domains (xhci->rh_bw[i]) are allocated it will oops when
      trying to access rh_bw members in xhci_mem_cleanup().
      Reported-by: default avatarManuel Reimer <manuel.reimer@gmx.de>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      caaeafd7
    • Mark's avatar
      storage: Add single-LUN quirk for Jaz USB Adapter · fb4289be
      Mark authored
      commit c66f1c62 upstream.
      
      The Iomega Jaz USB Adapter is a SCSI-USB converter cable. The hardware
      seems to be identical to e.g. the Microtech XpressSCSI, using a Shuttle/
      SCM chip set. However its firmware restricts it to only work with Jaz
      drives.
      
      On connecting the cable a message like this appears four times in the log:
       reset full speed USB device number 4 using uhci_hcd
      
      That's non-fatal but the US_FL_SINGLE_LUN quirk fixes it.
      Signed-off-by: default avatarMark Knibbs <markk@clara.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      fb4289be
    • Will Deacon's avatar
      arm64: flush TLS registers during exec · 3f303c59
      Will Deacon authored
      commit eb35bdd7 upstream.
      
      Nathan reports that we leak TLS information from the parent context
      during an exec, as we don't clear the TLS registers when flushing the
      thread state.
      
      This patch updates the flushing code so that we:
      
        (1) Unconditionally zero the tpidr_el0 register (since this is fully
            context switched for native tasks and zeroed for compat tasks)
      
        (2) Zero the tp_value state in thread_info before clearing the
            tpidrr0_el0 register for compat tasks (since this is only writable
            by the set_tls compat syscall and therefore not fully switched).
      
      A missing compiler barrier is also added to the compat set_tls syscall.
      Acked-by: default avatarNathan Lynch <Nathan_Lynch@mentor.com>
      Reported-by: default avatarNathan Lynch <Nathan_Lynch@mentor.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      3f303c59
    • Andrey Vagin's avatar
      fs/notify: don't show f_handle if exportfs_encode_inode_fh failed · 2ab02f45
      Andrey Vagin authored
      commit 7e882481 upstream.
      
      Currently we handle only ENOSPC.  In case of other errors the file_handle
      variable isn't filled properly and we will show a part of stack.
      Signed-off-by: default avatarAndrey Vagin <avagin@openvz.org>
      Acked-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      2ab02f45
    • Andrey Vagin's avatar
      fsnotify/fdinfo: use named constants instead of hardcoded values · 74ddb1d0
      Andrey Vagin authored
      commit 1fc98d11 upstream.
      
      MAX_HANDLE_SZ is equal to 128, but currently the size of pad is only 64
      bytes, so exportfs_encode_inode_fh can return an error.
      Signed-off-by: default avatarAndrey Vagin <avagin@openvz.org>
      Acked-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      74ddb1d0
    • Rasmus Villemoes's avatar
      kcmp: fix standard comparison bug · 73b1b78d
      Rasmus Villemoes authored
      commit acbbe6fb upstream.
      
      The C operator <= defines a perfectly fine total ordering on the set of
      values representable in a long.  However, unlike its namesake in the
      integers, it is not translation invariant, meaning that we do not have
      "b <= c" iff "a+b <= a+c" for all a,b,c.
      
      This means that it is always wrong to try to boil down the relationship
      between two longs to a question about the sign of their difference,
      because the resulting relation [a LEQ b iff a-b <= 0] is neither
      anti-symmetric or transitive.  The former is due to -LONG_MIN==LONG_MIN
      (take any two a,b with a-b = LONG_MIN; then a LEQ b and b LEQ a, but a !=
      b).  The latter can either be seen observing that x LEQ x+1 for all x,
      implying x LEQ x+1 LEQ x+2 ...  LEQ x-1 LEQ x; or more directly with the
      simple example a=LONG_MIN, b=0, c=1, for which a-b < 0, b-c < 0, but a-c >
      0.
      
      Note that it makes absolutely no difference that a transmogrying bijection
      has been applied before the comparison is done.  In fact, had the
      obfuscation not been done, one could probably not observe the bug
      (assuming all values being compared always lie in one half of the address
      space, the mathematical value of a-b is always representable in a long).
      As it stands, one can easily obtain three file descriptors exhibiting the
      non-transitivity of kcmp().
      
      Side note 1: I can't see that ensuring the MSB of the multiplier is
      set serves any purpose other than obfuscating the obfuscating code.
      
      Side note 2:
      #include <stdio.h>
      #include <stdlib.h>
      #include <string.h>
      #include <fcntl.h>
      #include <unistd.h>
      #include <assert.h>
      #include <sys/syscall.h>
      
      enum kcmp_type {
              KCMP_FILE,
              KCMP_VM,
              KCMP_FILES,
              KCMP_FS,
              KCMP_SIGHAND,
              KCMP_IO,
              KCMP_SYSVSEM,
              KCMP_TYPES,
      };
      pid_t pid;
      
      int kcmp(pid_t pid1, pid_t pid2, int type,
      	 unsigned long idx1, unsigned long idx2)
      {
      	return syscall(SYS_kcmp, pid1, pid2, type, idx1, idx2);
      }
      int cmp_fd(int fd1, int fd2)
      {
      	int c = kcmp(pid, pid, KCMP_FILE, fd1, fd2);
      	if (c < 0) {
      		perror("kcmp");
      		exit(1);
      	}
      	assert(0 <= c && c < 3);
      	return c;
      }
      int cmp_fdp(const void *a, const void *b)
      {
      	static const int normalize[] = {0, -1, 1};
      	return normalize[cmp_fd(*(int*)a, *(int*)b)];
      }
      #define MAX 100 /* This is plenty; I've seen it trigger for MAX==3 */
      int main(int argc, char *argv[])
      {
      	int r, s, count = 0;
      	int REL[3] = {0,0,0};
      	int fd[MAX];
      	pid = getpid();
      	while (count < MAX) {
      		r = open("/dev/null", O_RDONLY);
      		if (r < 0)
      			break;
      		fd[count++] = r;
      	}
      	printf("opened %d file descriptors\n", count);
      	for (r = 0; r < count; ++r) {
      		for (s = r+1; s < count; ++s) {
      			REL[cmp_fd(fd[r], fd[s])]++;
      		}
      	}
      	printf("== %d\t< %d\t> %d\n", REL[0], REL[1], REL[2]);
      	qsort(fd, count, sizeof(fd[0]), cmp_fdp);
      	memset(REL, 0, sizeof(REL));
      
      	for (r = 0; r < count; ++r) {
      		for (s = r+1; s < count; ++s) {
      			REL[cmp_fd(fd[r], fd[s])]++;
      		}
      	}
      	printf("== %d\t< %d\t> %d\n", REL[0], REL[1], REL[2]);
      	return (REL[0] + REL[2] != 0);
      }
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Reviewed-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      73b1b78d
    • Nicolas Iooss's avatar
      eventpoll: fix uninitialized variable in epoll_ctl · 18abd109
      Nicolas Iooss authored
      commit c680e41b upstream.
      
      When calling epoll_ctl with operation EPOLL_CTL_DEL, structure epds is
      not initialized but ep_take_care_of_epollwakeup reads its event field.
      When this unintialized field has EPOLLWAKEUP bit set, a capability check
      is done for CAP_BLOCK_SUSPEND in ep_take_care_of_epollwakeup.  This
      produces unexpected messages in the audit log, such as (on a system
      running SELinux):
      
          type=AVC msg=audit(1408212798.866:410): avc:  denied
          { block_suspend } for  pid=7754 comm="dbus-daemon" capability=36
          scontext=unconfined_u:unconfined_r:unconfined_t
          tcontext=unconfined_u:unconfined_r:unconfined_t
          tclass=capability2 permissive=1
      
          type=SYSCALL msg=audit(1408212798.866:410): arch=c000003e syscall=233
          success=yes exit=0 a0=3 a1=2 a2=9 a3=7fffd4d66ec0 items=0 ppid=1
          pid=7754 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0
          fsgid=0 tty=(none) ses=3 comm="dbus-daemon"
          exe="/usr/bin/dbus-daemon"
          subj=unconfined_u:unconfined_r:unconfined_t key=(null)
      
      ("arch=c000003e syscall=233 a1=2" means "epoll_ctl(op=EPOLL_CTL_DEL)")
      
      Remove use of epds in epoll_ctl when op == EPOLL_CTL_DEL.
      
      Fixes: 4d7e30d9 ("epoll: Add a flag, EPOLLWAKEUP, to prevent suspend while epoll events are ready")
      Signed-off-by: default avatarNicolas Iooss <nicolas.iooss_linux@m4x.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Arve Hjønnevåg <arve@android.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      18abd109
    • Joe Lawrence's avatar
      usb: hub: take hub->hdev reference when processing from eventlist · 9b5d4c19
      Joe Lawrence authored
      commit c605f3cd upstream.
      
      During surprise device hotplug removal tests, it was observed that
      hub_events may try to call usb_lock_device on a device that has already
      been freed. Protect the usb_device by taking out a reference (under the
      hub_event_lock) when hub_events pulls it off the list, returning the
      reference after hub_events is finished using it.
      Signed-off-by: default avatarJoe Lawrence <joe.lawrence@stratus.com>
      Suggested-by: David Bulkow <david.bulkow@stratus.com> for using kref
      Suggested-by: Alan Stern <stern@rowland.harvard.edu> for placement
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      9b5d4c19
    • John Sung's avatar
      Input: serport - add compat handling for SPIOCSTYPE ioctl · 25328c6d
      John Sung authored
      commit a80d8b02 upstream.
      
      When running a 32-bit inputattach utility in a 64-bit system, there will be
      error code "inputattach: can't set device type". This is caused by the
      serport device driver not supporting compat_ioctl, so that SPIOCSTYPE ioctl
      fails.
      Signed-off-by: default avatarJohn Sung <penmount.touch@gmail.com>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      25328c6d
    • Sage Weil's avatar
      libceph: gracefully handle large reply messages from the mon · 158524e4
      Sage Weil authored
      commit 73c3d481 upstream.
      
      We preallocate a few of the message types we get back from the mon.  If we
      get a larger message than we are expecting, fall back to trying to allocate
      a new one instead of blindly using the one we have.
      Signed-off-by: default avatarSage Weil <sage@redhat.com>
      Reviewed-by: default avatarIlya Dryomov <ilya.dryomov@inktank.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      158524e4
    • Anssi Hannula's avatar
      dm cache: fix race causing dirty blocks to be marked as clean · 2cf00e26
      Anssi Hannula authored
      commit 40aa978e upstream.
      
      When a writeback or a promotion of a block is completed, the cell of
      that block is removed from the prison, the block is marked as clean, and
      the clear_dirty() callback of the cache policy is called.
      
      Unfortunately, performing those actions in this order allows an incoming
      new write bio for that block to come in before clearing the dirty status
      is completed and therefore possibly causing one of these two scenarios:
      
      Scenario A:
      
      Thread 1                      Thread 2
      cell_defer()                  .
      - cell removed from prison    .
      - detained bios queued        .
      .                             incoming write bio
      .                             remapped to cache
      .                             set_dirty() called,
      .                               but block already dirty
      .                               => it does nothing
      clear_dirty()                 .
      - block marked clean          .
      - policy clear_dirty() called .
      
      Result: Block is marked clean even though it is actually dirty. No
      writeback will occur.
      
      Scenario B:
      
      Thread 1                      Thread 2
      cell_defer()                  .
      - cell removed from prison    .
      - detained bios queued        .
      clear_dirty()                 .
      - block marked clean          .
      .                             incoming write bio
      .                             remapped to cache
      .                             set_dirty() called
      .                             - block marked dirty
      .                             - policy set_dirty() called
      - policy clear_dirty() called .
      
      Result: Block is properly marked as dirty, but policy thinks it is clean
      and therefore never asks us to writeback it.
      This case is visible in "dmsetup status" dirty block count (which
      normally decreases to 0 on a quiet device).
      
      Fix these issues by calling clear_dirty() before calling cell_defer().
      Incoming bios for that block will then be detained in the cell and
      released only after clear_dirty() has completed, so the race will not
      occur.
      
      Found by inspecting the code after noticing spurious dirty counts
      (scenario B).
      Signed-off-by: default avatarAnssi Hannula <anssi.hannula@iki.fi>
      Acked-by: default avatarJoe Thornber <ejt@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      2cf00e26
    • Alex Deucher's avatar
      drm/radeon/dpm: set the thermal type properly for special configs · bedaf63f
      Alex Deucher authored
      commit ff437792 upstream.
      
      On systems with special thermal configurations make sure we make
      note of the thermal setup.  This is required for proper firmware
      configuration on these systems.
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      bedaf63f
    • Cong Wang's avatar
      nfs: fix kernel warning when removing proc entry · 9784e963
      Cong Wang authored
      commit 21e81002 upstream.
      
      I saw the following kernel warning:
      
      [ 1852.321222] ------------[ cut here ]------------
      [ 1852.326527] WARNING: CPU: 0 PID: 118 at fs/proc/generic.c:521 remove_proc_entry+0x154/0x16b()
      [ 1852.335630] remove_proc_entry: removing non-empty directory 'fs/nfsfs', leaking at least 'volumes'
      [ 1852.344084] CPU: 0 PID: 118 Comm: kworker/u8:2 Not tainted 3.16.0+ #540
      [ 1852.350036] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
      [ 1852.354992] Workqueue: netns cleanup_net
      [ 1852.358701]  0000000000000000 ffff880116f2fbd0 ffffffff819c03e9 ffff880116f2fc18
      [ 1852.366474]  ffff880116f2fc08 ffffffff810744ee ffffffff811e0e6e ffff8800d4e96238
      [ 1852.373507]  ffffffff81dbe665 ffff8800d46a5948 0000000000000005 ffff880116f2fc68
      [ 1852.380224] Call Trace:
      [ 1852.381976]  [<ffffffff819c03e9>] dump_stack+0x4d/0x66
      [ 1852.385495]  [<ffffffff810744ee>] warn_slowpath_common+0x7a/0x93
      [ 1852.389869]  [<ffffffff811e0e6e>] ? remove_proc_entry+0x154/0x16b
      [ 1852.393987]  [<ffffffff8107457b>] warn_slowpath_fmt+0x4c/0x4e
      [ 1852.397999]  [<ffffffff811e0e6e>] remove_proc_entry+0x154/0x16b
      [ 1852.402034]  [<ffffffff8129c73d>] nfs_fs_proc_net_exit+0x53/0x56
      [ 1852.406136]  [<ffffffff812a103b>] nfs_net_exit+0x12/0x1d
      [ 1852.409774]  [<ffffffff81785bc9>] ops_exit_list+0x44/0x55
      [ 1852.413529]  [<ffffffff81786389>] cleanup_net+0xee/0x182
      [ 1852.417198]  [<ffffffff81088c9e>] process_one_work+0x209/0x40d
      [ 1852.502320]  [<ffffffff81088bf7>] ? process_one_work+0x162/0x40d
      [ 1852.587629]  [<ffffffff810890c1>] worker_thread+0x1f0/0x2c7
      [ 1852.673291]  [<ffffffff81088ed1>] ? process_scheduled_works+0x2f/0x2f
      [ 1852.759470]  [<ffffffff8108e079>] kthread+0xc9/0xd1
      [ 1852.843099]  [<ffffffff8109427f>] ? finish_task_switch+0x3a/0xce
      [ 1852.926518]  [<ffffffff8108dfb0>] ? __kthread_parkme+0x61/0x61
      [ 1853.008565]  [<ffffffff819cbeac>] ret_from_fork+0x7c/0xb0
      [ 1853.076477]  [<ffffffff8108dfb0>] ? __kthread_parkme+0x61/0x61
      [ 1853.140653] ---[ end trace 69c4c6617f78e32d ]---
      
      It looks wrong that we add "/proc/net/nfsfs" in nfs_fs_proc_net_init()
      while remove "/proc/fs/nfsfs" in nfs_fs_proc_net_exit().
      
      Fixes: commit 65b38851 (NFS: Fix /proc/fs/nfsfs/servers and /proc/fs/nfsfs/volumes)
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Trond Myklebust <trond.myklebust@primarydata.com>
      Cc: Dan Aloni <dan@kernelim.com>
      Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      [Trond: replace uses of remove_proc_entry() with remove_proc_subtree()
      as suggested by Al Viro]
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      9784e963
    • Thomas Pugliese's avatar
      uwb: init beacon cache entry before registering uwb device · 1bda1ada
      Thomas Pugliese authored
      commit 675f0ab2 upstream.
      
      Make sure the uwb_dev->bce entry is set before calling uwb_dev_add in
      uwbd_dev_onair so that usermode will only see the device after it is
      properly initialized.  This fixes a kernel panic that can occur if
      usermode tries to access the IEs sysfs attribute of a UWB device before
      the driver has had a chance to set the beacon cache entry.
      Signed-off-by: default avatarThomas Pugliese <thomas.pugliese@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      1bda1ada
    • Taylor Braun-Jones's avatar
      USB: ftdi_sio: Add support for GE Healthcare Nemo Tracker device · 08837404
      Taylor Braun-Jones authored
      commit 9c491c37 upstream.
      Signed-off-by: default avatarTaylor Braun-Jones <taylor.braun-jones@ge.com>
      Cc: Johan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      08837404
    • Hans de Goede's avatar
      Input: elantech - fix detection of touchpad on ASUS s301l · 92f3f4c5
      Hans de Goede authored
      commit 271329b3 upstream.
      
      Adjust Elantech signature validation to account fo rnewer models of
      touchpads.
      Reported-and-tested-by: default avatarMàrius Monton <marius.monton@gmail.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      92f3f4c5
    • Felipe Balbi's avatar
      usb: host: xhci: fix compliance mode workaround · 6d17be06
      Felipe Balbi authored
      commit 96908589 upstream.
      
      Commit 71c731a2 (usb: host: xhci: Fix Compliance Mode
      on SN65LVP3502CP Hardware) implemented a workaround
      for a known issue with Texas Instruments' USB 3.0
      redriver IC but it left a condition where any xHCI
      host would be taken out of reset if port was placed
      in compliance mode and there was no device connected
      to the port.
      
      That condition would trigger a fake connection to a
      non-existent device so that usbcore would trigger a
      warm reset of the port, thus taking the link out of
      reset.
      
      This has the side-effect of preventing any xHCI host
      connected to a Linux machine from starting and running
      the USB 3.0 Electrical Compliance Suite because the
      port will mysteriously taken out of compliance mode
      and, thus, xHCI won't step through the necessary
      compliance patterns for link validation.
      
      This patch fixes the issue by just adding a missing
      check for XHCI_COMP_MODE_QUIRK inside
      xhci_hub_report_usb3_link_state() when PORT_CAS isn't
      set.
      
      This patch should be backported to all kernels containing
      commit 71c731a2.
      
      Fixes: 71c731a2 (usb: host: xhci: Fix Compliance Mode on SN65LVP3502CP Hardware)
      Cc: Alexis R. Cortes <alexis.cortes@ti.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Acked-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      6d17be06
    • Russell King's avatar
      imx-drm: ipuv3-plane: fix ipu_plane_dpms() · 9980ceea
      Russell King authored
      commit 3a44a205 upstream.
      
      When unbinding imx-drm, the following oops was observed:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000004
      pgd = e995c000
      [00000004] *pgd=4fea5831
      Internal error: Oops: 817 [#1] SMP ARM
      Modules linked in: bnep rfcomm bluetooth nfsd exportfs hid_cypress brcmfmac brcmutil snd_soc_fsl_ssi snd_soc_fsl_spdif imx_pcm_fiq imx_pcm_dma snd_soc_sgtl5000 imx_sdma imx2_wdt imx_ldb(C) imx_thermal snd_soc_imx_sgtl5000 snd_soc_imx_spdif snd_soc_imx_audmux
      CPU: 1 PID: 779 Comm: bash Tainted: G         C    3.16.0-rc2+ #1230
      task: ea9eb180 ti: ea378000 task.ti: ea378000
      PC is at ipu_dp_put+0x10/0x18
      LR is at ipu_plane_dpms+0x60/0x8c
      pc : [<c0350d20>]    lr : [<c04bd9e8>]    psr: 200f0013
      sp : ea379d80  ip : ea379d90  fp : ea379d8c
      r10: 00100100  r9 : 00000000  r8 : 00200200
      r7 : e9ba0264  r6 : e9ba01f8  r5 : 00000000  r4 : ea34b800
      r3 : 00000000  r2 : 00000000  r1 : 0000009b  r0 : 00000000
      Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
      Control: 10c53c7d  Table: 3995c04a  DAC: 00000015
      Process bash (pid: 779, stack limit = 0xea378240)
      Stack: (0xea379d80 to 0xea37a000)
      ...
      Backtrace:
      [<c0350d10>] (ipu_dp_put) from [<c04bd9e8>] (ipu_plane_dpms+0x60/0x8c)
      [<c04bd988>] (ipu_plane_dpms) from [<c04bda40>] (ipu_disable_plane+0x2c/0x60)
      [<c04bda14>] (ipu_disable_plane) from [<c04bda9c>] (ipu_plane_destroy+0x28/0x60)
      [<c04bda74>] (ipu_plane_destroy) from [<c033ff84>] (drm_mode_config_cleanup+0x1b8/0x250)
      [<c033fdcc>] (drm_mode_config_cleanup) from [<c04bc234>] (imx_drm_driver_unload+0x44/0x4c)
      [<c04bc1f0>] (imx_drm_driver_unload) from [<c03394a4>] (drm_dev_unregister+0x2c/0xa0)
      [<c0339478>] (drm_dev_unregister) from [<c0339f8c>] (drm_put_dev+0x30/0x6c)
      [<c0339f5c>] (drm_put_dev) from [<c04bc1cc>] (imx_drm_unbind+0x14/0x18)
      [<c04bc1b8>] (imx_drm_unbind) from [<c03530b4>] (component_master_del+0xbc/0xd8)
      ...
      Code: e1a0c00d e92dd800 e24cb004 e3a03000 (e5c03004)
      
      This is caused by a missing check in ipu_plane_dpms for a NULL pointer.
      
      Fixes: b8d181e4 ("staging: drm/imx: add drm plane support")
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      9980ceea