From patchwork Sat Jul 15 21:24:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 120854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp355873vqt; Sat, 15 Jul 2023 15:10:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlEnJqHihGoi7UMJRs9d7+CFGRLnlSHiUwDw1ACj7kPu5x1m4I0V9LcfzYsKFv+Sk3dYYXqN X-Received: by 2002:a17:903:455:b0:1b8:a4a9:6225 with SMTP id iw21-20020a170903045500b001b8a4a96225mr7538595plb.7.1689459047439; Sat, 15 Jul 2023 15:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689459047; cv=none; d=google.com; s=arc-20160816; b=qchM+Ih6BnPMMclA/gqm+71PUPWqW0buNftf3COAK1xl7Bmyd5r79qatsfgtkVKRKa rZO0A/S5lqVeQqzF2eXyEuy1QkdAAPuM5zB2ZFiIZRXyeFfMNytSMyjREujgW+yBMboZ ZnhmfX/YlpoVHKqcPV6wrHa94l8EAXZbxpJ6H/VwsxlAb7XvyoRRrwXTxJcfiGh2PcZp fZCU334vobjdAv4WJdgG8XH/v4WOpCingGfEBVsZ2HB0uXK76TH7dttnuNM1fXndRlIp fqU9diWhKFIN/UmMPp3ZWXfOCeUmmgfCWJTC6n6uQHkWHwe1vnHdpddXjG94GnrK5TW7 Ludw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:message-id:subject:from:to:dkim-signature:date; bh=D16/wC9ybg52jiDQV5+eLtWgvfFQ5TkNWX0NVbvr7UM=; fh=pr1skOTrBYO4iZl7wsLE0ZnNuTQDieJQFCBt9vHtbYw=; b=D4gWHqoSX5rP6HKS9WgKYdctYdFHvyiut0I2pl3tSRfbr+HKjTrgickgfBX+38pNud CLMqz+ZjQrIXxN5WXq45JalIOg6kgkSCuA587rbGx9pHw7iJM7/yXhEq+H9oFlClEEkC wdEvA/kdZA3huVwqfs083tyg7KtbUDTcQUr/0Pbey358VxhRdEhJKNKd6qaTarphqqBY lo9Y2T/NROyYR9NGPmXN46XOndKfynCNUztpvm1zf0in6ZeuXzfBf2ChFfqHCfRczlD4 2uBW+kD8BtPJgLSoX9bbMPW4S6IX6cT2u1o4SM7+nlSzqnow0TrWspGWEonumC3E6r2o HKEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=HEgOvr1g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a170902e54c00b001b8ba6a45d2si9692306plf.245.2023.07.15.15.10.20; Sat, 15 Jul 2023 15:10:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=HEgOvr1g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbjGOVYd (ORCPT + 99 others); Sat, 15 Jul 2023 17:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbjGOVYc (ORCPT ); Sat, 15 Jul 2023 17:24:32 -0400 Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C21E62738 for ; Sat, 15 Jul 2023 14:24:31 -0700 (PDT) Date: Sat, 15 Jul 2023 21:24:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1689456269; x=1689715469; bh=D16/wC9ybg52jiDQV5+eLtWgvfFQ5TkNWX0NVbvr7UM=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=HEgOvr1gXJfy3G3zyZiPwPxBdoD7tktehWXIfQl+Sm1e2Hm0s/k6GRcV8TV+XeZNz hh8E2Eq8rjgZURZ0ZRfjRfW072M6VW2tbTnwUmR68cifj5lxylUJ4SuXjdwjbtzp4j m6TA4hW/B4Qm7a7kCNlzCvAarU8o9HHaytB9V9zCCUOo/iBXBKSccN4t4deV7xOzig BZhJaXNO8bYWBO4lGuqrWPg1+ySeA2MC5iYBCsq9yDmYF218ldwWyH8bj4V7Z2Mh5b GB2iE57fDk0zm0nOV1dMfg4J7FiTD4WUwn7GeTo+TqAtbz0eo2NLOwFHVfCouI3faf ikSm1Ec7BpaIA== To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, Mark Gross , Hans de Goede , Armin Wolf , Andy Shevchenko From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH v1] platform/x86: wmi: Do not register driver with invalid GUID Message-ID: <20230715211604.1272227-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771526210000244230 X-GMAIL-MSGID: 1771526210000244230 Since a WMI driver's ID table contains strings it is relatively easy to make mistakes. At the moment, there is no feedback if any of the specified GUIDs are invalid (since 028e6e204ace1f080cfeacd72c50397eb8ae8883). So check if the GUIDs in the driver's ID table are valid, print all invalid ones, and refuse to register the driver if any of the GUIDs are invalid. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index a78ddd83cda0..bf0be40b418a 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1513,6 +1513,19 @@ static int acpi_wmi_probe(struct platform_device *device) int __must_check __wmi_driver_register(struct wmi_driver *driver, struct module *owner) { + bool any_id_invalid = false; + + for (const struct wmi_device_id *id = driver->id_table; *id->guid_string; id++) { + if (!uuid_is_valid(id->guid_string)) { + pr_err("driver '%s' has invalid GUID: %s", + driver->driver.name, id->guid_string); + any_id_invalid = true; + } + } + + if (any_id_invalid) + return -EINVAL; + driver->driver.owner = owner; driver->driver.bus = &wmi_bus_type;