get_abi.pl: Check for missing symbols at the ABI specs
Subsystems (4)
PATCH 1/9 scripts: get_abi.pl: Check for missing symbols at the ABI specs
In reply to Mauro Carvalho ChehabCheck for the symbols that exists under /sys but aren't defined at Documentation/ABI.
--- scripts/get_abi.pl | 88 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 2 deletions(-)
scripts/get_abi.pl +86 -2
@@ -13,7 +13,9 @@ my $help = 0; my $man = 0; my $debug = 0; my $enable_lineno = 0; +my $show_warnings = 1; my $prefix="Documentation/ABI"; +my $sysfs_prefix="/sys"; # # If true, assumes that the description is formatted with ReST
@@ -36,7 +38,7 @@ pod2usage(2) if (scalar @ARGV < 1 || @ARGV > 2); my ($cmd, $arg) = @ARGV; -pod2usage(2) if ($cmd ne "search" && $cmd ne "rest" && $cmd ne "validate"); +pod2usage(2) if ($cmd ne "search" && $cmd ne "rest" && $cmd ne "validate" && $cmd ne "undefined"); pod2usage(2) if ($cmd eq "search" && !$arg); require Data::Dumper if ($debug);
@@ -50,6 +52,8 @@ my %symbols; sub parse_error($$$$) { my ($file, $ln, $msg, $data) = @_; + return if (!$show_warnings); + $data =~ s/\s+$/\n/; print STDERR "Warning: file $file#$ln:\n\t$msg";
@@ -521,11 +525,86 @@ sub search_symbols { } } +# Exclude /sys/kernel/debug and /sys/kernel/tracing from the search path +sub skip_debugfs { + if (($File::Find::dir =~ m,^/sys/kernel,)) { + return grep {!/(debug|tracing)/ } @_; + } + + if (($File::Find::dir =~ m,^/sys/fs,)) { + return grep {!/(pstore|bpf|fuse)/ } @_; + } + + return @_ +} + +my %leaf; + +my $escape_symbols = qr { ([\x01-\x08\x0e-\x1f\x21-\x29\x2b-\x2d\x3a-\x40\x7b-\xff]) }x; +sub parse_existing_sysfs { + my $file = $File::Find::name; + + my $mode = (stat($file))[2]; + return if ($mode & S_IFDIR); + + my $leave = $file; + $leave =~ s,.*/,,; + + if (defined($leaf{$leave})) { + # FIXME: need to check if the path makes sense + my $what = $leaf{$leave}; + + $what =~ s/,/ /g; + + $what =~ s/\<[^\>]+\>/.*/g; + $what =~ s/\{[^\}]+\}/.*/g; + $what =~ s/\[[^\]]+\]/.*/g; + $what =~ s,/\.\.\./,/.*/,g; + $what =~ s,/\*/,/.*/,g; + + $what =~ s/\s+/ /g; + + # Escape all other symbols + $what =~ s/$escape_symbols/\\$1/g; + + foreach my $i (split / /,$what) { + if ($file =~ m#^$i$#) { +# print "$file: $i: OK!\n"; + return; + } + } + + print "$file: $leave is defined at $what\n"; + + return; + } + + print "$file not found.\n"; +} + +sub undefined_symbols { + foreach my $what (sort keys %data) { + my $leave = $what; + $leave =~ s,.*/,,; + + if (defined($leaf{$leave})) { + $leaf{$leave} .= " " . $what; + } else { + $leaf{$leave} = $what; + } + } + + find({wanted =>\&parse_existing_sysfs, preprocess =>\&skip_debugfs, no_chdir => 1}, $sysfs_prefix); +} + # Ensure that the prefix will always end with a slash # While this is not needed for find, it makes the patch nicer # with --enable-lineno $prefix =~ s,/?$,/,; +if ($cmd eq "undefined" || $cmd eq "search") { + $show_warnings = 0; +} # # Parses all ABI files located at $prefix dir #
@@ -536,7 +615,9 @@ print STDERR Data::Dumper->Dump([\%data], [qw(*data)]) if ($debug); # # Handles the command # -if ($cmd eq "search") { +if ($cmd eq "undefined") { + undefined_symbols; +} elsif ($cmd eq "search") { search_symbols; } else { if ($cmd eq "rest") {
@@ -575,6 +656,9 @@ B<rest> - output the ABI in ReST markup language B<validate> - validate the ABI contents +B<undefined> - existing symbols at the system that aren't + defined at Documentation/ABI + =back =head1 OPTIONS
Signature · 1 line
2.31.1
PATCH 5/9 ABI: sysfs-module: better document module name parameter
In reply to Mauro Carvalho ChehabOn almost all ABI documents, variable arguments are declared as <foo_bar>. Change it here too, in order to allow replacing such wildcards by regexes on a scriptable way.
--- Documentation/ABI/stable/sysfs-module | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Documentation/ABI/stable/sysfs-module +7 -3
@@ -2,7 +2,7 @@ What: /sys/module Description: The /sys/module tree consists of the following structure: - /sys/module/MODULENAME + /sys/module/<MODULENAME> The name of the module that is in the kernel. This module name will always show up if the module is loaded as a dynamic module. If it is built directly into the kernel, it
@@ -12,7 +12,7 @@ Description: Note: The conditions of creation in the built-in case are not by design and may be removed in the future. - /sys/module/MODULENAME/parameters + /sys/module/<MODULENAME>/parameters This directory contains individual files that are each individual parameters of the module that are able to be changed at runtime. See the individual module
@@ -25,10 +25,14 @@ Description: individual driver documentation for details as to the stability of the different parameters. - /sys/module/MODULENAME/refcnt + /sys/module/<MODULENAME>/refcnt If the module is able to be unloaded from the kernel, this file will contain the current reference count of the module. Note: If the module is built into the kernel, or if the CONFIG_MODULE_UNLOAD kernel configuration value is not enabled, this file will not be present. + + /sys/module/<MODULENAME>/srcversion + If the module source has MODULE_VERSION, this file will contain + the version of the source code.
Signature · 1 line
2.31.1
cover get_abi.pl: Check for missing symbols at the ABI specs
Hi Greg,
Sometime ago, I discussed with Jonathan Cameron about providing a way check that the ABI documentation is incomplete.
While it would be doable to validate the ABI by searching __ATTR and similar macros around the driver, this would probably be very complex and would take a while to parse.
So, I ended by implementing a new feature at scripts/get_abi.pl which does a check on the sysfs contents of a running system:
it reads everything under /sys and reads the entire ABI from Documentation/ABI. It then warns for symbols that weren't found, optionally showing possible candidates that might be misdefined.
I opted to place it on 3 patches:
The first patch adds the basic logic. It runs really quicky (up to 2 seconds), but it doesn't use sysfs softlinks.
Patch 2 adds support for also parsing softlinks. It slows the logic, with now takes ~40 seconds to run on my desktop (and ~23 seconds on a HiKey970 ARM board). There are space there for performance improvements, by using a more sophisticated algorithm, at the expense of making the code harder to understand. I ended opting to use a simple implementation for now, as ~40 seconds sounds acceptable on my eyes.
Patch 3 adds an optional parameter to allow filtering the results using a regex given by the user.
One of the problems with the current ABI definitions is that several symbols define wildcards, on non-standard ways. The more commonly wildcards used there are:
<foo>
{foo}
[foo]
X
Y
Z
/.../The script converts the above wildcards into (somewhat relaxed) regexes.
There's one place using "(some description)". This one is harder to parse, as parenthesis are used by the parsing regexes. As this happens only on one file, patch 4 addresses such case.
Patch 5 to 9 fix some other ABI troubles I identified.
In long term, perhaps the better would be to just use regex on What:
fields, as this would avoid extra heuristics at get_abi.pl, but this is OOT from this patch, and would mean a large number of changes.
-
As reference, I sent an early implementation of this change as a RFC:
https://lore.kernel.org/lkml/[email protected]/
Mauro Carvalho Chehab (9):
scripts: get_abi.pl: Check for missing symbols at the ABI specs
scripts: get_abi.pl: detect softlinks
scripts: get_abi.pl: add an option to filter undefined results
ABI: sysfs-bus-usb: better document variable argument
ABI: sysfs-module: better document module name parameter
ABI: sysfs-tty: better document module name parameter
ABI: sysfs-kernel-slab: use a wildcard for the cache name
ABI: security: fix location for evm and ima_policy
ABI: sysfs-module: document initstate
Documentation/ABI/stable/sysfs-module | 10 +- Documentation/ABI/testing/evm | 4 +- Documentation/ABI/testing/ima_policy | 2 +- Documentation/ABI/testing/sysfs-bus-usb | 16 +- Documentation/ABI/testing/sysfs-kernel-slab | 94 ++++----- Documentation/ABI/testing/sysfs-module | 7 + Documentation/ABI/testing/sysfs-tty | 32 +-- scripts/get_abi.pl | 218 +++++++++++++++++++- 8 files changed, 303 insertions(+), 80 deletions(-)
Signature · 1 line
2.31.1
PATCH 6/9 ABI: sysfs-tty: better document module name parameter
On almost all ABI documents, variable arguments are declared as <foo_bar>. Change it here too, in order to allow replacing such wildcards by regexes on a scriptable way.
--- Documentation/ABI/testing/sysfs-tty | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-)
Documentation/ABI/testing/sysfs-tty +16 -16
@@ -9,7 +9,7 @@ Description: The file supports poll() to detect virtual console switches. -What: /sys/class/tty/tty0/active +What: /sys/class/tty/tty<x>/active Date: Nov 2010 Contact: Kay Sievers <[email protected]> Description:
@@ -18,7 +18,7 @@ Description: The file supports poll() to detect virtual console switches. -What: /sys/class/tty/ttyS0/uartclk +What: /sys/class/tty/ttyS<x>/uartclk Date: Sep 2012 Contact: Tomas Hlavacek <[email protected]> Description:
@@ -29,7 +29,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/type +What: /sys/class/tty/ttyS<x>/type Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -38,7 +38,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/line +What: /sys/class/tty/ttyS<x>/line Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -47,7 +47,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/port +What: /sys/class/tty/ttyS<x>/port Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -56,7 +56,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/irq +What: /sys/class/tty/ttyS<x>/irq Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -65,7 +65,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/flags +What: /sys/class/tty/ttyS<x>/flags Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -74,7 +74,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/xmit_fifo_size +What: /sys/class/tty/ttyS<x>/xmit_fifo_size Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -83,7 +83,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/close_delay +What: /sys/class/tty/ttyS<x>/close_delay Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -92,7 +92,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/closing_wait +What: /sys/class/tty/ttyS<x>/closing_wait Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -101,7 +101,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/custom_divisor +What: /sys/class/tty/ttyS<x>/custom_divisor Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -110,7 +110,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/io_type +What: /sys/class/tty/ttyS<x>/io_type Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -120,7 +120,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/iomem_base +What: /sys/class/tty/ttyS<x>/iomem_base Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -129,7 +129,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/iomem_reg_shift +What: /sys/class/tty/ttyS<x>/iomem_reg_shift Date: October 2012 Contact: Alan Cox <[email protected]> Description:
@@ -139,7 +139,7 @@ Description: These sysfs values expose the TIOCGSERIAL interface via sysfs rather than via ioctls. -What: /sys/class/tty/ttyS0/rx_trig_bytes +What: /sys/class/tty/ttyS<x>/rx_trig_bytes Date: May 2014 Contact: Yoshihiro YUNOMAE <[email protected]> Description:
@@ -155,7 +155,7 @@ Description: 16550A, which has 1/4/8/14 bytes trigger, the RX trigger is automatically changed to 4 bytes. -What: /sys/class/tty/ttyS0/console +What: /sys/class/tty/ttyS<x>/console Date: February 2020 Contact: Andy Shevchenko <[email protected]> Description:
Signature · 1 line
2.31.1
PATCH 8/9 ABI: security: fix location for evm and ima_policy
In reply to Mauro Carvalho ChehabThe What: definitions there are wrong, pointing to different locations than what's expected.
--- Documentation/ABI/testing/evm | 4 ++-- Documentation/ABI/testing/ima_policy | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Documentation/ABI/testing/evm +2 -2
@@ -1,4 +1,4 @@ -What: security/evm +What: /sys/kernel/security/evm /sys/kernel/security/*/evm Date: March 2011 Contact: Mimi Zohar <[email protected]> Description:
@@ -93,7 +93,7 @@ Description: core/ima-setup) have support for loading keys at boot time. -What: security/integrity/evm/evm_xattrs +What: /sys/kernel/security/*/evm/evm_xattrs Date: April 2018 Contact: Matthew Garrett <[email protected]> Description:
Documentation/ABI/testing/ima_policy +1 -1
@@ -1,4 +1,4 @@ -What: security/ima/policy +What: /sys/kernel/security/*/ima/policy Date: May 2008 Contact: Mimi Zohar <[email protected]> Description:
Signature · 1 line
2.31.1
PATCH 9/9 ABI: sysfs-module: document initstate
In reply to Mauro Carvalho ChehabDespite being an old ABI, present on all modules, its documentation is missing. Add it, based on the original commit.
--- Documentation/ABI/testing/sysfs-module | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/ABI/testing/sysfs-module +7 -0
@@ -41,6 +41,13 @@ KernelVersion: 3.3 Contact: Kay Sievers <[email protected]> Description: Module size in bytes. +What: /sys/module/*/initstate +Date: Nov 2006 +KernelVersion: 2.6.19 +Contact: Kay Sievers <[email protected]> +Description: Show the initialization state(live, coming, going) of + the module. + What: /sys/module/*/taint Date: Jan 2012 KernelVersion: 3.3
Signature · 1 line
2.31.1
PATCH 2/9 scripts: get_abi.pl: detect softlinks
In reply to Mauro Carvalho ChehabThe way sysfs works is that the same leave may be present under /sys/devices, /sys/bus and /sys/class, etc, linked via soft symlinks.
To make it harder to parse, the ABI definition usually refers only to one of those locations.
So, improve the logic in order to retrieve the symlinks.
--- scripts/get_abi.pl | 177 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 143 insertions(+), 34 deletions(-)
scripts/get_abi.pl +143 -34
@@ -8,8 +8,10 @@ use Pod::Usage; use Getopt::Long; use File::Find; use Fcntl ':mode'; +use Cwd 'abs_path'; my $help = 0; +my $hint = 0; my $man = 0; my $debug = 0; my $enable_lineno = 0;
@@ -28,6 +30,7 @@ GetOptions( "rst-source!" => \$description_is_rst, "dir=s" => \$prefix, 'help|?' => \$help, + "show-hints" => \$hint, man => \$man ) or pod2usage(2);
@@ -526,7 +529,7 @@ sub search_symbols { } # Exclude /sys/kernel/debug and /sys/kernel/tracing from the search path -sub skip_debugfs { +sub dont_parse_special_attributes { if (($File::Find::dir =~ m,^/sys/kernel,)) { return grep {!/(debug|tracing)/ } @_; }
@@ -539,62 +542,162 @@ sub skip_debugfs { } my %leaf; +my %aliases; +my @files; my $escape_symbols = qr { ([\x01-\x08\x0e-\x1f\x21-\x29\x2b-\x2d\x3a-\x40\x7b-\xff]) }x; sub parse_existing_sysfs { my $file = $File::Find::name; + my $mode = (lstat($file))[2]; + my $abs_file = abs_path($file); - my $mode = (stat($file))[2]; - return if ($mode & S_IFDIR); + if (S_ISLNK($mode)) { + $aliases{$file} = $abs_file; + return; + } - my $leave = $file; - $leave =~ s,.*/,,; + return if (S_ISDIR($mode)); - if (defined($leaf{$leave})) { - # FIXME: need to check if the path makes sense - my $what = $leaf{$leave}; + # Trivial: file is defined exactly the same way at ABI What: + return if (defined($data{$file})); + return if (defined($data{$abs_file})); + + push @files, $abs_file; +} + +sub check_undefined_symbols { + foreach my $file (sort @files) { + + # sysfs-module is special, as its definitions are inside + # a text. For now, just ignore them. + next if ($file =~ m#^/sys/module/#); + + # Ignore cgroup and firmware + next if ($file =~ m#^/sys/(fs/cgroup|firmware)/#); + + my $defined = 0; + my $exact = 0; + my $whats = ""; + + my $leave = $file; + $leave =~ s,.*/,,; + + my $path = $file; + $path =~ s,(.*/).*,$1,; + + if (defined($leaf{$leave})) { + my $what = $leaf{$leave}; + $whats .= " $what" if (!($whats =~ m/$what/)); + + foreach my $w (split / /, $what) { + if ($file =~ m#^$w$#) { + $exact = 1; + last; + } + } + # Check for aliases + # + # TODO: this algorithm is O(w * n²). It can be + # improved in the future in order to handle it + # faster, by changing parse_existing_sysfs to + # store the sysfs inside a tree, at the expense + # on making the code less readable and/or using some + # additional perl library. + foreach my $a (keys %aliases) { + my $new = $aliases{$a}; + my $len = length($new); + + if (substr($file, 0, $len) eq $new) { + my $newf = $a . substr($file, $len); + + foreach my $w (split / /, $what) { + if ($newf =~ m#^$w$#) { + $exact = 1; + last; + } + } + } + } + + $defined++; + } + next if ($exact); + + # Ignore some sysfs nodes + next if ($file =~ m#/(sections|notes)/#); + + # Would need to check at + # Documentation/admin-guide/kernel-parameters.txt, but this + # is not easily parseable. + next if ($file =~ m#/parameters/#); + + if ($hint && $defined) { + print "$leave at $path might be one of:$whats\n"; + next; + } + print "$file not found.\n"; + } +} + +sub undefined_symbols { + find({ + wanted =>\&parse_existing_sysfs, + preprocess =>\&dont_parse_special_attributes, + no_chdir => 1 + }, $sysfs_prefix); + + foreach my $what (sort keys %data) { + next if (!($what =~ m/^$sysfs_prefix/)); + + # Convert what into regular expressions $what =~ s/,/ /g; + $what =~ s,/\.\.\./,/.*/,g; + + # Temporarely change [0-9] type of patterns + $what =~ s/\[(\d+)\-(\d+)\]/\xf4$1-$2\xf5/g; + + # Handle multiple option patterns + $what =~ s/[\{\<\[]([\w_]+)(?:[,|\s]+([\w_]+)){1,}[\}\>\]]/($1|$2)/g; + + # Handle wildcards $what =~ s/\<[^\>]+\>/.*/g; $what =~ s/\{[^\}]+\}/.*/g; $what =~ s/\[[^\]]+\]/.*/g; - $what =~ s,/\.\.\./,/.*/,g; + + $what =~ s/[XYZ]/.*/g; $what =~ s,/\*/,/.*/,g; + # Recover [0-9] type of patterns + $what =~ s/\xf4/[/g; + $what =~ s/\xf5/]/g; + + # Remove duplicated spaces $what =~ s/\s+/ /g; + my $leave = $what; + $leave =~ s,.*/,,; + + next if ($leave =~ m/^\.\*/ || $leave eq ""); + # Escape all other symbols $what =~ s/$escape_symbols/\\$1/g; + $what =~ s/\\([\[\]\(\)\|])/$1/g; + $what =~ s/(\d+)\\(-\d+)/$1$2/g; - foreach my $i (split / /,$what) { - if ($file =~ m#^$i$#) { -# print "$file: $i: OK!\n"; - return; + $leave =~ s/[\(\)]//g; + + foreach my $l (split /\|/, $leave) { + if (defined($leaf{$l})) { + $leaf{$l} .= " " . $what; + } else { + $leaf{$l} = $what; } } - - print "$file: $leave is defined at $what\n"; - - return; - } - - print "$file not found.\n"; -} - -sub undefined_symbols { - foreach my $what (sort keys %data) { - my $leave = $what; - $leave =~ s,.*/,,; - - if (defined($leaf{$leave})) { - $leaf{$leave} .= " " . $what; - } else { - $leaf{$leave} = $what; - } } - find({wanted =>\&parse_existing_sysfs, preprocess =>\&skip_debugfs, no_chdir => 1}, $sysfs_prefix); + check_undefined_symbols; } # Ensure that the prefix will always end with a slash
@@ -644,7 +747,8 @@ abi_book.pl - parse the Linux ABI files and produce a ReST book. =head1 SYNOPSIS B<abi_book.pl> [--debug] [--enable-lineno] [--man] [--help] - [--(no-)rst-source] [--dir=<dir>] <COMAND> [<ARGUMENT>] + [--(no-)rst-source] [--dir=<dir>] [--show-hints] + <COMAND> [<ARGUMENT>] Where <COMMAND> can be:
@@ -686,6 +790,11 @@ Enable output of #define LINENO lines. Put the script in verbose mode, useful for debugging. Can be called multiple times, to increase verbosity. +=item B<--show-hints> + +Show hints about possible definitions for the missing ABI symbols. +Used only when B<undefined>. + =item B<--help> Prints a brief help message and exits.
Signature · 1 line
2.31.1
PATCH 4/9 ABI: sysfs-bus-usb: better document variable argument
In reply to Mauro Carvalho ChehabOn almost all ABI documents, variable arguments are declared as <foo_bar>. Change it here too, in order to allow replacing such wildcards by regexes on a scriptable way.
--- Documentation/ABI/testing/sysfs-bus-usb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Documentation/ABI/testing/sysfs-bus-usb +8 -8
@@ -166,14 +166,14 @@ Description: The file will be present for all speeds of USB devices, and will always read "no" for USB 1.1 and USB 2.0 devices. -What: /sys/bus/usb/devices/.../(hub interface)/portX +What: /sys/bus/usb/devices/.../<hub_interface>/port<X> Date: August 2012 Contact: Lan Tianyu <[email protected]> Description: - The /sys/bus/usb/devices/.../(hub interface)/portX + The /sys/bus/usb/devices/.../<hub_interface>/port<X> is usb port device's sysfs directory. -What: /sys/bus/usb/devices/.../(hub interface)/portX/connect_type +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/connect_type Date: January 2013 Contact: Lan Tianyu <[email protected]> Description:
@@ -182,7 +182,7 @@ Description: The file will read "hotplug", "hardwired" and "not used" if the information is available, and "unknown" otherwise. -What: /sys/bus/usb/devices/.../(hub interface)/portX/location +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/location Date: October 2018 Contact: Bjørn Mork <[email protected]> Description:
@@ -192,7 +192,7 @@ Description: raw location value as a hex integer. -What: /sys/bus/usb/devices/.../(hub interface)/portX/quirks +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/quirks Date: May 2018 Contact: Nicolas Boichat <[email protected]> Description:
@@ -216,7 +216,7 @@ Description: used to help make enumeration work better on some high speed devices. -What: /sys/bus/usb/devices/.../(hub interface)/portX/over_current_count +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/over_current_count Date: February 2018 Contact: Richard Leitner <[email protected]> Description:
@@ -230,10 +230,10 @@ Description: Any time this value changes the corresponding hub device will send a udev event with the following attributes:: - OVER_CURRENT_PORT=/sys/bus/usb/devices/.../(hub interface)/portX + OVER_CURRENT_PORT=/sys/bus/usb/devices/.../<hub_interface>/port<X> OVER_CURRENT_COUNT=[current value of this sysfs attribute] -What: /sys/bus/usb/devices/.../(hub interface)/portX/usb3_lpm_permit +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/usb3_lpm_permit Date: November 2015 Contact: Lu Baolu <[email protected]> Description:
Signature · 1 line
2.31.1
PATCH 7/9 ABI: sysfs-kernel-slab: use a wildcard for the cache name
In reply to Mauro Carvalho Chehabthe "cache" part of the description is actually a wildcard, as, in practice, this will use per-subsystem names:
/sys/kernel/slab/Acpi-Namespace/align
/sys/kernel/slab/Acpi-Operand/align
/sys/kernel/slab/Acpi-Parse/align
...
/sys/kernel/slab/zswap_entry/align
--- Documentation/ABI/testing/sysfs-kernel-slab | 94 ++++++++++----------- 1 file changed, 47 insertions(+), 47 deletions(-)
Documentation/ABI/testing/sysfs-kernel-slab +47 -47
@@ -10,7 +10,7 @@ Description: any cache it aliases, if any). Users: kernel memory tuning tools -What: /sys/kernel/slab/cache/aliases +What: /sys/kernel/slab/<cache>/aliases Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -19,7 +19,7 @@ Description: The aliases file is read-only and specifies how many caches have merged into this cache. -What: /sys/kernel/slab/cache/align +What: /sys/kernel/slab/<cache>/align Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -28,7 +28,7 @@ Description: The align file is read-only and specifies the cache's object alignment in bytes. -What: /sys/kernel/slab/cache/alloc_calls +What: /sys/kernel/slab/<cache>/alloc_calls Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -39,7 +39,7 @@ Description: The alloc_calls file only contains information if debugging is enabled for that cache (see Documentation/vm/slub.rst). -What: /sys/kernel/slab/cache/alloc_fastpath +What: /sys/kernel/slab/<cache>/alloc_fastpath Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -50,7 +50,7 @@ Description: current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/alloc_from_partial +What: /sys/kernel/slab/<cache>/alloc_from_partial Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -62,7 +62,7 @@ Description: count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/alloc_refill +What: /sys/kernel/slab/<cache>/alloc_refill Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -73,7 +73,7 @@ Description: remote cpu frees. It can be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/alloc_slab +What: /sys/kernel/slab/<cache>/alloc_slab Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -84,7 +84,7 @@ Description: clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/alloc_slowpath +What: /sys/kernel/slab/<cache>/alloc_slowpath Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -96,7 +96,7 @@ Description: clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/cache_dma +What: /sys/kernel/slab/<cache>/cache_dma Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -106,7 +106,7 @@ Description: are from ZONE_DMA. Available when CONFIG_ZONE_DMA is enabled. -What: /sys/kernel/slab/cache/cpu_slabs +What: /sys/kernel/slab/<cache>/cpu_slabs Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -115,7 +115,7 @@ Description: The cpu_slabs file is read-only and displays how many cpu slabs are active and their NUMA locality. -What: /sys/kernel/slab/cache/cpuslab_flush +What: /sys/kernel/slab/<cache>/cpuslab_flush Date: April 2009 KernelVersion: 2.6.31 Contact: Pekka Enberg <[email protected]>,
@@ -128,7 +128,7 @@ Description: current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/ctor +What: /sys/kernel/slab/<cache>/ctor Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -138,7 +138,7 @@ Description: constructor function, which is invoked for each object when a new slab is allocated. -What: /sys/kernel/slab/cache/deactivate_empty +What: /sys/kernel/slab/<cache>/deactivate_empty Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -148,7 +148,7 @@ Description: was deactivated. It can be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/deactivate_full +What: /sys/kernel/slab/<cache>/deactivate_full Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -158,7 +158,7 @@ Description: was deactivated. It can be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/deactivate_remote_frees +What: /sys/kernel/slab/<cache>/deactivate_remote_frees Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -169,7 +169,7 @@ Description: remotely. It can be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/deactivate_to_head +What: /sys/kernel/slab/<cache>/deactivate_to_head Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -180,7 +180,7 @@ Description: list. It can be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/deactivate_to_tail +What: /sys/kernel/slab/<cache>/deactivate_to_tail Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -191,7 +191,7 @@ Description: list. It can be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/destroy_by_rcu +What: /sys/kernel/slab/<cache>/destroy_by_rcu Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -200,7 +200,7 @@ Description: The destroy_by_rcu file is read-only and specifies whether slabs (not objects) are freed by rcu. -What: /sys/kernel/slab/cache/free_add_partial +What: /sys/kernel/slab/<cache>/free_add_partial Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -211,7 +211,7 @@ Description: partial list. It can be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/free_calls +What: /sys/kernel/slab/<cache>/free_calls Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -221,7 +221,7 @@ Description: object frees if slab debugging is enabled (see Documentation/vm/slub.rst). -What: /sys/kernel/slab/cache/free_fastpath +What: /sys/kernel/slab/<cache>/free_fastpath Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -232,7 +232,7 @@ Description: It can be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/free_frozen +What: /sys/kernel/slab/<cache>/free_frozen Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -243,7 +243,7 @@ Description: clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/free_remove_partial +What: /sys/kernel/slab/<cache>/free_remove_partial Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -255,7 +255,7 @@ Description: count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/free_slab +What: /sys/kernel/slab/<cache>/free_slab Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -266,7 +266,7 @@ Description: the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/free_slowpath +What: /sys/kernel/slab/<cache>/free_slowpath Date: February 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -277,7 +277,7 @@ Description: be written to clear the current count. Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/hwcache_align +What: /sys/kernel/slab/<cache>/hwcache_align Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -286,7 +286,7 @@ Description: The hwcache_align file is read-only and specifies whether objects are aligned on cachelines. -What: /sys/kernel/slab/cache/min_partial +What: /sys/kernel/slab/<cache>/min_partial Date: February 2009 KernelVersion: 2.6.30 Contact: Pekka Enberg <[email protected]>,
@@ -297,7 +297,7 @@ Description: allocating new slabs. Such slabs may be reclaimed by utilizing the shrink file. -What: /sys/kernel/slab/cache/object_size +What: /sys/kernel/slab/<cache>/object_size Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -306,7 +306,7 @@ Description: The object_size file is read-only and specifies the cache's object size. -What: /sys/kernel/slab/cache/objects +What: /sys/kernel/slab/<cache>/objects Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -315,7 +315,7 @@ Description: The objects file is read-only and displays how many objects are active and from which nodes they are from. -What: /sys/kernel/slab/cache/objects_partial +What: /sys/kernel/slab/<cache>/objects_partial Date: April 2008 KernelVersion: 2.6.26 Contact: Pekka Enberg <[email protected]>,
@@ -325,7 +325,7 @@ Description: objects are on partial slabs and from which nodes they are from. -What: /sys/kernel/slab/cache/objs_per_slab +What: /sys/kernel/slab/<cache>/objs_per_slab Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -333,9 +333,9 @@ Contact: Pekka Enberg <[email protected]>, Description: The file objs_per_slab is read-only and specifies how many objects may be allocated from a single slab of the order - specified in /sys/kernel/slab/cache/order. + specified in /sys/kernel/slab/<cache>/order. -What: /sys/kernel/slab/cache/order +What: /sys/kernel/slab/<cache>/order Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -352,7 +352,7 @@ Description: order is used and this sysfs entry can not be used to change the order at run time. -What: /sys/kernel/slab/cache/order_fallback +What: /sys/kernel/slab/<cache>/order_fallback Date: April 2008 KernelVersion: 2.6.26 Contact: Pekka Enberg <[email protected]>,
@@ -365,7 +365,7 @@ Description: Available when CONFIG_SLUB_STATS is enabled. -What: /sys/kernel/slab/cache/partial +What: /sys/kernel/slab/<cache>/partial Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -374,7 +374,7 @@ Description: The partial file is read-only and displays how long many partial slabs there are and how long each node's list is. -What: /sys/kernel/slab/cache/poison +What: /sys/kernel/slab/<cache>/poison Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -383,7 +383,7 @@ Description: The poison file specifies whether objects should be poisoned when a new slab is allocated. -What: /sys/kernel/slab/cache/reclaim_account +What: /sys/kernel/slab/<cache>/reclaim_account Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -392,7 +392,7 @@ Description: The reclaim_account file specifies whether the cache's objects are reclaimable (and grouped by their mobility). -What: /sys/kernel/slab/cache/red_zone +What: /sys/kernel/slab/<cache>/red_zone Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -401,7 +401,7 @@ Description: The red_zone file specifies whether the cache's objects are red zoned. -What: /sys/kernel/slab/cache/remote_node_defrag_ratio +What: /sys/kernel/slab/<cache>/remote_node_defrag_ratio Date: January 2008 KernelVersion: 2.6.25 Contact: Pekka Enberg <[email protected]>,
@@ -415,7 +415,7 @@ Description: Available when CONFIG_NUMA is enabled. -What: /sys/kernel/slab/cache/sanity_checks +What: /sys/kernel/slab/<cache>/sanity_checks Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -426,7 +426,7 @@ Description: checks. Caches that enable sanity_checks cannot be merged with caches that do not. -What: /sys/kernel/slab/cache/shrink +What: /sys/kernel/slab/<cache>/shrink Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -442,7 +442,7 @@ Description: adversely impact other running applications. So it should be used with care. -What: /sys/kernel/slab/cache/slab_size +What: /sys/kernel/slab/<cache>/slab_size Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -451,7 +451,7 @@ Description: The slab_size file is read-only and specifies the object size with metadata (debugging information and alignment) in bytes. -What: /sys/kernel/slab/cache/slabs +What: /sys/kernel/slab/<cache>/slabs Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -461,7 +461,7 @@ Description: there are (both cpu and partial) and from which nodes they are from. -What: /sys/kernel/slab/cache/store_user +What: /sys/kernel/slab/<cache>/store_user Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -470,7 +470,7 @@ Description: The store_user file specifies whether the location of allocation or free should be tracked for a cache. -What: /sys/kernel/slab/cache/total_objects +What: /sys/kernel/slab/<cache>/total_objects Date: April 2008 KernelVersion: 2.6.26 Contact: Pekka Enberg <[email protected]>,
@@ -479,7 +479,7 @@ Description: The total_objects file is read-only and displays how many total objects a cache has and from which nodes they are from. -What: /sys/kernel/slab/cache/trace +What: /sys/kernel/slab/<cache>/trace Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
@@ -488,7 +488,7 @@ Description: The trace file specifies whether object allocations and frees should be traced. -What: /sys/kernel/slab/cache/validate +What: /sys/kernel/slab/<cache>/validate Date: May 2007 KernelVersion: 2.6.22 Contact: Pekka Enberg <[email protected]>,
Signature · 1 line
2.31.1
PATCH 3/9 scripts: get_abi.pl: add an option to filter undefined results
In reply to Mauro Carvalho ChehabThe output of this script can be too big. Add an option to filter out results, in order to help finding issues at the ABI files.
--- scripts/get_abi.pl | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
scripts/get_abi.pl +21 -2
@@ -18,6 +18,7 @@ my $enable_lineno = 0; my $show_warnings = 1; my $prefix="Documentation/ABI"; my $sysfs_prefix="/sys"; +my $search_string; # # If true, assumes that the description is formatted with ReST
@@ -31,6 +32,7 @@ GetOptions( "dir=s" => \$prefix, 'help|?' => \$help, "show-hints" => \$hint, + "search-string=s" => \$search_string, man => \$man ) or pod2usage(2);
@@ -578,6 +580,7 @@ sub check_undefined_symbols { my $defined = 0; my $exact = 0; my $whats = ""; + my $found_string; my $leave = $file; $leave =~ s,.*/,,;
@@ -585,6 +588,11 @@ sub check_undefined_symbols { my $path = $file; $path =~ s,(.*/).*,$1,; + if ($search_string) { + $found_string = 1 if ($file =~ m#$search_string#); + } + + print "--> $file\n" if ($found_string && $hint); if (defined($leaf{$leave})) { my $what = $leaf{$leave}; $whats .= " $what" if (!($whats =~ m/$what/));
@@ -610,6 +618,7 @@ sub check_undefined_symbols { if (substr($file, 0, $len) eq $new) { my $newf = $a . substr($file, $len); + print " $newf\n" if ($found_string && $hint); foreach my $w (split / /, $what) { if ($newf =~ m#^$w$#) { $exact = 1;
@@ -632,10 +641,10 @@ sub check_undefined_symbols { next if ($file =~ m#/parameters/#); if ($hint && $defined) { - print "$leave at $path might be one of:$whats\n"; + print "$leave at $path might be one of:$whats\n" if (!$search_string || $found_string); next; } - print "$file not found.\n"; + print "$file not found.\n" if (!$search_string || $found_string); } }
@@ -686,6 +695,10 @@ sub undefined_symbols { $what =~ s/\\([\[\]\(\)\|])/$1/g; $what =~ s/(\d+)\\(-\d+)/$1$2/g; + if ($search_string) { + print "What: $what\n" if ($what =~ m#$search_string#); + } + $leave =~ s/[\(\)]//g; foreach my $l (split /\|/, $leave) {
@@ -748,6 +761,7 @@ abi_book.pl - parse the Linux ABI files and produce a ReST book. B<abi_book.pl> [--debug] [--enable-lineno] [--man] [--help] [--(no-)rst-source] [--dir=<dir>] [--show-hints] + [--search-string <regex>] <COMAND> [<ARGUMENT>] Where <COMMAND> can be:
@@ -795,6 +809,11 @@ times, to increase verbosity. Show hints about possible definitions for the missing ABI symbols. Used only when B<undefined>. +=item B<--search-string> [regex string] + +Show only occurences that match a search string. +Used only when B<undefined>. + =item B<--help> Prints a brief help message and exits.
Signature · 1 line
2.31.1
Re: [PATCH 8/9] ABI: security: fix location for evm and ima_policy
In reply to Mauro Carvalho ChehabHi Mauro,
Quoted 4 lines · Mauro Carvalho Chehab
The What: definitions there are wrong, pointing to different locations than what's expected.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
What is the purpose for the asterisks in the file path?
thanks,
Mimi
Quoted 34 lines
--- Documentation/ABI/testing/evm | 4 ++-- Documentation/ABI/testing/ima_policy | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)Documentation/ABI/testing/evm +2
-2@@ -1,4 +1,4 @@ -What: security/evm +What: /sys/kernel/security/evm /sys/kernel/security/*/evm Date: March 2011 Contact: Mimi Zohar <[email protected]> Description:@@ -93,7 +93,7 @@ Description: core/ima-setup) have support for loading keys at boot time. -What: security/integrity/evm/evm_xattrs +What: /sys/kernel/security/*/evm/evm_xattrs Date: April 2018 Contact: Matthew Garrett <[email protected]> Description:Documentation/ABI/testing/ima_policy +1
-1@@ -1,4 +1,4 @@ -What: security/ima/policy +What: /sys/kernel/security/*/ima/policy Date: May 2008 Contact: Mimi Zohar <[email protected]> Description:
Quoted 50 lines · Mauro Carvalho Chehab
Hi Greg,
Sometime ago, I discussed with Jonathan Cameron about providing a way check that the ABI documentation is incomplete.
While it would be doable to validate the ABI by searching
__ATTRand similar macros around the driver, this would probably be very complex and would take a while to parse.So, I ended by implementing a new feature at
scripts/get_abi.plwhich does a check on the sysfs contents of a running system:
it reads everything under /sys and reads the entire ABI fromDocumentation/ABI. It then warns for symbols that weren't found, optionally showing possible candidates that might be misdefined.I opted to place it on 3 patches:
The first patch adds the basic logic. It runs really quicky (up to 2 seconds), but it doesn't use sysfs softlinks.
Patch 2 adds support for also parsing softlinks. It slows the logic, with now takes ~40 seconds to run on my desktop (and ~23 seconds on a HiKey970 ARM board). There are space there for performance improvements, by using a more sophisticated algorithm, at the expense of making the code harder to understand. I ended opting to use a simple implementation for now, as ~40 seconds sounds acceptable on my eyes.
Patch 3 adds an optional parameter to allow filtering the results using a regex given by the user.
One of the problems with the current ABI definitions is that several symbols define wildcards, on non-standard ways. The more commonly wildcards used there are:
<foo> {foo} [foo] X Y Z /.../The script converts the above wildcards into (somewhat relaxed) regexes.
There's one place using "(some description)". This one is harder to parse, as parenthesis are used by the parsing regexes. As this happens only on one file, patch 4 addresses such case.
Quoted 5 lines
Patch 5 to 9 fix some other ABI troubles I identified.
In long term, perhaps the better would be to just use regex on What:
fields, as this would avoid extra heuristics at get_abi.pl, but this is OOT from this patch, and would mean a large number of changes.
This is cool stuff, thanks for doing this!
I'll look at it more once 5.15-rc1 is out, thanks.
greg k-h
Re: [PATCH 8/9] ABI: security: fix location for evm and ima_policy
In reply to Mimi ZoharEm Thu, 09 Sep 2021 09:48:11 -0400
Mimi Zohar <[email protected]> escreveu:
Quoted 9 lines
Hi Mauro,
Quoted 4 lines · Mauro Carvalho Chehab
The What: definitions there are wrong, pointing to different locations than what's expected.
Signed-off-by Mauro Carvalho Chehab <[email protected]>What is the purpose for the asterisks in the file path?
That's a standard filesystem wildcard. On ABI documents, there are some other ways to specify it. The most used ones are:
/sys/kernel/security/*/evm /sys/kernel/security/.../evm /sys/kernel/security/<something>/evm
(currently, there's no preferences between them)
If you check patches 1-3, the goal here is to have something that will be replaced by this regex by scripts/get_abi.pl, e.g. it will turn into:
/sys/kernel/security/.*/evm
So, this what:
What: /sys/kernel/security/evm /sys/kernel/security/*/evm
Matches all three occurrences of evm on my system:
/sys/kernel/security/evm
/sys/kernel/security/integrity/evm
/sys/kernel/security/integrity/evm/evm
Regards,
Mauro
Quoted 41 lines
thanks,
Mimi
Quoted 34 lines
--- Documentation/ABI/testing/evm | 4 ++-- Documentation/ABI/testing/ima_policy | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)Documentation/ABI/testing/evm +2
-2@@ -1,4 +1,4 @@ -What: security/evm +What: /sys/kernel/security/evm /sys/kernel/security/*/evm Date: March 2011 Contact: Mimi Zohar <[email protected]> Description:@@ -93,7 +93,7 @@ Description: core/ima-setup) have support for loading keys at boot time. -What: security/integrity/evm/evm_xattrs +What: /sys/kernel/security/*/evm/evm_xattrs Date: April 2018 Contact: Matthew Garrett <[email protected]> Description:Documentation/ABI/testing/ima_policy +1
-1@@ -1,4 +1,4 @@ -What: security/ima/policy +What: /sys/kernel/security/*/ima/policy Date: May 2008 Contact: Mimi Zohar <[email protected]> Description:
Re: [PATCH 4/9] ABI: sysfs-bus-usb: better document variable argument
In reply to Mauro Carvalho ChehabQuoted 5 lines · Mauro Carvalho Chehab
On almost all ABI documents, variable arguments are declared as <
foo_bar>. Change it here too, in order to allow replacing such wildcards by regexes on a scriptable way.Signed-off-by Mauro Carvalho Chehab <[email protected]>
Quoted 68 lines
--- Documentation/ABI/testing/sysfs-bus-usb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)Documentation/ABI/testing/sysfs-bus-usb +8
-8@@ -166,14 +166,14 @@ Description: The file will be present for all speeds of USB devices, and will always read "no" for USB 1.1 and USB 2.0 devices. -What: /sys/bus/usb/devices/.../(hub interface)/portX +What: /sys/bus/usb/devices/.../<hub_interface>/port<X> Date: August 2012 Contact: Lan Tianyu <[email protected]> Description: - The /sys/bus/usb/devices/.../(hub interface)/portX + The /sys/bus/usb/devices/.../<hub_interface>/port<X> is usb port device's sysfs directory. -What: /sys/bus/usb/devices/.../(hub interface)/portX/connect_type +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/connect_type Date: January 2013 Contact: Lan Tianyu <[email protected]> Description:@@ -182,7 +182,7 @@ Description: The file will read "hotplug", "hardwired" and "not used" if the information is available, and "unknown" otherwise. -What: /sys/bus/usb/devices/.../(hub interface)/portX/location +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/location Date: October 2018 Contact: Bjørn Mork <[email protected]> Description:@@ -192,7 +192,7 @@ Description: raw location value as a hex integer. -What: /sys/bus/usb/devices/.../(hub interface)/portX/quirks +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/quirks Date: May 2018 Contact: Nicolas Boichat <[email protected]> Description:@@ -216,7 +216,7 @@ Description: used to help make enumeration work better on some high speed devices. -What: /sys/bus/usb/devices/.../(hub interface)/portX/over_current_count +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/over_current_count Date: February 2018 Contact: Richard Leitner <[email protected]> Description:@@ -230,10 +230,10 @@ Description: Any time this value changes the corresponding hub device will send a udev event with the following attributes:: - OVER_CURRENT_PORT=/sys/bus/usb/devices/.../(hub interface)/portX + OVER_CURRENT_PORT=/sys/bus/usb/devices/.../<hub_interface>/port<X> OVER_CURRENT_COUNT=[current value of this sysfs attribute] -What: /sys/bus/usb/devices/.../(hub interface)/portX/usb3_lpm_permit +What: /sys/bus/usb/devices/.../<hub_interface>/port<X>/usb3_lpm_permit Date: November 2015 Contact: Lu Baolu <[email protected]> Description:Signature · 1 line
2.31.1
Signature · 1 line
heikki
Em Thu, 9 Sep 2021 15:51:00 +0200
Greg KH <[email protected]> escreveu:
Quoted 53 lines · Mauro Carvalho Chehab
Quoted 52 lines
Hi Greg,
Sometime ago, I discussed with Jonathan Cameron about providing a way check that the ABI documentation is incomplete.
While it would be doable to validate the ABI by searching
__ATTRand similar macros around the driver, this would probably be very complex and would take a while to parse.So, I ended by implementing a new feature at
scripts/get_abi.plwhich does a check on the sysfs contents of a running system:
it reads everything under /sys and reads the entire ABI fromDocumentation/ABI. It then warns for symbols that weren't found, optionally showing possible candidates that might be misdefined.I opted to place it on 3 patches:
The first patch adds the basic logic. It runs really quicky (up to 2 seconds), but it doesn't use sysfs softlinks.
Patch 2 adds support for also parsing softlinks. It slows the logic, with now takes ~40 seconds to run on my desktop (and ~23 seconds on a HiKey970 ARM board). There are space there for performance improvements, by using a more sophisticated algorithm, at the expense of making the code harder to understand. I ended opting to use a simple implementation for now, as ~40 seconds sounds acceptable on my eyes.
Patch 3 adds an optional parameter to allow filtering the results using a regex given by the user.
One of the problems with the current ABI definitions is that several symbols define wildcards, on non-standard ways. The more commonly wildcards used there are:
<foo> {foo} [foo] X Y Z /.../The script converts the above wildcards into (somewhat relaxed) regexes.
There's one place using "(some description)". This one is harder to parse, as parenthesis are used by the parsing regexes. As this happens only on one file, patch 4 addresses such case.
Patch 5 to 9 fix some other ABI troubles I identified.
Quoted 7 lines
Quoted 3 lines
In long term, perhaps the better would be to just use regex on What:
fields, as this would avoid extra heuristics at get_abi.pl, but this is OOT from this patch, and would mean a large number of changes.This is cool stuff, thanks for doing this!
I'll look at it more once 5.15-rc1 is out, thanks.
FYI, there's a new version at:
https://git.kernel.org/pub/scm/linux/kernel/git/mchehab/devel.git/log/?h=get_undefined
In order for get_abi.pl to convert What: into regex, changes are needed on existing ABI files. One alternative would be to convert everything into regex, but that would probably mean that most ABI files would require work.
In order to avoid a huge number of patches/changes, I opted to touch only the ones that aren't following the de-facto wildcard standards already found on most of the ABI files. So, I added support at get_abi.pl to consider those patterns as wildcards:
/.../ * <foo> X Y Z [0-9] (and variants)
The files that use something else meaning a wildcard need changes, in order to avoid ambiguity when the script decides if a character is either a wildcard or not.
One of the issues there is with "N". several files use it as a wildcard, but USB sysfs parameters have several ABI nodes with an uppercase "N" letter (like bNumInterfaces and such). So, this one had to be converted too (and represents the vast majority of patches).
Anyway, as the number of such patches is high, I'll submit the work on three separate series:
- What: changes needed for regex conversion;
- get_abi.pl updates;
- Some additions for missing symbols found on my desktop.
Thanks,
Mauro