public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Feng Yang <yangfeng59949@163.com>
To: alexei.starovoitov@gmail.com
Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org,
	daniel@iogearbox.net, eddyz87@gmail.com, jiayuan.chen@linux.dev,
	john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org,
	leon.hwang@linux.dev, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, martin.lau@linux.dev,
	mattbobrowski@google.com, memxor@gmail.com,
	menglong.dong@linux.dev, song@kernel.org, yangfeng59949@163.com,
	yangfeng@kylinos.cn, yonghong.song@linux.dev
Subject: Re: [PATCH v3 bpf-next 1/2] bpf: Fix Null-Pointer Dereference in kernel_clone() via BPF fmod_ret on security_task_alloc
Date: Sun, 12 Apr 2026 10:40:17 +0800	[thread overview]
Message-ID: <20260412024017.6671-1-yangfeng59949@163.com> (raw)
In-Reply-To: <CAADnVQ+PE9t0XPM=k=mqpRd=efJ0KYFGbaadwfL5e9iS-pWWVQ@mail.gmail.com>

On Sun, 12 Apr 2026 00:35:55 +0800 Alexei Starovoitov wrote:

> > +/* The system call return value is allowed to be an arbitrary value. */
> > +static int modify_return_get_retval_range(const struct bpf_prog *prog,
> > +                                         struct bpf_retval_range *range)
> > +{
> > +       return -EINVAL;
> > +}
> > +
> > +#endif /* CONFIG_FUNCTION_ERROR_INJECTION */

> I recall people already explained that this is no go.
> We cannot break all fmod_ret because error injection is disabled.

When error injection is disabled, the returned -EINVAL will result in a false return.
This shouldn't change the previous logic.

 		case BPF_TRACE_RAW_TP:
-		case BPF_MODIFY_RETURN:
 			return false;
+		case BPF_MODIFY_RETURN:
+			if (!bpf_security_get_retval_range(env->prog, range))
+				break;
+			if (modify_return_get_retval_range(env->prog, range))
+				return false;
+			break;

> Also see sashiko reports.
>

Okay.
Thansks.

> let's copy paste bpf_lsm_get_retval_range() for no good reason?!

So should we modify this part according to Jiayuan Chen's logic?

Jiayuan's previous reply:
Also, I think a whitelist approach would be better here.
The known danger is specifically those security hooks whose return 
values get fed into ERR_PTR() by callers, such as:
- security_task_alloc
- security_inode_readlink
- security_task_movememory
- security_inode_follow_link
- security_fs_context_submount
- security_dentry_create_files_as
- security_perf_event_alloc
- security_inode_get_acl

> please don't send such poor quality patches.


  reply	other threads:[~2026-04-12  2:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-11 16:35 [PATCH v3 bpf-next 0/2] bpf: Fix Null-Pointer Dereference in kernel_clone() via BPF fmod_ret on security_task_alloc Feng Yang
2026-04-11 16:35 ` [PATCH v3 bpf-next 1/2] " Feng Yang
2026-04-11 17:32   ` Alexei Starovoitov
2026-04-12  2:40     ` Feng Yang [this message]
2026-04-12  3:39   ` Menglong Dong
2026-04-13  1:58     ` Feng Yang
2026-04-21  9:18   ` Feng Yang
2026-04-11 16:35 ` [PATCH v3 bpf-next 2/2] selftests/bpf: Add selftests for verifying return values of fmod_ret Feng Yang

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=20260412024017.6671-1-yangfeng59949@163.com \
    --to=yangfeng59949@163.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=leon.hwang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mattbobrowski@google.com \
    --cc=memxor@gmail.com \
    --cc=menglong.dong@linux.dev \
    --cc=song@kernel.org \
    --cc=yangfeng@kylinos.cn \
    --cc=yonghong.song@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox