android_kernel_xiaomi_sm8450/net/mptcp
Matthieu Baerts (NGI0) ddee5b4b6a mptcp: pm: avoid possible UaF when selecting endp
commit 48e50dcbcbaaf713d82bf2da5c16aeced94ad07d upstream.

select_local_address() and select_signal_address() both select an
endpoint entry from the list inside an RCU protected section, but return
a reference to it, to be read later on. If the entry is dereferenced
after the RCU unlock, reading info could cause a Use-after-Free.

A simple solution is to copy the required info while inside the RCU
protected section to avoid any risk of UaF later. The address ID might
need to be modified later to handle the ID0 case later, so a copy seems
OK to deal with.

Reported-by: Paolo Abeni <pabeni@redhat.com>
Closes: https://lore.kernel.org/45cd30d3-7710-491c-ae4d-a1368c00beb1@redhat.com
Fixes: 01cacb00b3 ("mptcp: add netlink-based PM")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20240819-net-mptcp-pm-reusing-id-v1-14-38035d40de5b@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ Conflicts in pm_netlink.c, because quite a bit of new code has been
  added around since commit 86e39e04482b ("mptcp: keep track of local
  endpoint still available for each msk"), and commit 2843ff6f36db
  ("mptcp: remote addresses fullmesh"). But the issue is still there.
  The conflicts have been resolved using the same way: by adding a new
  parameter to select_local_address() and select_signal_address(), and
  use it instead of the pointer they were previously returning. The code
  is simpler in this version, this conflict resolution looks safe. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-12 11:06:44 +02:00
..
crypto_test.c mptcp: move crypto test to KUNIT 2020-06-26 16:21:39 -07:00
crypto.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-08-05 20:13:21 -07:00
ctrl.c mptcp: enable JOIN requests even if cookies are in use 2020-07-31 16:55:32 -07:00
diag.c mptcp: correct MPTCP_SUBFLOW_ATTR_SSN_OFFSET reserved size 2024-09-04 13:17:32 +02:00
Kconfig mptcp: depends on IPV6 but not as a module 2020-10-21 08:05:40 -07:00
Makefile mptcp: enable JOIN requests even if cookies are in use 2020-07-31 16:55:32 -07:00
mib.c mptcp: mib: count MPJ with backup flag 2024-08-19 05:41:21 +02:00
mib.h mptcp: mib: count MPJ with backup flag 2024-08-19 05:41:21 +02:00
mptcp_diag.c mptcp: don't return sockets in foreign netns 2021-10-06 15:55:52 +02:00
options.c mptcp: pr_debug: add missing \n at the end 2024-09-12 11:06:44 +02:00
pm_netlink.c mptcp: pm: avoid possible UaF when selecting endp 2024-09-12 11:06:44 +02:00
pm.c mptcp: pr_debug: add missing \n at the end 2024-09-12 11:06:44 +02:00
protocol.c mptcp: pr_debug: add missing \n at the end 2024-09-12 11:06:44 +02:00
protocol.h mptcp: pr_debug: add missing \n at the end 2024-09-12 11:06:44 +02:00
subflow.c mptcp: pr_debug: add missing \n at the end 2024-09-12 11:06:44 +02:00
syncookies.c mptcp: don't return sockets in foreign netns 2021-10-06 15:55:52 +02:00
token_test.c mptcp: don't return sockets in foreign netns 2021-10-06 15:55:52 +02:00
token.c mptcp: don't return sockets in foreign netns 2021-10-06 15:55:52 +02:00