Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1021711ybe; Wed, 4 Sep 2019 11:16:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVXMC7C3YGg5hmWfmMrOJ8vkpyhIznSY57QRu6jZYnYvfg/3nkp33j9EOupxNciR2n1LxO X-Received: by 2002:a17:90b:948:: with SMTP id dw8mr6444485pjb.48.1567620967718; Wed, 04 Sep 2019 11:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620967; cv=none; d=google.com; s=arc-20160816; b=yKdhdieFPptKdDKhI4ezIS+Eg0ymcPxnsWjtJrRvW8/nHm0SlA43rlkfHrMmfAWRCs dOteWVii/9bDDGujqy/OXDsmSFC3ZxZYyvfRn68dj1JRYw9ug+x8J+bYWMLhOj1ulSfR O1bIKPsMRxfQiCglEKE2VZHTe+NXIEztMeReV/af+80vPJFOd7hiU8x+eleFu7qaKT2h H3zNdM3TSzBEMxNXXC/eEF90RJJ5K1FSUawTVUeB0l//fWcWlhjUpL3tfe0oTd5/vq5u V7B3XMNKiGPTkm5OrogE5Z6wrVFTEl5C3lSNnWCEQZ+3NpiXE4C/bH7GES9MPJkDJOLn epcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=47JTqZWQhSIhP4Ye38KtG53FX2AxH+LB71F7E7DHPkQ=; b=wHSDt+pPg/263O6JifRPRcBuwNJ1WyoTk8NHBO+IsWM11sdfCMolBP9qauAyzSRwmU KIlug8GkqjzuvVKe8hSaKPtdooLeCPvact2thbzLMzmISAmQStqeRSJMmV9/Uxn6yRmh Em6FhHeLhzf3N7iYLDaSbBEj8QXgYtOW4qZ0+nw8yg2TJRQh/NJGrKryqZICSAbxA+vl hLVC9u4ztc9Z8crKqCwQI141ClLUdBmkShpGFmdtNMvS6VNSt5+l/cipfm9irm3AnyGd os/Ii4ASHusJhr0KyBHVkqNKJUpbmi15P0VVUWNUhL0SjYbIa8uwmQPzJII2p/iEKT7W +FOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cwDWkr5z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ci9si290727plb.103.2019.09.04.11.15.52; Wed, 04 Sep 2019 11:16:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cwDWkr5z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389317AbfIDSOb (ORCPT + 99 others); Wed, 4 Sep 2019 14:14:31 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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);