From patchwork Fri Dec 13 14:17:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 11291077 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F5D6138D for ; Fri, 13 Dec 2019 20:52:09 +0000 (UTC) Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55C672469B for ; Fri, 13 Dec 2019 20:52:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55C672469B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=libteam-bounces@lists.fedorahosted.org Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id DACEC605BAFA; Fri, 13 Dec 2019 14:17:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org DACEC605BAFA Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id D0FE25BEA066C; Fri, 13 Dec 2019 14:17:37 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 3DED05BEA0669; Fri, 13 Dec 2019 14:17:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mailman01.phx2.fedoraproject.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=disabled version=3.4.0 Received: from smtp-mm-ib01.fedoraproject.org (smtp-mm-ib01.vpn.fedoraproject.org [192.168.1.83]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id E187A5BEA065F for ; Fri, 13 Dec 2019 14:17:31 +0000 (UTC) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by smtp-mm-ib01.fedoraproject.org (Postfix) with ESMTPS id 740E4605D2EB for ; Fri, 13 Dec 2019 14:17:31 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id l127so1561133pfl.1 for ; Fri, 13 Dec 2019 06:17:31 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=vmfph1/fchdpKVcfw19QmQC4SNPgUscweYa20TRU7EE=; b=Cnan0OQohXSruyrBiuMjcdXjzmK48VpueJov05pitWyWCO/KAPVzvolq3yv5jeiq9n gpwubx6alkGcMMHCwNpvzpIq2Zd+NlIVzqrAdqUwHmVf7w0ar9fX1pDWDSlzOITqyvBp HMY8ASC+lMUEbQMY6ihyrm0yyX8jYNgpDTZSCdVXEw+HjUGiHCm+msXvNqg7FPjWpOdk 8xy3p+BloXKJo9QQdiJUkqzKPG/j3ZHtX21KV11DL0Acu8yx8okkMBMKVTRa2v+Yecvt 8OUyPqZEI1jHVHIHsFMtXPCuTyKv8/k5GpzxmxEtBa8D+Z/Su2qRLiOhx4H/bH4yS/6I RuSQ== X-Gm-Message-State: APjAAAXlRvl7DbZK+J3In18bBYELWFYqeQfnf1rGn0+ltv5GqYUvPH1x QZwc8jHwISfrbsnWtmjTwSeWi5A+7As= X-Google-Smtp-Source: APXvYqxzp0mXVIEg2Lo4NrID4zy0U5fHwvjk6CSMbbNkgJLcgxmMYE1uHPA4VnmE/lT9caZtXvmchw== X-Received: by 2002:a65:56c9:: with SMTP id w9mr16524798pgs.296.1576246649992; Fri, 13 Dec 2019 06:17:29 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d22sm11863883pfo.187.2019.12.13.06.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2019 06:17:29 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [libteam PATCH] teamd/lacp: fix segfault due to NULL pointer dereference Date: Fri, 13 Dec 2019 22:17:14 +0800 Message-Id: <20191213141714.26865-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Message-ID-Hash: 33TVLSTVCWSIWLDJZ5Y6AJ4MLKPHHK2Y X-Message-ID-Hash: 33TVLSTVCWSIWLDJZ5Y6AJ4MLKPHHK2Y X-MailFrom: liuhangbin@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Hangbin Liu , Jiri Pirko X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: If we set a team0 link down with lacp mode, we will call like - lacp_port_agg_unselect() - lacp_switch_agg_lead() - teamd_log_dbg() while the new_agg_lead in lacp_switch_agg_lead() may be NULL, then we will got NULL pointer dereference as we called new_agg_lead->ctx in new teamd_log_dbg(). Fix it by using agg_lead->ctx, which is safe as we referenced it in function lacp_switch_agg_lead(). Fixes: f32310b9a5cc ("libteam: wapper teamd_log_dbg with teamd_log_dbgx") Signed-off-by: Hangbin Liu --- teamd/teamd_runner_lacp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c index 7d940b3..ec01237 100644 --- a/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c @@ -634,7 +634,7 @@ static void lacp_switch_agg_lead(struct lacp_port *agg_lead, struct teamd_port *tdport; struct lacp_port *lacp_port; - teamd_log_dbg(new_agg_lead->ctx, "Renaming aggregator %u to %u", + teamd_log_dbg(agg_lead->ctx, "Renaming aggregator %u to %u", lacp_agg_id(agg_lead), lacp_agg_id(new_agg_lead)); if (lacp->selected_agg_lead == agg_lead) lacp->selected_agg_lead = new_agg_lead;