diff options
author | Chris Lew <quic_clew@quicinc.com> | 2023-08-01 12:17:12 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-09-23 10:48:12 +0200 |
commit | 6b58859e7c4ac357517a59f0801e8ce1b58a8ee2 (patch) | |
tree | 5f2baf1d61d15be8969a97e7261bf75eaaa95619 | |
parent | 669b1f3b915bfebf7abf5865bdb46c9de54ff18e (diff) | |
download | linux-stable-6b58859e7c4ac357517a59f0801e8ce1b58a8ee2.tar.gz linux-stable-6b58859e7c4ac357517a59f0801e8ce1b58a8ee2.tar.bz2 linux-stable-6b58859e7c4ac357517a59f0801e8ce1b58a8ee2.zip |
soc: qcom: qmi_encdec: Restrict string length in decode
commit 8d207400fd6b79c92aeb2f33bb79f62dff904ea2 upstream.
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: 9b8a11e82615 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/soc/qcom/qmi_encdec.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c index 3aaab71d1b2c..dbc8b4c93190 100644 --- a/drivers/soc/qcom/qmi_encdec.c +++ b/drivers/soc/qcom/qmi_encdec.c @@ -534,8 +534,8 @@ static int qmi_decode_string_elem(struct qmi_elem_info *ei_array, decoded_bytes += rc; } - if (string_len > temp_ei->elem_len) { - pr_err("%s: String len %d > Max Len %d\n", + if (string_len >= temp_ei->elem_len) { + pr_err("%s: String len %d >= Max Len %d\n", __func__, string_len, temp_ei->elem_len); return -ETOOSMALL; } else if (string_len > tlv_len) { |