Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2565999lqp; Mon, 25 Mar 2024 02:50:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVUG6DswcnFuibCexmGAfbJYsPODgy9o7RWbSwhY3Q2aZwHCC86TZuSzNyY5dLyI1hcjYYvHtgAp1q1BeVaIJ/QGD+Y5mU56A0V0PYACw== X-Google-Smtp-Source: AGHT+IH8OAOQKJ4xniW///VQCboXG9ckLib6SckcZxMy9oflqI/Zy0JwmDgG4qeQST3Y02NnkMXw X-Received: by 2002:a05:6808:99b:b0:3c2:3097:96bd with SMTP id a27-20020a056808099b00b003c2309796bdmr6877980oic.47.1711360212244; Mon, 25 Mar 2024 02:50:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711360212; cv=pass; d=google.com; s=arc-20160816; b=J+GgUiAJ6vONG4D375Nazyqnn+vao4MZvDKBltt7+4+aVA1my64zWIPJzD6y2JUX0s 4NqJG9YcdjShd3yYJdjrUr2HDLDmWBye6DuElOeOIddjD0rZtsjuRutRMKT90T77P+WY VuU6pTbVHbBuV4Mo5MeIHzMhmiSv4UGNsitFr4THvSxSgcc2+EKzzrJKW0iedEtvc9CT eEXNI70r9TNM4go5AWpVIZJM5ruuHYrR4IZ7n8vAqCPr8MZ7MNPqkYhHgN3SeS63w8uW shbgwSMir8NZMYajb+jHYco7OeEyaK4yxXDsm73qsNrtOfDtqsX3xvJURYp3jv0ISv9w dEPA== 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=1xK64z31j6epvzJwhdKv6HJj2FcldHrJ2nLxBRM7sDo=; fh=zCJ8LEqfc7CTRaa9rC5E32DRSRbh8p5bU3ZvvXpUgB8=; b=mCRCSCRqqR8U/7RNHF/d5XcTllqne17jbtOXBsU/SYVd9D41YjmHwXBAn1yKekcj/1 NYlupAYzgiN2XOG5yxgpvgcCZSZTdlT+xU+No3A+r1HYc4XhMlu6Ktqli/S+nZf9aYiu Dg7kRW3YfwGreBXIZDhzuO6nIpP4JAaXGfhY1KLcUipYpA8RkHvAqsW1aA7jxF/cuHAi LyPlfxS54hM11KE68YHT10qkUpalon30zpV/KTOFaM+dC3Adpu0weYBoI+coQvcXG3YB ROhXJjVkHWwbLuuvtWGD7bHDyuA6OZ81bnmBKyyIyfLFWKS7sgUvdade1QL+5pBUTw/c QWww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DaFeqPWK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115760-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115760-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d193-20020a6336ca000000b005d7bf204e26si7621682pga.899.2024.03.25.02.50.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:50:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115760-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DaFeqPWK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115760-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115760-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 893BFB27CCB for ; Mon, 25 Mar 2024 09:16:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBB7336ACFD; Mon, 25 Mar 2024 03:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DaFeqPWK" 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 A48301448E9; Sun, 24 Mar 2024 23:12:45 +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=1711321965; cv=none; b=gF6A6ANDvSOh2UFaLAe0ijs0ujoOfQaKjGO/bl5yz7aDRH+pYYhEq0MXTpznWadmY1VWHcmSzHaLeY5R1f6f2Iv2GPNcFhm1TUoaDZA/0nm9AnZ75hGq89tQNbmKgEWoj7iSbKdFQNyt6d1MKGWgQdwVy3Bue+oBySsEcg7UpNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321965; c=relaxed/simple; bh=vIYxEkfgTpOst8IRDB0xL9ewxCjd8NxYDv27uR59C3c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QeGFS0yAzzdo1IVvGpQhUj8MSf4hoFQh2ChdL8SsmzysF0rOJwp/wYivZVkAnLiDuE40VWg9c3kc4ATpRfTB+OJsldCZaK1ZYIW16Ui8664uRYUtnDLVkEoT/7CVCU1d9d0fl60FU3YN73hrgfEJg2BBPigIglREJrE6uDXR0i8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DaFeqPWK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93F07C433F1; Sun, 24 Mar 2024 23:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321965; bh=vIYxEkfgTpOst8IRDB0xL9ewxCjd8NxYDv27uR59C3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DaFeqPWKW7sL3cgrFXP0ucMoUef3sO/mpi5RJxPIK/Q6mbjNjY9D3F4adcehrVd5t MX2EH60G0nhMxJfDfAjaGm5jDggQj/d75u75acfpdxgmIjhpjVuHZO94fIuY74Gvhu U7e6yD7AKrAfsUrOEtXkzT2FIPTyHoEIQ/DBZGbIxsqyh2S17s3vU/IVR47xQKcqr4 L9EgATCbNoZrViNik9GmMsJNBDGq4xtGyr0WpDFVlEbGjluLJb8m7ag+1HaobaozEi Z55UUPazOKg5PROImMc2j6/4TQ43JG2n01DNHDzUjJfw68Qma9xITEU2khQL5CBeL1 M9Vq3FglATD0Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Joyce , Jens Axboe , Sasha Levin Subject: [PATCH 6.1 037/451] block: sed-opal: handle empty atoms when parsing response Date: Sun, 24 Mar 2024 19:05:13 -0400 Message-ID: <20240324231207.1351418-38-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 7152aa1f1a49e..7f306b08a0fe7 100644 --- a/block/opal_proto.h +++ b/block/opal_proto.h @@ -71,6 +71,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 9bdb833e5817d..25e4ce452c1d3 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -935,16 +935,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