All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Quan Sun" <m202672221@hust.edu.cn>, bpf@vger.kernel.org
Subject: Re: [PATCH] bpf, lsm: Mark IPC control hook perm parameters nullable
Date: Wed, 25 Nov 2026 18:10:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-233914@kernel.org> (raw)
In-Reply-To: <51ae120f0b3cd8c20dbaaf02c9c384dc2afab6bc.1795627805.git.m202672221@hust.edu.cn>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] bpf, lsm: missing __nullable annotation on kacl in
  bpf_lsm_inode_set_acl() [1]
--

commit 77496f1a0298baa887511d2928e2317763dbc7b6
Author: Quan Sun <m202672221@hust.edu.cn>

bpf, lsm: Mark IPC control hook perm parameters nullable

This commit adds strong overrides in kernel/bpf/bpf_lsm_proto.c for
bpf_lsm_shm_shmctl(), bpf_lsm_sem_semctl(), and
bpf_lsm_msg_queue_msgctl() to annotate their perm parameters with
__nullable.

> diff --git a/kernel/bpf/bpf_lsm_proto.c b/kernel/bpf/bpf_lsm_proto.c
> index b81179ae2e086..7c48af32c2d40 100644
> --- a/kernel/bpf/bpf_lsm_proto.c
> +++ b/kernel/bpf/bpf_lsm_proto.c
> @@ -5,6 +5,7 @@
>  
>  #include <linux/fs.h>
>  #include <linux/xattr.h>
> +#include <linux/ipc.h>
>  #include <linux/bpf_lsm.h>
>  
>  /*
> @@ -32,3 +33,31 @@ noinline int bpf_lsm_inode_init_security(struct inode *inode, struct inode *dir,
>  {
>  	return -EOPNOTSUPP;
>  }
> +
> +/*
> + * Strong definitions of the IPC control BPF LSM hooks. The informational
> + * commands have no object to authorize, so they pass a NULL struct
> + * kern_ipc_perm: shmctl_ipc_info() and shmctl_shm_info() call
> + * security_shm_shmctl(NULL, IPC_INFO | SHM_INFO), semctl_info() calls
> + * security_sem_semctl(NULL, cmd) and msgctl_info() calls
> + * security_msg_queue_msgctl(NULL, cmd). The __nullable suffix marks perm as
> + * PTR_MAYBE_NULL so that BPF LSM programs have to check it before
> + * dereferencing it. Without these overrides the hooks fall back to the
> + * __weak prototypes generated from lsm_hook_defs.h in bpf_lsm.c, which carry
> + * no annotation and let the verifier type perm as non-nullable.
> + */
> +noinline int bpf_lsm_shm_shmctl(struct kern_ipc_perm *perm__nullable, int cmd)
> +{
> +	return 0;
> +}

[Severity: High]
This problem wasn't introduced by this patch, but should
bpf_lsm_inode_set_acl() also have a strong definition [1] marking
its kacl parameter with __nullable?

When setxattr() is called on a POSIX ACL attribute with size == 0,
do_set_acl() passes a NULL acl through vfs_set_acl() and
security_inode_set_acl() to bpf_lsm_inode_set_acl().  Without the
__nullable annotation, the verifier treats kacl as a trusted non-null
pointer and neither requires a NULL check nor rewrites loads to use
BPF_PROBE_MEM, allowing a BPF LSM program attached to inode_set_acl to
trigger a NULL pointer dereference.

[1] https://sashiko.dev/#/bug/linux-bc5e250e-6772-4ebe-b887-e6439d751142

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/51ae120f0b3cd8c20dbaaf02c9c384dc2afab6bc.1795627805.git.m202672221@hust.edu.cn?part=1

  reply	other threads:[~2026-11-25 18:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 17:59 [PATCH] bpf, lsm: Mark IPC control hook perm parameters nullable Quan Sun
2026-11-25 18:10 ` sashiko-bot [this message]
2026-11-25 18:25 ` bot+bpf-ci
2026-11-30  5:29 ` Alexei Starovoitov

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=sashiko-outbox-233914@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=m202672221@hust.edu.cn \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.