diff mbox series

bpf: lirc program type should not require SYS_CAP_ADMIN

Message ID ZDWAcN6wfeXzipHz@gofer.mess.org (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series bpf: lirc program type should not require SYS_CAP_ADMIN | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 20 this patch: 20
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 20 this patch: 20
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-7 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-21 fail Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 fail Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-16 fail Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 fail Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-33 fail Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on s390x with gcc

Commit Message

Sean Young April 11, 2023, 3:44 p.m. UTC
Make it possible to load lirc program type with just CAP_BPF.

Signed-off-by: Sean Young <sean@mess.org>
---
 kernel/bpf/syscall.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Alexei Starovoitov April 12, 2023, 11:14 p.m. UTC | #1
On Tue, Apr 11, 2023 at 8:45 AM Sean Young <sean@mess.org> wrote:
>
> Make it possible to load lirc program type with just CAP_BPF.

Is it safe?
If the user can load with just CAP_BPF the FD to the prog and target_fd
will allow attach as well.


> Signed-off-by: Sean Young <sean@mess.org>
> ---
>  kernel/bpf/syscall.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index adc83cb82f37..19d9265270b3 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -2439,7 +2439,6 @@ static bool is_net_admin_prog_type(enum bpf_prog_type prog_type)
>         case BPF_PROG_TYPE_LWT_SEG6LOCAL:
>         case BPF_PROG_TYPE_SK_SKB:
>         case BPF_PROG_TYPE_SK_MSG:
> -       case BPF_PROG_TYPE_LIRC_MODE2:
>         case BPF_PROG_TYPE_FLOW_DISSECTOR:
>         case BPF_PROG_TYPE_CGROUP_DEVICE:
>         case BPF_PROG_TYPE_CGROUP_SOCK:
> --
> 2.39.2
>
Sean Young April 13, 2023, 8:28 a.m. UTC | #2
On Wed, Apr 12, 2023 at 04:14:05PM -0700, Alexei Starovoitov wrote:
> On Tue, Apr 11, 2023 at 8:45 AM Sean Young <sean@mess.org> wrote:
> >
> > Make it possible to load lirc program type with just CAP_BPF.
> 
> Is it safe?
> If the user can load with just CAP_BPF the FD to the prog and target_fd
> will allow attach as well.

Exactly, that's the $1m question of course. 

I think it's safe from a lirc perspective because you need to be able to
open the /dev/lirc0 device in the first place; if you can open it, you
alter all sorts of lirc receiving options already. Changing the IR protocol
decoder is no different in that perspective.

The other side of course, is it save to load a bpf lirc program as a normal
user. I don't see any issue with this; I guess this depends on whether the
subset of functions in lirc_mode2_func_proto() is safe. I am hoping that
the expert opinion everyone here can help answer that question.

Thanks,

Sean

> 
> 
> > Signed-off-by: Sean Young <sean@mess.org>
> > ---
> >  kernel/bpf/syscall.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > index adc83cb82f37..19d9265270b3 100644
> > --- a/kernel/bpf/syscall.c
> > +++ b/kernel/bpf/syscall.c
> > @@ -2439,7 +2439,6 @@ static bool is_net_admin_prog_type(enum bpf_prog_type prog_type)
> >         case BPF_PROG_TYPE_LWT_SEG6LOCAL:
> >         case BPF_PROG_TYPE_SK_SKB:
> >         case BPF_PROG_TYPE_SK_MSG:
> > -       case BPF_PROG_TYPE_LIRC_MODE2:
> >         case BPF_PROG_TYPE_FLOW_DISSECTOR:
> >         case BPF_PROG_TYPE_CGROUP_DEVICE:
> >         case BPF_PROG_TYPE_CGROUP_SOCK:
> > --
> > 2.39.2
> >
Alexei Starovoitov April 13, 2023, 11:54 p.m. UTC | #3
On Thu, Apr 13, 2023 at 1:28 AM Sean Young <sean@mess.org> wrote:
>
> On Wed, Apr 12, 2023 at 04:14:05PM -0700, Alexei Starovoitov wrote:
> > On Tue, Apr 11, 2023 at 8:45 AM Sean Young <sean@mess.org> wrote:
> > >
> > > Make it possible to load lirc program type with just CAP_BPF.
> >
> > Is it safe?
> > If the user can load with just CAP_BPF the FD to the prog and target_fd
> > will allow attach as well.
>
> Exactly, that's the $1m question of course.
>
> I think it's safe from a lirc perspective because you need to be able to
> open the /dev/lirc0 device in the first place; if you can open it, you
> alter all sorts of lirc receiving options already. Changing the IR protocol
> decoder is no different in that perspective.
>
> The other side of course, is it save to load a bpf lirc program as a normal
> user. I don't see any issue with this; I guess this depends on whether the
> subset of functions in lirc_mode2_func_proto() is safe. I am hoping that
> the expert opinion everyone here can help answer that question.

That part is fine under CAP_BPF.
I don't know how lirc devices are typically setup.
If they need root to open them
then why bother relaxing bpf loading part?
Sean Young April 14, 2023, 10:58 a.m. UTC | #4
On Thu, Apr 13, 2023 at 04:54:21PM -0700, Alexei Starovoitov wrote:
> On Thu, Apr 13, 2023 at 1:28 AM Sean Young <sean@mess.org> wrote:
> >
> > On Wed, Apr 12, 2023 at 04:14:05PM -0700, Alexei Starovoitov wrote:
> > > On Tue, Apr 11, 2023 at 8:45 AM Sean Young <sean@mess.org> wrote:
> > > >
> > > > Make it possible to load lirc program type with just CAP_BPF.
> > >
> > > Is it safe?
> > > If the user can load with just CAP_BPF the FD to the prog and target_fd
> > > will allow attach as well.
> >
> > Exactly, that's the $1m question of course.
> >
> > I think it's safe from a lirc perspective because you need to be able to
> > open the /dev/lirc0 device in the first place; if you can open it, you
> > alter all sorts of lirc receiving options already. Changing the IR protocol
> > decoder is no different in that perspective.
> >
> > The other side of course, is it save to load a bpf lirc program as a normal
> > user. I don't see any issue with this; I guess this depends on whether the
> > subset of functions in lirc_mode2_func_proto() is safe. I am hoping that
> > the expert opinion everyone here can help answer that question.
> 
> That part is fine under CAP_BPF.
> I don't know how lirc devices are typically setup.
> If they need root to open them
> then why bother relaxing bpf loading part?

I'd like to get a point where /dev/lircN can have the same permissions as
for example /dev/videoN devices: group read/write, so that local users
don't have to become root to use them.

Without relaxing the bpf side, this seems like a chicken and egg problem
(tiktaalik and egg?).

Also - the CAP_NET_ADMIN requirement seems completely arbitrary compared
to other program types.


Sean
Alexei Starovoitov April 14, 2023, 3:39 p.m. UTC | #5
On Fri, Apr 14, 2023 at 3:58 AM Sean Young <sean@mess.org> wrote:
>
> On Thu, Apr 13, 2023 at 04:54:21PM -0700, Alexei Starovoitov wrote:
> > On Thu, Apr 13, 2023 at 1:28 AM Sean Young <sean@mess.org> wrote:
> > >
> > > On Wed, Apr 12, 2023 at 04:14:05PM -0700, Alexei Starovoitov wrote:
> > > > On Tue, Apr 11, 2023 at 8:45 AM Sean Young <sean@mess.org> wrote:
> > > > >
> > > > > Make it possible to load lirc program type with just CAP_BPF.
> > > >
> > > > Is it safe?
> > > > If the user can load with just CAP_BPF the FD to the prog and target_fd
> > > > will allow attach as well.
> > >
> > > Exactly, that's the $1m question of course.
> > >
> > > I think it's safe from a lirc perspective because you need to be able to
> > > open the /dev/lirc0 device in the first place; if you can open it, you
> > > alter all sorts of lirc receiving options already. Changing the IR protocol
> > > decoder is no different in that perspective.
> > >
> > > The other side of course, is it save to load a bpf lirc program as a normal
> > > user. I don't see any issue with this; I guess this depends on whether the
> > > subset of functions in lirc_mode2_func_proto() is safe. I am hoping that
> > > the expert opinion everyone here can help answer that question.
> >
> > That part is fine under CAP_BPF.
> > I don't know how lirc devices are typically setup.
> > If they need root to open them
> > then why bother relaxing bpf loading part?
>
> I'd like to get a point where /dev/lircN can have the same permissions as
> for example /dev/videoN devices: group read/write, so that local users
> don't have to become root to use them.
>
> Without relaxing the bpf side, this seems like a chicken and egg problem
> (tiktaalik and egg?).
>
> Also - the CAP_NET_ADMIN requirement seems completely arbitrary compared
> to other program types.

Yeah. Agree. Could you respin with all these additional details
explaining the motivation and driver permission model?
Sean Young April 14, 2023, 5:49 p.m. UTC | #6
On Fri, Apr 14, 2023 at 08:39:13AM -0700, Alexei Starovoitov wrote:
> Yeah. Agree. Could you respin with all these additional details
> explaining the motivation and driver permission model?

Thanks, will do. The commit message was way too short.


Sean
diff mbox series

Patch

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index adc83cb82f37..19d9265270b3 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2439,7 +2439,6 @@  static bool is_net_admin_prog_type(enum bpf_prog_type prog_type)
 	case BPF_PROG_TYPE_LWT_SEG6LOCAL:
 	case BPF_PROG_TYPE_SK_SKB:
 	case BPF_PROG_TYPE_SK_MSG:
-	case BPF_PROG_TYPE_LIRC_MODE2:
 	case BPF_PROG_TYPE_FLOW_DISSECTOR:
 	case BPF_PROG_TYPE_CGROUP_DEVICE:
 	case BPF_PROG_TYPE_CGROUP_SOCK: