All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 0/6] test_sysfs: add new selftest for sysfs
@ 2021-10-29 18:44 Luis Chamberlain
  2021-10-29 18:44 ` [PATCH v9 1/6] LICENSES: Add the copyleft-next-0.3.1 license Luis Chamberlain
                   ` (5 more replies)
  0 siblings, 6 replies; 36+ messages in thread
From: Luis Chamberlain @ 2021-10-29 18:44 UTC (permalink / raw)
  To: tj, gregkh, akpm, jeyu, shuah
  Cc: bvanassche, dan.j.williams, joe, tglx, mcgrof, keescook, rostedt,
	minchan, linux-spdx, linux-doc, linux-block, linux-fsdevel,
	linux-kselftest, linux-kernel

On this v9 I've dropped the generic sysfs deadlock fix given Ming Lei
has provided alternative fixes for the zram driver without incurring
a generic lock *and* we don't yet have full assessment of how wide
spread the deadlock case might be in the kernel. A full assessment
effort is still underway using Coccinelle with iteration support,
however that effort will take a bit more time to complete. We can
re-evaluate the value of a generic fix later after the assessment
is complete.

This series now just adds the test_sysfs selftest and failure injection
support for it on kernfs. The most valuable tests are those which
confirm that once a kernfs active reference is obtained with
kernfs_get_active() the pointers used there are still valid, and so
using sysfs ops *are* safe if we race against module removal. Likewise
it also confirms how module removal will *wait* for these ops to
complete if a kernfs node is already active.

This v9 series also addresses feedback mostly provided by Kees Cook and Greg.
I also made a few changes to the test_sysfs driver to account for changes in
the block layer. I also improved the kernfs failure injection tests with
documentation of how they work and to account for the real expected return
value of a write before the kernfs active reference is obtained. Upstream
commit 8e141f9eb803e ("block: drain file system I/O on del_gendisk") has
revealed that small minor induced delays on del_gendisk() can make a few
writes succeed if the delays used are small. So we clarify the logic of why
writes could either fail or succeed before the kernfs active reference is taken.

These changes also availble on this tree:

https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?h=20211029-test-sysfs-v2

v9:
  * rebased onto linux-next tag next-20211029
  * add Reviewed-by tags for the SPDX change, and the drivers which
    get the tag for it
  * drop the generic sysfs deadlock fix for now as the scope of how
    wide spread the issue is still needs to be assessed
  * drop the zram patches as they are replaced by Ming Lei's fixes
  * drop already merged patches
  * try_module_get() docs: enhanced using feedback from Kees Cook. I
    extended the documention to make it clear that if proper care is not
    taken the use of this routine could crash the kernel.
  * kernfs: move failure injection knobs under /sys/kernel/debug/fail_kernfs
    as suggested by Kees Cook
  * kernfs: rename failure injection file to fault_inject.c as suggested
    by Kees Cook
  * kernfs: split up documentation of failure injection knobs as
    suggested by Kees Cook
  * kernfs: move the wait into debug call, and use a simple one liner
    may_wait() calls to make the changes much less intrusive and more
    readable  as suggested by Kees Cook 
  * kernfs: drop __func__ uses as suggested by Kees Cook
  * test_sysfs: use sizeof() instead of open coded 16 as suggested by
    Kees Cook
  * test_sysfs: use sysfs_emit as suggested by Kees Cook
  * test_sysfs: drop boiler place license as suggested by Greg KH
  * test_sysfs: use depends instead of select as suggested by Kees Cook
  * test_sysfs: drop #ifdefery as suggested by Kees Cook
  * test_sysfs: clarified that the use of a lock on rmmod which causes
    a deadlock is something drivers should avoid, and its why we leave
    the test disabled.
  * test_sysfs: now that device_add_disk() returns an error, use the
    new error return code, otherwise this is going to prevent us from
    eventually embracing __must_check() on that call on the block layer.
  * test_syfs: testdev_submit_bio() needed to change data types as now
    it returns void.
  * test_sysfs: enhance kernfs failure injection tests with documenation
    and correct the expected return value for writes

Luis Chamberlain (6):
  LICENSES: Add the copyleft-next-0.3.1 license
  testing: use the copyleft-next-0.3.1 SPDX tag
  selftests: add tests_sysfs module
  kernfs: add initial failure injection support
  test_sysfs: add support to use kernfs failure injection
  kernel/module: add documentation for try_module_get()

 .../fault-injection/fault-injection.rst       |   50 +
 LICENSES/dual/copyleft-next-0.3.1             |  237 +++
 MAINTAINERS                                   |    9 +-
 fs/kernfs/Makefile                            |    1 +
 fs/kernfs/fault_inject.c                      |   93 ++
 fs/kernfs/file.c                              |    9 +
 fs/kernfs/kernfs-internal.h                   |   70 +
 include/linux/kernfs.h                        |    5 +
 include/linux/module.h                        |   37 +-
 lib/Kconfig.debug                             |   23 +
 lib/Makefile                                  |    1 +
 lib/test_kmod.c                               |   12 +-
 lib/test_sysctl.c                             |   12 +-
 lib/test_sysfs.c                              |  913 +++++++++++
 tools/testing/selftests/kmod/kmod.sh          |   13 +-
 tools/testing/selftests/sysctl/sysctl.sh      |   12 +-
 tools/testing/selftests/sysfs/Makefile        |   12 +
 tools/testing/selftests/sysfs/config          |    5 +
 tools/testing/selftests/sysfs/settings        |    1 +
 tools/testing/selftests/sysfs/sysfs.sh        | 1411 +++++++++++++++++
 20 files changed, 2878 insertions(+), 48 deletions(-)
 create mode 100644 LICENSES/dual/copyleft-next-0.3.1
 create mode 100644 fs/kernfs/fault_inject.c
 create mode 100644 lib/test_sysfs.c
 create mode 100644 tools/testing/selftests/sysfs/Makefile
 create mode 100644 tools/testing/selftests/sysfs/config
 create mode 100644 tools/testing/selftests/sysfs/settings
 create mode 100755 tools/testing/selftests/sysfs/sysfs.sh

-- 
2.30.2


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2022-06-02 19:41 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-29 18:44 [PATCH v9 0/6] test_sysfs: add new selftest for sysfs Luis Chamberlain
2021-10-29 18:44 ` [PATCH v9 1/6] LICENSES: Add the copyleft-next-0.3.1 license Luis Chamberlain
2022-05-23 21:10   ` Thomas Gleixner
2022-05-24 13:59     ` Richard Fontana
2022-05-25 17:10     ` Luis Chamberlain
2022-05-25 19:13     ` Bradley M. Kuhn
2022-05-25 21:50       ` J Lovejoy
2022-05-25 22:29         ` Bradley M. Kuhn
2022-05-23 21:22   ` Thomas Gleixner
2022-05-25 16:57     ` Luis Chamberlain
2022-05-25 20:51       ` Thomas Gleixner
2022-05-25 23:53         ` Luis Chamberlain
2022-05-23 21:27   ` Thomas Gleixner
2022-05-25 16:43     ` Luis Chamberlain
2022-05-25 17:05       ` Bird, Tim
2022-05-25 18:11         ` Luis Chamberlain
2022-05-25 19:05           ` Bird, Tim
2022-05-25 19:44             ` Luis Chamberlain
2022-05-25 22:16             ` Thomas Gleixner
2022-06-02  4:11               ` Bird, Tim
2022-06-02  6:20                 ` gregkh
2022-06-02 19:41                   ` Luis Chamberlain
2022-06-02 19:30                 ` Luis Chamberlain
2021-10-29 18:44 ` [PATCH v9 2/6] testing: use the copyleft-next-0.3.1 SPDX tag Luis Chamberlain
2021-10-29 18:44 ` [PATCH v9 3/6] selftests: add tests_sysfs module Luis Chamberlain
2021-12-03 15:29   ` Greg KH
2021-12-09  1:48     ` Luis Chamberlain
2021-12-10 21:39       ` Luis Chamberlain
2021-12-14 19:31       ` [copyleft-next] " Richard Fontana
2022-05-22 14:37     ` Thomas Gleixner
2022-05-22 14:47       ` Greg KH
2022-05-22 15:06         ` Thomas Gleixner
2022-05-23 19:37           ` Luis Chamberlain
2021-10-29 18:44 ` [PATCH v9 4/6] kernfs: add initial failure injection support Luis Chamberlain
2021-10-29 18:44 ` [PATCH v9 5/6] test_sysfs: add support to use kernfs failure injection Luis Chamberlain
2021-10-29 18:45 ` [PATCH v9 6/6] kernel/module: add documentation for try_module_get() Luis Chamberlain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.