lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250204082848.13471-1-hotforest@gmail.com>
Date: Tue,  4 Feb 2025 16:28:45 +0800
From: Hou Tao <hotforest@...il.com>
To: bpf@...r.kernel.org,
	rcu@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
	Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Andrii Nakryiko <andrii@...nel.org>,
	Martin KaFai Lau <martin.lau@...ux.dev>,
	Eduard Zingerman <eddyz87@...il.com>,
	Song Liu <song@...nel.org>,
	Yonghong Song <yonghong.song@...ux.dev>,
	John Fastabend <john.fastabend@...il.com>,
	KP Singh <kpsingh@...nel.org>,
	Stanislav Fomichev <sdf@...ichev.me>,
	Hao Luo <haoluo@...gle.com>,
	Jiri Olsa <jolsa@...nel.org>,
	"Paul E . McKenney" <paulmck@...nel.org>,
	houtao1@...wei.com,
	hotforest@...il.com
Subject: [PATCH bpf-next 0/3] bpf: Overwrite the htab element atomically

Hi,

The motivation for the patch set comes from the question raised by Cody
Haas [1]. He asked whether or not the update of htab of map is atomic in
the perspective of lookup operation. Currently, the update is not atomic
because the overwrite of existing element happens in a two-steps way,
but the support of atomic update is feasible. Initiallly, I only plan to
support atomic update for htab of map because array of map has already
supported that. Afterwards, I think it may be reasonable to support
atomic update for all kinds of hash map. However, for the BPF_F_LOCK
case, although the update is protected by a spin-lock, the update is
still not atomic in the perspective of the lookup operation.

Please see individual patches for details. Comments are always welcome.

---

[1] : https://lore.kernel.org/xdp-newbies/07a365d8-2e66-2899-4298-b8b158a928fa@huaweicloud.com/T/#m06fcd687c6cfdbd0f9b643b227e69b479fc8c2f6

Hou Tao (3):
  rculist: add hlist_nulls_replace_rcu() helper
  bpf: Overwrite the element in hash map atomically
  selftests/bpf: Add test case for atomic htab update

 include/linux/rculist_nulls.h                 |  42 ++++++
 kernel/bpf/hashtab.c                          |  14 +-
 .../selftests/bpf/prog_tests/htab_lookup.c    | 130 ++++++++++++++++++
 .../testing/selftests/bpf/progs/htab_lookup.c |  13 ++
 4 files changed, 193 insertions(+), 6 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/htab_lookup.c
 create mode 100644 tools/testing/selftests/bpf/progs/htab_lookup.c

-- 
2.48.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ