From: Eric Suen <ericsu@linux.microsoft.com>
To: Daniel Durning <danieldurning.work@gmail.com>
Cc: selinux@vger.kernel.org, paul@paul-moore.com,
stephen.smalley.work@gmail.com, omosnace@redhat.com
Subject: Re: [PATCH testsuite v2] tests/bpf: Add tests for SELinux BPF token access control
Date: Thu, 21 Aug 2025 11:21:49 -0700 [thread overview]
Message-ID: <b61eb6c4-4fd3-462f-9e74-d0006f8d488d@linux.microsoft.com> (raw)
In-Reply-To: <CAKrb_fEMvB2h0uwwm3ZAWXXoEfA6Yk634njGpWoW8hDOQLbMEQ@mail.gmail.com>
On 8/19/2025 8:11 AM, Daniel Durning wrote:
> On Sun, Aug 17, 2025 at 3:10 PM Eric Suen <ericsu@linux.microsoft.com> wrote:
>> This patch adds new tests to verify the SELinux support for BPF token
>> access control, as introduced in the corresponding kernel patch:
>> https://lore.kernel.org/selinux/20250816201420.197-1-ericsu@linux.microsoft.com/
>>
>> Four new tests are added to cover both positive and negative scenarios,
>> ensuring that the SELinux policy enforcement on BPF token usage behaves
>> as expected.
>> - Successful map_create and prog_load when SELinux permissions are
>> granted.
>> - Enforcement of SELinux policy restrictions when access is denied.
>>
>> For testing purposes, you can update the base policy by manually
>> modifying your base module and tweaking /usr/share/selinux/devel as
>> follows:
>> sudo semodule -c -E base
>> sudo cp base.sil base.sil.orig
> Should be sudo cp base.cil base.cil.orig.
Thank you so much, Daniel, for reviewing this.
>> sudo sed -i "s/map_create/map_create map_create_as/" base.cil
>> sudo sed -i "s/prog_load/prog_load prog_load_as/" base.cil
>> sudo semodule -i base.cil
>> echo "(policycap bpf_token_perms)" > bpf_token_perms.cil
>> sudo semodule -i bpf_token_perms.cil
>> sudo cp /usr/share/selinux/devel/include/support/all_perms.spt \
>> /usr/share/selinux/devel/include/support/all_perms.spt.orig
>> sudo sed -i "s/"map_create/map_create map_create_as/" \
>> /usr/share/selinux/devel/include/support/all_perms.spt
> You have an extra quotation mark here just before map_create.
>
>> sudo sed -i "s/prog_load/prog_load prog_load_as/" \
>> /usr/share/selinux/devel/include/support/all_perms.spt
>>
>> When finished testing, you can semodule -r base bpf_token_perms to
>> undo the two module changes and restore your all_perms.spt file from
>> the saved .orig file.
> Might be best to do a sudo dnf reinstall selinux-policy-devel to make
> sure everything is reset.
>
>> Changes in v2:
>> - Removed allow rule for 'kernel_t' in test_bpf.te which was added due
>> to a bug in the kernel
>> - Cleaned up other unnecessary rules in test_bpf.te
>> - Added token_test.c which was missing from previous patch
>>
>> Signed-off-by: Eric Suen <ericsu@linux.microsoft.com>
> Tested-by: Daniel Durning <danieldurning.work@gmail.com>
prev parent reply other threads:[~2025-08-21 18:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-17 19:10 [PATCH testsuite v2] tests/bpf: Add tests for SELinux BPF token access control Eric Suen
2025-08-18 14:37 ` Daniel Durning
2025-08-18 16:26 ` Eric Suen
2025-08-19 15:11 ` Daniel Durning
2025-08-21 18:21 ` Eric Suen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b61eb6c4-4fd3-462f-9e74-d0006f8d488d@linux.microsoft.com \
--to=ericsu@linux.microsoft.com \
--cc=danieldurning.work@gmail.com \
--cc=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.