From patchwork Thu May 19 03:15:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 12854480 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94217C433F5 for ; Thu, 19 May 2022 03:16:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232141AbiESDQV (ORCPT ); Wed, 18 May 2022 23:16:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231214AbiESDQT (ORCPT ); Wed, 18 May 2022 23:16:19 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB6B175B5 for ; Wed, 18 May 2022 20:16:10 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id h186so3875353pgc.3 for ; Wed, 18 May 2022 20:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7cGWxABWTSRnqkdVtl2RjsmthyMxxZ7L/JYrNk80LP8=; b=UYuzASZxKGeGCcE9fYC/vEyWX9E/NY4zkkS0tXi8T13+AhebTygGF7o9/RhwBdIzwW iTJk+i6b22Cp77qeVsGZ2Tzix5hjebDSSCiT2rY2ErWlg4Z6HTzhrKkWe0LpCzeaCu4F jR5+LjBuzTBozLA3nbJSYo/0p9v+SdT3vfnMBGu2soPyyRsDTxnhGTJ327K1k5tzlsUc hDRVidYhf7HGjyvHStTguykxRvnboftohCpQkFSm0Gg1y6x0+Fc+BYX/usyDCcofI0Oe YMPtfD40IxKlLjNmxIQigx3qcoFwjWe6h+DD0gH4WYNJSX7oh18lU8l0sED5/7/atOCU 4Iuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7cGWxABWTSRnqkdVtl2RjsmthyMxxZ7L/JYrNk80LP8=; b=QBbniJ6rVphvDSqWXwIbD9oOGlwlT38x+wxfGlYtjDpYyxW7ROzacbW4QIyH7Exmt+ oOhmmisHEAXWM4eC3ERWM1CrVNqNhq85mTm34B699xa1Xv0KvaTO665xBxEF0oU5cLmj V+Hmo/86Mbn18QTTzdadis4fi6ugmJiR4f1oXyvvq5P88bZZDYeg6nuAlFsna9JgSJ2X DXkTO4Q8eZXnXH/VjFROyTrJYEgqU1eV1jE+7qXHm+NxgSeRB1DPXoHVQJ1UVVzER52d m1SaQFyKWfmNkiQt/fddmVIH2ewrxbyQDtZHLTVXAXF0Ipm8X0JbL1gXj2o5G2nD6EEc Hnsw== X-Gm-Message-State: AOAM5328QHuTSnDavINsXs1qlthO5QYqqWWbDi432KYFRxfjI9zWXrti BUluf9qqxNumDi1HbOgcd/A= X-Google-Smtp-Source: ABdhPJw814agA3//hKtA2T6GO8o6Y3lu4bS1FABulsjhExk9ezEBpjRBMvx9Iyxqu+HXdYqQ9nTmiA== X-Received: by 2002:a63:111f:0:b0:3da:ed0d:7623 with SMTP id g31-20020a63111f000000b003daed0d7623mr2223445pgl.586.1652930170492; Wed, 18 May 2022 20:16:10 -0700 (PDT) Received: from localhost.localdomain ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id f186-20020a62dbc3000000b0050dc7628133sm2833459pfg.13.2022.05.18.20.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 20:16:09 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: ap420073@gmail.com Subject: [PATCH net v3 1/2] amt: fix gateway mode stuck Date: Thu, 19 May 2022 03:15:54 +0000 Message-Id: <20220519031555.3192-2-ap420073@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220519031555.3192-1-ap420073@gmail.com> References: <20220519031555.3192-1-ap420073@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If a gateway can not receive any response to requests from a relay, gateway resets status from SENT_REQUEST to INIT and variable about a relay as well. And then it should start the full establish step from sending a discovery message and receiving advertisement message. But, after failure in amt_req_work() it continues sending a request message step with flushed(invalid) relay information and sets SENT_REQUEST. So, a gateway can't be established with a relay. In order to avoid this situation, it stops sending the request message step if it fails. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo --- v3: - No changed. v2: - Separate patch. drivers/net/amt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 10455c9b9da0..2b4ce3869f08 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -943,7 +943,7 @@ static void amt_req_work(struct work_struct *work) if (amt->status < AMT_STATUS_RECEIVED_ADVERTISEMENT) goto out; - if (amt->req_cnt++ > AMT_MAX_REQ_COUNT) { + if (amt->req_cnt > AMT_MAX_REQ_COUNT) { netdev_dbg(amt->dev, "Gateway is not ready"); amt->qi = AMT_INIT_REQ_TIMEOUT; amt->ready4 = false; @@ -951,13 +951,15 @@ static void amt_req_work(struct work_struct *work) amt->remote_ip = 0; __amt_update_gw_status(amt, AMT_STATUS_INIT, false); amt->req_cnt = 0; + goto out; } spin_unlock_bh(&amt->lock); amt_send_request(amt, false); amt_send_request(amt, true); - amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true); spin_lock_bh(&amt->lock); + __amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true); + amt->req_cnt++; out: exp = min_t(u32, (1 * (1 << amt->req_cnt)), AMT_MAX_REQ_TIMEOUT); mod_delayed_work(amt_wq, &amt->req_wq, msecs_to_jiffies(exp * 1000)); From patchwork Thu May 19 03:15:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 12854481 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3166DC433F5 for ; Thu, 19 May 2022 03:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231453AbiESDQZ (ORCPT ); Wed, 18 May 2022 23:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231901AbiESDQU (ORCPT ); Wed, 18 May 2022 23:16:20 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 368CC19299 for ; Wed, 18 May 2022 20:16:13 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id gg20so3996166pjb.1 for ; Wed, 18 May 2022 20:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DhMAH9oZeK2H9XQyPbZeKbPmsdMY9wxoMSIAbnfOe5s=; b=Ch922lE+CFPiOdcPzg1+mqzxaCX/UK7EOhQ5IfntoFOopkjx5NDz3JtvNcGBcmngcb Xc9LeZ6uwLvc2w7vaNdRBD20H/GcJV20vqW+tgMFATNgrbKQ+4AeieAhUw7lSdBR4zPa DCV/t25E2GweYzTkB5JseDHmqic+Ck9dnHhJF45AUycWU9cyAGMLBhhhdqH8pk2ckEky LTwTdde3QUsAl5E41/Uv8OjC8CwlDSzGK52Li844jN15XUbJ6H6u2xPDxLAROBP/Q6RN D2uJq67Z/Le2RmYW2WuCrOGvTExXA+cQB1RjO/fQzOk82VBbt9OAlzUMSaO0XQaohDmi OLmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DhMAH9oZeK2H9XQyPbZeKbPmsdMY9wxoMSIAbnfOe5s=; b=WZkcaRsnuyIw+2U/9CxXgjr8Qob13Zgxu+HUkoFwqW0ydjY85ef3JnRClmmcAS83Yw QE4IjakPD/LuY5Lq+NY0LDjlNnj38qTAP8BAu02y1r9ndEkWhHyuUxmBdn/y/QQwrZLH DtluWvzmtY+ZVUq619PEZIDQRWRsbHdZ2EQXcsBzOOq/2Fu2E73hKi1JdM6gMHgKMy1B JGuwZ2Ac/Fk+lOVxJZMvyqOBYUEGIryMhrLMOJqg9jJoQhVu11F+5Twj/GPdXMSAlQ+N LlqzMhndbTsvfWlzwG30TKCCzPwEttBxA+7lGxzKjjqLLRKjr4ffsyvAQ1D84PmCzr11 nvWA== X-Gm-Message-State: AOAM530knqeOdDWN7j5gYAd3mNIAWrVDx2IJ7pXdcKVJjv+g2YAa9sEq 7GCaykwT+8Z7jqB2nRFY5eKW8Y6pgh4= X-Google-Smtp-Source: ABdhPJzCpEJvP9nscV//K2NaJPZxaHtFazXEH7ixjVCRJggzEZPS90DQDOJJviGRsCXHcAd3k3IKPQ== X-Received: by 2002:a17:90a:2e83:b0:1da:3273:53ab with SMTP id r3-20020a17090a2e8300b001da327353abmr3445705pjd.14.1652930173127; Wed, 18 May 2022 20:16:13 -0700 (PDT) Received: from localhost.localdomain ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id f186-20020a62dbc3000000b0050dc7628133sm2833459pfg.13.2022.05.18.20.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 20:16:12 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: ap420073@gmail.com Subject: [PATCH net v3 2/2] amt: fix memory leak for advertisement message Date: Thu, 19 May 2022 03:15:55 +0000 Message-Id: <20220519031555.3192-3-ap420073@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220519031555.3192-1-ap420073@gmail.com> References: <20220519031555.3192-1-ap420073@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When a gateway receives an advertisement message, it extracts relay information and then it should be freed. But the advertisement handler doesn't free it. So, memory leak would occur. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo --- v3: - Update git log message. - Do not increase rx_dropped stats twice. v2: - Separate patch. drivers/net/amt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 2b4ce3869f08..de4ea518c793 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -2698,9 +2698,8 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) err = true; goto drop; } - if (amt_advertisement_handler(amt, skb)) - amt->dev->stats.rx_dropped++; - goto out; + err = amt_advertisement_handler(amt, skb); + break; case AMT_MSG_MULTICAST_DATA: if (iph->saddr != amt->remote_ip) { netdev_dbg(amt->dev, "Invalid Relay IP\n");