selftests: bpf: don't try to read files without read permission
Subsystems (5)
PATCH 1/1 selftests: bpf: don't try to read files without read permission
From: Jiri Pirko <[email protected]>
Recently couple of files that are write only were added to netdevsim debugfs. Don't read these files and avoid error.
--- tools/testing/selftests/bpf/test_offload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/test_offload.py +1 -1
@@ -312,7 +312,7 @@ class DebugfsDir: if f == "ports": continue p = os.path.join(path, f) - if os.path.isfile(p): + if os.path.isfile(p) and os.access(p, os.R_OK): _, out = cmd('cat %s/%s' % (path, f)) dfs[f] = out.strip() elif os.path.isdir(p):
Signature · 1 line
2.21.0
Quoted 7 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Recently couple of files that are write only were added to netdevsim debugfs. Don't read these files and avoid error.
Reported-by kernel test robot <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
Thanks!
Alexei Starovoitov
AppliedQuoted 11 lines · Jakub Kicinski
Quoted 7 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Recently couple of files that are write only were added to netdevsim debugfs. Don't read these files and avoid error.
Reported-by kernel test robot <[email protected]>Signed-off-by Jiri Pirko <[email protected]>Acked-by Jakub Kicinski <[email protected]>
Applied. Thanks
Quoted 16 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Recently couple of files that are write only were added to netdevsim debugfs. Don't read these files and avoid error.
Reported-by kernel test robot <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- tools/testing/selftests/bpf/test_offload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/test_offload.py +0
-0
tools/testing/selftests/bpf/test_offload.py class DebugfsDir: · line 315
Quoted 5 lines
tools/testing/selftests/bpf/test_offload.py +1
-1@@ -312,7 +312,7 @@ class DebugfsDir: if f == "ports": continue p = os.path.join(path, f) - if os.path.isfile(p): + if os.path.isfile(p) and os.access(p, os.R_OK):
Have you tested this? Looks like python always returns True here when run as root, and this script requires root (and checks for it).
Also the fix is needed in net, not sure why you sent it to net-next.
Quoted 3 lines
tools/testing/selftests/bpf/test_offload.py +0
-0_, out = cmd('cat %s/%s' % (path, f)) dfs[f] = out.strip() elif os.path.isdir(p):
Quoted 12 lines · Jakub Kicinski
Quoted 11 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Recently couple of files that are write only were added to netdevsim debugfs. Don't read these files and avoid error.
Reported-by kernel test robot <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- tools/testing/selftests/bpf/test_offload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
tools/testing/selftests/bpf/test_offload.py class DebugfsDir: · line 315
Quoted 10 lines
tools/testing/selftests/bpf/test_offload.py +1
-1@@ -312,7 +312,7 @@ class DebugfsDir: if f == "ports": continue p = os.path.join(path, f) - if os.path.isfile(p): + if os.path.isfile(p) and os.access(p, os.R_OK):Have you tested this? Looks like python always returns True here when run as root, and this script requires root (and checks for it).
Yeah, you definitely haven't tested this. Even if it worked we'd fall into the else condition and say:
Exception: /sys/kernel/debug/netdevsim/netdevsim0//ports/0/dev/take_snapshot is neither file nor directory
Quoted 5 lines
Also the fix is needed in net, not sure why you sent it to net-next.
Quoted 3 lines
tools/testing/selftests/bpf/test_offload.py +0
-0_, out = cmd('cat %s/%s' % (path, f)) dfs[f] = out.strip() elif os.path.isdir(p):
Quoted 27 lines · Fri, Nov 01, 2019 at 12:40:57AM CET, [email protected] wrote:
Quoted 12 lines · Jakub Kicinski
Quoted 11 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Recently couple of files that are write only were added to netdevsim debugfs. Don't read these files and avoid error.
Reported-by kernel test robot <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- tools/testing/selftests/bpf/test_offload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
tools/testing/selftests/bpf/test_offload.py class DebugfsDir: · line 315
Quoted 10 lines
tools/testing/selftests/bpf/test_offload.py +1
-1@@ -312,7 +312,7 @@ class DebugfsDir: if f == "ports": continue p = os.path.join(path, f) - if os.path.isfile(p): + if os.path.isfile(p) and os.access(p, os.R_OK):Have you tested this? Looks like python always returns True here when run as root, and this script requires root (and checks for it).
Quoted 2 lines
Yeah, you definitely haven't tested this. Even if it worked we'd fall into the else condition and say:
Sure I tested. It worked. Odd.
Quoted 9 lines
Exception:
/sys/kernel/debug/netdevsim/netdevsim0//ports/0/dev/take_snapshotis neither file nor directoryQuoted 5 lines
Also the fix is needed in net, not sure why you sent it to net-next.
Quoted 3 lines
tools/testing/selftests/bpf/test_offload.py +0
-0_, out = cmd('cat %s/%s' % (path, f)) dfs[f] = out.strip() elif os.path.isdir(p):