Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1276843rdb; Mon, 19 Feb 2024 09:36:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJTkjPr5K/Wg1p0lW08R+VTuTA0HXFI4+2si4wuw3t77DLoik5F0ylV0uX8qHHFVayfZgfRH4RhDgCp5AcVqfqYfXsD19L6VHWh4fWgg== X-Google-Smtp-Source: AGHT+IGF4CH8dTHmnHbmydn4WX7vCu/sGQ5a7VYhojnSpgNu4NkIiG64CNJ9wPlksUPk/uihdPkr X-Received: by 2002:a17:902:c949:b0:1dc:43d:962 with SMTP id i9-20020a170902c94900b001dc043d0962mr1822920pla.42.1708364178975; Mon, 19 Feb 2024 09:36:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708364178; cv=pass; d=google.com; s=arc-20160816; b=CuOsGs6UStwbd5rUK2K7tJULiATcYjYILlXH+tpGhfe5OAQPCoT7A3p4CiHGt+OskF PVUaii1tyYht3tPD6KVQKqQv9uAfjVK2lwXQ2fzGgBTJfLJvtKoospFX0si6kU/Vgeqr Mb/C2JuoCyPy9xS5rY/GBEGvi5nK/LoOhx/H3ttc6xpdramH9gEGT6+yuW+8gdThrtLs fPnB++a2qVhMZYZEizSijNMaqqVv7/MxrCZdh35jkhDphYJLC25KB2UfPPjlsMpam4Ih HsQTto2HGuMIY/bIHqhAamXvKHXaOsXckCDNob+T1pyBSrekjMT9nK3Pe0SEhJka3BY0 cRoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=TzE2ImKo71OrGpPwUdYL/4pHbPBLfbVgHi0cr9m3U8k=; fh=vBYPWLrAssATIIUMFsvUwJwTvYhXRJ8FiZBnJvBSu38=; b=dffAtHqC44AlUzfpcIoXF1A3L1LXdzXR6LoVqaAXGKqF1+IUt2QMsJt14g3UldsCEj Vs+mK9GMbA8akLVitrPM/lS+GT+2QtQkH1zPDVTd9jZpE82GB2vWQtJgEiGBqhXSKP0a I96tc8XoviVEm25O2ov2Hw1SgtUQgVyf9t2OkEb2UwMn/smJGv4Gz8g4Dh/sxkP46ZFf mtSi55UHOCWQY1OkkyDRQ0qZpUnQJqI04PwrJNvg1+4E9b115/X+IlkgEPzbcLz0hw6p DVC5hIcgMGfTv1J29Gz+MaEpJCQdw/mKn/8+PXw0u4AqP5adjnsyNzXntVRbzpDXuDfd ZSSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sL45fs6s; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-71747-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71747-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q13-20020a17090311cd00b001da195b41dfsi4780295plh.390.2024.02.19.09.36.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:36:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71747-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sL45fs6s; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-71747-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71747-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 36E50B23F25 for ; Mon, 19 Feb 2024 17:22:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F7FA44C89; Mon, 19 Feb 2024 17:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sL45fs6s" Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F5CB446C4 for ; Mon, 19 Feb 2024 17:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363327; cv=none; b=lyEqIBzqeaf2sAjqq5wTmWXvXlDCUlP6mZ0Tu+ZKdm7GjVQvVyCDl3aXtdnU9k3r76grSe4yPPXVAW2HstUDzUrDcO09FBzn6x95Zk/rhD2FgEKpY1tdGJXrRyg9mt9DDpvr1/rkNAK7SUrurovI/QhNnxgYw+Nx+xMv/IY7atk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363327; c=relaxed/simple; bh=D4hbJX7uGV8vohd/O7pYTtYq3FdJW6tASIcFVTSogHk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=q/DCT6Atc6L3hHg/mEaXlFn0z39QYccwLcMMXH5qgTHThx9ubB4o7MdxmmRpAcBgxdwj/T6njmM0d80jGKhR9V61DbNoL0IgipPHC/dVBeNrp24H8vWmDIn1Mt1G5xualjzdJK91bzynQiXVfYDheM1IUbVtfMipN0klY5sUM18= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sL45fs6s; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-411d9e901dcso108535e9.1 for ; Mon, 19 Feb 2024 09:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708363324; x=1708968124; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TzE2ImKo71OrGpPwUdYL/4pHbPBLfbVgHi0cr9m3U8k=; b=sL45fs6sLPjwI75d4uFu8XxABRB/V521bZaKwne7qpuU6wrVTEUIA4UD0hzj9EP1O8 B1KKCZt+3VgGoF7Eo2IK+Ni47YoRntvhkFlPY+A30st5Hr1LZsE870leOriwliLFM4QA 31E+8KBHTjFLEA+KJaLBmftERuQMO0lMH4rO1dbFlAFgXkw+cHn0FrNw8SCEU0nZGulC SwhH+okvFFFS5sgOktS/IHc3YZD6XDQ/hCp7YNUskEC815Xaf5V69Ae0BrsidNm/K/am V2+XY8s87cXVXfMS1wl6/JChlHQIJQT+srZdiZQmJw+uP/TycvNIHtGv37Skm41h4kit Ly3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363324; x=1708968124; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TzE2ImKo71OrGpPwUdYL/4pHbPBLfbVgHi0cr9m3U8k=; b=l9K4Yxm63nlxbm0BZ3u2ApNbdVOkuYW6NOW9z3QnZQ5oomk/EDtiTNuFnvp2doArus KBl5ujtcE4kNGZalq33duQuNUYn4jyUsKGa7iy59DXpUTxF78oyKtw0ENXkPFLtXWOKr e1dM8XgvjKIwWxgY52hxLvGRXN9s5yW9qcHyaG9uSzkj4GijO5JiJK+/SjIUEF2cDcJx roAxujKXzEr7WJ3UkcHJFgd0N28eW7tAnVs6ipV39q2REY90dmgQFQ0/8vpH0ByiGXTs YcpxbzmEfHYQOw/CwMVFzr3N3qGzqvpi6tFcpHSZ3okt57QQwR2o4r+PteCO1RUV/de6 iuvg== X-Forwarded-Encrypted: i=1; AJvYcCVmV+yGCWMFHPTi6Qn1/104Wq7s7Pfq06QBRwuoiApasr3A3iNTtL1iNomZNGpB/1M4KNsxIFe9BBQtrtVtEQkO9lGtaZt8Czmqa/yA X-Gm-Message-State: AOJu0YwLmMn9+B19OoVn7XQ7J3Cuh4DrvB7/MTt+kbDJQs90X9ZlL0Tc 2lJuMCbLzwjE9u9Kqx4kWBxZFDHjDjt7WlIXOBsQE+HmDdI0n2LsnhhetA5+7eu8NUMwaKd3wnx 2YpbtzrcO+KaN8rq1XcJqid3k/Hu2GIYkUOal X-Received: by 2002:a05:600c:c08:b0:412:68a7:913a with SMTP id fm8-20020a05600c0c0800b0041268a7913amr116160wmb.4.1708363323800; Mon, 19 Feb 2024 09:22:03 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240215-upstream-net-20240215-misc-fixes-v1-0-8c01a55d8f6a@kernel.org> <20240215-upstream-net-20240215-misc-fixes-v1-3-8c01a55d8f6a@kernel.org> In-Reply-To: <20240215-upstream-net-20240215-misc-fixes-v1-3-8c01a55d8f6a@kernel.org> From: Eric Dumazet Date: Mon, 19 Feb 2024 18:21:52 +0100 Message-ID: Subject: Re: [PATCH net 03/13] mptcp: fix lockless access in subflow ULP diag To: "Matthieu Baerts (NGI0)" Cc: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Davide Caratti , Shuah Khan , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, stable@vger.kernel.org, Boris Pismenny , John Fastabend Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 15, 2024 at 7:25=E2=80=AFPM Matthieu Baerts (NGI0) wrote: > > From: Paolo Abeni > > Since the introduction of the subflow ULP diag interface, the > dump callback accessed all the subflow data with lockless. > > We need either to annotate all the read and write operation accordingly, > or acquire the subflow socket lock. Let's do latter, even if slower, to > avoid a diffstat havoc. > > Fixes: 5147dfb50832 ("mptcp: allow dumping subflow context to userspace") > Cc: stable@vger.kernel.org > Signed-off-by: Paolo Abeni > Reviewed-by: Mat Martineau > Signed-off-by: Matthieu Baerts (NGI0) > --- > Notes: > - This patch modifies the existing ULP API. No better solutions have > been found for -net, and there is some similar prior art, see > commit 0df48c26d841 ("tcp: add tcpi_bytes_acked to tcp_info"). > > Please also note that TLS ULP Diag has likely the same issue. > To: Boris Pismenny > To: John Fastabend > --- > include/net/tcp.h | 2 +- > net/mptcp/diag.c | 6 +++++- > net/tls/tls_main.c | 2 +- > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/include/net/tcp.h b/include/net/tcp.h > index dd78a1181031..f6eba9652d01 100644 > --- a/include/net/tcp.h > +++ b/include/net/tcp.h > @@ -2506,7 +2506,7 @@ struct tcp_ulp_ops { > /* cleanup ulp */ > void (*release)(struct sock *sk); > /* diagnostic */ > - int (*get_info)(const struct sock *sk, struct sk_buff *skb); > + int (*get_info)(struct sock *sk, struct sk_buff *skb); > size_t (*get_info_size)(const struct sock *sk); > /* clone ulp */ > void (*clone)(const struct request_sock *req, struct sock *newsk, > diff --git a/net/mptcp/diag.c b/net/mptcp/diag.c > index a536586742f2..e57c5f47f035 100644 > --- a/net/mptcp/diag.c > +++ b/net/mptcp/diag.c > @@ -13,17 +13,19 @@ > #include > #include "protocol.h" > > -static int subflow_get_info(const struct sock *sk, struct sk_buff *skb) > +static int subflow_get_info(struct sock *sk, struct sk_buff *skb) > { > struct mptcp_subflow_context *sf; > struct nlattr *start; > u32 flags =3D 0; > + bool slow; > int err; > > start =3D nla_nest_start_noflag(skb, INET_ULP_INFO_MPTCP); > if (!start) > return -EMSGSIZE; > > + slow =3D lock_sock_fast(sk); > rcu_read_lock(); I am afraid lockdep is not happy with this change. Paolo, we probably need the READ_ONCE() annotations after all.