From nobody Fri Apr 19 04:51:31 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp4191671uad; Wed, 6 Jul 2022 04:18:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uFduDolfparcdE1I3uNUC6L6IXMDrTSEwO8CZEGhbkyfU2X+b9CxSaB8YKKP+neJGIs82w X-Received: by 2002:a05:6870:b40c:b0:10b:8a3c:b13d with SMTP id x12-20020a056870b40c00b0010b8a3cb13dmr24495886oap.108.1657106334206; Wed, 06 Jul 2022 04:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657106334; cv=none; d=google.com; s=arc-20160816; b=MTKLyn33uyqzal9QLsDoO/hZA4kGAqAWiHJKn++w0TZu2t0lpS9mC1HYdDo+GrL3bH 8sFaNZkyZ3tdfAl9sCwLzkoek6wSdy+4n0CdHSRVRE82Fz1Mg/5/qfk5y9xUNZ/hG1DL JJ8LY6BLNjUwY3BGgDQ4nrBsS5ZlB8Ewq5jGEXUA3k8DTNuDBuLfErrBtI0d00b+jR6F n3idff/j6suZrl68k4T1pwV3EMSo0x4IJwJF2vfR25n7J4EnZzNteTpCOgjLJelSiTW/ xNK+vGsvMgVqtl7zkrQSjoJ+khctVSHTcz2cmNl1rTyUXpVCAan61gXAQuQLHs0TTWmk a9ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=n/+33ewEEP3NNc8FkZf4PAVIf5CFGh0Xsp8W3PvO8KM=; b=rtSuRHxzT7RrqyT3s+gJTtPYAoQnswC+rc/9mdqdORmi/NoJH5d+bAAKNF/OSFiWD3 HWGGfFGm6xI4ionnQkvPYCAtlf8JtEtigZ+ODeTIts1kpj0eLh6vVTBj7dCFmWuzbYTB Cfi/rkX3hCwK5QRJyexBUdY7FA96v6K7fknoD4n1kt1d2LWzFjTV1FdnpfU0FrK9tnRA EBuBqQFGrWGDJlDz8IqLOR1wA48AI/o48zCKu8DoDoCnxlFgCzdR61EF0RTBcRd5BQoQ Gj7xD0R6bhiK/TFr5XojVNkf2rEStqYXwt7ua6SC8NcTc83UoTG90cQdtPPptRGRkgZc hL6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YSlA0npo; spf=pass (google.com: domain of mptcp+bounces-5969-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-5969-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q9-20020a0568080ec900b00335a1dbddbbsi37527723oiv.298.2022.07.06.04.18.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2022 04:18:54 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5969-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YSlA0npo; spf=pass (google.com: domain of mptcp+bounces-5969-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-5969-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0622D2809A1 for ; Wed, 6 Jul 2022 11:18:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA5202F55; Wed, 6 Jul 2022 11:18:51 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B63DA2F3A for ; Wed, 6 Jul 2022 11:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657106328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n/+33ewEEP3NNc8FkZf4PAVIf5CFGh0Xsp8W3PvO8KM=; b=YSlA0npo9y++eZsCzc5RruCbNaZsnaTPm6MzeC+hdtDP+ETMltMHZRgfaoBF/pM4IySwrz kOU6VIHnRSLWEDM+pMRZ1J70p4SOkszjnrUVg7LH1IddD2/TYp+mthcSY0OS6M+pr9NlHc ebUkEMquM//sP/bEzWftH1wLy6edadc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-LT9AhhAdN8-1cBnvjcP2OA-1; Wed, 06 Jul 2022 07:18:47 -0400 X-MC-Unique: LT9AhhAdN8-1cBnvjcP2OA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63593101A586 for ; Wed, 6 Jul 2022 11:18:47 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id D85DB1121315 for ; Wed, 6 Jul 2022 11:18:46 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-net] mptcp: fix subflow traveral at disconnect time Date: Wed, 6 Jul 2022 13:18:29 +0200 Message-Id: <2c5147569717a1c879b291230d460e8e85992878.1657106043.git.pabeni@redhat.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" At disconnect time the MPTCP protocol traverse the subflows list closing each of them. In some circumstances - MPJ subflow, passive MPTCP socket, the latter operation can remove the subflow from the list, invalidating the current iterator. Address the issue using the safe list traversing helper variant. Reported-by: van fantasy Fixes: b29fcfb54cd7 ("mptcp: full disconnect implementation") Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Tested-by: Matthieu Baerts --- I think this should go soon upstream, sending here to trigger the CI A pktdrill test will follow. --- net/mptcp/protocol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 10bfa2b78206..0264642f133f 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2881,12 +2881,12 @@ static void mptcp_copy_inaddrs(struct sock *msk, co= nst struct sock *ssk) =20 static int mptcp_disconnect(struct sock *sk, int flags) { - struct mptcp_subflow_context *subflow; + struct mptcp_subflow_context *subflow, *tmp; struct mptcp_sock *msk =3D mptcp_sk(sk); =20 inet_sk_state_store(sk, TCP_CLOSE); =20 - mptcp_for_each_subflow(msk, subflow) { + list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); =20 __mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_FASTCLOSE); --=20 2.35.3