[PATCH v2 security-next 1/4] security: Hornet LSM
Paul Moore
paul at paul-moore.com
Sat Apr 19 16:21:25 UTC 2025
On Tue, Apr 15, 2025 at 3:08 PM Blaise Boscaccy
<bboscaccy at linux.microsoft.com> wrote:
> ... would you be ammenable to a simple patch in
> skel_internal.h that freezes maps? e.g
I have limited network access at the moment, so it is possible I've
missed it, but I think it would be helpful to get a verdict on the
RFC-esque patch from Blaise below.
> diff --git a/tools/lib/bpf/skel_internal.h b/tools/lib/bpf/skel_internal.h
> index 4d5fa079b5d6..51e72dc23062 100644
> --- a/tools/lib/bpf/skel_internal.h
> +++ b/tools/lib/bpf/skel_internal.h
> @@ -263,6 +263,17 @@ static inline int skel_map_delete_elem(int fd, const void *key)
> return skel_sys_bpf(BPF_MAP_DELETE_ELEM, &attr, attr_sz);
> }
>
> +static inline int skel_map_freeze(int fd)
> +{
> + const size_t attr_sz = offsetofend(union bpf_attr, map_fd);
> + union bpf_attr attr;
> +
> + memset(&attr, 0, attr_sz);
> + attr.map_fd = fd;
> +
> + return skel_sys_bpf(BPF_MAP_FREEZE, &attr, attr_sz);
> +}
> +
> static inline int skel_map_get_fd_by_id(__u32 id)
> {
> const size_t attr_sz = offsetofend(union bpf_attr, flags);
> @@ -327,6 +338,13 @@ static inline int bpf_load_and_run(struct bpf_load_and_run_opts *opts)
> goto out;
> }
>
> + err = skel_map_freeze(map_fd);
> + if (err < 0) {
> + opts->errstr = "failed to freeze map";
> + set_err;
> + goto out;
> + }
> +
> memset(&attr, 0, prog_load_attr_sz);
> attr.prog_type = BPF_PROG_TYPE_SYSCALL;
> attr.insns = (long) opts->insns;
>
--
paul-moore.com
More information about the Linux-security-module-archive
mailing list