soc: qcom: qmi_encdec: Restrict string length in decode
Subsystems (2)
PATCH v2 1/1 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.
---
[v2]:
Added Fixes and Cc: stable
drivers/soc/qcom/qmi_encdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/qcom/qmi_encdec.c +2 -2
@@ -534,8 +534,8 @@ static int qmi_decode_string_elem(const 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) {
Signature · 1 line
2.34.1
Bjorn Andersson
maintainerQuoted 9 lines · Praveenkumar I
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 actuallyMAX_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")Signed-off-by Chris Lew <[email protected]>Signed-off-by Praveenkumar I <[email protected]>
The signed-off-by list says that Chris certified the patch's origin first, then you took it, certified the origin and submitted it to the mailing list.
This matches reality, but you lost Chris' authorship in the process, please add that back.
Thanks,
Bjorn
Quoted 25 lines
---
[v2]:
Added Fixes and Cc: stabledrivers/soc/qcom/qmi_encdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/soc/qcom/qmi_encdec.c +2
-2@@ -534,8 +534,8 @@ static int qmi_decode_string_elem(const 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) {Signature · 1 line
2.34.1
Quoted 10 lines · Bjorn Andersson
Quoted 9 lines · Praveenkumar I
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 actuallyMAX_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")Signed-off-by Chris Lew <[email protected]>Signed-off-by Praveenkumar I <[email protected]>
Quoted 6 lines
The signed-off-by list says that Chris certified the patch's origin first, then you took it, certified the origin and submitted it to the mailing list.
This matches reality, but you lost Chris' authorship in the process, please add that back.
Yes, you are right. Will add that, and post it.
- Praveenkumar
Quoted 28 lines
Thanks,
BjornQuoted 25 lines
---
[v2]:
Added Fixes and Cc: stabledrivers/soc/qcom/qmi_encdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/soc/qcom/qmi_encdec.c +2
-2@@ -534,8 +534,8 @@ static int qmi_decode_string_elem(const 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) {Signature · 1 line
2.34.1