netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net-next] selftests: bpf: don't try to read files without read permission
@ 2019-10-15 10:00 Jiri Pirko
  2019-10-15 15:35 ` Jakub Kicinski
  2019-10-31 23:35 ` Jakub Kicinski
  0 siblings, 2 replies; 6+ messages in thread
From: Jiri Pirko @ 2019-10-15 10:00 UTC (permalink / raw)
  To: netdev; +Cc: davem, jakub.kicinski, shuah, ast, daniel, rong.a.chen, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

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 <rong.a.chen@intel.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 tools/testing/selftests/bpf/test_offload.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
index 15a666329a34..c44c650bde3a 100755
--- a/tools/testing/selftests/bpf/test_offload.py
+++ b/tools/testing/selftests/bpf/test_offload.py
@@ -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):
-- 
2.21.0


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

* Re: [patch net-next] selftests: bpf: don't try to read files without read permission
  2019-10-15 10:00 [patch net-next] selftests: bpf: don't try to read files without read permission Jiri Pirko
@ 2019-10-15 15:35 ` Jakub Kicinski
  2019-10-15 23:28   ` Alexei Starovoitov
  2019-10-31 23:35 ` Jakub Kicinski
  1 sibling, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2019-10-15 15:35 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, shuah, ast, daniel, rong.a.chen, mlxsw

On Tue, 15 Oct 2019 12:00:56 +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> 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 <rong.a.chen@intel.com>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Thanks!

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

* Re: [patch net-next] selftests: bpf: don't try to read files without read permission
  2019-10-15 15:35 ` Jakub Kicinski
@ 2019-10-15 23:28   ` Alexei Starovoitov
  0 siblings, 0 replies; 6+ messages in thread
From: Alexei Starovoitov @ 2019-10-15 23:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jiri Pirko, Network Development, David S. Miller, Shuah Khan,
	Alexei Starovoitov, Daniel Borkmann, kernel test robot, mlxsw

On Tue, Oct 15, 2019 at 8:35 AM Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:
>
> On Tue, 15 Oct 2019 12:00:56 +0200, Jiri Pirko wrote:
> > From: Jiri Pirko <jiri@mellanox.com>
> >
> > 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 <rong.a.chen@intel.com>
> > Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Applied. Thanks

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

* Re: [patch net-next] selftests: bpf: don't try to read files without read permission
  2019-10-15 10:00 [patch net-next] selftests: bpf: don't try to read files without read permission Jiri Pirko
  2019-10-15 15:35 ` Jakub Kicinski
@ 2019-10-31 23:35 ` Jakub Kicinski
  2019-10-31 23:40   ` Jakub Kicinski
  1 sibling, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2019-10-31 23:35 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, shuah, ast, daniel, rong.a.chen, mlxsw

On Tue, 15 Oct 2019 12:00:56 +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> 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 <rong.a.chen@intel.com>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> ---
>  tools/testing/selftests/bpf/test_offload.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
> index 15a666329a34..c44c650bde3a 100755
> --- a/tools/testing/selftests/bpf/test_offload.py
> +++ b/tools/testing/selftests/bpf/test_offload.py
> @@ -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.

>                  _, out = cmd('cat %s/%s' % (path, f))
>                  dfs[f] = out.strip()
>              elif os.path.isdir(p):

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

* Re: [patch net-next] selftests: bpf: don't try to read files without read permission
  2019-10-31 23:35 ` Jakub Kicinski
@ 2019-10-31 23:40   ` Jakub Kicinski
  2019-11-01  6:36     ` Jiri Pirko
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2019-10-31 23:40 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, shuah, ast, daniel, rong.a.chen, mlxsw

On Thu, 31 Oct 2019 16:35:35 -0700, Jakub Kicinski wrote:
> On Tue, 15 Oct 2019 12:00:56 +0200, Jiri Pirko wrote:
> > From: Jiri Pirko <jiri@mellanox.com>
> > 
> > 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 <rong.a.chen@intel.com>
> > Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> > ---
> >  tools/testing/selftests/bpf/test_offload.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
> > index 15a666329a34..c44c650bde3a 100755
> > --- a/tools/testing/selftests/bpf/test_offload.py
> > +++ b/tools/testing/selftests/bpf/test_offload.py
> > @@ -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

> Also the fix is needed in net, not sure why you sent it to net-next.
> 
> >                  _, out = cmd('cat %s/%s' % (path, f))
> >                  dfs[f] = out.strip()
> >              elif os.path.isdir(p):  


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

* Re: [patch net-next] selftests: bpf: don't try to read files without read permission
  2019-10-31 23:40   ` Jakub Kicinski
@ 2019-11-01  6:36     ` Jiri Pirko
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2019-11-01  6:36 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, davem, shuah, ast, daniel, rong.a.chen, mlxsw

Fri, Nov 01, 2019 at 12:40:57AM CET, jakub.kicinski@netronome.com wrote:
>On Thu, 31 Oct 2019 16:35:35 -0700, Jakub Kicinski wrote:
>> On Tue, 15 Oct 2019 12:00:56 +0200, Jiri Pirko wrote:
>> > From: Jiri Pirko <jiri@mellanox.com>
>> > 
>> > 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 <rong.a.chen@intel.com>
>> > Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> > ---
>> >  tools/testing/selftests/bpf/test_offload.py | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> > 
>> > diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
>> > index 15a666329a34..c44c650bde3a 100755
>> > --- a/tools/testing/selftests/bpf/test_offload.py
>> > +++ b/tools/testing/selftests/bpf/test_offload.py
>> > @@ -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:

Sure I tested. It worked. Odd.

>
>Exception: /sys/kernel/debug/netdevsim/netdevsim0//ports/0/dev/take_snapshot is neither file nor directory
>
>> Also the fix is needed in net, not sure why you sent it to net-next.
>> 
>> >                  _, out = cmd('cat %s/%s' % (path, f))
>> >                  dfs[f] = out.strip()
>> >              elif os.path.isdir(p):  
>

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

end of thread, other threads:[~2019-11-01  6:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 10:00 [patch net-next] selftests: bpf: don't try to read files without read permission Jiri Pirko
2019-10-15 15:35 ` Jakub Kicinski
2019-10-15 23:28   ` Alexei Starovoitov
2019-10-31 23:35 ` Jakub Kicinski
2019-10-31 23:40   ` Jakub Kicinski
2019-11-01  6:36     ` Jiri Pirko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).