debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage
authorNicolai Stange <nicstange@gmail.com>
Tue, 22 Mar 2016 13:11:16 +0000 (14:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Apr 2016 21:14:21 +0000 (14:14 -0700)
commit5103068eaca290f890a30aae70085fac44cecaf6
tree6b80fbb88b8001ae258903d463266ca4099bc489
parentc64688081490321f2d23a292ef24e60bb321f3f1
debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage

In order to protect against file removal races, debugfs files created via
debugfs_create_file() now get wrapped by a struct file_operations at their
opening.

If the original struct file_operations are known to be safe against removal
races by themselves already, the proxy creation may be bypassed by creating
the files through debugfs_create_file_unsafe().

In order to help debugfs users who use the common
  DEFINE_SIMPLE_ATTRIBUTE() + debugfs_create_file()
idiom to transition to removal safe struct file_operations, the helper
macro DEFINE_DEBUGFS_ATTRIBUTE() has been introduced.

Thus, the preferred strategy is to use
  DEFINE_DEBUGFS_ATTRIBUTE() + debugfs_create_file_unsafe()
now.

Introduce a Coccinelle script that searches for
DEFINE_SIMPLE_ATTRIBUTE()-defined struct file_operations handed into
debugfs_create_file(). Suggest to turn these usages into the
  DEFINE_DEBUGFS_ATTRIBUTE() + debugfs_create_file_unsafe()
pattern.

Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Acked-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci [new file with mode: 0644]