From: Avi Weiss <thnkslprpt@gmail.com>
To: Jonathan Derrick <jonathan.derrick@linux.dev>,
Jens Axboe <axboe@kernel.dk>
Cc: Rafael Antognolli <Rafael.Antognolli@intel.com>,
Scott Bauer <scott.bauer@intel.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] block: sed-opal: reject invalid method status tokens
Date: Tue, 27 Oct 2026 19:17:30 +0200 [thread overview]
Message-ID: <20261027171729.331186-2-thnkslprpt@gmail.com> (raw)
response_status() uses response_get_u64() to read the method
status. The helper returns zero for an invalid type or unsupported
atom width, so malformed responses can be reported as successful.
Values such as 256 also become zero when truncated to u8.
Validate the status token before returning its value. Report
DTAERROR_NO_METHOD_STATUS for invalid tokens while preserving valid
status values and the end-session special case.
Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
block/sed-opal.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/block/sed-opal.c b/block/sed-opal.c
index 79b290d9458a9..1eb68ce33647b 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -1167,7 +1167,14 @@ static u8 response_status(const struct parsed_resp *resp)
if (!response_token_matches(tok, OPAL_ENDLIST))
return DTAERROR_NO_METHOD_STATUS;
- return response_get_u64(resp, resp->num - 4);
+ tok = response_get_token(resp, resp->num - 4);
+ if (IS_ERR(tok) || tok->type != OPAL_DTA_TOKENID_UINT ||
+ (tok->width != OPAL_WIDTH_TINY &&
+ tok->width != OPAL_WIDTH_SHORT) ||
+ tok->stored.u > U8_MAX)
+ return DTAERROR_NO_METHOD_STATUS;
+
+ return tok->stored.u;
}
/* Parses and checks for errors */
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
--
2.43.0
reply other threads:[~2026-10-27 17:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261027171729.331186-2-thnkslprpt@gmail.com \
--to=thnkslprpt@gmail.com \
--cc=Rafael.Antognolli@intel.com \
--cc=axboe@kernel.dk \
--cc=jonathan.derrick@linux.dev \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=scott.bauer@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®