From patchwork Thu Jun 10 06:47:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1490201 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=f/dUepcd; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G0vgX4Nkyz9sWQ; Thu, 10 Jun 2021 16:48:08 +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 1lrEU1-0002Te-Nu; Thu, 10 Jun 2021 06:48:05 +0000 Received: from mail-pj1-f50.google.com ([209.85.216.50]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lrETz-0002Sb-Lt for kernel-team@lists.ubuntu.com; Thu, 10 Jun 2021 06:48:03 +0000 Received: by mail-pj1-f50.google.com with SMTP id k5so3064980pjj.1 for ; Wed, 09 Jun 2021 23:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2zOtjEvc03pg/ifSGEJfRtATvWixeGqJMJWiRxpXNCA=; b=f/dUepcdpVRlbxdnokB1GelkpWXK9kEtMywDf0dBcDnYzAhWzT8VimMOnZBfTWjSFn gw9Z8CmvAJ0pY9aed1RlOivTqXCokuivG08qsuSRi6Sby5xOtn2ArwSHRsbWM3b9vT0W Pab3Z1RMPbi//VwjIHr+b5Fkc53BJtQczI0HDeLdkVTICM/UBEk9Dsg20IKPyGeoW9K2 G9N6OBvvT8G/k2PcG9MB7phpAolM6YwRXamDiOOyfKLpkmK2ORZivg4kTdLuMKQ63Voo cxcPqSV7D4dI/yTpezOVQXGHkpB1q2IL1fUre+MbpVRHivf+anSkx9WFYv+Z6SqNPFUg hbxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=2zOtjEvc03pg/ifSGEJfRtATvWixeGqJMJWiRxpXNCA=; b=bFIrE60sEgV0QEnk3yBeHtckAvrkboiN197rm0vi4PFOx/Kil/UBHT3bWqGOg2uMJv RXaFGU5TbSGoyQ9b60qDSLjDS7HafkGAtjbp6ImpW0vr3DnVCQ57Qpo23cxqwp8BjuhO SC1heiL7BIYwm4hHDp2A7k9Pf4DZEv/mPPdRKLz16094QcAXJ6kqXw7V04FqpXq2XqzK 3IU5V9FEkXpF0vk25/ILEpg/rkrOxDnvRIJToJScLy5XuNFEDO+hPpvOBB2YaCOMJqe5 O8WcGHycyW5u4iyAh27sQdi4J6yykWhQChWfbmbm978rX0MV0WcmgyJyHC29eRjtuAHU dzVQ== X-Gm-Message-State: AOAM530lfPCMyoyeBciyZqSCg54YuruwJ9eivg9oY8WkgLR66FGrz7mq 5cAYmGKllu+u1kvQ+AnHE4jcpmV5UR4GaYjl X-Google-Smtp-Source: ABdhPJyZLFMP8E764fpy8DA9HZie332SlS4vHqjISPvsxDxYft+TxudLi5cgA89iOn3hw097VzDYCQ== X-Received: by 2002:a17:90b:190a:: with SMTP id mp10mr1822046pjb.145.1623307680945; Wed, 09 Jun 2021 23:48:00 -0700 (PDT) Received: from localhost (220-135-95-34.HINET-IP.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id v6sm1801083pgk.33.2021.06.09.23.47.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:48:00 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/7][SRU][OEM-5.10] platform/x86: dell-wmi-sysman: Fix crash caused by calling kset_unregister twice Date: Thu, 10 Jun 2021 14:47:48 +0800 Message-Id: <20210610064754.1061717-2-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610064754.1061717-1-acelan.kao@canonical.com> References: <20210610064754.1061717-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.50; envelope-from=acelan@gmail.com; helo=mail-pj1-f50.google.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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1931509 On some system the WMI GUIDs used by dell-wmi-sysman are present but there are no enum type attributes, this causes init_bios_attributes() to return -ENODEV, after which sysman_init() does a "goto fail_create_group" and then calls release_attributes_data(). release_attributes_data() calls kset_unregister(wmi_priv.main_dir_kset); but before this commit it was missing a "wmi_priv.main_dir_kset = NULL;" statement; and after calling release_attributes_data() the sysman_init() error handling does this: if (wmi_priv.main_dir_kset) { kset_unregister(wmi_priv.main_dir_kset); wmi_priv.main_dir_kset = NULL; } Which causes a second kset_unregister(wmi_priv.main_dir_kset), leading to a double-free, which causes a crash. Add the missing "wmi_priv.main_dir_kset = NULL;" statement to release_attributes_data() to fix this double-free crash. Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: Divya Bharathi Cc: Mario Limonciello Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210321115901.35072-2-hdegoede@redhat.com (cherry picked from commit bdda39673fdef32631448dcb75df79aed9643b31) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index cb81010ba1a21..c1997db74cca5 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -388,6 +388,7 @@ static void release_attributes_data(void) if (wmi_priv.main_dir_kset) { destroy_attribute_objs(wmi_priv.main_dir_kset); kset_unregister(wmi_priv.main_dir_kset); + wmi_priv.main_dir_kset = NULL; } mutex_unlock(&wmi_priv.mutex); From patchwork Thu Jun 10 06:47:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1490202 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=sKWbMKHW; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G0vgf1C1bz9sW7; Thu, 10 Jun 2021 16:48:14 +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 1lrEU7-0002WL-5v; Thu, 10 Jun 2021 06:48:11 +0000 Received: from mail-pf1-f179.google.com ([209.85.210.179]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lrEU2-0002TC-GA for kernel-team@lists.ubuntu.com; Thu, 10 Jun 2021 06:48:06 +0000 Received: by mail-pf1-f179.google.com with SMTP id p13so815383pfw.0 for ; Wed, 09 Jun 2021 23:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3VKZgQzc1KobN3jDqMuioRwjBZl8TdLi8q9RMMnOwwQ=; b=sKWbMKHWApw189sVRarYKDajVnOcsZTk3zXcAfBa1Ine9kNv4dQtwDKPR8mcDo0B7H AP81bVIElocd7FbmtW/hMuqDsRQj9DN53cE+EgoL2SpHEp886Lk3AWsXfD/fKwRUlik2 kW0QT8xoJC9PbCebrvxwiq+mbLYkWAoZc78nJhIvVKxgMvjJ2X236UzFGwBKXdUbsKbk NRq7OZeBOg5jp9WHO84GVFm2pxCMcVvlxa4J60AV6PSJCEkjomNcAglkV3VuCEvi9//4 RFiReVH0s+wkHtCr4sSTmdgKbG1IC5Rh/og6aeX+7MEfqWWxur8zdbpit6EzDjt732Ao RJfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3VKZgQzc1KobN3jDqMuioRwjBZl8TdLi8q9RMMnOwwQ=; b=F6DJcpII1pbM77JREkEW4Xrm6pPHRvO6hdkVU8HSYSCwjjOxPmsL2J7qxxvc2R1z0w 9JMiIPNBVNWhSOgyqUKwnNW4qaJajAWGVnGHIv457k98jw/ltDkHLc/VvGIv4FXiB4y4 1bQ6ZKnI24LxfMmY26g+1uNuFsG3HcYjzBckVSaUKMFKftCvNPn9C2nbV9sbN60seOu/ Ja3xQlRM0elYN6kR755fbu/S5KCFR7EQI9X6Ixd2qXYaiXUT815fnxkmVEgkD41qDa79 ASMdHaV4bq+OzKp25Ra2gM7eP7KgUd1k7/uXq8xon51OY6wVUx0OD8yWX8liTVUmr72Z /zEA== X-Gm-Message-State: AOAM530D0lD5gJgYHqgCJkG9dI4vZio3S4/gEKu/jAyvTpDWhRsfYLx/ mXvz1I6Y7tAF4C23oX2bUq334xQM3fDLISIV X-Google-Smtp-Source: ABdhPJwk9YNywjADag2fDb+3aUZzuug8IpaQNyQXzS2oKSi6Cn8LEUEZ+3TicYkSEVsaQbKPQ7xOPw== X-Received: by 2002:a63:a602:: with SMTP id t2mr3486345pge.320.1623307683561; Wed, 09 Jun 2021 23:48:03 -0700 (PDT) Received: from localhost (220-135-95-34.HINET-IP.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id g63sm1406702pfb.55.2021.06.09.23.48.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:48:02 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/7][SRU][OEM-5.10] platform/x86: dell-wmi-sysman: Cleanup sysman_init() error-exit handling Date: Thu, 10 Jun 2021 14:47:49 +0800 Message-Id: <20210610064754.1061717-3-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610064754.1061717-1-acelan.kao@canonical.com> References: <20210610064754.1061717-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.179; envelope-from=acelan@gmail.com; helo=mail-pf1-f179.google.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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1931509 Cleanup sysman_init() error-exit handling: 1. There is no need for the fail_reset_bios and fail_authentication_kset eror-exit cases, these can be handled by release_attributes_data() 2. Rename all the labels from fail_what_failed, to err_what_to_cleanup this is the usual way to name these and avoids the need to rename them when extra steps are added. Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: Divya Bharathi Cc: Mario Limonciello Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210321115901.35072-6-hdegoede@redhat.com (cherry picked from commit eaa1dcc79694674494620ee62098b937ef758df8) Signed-off-by: Chia-Lin Kao (AceLan) --- .../x86/dell/dell-wmi-sysman/sysman.c | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index c1997db74cca5..c40d5658c7c42 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -516,100 +516,87 @@ static int __init sysman_init(void) ret = init_bios_attr_set_interface(); if (ret || !wmi_priv.bios_attr_wdev) { pr_debug("failed to initialize set interface\n"); - goto fail_set_interface; + return ret; } ret = init_bios_attr_pass_interface(); if (ret || !wmi_priv.password_attr_wdev) { pr_debug("failed to initialize pass interface\n"); - goto fail_pass_interface; + goto err_exit_bios_attr_set_interface; } ret = class_register(&firmware_attributes_class); if (ret) - goto fail_class; + goto err_exit_bios_attr_pass_interface; wmi_priv.class_dev = device_create(&firmware_attributes_class, NULL, MKDEV(0, 0), NULL, "%s", DRIVER_NAME); if (IS_ERR(wmi_priv.class_dev)) { ret = PTR_ERR(wmi_priv.class_dev); - goto fail_classdev; + goto err_unregister_class; } wmi_priv.main_dir_kset = kset_create_and_add("attributes", NULL, &wmi_priv.class_dev->kobj); if (!wmi_priv.main_dir_kset) { ret = -ENOMEM; - goto fail_main_kset; + goto err_destroy_classdev; } wmi_priv.authentication_dir_kset = kset_create_and_add("authentication", NULL, &wmi_priv.class_dev->kobj); if (!wmi_priv.authentication_dir_kset) { ret = -ENOMEM; - goto fail_authentication_kset; + goto err_release_attributes_data; } ret = create_attributes_level_sysfs_files(); if (ret) { pr_debug("could not create reset BIOS attribute\n"); - goto fail_reset_bios; + goto err_release_attributes_data; } ret = init_bios_attributes(ENUM, DELL_WMI_BIOS_ENUMERATION_ATTRIBUTE_GUID); if (ret) { pr_debug("failed to populate enumeration type attributes\n"); - goto fail_create_group; + goto err_release_attributes_data; } ret = init_bios_attributes(INT, DELL_WMI_BIOS_INTEGER_ATTRIBUTE_GUID); if (ret) { pr_debug("failed to populate integer type attributes\n"); - goto fail_create_group; + goto err_release_attributes_data; } ret = init_bios_attributes(STR, DELL_WMI_BIOS_STRING_ATTRIBUTE_GUID); if (ret) { pr_debug("failed to populate string type attributes\n"); - goto fail_create_group; + goto err_release_attributes_data; } ret = init_bios_attributes(PO, DELL_WMI_BIOS_PASSOBJ_ATTRIBUTE_GUID); if (ret) { pr_debug("failed to populate pass object type attributes\n"); - goto fail_create_group; + goto err_release_attributes_data; } return 0; -fail_create_group: +err_release_attributes_data: release_attributes_data(); -fail_reset_bios: - if (wmi_priv.authentication_dir_kset) { - kset_unregister(wmi_priv.authentication_dir_kset); - wmi_priv.authentication_dir_kset = NULL; - } - -fail_authentication_kset: - if (wmi_priv.main_dir_kset) { - kset_unregister(wmi_priv.main_dir_kset); - wmi_priv.main_dir_kset = NULL; - } - -fail_main_kset: +err_destroy_classdev: device_destroy(&firmware_attributes_class, MKDEV(0, 0)); -fail_classdev: +err_unregister_class: class_unregister(&firmware_attributes_class); -fail_class: +err_exit_bios_attr_pass_interface: exit_bios_attr_pass_interface(); -fail_pass_interface: +err_exit_bios_attr_set_interface: exit_bios_attr_set_interface(); -fail_set_interface: return ret; } From patchwork Thu Jun 10 06:47:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1490204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=gHR0ZLo6; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G0vgk5LvLz9sVt; Thu, 10 Jun 2021 16:48: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 1lrEUB-0002ZB-Lz; Thu, 10 Jun 2021 06:48:15 +0000 Received: from mail-pj1-f51.google.com ([209.85.216.51]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lrEU4-0002Ur-QE for kernel-team@lists.ubuntu.com; Thu, 10 Jun 2021 06:48:08 +0000 Received: by mail-pj1-f51.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso3207890pjp.2 for ; Wed, 09 Jun 2021 23:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kgAqub5mT+NsYAuXTNx326YWDh9xXebovrR6zb3Idds=; b=gHR0ZLo60nniOkZqKjeZvgJlkhB3Pb/1v73ujUOjRgDIMJ2Qr+Mq0wU2eqX0J6LpRN pYOc1DkM3Tp+Vry4I6rX8JnBQsw4qTd1GXgqirVJidHLs6/4UxlX8x+yLIzo0cBo5MHY BfW1bLGnezt1L40MIAybzE2AWGBJKi3moK0R4OSLk3ywu+/PZEiNcXhgTvJNRI77Kf2f b3prCVh1RlC/p81Sf+/z6xZb4oPF1y2Tw3sJWAr4cqGKPQ5iEycKrJHurRMOq0bvyGyt Jx1N3fOOonm9P5iRhF3Ecfradi2mfiDZRrJgCqemm9pRiQpZgy34ayvDh0qpIVAdrJnt 664w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=kgAqub5mT+NsYAuXTNx326YWDh9xXebovrR6zb3Idds=; b=POl08OEBJkHFX3vHdC6IGfNB9VJBJPlaWkw9G67s4Lx4gHv8n6WFSe7Z7oPE7uWHRr ClQOpQBkxJ5nHIPQWoP+EszOy8tyD7ZWtGav+9T+Uz9Cl1slicEXzfWB2UXdmYy2YbLX LjwvTCXAjDNKLULOKL7XtstLM58z0RhiYfDlFNFoS7rlEMPuRnUmy1ZHmaYYxMljkU1m F47kRm+GyDiqYSwrl73f4cIURgkgDLtbFdE3SI3fIhKa4wBB3dpxfI398kdN6+8GNe9u HMiMIQc7Cp73qsHkgKYJroodLSmU1nX2KsO9xcrLhPTOuKawXybptcFeje9hpwjP5yyG IysA== X-Gm-Message-State: AOAM531cMcRWehpFBfxXjjSvtpvxT9NNVjFsu/GWSo8vUDJXkYqLVAx0 Y7GbvFSrH8plIeWKmo6C5XJK1NdzMgZBNVqY X-Google-Smtp-Source: ABdhPJytXcrbnXJ2L34g+E1ushhCCcCLdUjtYpIaSW/Esi/5AnBtG6gZWfiOUYFywKB3RQdWKeXllg== X-Received: by 2002:a17:902:ff11:b029:114:37a7:21ad with SMTP id f17-20020a170902ff11b029011437a721admr3268027plj.68.1623307686222; Wed, 09 Jun 2021 23:48:06 -0700 (PDT) Received: from localhost (220-135-95-34.HINET-IP.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id o186sm1374411pfb.59.2021.06.09.23.48.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:48:05 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/7][SRU][OEM-5.10] platform/x86: dell-wmi-sysman: Fix release_attributes_data() getting called twice on init_bios_attributes() failure Date: Thu, 10 Jun 2021 14:47:50 +0800 Message-Id: <20210610064754.1061717-4-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610064754.1061717-1-acelan.kao@canonical.com> References: <20210610064754.1061717-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.51; envelope-from=acelan@gmail.com; helo=mail-pj1-f51.google.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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1931509 All calls of init_bios_attributes() will result in a goto fail_create_group if they fail, which calls release_attributes_data(). So there is no need to call release_attributes_data() from init_bios_attributes() on failure itself. Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: Divya Bharathi Cc: Mario Limonciello Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210321115901.35072-5-hdegoede@redhat.com (cherry picked from commit f4c4e9ad1523a32a78f5caf68f1b346a30035481) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index c40d5658c7c42..8bc44316648ff 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -498,7 +498,6 @@ static int init_bios_attributes(int attr_type, const char *guid) err_attr_init: mutex_unlock(&wmi_priv.mutex); - release_attributes_data(); kfree(obj); return retval; } From patchwork Thu Jun 10 06:47:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1490203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=iqpG6NeP; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G0vgj2rwjz9sW7; Thu, 10 Jun 2021 16:48:17 +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 1lrEUA-0002YC-Ep; Thu, 10 Jun 2021 06:48:14 +0000 Received: from mail-pl1-f179.google.com ([209.85.214.179]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lrEU8-0002WH-6Q for kernel-team@lists.ubuntu.com; Thu, 10 Jun 2021 06:48:12 +0000 Received: by mail-pl1-f179.google.com with SMTP id x10so462635plg.3 for ; Wed, 09 Jun 2021 23:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o5CguEQvcqtTcyIEpKUn5Bjq+aIVqZGFrnhM/vm7j3Q=; b=iqpG6NePVptjUSch43/dGbDR7fG2g6WbOnLHWd1vMajyuxHa7O7azrxe7B/dOGdbwf ZyTyi9Dz5nT89380+67uhgykof7XLRpUBJdiUWJVEFNNcr3i539VYYQmuRXZ/jArSvzZ O6AzdlXlgOGv/4Jw+dl9VAATV9ZFPgmvt8MJKvcszzAfyfhh2P46xZJnpnQxUsAFGWKB 0TLesJapqcABXEOfzYYMl0qHttY77fUC1X3g3Z2Iw2WcJ0GbYAs0DSnJd7f+htXVWJvV jxXZK61vwoYfnw/vgsX1qaKAdlr3N5GL6hjF1EfA3Zvec1Ndk5Z+dc928g8/QSpAUliS Q3Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=o5CguEQvcqtTcyIEpKUn5Bjq+aIVqZGFrnhM/vm7j3Q=; b=SJbhNxDkB6QPnWFypavZg3ZPfXykgd57DvgTAtNcrPHyExHU82vSEmOf27TH55OwjE 8RxheGzrJnv8l7l5E44tkTUliPqDo3DZ7ibNYhZzO8K3l9Z1PsBT/R2BGEskv11sYPGn XgOJ2wRD5HTN1yng/PQ1z5tIXibDFaPANjleo20oIKNWADdntdbLTdMkdpn8Wi5NZ0Zc WjSG1xEEwhveaU3UysrxsZlE0PXUulk0brUPBYB4zYZdqeiL5dUOCEXXZDy/EtRjqZiR 9WVMW7NOtgA2B1Andf1hHkvLbAoUlU/rMtBy972c6tBuoBvfxFoCxESAT/59oNhDMh1N 0YKQ== X-Gm-Message-State: AOAM530qd6j7aKes1njc6OPY+KO5uD5NBXGIMWGEDerKehzQnfdzzS0v 1kWqeAhwu6PqhM2DEYrN2wQvXE7zn/ZF0YyB X-Google-Smtp-Source: ABdhPJzPRdzylrrdv5BaySKBCAAOfaMVlAemStbLi291zj8mosOM/V86dy1f/hxq7wlq0IYC23LbLg== X-Received: by 2002:a17:902:e289:b029:10c:97e9:2c74 with SMTP id o9-20020a170902e289b029010c97e92c74mr3544604plc.34.1623307689597; Wed, 09 Jun 2021 23:48:09 -0700 (PDT) Received: from localhost (220-135-95-34.HINET-IP.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id b21sm1393329pfp.134.2021.06.09.23.48.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:48:08 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/7][SRU][OEM-5.10] platform/x86: dell-wmi-sysman: Fix possible NULL pointer deref on exit Date: Thu, 10 Jun 2021 14:47:51 +0800 Message-Id: <20210610064754.1061717-5-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610064754.1061717-1-acelan.kao@canonical.com> References: <20210610064754.1061717-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.179; envelope-from=acelan@gmail.com; helo=mail-pl1-f179.google.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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1931509 It is possible for release_attributes_data() to get called when the main_dir_kset has not been created yet, move the removal of the bios-reset sysfs attr to under a if (main_dir_kset) check to avoid a NULL pointer deref. Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: Divya Bharathi Cc: Mario Limonciello Reported-by: Alexander Naumann Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210321115901.35072-3-hdegoede@redhat.com (cherry picked from commit ececdb8983762d08ed726c1e5308d2f77db9ffd1) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index 8bc44316648ff..99dc2f3bdf49e 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -225,12 +225,6 @@ static int create_attributes_level_sysfs_files(void) return ret; } -static void release_reset_bios_data(void) -{ - sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr); - sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &pending_reboot.attr); -} - static ssize_t wmi_sysman_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -373,8 +367,6 @@ static void destroy_attribute_objs(struct kset *kset) */ static void release_attributes_data(void) { - release_reset_bios_data(); - mutex_lock(&wmi_priv.mutex); exit_enum_attributes(); exit_int_attributes(); @@ -386,12 +378,13 @@ static void release_attributes_data(void) wmi_priv.authentication_dir_kset = NULL; } if (wmi_priv.main_dir_kset) { + sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr); + sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &pending_reboot.attr); destroy_attribute_objs(wmi_priv.main_dir_kset); kset_unregister(wmi_priv.main_dir_kset); wmi_priv.main_dir_kset = NULL; } mutex_unlock(&wmi_priv.mutex); - } /** From patchwork Thu Jun 10 06:47:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1490205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=I6UDMXM/; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G0vgm5FyYz9sX5; Thu, 10 Jun 2021 16:48:20 +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 1lrEUD-0002ah-5w; Thu, 10 Jun 2021 06:48:17 +0000 Received: from mail-pf1-f176.google.com ([209.85.210.176]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lrEUA-0002Xr-W5 for kernel-team@lists.ubuntu.com; Thu, 10 Jun 2021 06:48:15 +0000 Received: by mail-pf1-f176.google.com with SMTP id u18so772766pfk.11 for ; Wed, 09 Jun 2021 23:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bWx6KbwgBvFCl7R0/CRyByKUZh/CxxSVDZ0AMvMKdm0=; b=I6UDMXM/AfQqIFEo7yfIelm5uGBcwaenVbQ+lpqATTF+IaGGsjRaziOZCjs8ecV1NX QkGSA89T36MiiWxu9ZqCg8XbkywF/RqizN9xlZ5JEjYX0gD1m4cm2UdOJ7I0jQDmzgXP q138IdUXRIROWMHrtto8HtVlAmac2jugZvnFaehR7qYSyeJ2p/cFJ/I7p6SJSfV40UHD oxpvgnDXzO+hq+qjKYI5a5UmiP7jLuEMjnNS6+NPtfvrPol/0eW5RaPgtX/i9txtmqew yyOZegDbirEWXKVQsABiChL9n+Gq9lff7iyVpGBsrFyWjsD56COaDgK6yaFed5RXczrp hgVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=bWx6KbwgBvFCl7R0/CRyByKUZh/CxxSVDZ0AMvMKdm0=; b=QdvVdWxoYCMb0tKEc1Gs2De3CL/oBOHrR3TURFiEkC+oWt3H5jSL4iaCeDpeovvNhf n7Wdq6HSpfOQG4/v+vvv5eFiEIDx0yCTDlW9T1yHM5T1bRYDZnNHs057+r8bID7JSXiH Hx78902diz5hXxUMkNbZLeDjjfOhgGwbBJpPQf/JIelrE6qRWeuagbsV5bJZSvkClG7Y OSJK8+F8jngHMvtcPcPOZXgItmuJjV8v8yFv0rjj6OGZbldNYcUYlz32WolS4ca8dsFT WYh+LLoLuZKHe7k5RbqG4NoR1AGFm9u0X19q+c3o6RnAtrSDiQTBNYgcKTF3F04dxOJU p+Yw== X-Gm-Message-State: AOAM5327NgebrXWTh3WD/EYejfH8X6BKJZF31BvXvZGyD68YmlOdCP+S ZY8qfRZcTicTUz86jX6/0+kuY/PX/dEDy+sZ X-Google-Smtp-Source: ABdhPJyZsF/Sm1hjOJ50SBmSx/bSE/4q+3yQs8RDQgWpqfTIQ9Fq5pOAVxE805CQRRdFNCar+sKMcg== X-Received: by 2002:a63:3603:: with SMTP id d3mr3506266pga.346.1623307692192; Wed, 09 Jun 2021 23:48:12 -0700 (PDT) Received: from localhost (220-135-95-34.HINET-IP.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id d24sm1510242pjv.49.2021.06.09.23.48.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:48:11 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 5/7][SRU][OEM-5.10] platform/x86: dell-wmi-sysman: Make sysman_init() return -ENODEV of the interfaces are not found Date: Thu, 10 Jun 2021 14:47:52 +0800 Message-Id: <20210610064754.1061717-6-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610064754.1061717-1-acelan.kao@canonical.com> References: <20210610064754.1061717-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.176; envelope-from=acelan@gmail.com; helo=mail-pf1-f176.google.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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1931509 When either the attributes or the password interface is not found, then unregister the 2 wmi drivers again and return -ENODEV from sysman_init(). Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: Divya Bharathi Cc: Mario Limonciello Reported-by: Alexander Naumann Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210321115901.35072-7-hdegoede@redhat.com (cherry picked from commit 9b95665a83ec555f441f5681daa58f75828d0255) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index 99dc2f3bdf49e..5dd9b29d939c7 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -506,15 +506,17 @@ static int __init sysman_init(void) } ret = init_bios_attr_set_interface(); - if (ret || !wmi_priv.bios_attr_wdev) { - pr_debug("failed to initialize set interface\n"); + if (ret) return ret; - } ret = init_bios_attr_pass_interface(); - if (ret || !wmi_priv.password_attr_wdev) { - pr_debug("failed to initialize pass interface\n"); + if (ret) goto err_exit_bios_attr_set_interface; + + if (!wmi_priv.bios_attr_wdev || !wmi_priv.password_attr_wdev) { + pr_debug("failed to find set or pass interface\n"); + ret = -ENODEV; + goto err_exit_bios_attr_pass_interface; } ret = class_register(&firmware_attributes_class); From patchwork Thu Jun 10 06:47:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1490206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=D8jY7lod; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G0vgr5JCLz9sVt; Thu, 10 Jun 2021 16:48:24 +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 1lrEUH-0002fO-Mz; Thu, 10 Jun 2021 06:48:21 +0000 Received: from mail-pf1-f169.google.com ([209.85.210.169]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lrEUE-0002Zp-GH for kernel-team@lists.ubuntu.com; Thu, 10 Jun 2021 06:48:18 +0000 Received: by mail-pf1-f169.google.com with SMTP id u18so772842pfk.11 for ; Wed, 09 Jun 2021 23:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qoM9ozpxc2Na/5jNtotWh1UDAEKibBejwM+dekKjEBc=; b=D8jY7lodvBD8GgdwSX/GsLyco9FOLEOj5jConjCtgD7zxbb8hnayvyWxGqr1IWLRsZ TvyrqT/n5osc6BK0r9mhaVjhr9gjT9FX2AI9uNvV6fkCCgIGKq3XJk3U81ragu/eDN+D aKPeqs8KGDyxmC6LW1lvBBrJs71lZlkRcRwVTjnGjHmfRLJGWRBpL2hr8x7n9ZMxcLZ6 Ti1Ra25sN2woZILK5+h1Ya/XVtp5wh0+GX1rHJz2TL0vs9WiFD/mXWvWpaseRR9GAovL yeqsi0sTFOOdQnqvPK0s4+OzFFXhrMwBeX0rqKDnXYKToadWfXwOWskqm73dg5hL+oXr z9xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=qoM9ozpxc2Na/5jNtotWh1UDAEKibBejwM+dekKjEBc=; b=OQhlB/zrUebxda2SQiYU0zKfZkQj7o9n81E2m5+G18DsUa1rbXxrwcZbScS0iOQzzV uY+sd+XdLWSdjiprv/Mw/O1h9VWgNVp3Uw5q4bg+RGquTHpI0sVpK7F0I4fuNzXxTRks Ad23q8pahzlw3jOb7KdTcKpFv2dAVd7jVa0m5m+ha5pksJ7XMyPca/+EXBrV/nv4aXSy DmnzMNUxTOj0LWmQBsH+uHDy2mcVi7HlD/p7p/QMBpUpJ9Q9Sx2cg4QYb5X1E4SlGSbk 9aLACV+Zq85yBmS52Y3M7K0WziXshfFCsk4riAbs03kH3uoVPL1s4Kvn8vY/ZQ1+CgYN MdVQ== X-Gm-Message-State: AOAM531Ig+k7AuwpVuR1FOyqE+SZNuUbcb9zC2ukF5EIneeVNv4dyCfF rX5AxVa2mMZGW2TRYMPxTWBa3ZnyCeklO9z1 X-Google-Smtp-Source: ABdhPJzwMxDNqXRgvuPfIMbTGtO8fMBsWamQd27kEYfYMTm2+rI/x2qCxOjhJX4k7De5IvhC3UQ0aQ== X-Received: by 2002:a65:5b0d:: with SMTP id y13mr1153404pgq.165.1623307694903; Wed, 09 Jun 2021 23:48:14 -0700 (PDT) Received: from localhost (220-135-95-34.HINET-IP.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id w79sm1514649pff.21.2021.06.09.23.48.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:48:14 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 6/7][SRU][OEM-5.10] platform/x86: dell-wmi-sysman: Make init_bios_attributes() ACPI object parsing more robust Date: Thu, 10 Jun 2021 14:47:53 +0800 Message-Id: <20210610064754.1061717-7-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610064754.1061717-1-acelan.kao@canonical.com> References: <20210610064754.1061717-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.169; envelope-from=acelan@gmail.com; helo=mail-pf1-f169.google.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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1931509 Make init_bios_attributes() ACPI object parsing more robust: 1. Always check that the type of the return ACPI object is package, rather then only checking this for instance_id == 0 2. Check that the package has the minimum amount of elements which will be consumed by the populate_foo_data() for the attr_type Note/TODO: The populate_foo_data() functions should also be made more robust. The should check the type of each of the elements matches the type which they expect and in case of populate_enum_data() obj->package.count should be passed to it as an argument and it should re-check this itself since it consume a variable number of elements. Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: Divya Bharathi Cc: Mario Limonciello Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210321121607.35717-1-hdegoede@redhat.com (cherry picked from commit 5e3f5973c8dfd2b80268f1825ed2f2ddf81d3267) Signed-off-by: Chia-Lin Kao (AceLan) --- .../x86/dell/dell-wmi-sysman/sysman.c | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index 5dd9b29d939c7..1d996bbf7f5a7 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -401,6 +401,7 @@ static int init_bios_attributes(int attr_type, const char *guid) union acpi_object *obj = NULL; union acpi_object *elements; struct kset *tmp_set; + int min_elements; /* instance_id needs to be reset for each type GUID * also, instance IDs are unique within GUID but not across @@ -411,14 +412,38 @@ static int init_bios_attributes(int attr_type, const char *guid) retval = alloc_attributes_data(attr_type); if (retval) return retval; + + switch (attr_type) { + case ENUM: min_elements = 8; break; + case INT: min_elements = 9; break; + case STR: min_elements = 8; break; + case PO: min_elements = 4; break; + default: + pr_err("Error: Unknown attr_type: %d\n", attr_type); + return -EINVAL; + } + /* need to use specific instance_id and guid combination to get right data */ obj = get_wmiobj_pointer(instance_id, guid); - if (!obj || obj->type != ACPI_TYPE_PACKAGE) + if (!obj) return -ENODEV; - elements = obj->package.elements; mutex_lock(&wmi_priv.mutex); - while (elements) { + while (obj) { + if (obj->type != ACPI_TYPE_PACKAGE) { + pr_err("Error: Expected ACPI-package type, got: %d\n", obj->type); + retval = -EIO; + goto err_attr_init; + } + + if (obj->package.count < min_elements) { + pr_err("Error: ACPI-package does not have enough elements: %d < %d\n", + obj->package.count, min_elements); + goto nextobj; + } + + elements = obj->package.elements; + /* sanity checking */ if (elements[ATTR_NAME].type != ACPI_TYPE_STRING) { pr_debug("incorrect element type\n"); @@ -483,7 +508,6 @@ static int init_bios_attributes(int attr_type, const char *guid) kfree(obj); instance_id++; obj = get_wmiobj_pointer(instance_id, guid); - elements = obj ? obj->package.elements : NULL; } mutex_unlock(&wmi_priv.mutex); From patchwork Thu Jun 10 06:47:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1490207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DZMVcvVX; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G0vgw2kz8z9sWQ; Thu, 10 Jun 2021 16:48:28 +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 1lrEUL-0002j0-H4; Thu, 10 Jun 2021 06:48:25 +0000 Received: from mail-pg1-f180.google.com ([209.85.215.180]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lrEUH-0002dM-9Y for kernel-team@lists.ubuntu.com; Thu, 10 Jun 2021 06:48:21 +0000 Received: by mail-pg1-f180.google.com with SMTP id q15so21780977pgg.12 for ; Wed, 09 Jun 2021 23:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0BIyJlOqkKtXQP12uZqhw8yDbrsvUUT+DUg0UwYllqY=; b=DZMVcvVXxzJtzXK/tRqCTqmfp03cNQNMv93DwWODZhoTZfjZOOSzf3fKDB1WsWwwTn N3xXT1e/wBEcDHJWa5XHTRAc2F4PhNeEopcWpK8Z9xdVzMhfIAtQxHwnnMFsHaA5KEz2 gbXlIu8BamcMbN9vrB2BV3nlcMA32mm6MuzVVmVfZ8Qd+7TwSTTaRrCsbcym4AkptMEI Doqf9VRqc4ScEx2xw3alt3qOArwW63NEUpDlggc8dMxdELcZqWmLgEl07xRMCpTOUi7V /dCer4iGONvLrtGGeJNvGYrJnfMR5uLp91R0pycLw/61d1Qc0ldEyADc2Uv1O8uWPlBw fOBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0BIyJlOqkKtXQP12uZqhw8yDbrsvUUT+DUg0UwYllqY=; b=Dd7btzC9ioyrR1ofRZntGPMFTyeD0Cdd5k0YKjtDiwxgHYdDPSXrr9rjsB5Lx4Mujh y5d6YXpA52mY2iqQYt/VvnbJBNH+dlWsFj8lc5/bq+xZSO2Uc/HTgupL3JRhs8pvVoaH +uVhrwx39C/tRoXeK049GudKHBbVJRd2jXZT6FBNlmRZwGNwE20DhJiCOSxn5ObdlsNn y/4uOSuNzdFw2bQW8Z9jR17QLnvZVrW20UmI/BAUwZF2ZaARWDeUsa62MNlJlhZecjSj xr25zo6HNRK5Ztdbr/tIYM1vj51pPwSX3ZwvGadvL1tbfQHu82z/Iq0q28ErGv55MTzG 7+Kg== X-Gm-Message-State: AOAM530Jur7cNsnbsywsyGzYHghJyvPyWYGpiugffDl32NZugxQoCV3i Sij9XhgcyGSEywC7fdpMWcpQmxXqMPlbdB6q X-Google-Smtp-Source: ABdhPJw4Afa2K3atAb0mbbRA7HIpkt4/9/5Ugrpqi7JoRTkXVbmgfjl9Ow88xTka027k5GJSwRJMsQ== X-Received: by 2002:a63:5148:: with SMTP id r8mr3526493pgl.283.1623307698329; Wed, 09 Jun 2021 23:48:18 -0700 (PDT) Received: from localhost (220-135-95-34.HINET-IP.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id x20sm1386622pfu.205.2021.06.09.23.48.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:48:17 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 7/7][SRU][OEM-5.10] platform/x86: dell-wmi-sysman: Cleanup create_attributes_level_sysfs_files() Date: Thu, 10 Jun 2021 14:47:54 +0800 Message-Id: <20210610064754.1061717-8-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610064754.1061717-1-acelan.kao@canonical.com> References: <20210610064754.1061717-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.215.180; envelope-from=acelan@gmail.com; helo=mail-pg1-f180.google.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: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1931509 Cleanup create_attributes_level_sysfs_files(): 1. There is no need to call sysfs_remove_file() on error, sysman_init() will already call release_attributes_data() on failure which already does this. 2. There is no need for the pr_debug() calls sysfs_create_file() should never fail and if it does it will already complain about the problem itself. Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: Divya Bharathi Cc: Mario Limonciello Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210321115901.35072-8-hdegoede@redhat.com (cherry picked from commit 42f38dcccfb3c235f25f5b0b5a99436ccfcd0737) Signed-off-by: Chia-Lin Kao (AceLan) --- .../platform/x86/dell/dell-wmi-sysman/sysman.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index 1d996bbf7f5a7..a90ae6ba4a73b 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -210,19 +210,17 @@ static struct kobj_attribute pending_reboot = __ATTR_RO(pending_reboot); */ static int create_attributes_level_sysfs_files(void) { - int ret = sysfs_create_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr); + int ret; - if (ret) { - pr_debug("could not create reset_bios file\n"); + ret = sysfs_create_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr); + if (ret) return ret; - } ret = sysfs_create_file(&wmi_priv.main_dir_kset->kobj, &pending_reboot.attr); - if (ret) { - pr_debug("could not create changing_pending_reboot file\n"); - sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr); - } - return ret; + if (ret) + return ret; + + return 0; } static ssize_t wmi_sysman_attr_show(struct kobject *kobj, struct attribute *attr,