From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73815C3A5A8 for ; Wed, 4 Sep 2019 18:16:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 451FB2087E for ; Wed, 4 Sep 2019 18:16:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620990; bh=QS2EO+bz72QZXczxXVN/e5/PS+AuqMibVBLItVH+2uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SnleQYc4d25DNUaGuhbNKTmByYrcW31GyKYkoHuHlGvu6aCiTBSu0Deqm7K147Zhe j87F+zMW7dJQRtRwBZRIeuuqGPxXZwDvpm7xo+6D7HvLb8nOgOd2srtpcuZAoLpuYf o1z7li7ushJKumySFTf4LMjRK7tBUYDpOx9tmj7g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389790AbfIDSO3 (ORCPT ); Wed, 4 Sep 2019 14:14:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732094AbfIDSO3 (ORCPT ); Wed, 4 Sep 2019 14:14:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A29BB208E4; Wed, 4 Sep 2019 18:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620868; bh=QS2EO+bz72QZXczxXVN/e5/PS+AuqMibVBLItVH+2uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cwDWkr5zK4HVV++Awmn03bzHkHfNJNteIP9qkUQo8bzY9rDAu3+KzDtIVcRHACEjC WpIS8OC1/30V0uyqYwzg+jmEostpFTe6NRT1TV6fWtIsb5MkZJEecm4IDexpfL1RaQ ol/LWBOgsTlNnfg/8zlOwjQAs6lM38k3SxmAAq1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg Subject: [PATCH 5.2 125/143] mac80211: fix possible sta leak Date: Wed, 4 Sep 2019 19:54:28 +0200 Message-Id: <20190904175319.298497697@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Johannes Berg commit 5fd2f91ad483baffdbe798f8a08f1b41442d1e24 upstream. If TDLS station addition is rejected, the sta memory is leaked. Avoid this by moving the check before the allocation. Cc: stable@vger.kernel.org Fixes: 7ed5285396c2 ("mac80211: don't initiate TDLS connection if station is not associated to AP") Link: https://lore.kernel.org/r/20190801073033.7892-1-johannes@sipsolutions.net Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/cfg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1543,6 +1543,11 @@ static int ieee80211_add_station(struct if (is_multicast_ether_addr(mac)) return -EINVAL; + if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) && + sdata->vif.type == NL80211_IFTYPE_STATION && + !sdata->u.mgd.associated) + return -EINVAL; + sta = sta_info_alloc(sdata, mac, GFP_KERNEL); if (!sta) return -ENOMEM; @@ -1550,10 +1555,6 @@ static int ieee80211_add_station(struct if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) sta->sta.tdls = true; - if (sta->sta.tdls && sdata->vif.type == NL80211_IFTYPE_STATION && - !sdata->u.mgd.associated) - return -EINVAL; - err = sta_apply_parameters(local, sta, params); if (err) { sta_info_free(local, sta);