Skip to content

Commit 8d20740

Browse files
quic-clewandersson
authored andcommitted
soc: qcom: qmi_encdec: Restrict string length in decode
The QMI TLV value for strings in a lot of qmi element info structures account for null terminated strings with MAX_LEN + 1. If a string is actually MAX_LEN + 1 length, this will cause an out of bounds access when the NULL character is appended in decoding. Fixes: 9b8a11e ("soc: qcom: Introduce QMI encoder/decoder") Cc: stable@vger.kernel.org Signed-off-by: Chris Lew <quic_clew@quicinc.com> Signed-off-by: Praveenkumar I <quic_ipkumar@quicinc.com> Link: https://lore.kernel.org/r/20230801064712.3590128-1-quic_ipkumar@quicinc.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 5f90878 commit 8d20740

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/soc/qcom/qmi_encdec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ static int qmi_decode_string_elem(const struct qmi_elem_info *ei_array,
534534
decoded_bytes += rc;
535535
}
536536

537-
if (string_len > temp_ei->elem_len) {
538-
pr_err("%s: String len %d > Max Len %d\n",
537+
if (string_len >= temp_ei->elem_len) {
538+
pr_err("%s: String len %d >= Max Len %d\n",
539539
__func__, string_len, temp_ei->elem_len);
540540
return -ETOOSMALL;
541541
} else if (string_len > tlv_len) {

0 commit comments

Comments
 (0)