lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4055223.VTxhiZFAix@pc-42>
Date:   Thu, 10 Feb 2022 15:41:39 +0100
From:   Jérôme Pouiller <jerome.pouiller@...abs.com>
To:     Kalle Valo <kvalo@...nel.org>
Cc:     linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "David S . Miller" <davem@...emloft.net>,
        devicetree@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
        linux-mmc@...r.kernel.org,
        Pali Rohár <pali@...nel.org>,
        Ulf Hansson <ulf.hansson@...aro.org>
Subject: Re: [PATCH v9 05/24] wfx: add main.c/main.h

On Thursday 10 February 2022 15:20:56 CET Kalle Valo wrote:
> 
> Jérôme Pouiller <jerome.pouiller@...abs.com> writes:
> 
> > Hi Kalle,
> >
> > On Tuesday 11 January 2022 18:14:05 CET Jerome Pouiller wrote:
> >> From: Jérôme Pouiller <jerome.pouiller@...abs.com>
> >>
> >> Signed-off-by: Jérôme Pouiller <jerome.pouiller@...abs.com>
> >> ---
> >>  drivers/net/wireless/silabs/wfx/main.c | 485 +++++++++++++++++++++++++
> >>  drivers/net/wireless/silabs/wfx/main.h |  42 +++
> >>  2 files changed, 527 insertions(+)
> >>  create mode 100644 drivers/net/wireless/silabs/wfx/main.c
> >>  create mode 100644 drivers/net/wireless/silabs/wfx/main.h
> >>
> > [...]
> >> +/* The device needs data about the antenna configuration. This information in
> >> + * provided by PDS (Platform Data Set, this is the wording used in WF200
> >> + * documentation) files. For hardware integrators, the full process to create
> >> + * PDS files is described here:
> >> + *   https:github.com/SiliconLabs/wfx-firmware/blob/master/PDS/README.md
> >> + *
> >> + * The PDS file is an array of Time-Length-Value structs.
> >> + */
> >> + int wfx_send_pds(struct wfx_dev *wdev, u8 *buf, size_t len)
> >> +{
> >> +    int ret, chunk_type, chunk_len, chunk_num = 0;
> >> +
> >> +    if (*buf == '{') {
> >> +            dev_err(wdev->dev, "PDS: malformed file (legacy format?)\n");
> >> +            return -EINVAL;
> >> +    }
> >> +    while (len > 0) {
> >> +            chunk_type = get_unaligned_le16(buf + 0);
> >> +            chunk_len = get_unaligned_le16(buf + 2);
> >> +            if (chunk_len > len) {
> >> +                    dev_err(wdev->dev, "PDS:%d: corrupted file\n", chunk_num);
> >> +                    return -EINVAL;
> >> +            }
> >> +            if (chunk_type != WFX_PDS_TLV_TYPE) {
> >> +                    dev_info(wdev->dev, "PDS:%d: skip unknown data\n", chunk_num);
> >> +                    goto next;
> >> +            }
> >> +            if (chunk_len > WFX_PDS_MAX_CHUNK_SIZE)
> >> + dev_warn(wdev->dev, "PDS:%d: unexpectly large chunk\n",
> >> chunk_num);
> >> +            if (buf[4] != '{' || buf[chunk_len - 1] != '}')
> >> + dev_warn(wdev->dev, "PDS:%d: unexpected content\n", chunk_num);
> >> +
> >> +            ret = wfx_hif_configuration(wdev, buf + 4, chunk_len - 4);
> >> +            if (ret > 0) {
> >> + dev_err(wdev->dev, "PDS:%d: invalid data (unsupported
> >> options?)\n",
> >> +                            chunk_num);
> >> +                    return -EINVAL;
> >> +            }
> >> +            if (ret == -ETIMEDOUT) {
> >> + dev_err(wdev->dev, "PDS:%d: chip didn't reply (corrupted
> >> file?)\n",
> >> +                            chunk_num);
> >> +                    return ret;
> >> +            }
> >> +            if (ret) {
> >> + dev_err(wdev->dev, "PDS:%d: chip returned an unknown error\n",
> >> chunk_num);
> >> +                    return -EIO;
> >> +            }
> >> +next:
> >> +            chunk_num++;
> >> +            len -= chunk_len;
> >> +            buf += chunk_len;
> >> +    }
> >> +    return 0;
> >> +}
> >
> > Kalle, is this function what you expected? If it is right for you, I am
> > going to send it to the staging tree.
> 
> Looks better, but I don't get why '{' and '}' are still needed. Ah, does
> the firmware require to have them?

Indeed. If '{' and '}' are not present, I guarantee the firmware will return
an error (or assert). However, I am more confident in the driver than in the
firmware to report errors to the user.

If there is no other comment, I am going to:
  - submit this change to the staging tree
  - publish the tool that generate this new format
  - submit the PDS files referenced in bus_{sdio,spi}.c to linux-firmware
  - send the v10 of this PR


-- 
Jérôme Pouiller


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ