1. 07 Aug, 2019 2 commits
  2. 02 Aug, 2019 9 commits
  3. 01 Aug, 2019 13 commits
  4. 30 Jul, 2019 11 commits
  5. 25 Jul, 2019 3 commits
    • Jia-Ju Bai's avatar
      fs: kernfs: Fix possible null-pointer dereferences in kernfs_path_from_node_locked() · bbe70e4e
      Jia-Ju Bai authored
      In kernfs_path_from_node_locked(), there is an if statement on line 147
      to check whether buf is NULL:
          if (buf)
      
      When buf is NULL, it is used on line 151:
          len += strlcpy(buf + len, parent_str, ...)
      and line 158:
          len += strlcpy(buf + len, "/", ...)
      and line 160:
          len += strlcpy(buf + len, kn->name, ...)
      
      Thus, possible null-pointer dereferences may occur.
      
      To fix these possible bugs, buf is checked before being used.
      If it is NULL, -EINVAL is returned.
      
      These bugs are found by a static analysis tool STCheck written by us.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Link: https://lore.kernel.org/r/20190724022242.27505-1-baijiaju1990@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbe70e4e
    • Peng Wang's avatar
      kernfs: fix potential null pointer dereference · 2fd60da4
      Peng Wang authored
      Get root safely after kn is ensureed to be not null.
      Signed-off-by: default avatarPeng Wang <rocking@whu.edu.cn>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Link: https://lore.kernel.org/r/20190708151611.13242-1-rocking@whu.edu.cnSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2fd60da4
    • Rafael J. Wysocki's avatar
      driver core: Remove device link creation limitation · 515db266
      Rafael J. Wysocki authored
      If device_link_add() is called for a consumer/supplier pair with an
      existing device link between them and the existing link's type is
      not in agreement with the flags passed to that function by its
      caller, NULL will be returned.  That is seriously inconvenient,
      because it forces the callers of device_link_add() to worry about
      what others may or may not do even if that is not relevant to them
      for any other reasons.
      
      It turns out, however, that this limitation can be made go away
      relatively easily.
      
      The underlying observation is that if DL_FLAG_STATELESS has been
      passed to device_link_add() in flags for the given consumer/supplier
      pair at least once, calling either device_link_del() or
      device_link_remove() to release the link returned by it should work,
      but there are no other requirements associated with that flag.  In
      turn, if at least one of the callers of device_link_add() for the
      given consumer/supplier pair has not passed DL_FLAG_STATELESS to it
      in flags, the driver core should track the status of the link and act
      on it as appropriate (ie. the link should be treated as "managed").
      This means that DL_FLAG_STATELESS needs to be set for managed device
      links and it should be valid to call device_link_del() or
      device_link_remove() to drop references to them in certain
      sutiations.
      
      To allow that to happen, introduce a new (internal) device link flag
      called DL_FLAG_MANAGED and make device_link_add() set it automatically
      whenever DL_FLAG_STATELESS is not passed to it.  Also make it take
      additional references to existing device links that were previously
      stateless (that is, with DL_FLAG_STATELESS set and DL_FLAG_MANAGED
      unset) and will need to be managed going forward and initialize
      their status (which has been DL_STATE_NONE so far).
      
      Accordingly, when a managed device link is dropped automatically
      by the driver core, make it clear DL_FLAG_MANAGED, reset the link's
      status back to DL_STATE_NONE and drop the reference to it associated
      with DL_FLAG_MANAGED instead of just deleting it right away (to
      allow it to stay around in case it still needs to be released
      explicitly by someone).
      
      With that, since setting DL_FLAG_STATELESS doesn't mean that the
      device link in question is not managed any more, replace all of the
      status-tracking checks against DL_FLAG_STATELESS with analogous
      checks against DL_FLAG_MANAGED and update the documentation to
      reflect these changes.
      
      While at it, make device_link_add() reject flags that it does not
      recognize, including DL_FLAG_MANAGED.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: default avatarSaravana Kannan <saravanak@google.com>
      Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Review-by: default avatarSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/2305283.AStDPdUUnE@kreacherSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      515db266
  6. 21 Jul, 2019 2 commits