From: Jorge Lopez <jorgealtxwork@gmail.com>
To: "Thomas Weißschuh" <thomas@t-8ch.de>
Cc: hdegoede@redhat.com, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v11 08/14] HP BIOSCFG driver - bioscfg-h
Date: Fri, 28 Apr 2023 11:03:56 -0500 [thread overview]
Message-ID: <CAOOmCE8iBfeuodTO7C=0EUOkqv16008h7vsZO2hhBZPuLoLECw@mail.gmail.com> (raw)
In-Reply-To: <462b5d12-0430-4fbe-8c26-7b6126556ec8@t-8ch.de>
On Fri, Apr 28, 2023 at 10:36 AM Thomas Weißschuh <thomas@t-8ch.de> wrote:
>
> On 2023-04-28 10:24:40-0500, Jorge Lopez wrote:
> > On Sun, Apr 23, 2023 at 7:01 AM Thomas Weißschuh <thomas@t-8ch.de> wrote:
> > >
> > > On 2023-04-20 11:54:48-0500, Jorge Lopez wrote:
> > > > ---
> > > > drivers/platform/x86/hp/hp-bioscfg/bioscfg.h | 613 +++++++++++++++++++
> > > > 1 file changed, 613 insertions(+)
> > > > create mode 100644 drivers/platform/x86/hp/hp-bioscfg/bioscfg.h
>
> <snip>
>
> > > > +/* global structure used by multiple WMI interfaces */
> > > > +extern struct bioscfg_priv bioscfg_drv;
> > > > +
> > > > +enum hp_wmi_data_type {
> > > > + HPWMI_STRING_TYPE = 0x00,
> > > > + HPWMI_INTEGER_TYPE = 0x01,
> > > > + HPWMI_ENUMERATION_TYPE = 0x02,
> > > > + HPWMI_ORDERED_LIST_TYPE = 0x03,
> > > > + HPWMI_PASSWORD_TYPE = 0x04,
> > > > + HPWMI_SECURE_PLATFORM_TYPE = 0x05,
> > > > + HPWMI_SURE_START_TYPE = 0x06
> > > > +};
> > >
> > > Unused.
> >
> > Both hp_wmi_data_type and hp_wmi_data_elements are used
> > for instance HP_WMI_STRING_TYPE
> >
> > bioscfg.c:338: case HPWMI_STRING_TYPE:
> > bioscfg.c:626: case HPWMI_STRING_TYPE:
> > bioscfg.c:722: case HPWMI_STRING_TYPE:
> > bioscfg.c:798: case HPWMI_STRING_TYPE:
> > bioscfg.c:906: ret = hp_init_bios_attributes(HPWMI_STRING_TYPE,
> > HP_WMI_BIOS_STRING_GUID);
> > bioscfg.h:247: HPWMI_STRING_TYPE
>
> Indeed. I think I just searched for "hp_wmi_data_type".
>
> The proper enum hp_wmi_data_type type should be used instead of
> "int attr_type".
>
Done!
> <snip>
>
> > > > +
> > > > +enum hp_wmi_elements_count {
> > > > + STRING_ELEM_CNT = 12,
> > > > + INTEGER_ELEM_CNT = 13,
> > > > + ENUM_ELEM_CNT = 13,
> > > > + ORDERED_ELEM_CNT = 12,
> > > > + PASSWORD_ELEM_CNT = 15
> > > > +};
> > >
> > > To make it clearer where these values come from you could put them into
> > > the enum hp_wmi_data_elements.
> > >
> > > ...
> > > ORD_LIST_ELEMENTS = 11,
> > > ORD_LIST_ELEM_CNT = 12,
> > > ...
> >
> > Done! changes provided across all files affected.
> >
> > >
> > > But replacing the loop logic would remove the need for these enums
> > > completely.
> > >
> >
> > _CNT values are necessary when elements are read from a buffer (
> > populate_string_elements_from_buffer).
> > _CNT values are not needed when elements are read from a package
> > (populate_string_package_data)
>
> Hm, I don't see why populate_string_elements_from_buffer() would need
> the _CNT define.
>
> (In another review mail I wrote down how I would expect it to look
> without the loop)
>
> <snip>
>
> > > > +
> > > > +#define ATTRIBUTE_PROPERTY_STORE(curr_val, type) \
> > > > + static ssize_t curr_val##_store(struct kobject *kobj, \
> > > > + struct kobj_attribute *attr, \
> > > > + const char *buf, size_t count) \
> > > > + { \
> > > > + char *p = NULL; \
> > > > + char *attr_value = NULL; \
> > > > + int i; \
> > > > + int ret = -EIO; \
> > > > + \
> > > > + attr_value = kstrdup(buf, GFP_KERNEL); \
> > > > + if (!attr_value) \
> > > > + return -ENOMEM; \
> > > > + \
> > > > + p = memchr(attr_value, '\n', count); \
> > > > + if (p != NULL) \
> > > > + *p = '\0'; \
> > >
> > > This can also truncate the string if there is data after the newline.
> >
> > This is a expected behavior as described by Hans in a later email
>
> I'm fine with stripping a trailing newline.
>
> But this truncates the string at the first newline.
>
> "foo\nbar" -> "foo"
> "\nfoo" -> ""
>
All inputs expected by this driver and respectively by BIOS are a
single line. For this reason, '\n' will cause the string to be
truncated.
I propose reporting a warning message indicating that the data entered
has a '\n' character and will be truncated in addition to failing the
operation with -EINVAL
> <snip>
next prev parent reply other threads:[~2023-04-28 16:04 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 16:54 [PATCH v11 00/14] HP BIOSCFG driver Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 01/14] HP BIOSCFG driver - Documentation Jorge Lopez
2023-04-22 20:50 ` Thomas Weißschuh
2023-04-24 16:11 ` Jorge Lopez
2023-04-24 20:52 ` Thomas Weißschuh
2023-04-24 21:35 ` Jorge Lopez
2023-04-26 13:04 ` Hans de Goede
2023-04-20 16:54 ` [PATCH v11 02/14] HP BIOSCFG driver - biosattr-interface Jorge Lopez
2023-04-22 21:30 ` Thomas Weißschuh
2023-04-24 20:33 ` Jorge Lopez
2023-04-24 21:04 ` Thomas Weißschuh
2023-04-24 21:49 ` Jorge Lopez
2023-04-24 22:14 ` Jorge Lopez
2023-04-25 5:28 ` Thomas Weißschuh
2023-04-25 13:39 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 03/14] HP BIOSCFG driver - bioscfg Jorge Lopez
2023-04-22 22:16 ` thomas
2023-05-02 19:52 ` Jorge Lopez
2023-05-02 21:14 ` Thomas Weißschuh
2023-05-02 21:36 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 04/14] HP BIOSCFG driver - int-attributes Jorge Lopez
2023-04-22 22:43 ` Thomas Weißschuh
2023-05-02 20:56 ` Jorge Lopez
2023-05-02 21:30 ` Thomas Weißschuh
2023-05-03 15:35 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 05/14] HP BIOSCFG driver - ordered-attributes Jorge Lopez
2023-04-23 6:54 ` thomas
2023-05-05 16:09 ` Jorge Lopez
2023-05-05 21:11 ` Thomas Weißschuh
2023-05-05 21:57 ` Jorge Lopez
2023-05-06 5:51 ` Thomas Weißschuh
2023-05-08 13:56 ` Jorge Lopez
2023-05-08 20:50 ` Thomas Weißschuh
2023-05-08 21:25 ` Jorge Lopez
2023-05-09 18:38 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 06/14] HP BIOSCFG driver - passwdobj-attributes Jorge Lopez
2023-04-23 9:07 ` thomas
2023-04-26 13:13 ` Hans de Goede
2023-05-04 20:29 ` Jorge Lopez
2023-05-04 20:59 ` Thomas Weißschuh
2023-05-04 21:34 ` Jorge Lopez
2023-05-04 22:21 ` Thomas Weißschuh
2023-05-05 14:30 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 07/14] HP BIOSCFG driver - string-attributes Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 08/14] HP BIOSCFG driver - bioscfg-h Jorge Lopez
2023-04-23 12:01 ` Thomas Weißschuh
2023-04-28 15:24 ` Jorge Lopez
2023-04-28 15:36 ` Thomas Weißschuh
2023-04-28 16:03 ` Jorge Lopez [this message]
2023-04-28 16:09 ` Thomas Weißschuh
2023-04-28 16:19 ` Jorge Lopez
2023-04-28 16:30 ` Thomas Weißschuh
2023-04-28 19:38 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 09/14] HP BIOSCFG driver - enum-attributes Jorge Lopez
2023-04-23 12:55 ` Thomas Weißschuh
2023-05-03 19:42 ` Jorge Lopez
2023-05-03 20:10 ` Thomas Weißschuh
2023-05-03 21:08 ` Jorge Lopez
2023-05-04 15:51 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 10/14] HP BIOSCFG driver - passwdattr-interface Jorge Lopez
2023-04-23 12:58 ` Thomas Weißschuh
2023-05-03 21:16 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 11/14] HP BIOSCFG driver - spmobj-attributes Jorge Lopez
2023-04-23 9:24 ` thomas
2023-05-03 19:34 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 12/14] HP BIOSCFG driver - surestart-attributes Jorge Lopez
2023-04-23 12:16 ` Thomas Weißschuh
2023-04-27 22:17 ` Jorge Lopez
2023-04-28 6:03 ` Thomas Weißschuh
2023-04-28 14:58 ` Jorge Lopez
2023-04-28 15:21 ` Thomas Weißschuh
2023-04-28 15:40 ` Jorge Lopez
2023-04-28 16:06 ` Thomas Weißschuh
2023-04-28 16:12 ` Jorge Lopez
2023-04-28 20:46 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 13/14] HP BIOSCFG driver - Makefile Jorge Lopez
2023-05-04 11:59 ` kernel test robot
2023-05-04 13:45 ` Jorge Lopez
2023-04-20 16:54 ` [PATCH v11 14/14] HP BIOSCFG driver - MAINTAINERS Jorge Lopez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOOmCE8iBfeuodTO7C=0EUOkqv16008h7vsZO2hhBZPuLoLECw@mail.gmail.com' \
--to=jorgealtxwork@gmail.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=thomas@t-8ch.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®