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: <1520382203.4178.87.camel@intel.com>
Date:   Wed, 7 Mar 2018 00:23:24 +0000
From:   "Derrick, Jonathan" <jonathan.derrick@...el.com>
To:     "Bauer, Scott" <scott.bauer@...el.com>,
        "jonas.rabenstein@...dium.uni-erlangen.de" 
        <jonas.rabenstein@...dium.uni-erlangen.de>,
        "axboe@...nel.dk" <axboe@...nel.dk>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>
Subject: Re: [PATCH][RESEND] block: sed-opal: fix response string extraction

This looks correct.

Adding my Ack unless Scott has objections

Acked-by: Jonathan Derrick <jonathan.derrick@...el.com>

On Thu, 2018-03-01 at 14:26 +0100, Jonas Rabenstein wrote:
> Tokens are prefixed by a variable length of bytes. If a bytestring is
> not stored in an tiny or short atom, we have to skip more than one
> byte
> in order to have the actual bytes not prefixed by the bytes
> describing
> the actual length of the string.
> 
> Signed-off-by: Jonas Rabenstein <jonas.rabenstein@...dium.uni-erlange
> n.de>
> ---
>  block/sed-opal.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/block/sed-opal.c b/block/sed-opal.c
> index 525506bed399..33052d0111de 100644
> --- a/block/sed-opal.c
> +++ b/block/sed-opal.c
> @@ -876,6 +876,9 @@ static int response_parse(const u8 *buf, size_t
> length,
>  static size_t response_get_string(const struct parsed_resp *resp,
> int n,
>  				  const char **store)
>  {
> +	u8 skip;
> +	const struct opal_resp_tok *token;
> +
>  	*store = NULL;
>  	if (!resp) {
>  		pr_debug("Response is NULL\n");
> @@ -888,13 +891,30 @@ static size_t response_get_string(const struct
> parsed_resp *resp, int n,
>  		return 0;
>  	}
>  
> -	if (resp->toks[n].type != OPAL_DTA_TOKENID_BYTESTRING) {
> +	token = &resp->toks[n];
> +	if (token->type != OPAL_DTA_TOKENID_BYTESTRING) {
>  		pr_debug("Token is not a byte string!\n");
>  		return 0;
>  	}
>  
> -	*store = resp->toks[n].pos + 1;
> -	return resp->toks[n].len - 1;
> +	switch (token->width) {
> +	case OPAL_WIDTH_TINY:
> +	case OPAL_WIDTH_SHORT:
> +		skip = 1;
> +		break;
> +	case OPAL_WIDTH_MEDIUM:
> +		skip = 2;
> +		break;
> +	case OPAL_WIDTH_LONG:
> +		skip = 4;
> +		break;
> +	default:
> +		pr_debug("Token has invalid width!\n");
> +		return 0;
> +	}
> +
> +	*store = token->pos + skip;
> +	return token->len - skip;
>  }
>  
>  static u64 response_get_u64(const struct parsed_resp *resp, int n)
Download attachment "smime.p7s" of type "application/x-pkcs7-signature" (3278 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ