Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp147701lqc; Thu, 29 Feb 2024 12:58:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVgPGdhCdvE/jwAcNbwH908XGOBDsC75FnWCOrSUQu38J6ixwzpMByixxUZittHFbL5xXaQImedncO9jFbQ3hgBQE0axV6sGACh+MmLUw== X-Google-Smtp-Source: AGHT+IF0GLUOl7YReMKoQ1PxcODL8cNThJfRxPJ2MEyQa2lmlkTYZJoYcCcxQHboDltcXTQsJFLT X-Received: by 2002:a05:620a:4145:b0:787:ecea:69af with SMTP id k5-20020a05620a414500b00787ecea69afmr4415619qko.5.1709240283359; Thu, 29 Feb 2024 12:58:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709240283; cv=pass; d=google.com; s=arc-20160816; b=vGlsAbNDHtUUXomccnBZ6MuaZsX6hQNOU/Zqwq3S7OsyxDAQ8fkF+U/7sSJsYlz4PP GYAX8mvCS7fqovOd3zYw2X5LJcwSro3kkU8GX5zwNTsegXMhAl2yFXsHT9C9Vpqq77UR JL8qLuTckx6/awPC1DnqYAhFZHZ8VyLwqtS/Ef3+CwDoAAHcNyJ8kBAaInibiINCNsrT 7YziUbgeO3mKB80UR7TlDXY0jAxYhkvdUd3dMLF03V9mg2gEyjS+EbGJFEC+zmUCGdBK M61GKy9Vb7Ux/gwUNHhSOK4n3iq9lrq7WCWy6DP/dff2t5JvU+uTB9WPppmk9U0rYMtQ 6S0g== 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=VlslDqiRF8KjYkpNq9IYSuunUsgWBpuWNo5Hryp1/0s=; b=y2ZkknL5sG+0pSj+kBjxkRFbm5o0fahdj7xJsd9qHq/Kl145hUdWKtCnkEI8RH7px5 6UClTiql/DEIOPvWm1/Cyl4w+mDaPSGB2eKjWStJL2GdtO3LpbKYXzi+9g4FMEpA2cN3 Cv0rTW6lW89XfDEohwAKdsFGMw2etjN5AZpuOPxw0VYV6Py7oMhhuMeaKUXqQly1m7yU tL1Ysxxl4n+cgyMgLrLqkgdZrwC+tRakhiw07yeibdZuS/hwpQVeVVfD/AbFdJsMGezc 1QI+zQYMtTjvIRyUMZ2ERl8Y/P31loAs+N35z5TY2lFLsOHjArjoRaoajd+HJoui+QA1 vMsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7OdlOST; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87503-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87503-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a26-20020a05620a103a00b0078749f9aeaasi2150458qkk.367.2024.02.29.12.58.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 12:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87503-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7OdlOST; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87503-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87503-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0EC101C21D3D for ; Thu, 29 Feb 2024 20:58:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35594151CC8; Thu, 29 Feb 2024 20:41:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M7OdlOST" 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 5B9811683AB; Thu, 29 Feb 2024 20:41:22 +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=1709239282; cv=none; b=rKInTouxHGDPmAjD1WDhAV2YdHOoBsdnJhn9mwaWFVzqx70frVdPLQLIP163Ve5BXfgMB7qXVZvEuqBLdtjP/Un8xph5oyyOVqISovvNYNt2AgSAbGz20nuvN5uawC11W9PYo10m4J+uK7OdJ9a0IdFalvdJao99jOrCdS6JtXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709239282; c=relaxed/simple; bh=/asW2tftmwjIBrAfKoCxa3oRNne3RxOit1L2BaOZ8Jg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TWEuhePjPl3sfHv188ejh6zyTen4nWDXTGWejzD/h2nSkBwrBYHStM2VrEo8+raPUpNTc3dKNZDM9lcZ3FtzIXz9P2UcH9iLkzPlbRG16MbW0nJynCVv6FeNeht/ZsMNIPl5H/RpV38a3B5BHis2ZWDQflVUy+wHLJBE+XbmOQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M7OdlOST; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44594C433F1; Thu, 29 Feb 2024 20:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709239282; bh=/asW2tftmwjIBrAfKoCxa3oRNne3RxOit1L2BaOZ8Jg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7OdlOSTdq9HghYwO3xN5HZ6nTPUHFXVJ7J+dznHc6pGvojLnwJI7L0BDtR9Yr+tq uM/Y1Jd9bND/0IiI9QN92fsvB/o7vZTVMn7pBst8OqpGNBbsnYbkShCY6h9G9WOjiZ hLsToGIsruW8AnmzZ2U+RTINluoTwd9McEGj3bzC9Aw5TqGJJvh+UeBlKjCSMJO/Fb l8Nf43ZvDoBn6ESbFheYXV14hAPana5wEOFZzs+Ys9lHg/JZTp6U8WTtDm6s4Tg/7A Af20lGGvdMmiylObQZYDgT3MnAL7orun292lUPgk2u1POD+7TWWB0m/USTrEqaIIgx bXi2H8Wf3s9Ng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Joyce , Jens Axboe , Sasha Levin , jonathan.derrick@linux.dev, linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 8/9] block: sed-opal: handle empty atoms when parsing response Date: Thu, 29 Feb 2024 15:41:04 -0500 Message-ID: <20240229204107.2861780-8-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229204107.2861780-1-sashal@kernel.org> References: <20240229204107.2861780-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 X-stable-base: Linux 5.15.149 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