Re: [PATCH 3/3] block: sed-opal: Add support to read/write opal tables generically

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



+David

On Wed, 2019-08-21 at 13:10 -0600, Revanth Rajashekar wrote:
> This feature gives the user RW access to any opal table with admin1
> authority.
> 
> The flags described in the new structure determines if the user
> wants to read/write the data. Flags are checked for valid values in
> order to allow future features to be added to the ioctl.
> 
> Previously exposed opal UIDs allows the user to easily select the
> desired table to retrieve its UID.
> 
> The ioctl provides a size and offset field and internally will loop
> data accesses to return the full data block.
> 
> The ioctl provides a private field with the intentiont to accommodate
> any future expansions to the ioctl.
> 
> Signed-off-by: Revanth Rajashekar <revanth.rajashekar@xxxxxxxxx>
> ---
>  block/sed-opal.c              | 140 ++++++++++++++++++++++++++++++++++
>  include/linux/sed-opal.h      |   1 +
>  include/uapi/linux/sed-opal.h |  16 ++++
>  3 files changed, 157 insertions(+)
> 
> diff --git a/block/sed-opal.c b/block/sed-opal.c
> index 7179582730b6..3f41fc56f3cb 100644
> --- a/block/sed-opal.c
> +++ b/block/sed-opal.c
> @@ -1896,6 +1896,108 @@ static int get_msid_cpin_pin(struct opal_dev *dev, void *data)
>  	return 0;
>  }
> 
> +static int write_table_data(struct opal_dev *dev, void *data)
> +{
> +	struct opal_read_write_table *write_tbl = data;
> +
> +	return generic_table_write_data(dev, write_tbl->data, write_tbl->offset,
> +					write_tbl->size, write_tbl->table_uid);
> +}
> +
> +static int read_table_data_cont(struct opal_dev *dev)
> +{
> +	int err = 0;
> +	const char *data_read;
> +
> +	err = parse_and_check_status(dev);
> +	if (err)
> +		return err;
> +
> +	dev->prev_d_len = response_get_string(&dev->parsed, 1, &data_read);
> +
> +	dev->prev_data = data_read;
> +	if (!dev->prev_data) {
> +		pr_debug("%s: Couldn't read data from the table.\n", __func__);
> +		return OPAL_INVAL_PARAM;
> +	}
> +
> +	return 0;
> +}
> +
> +/*
> + * IO_BUFFER_LENGTH = 2048
> + * sizeof(header) = 56
> + * No. of Token Bytes in the Response = 11
> + * MAX size of data that can be carried in response buffer
> + * at a time is : 2048 - (56 + 11) = 1981 = 0x7BD.
> + */
> +#define OPAL_MAX_READ_TABLE (0x7BD)
This is the only part I'm concerned about, but I'm not aware of any
condition in the spec allowing for the response to have extra fields
that would overflow the buffer.



[snip]

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux