From: Jakub Sitnicki <jakub@cloudflare.com>
To: kernel test robot <lkp@intel.com>
Cc: oe-kbuild-all@lists.linux.dev, Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [linux-next:master 2782/3950] kernel/bpf/helpers.c:1784:17: warning: argument 2 null where non-null expected because argument 3 is nonzero
Date: Thu, 21 Aug 2025 21:12:37 +0200 [thread overview]
Message-ID: <878qjczdy2.fsf@cloudflare.com> (raw)
In-Reply-To: <87cy8ozoiz.fsf@cloudflare.com> (Jakub Sitnicki's message of "Thu, 21 Aug 2025 17:24:04 +0200")
On Thu, Aug 21, 2025 at 05:24 PM +02, Jakub Sitnicki wrote:
> On Thu, Aug 21, 2025 at 08:53 PM +08, kernel test robot wrote:
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
>> head: 7fa4d8dc380fbd81a9d702a855c50690c9c6442c
>> commit: 6877cd392baecf816c2ba896a9d42874628004a5 [2782/3950] bpf: Enable
>> read/write access to skb metadata through a dynptr
>> config: sparc-randconfig-r063-20250821
>> (https://download.01.org/0day-ci/archive/20250821/202508212031.ir9b3B6Q-lkp@intel.com/config)
>> compiler: sparc-linux-gcc (GCC) 15.1.0
>> reproduce (this is a W=1 build):
>> (https://download.01.org/0day-ci/archive/20250821/202508212031.ir9b3B6Q-lkp@intel.com/reproduce)
>>
[...]
>> vim +1784 kernel/bpf/helpers.c
>>
>> 1754
>> 1755 static int __bpf_dynptr_read(void *dst, u32 len, const struct bpf_dynptr_kern *src,
>> 1756 u32 offset, u64 flags)
>> 1757 {
>> 1758 enum bpf_dynptr_type type;
>> 1759 int err;
>> 1760
>> 1761 if (!src->data || flags)
>> 1762 return -EINVAL;
>> 1763
>> 1764 err = bpf_dynptr_check_off_len(src, offset, len);
>> 1765 if (err)
>> 1766 return err;
>> 1767
>> 1768 type = bpf_dynptr_get_type(src);
>> 1769
>> 1770 switch (type) {
>> 1771 case BPF_DYNPTR_TYPE_LOCAL:
>> 1772 case BPF_DYNPTR_TYPE_RINGBUF:
>> 1773 /* Source and destination may possibly overlap, hence use memmove to
>> 1774 * copy the data. E.g. bpf_dynptr_from_mem may create two dynptr
>> 1775 * pointing to overlapping PTR_TO_MAP_VALUE regions.
>> 1776 */
>> 1777 memmove(dst, src->data + src->offset + offset, len);
>> 1778 return 0;
>> 1779 case BPF_DYNPTR_TYPE_SKB:
>> 1780 return __bpf_skb_load_bytes(src->data, src->offset + offset, dst, len);
>> 1781 case BPF_DYNPTR_TYPE_XDP:
>> 1782 return __bpf_xdp_load_bytes(src->data, src->offset + offset, dst, len);
>> 1783 case BPF_DYNPTR_TYPE_SKB_META:
>>> 1784 memmove(dst, bpf_skb_meta_pointer(src->data, src->offset + offset), len);
>> 1785 return 0;
>> 1786 default:
>> 1787 WARN_ONCE(true, "bpf_dynptr_read: unknown dynptr type %d\n", type);
>> 1788 return -EFAULT;
>> 1789 }
>> 1790 }
>> 1791
>
> Right. This happens with CONFIG_NET=n.
>
> I think in the end we need a simple wrapper around memmove to stub it
> out with -EOPNOTSUPP when CONFIG_NET is disabled.
Forgot to mention that this null-ptr-deref is not triggerable because
the bpf_dynptr_from_skb_meta kfunc is present only with CONFIG_NET=y.
So a fix is needed just for the sake of silencing compiler diagnostics.
prev parent reply other threads:[~2025-08-21 19:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 12:53 [linux-next:master 2782/3950] kernel/bpf/helpers.c:1784:17: warning: argument 2 null where non-null expected because argument 3 is nonzero kernel test robot
2025-08-21 15:24 ` Jakub Sitnicki
2025-08-21 19:12 ` Jakub Sitnicki [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=878qjczdy2.fsf@cloudflare.com \
--to=jakub@cloudflare.com \
--cc=lkp@intel.com \
--cc=martin.lau@kernel.org \
--cc=oe-kbuild-all@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.