IPv6 addresses with the same scope are returned in reverse insertion
order, unlike IPv4. For example, when adding a -> b -> c, the list is
reported as c -> b -> a, while IPv4 preserves the original order.
This behavior causes:
a. When using `ip -6 a save` and `ip -6 a restore`, addresses are restored
in the opposite order from which they were saved. See example below
showing addresses added as 1::1, 1::2, 1::3 but displayed and saved
in reverse order.
# ip -6 a a 1::1 dev x
# ip -6 a a 1::2 dev x
# ip -6 a a 1::3 dev x
# ip -6 a s dev x
2: x: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
inet6 1::3/128 scope global tentative
valid_lft forever preferred_lft forever
inet6 1::2/128 scope global tentative
valid_lft forever preferred_lft forever
inet6 1::1/128 scope global tentative
valid_lft forever preferred_lft forever
# ip -6 a save > dump
# ip -6 a d 1::1 dev x
# ip -6 a d 1::2 dev x
# ip -6 a d 1::3 dev x
# ip a d ::1 dev lo
# ip a restore < dump
# ip -6 a s dev x
2: x: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
inet6 1::1/128 scope global tentative
valid_lft forever preferred_lft forever
inet6 1::2/128 scope global tentative
valid_lft forever preferred_lft forever
inet6 1::3/128 scope global tentative
valid_lft forever preferred_lft forever
# ip a showdump < dump
if1:
inet6 ::1/128 scope host proto kernel_lo
valid_lft forever preferred_lft forever
if2:
inet6 1::3/128 scope global tentative
valid_lft forever preferred_lft forever
if2:
inet6 1::2/128 scope global tentative
valid_lft forever preferred_lft forever
if2:
inet6 1::1/128 scope global tentative
valid_lft forever preferred_lft forever
b. Addresses in pasta to appear in reversed order compared to host
addresses.
The ipv6 addresses were added in reverse order by commit e55ffac60117
("[IPV6]: order addresses by scope"), then it was changed by commit
502a2ffd7376 ("ipv6: convert idev_list to list macros"), and restored by
commit b54c9b98bbfb ("ipv6: Preserve pervious behavior in
ipv6_link_dev_addr()."). However, this reverse ordering within the same
scope causes inconsistency with IPv4 and the issues described above.
This patch aligns IPv6 address ordering with IPv4 for consistency
by changing the comparison from >= to > when inserting addresses
into the address list. Also updates the ioam6 selftest to reflect
the new address ordering behavior. Combine these two changes into
one patch for bisectability.
Fixes: e55ffac60117 ("[IPV6]: order addresses by scope")
Link: https://bugs.passt.top/show_bug.cgi?id=175
Suggested-by: Stefano Brivio <sbrivio(a)redhat.com>
Signed-off-by: Yumei Huang <yuhuang(a)redhat.com>
---
net/ipv6/addrconf.c | 2 +-
tools/testing/selftests/net/ioam6.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 40e9c336f6c5..ca998bf46863 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1013,7 +1013,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
list_for_each(p, &idev->addr_list) {
struct inet6_ifaddr *ifa
= list_entry(p, struct inet6_ifaddr, if_list);
- if (ifp_scope >= ipv6_addr_src_scope(&ifa->addr))
+ if (ifp_scope > ipv6_addr_src_scope(&ifa->addr))
break;
}
diff --git a/tools/testing/selftests/net/ioam6.sh b/tools/testing/selftests/net/ioam6.sh
index 845c26dd01a9..b2b99889942f 100755
--- a/tools/testing/selftests/net/ioam6.sh
+++ b/tools/testing/selftests/net/ioam6.sh
@@ -273,8 +273,8 @@ setup()
ip -netns $ioam_node_beta link set ioam-veth-betaR name veth1 &>/dev/null
ip -netns $ioam_node_gamma link set ioam-veth-gamma name veth0 &>/dev/null
- ip -netns $ioam_node_alpha addr add 2001:db8:1::50/64 dev veth0 &>/dev/null
ip -netns $ioam_node_alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null
+ ip -netns $ioam_node_alpha addr add 2001:db8:1::50/64 dev veth0 &>/dev/null
ip -netns $ioam_node_alpha link set veth0 up &>/dev/null
ip -netns $ioam_node_alpha link set lo up &>/dev/null
ip -netns $ioam_node_alpha route add 2001:db8:2::/64 \
--
2.52.0
This patch series enhances BPF's cryptographic functionality by introducing
kernel functions for SHA hashing and ECDSA signature verification. The changes
enable BPF programs to verify data integrity and authenticity across
networking, security, and observability use cases.
The series addresses two gaps in BPF's cryptographic toolkit:
1. Cryptographic hashing - supports content verification and message digest
preparation
2. Asymmetric signature verification - allows validation of signed data
without requiring private keys in the datapath
Use cases include:
- Verifying signed network packets or application data in XDP/TC programs
- Integrity checks within tracing and security monitoring
- Zero-trust security models with BPF-based credential verification
- Content-addressed storage in BPF-based filesystems
The implementation leverages existing BPF patterns: it uses bpf_dynptr for
memory safety, reuses kernel crypto libraries (lib/crypto/sha256.c and
crypto/ecdsa.c) rather than reimplementing algorithms, and provides
context-based APIs supporting multiple program types.
v2:
- Fixed redundant __bpf_dynptr_is_rdonly() checks (Vadim)
- Added BPF hash algorithm type registration module in crypto/ subsystem
- Added CONFIG_CRYPTO_HASH2 guards around bpf_crypto_hash() kfunc and its
BTF registration, matching the pattern used for CONFIG_CRYPTO_ECDSA
- Added mandatory digestsize validation for hash operations
v3:
- Fixed patch ordering - header changes now in separate first commit before
crypto module to ensure bisectability (bot+bpf-ci)
- Fixed type mismatch - changed u32 to u64 for dynptr sizes in
bpf_crypto_hash() to match __bpf_dynptr_size() return type (Mykyta)
- Added CONFIG_CRYPTO_ECDSA to selftest config (Song)
- Refactored test code duplication with setup_skel() helper (Song)
- Added copyright notices to all new files
v4:
- Reused common bpf_crypto_ctx structure for hash and signature operations
instead of separate context types (Song)
- Fixed integer truncation in bpf_crypto_hash when data_len > UINT_MAX
- Corrected KF_RCU flags for ECDSA kfuncs (only bpf_ecdsa_verify needs KF_RCU)
- Updated MAINTAINERS file in test patches
- Refactored selftests to use crypto_common.h for kfunc declarations
Daniel Hodges (6):
crypto: Add BPF hash algorithm type registration module
crypto: Add BPF signature algorithm type registration module
bpf: Add hash kfunc for cryptographic hashing
selftests/bpf: Add tests for bpf_crypto_hash kfunc
bpf: Add ECDSA signature verification kfuncs
selftests/bpf: Add tests for ECDSA signature verification kfuncs
MAINTAINERS | 6 +
crypto/Makefile | 6 +
crypto/bpf_crypto_shash.c | 96 +++++++++
crypto/bpf_crypto_sig.c | 60 ++++++
crypto/bpf_crypto_skcipher.c | 1 +
include/linux/bpf_crypto.h | 7 +
kernel/bpf/crypto.c | 193 +++++++++++++++++-
tools/testing/selftests/bpf/config | 3 +
.../selftests/bpf/prog_tests/crypto_hash.c | 147 +++++++++++++
.../selftests/bpf/prog_tests/ecdsa_verify.c | 75 +++++++
.../selftests/bpf/progs/crypto_common.h | 7 +
.../testing/selftests/bpf/progs/crypto_hash.c | 136 ++++++++++++
.../selftests/bpf/progs/ecdsa_verify.c | 157 ++++++++++++++
13 files changed, 886 insertions(+), 8 deletions(-)
create mode 100644 crypto/bpf_crypto_shash.c
create mode 100644 crypto/bpf_crypto_sig.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/crypto_hash.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/ecdsa_verify.c
create mode 100644 tools/testing/selftests/bpf/progs/crypto_hash.c
create mode 100644 tools/testing/selftests/bpf/progs/ecdsa_verify.c
--
2.51.0
The standardisation of Ssdtso is on-hold (probably permanently) in
response to feedback received during the review process.
Unless a strong consensus forms around the need to standardise for one
vertical or the other, I don't see Ssdtso moving forward given the
concerns regarding possible fragmentation for the ecosystem.
Best,
Philipp.
On Tue, 6 Jan 2026 at 22:54, Hans Boehm <hboehm(a)google.com> wrote:
>
> I'm not sure what the Sstdso status is.
>
> I would also greatly prefer to not have such a dynamic switching facility generally available, for reasons very similar to those that Will Deacon gave in the earlier ARM discussion. If this is generally available, I expect people to use it to work around memory ordering bugs in one software component by switching the entire process to TSO mode, even on hardware with an unoptimized TSO implementation. This will impose pressure to optimize TSO everywhere. We will increase pressure to ship TSO libraries to take advantage of situations in which we're running in TSO mode. I think there is significant risk of splitting the ecosystem in this way, possibly with an eventual painful migration from RVWMO to TSO. IIRC, SPARC went through something vaguely similar in its early days.
>
> Dealing with one memory model per platform is complicated enough; we don't want two.
>
> If you do this somewhere under the covers to implement an x86 VM, OK. But please don't let apps switch memory models.
>
> Hans
>
> On Mon, Jan 5, 2026 at 11:46 PM Yangyu Chen <cyy(a)cyyself.name> wrote:
>>
>> Hi Mullner,
>>
>> Thanks for this work, although it has already lasted for about 2 years.
>>
>> On 9/2/2024 14:40, Christoph Müllner wrote:
>> > We can use the PR_{S,G}ET_MEMORY_CONSISTENCY_MODEL prctl calls to change
>> > the memory consistency model at run-time if we have Ssdtso.
>> > This patch registers RISCV_WMO and RISCV_TSO as valid arguments
>> > for these prctl calls and implements the glue code to switch
>> > between these.
>> >
>> > Signed-off-by: Christoph Müllner <christoph.muellner(a)vrull.eu>
>> > ---
>> > .../mm/dynamic-memory-consistency-model.rst | 12 +++-
>> > arch/riscv/include/asm/processor.h | 7 ++
>> > arch/riscv/kernel/Makefile | 1 +
>> > arch/riscv/kernel/dtso.c | 67 +++++++++++++++++++
>> > include/uapi/linux/prctl.h | 2 +
>> > 5 files changed, 88 insertions(+), 1 deletion(-)
>> > create mode 100644 arch/riscv/kernel/dtso.c
>> >
>> > diff --git a/Documentation/mm/dynamic-memory-consistency-model.rst b/Documentation/mm/dynamic-memory-consistency-model.rst
>> > index 1fce855a1fad..c8188c174e27 100644
>> > --- a/Documentation/mm/dynamic-memory-consistency-model.rst
>> > +++ b/Documentation/mm/dynamic-memory-consistency-model.rst
>> > @@ -73,4 +73,14 @@ Supported memory consistency models
>> > This section defines the memory consistency models which are supported
>> > by the prctl interface.
>> >
>> > -<none>
>> > +RISC-V
>> > +------
>> > +
>> > +RISC-V uses RVWMO (RISC-V weak memory ordering) as default memory consistency
>> > +model. TSO (total store ordering) is another specified model and provides
>> > +additional ordering guarantees. Switching user-mode processes from RVWMO to TSO
>> > +is possible when the Ssdtso extension is available.
>> > +
>> > +* :c:macro:`PR_MEMORY_CONSISTENCY_MODEL_RISCV_WMO`: RISC-V weak memory ordering (default).
>> > +
>> > +* :c:macro:`PR_MEMORY_CONSISTENCY_MODEL_RISCV_TSO`: RISC-V total store ordering.
>> > diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h
>> > index a8509cc31ab2..05e05fddc94d 100644
>> > --- a/arch/riscv/include/asm/processor.h
>> > +++ b/arch/riscv/include/asm/processor.h
>> > @@ -184,6 +184,13 @@ extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val);
>> > #define GET_UNALIGN_CTL(tsk, addr) get_unalign_ctl((tsk), (addr))
>> > #define SET_UNALIGN_CTL(tsk, val) set_unalign_ctl((tsk), (val))
>> >
>> > +#ifdef CONFIG_RISCV_ISA_SSDTSO
>> > +extern int dtso_set_memory_consistency_model(unsigned long arg);
>> > +extern int dtso_get_memory_consistency_model(void);
>> > +#define SET_MEMORY_CONSISTENCY_MODEL(arg) dtso_set_memory_consistency_model(arg)
>> > +#define GET_MEMORY_CONSISTENCY_MODEL() dtso_get_memory_consistency_model()
>> > +#endif /* CONIG_RISCV_ISA_SSDTSO */
>> > +
>> > #endif /* __ASSEMBLY__ */
>> >
>> > #endif /* _ASM_RISCV_PROCESSOR_H */
>> > diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
>> > index f71910718053..85f7291da498 100644
>> > --- a/arch/riscv/kernel/Makefile
>> > +++ b/arch/riscv/kernel/Makefile
>> > @@ -65,6 +65,7 @@ obj-$(CONFIG_RISCV_MISALIGNED) += traps_misaligned.o
>> > obj-$(CONFIG_FPU) += fpu.o
>> > obj-$(CONFIG_RISCV_ISA_V) += vector.o
>> > obj-$(CONFIG_RISCV_ISA_V) += kernel_mode_vector.o
>> > +obj-$(CONFIG_RISCV_ISA_SSDTSO) += dtso.o
>> > obj-$(CONFIG_SMP) += smpboot.o
>> > obj-$(CONFIG_SMP) += smp.o
>> > obj-$(CONFIG_SMP) += cpu_ops.o
>> > diff --git a/arch/riscv/kernel/dtso.c b/arch/riscv/kernel/dtso.c
>> > new file mode 100644
>> > index 000000000000..591d5f9de0f5
>> > --- /dev/null
>> > +++ b/arch/riscv/kernel/dtso.c
>> > @@ -0,0 +1,67 @@
>> > +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> > +/*
>> > + * Copyright (c) 2024 Christoph Muellner <christoph.muellner(a)vrull.eu>
>> > + */
>> > +
>> > +#include <linux/cpu.h>
>> > +#include <linux/smp.h>
>> > +#include <linux/prctl.h>
>> > +
>> > +#include <asm/cpu.h>
>> > +#include <asm/dtso.h>
>> > +
>> > +#include <trace/events/ipi.h>
>> > +
>> > +int dtso_set_memory_consistency_model(unsigned long arg)
>> > +{
>> > + int cpu;
>> > + unsigned long cur_model = get_memory_consistency_model(current);
>> > + unsigned long new_model;
>> > +
>> > + switch (arg) {
>> > + case PR_MEMORY_CONSISTENCY_MODEL_RISCV_WMO:
>> > + new_model = RISCV_MEMORY_CONSISTENCY_MODEL_WMO;
>> > + break;
>> > + case PR_MEMORY_CONSISTENCY_MODEL_RISCV_TSO:
>> > + new_model = RISCV_MEMORY_CONSISTENCY_MODEL_TSO;
>> > + break;
>> > + default:
>> > + return -EINVAL;
>> > + }
>> > +
>> > + /* No change requested. */
>> > + if (cur_model == new_model)
>> > + return 0;
>> > +
>> > + /* Enabling TSO only works if DTSO is available. */
>> > + if (new_model == PR_MEMORY_CONSISTENCY_MODEL_RISCV_TSO && !has_dtso())
>> > + return -EINVAL;
>> > +
>> > + /* Switching TSO->WMO is not allowed. */
>> > + if (new_model == RISCV_MEMORY_CONSISTENCY_MODEL_WMO)
>> > + return -EINVAL;
>> > +
>> > + /* Set the new model in the task struct. */
>> > + set_memory_consitency_model(current, new_model);
>> > +
>> > + /*
>> > + * We need to reschedule all threads of the current process.
>> > + * Let's do this by rescheduling all CPUs.
>> > + * This is stricter than necessary, but since this call is
>> > + * not expected to happen frequently the impact is low.
>> > + */
>> > + for_each_cpu(cpu, cpu_online_mask)
>> > + smp_send_reschedule(cpu);
>> > +
>> > + return 0;
>> > +}
>> > +
>> > +int dtso_get_memory_consistency_model(void)
>> > +{
>> > + unsigned long cur_model = get_memory_consistency_model(current);
>> > +
>> > + if (cur_model == RISCV_MEMORY_CONSISTENCY_MODEL_TSO)
>> > + return PR_MEMORY_CONSISTENCY_MODEL_RISCV_TSO;
>> > +
>> > + return PR_MEMORY_CONSISTENCY_MODEL_RISCV_WMO;
>> > +}
>> > diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
>> > index 579662731eaa..20264bdc3092 100644
>> > --- a/include/uapi/linux/prctl.h
>> > +++ b/include/uapi/linux/prctl.h
>> > @@ -308,5 +308,7 @@ struct prctl_mm_map {
>> >
>> > #define PR_SET_MEMORY_CONSISTENCY_MODEL 71
>> > #define PR_GET_MEMORY_CONSISTENCY_MODEL 72
>> > +# define PR_MEMORY_CONSISTENCY_MODEL_RISCV_WMO 1
>> > +# define PR_MEMORY_CONSISTENCY_MODEL_RISCV_TSO 2
>>
>> Should we replace "PR_MEMORY_CONSISTENCY_MODEL_RISCV_TSO" with
>> "PR_MEMORY_CONSISTENCY_MODEL_TSO", so that it can share the same key as
>> Apple's TSO implementation [1]? RISC-V Ssdtso would make such prctl more
>> likely to be accepted.
>>
>> [1] https://lore.kernel.org/lkml/20240411-tso-v1-0-754f11abfbff@marcan.st/
>>
>> Thanks,
>> Yangyu Chen
>>
>> >
>> > #endif /* _LINUX_PRCTL_H */
>>
Commit 66bce7afbaca ("selftests/mm: fix test result reporting in
gup_longterm") introduced a small bug causing unknown filesystems to always
result in a test failure.
This is because do_test() was updated to use a common reporting path, but
this case appears to have been missed.
This is problematic for e.g. virtme-ng which uses an overlayfs file system,
causing gup_longterm to appear to fail each time due to a test count
mismatch:
# Planned tests != run tests (50 != 46)
# Totals: pass:24 fail:0 xfail:0 xpass:0 skip:22 error:0
The fix is to simply change the return into a break.
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes(a)oracle.com>
Fixes: 66bce7afbaca ("selftests/mm: fix test result reporting in gup_longterm")
---
tools/testing/selftests/mm/gup_longterm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/gup_longterm.c b/tools/testing/selftests/mm/gup_longterm.c
index 6279893a0adc..f61150d28eb2 100644
--- a/tools/testing/selftests/mm/gup_longterm.c
+++ b/tools/testing/selftests/mm/gup_longterm.c
@@ -179,7 +179,7 @@ static void do_test(int fd, size_t size, enum test_type type, bool shared)
if (rw && shared && fs_is_unknown(fs_type)) {
ksft_print_msg("Unknown filesystem\n");
result = KSFT_SKIP;
- return;
+ break;
}
/*
* R/O pinning or pinning in a private mapping is always
--
2.52.0
This patch set introduces the BPF_F_CPU and BPF_F_ALL_CPUS flags for
percpu maps, as the requirement of BPF_F_ALL_CPUS flag for percpu_array
maps was discussed in the thread of
"[PATCH bpf-next v3 0/4] bpf: Introduce global percpu data"[1].
The goal of BPF_F_ALL_CPUS flag is to reduce data caching overhead in light
skeletons by allowing a single value to be reused to update values across all
CPUs. This avoids the M:N problem where M cached values are used to update a
map on N CPUs kernel.
The BPF_F_CPU flag is accompanied by *flags*-embedded cpu info, which
specifies the target CPU for the operation:
* For lookup operations: the flag field alongside cpu info enable querying
a value on the specified CPU.
* For update operations: the flag field alongside cpu info enable
updating value for specified CPU.
Links:
[1] https://lore.kernel.org/bpf/20250526162146.24429-1-leon.hwang@linux.dev/
Changes:
v11 -> v12:
* Dropped the v11 changes.
* Stabilized the lru_percpu_hash map test by keeping an extra spare entry,
which can be used temporarily during updates to avoid unintended LRU
evictions.
v10 -> v11:
* Support the combination of BPF_EXIST and BPF_F_CPU/BPF_F_ALL_CPUS for
update operations.
* Fix unstable lru_percpu_hash map test using the combination of
BPF_EXIST and BPF_F_CPU/BPF_F_ALL_CPUS to avoid LRU eviction
(reported by Alexei).
v9 -> v10:
* Add tests to verify array and hash maps do not support BPF_F_CPU and
BPF_F_ALL_CPUS flags.
* Address comment from Andrii:
* Copy map value using copy_map_value_long for percpu_cgroup_storage
maps in a separate patch.
v8 -> v9:
* Change value type from u64 to u32 in selftests.
* Address comments from Andrii:
* Keep value_size unaligned and update everywhere for consistency when
cpu flags are specified.
* Update value by getting pointer for percpu hash and percpu
cgroup_storage maps.
v7 -> v8:
* Address comments from Andrii:
* Check BPF_F_LOCK when update percpu_array, percpu_hash and
lru_percpu_hash maps.
* Refactor flags check in __htab_map_lookup_and_delete_batch().
* Keep value_size unaligned and copy value using copy_map_value() in
__htab_map_lookup_and_delete_batch() when BPF_F_CPU is specified.
* Update warn message in libbpf's validate_map_op().
* Update comment of libbpf's bpf_map__lookup_elem().
v6 -> v7:
* Get correct value size for percpu_hash and lru_percpu_hash in
update_batch API.
* Set 'count' as 'max_entries' in test cases for lookup_batch API.
* Address comment from Alexei:
* Move cpu flags check into bpf_map_check_op_flags().
v5 -> v6:
* Move bpf_map_check_op_flags() from 'bpf.h' to 'syscall.c'.
* Address comments from Alexei:
* Drop the refactoring code of data copying logic for percpu maps.
* Drop bpf_map_check_op_flags() wrappers.
v4 -> v5:
* Address comments from Andrii:
* Refactor data copying logic for all percpu maps.
* Drop this_cpu_ptr() micro-optimization.
* Drop cpu check in libbpf's validate_map_op().
* Enhance bpf_map_check_op_flags() using *allowed flags* instead of
'extra_flags_mask'.
v3 -> v4:
* Address comments from Andrii:
* Remove unnecessary map_type check in bpf_map_value_size().
* Reduce code churn.
* Remove unnecessary do_delete check in
__htab_map_lookup_and_delete_batch().
* Introduce bpf_percpu_copy_to_user() and bpf_percpu_copy_from_user().
* Rename check_map_flags() to bpf_map_check_op_flags() with
extra_flags_mask.
* Add human-readable pr_warn() explanations in validate_map_op().
* Use flags in bpf_map__delete_elem() and
bpf_map__lookup_and_delete_elem().
* Drop "for alignment reasons".
v3 link: https://lore.kernel.org/bpf/20250821160817.70285-1-leon.hwang@linux.dev/
v2 -> v3:
* Address comments from Alexei:
* Use BPF_F_ALL_CPUS instead of BPF_ALL_CPUS magic.
* Introduce these two cpu flags for all percpu maps.
* Address comments from Jiri:
* Reduce some unnecessary u32 cast.
* Refactor more generic map flags check function.
* A code style issue.
v2 link: https://lore.kernel.org/bpf/20250805163017.17015-1-leon.hwang@linux.dev/
v1 -> v2:
* Address comments from Andrii:
* Embed cpu info as high 32 bits of *flags* totally.
* Use ERANGE instead of E2BIG.
* Few format issues.
Leon Hwang (7):
bpf: Introduce BPF_F_CPU and BPF_F_ALL_CPUS flags
bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_array
maps
bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu_hash
and lru_percpu_hash maps
bpf: Copy map value using copy_map_value_long for
percpu_cgroup_storage maps
bpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for
percpu_cgroup_storage maps
libbpf: Add BPF_F_CPU and BPF_F_ALL_CPUS flags support for percpu maps
selftests/bpf: Add cases to test BPF_F_CPU and BPF_F_ALL_CPUS flags
include/linux/bpf-cgroup.h | 4 +-
include/linux/bpf.h | 35 +-
include/uapi/linux/bpf.h | 2 +
kernel/bpf/arraymap.c | 29 +-
kernel/bpf/hashtab.c | 94 +++--
kernel/bpf/local_storage.c | 27 +-
kernel/bpf/syscall.c | 37 +-
tools/include/uapi/linux/bpf.h | 2 +
tools/lib/bpf/bpf.h | 8 +
tools/lib/bpf/libbpf.c | 26 +-
tools/lib/bpf/libbpf.h | 21 +-
.../selftests/bpf/prog_tests/percpu_alloc.c | 328 ++++++++++++++++++
.../selftests/bpf/progs/percpu_alloc_array.c | 32 ++
13 files changed, 560 insertions(+), 85 deletions(-)
--
2.51.2
This patch series builds upon the discussion in
"[PATCH bpf-next v4 0/4] bpf: Improve error reporting for freplace attachment failure" [1].
This patch series introduces support for *common attributes* in the BPF
syscall, providing a unified mechanism for passing shared metadata across
all BPF commands.
The initial set of common attributes includes:
1. 'log_buf': User-provided buffer for storing log output.
2. 'log_size': Size of the provided log buffer.
3. 'log_level': Verbosity level for logging.
4. 'log_true_size': The size of log reported by kernel.
With this extension, the BPF syscall will be able to return meaningful
error messages (e.g., failures of creating map), improving debuggability
and user experience.
Changes:
RFC v3 -> v4:
* Drop RFC.
* Address comments from Andrii:
* Add parentheses in 'sys_bpf_ext()'.
* Avoid creating new fd in 'probe_sys_bpf_ext()'.
* Add a new struct to wrap log fields in libbpf.
* Address comments from Alexei:
* Do not skip writing to user space when log_true_size is zero.
* Do not use 'bool' arguments.
* Drop the adding WARN_ON_ONCE()'s.
RFC v2 -> RFC v3:
* Rename probe_sys_bpf_extended to probe_sys_bpf_ext.
* Refactor reporting 'log_true_size' for prog_load.
* Refactor reporting 'btf_log_true_size' for btf_load.
* Add warnings for internal bugs in map_create.
* Check log_true_size in test cases.
* Address comment from Alexei:
* Change kvzalloc/kvfree to kzalloc/kfree.
* Address comments from Andrii:
* Move BPF_COMMON_ATTRS to 'enum bpf_cmd' alongside brief comment.
* Add bpf_check_uarg_tail_zero() for extra checks.
* Rename sys_bpf_extended to sys_bpf_ext.
* Rename sys_bpf_fd_extended to sys_bpf_ext_fd.
* Probe the new feature using NULL and -EFAULT.
* Move probe_sys_bpf_ext to libbpf_internal.h and drop LIBBPF_API.
* Return -EUSERS when log attrs are conflict between bpf_attr and
bpf_common_attr.
* Avoid touching bpf_vlog_init().
* Update the reason messages in map_create.
* Finalize the log using __cleanup().
* Report log size to users.
* Change type of log_buf from '__u64' to 'const char *' and cast type
using ptr_to_u64() in bpf_map_create().
* Do not return -EOPNOTSUPP when kernel doesn't support this feature
in bpf_map_create().
* Add log_level support for map creation for consistency.
* Address comment from Eduard:
* Use common_attrs->log_level instead of BPF_LOG_FIXED.
RFC v1 -> RFC v2:
* Fix build error reported by test bot.
* Address comments from Alexei:
* Drop new uapi for freplace.
* Add common attributes support for prog_load and btf_load.
* Add common attributes support for map_create.
Links:
[1] https://lore.kernel.org/bpf/20250224153352.64689-1-leon.hwang@linux.dev/
Leon Hwang (9):
bpf: Extend bpf syscall with common attributes support
libbpf: Add support for extended bpf syscall
bpf: Refactor reporting log_true_size for prog_load
bpf: Add common attr support for prog_load
bpf: Refactor reporting btf_log_true_size for btf_load
bpf: Add common attr support for btf_load
bpf: Add common attr support for map_create
libbpf: Add common attr support for map_create
selftests/bpf: Add tests to verify map create failure log
include/linux/bpf.h | 2 +-
include/linux/btf.h | 2 +-
include/linux/syscalls.h | 3 +-
include/uapi/linux/bpf.h | 8 +
kernel/bpf/btf.c | 25 +-
kernel/bpf/syscall.c | 223 ++++++++++++++++--
kernel/bpf/verifier.c | 12 +-
tools/include/uapi/linux/bpf.h | 8 +
tools/lib/bpf/bpf.c | 49 +++-
tools/lib/bpf/bpf.h | 17 +-
tools/lib/bpf/features.c | 8 +
tools/lib/bpf/libbpf_internal.h | 3 +
.../selftests/bpf/prog_tests/map_init.c | 143 +++++++++++
13 files changed, 448 insertions(+), 55 deletions(-)
--
2.52.0
This small patchset is about avoid user-memory-access vulnerability
for LIVE_FRAMES at specific xdp_md context.
---
KaFai Wan (2):
bpf, test_run: Fix user-memory-access vulnerability for LIVE_FRAMES
selftests/bpf: Add test for xdp_md context with LIVE_FRAMES in
BPF_PROG_TEST_RUN
net/bpf/test_run.c | 23 +++++++++----------
.../bpf/prog_tests/xdp_context_test_run.c | 19 +++++++++++++++
.../bpf/prog_tests/xdp_do_redirect.c | 6 ++---
.../bpf/progs/test_xdp_context_test_run.c | 6 +++++
4 files changed, 39 insertions(+), 15 deletions(-)
--
2.43.0
Fix the execution of 'make run_tests' and also wire up libc-test.
Signed-off-by: Thomas Weißschuh <linux(a)weissschuh.net>
---
Thomas Weißschuh (3):
selftests/nolibc: try to read from stdin in readv_zero test
selftests/nolibc: scope custom flags to the nolibc-test target
selftests/nolibc: also test libc-test through regular selftest framework
tools/testing/selftests/nolibc/Makefile | 14 +++++++-------
tools/testing/selftests/nolibc/nolibc-test.c | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
---
base-commit: 6b6dbf3e4ecfd7d1086bd7cd8b31ca8e45d4dc1f
change-id: 20260106-nolibc-selftests-45ca3266eec5
Best regards,
--
Thomas Weißschuh <linux(a)weissschuh.net>