Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2574591lqp; Mon, 25 Mar 2024 03:10:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWaSegmy+eMSYD0/1Sayr07au9eDvGYUvAOfU+BpsVCGGcLj8jj7zBbVA+YSyxHMslY7Rn00E6NPl9OeQQMQoQZLws6sKmAdcx7BZo5Hg== X-Google-Smtp-Source: AGHT+IEPrsraakA4FleegPLslUE4n6vjywiAsk2hXGn8PMNK5HOP0c51b3pMJUPSrW9Gl+66KSsy X-Received: by 2002:a17:906:6781:b0:a47:34b5:fa6e with SMTP id q1-20020a170906678100b00a4734b5fa6emr4791607ejp.2.1711361442542; Mon, 25 Mar 2024 03:10:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711361442; cv=pass; d=google.com; s=arc-20160816; b=LNVnRUiwgg0qlFqpUHqVaRhr09uo5Be5A9Iczg12R3kB11HTYSXfS20xMhCNj50Xht LCgu7zct+AcJgJ9ueGchnJLsVH/pNAvjvL0yldBMbhjUJfoVZsJjiioJ1O3Pgaa6P0/F ogljq3Rgid5hkAcEt+TJ2yKLvUsg3UUFhfGfZqSZgVGVQKI73SJh/HQeQJzMz9oNqDYy 254R3ATW+b9KOsp62fMEmM+pYBPvTfbSZik5AWj3DIlXFR4JLxN9D1NeJrs7jZB7ti0e U9f9um9nddEvUhPY1awcxRFVNPYtaPOoR60rlYVaO5rZARoKgo8WMAlsSMVSMykoSdm3 PZGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QDqLA80796gRKWKgc1nEUAEjIpGLSdquiKSc6oFCzSA=; fh=zCJ8LEqfc7CTRaa9rC5E32DRSRbh8p5bU3ZvvXpUgB8=; b=tras9RO/8KsncToRHOHOiNhiV5nikhkhu30b70v2hNylJFWoAnFWMy01RmfshXP3u8 VxkcAGo2e/RmeH+wdocUtKfwdcH9aGtoVGpTYR42S6ZHd3Q6ckSOwo1lMdlSpJlM3NZd 4vZHC80lSOKymc05JH3FM5APF53VUHLAQreiM+DILRm9herugJlTqiMGCBi+FMDJJTQK U6qdT5WMX8iLczquovXiEpOU07YxYCo1x/I5tAv1X1dbC/wtWxDY5AdlNButF51fZFv+ QQ+ps7SBYMiGWJmRug65jrfNVPloubqMvjEF6yf1LOC7bvn+7SzsADyZ/s9dX9gxX242 yZGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jBa9bbE5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116121-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bt7-20020a170906b14700b00a46caa13e60si2273643ejb.476.2024.03.25.03.10.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:10:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116121-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jBa9bbE5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116121-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 468C11F314F9 for ; Mon, 25 Mar 2024 10:10:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5BF628EC3F; Mon, 25 Mar 2024 03:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jBa9bbE5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0F39179FB5; Sun, 24 Mar 2024 23:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323648; cv=none; b=juGK8dX/+SwGyF6BJNZOMmg635b6vcQdiUFeLQw4c7Lod4TDmMJJnz9ZosFUj3H1vbmBWGZrzwAoIltuZd8oDNTTm61zmo17MREdncbugoX+81kUx5eFyc9F7mnmD1FUb8O94sQEjvOGBv+HvJQY/nfgb51Sfd/zOWPcki9s0vc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323648; c=relaxed/simple; bh=/asW2tftmwjIBrAfKoCxa3oRNne3RxOit1L2BaOZ8Jg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MAw/rwmbEN4kLlRTuKnWwSJgJFRQELsBG80sBACX3RM3qFcWovjhE2CRcYNuokyu9Eqph4HjTgtF8PoV8d8mGRZ49DoFvg2Al2SIudM2q8MrB2ZsmXImrFpTqzEowfvQWbGSTRWhIHnJJLYy43KMB8HlurnS/iPJmva6JkcXIRA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jBa9bbE5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D68AC43394; Sun, 24 Mar 2024 23:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323646; bh=/asW2tftmwjIBrAfKoCxa3oRNne3RxOit1L2BaOZ8Jg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jBa9bbE5Oyrf7BlqoHreKOT3CDDJ8lG7TbT9+QTPwY4y5BWbhj0/9NqpO6qiRDNJJ iMBBivkjuMoEWA/pLR03VEpF4EXsTXRLZYF1d/HhwQ9BR4GthDJoIpa/hCAMjuMDJR NfLaMrBhUgBFvC8oxo2GR65F8SbYsjNY78S6LNEF5nHBZ12hKYWOCxUrlhxNEg57dG Oj57Zq+g15swndc8bxaob/I+OJLRu9eSEKVljfyJW34V9WOh7REsVp/3Fa6/of+vQ6 /GJWe6ii+jTrrQ7EsA49MZhiYbuyAGOs+msgffJ59pPQr01z9KoZBkMBTFiJ0S3HB6 S8yem5TvDPpoQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Joyce , Jens Axboe , Sasha Levin Subject: [PATCH 5.10 018/238] block: sed-opal: handle empty atoms when parsing response Date: Sun, 24 Mar 2024 19:36:46 -0400 Message-ID: <20240324234027.1354210-19-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Greg Joyce [ Upstream commit 5429c8de56f6b2bd8f537df3a1e04e67b9c04282 ] The SED Opal response parsing function response_parse() does not handle the case of an empty atom in the response. This causes the entry count to be too high and the response fails to be parsed. Recognizing, but ignoring, empty atoms allows response handling to succeed. Signed-off-by: Greg Joyce Link: https://lore.kernel.org/r/20240216210417.3526064-2-gjoyce@linux.ibm.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/opal_proto.h | 1 + block/sed-opal.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/block/opal_proto.h b/block/opal_proto.h index b486b3ec7dc41..a50191bddbc26 100644 --- a/block/opal_proto.h +++ b/block/opal_proto.h @@ -66,6 +66,7 @@ enum opal_response_token { #define SHORT_ATOM_BYTE 0xBF #define MEDIUM_ATOM_BYTE 0xDF #define LONG_ATOM_BYTE 0xE3 +#define EMPTY_ATOM_BYTE 0xFF #define OPAL_INVAL_PARAM 12 #define OPAL_MANUFACTURED_INACTIVE 0x08 diff --git a/block/sed-opal.c b/block/sed-opal.c index 0ac5a4f3f2261..00e4d23ac49e7 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -895,16 +895,20 @@ static int response_parse(const u8 *buf, size_t length, token_length = response_parse_medium(iter, pos); else if (pos[0] <= LONG_ATOM_BYTE) /* long atom */ token_length = response_parse_long(iter, pos); + else if (pos[0] == EMPTY_ATOM_BYTE) /* empty atom */ + token_length = 1; else /* TOKEN */ token_length = response_parse_token(iter, pos); if (token_length < 0) return token_length; + if (pos[0] != EMPTY_ATOM_BYTE) + num_entries++; + pos += token_length; total -= token_length; iter++; - num_entries++; } resp->num = num_entries; -- 2.43.0