Skip to content
Snippets Groups Projects
  1. Jun 12, 2019
  2. Jun 03, 2019
  3. May 31, 2019
  4. May 30, 2019
  5. May 29, 2019
  6. May 28, 2019
  7. May 27, 2019
  8. May 24, 2019
  9. May 23, 2019
  10. May 22, 2019
  11. May 21, 2019
    • qctecmdr's avatar
    • Tharun Kumar Merugu's avatar
      msm: adsprpc: maintain local copy of rpra offloaded to DSP · 564f8937
      Tharun Kumar Merugu authored
      
      Since DSP is not supposed to modify the base pointer rpra of the
      input/output arguments offloaded to DSP, maintain a local copy of
      the pointer and use it after receiving interrupt from DSP.
      
      Change-Id: I4afade7184cb2aca148060fb0cda06c6174f3b55
      Acked-by: default avatarMaitreyi Gupta <maitreyi@qti.qualcomm.com>
      Signed-off-by: default avatarTharun Kumar Merugu <mtharu@codeaurora.org>
      564f8937
    • qctecmdr's avatar
    • Muchun Song's avatar
      drivers: core: Fix use-after-free and double free on glue_dirs · ccebcf37
      Muchun Song authored
      
      There is a race condition between removing glue directory and adding a new
      device under the glue directory. It can be reproduced in following test:
      
      path 1: Add the child device under glue dir
      device_add()
          get_device_parent()
              mutex_lock(&gdp_mutex);
              ....
              /*find parent from glue_dirs.list*/
              list_for_each_entry(k, &dev->class->p->glue_dirs.list, entry)
                  if (k->parent == parent_kobj) {
                      kobj = kobject_get(k);
                      break;
                  }
              ....
              mutex_unlock(&gdp_mutex);
              ....
          ....
          kobject_add()
              kobject_add_internal()
                  create_dir()
                      sysfs_create_dir_ns()
                          if (kobj->parent)
                              parent = kobj->parent->sd;
                          ....
                          kernfs_create_dir_ns(parent)
                              kernfs_new_node()
                                  kernfs_get(parent)
                              ....
                              /* link in */
                              rc = kernfs_add_one(kn);
                              if (!rc)
                                  return kn;
      
                              kernfs_put(kn)
                                  ....
                                  repeat:
                                  kmem_cache_free(kn)
                                  kn = parent;
      
                                  if (kn) {
                                      if (atomic_dec_and_test(&kn->count))
                                          goto repeat;
                                  }
                              ....
      
      path2: Remove last child device under glue dir
      device_del()
          cleanup_device_parent()
              cleanup_glue_dir()
                  mutex_lock(&gdp_mutex);
                  if (!kobject_has_children(glue_dir))
                      kobject_del(glue_dir);
                  kobject_put(glue_dir);
                  mutex_unlock(&gdp_mutex);
      
      Before path2 remove last child device under glue dir, If path1 add a new
      device under glue dir, the glue_dir kobject reference count will be
      increase to 2 via kobject_get(k) in get_device_parent(). And path1 has
      been called kernfs_new_node(), but not call kernfs_get(parent).
      Meanwhile, path2 call kobject_del(glue_dir) beacause 0 is returned by
      kobject_has_children(). This result in glue_dir->sd is freed and it's
      reference count will be 0. Then path1 call kernfs_get(parent) will trigger
      a warning in kernfs_get()(WARN_ON(!atomic_read(&kn->count))) and increase
      it's reference count to 1. Because glue_dir->sd is freed by path2, the next
      call kernfs_add_one() by path1 will fail(This is also use-after-free)
      and call atomic_dec_and_test() to decrease reference count. Because the
      reference count is decremented to 0, it will also call kmem_cache_free()
      to free glue_dir->sd again. This will result in double free.
      
      In order to avoid this happening, we we should not call kobject_del() on
      path2 when the reference count of glue_dir is greater than 1. So we add a
      conditional statement to fix it.
      
      The following calltrace is captured in kernel 4.14 with the following patch
      applied:
      
      commit 726e4109 ("drivers: core: Remove glue dirs from sysfs earlier")
      
      --------------------------------------------------------------------------
      [    3.633703] WARNING: CPU: 4 PID: 513 at .../fs/kernfs/dir.c:494
                      Here is WARN_ON(!atomic_read(&kn->count) in kernfs_get().
      ....
      [    3.633986] Call trace:
      [    3.633991]  kernfs_create_dir_ns+0xa8/0xb0
      [    3.633994]  sysfs_create_dir_ns+0x54/0xe8
      [    3.634001]  kobject_add_internal+0x22c/0x3f0
      [    3.634005]  kobject_add+0xe4/0x118
      [    3.634011]  device_add+0x200/0x870
      [    3.634017]  _request_firmware+0x958/0xc38
      [    3.634020]  request_firmware_into_buf+0x4c/0x70
      ....
      [    3.634064] kernel BUG at .../mm/slub.c:294!
                      Hrer is BUG_ON(object == fp) in set_freepointer().
      ....
      [    3.634346] Call trace:
      [    3.634351]  kmem_cache_free+0x504/0x6b8
      [    3.634355]  kernfs_put+0x14c/0x1d8
      [    3.634359]  kernfs_create_dir_ns+0x88/0xb0
      [    3.634362]  sysfs_create_dir_ns+0x54/0xe8
      [    3.634366]  kobject_add_internal+0x22c/0x3f0
      [    3.634370]  kobject_add+0xe4/0x118
      [    3.634374]  device_add+0x200/0x870
      [    3.634378]  _request_firmware+0x958/0xc38
      [    3.634381]  request_firmware_into_buf+0x4c/0x70
      --------------------------------------------------------------------------
      
      Fixes: 726e4109 ("drivers: core: Remove glue dirs from sysfs earlier")
      
      Change-Id: I2c5b99e62d78783e2c454af1266d787500b6675e
      Signed-off-by: default avatarMuchun Song <smuchun@gmail.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Patch-mainline: linux-kernel @ 04/23/19, 22:32
      Signed-off-by: default avatarPrateek Sood <prsood@codeaurora.org>
      ccebcf37
    • Venu Raidu's avatar
      msm: camera_v2: CPP AXI reset at close · 133378cf
      Venu Raidu authored
      
      Enable AXI/ABH clocks, inorder to perform CPP AXI
      reset successfully.
      
      Change-Id: I68d16825243d63f612709ce414bdaaa19af45bbe
      Signed-off-by: default avatarVenu Raidu <vraidu@codeaurora.org>
      133378cf
  12. May 20, 2019
Loading