Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <gjoyce@linux.ibm.com>
Link: https://lore.kernel.org/r/20240216210417.3526064-2-gjoyce@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Greg Joyce and committed by
Jens Axboe
5429c8de 15afd3d3

+6 -1
+1
block/opal_proto.h
··· 71 71 #define SHORT_ATOM_BYTE 0xBF 72 72 #define MEDIUM_ATOM_BYTE 0xDF 73 73 #define LONG_ATOM_BYTE 0xE3 74 + #define EMPTY_ATOM_BYTE 0xFF 74 75 75 76 #define OPAL_INVAL_PARAM 12 76 77 #define OPAL_MANUFACTURED_INACTIVE 0x08
+5 -1
block/sed-opal.c
··· 1056 1056 token_length = response_parse_medium(iter, pos); 1057 1057 else if (pos[0] <= LONG_ATOM_BYTE) /* long atom */ 1058 1058 token_length = response_parse_long(iter, pos); 1059 + else if (pos[0] == EMPTY_ATOM_BYTE) /* empty atom */ 1060 + token_length = 1; 1059 1061 else /* TOKEN */ 1060 1062 token_length = response_parse_token(iter, pos); 1061 1063 1062 1064 if (token_length < 0) 1063 1065 return token_length; 1064 1066 1067 + if (pos[0] != EMPTY_ATOM_BYTE) 1068 + num_entries++; 1069 + 1065 1070 pos += token_length; 1066 1071 total -= token_length; 1067 1072 iter++; 1068 - num_entries++; 1069 1073 } 1070 1074 1071 1075 resp->num = num_entries;