Received: by 10.223.185.116 with SMTP id b49csp4471516wrg; Tue, 6 Mar 2018 16:59:08 -0800 (PST) X-Google-Smtp-Source: AG47ELvaPD4twlQ/JF+vC5IpNsexQ7miLbDwOL7IjkKpUwTakdORGEKYCsJXuhEjohQG7iaEI7Uz X-Received: by 10.101.97.139 with SMTP id c11mr16258217pgv.439.1520384348788; Tue, 06 Mar 2018 16:59:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520384348; cv=none; d=google.com; s=arc-20160816; b=y63V1NNR08dFgIvdaJdo5GUlvmzHoO8pGqSa/PlMxcnX25priPE2iv51FhFk4MOtU9 B3CadR8lftIM2Y5vkfavAdm0pIHoq82n1wnh9J64b4w360J6uuv0DxZWg5hmEkjU45y1 Zf/T5SunXs+sSBwfbRy35SZ3xOIVzm8SRg9KEu3PoR4gb8omMkVerixLo5J674yw2l7t YVN5VEkFQY1myrCuiqUBAZs6W7i8O6LMCcEWVIW/eJ/BovcPv1lJjPTtKUdnBSnQmVKD zFT2n9pyPS8uG4peX8qq9iZg7wSS3cvOkK3AfRELBO6SUbjiQdfpNuk8IkD1Mrnk7gKI AKew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=qrDv1xx/tJ9xuhCyixfvrN4kLqogxM4gocCYKYmSl9Q=; b=iv4LgyMhLloG/rHYLJpw6d8gXBg6WUUQJ2jB8F3PQiiwofF9pyUHyy2kp8hOryPXAy Go6vq4XFvB89KaQnWvE8P1Sk6kfNYBuuXJx9fnj8Kw5my4S+eZ4H/4zWlVEYex1IeghX 0J0C3ss3qi/aAXNy7p3m6+0kKgikWUlPy0nkJruXaM7urr+lJDGLOwHfxLrygbmZ+nhb vIOy1UQ20YD9gjrRHSoJ0MA6DP5vXkvb5PMNWNMaV+M+oYs9LX7xTkCgK3KNTyOONbcj KaKKjO0QzVlbSAXG5b2JyjmLlTwZws+mmrPiY/KO7T0hfpHCtUAZcGCuu6pV/Ib4y+K2 vKbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5si12694703pfn.386.2018.03.06.16.58.54; Tue, 06 Mar 2018 16:59:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933130AbeCGAX2 (ORCPT + 99 others); Tue, 6 Mar 2018 19:23:28 -0500 Received: from mga14.intel.com ([192.55.52.115]:40758 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932182AbeCGAX0 (ORCPT ); Tue, 6 Mar 2018 19:23:26 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 16:23:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,433,1515484800"; d="p7s'?scan'208";a="36043743" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by fmsmga001.fm.intel.com with ESMTP; 06 Mar 2018 16:23:25 -0800 Received: from orsmsx163.amr.corp.intel.com (10.22.240.88) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 6 Mar 2018 16:23:25 -0800 Received: from orsmsx101.amr.corp.intel.com ([169.254.8.72]) by ORSMSX163.amr.corp.intel.com ([169.254.9.220]) with mapi id 14.03.0319.002; Tue, 6 Mar 2018 16:23:25 -0800 From: "Derrick, Jonathan" To: "Bauer, Scott" , "jonas.rabenstein@studium.uni-erlangen.de" , "axboe@kernel.dk" CC: "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" Subject: Re: [PATCH][RESEND] block: sed-opal: fix response string extraction Thread-Topic: [PATCH][RESEND] block: sed-opal: fix response string extraction Thread-Index: AQHTsWD/O+AFGX6RJUGYpKt/0j9IEaPEeFuA Date: Wed, 7 Mar 2018 00:23:24 +0000 Message-ID: <1520382203.4178.87.camel@intel.com> References: <20180301132637.1230-1-jonas.rabenstein@studium.uni-erlangen.de> In-Reply-To: <20180301132637.1230-1-jonas.rabenstein@studium.uni-erlangen.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.232.112.61] Content-Type: multipart/signed; micalg=sha-1; protocol="application/x-pkcs7-signature"; boundary="=-ADUGnyFcKkq7uWI66hkK" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-ADUGnyFcKkq7uWI66hkK Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This looks correct. Adding my Ack unless Scott has objections Acked-by: Jonathan Derrick 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. >=20 > Signed-off-by: Jonas Rabenstein n.de> > --- > block/sed-opal.c | 26 +++++++++++++++++++++++--- > 1 file changed, 23 insertions(+), 3 deletions(-) >=20 > 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 =3D 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; > } > =20 > - if (resp->toks[n].type !=3D OPAL_DTA_TOKENID_BYTESTRING) { > + token =3D &resp->toks[n]; > + if (token->type !=3D OPAL_DTA_TOKENID_BYTESTRING) { > pr_debug("Token is not a byte string!\n"); > return 0; > } > =20 > - *store =3D resp->toks[n].pos + 1; > - return resp->toks[n].len - 1; > + switch (token->width) { > + case OPAL_WIDTH_TINY: > + case OPAL_WIDTH_SHORT: > + skip =3D 1; > + break; > + case OPAL_WIDTH_MEDIUM: > + skip =3D 2; > + break; > + case OPAL_WIDTH_LONG: > + skip =3D 4; > + break; > + default: > + pr_debug("Token has invalid width!\n"); > + return 0; > + } > + > + *store =3D token->pos + skip; > + return token->len - skip; > } > =20 > static u64 response_get_u64(const struct parsed_resp *resp, int n) --=-ADUGnyFcKkq7uWI66hkK Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIKeTCCBOsw ggPToAMCAQICEFLpAsoR6ESdlGU4L6MaMLswDQYJKoZIhvcNAQEFBQAwbzELMAkGA1UEBhMCU0Ux FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5hbCBUVFAgTmV0 d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9vdDAeFw0xMzAzMTkwMDAwMDBa Fw0yMDA1MzAxMDQ4MzhaMHkxCzAJBgNVBAYT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