From patchwork Thu Sep 17 05:12:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 1365868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=o3xe9pPx; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BsQBM5VJNz9sRR for ; Thu, 17 Sep 2020 15:14:35 +1000 (AEST) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A435614783E66; Wed, 16 Sep 2020 22:14:27 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::102b; helo=mail-pj1-x102b.google.com; envelope-from=geliangtang@gmail.com; receiver= Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3A1B814783E64 for ; Wed, 16 Sep 2020 22:14:25 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id b17so618212pji.1 for ; Wed, 16 Sep 2020 22:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=HSbHTllNK0Kk4uuIq6jtB4e0ndKGpDVisSXL62O2Fko=; b=o3xe9pPxxU3tJPDTaCM3oTfQXvS25GPkaC1cgJI6mjYZgJMCJhSeP/PpjIOnBn8L/Y qi7xP+ozXsckeYgCxLBVF63s6TmTqxFwW64PKHJRvSF7pH0xY4KJyRl9pP63ooe/SAjE wtxJ61uFrUlgCSfXIfIhq/+QGh3HvbpmkmYOBFKiAmdhzz2fL6nynhtfTt4/N18Ka/qm SbrIC+0ioWWjA+FYp5DFGSXs0c8ienzdtx1Iq5OgtTt3ANFZMONf+xlTlvINPUm1bEGG wetgFxye4LB9xh52JGRPMLb7A9iEOmrRNRAKRaWWfvVpDt4dEpW52ByRwXJbdkI0uCSQ Hpzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HSbHTllNK0Kk4uuIq6jtB4e0ndKGpDVisSXL62O2Fko=; b=K6TIi6waroB217fK/9Ejb131g4WHJAb1vXgLEJ6wPXg7U2FuxLezp69A/M15pmLmNu 41BGkwrogwUkr4lmI8TOVMOmMuKuqwQYWVh6xIf58xiRFWNaDTSeT5OXTFBf79Lziq99 9JSbKme4RtHFfUzjvqU1CFGqXtxcUbj/yFfXC5gLp1W6SdxNZ8EYCL4IL+i46Re1XzdV HTMiUQQgLlIH4UhmgIVk49Q3uK68mJAymiDcv5XMeUogVkrljY24gZAabnxBezGXB8Rb AyoLaOq7QK/unnK2qR+EcWO1B6DVMcRXXTj+6eOdKPkOJvMbKgNGBj9CvNih+UHVdFF3 F94w== X-Gm-Message-State: AOAM531HrsLB/NWPcxPnuQ/aKnTmjPm8MAMiisevEMhgHuAs4AiMqR8a X/IYzkCuHE0HWbFYw5EVLyuoWn1ZzJbwFQ== X-Google-Smtp-Source: ABdhPJxKLw3Z9EXC+LMZYK4dyQm6gKPFy3KL2BCgXVITeUFIbKcDCaHAb7+MXP0bKZo+Fj1YztwwqQ== X-Received: by 2002:a17:90a:2ecb:: with SMTP id h11mr6586762pjs.195.1600319664321; Wed, 16 Sep 2020 22:14:24 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id g32sm16340328pgl.89.2020.09.16.22.14.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 22:14:23 -0700 (PDT) From: Geliang Tang To: mptcp@lists.01.org Date: Thu, 17 Sep 2020 13:12:09 +0800 Message-Id: <5f006df48114968c8919cfd35424821e53b26b15.1600319465.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.17.1 Message-ID-Hash: 7RNUC55KEAOVCX5KMZBERHGCZMXIDQOE X-Message-ID-Hash: 7RNUC55KEAOVCX5KMZBERHGCZMXIDQOE X-MailFrom: geliangtang@gmail.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address CC: Geliang Tang X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [MPTCP][PATCH mptcp-next] Squash-to: "mptcp: remove addr and subflow in PM netlink v9" Part 2 List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch fixed BUG in mptcp_pm_free_anno_list(), mptcp_pm_free_anno_list may be called when PM has not been inited. Then we'll get the "NULL pointer dereference" BUG. This patch added a flag to mark whether PM has been inited. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/90 Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 1 + net/mptcp/pm_netlink.c | 3 +++ net/mptcp/protocol.h | 1 + 3 files changed, 5 insertions(+) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 6ca88422e774..60e9a0d2ba1d 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -243,6 +243,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) INIT_LIST_HEAD(&msk->pm.anno_list); mptcp_pm_nl_data_init(msk); + WRITE_ONCE(msk->pm.inited, true); } void __init mptcp_pm_init(void) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 8780d618a05a..9afd66adffe2 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -214,6 +214,9 @@ void mptcp_pm_free_anno_list(struct mptcp_sock *msk) pr_debug("msk=%p\n", msk); + if (!READ_ONCE(msk->pm.inited)) + return; + spin_lock_bh(&msk->pm.lock); list_for_each_entry_safe(entry, tmp, &msk->pm.anno_list, list) { list_del(&entry->list); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index db1e5de2fee7..a33ec4eae071 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -171,6 +171,7 @@ struct mptcp_pm_data { bool accept_addr; bool accept_subflow; bool add_addr_echo; + bool inited; u8 add_addr_signaled; u8 add_addr_accepted; u8 local_addr_used;