mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Harald Mommer <hmo@opensynergy.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, linux-kernel@vger.kernel.org
Cc: maxim.uvarov@linaro.org, joakim.bech@linaro.org,
	ulf.hansson@linaro.org, ilias.apalodimas@linaro.org,
	arnd@linaro.org, ruchika.gupta@linaro.org,
	tomas.winkler@intel.com, yang.huang@intel.com,
	bing.zhu@intel.com, Matti.Moell@opensynergy.com,
	linux-mmc@vger.kernel.org, linux-scsi@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Arnd Bergmann <arnd.bergmann@linaro.org>,
	Alexander Usyskin <alexander.usyskin@intel.com>,
	Avri Altman <avri.altman@sandisk.com>
Subject: Re: [PATCH v2 2/4] char: rpmb: provide a user space interface
Date: Thu, 16 Jun 2022 17:09:04 +0200	[thread overview]
Message-ID: <0222bc88-e3d1-243b-ffb1-111ba6bcd764@opensynergy.com> (raw)
In-Reply-To: <20220405093759.1126835-3-alex.bennee@linaro.org>

Hello,

On 05.04.22 11:37, Alex Bennée wrote:
> The user space API is achieved via a number of synchronous IOCTLs.
>
>    * RPMB_IOC_VER_CMD - simple versioning API
>    * RPMB_IOC_CAP_CMD - query of underlying capabilities
>    * RPMB_IOC_PKEY_CMD - one time programming of access key
>    * RPMB_IOC_COUNTER_CMD - query the write counter
>    * RPMB_IOC_WBLOCKS_CMD - write blocks to device
>    * RPMB_IOC_RBLOCKS_CMD - read blocks from device
>
> The operations which require authenticated frames or will respond with
> MAC hashes of nonce filled frames that userspace will need to verify
> share a common command frame format. The other operations can be
> considered generic and allow for common handling.
>
> [AJB: here the are key difference is the avoiding a single ioctl where
> all the frame data is put together by user space. User space is still
> the only place where certain operations can be verified due to the
> need of a secret key]
I have less problems to understand this reworked ioctl() interface as I 
had with the older one. Nice.
> diff --git a/drivers/rpmb/cdev.c b/drivers/rpmb/cdev.c
> ...
> +static long rpmb_ioctl_cap_cmd(struct rpmb_dev *rdev,
> +			       struct rpmb_ioc_cap_cmd __user *ptr)
> +{
> +	struct rpmb_ioc_cap_cmd cap;
> +
> +	cap.target      = rdev->target;
> +	cap.block_size  = rdev->ops->block_size;
> +	cap.wr_cnt_max  = rdev->ops->wr_cnt_max;
> +	cap.rd_cnt_max  = rdev->ops->rd_cnt_max;
> +	cap.capacity    = rpmb_get_capacity(rdev);
> +	cap.reserved    = 0;
auth_method is still part of the structure but not set. Means arbitrary 
data from the stack is copied to user land.
> +
> +	return copy_to_user(ptr, &cap, sizeof(cap)) ? -EFAULT : 0;
> +}
> ...
> +/**
> + * struct rpmb_ioc_cap_cmd - rpmb capabilities
> + *
> + * @target: rpmb target/region within RPMB partition.
> + * @capacity: storage capacity (in units of 128K)
> + * @block_size: storage data block size (in units of 256B)
> + * @wr_cnt_max: maximal number of block that can be written in a single request.
> + * @rd_cnt_max: maximal number of block that can be read in a single request.
> + * @auth_method: authentication method: currently always HMAC_SHA_256
> + * @reserved: reserved to align to 4 bytes.
> + */
> +struct rpmb_ioc_cap_cmd {
> +	__u16 target;
> +	__u16 capacity;
> +	__u16 block_size;
> +	__u16 wr_cnt_max;
> +	__u16 rd_cnt_max;
> +	__u16 auth_method;
> +	__u16 reserved;
> +} __packed;
> ...+

-- 
Dipl.-Ing. Harald Mommer
Senior Software Engineer

OpenSynergy GmbH
Rotherstr. 20, 10245 Berlin

Phone:  +49 (30) 60 98 540-0 <== Zentrale
Fax:    +49 (30) 60 98 540-99
E-Mail: harald.mommer@opensynergy.com

www.opensynergy.com

Handelsregister: Amtsgericht Charlottenburg, HRB 108616B
Geschäftsführer/Managing Director: Regis Adjamah



  reply	other threads:[~2022-06-16 15:09 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05  9:37 [PATCH v2 0/4] rpmb subsystem, uapi and virtio-rpmb driver Alex Bennée
2022-04-05  9:37 ` [PATCH v2 1/4] rpmb: add Replay Protected Memory Block (RPMB) subsystem Alex Bennée
2022-04-05 21:59   ` Bart Van Assche
2022-04-06 11:21     ` Alex Bennée
2022-04-05  9:37 ` [PATCH v2 2/4] char: rpmb: provide a user space interface Alex Bennée
2022-06-16 15:09   ` Harald Mommer [this message]
2022-06-16 19:21   ` Arnd Bergmann
2022-04-05  9:37 ` [PATCH v2 3/4] rpmb: create virtio rpmb frontend driver Alex Bennée
2022-06-16 15:44   ` Harald Mommer
2022-04-05  9:37 ` [PATCH v2 4/4] tools rpmb: add RPBM access tool Alex Bennée
2022-06-16 13:13   ` Harald Mommer
2022-04-05 14:54 ` [PATCH v2 0/4] rpmb subsystem, uapi and virtio-rpmb driver Bean Huo
2022-04-05 15:43   ` Alex Bennée
2022-04-05 17:03     ` Bean Huo
2022-04-06 11:22       ` Alex Bennée
2022-04-06 17:19         ` Bean Huo
2022-04-06 17:32           ` Bart Van Assche
2022-04-06 18:12             ` Bean Huo
2022-04-06 20:20               ` Bart Van Assche
2022-04-07 16:28                 ` Bean Huo
2022-04-06 17:27         ` Bean Huo
2022-04-22 14:21 ` Alex Bennée
     [not found] ` <20230531191007.13460-1-shyamsaini@linux.microsoft.com>
2023-06-01  1:02   ` Zhu, Bing
2023-06-01  5:31     ` Ilias Apalodimas
2023-06-01  5:48       ` Sumit Garg
2023-06-02  8:25         ` Ilias Apalodimas
2023-06-12 17:06           ` Jens Wiklander
2023-06-13  0:49           ` Shyam Saini
2023-06-13 16:47     ` Shyam Saini

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=0222bc88-e3d1-243b-ffb1-111ba6bcd764@opensynergy.com \
    --to=hmo@opensynergy.com \
    --cc=Matti.Moell@opensynergy.com \
    --cc=alex.bennee@linaro.org \
    --cc=alexander.usyskin@intel.com \
    --cc=arnd.bergmann@linaro.org \
    --cc=arnd@linaro.org \
    --cc=avri.altman@sandisk.com \
    --cc=bing.zhu@intel.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=joakim.bech@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=maxim.uvarov@linaro.org \
    --cc=ruchika.gupta@linaro.org \
    --cc=tomas.winkler@intel.com \
    --cc=ulf.hansson@linaro.org \
    --cc=yang.huang@intel.com \
    /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®