1. 09 11月, 2018 15 次提交
    • F
      of: unittest: find overlays[] entry by name instead of index · 160b1d4e
      Frank Rowand 提交于
      One accessor of overlays[] was using a hard coded index value to
      find the correct array entry instead of searching for the entry
      containing the correct name.
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      160b1d4e
    • F
      of: unittest: allow base devicetree to have symbol metadata · 5babefb7
      Frank Rowand 提交于
      The overlay metadata nodes in the FDT created from testcases.dts
      are not handled properly.
      
      The __fixups__ and __local_fixups__ node were added to the live
      devicetree, but should not be.
      
      Only the first property in the /__symbols__ node was added to the
      live devicetree if the live devicetree already contained a
      /__symbols node.  All of the node's properties must be added.
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      5babefb7
    • F
      of: overlay: set node fields from properties when add new overlay node · f9627881
      Frank Rowand 提交于
      Overlay nodes added by add_changeset_node() do not have the node
      fields name, phandle, and type set.
      
      The node passed to __of_attach_node() when the add node changeset
      entry is processed does not contain any properties.  The node's
      properties are located in add property changeset entries that will
      be processed after the add node changeset is applied.
      
      Set the node's fields in the node contained in the add node
      changeset entry and do not set them to incorrect values in
      add_changeset_node().
      
      A visible symptom that is fixed by this patch is the names of nodes
      added by overlays that have an entry in /sys/bus/platform/drivers/*/
      will contain the unit-address but the node-name will be <NULL>,  for
      example, "fc4ab000.<NULL>".  After applying the patch the name, in
      this example, for node restart@fc4ab000 is "fc4ab000.restart".
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      f9627881
    • F
      of: unittest: remove unused of_unittest_apply_overlay() argument · 8c329655
      Frank Rowand 提交于
      Argument unittest_nr is not used in of_unittest_apply_overlay(),
      remove it.
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      8c329655
    • F
      of: overlay: check prevents multiple fragments touching same property · 2fe0e876
      Frank Rowand 提交于
      Add test case of two fragments updating the same property.  After
      adding the test case, the system hangs at end of boot, after
      after slub stack dumps from kfree() in crypto modprobe code.
      
      Multiple overlay fragments adding, modifying, or deleting the same
      property is not supported.  Add check to detect the attempt and fail
      the overlay apply.
      
      Before this patch, the first fragment error would terminate
      processing.  Allow fragment checking to proceed and report all
      of the fragment errors before terminating the overlay apply. This
      is not a hot path, thus not a performance issue (the error is not
      transient and requires fixing the overlay before attempting to
      apply it again).
      
      After applying this patch, the devicetree unittest messages will
      include:
      
         OF: overlay: ERROR: multiple fragments add, update, and/or delete property /testcase-data-2/substation@100/motor-1/rpm_avail
      
         ...
      
         ### dt-test ### end of unittest - 212 passed, 0 failed
      
      The check to detect two fragments updating the same property is
      folded into the patch that created the test case to maintain
      bisectability.
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      2fe0e876
    • F
      of: overlay: check prevents multiple fragments add or delete same node · c168263b
      Frank Rowand 提交于
      Multiple overlay fragments adding or deleting the same node is not
      supported.  Replace code comment of such, with check to detect the
      attempt and fail the overlay apply.
      
      Devicetree unittest where multiple fragments added the same node was
      added in the previous patch in the series.  After applying this patch
      the unittest messages will no longer include:
      
         Duplicate name in motor-1, renamed to "controller#1"
         OF: overlay: of_overlay_apply() err=0
         ### dt-test ### of_overlay_fdt_apply() expected -22, ret=0, overlay_bad_add_dup_node
         ### dt-test ### FAIL of_unittest_overlay_high_level():2419 Adding overlay 'overlay_bad_add_dup_node' failed
      
         ...
      
         ### dt-test ### end of unittest - 210 passed, 1 failed
      
      but will instead include:
      
         OF: overlay: ERROR: multiple overlay fragments add and/or delete node /testcase-data-2/substation@100/motor-1/controller
      
         ...
      
         ### dt-test ### end of unittest - 211 passed, 0 failed
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      c168263b
    • F
      of: overlay: test case of two fragments adding same node · a68238a1
      Frank Rowand 提交于
      Multiple overlay fragments adding or deleting the same node is not
      supported.  An attempt to do so results in an incorrect devicetree.
      The node name will be munged for the second add.
      
      After adding this patch, the unittest messages will show:
      
         Duplicate name in motor-1, renamed to "controller#1"
         OF: overlay: of_overlay_apply() err=0
         ### dt-test ### of_overlay_fdt_apply() expected -22, ret=0, overlay_bad_add_dup_node
         ### dt-test ### FAIL of_unittest_overlay_high_level():2419 Adding overlay 'overlay_bad_add_dup_node' failed
      
         ...
      
         ### dt-test ### end of unittest - 210 passed, 1 failed
      
      The incorrect (munged) node name "controller#1" can be seen in the
      /proc filesystem:
      
         $ pwd
         /proc/device-tree/testcase-data-2/substation@100/motor-1
         $ ls
         compatible    controller    controller#1  name          phandle       spin
         $ ls controller
         power_bus
         $ ls controller#1
         power_bus_emergency
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      a68238a1
    • F
      of: overlay: make all pr_debug() and pr_err() messages unique · a15e824f
      Frank Rowand 提交于
      Make overlay.c debug and error messages unique so that they can be
      unambiguously found by grep.
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      a15e824f
    • F
      of: overlay: validate overlay properties #address-cells and #size-cells · 6f751188
      Frank Rowand 提交于
      If overlay properties #address-cells or #size-cells are already in
      the live devicetree for any given node, then the values in the
      overlay must match the values in the live tree.
      
      If the properties are already in the live tree then there is no
      need to create a changeset entry to add them since they must
      have the same value.  This reduces the memory used by the
      changeset and eliminates a possible memory leak.
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      6f751188
    • F
      of: overlay: reorder fields in struct fragment · 81225ea6
      Frank Rowand 提交于
      Order the fields of struct fragment in the same order as
      struct of_overlay_notify_data.  The order in struct fragment is
      not significant.  If both structs are ordered the same then when
      examining the data in a debugger or dump the human involved does
      not have to remember which context they are examining.
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      81225ea6
    • F
      of: overlay: do not duplicate properties from overlay for new nodes · 8814dc46
      Frank Rowand 提交于
      When allocating a new node, add_changeset_node() was duplicating the
      properties from the respective node in the overlay instead of
      allocating a node with no properties.
      
      When this patch is applied the errors reported by the devictree
      unittest from patch "of: overlay: add tests to validate kfrees from
      overlay removal" will no longer occur.  These error messages are of
      the form:
      
         "OF: ERROR: ..."
      
      and the unittest results will change from:
      
         ### dt-test ### end of unittest - 203 passed, 7 failed
      
      to
      
         ### dt-test ### end of unittest - 210 passed, 0 failed
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      8814dc46
    • F
      of: overlay: use prop add changeset entry for property in new nodes · 6b4955ba
      Frank Rowand 提交于
      The changeset entry 'update property' was used for new properties in
      an overlay instead of 'add property'.
      
      The decision of whether to use 'update property' was based on whether
      the property already exists in the subtree where the node is being
      spliced into.  At the top level of creating a changeset describing the
      overlay, the target node is in the live devicetree, so checking whether
      the property exists in the target node returns the correct result.
      As soon as the changeset creation algorithm recurses into a new node,
      the target is no longer in the live devicetree, but is instead in the
      detached overlay tree, thus all properties are incorrectly found to
      already exist in the target.
      
      This fix will expose another devicetree bug that will be fixed
      in the following patch in the series.
      
      When this patch is applied the errors reported by the devictree
      unittest will change, and the unittest results will change from:
      
         ### dt-test ### end of unittest - 210 passed, 0 failed
      
      to
      
         ### dt-test ### end of unittest - 203 passed, 7 failed
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      6b4955ba
    • F
      of: overlay: add missing of_node_get() in __of_attach_node_sysfs · 5b2c2f5a
      Frank Rowand 提交于
      There is a matching of_node_put() in __of_detach_node_sysfs()
      
      Remove misleading comment from function header comment for
      of_detach_node().
      
      This patch may result in memory leaks from code that directly calls
      the dynamic node add and delete functions directly instead of
      using changesets.
      
      This commit should result in powerpc systems that dynamically
      allocate a node, then later deallocate the node to have a
      memory leak when the node is deallocated.
      
      The next commit will fix the leak.
      Tested-by: NAlan Tull <atull@kernel.org>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      5b2c2f5a
    • F
      of: overlay: add missing of_node_put() after add new node to changeset · 7c528e45
      Frank Rowand 提交于
      The refcount of a newly added overlay node decrements to one
      (instead of zero) when the overlay changeset is destroyed.  This
      change will cause the final decrement be to zero.
      
      After applying this patch, new validation warnings will be
      reported from the devicetree unittest during boot due to
      a pre-existing devicetree bug.  The warnings will be similar to:
      
        OF: ERROR: memory leak before free overlay changeset,  /testcase-data/overlay-node/test-bus/test-unittest4
      
      This pre-existing devicetree bug will also trigger a WARN_ONCE() from
      refcount_sub_and_test_checked() when an overlay changeset is
      destroyed without having first been applied.  This scenario occurs
      when an error in the overlay is detected during the overlay changeset
      creation:
      
        WARNING: CPU: 0 PID: 1 at lib/refcount.c:187 refcount_sub_and_test_checked+0xa8/0xbc
        refcount_t: underflow; use-after-free.
      
        (unwind_backtrace) from (show_stack+0x10/0x14)
        (show_stack) from (dump_stack+0x6c/0x8c)
        (dump_stack) from (__warn+0xdc/0x104)
        (__warn) from (warn_slowpath_fmt+0x44/0x6c)
        (warn_slowpath_fmt) from (refcount_sub_and_test_checked+0xa8/0xbc)
        (refcount_sub_and_test_checked) from (kobject_put+0x24/0x208)
        (kobject_put) from (of_changeset_destroy+0x2c/0xb4)
        (of_changeset_destroy) from (free_overlay_changeset+0x1c/0x9c)
        (free_overlay_changeset) from (of_overlay_remove+0x284/0x2cc)
        (of_overlay_remove) from (of_unittest_apply_revert_overlay_check.constprop.4+0xf8/0x1e8)
        (of_unittest_apply_revert_overlay_check.constprop.4) from (of_unittest_overlay+0x960/0xed8)
        (of_unittest_overlay) from (of_unittest+0x1cc4/0x2138)
        (of_unittest) from (do_one_initcall+0x4c/0x28c)
        (do_one_initcall) from (kernel_init_freeable+0x29c/0x378)
        (kernel_init_freeable) from (kernel_init+0x8/0x110)
        (kernel_init) from (ret_from_fork+0x14/0x2c)
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      7c528e45
    • F
      of: overlay: add tests to validate kfrees from overlay removal · 144552c7
      Frank Rowand 提交于
      Add checks:
        - attempted kfree due to refcount reaching zero before overlay
          is removed
        - properties linked to an overlay node when the node is removed
        - node refcount > one during node removal in a changeset destroy,
          if the node was created by the changeset
      
      After applying this patch, several validation warnings will be
      reported from the devicetree unittest during boot due to
      pre-existing devicetree bugs. The warnings will be similar to:
      
        OF: ERROR: of_node_release(), unexpected properties in /testcase-data/overlay-node/test-bus/test-unittest11
        OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /testcase-data-2/substation@100/
        hvac-medium-2
      Tested-by: NAlan Tull <atull@kernel.org>
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      144552c7
  2. 03 11月, 2018 3 次提交
  3. 02 11月, 2018 5 次提交
    • K
      nvme-pci: fix conflicting p2p resource adds · 9fe5c59f
      Keith Busch 提交于
      The nvme pci driver had been adding its CMB resource to the P2P DMA
      subsystem everytime on on a controller reset. This results in the
      following warning:
      
          ------------[ cut here ]------------
          nvme 0000:00:03.0: Conflicting mapping in same section
          WARNING: CPU: 7 PID: 81 at kernel/memremap.c:155 devm_memremap_pages+0xa6/0x380
          ...
          Call Trace:
           pci_p2pdma_add_resource+0x153/0x370
           nvme_reset_work+0x28c/0x17b1 [nvme]
           ? add_timer+0x107/0x1e0
           ? dequeue_entity+0x81/0x660
           ? dequeue_entity+0x3b0/0x660
           ? pick_next_task_fair+0xaf/0x610
           ? __switch_to+0xbc/0x410
           process_one_work+0x1cf/0x350
           worker_thread+0x215/0x3d0
           ? process_one_work+0x350/0x350
           kthread+0x107/0x120
           ? kthread_park+0x80/0x80
           ret_from_fork+0x1f/0x30
          ---[ end trace f7ea76ac6ee72727 ]---
          nvme nvme0: failed to register the CMB
      
      This patch fixes this by registering the CMB with P2P only once.
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Reviewed-by: NLogan Gunthorpe <logang@deltatee.com>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      9fe5c59f
    • J
      nvme-fc: fix request private initialization · d19b8bc8
      James Smart 提交于
      The patch made to avoid Coverity reporting of out of bounds access
      on aen_op moved the assignment of a pointer, leaving it null when it
      was subsequently used to calculate a private pointer. Thus the private
      pointer was bad.
      
      Move/correct the private pointer initialization to be in sync with the
      patch.
      
      Fixes: 0d2bdf9f ("nvme-fc: rework the request initialization code")
      Signed-off-by: NJames Smart <jsmart2021@gmail.com>
      Reviewed-by: NSagi Grimberg <sagi@grimberg.me>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      d19b8bc8
    • D
      blkcg: revert blkcg cleanups series · b5f2954d
      Dennis Zhou 提交于
      This reverts a series committed earlier due to null pointer exception
      bug report in [1]. It seems there are edge case interactions that I did
      not consider and will need some time to understand what causes the
      adverse interactions.
      
      The original series can be found in [2] with a follow up series in [3].
      
      [1] https://www.spinics.net/lists/cgroups/msg20719.html
      [2] https://lore.kernel.org/lkml/20180911184137.35897-1-dennisszhou@gmail.com/
      [3] https://lore.kernel.org/lkml/20181020185612.51587-1-dennis@kernel.org/
      
      This reverts the following commits:
      d459d853, b2c3fa54, 101246ec, b3b9f24f, e2b09899,
      f0fcb3ec, c839e7a0, bdc24917, 74b7c02a, 5bf9a1f3,
      a7b39b4e, 07b05bcc, 49f4c2dc, 27e6fa99Signed-off-by: NDennis Zhou <dennis@kernel.org>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      b5f2954d
    • M
      block: brd: associate with queue until adding disk · 153fcd5f
      Ming Lei 提交于
      brd_free() may be called in failure path on one brd instance which
      disk isn't added yet, so release handler of gendisk may free the
      associated request_queue early and causes the following use-after-free[1].
      
      This patch fixes this issue by associating gendisk with request_queue
      just before adding disk.
      
      [1] KASAN: use-after-free Read in del_timer_syncNon-volatile memory driver v1.3
      Linux agpgart interface v0.103
      [drm] Initialized vgem 1.0.0 20120112 for virtual device on minor 0
      usbcore: registered new interface driver udl
      ==================================================================
      BUG: KASAN: use-after-free in __lock_acquire+0x36d9/0x4c20
      kernel/locking/lockdep.c:3218
      Read of size 8 at addr ffff8801d1b6b540 by task swapper/0/1
      
      CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.0+ #88
      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+0x244/0x39d lib/dump_stack.c:113
        print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
        kasan_report_error mm/kasan/report.c:354 [inline]
        kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
        __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
        __lock_acquire+0x36d9/0x4c20 kernel/locking/lockdep.c:3218
        lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844
        del_timer_sync+0xb7/0x270 kernel/time/timer.c:1283
        blk_cleanup_queue+0x413/0x710 block/blk-core.c:809
        brd_free+0x5d/0x71 drivers/block/brd.c:422
        brd_init+0x2eb/0x393 drivers/block/brd.c:518
        do_one_initcall+0x145/0x957 init/main.c:890
        do_initcall_level init/main.c:958 [inline]
        do_initcalls init/main.c:966 [inline]
        do_basic_setup init/main.c:984 [inline]
        kernel_init_freeable+0x5c6/0x6b9 init/main.c:1148
        kernel_init+0x11/0x1ae init/main.c:1068
        ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:350
      
      Reported-by: syzbot+3701447012fe951dabb2@syzkaller.appspotmail.com
      Signed-off-by: NMing Lei <ming.lei@redhat.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      153fcd5f
    • R
      of: Fix cpu node iterator to not ignore disabled cpu nodes · c961cb3b
      Rob Herring 提交于
      In most cases, nodes with 'status = "disabled";' are treated as if the
      node is not present though it is a common bug to forget to check that.
      However, cpu nodes are different in that "disabled" simply means offline
      and the OS can bring the CPU core online. Commit f1f207e4 ("of: Add
      cpu node iterator for_each_of_cpu_node()") followed the common behavior
      of ignoring disabled cpu nodes. This breaks some powerpc systems (at
      least NXP P50XX/e5500). Fix this by dropping the status check.
      
      Fixes: 651d44f9 ("of: use for_each_of_cpu_node iterator")
      Fixes: f1f207e4 ("of: Add cpu node iterator for_each_of_cpu_node()")
      Reported-by: NChristian Zigotzky <chzigotzky@xenosoft.de>
      Tested-by: NMichael Ellerman <mpe@ellerman.id.au>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      c961cb3b
  4. 01 11月, 2018 17 次提交