Skip to content

Commit 5429c8d

Browse files
gjoyce-ibmaxboe
authored andcommitted
block: sed-opal: handle empty atoms when parsing response
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 15afd3d commit 5429c8d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

block/opal_proto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ enum opal_response_token {
7171
#define SHORT_ATOM_BYTE 0xBF
7272
#define MEDIUM_ATOM_BYTE 0xDF
7373
#define LONG_ATOM_BYTE 0xE3
74+
#define EMPTY_ATOM_BYTE 0xFF
7475

7576
#define OPAL_INVAL_PARAM 12
7677
#define OPAL_MANUFACTURED_INACTIVE 0x08

block/sed-opal.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,16 +1056,20 @@ static int response_parse(const u8 *buf, size_t length,
10561056
token_length = response_parse_medium(iter, pos);
10571057
else if (pos[0] <= LONG_ATOM_BYTE) /* long atom */
10581058
token_length = response_parse_long(iter, pos);
1059+
else if (pos[0] == EMPTY_ATOM_BYTE) /* empty atom */
1060+
token_length = 1;
10591061
else /* TOKEN */
10601062
token_length = response_parse_token(iter, pos);
10611063

10621064
if (token_length < 0)
10631065
return token_length;
10641066

1067+
if (pos[0] != EMPTY_ATOM_BYTE)
1068+
num_entries++;
1069+
10651070
pos += token_length;
10661071
total -= token_length;
10671072
iter++;
1068-
num_entries++;
10691073
}
10701074

10711075
resp->num = num_entries;

0 commit comments

Comments
 (0)