Davide Caratti
8ec9897ec2
netlabel: fix RCU annotation for IPv4 options on socket creation
...
Xiumei reports the following splat when netlabel and TCP socket are used:
=============================
WARNING: suspicious RCU usage
6.9.0-rc2+ #637 Not tainted
-----------------------------
net/ipv4/cipso_ipv4.c:1880 suspicious rcu_dereference_protected() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by ncat/23333:
#0 : ffffffff906030c0 (rcu_read_lock){....}-{1:2}, at: netlbl_sock_setattr+0x25/0x1b0
stack backtrace:
CPU: 11 PID: 23333 Comm: ncat Kdump: loaded Not tainted 6.9.0-rc2+ #637
Hardware name: Supermicro SYS-6027R-72RF/X9DRH-7TF/7F/iTF/iF, BIOS 3.0 07/26/2013
Call Trace:
<TASK>
dump_stack_lvl+0xa9/0xc0
lockdep_rcu_suspicious+0x117/0x190
cipso_v4_sock_setattr+0x1ab/0x1b0
netlbl_sock_setattr+0x13e/0x1b0
selinux_netlbl_socket_post_create+0x3f/0x80
selinux_socket_post_create+0x1a0/0x460
security_socket_post_create+0x42/0x60
__sock_create+0x342/0x3a0
__sys_socket_create.part.22+0x42/0x70
__sys_socket+0x37/0xb0
__x64_sys_socket+0x16/0x20
do_syscall_64+0x96/0x180
? do_user_addr_fault+0x68d/0xa30
? exc_page_fault+0x171/0x280
? asm_exc_page_fault+0x22/0x30
entry_SYSCALL_64_after_hwframe+0x71/0x79
RIP: 0033:0x7fbc0ca3fc1b
Code: 73 01 c3 48 8b 0d 05 f2 1b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 29 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d d5 f1 1b 00 f7 d8 64 89 01 48
RSP: 002b:00007fff18635208 EFLAGS: 00000246 ORIG_RAX: 0000000000000029
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fbc0ca3fc1b
RDX: 0000000000000006 RSI: 0000000000000001 RDI: 0000000000000002
RBP: 000055d24f80f8a0 R08: 0000000000000003 R09: 0000000000000001
R10: 0000000000020000 R11: 0000000000000246 R12: 000055d24f80f8a0
R13: 0000000000000000 R14: 000055d24f80fb88 R15: 0000000000000000
</TASK>
The current implementation of cipso_v4_sock_setattr() replaces IP options
under the assumption that the caller holds the socket lock; however, such
assumption is not true, nor needed, in selinux_socket_post_create() hook.
Let all callers of cipso_v4_sock_setattr() specify the "socket lock held"
condition, except selinux_socket_post_create() _ where such condition can
safely be set as true even without holding the socket lock.
Fixes: f6d8bd051c39 ("inet: add RCU protection to inet->opt")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Link: https://lore.kernel.org/r/f4260d000a3a55b9e8b6a3b4e3fffc7da9f82d41.1715359817.git.dcaratti@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-05-13 14:58:12 -07:00
..
2023-03-27 02:33:48 +00:00
2024-04-24 16:26:11 -04:00
2023-08-10 18:24:48 -07:00
2024-03-13 09:23:48 +01:00
2024-04-03 19:32:03 -07:00
2024-04-11 12:13:11 +02:00
2023-12-15 11:01:27 +00:00
2024-03-05 11:21:18 -08:00
2024-02-19 12:30:27 -08:00
2023-06-15 22:33:26 -07:00
2024-02-05 11:08:06 +00:00
2024-01-02 12:41:16 +00:00
2024-02-02 10:57:55 -08:00
2024-04-09 17:09:05 -07:00
2023-12-24 15:22:50 +00:00
2024-04-25 08:37:02 -07:00
2023-12-15 10:37:35 +00:00
2022-07-22 12:53:22 +01:00
2023-03-21 21:32:18 -07:00
2023-03-18 12:23:34 +00:00
2022-08-09 22:14:02 -07:00
2021-12-13 12:34:09 +00:00
2024-02-06 13:17:54 +01:00
2022-11-02 20:38:13 -07:00
2024-02-06 13:17:54 +01:00
2024-02-06 13:17:54 +01:00
2021-03-26 17:43:55 +01:00
2024-02-09 10:01:09 -08:00
2022-11-16 11:31:47 +02:00
2024-03-25 15:23:06 +01:00
2024-03-06 21:01:26 +01:00
2023-01-27 11:19:46 +00:00
2024-05-13 14:58:12 -07:00
2021-12-22 15:03:47 -08:00
2022-07-22 12:53:22 +01:00
2023-07-14 20:39:29 -07:00
2022-07-24 18:39:17 -06:00
2023-07-27 17:17:32 -07:00
2022-07-22 12:53:22 +01:00
2023-01-20 09:33:22 +00:00
2023-10-20 11:34:51 +01:00
2024-02-28 10:39:21 +00:00
2023-08-14 08:01:06 +01:00
2023-10-24 13:08:14 -07:00
2024-01-31 12:30:47 +00:00
2021-11-29 19:50:45 -08:00
2022-12-05 21:58:27 -08:00
2023-08-22 13:19:02 +02:00
2024-02-06 11:45:53 +01:00
2024-03-05 19:21:17 -08:00
2022-07-22 12:53:22 +01:00
2022-07-22 12:53:22 +01:00
2022-07-22 12:53:22 +01:00
2021-12-06 16:06:02 -08:00
2024-01-03 16:42:48 -08:00
2022-07-28 22:21:54 -07:00
2023-08-02 10:09:31 +01:00
2023-10-06 11:37:02 +01:00
2023-11-02 09:31:02 +01:00
2023-04-12 16:40:39 -07:00
2022-12-01 15:09:10 +01:00
2023-08-08 15:58:23 -07:00
2022-07-22 12:53:22 +01:00
2021-10-18 12:54:41 +01:00
2024-02-23 18:17:36 -08:00
2022-10-31 10:43:04 +00:00
2021-01-29 20:39:14 -08:00
2024-05-02 11:02:48 +02:00
2023-06-10 00:11:41 -07:00
2022-07-22 12:53:22 +01:00
2022-07-22 12:53:22 +01:00
2023-07-28 14:07:59 -07:00
2024-03-07 21:12:43 -08:00
2022-07-22 12:53:22 +01:00
2021-06-28 14:29:45 -07:00
2023-10-12 15:14:27 +03:00
2023-11-20 11:43:03 +01:00
2024-02-26 18:40:34 -08:00
2022-07-22 12:53:22 +01:00
2023-08-15 13:57:51 -07:00
2023-08-14 07:06:13 +01:00
2024-03-25 19:51:57 -07:00
2022-02-07 20:12:45 -08:00
2021-10-15 11:33:08 +01:00
2023-07-14 20:39:29 -07:00
2023-12-22 22:15:35 +00:00
2024-03-06 12:37:06 +00:00
2023-12-22 22:15:35 +00:00
2024-02-28 11:19:41 +00:00
2021-11-16 13:16:54 +00:00
2024-02-12 10:24:12 +00:00
2024-03-01 08:42:31 +00:00
2022-04-25 11:40:45 +01:00
2024-02-26 11:46:12 +00:00
2024-04-08 11:51:04 +01:00
2023-04-22 01:39:41 +02:00
2024-01-26 21:05:26 -08:00
2022-09-29 07:18:00 +02:00
2022-07-22 12:53:22 +01:00
2022-10-31 20:14:27 -07:00
2023-10-30 14:36:57 -07:00
2024-03-01 08:42:31 +00:00
2023-08-22 21:40:40 +02:00
2023-06-12 21:13:23 -07:00
2021-03-23 14:14:50 -07:00
2023-08-04 15:33:17 -07:00
2023-08-04 15:33:17 -07:00
2022-07-22 12:53:22 +01:00
2023-07-20 10:46:28 +02:00
2021-10-13 09:40:46 -07:00
2024-01-19 21:30:09 -08:00
2022-07-22 12:53:22 +01:00
2022-07-22 12:53:22 +01:00
2022-07-28 11:29:36 +02:00
2021-11-07 19:25:29 +00:00
2023-08-18 16:05:26 +02:00
2024-04-08 20:11:34 +02:00
2022-10-12 12:57:19 +02:00
2024-04-25 08:20:54 -07:00
2024-02-29 14:24:56 -08:00
2021-10-29 13:23:51 +01:00
2021-03-26 15:14:56 -07:00
2022-07-22 12:53:22 +01:00
2023-08-22 17:31:18 -07:00
2022-11-18 12:14:55 +00:00
2022-07-22 12:53:22 +01:00
2023-08-07 08:53:55 +01:00
2023-11-28 12:18:29 +01:00
2022-05-11 12:43:10 +01:00
2024-02-07 18:55:10 -08:00
2021-12-10 06:38:26 -08:00
2024-03-07 21:13:26 -08:00
2023-12-04 18:04:05 -08:00
2022-07-22 12:53:22 +01:00
2023-11-20 10:15:16 -08:00
2024-05-13 14:58:12 -07:00
2023-12-19 15:31:40 +01:00
2024-02-20 09:22:58 +01:00
2022-07-22 12:53:22 +01:00
2024-03-11 14:14:07 -07:00
2023-11-20 11:43:45 +01:00
2023-07-14 20:39:29 -07:00
2023-08-04 15:33:50 -07:00
2023-07-14 20:39:30 -07:00
2023-06-02 09:55:22 +01:00
2024-02-02 10:57:55 -08:00
2024-02-02 10:57:55 -08:00
2022-07-22 12:53:22 +01:00
2024-03-07 21:12:43 -08:00
2021-08-09 15:34:21 -07:00
2022-07-22 12:53:22 +01:00
2023-04-06 12:01:20 -07:00
2023-03-17 08:56:37 +00:00
2022-10-11 17:42:58 -06:00
2023-09-18 09:44:05 +02:00
2024-03-19 19:35:59 -07:00
2022-08-01 11:59:23 -07:00
2024-02-12 17:33:05 -08:00
2023-06-19 11:32:58 -07:00
2024-03-07 21:12:43 -08:00
2023-07-14 20:39:30 -07:00
2024-02-26 11:46:12 +00:00
2024-04-17 18:22:52 -07:00
2024-01-26 20:34:25 -08:00
2022-07-22 12:53:22 +01:00
2022-01-04 12:17:35 +00:00
2021-04-28 14:06:45 -07:00
2023-12-26 20:24:33 +00:00
2022-10-25 11:35:16 +02:00
2024-04-23 19:02:24 -07:00
2023-10-04 11:49:20 -07:00
2022-07-22 12:53:22 +01:00
2022-07-18 11:24:10 +01:00
2024-02-16 09:36:37 +00:00
2024-02-14 10:49:37 +01:00
2024-01-04 18:06:46 -08:00
2023-12-04 14:45:26 -08:00
2024-02-28 10:39:22 +00:00
2023-10-23 15:01:53 -07:00
2023-07-28 14:07:59 -07:00
2024-04-25 08:32:37 -07:00
2023-08-01 15:06:27 -07:00
2022-12-12 15:04:39 -08:00
2022-07-22 12:53:22 +01:00
2023-10-23 08:48:57 +01:00
2023-08-07 08:53:55 +01:00
2023-09-14 16:16:36 +02:00
2023-11-16 22:33:31 +00:00
2023-03-18 12:23:34 +00:00
2022-07-22 12:53:22 +01:00
2024-01-24 16:24:06 -08:00
2024-03-19 13:47:29 +01:00
2023-12-14 16:38:59 +01:00
2024-04-26 06:44:33 +02:00
2023-12-13 16:16:40 -08:00