From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BB9015C82 for ; Mon, 5 Dec 2022 19:22:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94DD2C433D6; Mon, 5 Dec 2022 19:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670268120; bh=ciJ8RwnLVDRh3QcGYCa1O4DKrcsK0HUuDxhMstbQCWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SzL8qQU9HNV8okZrPOIj2tg36RrMnJqeyQi/OrEz9ugVvipt5hD71eaCIXUdJ8f7b 9zKjsVn8kIFn4JBhOisU+K9yI9OTuz/2zrVSjEu/2FGsKxu1pMTCPaLQerOiGyXAYA TcVtOqGEfGpMZj38Rm6DSJWIrWPfmy7iKC6WFuh8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gaosheng Cui , Guenter Roeck , Sasha Levin Subject: [PATCH 4.19 066/105] hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails Date: Mon, 5 Dec 2022 20:09:38 +0100 Message-Id: <20221205190805.406147646@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221205190803.124472741@linuxfoundation.org> References: <20221205190803.124472741@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Gaosheng Cui [ Upstream commit e2a87785aab0dac190ac89be6a9ba955e2c634f2 ] Smatch report warning as follows: drivers/hwmon/ibmpex.c:509 ibmpex_register_bmc() warn: '&data->list' not removed from list If ibmpex_find_sensors() fails in ibmpex_register_bmc(), data will be freed, but data->list will not be removed from driver_data.bmc_data, then list traversal may cause UAF. Fix by removeing it from driver_data.bmc_data before free(). Fixes: 57c7c3a0fdea ("hwmon: IBM power meter driver") Signed-off-by: Gaosheng Cui Link: https://lore.kernel.org/r/20221117034423.2935739-1-cuigaosheng1@huawei.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/ibmpex.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c index ab72cabf5a95..e289c845f970 100644 --- a/drivers/hwmon/ibmpex.c +++ b/drivers/hwmon/ibmpex.c @@ -517,6 +517,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev) return; out_register: + list_del(&data->list); hwmon_device_unregister(data->hwmon_dev); out_user: ipmi_destroy_user(data->user); -- 2.35.1