Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3564443imm; Mon, 1 Oct 2018 00:13:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV63GgrvPsFLMphrkWSlySOxQLA7uUxCLedENRxF3YpvnGp53n/M+C7+uUQQeuKeMbfW/6pCz X-Received: by 2002:a63:c306:: with SMTP id c6-v6mr251745pgd.133.1538378002055; Mon, 01 Oct 2018 00:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538378002; cv=none; d=google.com; s=arc-20160816; b=TmWhgOyrjklq/ehuRawyzrvE3tEPpmJUr5IZMJCjd4xPKQjcj1t1PtzyFbM9mtXGSP VcHMxu/fW5dyQkHBM47/3epYI36Pxc4BGrkZWfhqcSgQrSG0Yc3gWt9FGW9x040TXWNZ gWI2SvUI4VvJS0SbLCTRK6mBJYekJjWBhGddzsOliXJeg1LYjY1Re8wHbbFk+EgLoOyO M2+CdHKVagPah7ULUe1xTz2duWSrNHCwMRc71MZ+hRi7JJ/6ywKSi7HnQIOAb9nP6iIO 9aZ8nC4zJZv80SooU0I+GPWJImcLiO/p2co0x1qTYtuCVTQGXxarQPyacdt7bgizkta0 +AtQ== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=5CByEyOCHNMt8BmOgLtg4kMIvKhwfI8Tzj5xqDiUtY8=; b=0286RdK3QhssYMkIr9/NpzelAA0UO2Fd+G1iM4vTDiIKlYe30A8csxqCFpT6iL7BYq i8Mikg83b6q4acTjKieLuOLLkAeNWxrmpNzgKY5Nsn1pEI52BuguDMsf+tHRkM1h5dK6 7QiFN3NjOhTKCC3p6EzvTE/EQgJXLmskMwdVS4tbko/JOAEyIUWci0LI7CbN1rtkMTmB hGrRsV5+aH3CzTrH/JaLz8v4HW5nL5EMA3riV36eEscck+VxBC8VYQ24LZpURwJ+UeBo CBG4V07MEciti1HcHXOfzv3kGTcp1gWkOvm1p83r89+RzwJ6FGfOy/UM/g0UmEEqaUyp IRxg== ARC-Authentication-Results: i=1; mx.google.com; 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 p11-v6si11128850pgh.274.2018.10.01.00.13.07; Mon, 01 Oct 2018 00:13:22 -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; 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 S1728905AbeJANs4 (ORCPT + 99 others); Mon, 1 Oct 2018 09:48:56 -0400 Received: from s3.sipsolutions.net ([144.76.43.62]:53894 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728677AbeJANsz (ORCPT ); Mon, 1 Oct 2018 09:48:55 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.91) (envelope-from ) id 1g6sNg-00070c-6N; Mon, 01 Oct 2018 09:12:36 +0200 Message-ID: <1538377946.3126.0.camel@sipsolutions.net> Subject: Re: [PATCH] cfg80211: fix wext-compat memory leak From: Johannes Berg To: stefan.seyfried@googlemail.com, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Cc: Stefan Seyfried Date: Mon, 01 Oct 2018 09:12:26 +0200 In-Reply-To: <20180930105300.30797-1-stefan.seyfried@googlemail.com> (sfid-20180930_125439_767875_5C23A914) References: <20180930105300.30797-1-stefan.seyfried@googlemail.com> (sfid-20180930_125439_767875_5C23A914) Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 (3.26.6-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stefan, Thanks for the investigation & fix. I've changed the fix to use cfg80211_sinfo_release_content(), take care of the error path in cfg80211_wext_giwrate() and added a Fixes tag :-) Applied with those changes. johannes On Sun, 2018-09-30 at 12:53 +0200, stefan.seyfried@googlemail.com wrote: > From: Stefan Seyfried > > cfg80211_wext_giwrate and sinfo.pertid might allocate sinfo.pertid via > rdev_get_station(), but never release it > > Signed-off-by: Stefan Seyfried > --- > net/wireless/wext-compat.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c > index 167f7025ac98..f462336aac1c 100644 > --- a/net/wireless/wext-compat.c > +++ b/net/wireless/wext-compat.c > @@ -1277,12 +1277,16 @@ static int cfg80211_wext_giwrate(struct net_device *dev, > err = rdev_get_station(rdev, dev, addr, &sinfo); > if (err) > return err; > - > if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) > return -EOPNOTSUPP; > > rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); > > + /* sta_set_sinfo(), called from ieee80211_get_station(), called from > + * rdev_get_station via rdev->ops->get_station, allocates pertid struct > + * which we do not use here. */ > + kfree(sinfo.pertid); > + > return 0; > } > > @@ -1293,7 +1297,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) > struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); > /* we are under RTNL - globally locked - so can use static structs */ > static struct iw_statistics wstats; > - static struct station_info sinfo; > + static struct station_info sinfo = {}; > u8 bssid[ETH_ALEN]; > > if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) > @@ -1352,6 +1356,9 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) > if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED)) > wstats.discard.retries = sinfo.tx_failed; > > + /* see cfg80211_wext_giwrate() above */ > + kfree(sinfo.pertid); > + > return &wstats; > } >