1. 04 6月, 2021 1 次提交
  2. 16 4月, 2021 1 次提交
  3. 05 4月, 2021 1 次提交
  4. 30 10月, 2020 1 次提交
  5. 05 9月, 2020 1 次提交
  6. 11 7月, 2020 1 次提交
  7. 10 7月, 2020 1 次提交
  8. 17 4月, 2020 1 次提交
  9. 18 3月, 2020 1 次提交
    • T
      debugfs: Check module state before warning in {full/open}_proxy_open() · 275678e7
      Taehee Yoo 提交于
      When the module is being removed, the module state is set to
      MODULE_STATE_GOING. At this point, try_module_get() fails.
      And when {full/open}_proxy_open() is being called,
      it calls try_module_get() to try to hold module reference count.
      If it fails, it warns about the possibility of debugfs file leak.
      
      If {full/open}_proxy_open() is called while the module is being removed,
      it fails to hold the module.
      So, It warns about debugfs file leak. But it is not the debugfs file
      leak case. So, this patch just adds module state checking routine
      in the {full/open}_proxy_open().
      
      Test commands:
          #SHELL1
          while :
          do
              modprobe netdevsim
              echo 1 > /sys/bus/netdevsim/new_device
              modprobe -rv netdevsim
          done
      
          #SHELL2
          while :
          do
              cat /sys/kernel/debug/netdevsim/netdevsim1/ports/0/ipsec
          done
      
      Splat looks like:
      [  298.766738][T14664] debugfs file owner did not clean up at exit: ipsec
      [  298.766766][T14664] WARNING: CPU: 2 PID: 14664 at fs/debugfs/file.c:312 full_proxy_open+0x10f/0x650
      [  298.768595][T14664] Modules linked in: netdevsim(-) openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 n][  298.771343][T14664] CPU: 2 PID: 14664 Comm: cat Tainted: G        W         5.5.0+ #1
      [  298.772373][T14664] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [  298.773545][T14664] RIP: 0010:full_proxy_open+0x10f/0x650
      [  298.774247][T14664] Code: 48 c1 ea 03 80 3c 02 00 0f 85 c1 04 00 00 49 8b 3c 24 e8 e4 b5 78 ff 84 c0 75 2d 4c 89 ee 48
      [  298.776782][T14664] RSP: 0018:ffff88805b7df9b8 EFLAGS: 00010282[  298.777583][T14664] RAX: dffffc0000000008 RBX: ffff8880511725c0 RCX: 0000000000000000
      [  298.778610][T14664] RDX: 0000000000000000 RSI: 0000000000000006 RDI: ffff8880540c5c14
      [  298.779637][T14664] RBP: 0000000000000000 R08: fffffbfff15235ad R09: 0000000000000000
      [  298.780664][T14664] R10: 0000000000000001 R11: 0000000000000000 R12: ffffffffc06b5000
      [  298.781702][T14664] R13: ffff88804c234a88 R14: ffff88804c22dd00 R15: ffffffff8a1b5660
      [  298.782722][T14664] FS:  00007fafa13a8540(0000) GS:ffff88806c800000(0000) knlGS:0000000000000000
      [  298.783845][T14664] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  298.784672][T14664] CR2: 00007fafa0e9cd10 CR3: 000000004b286005 CR4: 00000000000606e0
      [  298.785739][T14664] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  298.786769][T14664] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  298.787785][T14664] Call Trace:
      [  298.788237][T14664]  do_dentry_open+0x63c/0xf50
      [  298.788872][T14664]  ? open_proxy_open+0x270/0x270
      [  298.789524][T14664]  ? __x64_sys_fchdir+0x180/0x180
      [  298.790169][T14664]  ? inode_permission+0x65/0x390
      [  298.790832][T14664]  path_openat+0xc45/0x2680
      [  298.791425][T14664]  ? save_stack+0x69/0x80
      [  298.791988][T14664]  ? save_stack+0x19/0x80
      [  298.792544][T14664]  ? path_mountpoint+0x2e0/0x2e0
      [  298.793233][T14664]  ? check_chain_key+0x236/0x5d0
      [  298.793910][T14664]  ? sched_clock_cpu+0x18/0x170
      [  298.794527][T14664]  ? find_held_lock+0x39/0x1d0
      [  298.795153][T14664]  do_filp_open+0x16a/0x260
      [ ... ]
      
      Fixes: 9fd4dcec ("debugfs: prevent access to possibly dead file_operations at file open")
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NTaehee Yoo <ap420073@gmail.com>
      Link: https://lore.kernel.org/r/20200218043150.29447-1-ap420073@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      275678e7
  10. 22 2月, 2020 1 次提交
  11. 11 2月, 2020 1 次提交
  12. 14 1月, 2020 1 次提交
    • E
      debugfs: Return -EPERM when locked down · a37f4958
      Eric Snowberg 提交于
      When lockdown is enabled, debugfs_is_locked_down returns 1. It will then
      trigger the following:
      
      WARNING: CPU: 48 PID: 3747
      CPU: 48 PID: 3743 Comm: bash Not tainted 5.4.0-1946.x86_64 #1
      Hardware name: Oracle Corporation ORACLE SERVER X7-2/ASM, MB, X7-2, BIOS 41060400 05/20/2019
      RIP: 0010:do_dentry_open+0x343/0x3a0
      Code: 00 40 08 00 45 31 ff 48 c7 43 28 40 5b e7 89 e9 02 ff ff ff 48 8b 53 28 4c 8b 72 70 4d 85 f6 0f 84 10 fe ff ff e9 f5 fd ff ff <0f> 0b 41 bf ea ff ff ff e9 3b ff ff ff 41 bf e6 ff ff ff e9 b4 fe
      RSP: 0018:ffffb8740dde7ca0 EFLAGS: 00010202
      RAX: ffffffff89e88a40 RBX: ffff928c8e6b6f00 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: ffff928dbfd97778 RDI: ffff9285cff685c0
      RBP: ffffb8740dde7cc8 R08: 0000000000000821 R09: 0000000000000030
      R10: 0000000000000057 R11: ffffb8740dde7a98 R12: ffff926ec781c900
      R13: ffff928c8e6b6f10 R14: ffffffff8936e190 R15: 0000000000000001
      FS:  00007f45f6777740(0000) GS:ffff928dbfd80000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fff95e0d5d8 CR3: 0000001ece562006 CR4: 00000000007606e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      PKRU: 55555554
      Call Trace:
       vfs_open+0x2d/0x30
       path_openat+0x2d4/0x1680
       ? tty_mode_ioctl+0x298/0x4c0
       do_filp_open+0x93/0x100
       ? strncpy_from_user+0x57/0x1b0
       ? __alloc_fd+0x46/0x150
       do_sys_open+0x182/0x230
       __x64_sys_openat+0x20/0x30
       do_syscall_64+0x60/0x1b0
       entry_SYSCALL_64_after_hwframe+0x170/0x1d5
      RIP: 0033:0x7f45f5e5ce02
      Code: 25 00 00 41 00 3d 00 00 41 00 74 4c 48 8d 05 25 59 2d 00 8b 00 85 c0 75 6d 89 f2 b8 01 01 00 00 48 89 fe bf 9c ff ff ff 0f 05 <48> 3d 00 f0 ff ff 0f 87 a2 00 00 00 48 8b 4c 24 28 64 48 33 0c 25
      RSP: 002b:00007fff95e0d2e0 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
      RAX: ffffffffffffffda RBX: 0000561178c069b0 RCX: 00007f45f5e5ce02
      RDX: 0000000000000241 RSI: 0000561178c08800 RDI: 00000000ffffff9c
      RBP: 00007fff95e0d3e0 R08: 0000000000000020 R09: 0000000000000005
      R10: 00000000000001b6 R11: 0000000000000246 R12: 0000000000000000
      R13: 0000000000000003 R14: 0000000000000001 R15: 0000561178c08800
      
      Change the return type to int and return -EPERM when lockdown is enabled
      to remove the warning above. Also rename debugfs_is_locked_down to
      debugfs_locked_down to make it sound less like it returns a boolean.
      
      Fixes: 5496197f ("debugfs: Restrict debugfs when the kernel is locked down")
      Signed-off-by: NEric Snowberg <eric.snowberg@oracle.com>
      Reviewed-by: NMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NJames Morris <jamorris@linux.microsoft.com>
      Link: https://lore.kernel.org/r/20191207161603.35907-1-eric.snowberg@oracle.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a37f4958
  13. 07 1月, 2020 1 次提交
    • D
      debugfs: Fix warnings when building documentation · adc92dd4
      Daniel W. S. Almeida 提交于
      Fix the following warnings:
      
      fs/debugfs/inode.c:423: WARNING: Inline literal start-string without end-string.
      fs/debugfs/inode.c:502: WARNING: Inline literal start-string without end-string.
      fs/debugfs/inode.c:534: WARNING: Inline literal start-string without end-string.
      fs/debugfs/inode.c:627: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:496: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:502: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:581: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:587: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:846: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:852: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:899: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:905: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:1091: WARNING: Inline literal start-string without end-string.
      fs/debugfs/file.c:1097: WARNING: Inline literal start-string without end-string
      
      By replacing %ERR_PTR with ERR_PTR.
      Signed-off-by: NDaniel W. S. Almeida <dwlsalmeida@gmail.com>
      Link: https://lore.kernel.org/r/20191227010035.854913-1-dwlsalmeida@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      adc92dd4
  14. 03 11月, 2019 2 次提交
  15. 16 10月, 2019 3 次提交
  16. 14 10月, 2019 4 次提交
  17. 20 8月, 2019 1 次提交
    • D
      debugfs: Restrict debugfs when the kernel is locked down · 5496197f
      David Howells 提交于
      Disallow opening of debugfs files that might be used to muck around when
      the kernel is locked down as various drivers give raw access to hardware
      through debugfs.  Given the effort of auditing all 2000 or so files and
      manually fixing each one as necessary, I've chosen to apply a heuristic
      instead.  The following changes are made:
      
       (1) chmod and chown are disallowed on debugfs objects (though the root dir
           can be modified by mount and remount, but I'm not worried about that).
      
       (2) When the kernel is locked down, only files with the following criteria
           are permitted to be opened:
      
      	- The file must have mode 00444
      	- The file must not have ioctl methods
      	- The file must not have mmap
      
       (3) When the kernel is locked down, files may only be opened for reading.
      
      Normal device interaction should be done through configfs, sysfs or a
      miscdev, not debugfs.
      
      Note that this makes it unnecessary to specifically lock down show_dsts(),
      show_devs() and show_call() in the asus-wmi driver.
      
      I would actually prefer to lock down all files by default and have the
      the files unlocked by the creator.  This is tricky to manage correctly,
      though, as there are 19 creation functions and ~1600 call sites (some of
      them in loops scanning tables).
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      cc: acpi4asus-user@lists.sourceforge.net
      cc: platform-driver-x86@vger.kernel.org
      cc: Matthew Garrett <mjg59@srcf.ucam.org>
      cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Greg KH <greg@kroah.com>
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Signed-off-by: NMatthew Garrett <matthewgarrett@google.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      5496197f
  18. 03 6月, 2019 1 次提交
  19. 25 4月, 2019 1 次提交
  20. 14 5月, 2018 1 次提交
  21. 12 2月, 2018 1 次提交
    • L
      vfs: do bulk POLL* -> EPOLL* replacement · a9a08845
      Linus Torvalds 提交于
      This is the mindless scripted replacement of kernel use of POLL*
      variables as described by Al, done by this script:
      
          for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
              L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
              for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
          done
      
      with de-mangling cleanups yet to come.
      
      NOTE! On almost all architectures, the EPOLL* constants have the same
      values as the POLL* constants do.  But they keyword here is "almost".
      For various bad reasons they aren't the same, and epoll() doesn't
      actually work quite correctly in some cases due to this on Sparc et al.
      
      The next patch from Al will sort out the final differences, and we
      should be all done.
      Scripted-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a9a08845
  22. 02 2月, 2018 1 次提交
  23. 28 11月, 2017 2 次提交
  24. 08 11月, 2017 9 次提交
    • G
      debugfs: Remove redundant license text · 2b2d8788
      Greg Kroah-Hartman 提交于
      Now that the SPDX tag is in all debugfs files, that identifies the
      license in a specific and legally-defined manner.  So the extra GPL text
      wording can be removed as it is no longer needed at all.
      
      This is done on a quest to remove the 700+ different ways that files in
      the kernel describe the GPL license text.  And there's unneeded stuff
      like the address (sometimes incorrect) for the FSF which is never
      needed.
      
      No copyright headers or other non-license-description text was removed.
      
      Cc: Nicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b2d8788
    • G
      debugfs: add SPDX identifiers to all debugfs files · 3bce94fd
      Greg Kroah-Hartman 提交于
      It's good to have SPDX identifiers in all files to make it easier to
      audit the kernel tree for correct licenses.
      
      Update the debugfs files files with the correct SPDX license identifier
      based on the license text in the file itself.  The SPDX identifier is a
      legally binding shorthand, which can be used instead of the full boiler
      plate text.
      
      This work is based on a script and data from Thomas Gleixner, Philippe
      Ombredanne, and Kate Stewart.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: Nicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3bce94fd
    • N
      debugfs: defer debugfs_fsdata allocation to first usage · 7d39bc50
      Nicolai Stange 提交于
      Currently, __debugfs_create_file allocates one struct debugfs_fsdata
      instance for every file created. However, there are potentially many
      debugfs file around, most of which are never touched by userspace.
      
      Thus, defer the allocations to the first usage, i.e. to the first
      debugfs_file_get().
      
      A dentry's ->d_fsdata starts out to point to the "real", user provided
      fops. After a debugfs_fsdata instance has been allocated (and the real
      fops pointer has been moved over into its ->real_fops member),
      ->d_fsdata is changed to point to it from then on. The two cases are
      distinguished by setting BIT(0) for the real fops case.
      
      struct debugfs_fsdata's foremost purpose is to track active users and to
      make debugfs_remove() block until they are done. Since no debugfs_fsdata
      instance means no active users, make debugfs_remove() return immediately
      in this case.
      
      Take care of possible races between debugfs_file_get() and
      debugfs_remove(): either debugfs_remove() must see a debugfs_fsdata
      instance and thus wait for possible active users or debugfs_file_get() must
      see a dead dentry and return immediately.
      
      Make a dentry's ->d_release(), i.e. debugfs_release_dentry(), check whether
      ->d_fsdata is actually a debugfs_fsdata instance before kfree()ing it.
      
      Similarly, make debugfs_real_fops() check whether ->d_fsdata is actually
      a debugfs_fsdata instance before returning it, otherwise emit a warning.
      
      The set of possible error codes returned from debugfs_file_get() has grown
      from -EIO to -EIO and -ENOMEM. Make open_proxy_open() and full_proxy_open()
      pass the -ENOMEM onwards to their callers.
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d39bc50
    • N
      debugfs: call debugfs_real_fops() only after debugfs_file_get() · 154b9d75
      Nicolai Stange 提交于
      The current implementation of debugfs_real_fops() relies on a
      debugfs_fsdata instance to be installed at ->d_fsdata.
      
      With future patches introducing lazy allocation of these, this requirement
      will be guaranteed to be fullfilled only inbetween a
      debugfs_file_get()/debugfs_file_put() pair.
      
      The full proxies' fops implemented by debugfs happen to be the only
      offenders. Fix them up by moving their debugfs_real_fops() calls past those
      to debugfs_file_get().
      
      full_proxy_release() is special as it doesn't invoke debugfs_file_get() at
      all. Leave it alone for now.
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      154b9d75
    • N
      debugfs: purge obsolete SRCU based removal protection · c9afbec2
      Nicolai Stange 提交于
      Purge the SRCU based file removal race protection in favour of the new,
      refcount based debugfs_file_get()/debugfs_file_put() API.
      
      Fixes: 49d200de ("debugfs: prevent access to removed files' private data")
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9afbec2
    • N
      debugfs: convert to debugfs_file_get() and -put() · 69d29f9e
      Nicolai Stange 提交于
      Convert all calls to the now obsolete debugfs_use_file_start() and
      debugfs_use_file_finish() from the debugfs core itself to the new
      debugfs_file_get() and debugfs_file_put() API.
      
      Fixes: 49d200de ("debugfs: prevent access to removed files' private data")
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      69d29f9e
    • N
      debugfs: debugfs_real_fops(): drop __must_hold sparse annotation · 055ab8e3
      Nicolai Stange 提交于
      Currently, debugfs_real_fops() is annotated with a
      __must_hold(&debugfs_srcu) sparse annotation.
      
      With the conversion of the SRCU based protection of users against
      concurrent file removals to a per-file refcount based scheme, this becomes
      wrong.
      
      Drop this annotation.
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      055ab8e3
    • N
      debugfs: implement per-file removal protection · e9117a5a
      Nicolai Stange 提交于
      Since commit 49d200de ("debugfs: prevent access to removed files'
      private data"), accesses to a file's private data are protected from
      concurrent removal by covering all file_operations with a SRCU read section
      and sychronizing with those before returning from debugfs_remove() by means
      of synchronize_srcu().
      
      As pointed out by Johannes Berg, there are debugfs files with forever
      blocking file_operations. Their corresponding SRCU read side sections would
      block any debugfs_remove() forever as well, even unrelated ones. This
      results in a livelock. Because a remover can't cancel any indefinite
      blocking within foreign files, this is a problem.
      
      Resolve this by introducing support for more granular protection on a
      per-file basis.
      
      This is implemented by introducing an  'active_users' refcount_t to the
      per-file struct debugfs_fsdata state. At file creation time, it is set to
      one and a debugfs_remove() will drop that initial reference. The new
      debugfs_file_get() and debugfs_file_put(), intended to be used in place of
      former debugfs_use_file_start() and debugfs_use_file_finish(), increment
      and decrement it respectively. Once the count drops to zero,
      debugfs_file_put() will signal a completion which is possibly being waited
      for from debugfs_remove().
      Thus, as long as there is a debugfs_file_get() not yet matched by a
      corresponding debugfs_file_put() around, debugfs_remove() will block.
      
      Actual users of debugfs_use_file_start() and -finish() will get converted
      to the new debugfs_file_get() and debugfs_file_put() by followup patches.
      
      Fixes: 49d200de ("debugfs: prevent access to removed files' private data")
      Reported-by: NJohannes Berg <johannes@sipsolutions.net>
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9117a5a
    • N
      debugfs: add support for more elaborate ->d_fsdata · 7c8d4698
      Nicolai Stange 提交于
      Currently, the user provided fops, "real_fops", are stored directly into
      ->d_fsdata.
      
      In order to be able to store more per-file state and thus prepare for more
      granular file removal protection, wrap the real_fops into a dynamically
      allocated container struct, debugfs_fsdata.
      
      A struct debugfs_fsdata gets allocated at file creation and freed from the
      newly intoduced ->d_release().
      
      Finally, move the implementation of debugfs_real_fops() out of the public
      debugfs header such that struct debugfs_fsdata's declaration can be kept
      private.
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c8d4698
  25. 16 5月, 2017 1 次提交