mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: rtoax@foxmail.com,vmalik@redhat.com,andrii@kernel.org,ast@kernel.org
Cc: rtoax@foxmail.com,rongtao@cestc.cn,daniel@iogearbox.net,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,shuah@kernel.org,ishiyama@hpc.is.uec.ac.jp,bpf@vger.kernel.org,linux-kernel@vger.kernel.org,linux-kselftest@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v5 1/2] bpf: add bpf_strcat,bpf_strncat kfunc
Date: Wed, 22 Jul 2026 06:19:36 +0000 (UTC)	[thread overview]
Message-ID: <455026ad71596cb0ff71074ef232644d1cd4d623cccbd0f695fa275aaf5ed972@mail.kernel.org> (raw)
In-Reply-To: <tencent_60882E4BE4F247C5F6D564F41BF1C3004805@qq.com>

[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]

> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index c18f1e16edee..85afff60365c 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -4195,6 +4195,79 @@ __bpf_kfunc int bpf_strncasestr(const char *s1__ign, const char *s2__ign,
>  	return __bpf_strnstr(s1__ign, s2__ign, len, true);
>  }
>
> +static int __bpf_strncat(char *dst, u32 dsz, const char *src, u32 sz)
> +{
> +	int dlen = 0, slen, space, copied;
> +
> +	if (sz == 0 || dsz == 0)
> +		return -EINVAL;
> +
> +	while (dlen < dsz && dst[dlen] != '\0')
> +		dlen++;
> +
> +	if (dlen >= dsz)
> +		return -E2BIG;
> +
> +	space = dsz - dlen;
> +
> +	slen = bpf_strnlen(src, sz);

This came up in the earlier review of the series: the length of src does not
need to be computed here, since strncpy_from_kernel_nofault() already bounds
the copy by sz.

  https://lore.kernel.org/bpf/3e73aeb2-afce-4ae9-9163-51e4dc1ded01@redhat.com/

That bpf_strnlen(src, sz) call was dropped in an earlier revision and has
returned in this one.  Is the separate src length scan still needed here, or
can strncpy_from_kernel_nofault() handle the bound on its own?

> +	if (space <= slen)
> +		return -E2BIG;
> +
> +	copied = strncpy_from_kernel_nofault(dst + dlen, src, sz);
> +	if (copied < 0)
> +		return copied;
> +	else if (copied == 0 || copied == 1)
> +		return dlen;
> +
> +	/* The copied character count includes '\0'. */
> +	return dlen + copied - 1;
> +}

[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/29894636510

  reply	other threads:[~2026-07-22  6:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1784695085.git.rtoax@foxmail.com>
2026-07-22  4:41 ` Rong Tao
2026-07-22  6:19   ` bot+bpf-ci [this message]
2026-07-27 22:56   ` Andrii Nakryiko
2026-07-28  2:50     ` Rong Tao
2026-07-28 15:58       ` Andrii Nakryiko
2026-07-29  1:08         ` Rong Tao
2026-07-22  4:41 ` [PATCH bpf-next v5 2/2] selftests/bpf: Test bpf_strcat,bpf_strncat kfuncs Rong Tao

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=455026ad71596cb0ff71074ef232644d1cd4d623cccbd0f695fa275aaf5ed972@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=ishiyama@hpc.is.uec.ac.jp \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=rongtao@cestc.cn \
    --cc=rtoax@foxmail.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=vmalik@redhat.com \
    --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

all inboxes | Powered by JetHome®