Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1011236ybe; Wed, 4 Sep 2019 11:06:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwgyc++wykh2GRbQUmP8giWzJfTnunO89dyAqUSWo5LXvkh4xNut542LWpjsNoLPhkGxhL X-Received: by 2002:a63:2807:: with SMTP id o7mr36863484pgo.131.1567620418464; Wed, 04 Sep 2019 11:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620418; cv=none; d=google.com; s=arc-20160816; b=QJf9p7vIao9sfq5aB87fYzo7TObtnlcdurwBrdlm1yYckbbI/3o/CMXcFP0AbSO41C 2iNnC8cCKitwZLRsTa4Nelfd8UIVQYF2XVV1vcCiptu1cIUcpwYTdHXiTa/TmiipwLQW XlSLlbLWjfsrFBUZATS5NF9tes4sS8FwRM7IW/fDYlSphdA7KieI7C5FarplJheavgkV dekZ9PArSCyEHZzwtIPL3vt7ahpKbEbgM/6NFJDmbHAdA1XExxKfUyELfzjnlm9tnPpj 9+lZIFZ0kBDIkWtu1KRA0z0txImbP45Yd/nbpTuw9oX5KBpZIP8vArU36xnlufOMWpQq UvkQ== 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=davhOXRou6COhJ6Ep9lF229XZGjM2DXIuS6FLVNYTKY=; b=oesyzPiZTLGJygJFInqoRD8m/Qg0ku+Dm/X4cR1vubmV78xVfhIx3YHA12fDtTclXE 8J4oxFiD/iVX/s//FIiNmir1o7KaNMCGMVD86oLkzZJ8M1FiHOYBdWlP98c1WkRlInd2 MoMMd2ofHb7hQI6o1kBij9G/hFrR8m2ENM0yeGXPtHPflgkjIN4Lf/d9NZLuzagVGDsC B/M/pyh5DxSZ0OvQ0IpERYmX4Ry0PSmpncL8Bqrq025lq6WX1kdYdFPnig4AUU0x4A80 gVGkb/STbd9vFvmJ+JGBjtyC80czA9jz1Ttm/a/l7RpymjDM2cP5jm4XLC/45lw60wDK hY+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nklbeQGz; 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 o35si2855182pje.106.2019.09.04.11.06.39; Wed, 04 Sep 2019 11:06:58 -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=nklbeQGz; 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 S2389171AbfIDSE5 (ORCPT + 99 others); Wed, 4 Sep 2019 14:04:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:46118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389143AbfIDSEz (ORCPT ); Wed, 4 Sep 2019 14:04:55 -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 EE7FB206B8; Wed, 4 Sep 2019 18:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620294; bh=/c0E3IhlUuK29sMKO5Ld2wcLO2NHBouIlgrO37+mFDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nklbeQGzP9xjR1u0cmIkFl4PFyGC/IQC8kEzl3us5hu9gt7rLf0CyfsptJCa8/EOn o6cTnqZBxAbiCRDFrr06uzBB/YY+zzQ4fos8fMhf1kK7K5qAwJOXaF9Dws/GxdAx4B kN9ngAav3qF2B/CftxvwpFiHHceFI+cYWN0XhoJE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg Subject: [PATCH 4.14 48/57] mac80211: fix possible sta leak Date: Wed, 4 Sep 2019 19:54:16 +0200 Message-Id: <20190904175306.641592543@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175301.777414715@linuxfoundation.org> References: <20190904175301.777414715@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 @@ -1459,6 +1459,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; @@ -1466,10 +1471,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);