You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm most likely missing something because there's little chance there would be the same mistake in both codes. If someone can explain it to me that would be great :)
As commented in the code.
if ((request.access & device.access) == 0)
goto next_block:
example:
device access permissions: r _ _ (bpf_access == BPF_DEVCG_ACC_READ)
device access request: r w _ (BPF_REG_3 = BPF_DEVCG_ACC_READ | BPF_DEVCG_ACC_WRITE)
then BPF_REG_3 & bpf_access != 0, so we keep on checking other fields and it makes the device a potential candidate to be accepted for write permissions despite the device access being only read ?
Shouldn't we rather have something like this ?
if (BPF_REG_R3 & BPF_DEVCG_ACC_READ != 0) && (bpf_access & BPF_DEVCG_ACC_READ == 0) goto next
if (BPF_REG_R3 & BPF_DEVCG_ACC_WRITE != 0) && (bpf_access & BPF_DEVCG_ACC_WRITE == 0) goto next
if (BPF_REG_R3 & BPF_DEVCG_ACC_MKNOD != 0) && (bpf_access & BPF_DEVCG_ACC_MKNOD == 0) goto next
Thanks
The text was updated successfully, but these errors were encountered:
Hello :); My question is the same as the one reported here
NVIDIA/libnvidia-container#227
Since the code there looks like this one:
https://github.com/containers/crun/blob/main/src/libcrun/ebpf.c#L195
I'm most likely missing something because there's little chance there would be the same mistake in both codes. If someone can explain it to me that would be great :)
As commented in the code.
the current code denies device access (at least stops checking the current device) only if the intersection between the requested access and the device permissions is empty
https://github.com/containers/crun/blob/main/src/libcrun/ebpf.c#L220
But is it enough ?
example:
device access permissions: r _ _ (bpf_access == BPF_DEVCG_ACC_READ)
device access request: r w _ (BPF_REG_3 = BPF_DEVCG_ACC_READ | BPF_DEVCG_ACC_WRITE)
then
BPF_REG_3 & bpf_access != 0
, so we keep on checking other fields and it makes the device a potential candidate to be accepted for write permissions despite the device access being only read ?Shouldn't we rather have something like this ?
Thanks
The text was updated successfully, but these errors were encountered: