Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7858241rwr; Wed, 10 May 2023 13:46:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZPTqaVRvXhbMJrUhXu0TyqsMiajZ5il55NjF8GTYoH4K/AcldqYGOs+JLiEvRybLiWt2Z X-Received: by 2002:a17:903:247:b0:1ab:16cd:51a3 with SMTP id j7-20020a170903024700b001ab16cd51a3mr24940472plh.10.1683751596228; Wed, 10 May 2023 13:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683751596; cv=none; d=google.com; s=arc-20160816; b=fwHZ/43pGJ7x4eR+JQKkOwjGWu6pdFqjTMu2mGDAT7tq+4PeiDiLTB9kCHwpCRf/YF nbAom28AqrzhQG4ranB9SrcHFxo5RlcG9Q7mI+YDMsyeY8Zo0WdU7bxBD+qM40tCk0EE qrdV8qvAesBCkNn2hjJaax55CbNbQUrpkNn1DDIghcpYgUxFVToGNJ+aU2P6araSH2hc 6jBhjl8ivl0oDaiJX/ItEFchEtyGOqdwIw2l5+RidTyukEdI/BCM4nI8IjaAILJLMbRf uyJNJk9zXtViGIz6GrqaLvZK+gycqZqCZHLwCDV5ZdqApq0tp9Epp4BHm4TEC+erUfKM hNOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PTuiC0ua1kIyWi3iheh/3XF1H10GgI50sRM4ZeY/JDg=; b=WbOaXR+uMGK4ZiZtMaOg/GAgf4KKQC8W9L4UudL8bQxq5EkNVdQFlZk426g5yZMR5I 12CH+AAJo4wXKKd2ZzqjhtHn6WnXcGmoqr2cb8kRt+DwtghmUGKwlygobwjbJ21XEfkv GKFIsv7RfK3wrl7BQpYYscJcUM2y2NwyzyGhNVMPB0LCgWzM/qYcLGtiAlbF5L5wY+7G wo2EKj9NEBZ1JCJ+AEYUbEtNOqvWPnPj4y38CouA3YC3iYi/o7kbSpVYWKQT8oNwp8gc 5Vm8NfcdwHMhcRa+PWUximZdcz5HBvErG9lzyW1Uv0gusplZppaZ00P+eLOpAJoaw9ry DUFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EtKP6OM3; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 20-20020a17090a1a1400b0024e500f373fsi18108832pjk.82.2023.05.10.13.46.21; Wed, 10 May 2023 13:46:36 -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=@gmail.com header.s=20221208 header.b=EtKP6OM3; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236184AbjEJUgT (ORCPT + 99 others); Wed, 10 May 2023 16:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235982AbjEJUgS (ORCPT ); Wed, 10 May 2023 16:36:18 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 015D14C16; Wed, 10 May 2023 13:36:16 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4ecb137af7eso8744925e87.2; Wed, 10 May 2023 13:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683750975; x=1686342975; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PTuiC0ua1kIyWi3iheh/3XF1H10GgI50sRM4ZeY/JDg=; b=EtKP6OM3eAtq9L7LIAH4ZD/qwUKVCv5RUrIRvLK65LqgYDQJ6DIMmcbScvI2ybkfR9 18LS2Nw6eltSEzL0eos7uwew0qWPitrbQXlkjWZl904zhOl/df/DIPQIttpiz9i3ZTnt m7f5lUnwmvpGSmFUq0zZExX6Vd4fVH/u78WB1mN8bT4RjYxPfUkGatD5Wvg+4XKPvmdk GRLqI86DTahAPl4Vzs3OUAV2gimPQHpT8ICd/K0gXkTJBRtyzrthi0FMgfO6s/oTK7zz LkgGpvSv2YNiXM2Wm2HWrgDzBpZ9eL3iqTC5xwsELAU+lLW2ilBzua/Y/jSMNxWXpAAc VqbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683750975; x=1686342975; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PTuiC0ua1kIyWi3iheh/3XF1H10GgI50sRM4ZeY/JDg=; b=Qt07KTOBAGuy5nb0+tjY3ExYGE1CgdFG2TGaW84Sik0hIpO5q4Qmkzz8WzMehlUqhA VBsLhOmv9NJpA+MOa5uwg7clPna2vfjubl/7X6742tAKG1dWiC8YmxzAVzBRuNw2MVJI P+ub5ChNlJ79QJRzNLOm4F8sd5EXSQjsNeDQLHlIFH4dc67134Fk5jTBPBDXyMc1QBm8 Qm6bcwvPHliRXRlWvT3lg05PGP3DKMG2ALTYl/BGV/C0P62poRJsqzYc2ahNIcBwjBB/ 5Zbjh5l6mWtaJMU5dStr5v3hGjNQ+OyDPRgtl5FrCCjDZMULKTC2WSd5l02X4o7ztjbQ 4Yjg== X-Gm-Message-State: AC+VfDxFjgtgFgCdM+ktwRaMcaTPSv7u3hfZCzcpw6f4//SnOjgVcMDC 4FabcQFhRVx5WBi2357jTDPnw7PhdLhViNfhq4A= X-Received: by 2002:a2e:9c18:0:b0:2ad:bedc:995b with SMTP id s24-20020a2e9c18000000b002adbedc995bmr218134lji.16.1683750975077; Wed, 10 May 2023 13:36:15 -0700 (PDT) MIME-Version: 1.0 References: <20230505220043.39036-1-jorge.lopez2@hp.com> <20230505220043.39036-8-jorge.lopez2@hp.com> <882cc771-7fdb-5ba6-b4ae-36e7d3ad920@linux.intel.com> In-Reply-To: <882cc771-7fdb-5ba6-b4ae-36e7d3ad920@linux.intel.com> From: Jorge Lopez Date: Wed, 10 May 2023 15:35:46 -0500 Message-ID: Subject: Re: [PATCH v12 07/13] HP BIOSCFG driver - string-attributes To: =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= Cc: hdegoede@redhat.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, thomas@t-8ch.de Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Tue, May 9, 2023 at 8:18=E2=80=AFAM Ilpo J=C3=A4rvinen wrote: > > On Fri, 5 May 2023, Jorge Lopez wrote: > > > HP BIOS Configuration driver purpose is to provide a driver supporting > > the latest sysfs class firmware attributes framework allowing the user > > to change BIOS settings and security solutions on HP Inc.=E2=80=99s com= mercial > > notebooks. > > > > Many features of HP Commercial notebooks can be managed using Windows > > Management Instrumentation (WMI). WMI is an implementation of Web-Based > > Enterprise Management (WBEM) that provides a standards-based interface > > for changing and monitoring system settings. HP BIOSCFG driver provides > > a native Linux solution and the exposed features facilitates the > > migration to Linux environments. > > > > The Linux security features to be provided in hp-bioscfg driver enables > > managing the BIOS settings and security solutions via sysfs, a virtual > > filesystem that can be used by user-mode applications. The new > > documentation cover HP-specific firmware sysfs attributes such Secure > > Platform Management and Sure Start. Each section provides security > > feature description and identifies sysfs directories and files exposed > > by the driver. > > > > Many HP Commercial notebooks include a feature called Secure Platform > > Management (SPM), which replaces older password-based BIOS settings > > management with public key cryptography. PC secure product management > > begins when a target system is provisioned with cryptographic keys > > that are used to ensure the integrity of communications between system > > management utilities and the BIOS. > > > > HP Commercial notebooks have several BIOS settings that control its > > behaviour and capabilities, many of which are related to security. > > To prevent unauthorized changes to these settings, the system can > > be configured to use a cryptographic signature-based authorization > > string that the BIOS will use to verify authorization to modify the > > setting. > > > > Linux Security components are under development and not published yet. > > The only linux component is the driver (hp bioscfg) at this time. > > Other published security components are under Windows. > > > > Signed-off-by: Jorge Lopez > > > > --- > > Based on the latest platform-drivers-x86.git/for-next > > --- > > .../x86/hp/hp-bioscfg/string-attributes.c | 415 ++++++++++++++++++ > > 1 file changed, 415 insertions(+) > > create mode 100644 drivers/platform/x86/hp/hp-bioscfg/string-attribute= s.c > > > > diff --git a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c b/d= rivers/platform/x86/hp/hp-bioscfg/string-attributes.c > > new file mode 100644 > > index 000000000000..d74ecc973703 > > --- /dev/null > > +static void update_string_value(int instance_id, char *attr_value) > > +{ > > + struct string_data *string_data =3D &bioscfg_drv.string_data[inst= ance_id]; > > + > > + /* Write settings to BIOS */ > > + strscpy(string_data->current_value, > > + attr_value, > > + sizeof(string_data->current_value)); > > Use less lines. Done! > > > +} > > + > > +ATTRIBUTE_S_COMMON_PROPERTY_SHOW(display_name_language_code, string); > > +static struct kobj_attribute string_display_langcode =3D > > + __ATTR_RO(display_name_language_code); > > + > > +ATTRIBUTE_S_COMMON_PROPERTY_SHOW(display_name, string); > > +static struct kobj_attribute string_display_name =3D > > + __ATTR_RO(display_name); > > + > > +ATTRIBUTE_PROPERTY_STORE(current_value, string); > > +static struct kobj_attribute string_current_val =3D > > + __ATTR_RW_MODE(current_value, 0644); > > + > > +ATTRIBUTE_N_PROPERTY_SHOW(min_length, string); > > +static struct kobj_attribute string_min_length =3D > > + __ATTR_RO(min_length); > > + > > +ATTRIBUTE_N_PROPERTY_SHOW(max_length, string); > > +static struct kobj_attribute string_max_length =3D > > + __ATTR_RO(max_length); > > + > > +static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *= attr, > > + char *buf) > > +{ > > + return sysfs_emit(buf, "string\n"); > > +} > > + > > +static struct kobj_attribute string_type =3D > > + __ATTR_RO(type); > > + > > +static struct attribute *string_attrs[] =3D { > > + &string_display_langcode.attr, > > + &string_display_name.attr, > > + &string_current_val.attr, > > + &string_min_length.attr, > > + &string_max_length.attr, > > + &string_type.attr, > > + NULL, > > +}; > > + > > +static const struct attribute_group string_attr_group =3D { > > + .attrs =3D string_attrs, > > +}; > > + > > +int alloc_string_data(void) > > +{ > > + bioscfg_drv.string_instances_count =3D get_instance_count(HP_WMI_= BIOS_STRING_GUID); > > + bioscfg_drv.string_data =3D kcalloc(bioscfg_drv.string_instances_= count, > > + sizeof(struct string_data), GFP= _KERNEL); > > sizeof(*bioscfg_drv.string_data) ? Done! > > > + if (!bioscfg_drv.string_data) { > > + bioscfg_drv.string_instances_count =3D 0; > > + return -ENOMEM; > > + } > > + return 0; > > +} > > +