Skip to contentSkip to conversation

bpf: lirc program type should not require SYS_CAP_ADMIN

PATCH Superseded Sean Young 2 participants 7 messages Apr 11, 2023 – Apr 14, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sean Young

author
#0 lore raw

PATCH 1/1 bpf: lirc program type should not require SYS_CAP_ADMIN

Make it possible to load lirc program type with just CAP_BPF.

---
 kernel/bpf/syscall.c | 1 -
 1 file changed, 1 deletion(-)
kernel/bpf/syscall.c +0 -1
index adc83cb82f37..19d9265270b3 100644
@@ -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:
Signature · 1 line
2.39.2
#1 lore raw
Quoted 2 lines · Sean Young

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.

Quoted 20 lines
---
 kernel/bpf/syscall.c | 1 -
 1 file changed, 1 deletion(-)
kernel/bpf/syscall.c +0 -2
index adc83cb82f37..19d9265270b3 100644
@@ -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

author
#2 lore raw
Quoted 7 lines · Alexei Starovoitov
Quoted 2 lines · Sean Young

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

Quoted 22 lines
Quoted 22 lines
---
 kernel/bpf/syscall.c | 1 -
 1 file changed, 1 deletion(-)
kernel/bpf/syscall.c +0 -2
index adc83cb82f37..19d9265270b3 100644
@@ -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

#3 lore raw
Quoted 17 lines · Sean Young
Quoted 7 lines · Alexei Starovoitov
Quoted 2 lines · Sean Young

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.

Quoted 4 lines

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?

author
#4 lore raw
Quoted 23 lines · Alexei Starovoitov
Quoted 17 lines · Sean Young
Quoted 7 lines · Alexei Starovoitov
Quoted 2 lines · Sean Young

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.

Quoted 4 lines

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.

Quoted 4 lines

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

#5 lore raw
Quoted 34 lines · Sean Young
Quoted 23 lines · Alexei Starovoitov
Quoted 17 lines · Sean Young
Quoted 7 lines · Alexei Starovoitov
Quoted 2 lines · Sean Young

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.

Quoted 4 lines

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.

Quoted 4 lines

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.

Quoted 5 lines

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?

author
#6 lore raw
Quoted 2 lines · Alexei Starovoitov

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