From patchwork Mon May 14 05:42:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 912685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40kqMt4jXnz9s0q; Mon, 14 May 2018 15:42:18 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fI6FR-0006T5-0w; Mon, 14 May 2018 05:42:13 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fI6FP-0006SW-4Z for kernel-team@lists.ubuntu.com; Mon, 14 May 2018 05:42:11 +0000 Received: from mail-it0-f70.google.com ([209.85.214.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fI6FO-0006S4-Mm for kernel-team@lists.ubuntu.com; Mon, 14 May 2018 05:42:10 +0000 Received: by mail-it0-f70.google.com with SMTP id c137-v6so11552477ith.3 for ; Sun, 13 May 2018 22:42:10 -0700 (PDT) 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:in-reply-to :references; bh=0oIwlvvS/onU8RkJPx8nLvqSydVqu5eLS74PF/nRN5w=; b=PEkkskPW4JvvJTc4XUi+lRR57zR2C1yJi+VvosQSmBnHhchBY+L70CLnYxUwCYXoPr pjOJeISzrwtC7PEw2xq5E/2kXbgpknXMoPRVrZ+cGV9cDEBkvHfOlvnG642Gaz0pg8h9 8UuMrIVz00f6AbIUpZnK3NREtiIGCZle47BwnClJ1Wrl0+3xFFuA/HYBIXqucQIqZ+OE HsDITKX5aHxmT3ClUPT2L+q7zV42xHPSsPmtyf7vKSLhEei8nNzLIJuByQBoCdqerBYB XRyVgvdvaa8Kg/QakQ5Ydd5eVOYLndgsKxywgdsfW9710ioL18XfQONaPRoCkg5fb/z0 8Ppw== X-Gm-Message-State: ALKqPwelZCWNTqGPlEGRm8vVDwhNYmYqGGJSvUBQy7pu2968y9HTp8ub iVcz9igqZmHQi/Q75+flqw2PHz1kLlrF4xTOKV/T34nyHK7/A8OLF2EsVmBj2an66pnvsIvxUGD RSSHJ86RUr+w+lWjSs8lNP2YJIsPRlWj2T24eAR3g7Q== X-Received: by 2002:a24:4455:: with SMTP id o82-v6mr7744000ita.4.1526276529429; Sun, 13 May 2018 22:42:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrY5nOrObfMixFOd/SL5r5CX8f+DzapUQ8Zgh4pbcxNj1mxy5cX+8nIRZe8nmVhLkLpYIOayQ== X-Received: by 2002:a24:4455:: with SMTP id o82-v6mr7743989ita.4.1526276529277; Sun, 13 May 2018 22:42:09 -0700 (PDT) Received: from kbuntu.fuzzbuzz.org (198-84-180-15.cpe.teksavvy.com. [198.84.180.15]) by smtp.gmail.com with ESMTPSA id 32-v6sm4250872ios.26.2018.05.13.22.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 May 2018 22:42:08 -0700 (PDT) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [X/A/B/C][PATCH 1/1] mac80211_hwsim: fix possible memory leak in hwsim_new_radio_nl() Date: Mon, 14 May 2018 01:42:03 -0400 Message-Id: <20180514054203.9489-2-khalid.elmously@canonical.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514054203.9489-1-khalid.elmously@canonical.com> References: <20180514054203.9489-1-khalid.elmously@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "weiyongjun (A)" CVE-2018-8087 'hwname' is malloced in hwsim_new_radio_nl() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Fixes: ff4dd73dd2b4 ("mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length") Signed-off-by: Wei Yongjun Reviewed-by: Ben Hutchings Signed-off-by: Johannes Berg (cherry-picked from 0ddcff49b672239dda94d70d0fcf50317a9f4b51) Signed-off-by: Khalid Elmously Acked-by: Andy Whitcroft --- drivers/net/wireless/mac80211_hwsim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 6467ffac9811..d2ab96863fce 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3142,8 +3142,10 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info) if (info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]) { u32 idx = nla_get_u32(info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]); - if (idx >= ARRAY_SIZE(hwsim_world_regdom_custom)) + if (idx >= ARRAY_SIZE(hwsim_world_regdom_custom)) { + kfree(hwname); return -EINVAL; + } param.regd = hwsim_world_regdom_custom[idx]; }