Martin KaFai Lau
937e41cb2e
bpf: btf: Avoid WARN_ON when CONFIG_REFCOUNT_FULL=y
If CONFIG_REFCOUNT_FULL=y, refcount_inc() WARN when refcount is 0.
When creating a new btf, the initial btf->refcnt is 0 and
triggered the following:
[ 34.855452] refcount_t: increment on 0; use-after-free.
[ 34.856252] WARNING: CPU: 6 PID: 1857 at lib/refcount.c:153 refcount_inc+0x26/0x30
....
[ 34.868809] Call Trace:
[ 34.869168] btf_new_fd+0x1af6/0x24d0
[ 34.869645] ? btf_type_seq_show+0x200/0x200
[ 34.870212] ? lock_acquire+0x3b0/0x3b0
[ 34.870726] ? security_capable+0x54/0x90
[ 34.871247] __x64_sys_bpf+0x1b2/0x310
[ 34.871761] ? __ia32_sys_bpf+0x310/0x310
[ 34.872285] ? bad_area_access_error+0x310/0x310
[ 34.872894] do_syscall_64+0x95/0x3f0
This patch uses refcount_set() instead.
Reported-by: Yonghong Song <yhs@fb.com>
Tested-by: Yonghong Song <yhs@fb.com>
Change-Id: I61918a383eb08dd8fb9320dadd1f0e616f68af1b
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
2025-01-13 14:37:38 -03:00
..
2025-01-13 14:37:38 -03:00
2024-12-23 00:59:42 -03:00
2019-04-03 06:59:52 -07:00
2024-10-11 00:50:20 -03:00
2024-10-31 20:49:41 -03:00
2024-08-16 22:07:21 -03:00
2024-12-24 00:01:56 -03:00
2023-12-07 20:15:44 -03:00
2024-10-31 20:49:41 -03:00
2024-11-20 02:27:51 -03:00
2024-10-29 20:17:04 -03:00
2024-12-23 00:53:44 -03:00
2024-12-23 00:58:50 -03:00
2024-12-13 00:13:33 -03:00
2024-10-31 20:49:41 -03:00
2019-06-12 12:34:50 +00:00
2023-01-18 09:26:30 +01:00
2023-08-11 11:33:32 +02:00
2022-09-05 10:25:02 +02:00
2023-11-28 16:45:44 +00:00
2024-03-08 08:21:30 +00:00
2020-06-20 10:25:10 +02:00
2020-06-20 10:25:10 +02:00
2023-09-23 10:46:56 +02:00
2022-07-01 09:16:44 +00:00
2020-04-30 10:08:09 -07:00
2023-04-05 11:14:19 +02:00
2020-09-06 01:12:33 +05:30
2024-12-23 00:53:44 -03:00
2023-12-20 15:32:35 +01:00
2019-03-21 16:19:55 -07:00
2024-11-19 23:55:52 -03:00
2023-12-07 20:15:44 -03:00
2024-12-23 00:59:46 -03:00
2023-12-07 20:15:44 -03:00
2020-07-12 21:32:07 -07:00
2019-06-25 03:05:18 -07:00
2022-06-10 15:41:47 +07:00
2020-01-29 17:06:43 -08:00
2020-01-13 19:40:11 +00:00
2023-08-11 11:33:34 +02:00
2022-07-02 16:18:11 +02:00
2019-06-12 12:35:03 +00:00
2020-04-24 08:00:44 +02:00
2024-06-04 16:33:29 -03:00
2024-11-02 20:11:24 -03:00
2024-03-27 17:56:46 -03:00
2024-09-29 17:32:34 -03:00
2022-07-01 09:14:41 +00:00
2023-12-07 20:15:44 -03:00
2020-04-02 16:34:20 +02:00
2023-11-28 16:45:43 +00:00
2024-03-25 23:54:05 -03:00
2024-07-15 17:44:31 +00:00
2021-09-22 11:45:32 +02:00
2022-07-31 09:36:45 +00:00
2022-08-25 11:11:24 +02:00
2022-06-14 16:53:43 +02:00
2024-11-01 22:39:10 -03:00
2020-08-26 10:29:54 +02:00
2020-06-02 16:13:43 +00:00
2022-02-16 12:44:52 +01:00
2022-07-31 09:36:45 +00:00
2024-10-31 20:49:41 -03:00
2021-02-07 14:47:41 +01:00
2024-05-10 15:48:33 -03:00
2022-07-31 09:36:45 +00:00
2024-04-18 09:46:38 -03:00
2019-02-05 17:36:19 -07:00
2024-12-16 13:44:56 -03:00
2020-06-17 12:53:11 +05:30
2022-04-06 13:18:17 +07:00
2022-04-06 13:18:17 +07:00
2022-02-23 11:57:34 +01:00
2020-10-14 09:51:10 +02:00
2021-05-22 10:57:35 +02:00
2022-04-06 13:18:49 +07:00
2024-10-10 10:27:24 +00:00
2020-08-05 11:41:56 +05:30
2019-03-21 16:19:56 -07:00
2024-12-23 00:53:44 -03:00