From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Nicolas Bouchinet <nicolas.bouchinet@oss.cyber.gouv.fr>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Kannappan R <r.kannappan@intel.com>,
Sabyrzhan Tasbolatov <snovitoll@gmail.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Stefan Eichenberger <stefan.eichenberger@toradex.com>,
Thomas Gleixner <tglx@linutronix.de>,
Pawel Laszczak <pawell@cadence.com>, Ma Ke <make_ruc2021@163.com>,
Jeff Johnson <jeff.johnson@oss.qualcomm.com>,
Luc Bonnafoux <luc.bonnafoux@ssi.gouv.fr>,
Luc Bonnafoux <luc.bonnafoux@oss.cyber.gouv.fr>,
Nicolas Bouchinet <nicolas.bouchinet@ssi.gouv.fr>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [RFC PATCH 2/4] usb: core: Introduce usb authentication feature
Date: Mon, 30 Jun 2025 13:43:05 +0200 [thread overview]
Message-ID: <2025063051-yelp-brim-d2d6@gregkh> (raw)
In-Reply-To: <16140d2c-1d44-400b-93de-2216013f017f@oss.cyber.gouv.fr>
On Mon, Jun 30, 2025 at 01:07:29PM +0200, Nicolas Bouchinet wrote:
> Hi Greg,
>
> Thank you very much for your review. We will take every style remarks into
> account in the next patch version. Other responses are inline (there is only
> one):
>
> On 6/20/25 16:54, Greg Kroah-Hartman wrote:
> > First off, thanks so much for doing this work, I've been wondering if
> > anyone would ever do it :)
> >
> > Just a few quick review comments that you might want to do for the next
> > round of your patches for some basic style things:
> >
> > On Fri, Jun 20, 2025 at 04:27:17PM +0200, nicolas.bouchinet@oss.cyber.gouv.fr wrote:
> > > +#include <linux/types.h>
> > > +#include <linux/usb.h>
> > > +#include <linux/usb/ch9.h>
> > > +#include <linux/usb/hcd.h>
> > > +#include <linux/usb/quirks.h>
> > > +#include <linux/module.h>
> > > +#include <linux/slab.h>
> > > +#include <linux/device.h>
> > > +#include <linux/delay.h>
> > > +#include <asm/byteorder.h>
> > > +
> > > +#include "authent_netlink.h"
> > > +
> > > +#include "authent.h"
> > No need for the blank lines there.
> >
> > > +static int usb_authent_req_digest(struct usb_device *dev, uint8_t *const buffer,
> > > + uint8_t digest[256], uint8_t *mask)
> > > +{
> > > + int ret = 0;
> > > + struct usb_authent_digest_resp *digest_resp = NULL;
> > > +
> > > + if (unlikely((buffer == NULL || mask == NULL))) {
> > > + pr_err("invalid arguments\n");
> > > + return -EINVAL;
> > > + }
> > > + ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), AUTH_IN, USB_DIR_IN,
> > > + (USB_SECURITY_PROTOCOL_VERSION << 8) +
> > > + USB_AUTHENT_DIGEST_REQ_TYPE,
> > > + 0, buffer, 260, USB_CTRL_GET_TIMEOUT);
> > > + if (ret < 0) {
> > > + pr_err("Failed to get digest: %d\n", ret);
> > > + ret = -ECOMM;
> > > + goto exit;
> > > + }
> > > +
> > > + // Parse received digest response
> > > + digest_resp = (struct usb_authent_digest_resp *)buffer;
> > > + pr_notice("received digest response:\n");
> > > + pr_notice(" protocolVersion: %x\n", digest_resp->protocolVersion);
> > > + pr_notice(" messageType: %x\n", digest_resp->messageType);
> > > + pr_notice(" capability: %x\n", digest_resp->capability);
> > > + pr_notice(" slotMask: %x\n", digest_resp->slotMask);
> > Always use the dev_*() macros instead of pr_*() ones as that way you
> > know what device is making the message please.
> >
> > > +
> > > + *mask = digest_resp->slotMask;
> > > + memcpy(digest, digest_resp->digests, 256);
> > > +
> > > + ret = 0;
> > > +
> > > +exit:
> > > +
> > > + return ret;
> > > +}
> > > +
> > > +struct usb_auth_cert_req {
> > > + uint16_t offset;
> > > + uint16_t length;
> > > +} __packed;
> > Kernel types are u16, not uint16_t. The uint*_t types are from
> > userspace C code, not kernel code. Yes, they are slowly sliding in in
> > places, but let's not do that unless really required for some specific
> > reason.
> >
> > And why packed?
>
> Since this structure is part of the usb authentication protocol, we need to
> be
> sure it is sent as is on the usb bus.
Great, then properly document it as such please. Ideally in a header
file as we have tried to document all the USB messages in ch9.h where
defined.
thanks,
greg k-h
next prev parent reply other threads:[~2025-06-30 11:43 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 14:27 [RFC PATCH 0/4] Support for usb authentication nicolas.bouchinet
2025-06-20 14:27 ` [RFC PATCH 1/4] usb: core: Introduce netlink usb authentication policy engine nicolas.bouchinet
2025-06-21 9:37 ` Sabyrzhan Tasbolatov
2025-06-30 11:42 ` Nicolas Bouchinet
2025-06-20 14:27 ` [RFC PATCH 2/4] usb: core: Introduce usb authentication feature nicolas.bouchinet
2025-06-20 14:54 ` Greg Kroah-Hartman
2025-06-30 11:07 ` Nicolas Bouchinet
2025-06-30 11:43 ` Greg Kroah-Hartman [this message]
2025-06-21 10:21 ` Sabyrzhan Tasbolatov
2025-06-30 11:56 ` Nicolas Bouchinet
2025-06-25 9:59 ` Oliver Neukum
2025-06-30 12:38 ` Nicolas Bouchinet
2025-06-20 14:27 ` [RFC PATCH 3/4] usb: core: Plug the usb authentication capability nicolas.bouchinet
2025-06-20 19:11 ` Alan Stern
2025-06-30 11:20 ` Nicolas Bouchinet
2025-06-30 18:04 ` Alan Stern
2025-06-21 11:09 ` Sabyrzhan Tasbolatov
2025-06-30 12:25 ` Nicolas Bouchinet
2025-06-23 18:15 ` Oliver Neukum
2025-06-30 12:34 ` Nicolas Bouchinet
2025-06-30 13:07 ` Oliver Neukum
2025-06-20 14:27 ` [RFC PATCH 4/4] usb: core: Add Kconfig option to compile usb authorization nicolas.bouchinet
2025-06-21 7:22 ` Greg Kroah-Hartman
2025-06-30 11:22 ` Nicolas Bouchinet
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=2025063051-yelp-brim-d2d6@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=luc.bonnafoux@oss.cyber.gouv.fr \
--cc=luc.bonnafoux@ssi.gouv.fr \
--cc=make_ruc2021@163.com \
--cc=nicolas.bouchinet@oss.cyber.gouv.fr \
--cc=nicolas.bouchinet@ssi.gouv.fr \
--cc=pawell@cadence.com \
--cc=r.kannappan@intel.com \
--cc=snovitoll@gmail.com \
--cc=stefan.eichenberger@toradex.com \
--cc=stern@rowland.harvard.edu \
--cc=tglx@linutronix.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