aboutsummaryrefslogtreecommitdiff
path: root/.cocciconfig
diff options
context:
space:
mode:
authorGravatar Dan Carpenter <dan.carpenter@linaro.org> 2023-07-11 11:20:44 +0300
committerGravatar Jeffrey Hugo <quic_jhugo@quicinc.com> 2023-07-14 10:00:45 -0600
commitea33cb6fc2788f9fe248d49e1c0b2553a58436ef (patch)
treed9fec328b819ce9839e7bfddb74860ac2c7e8732 /.cocciconfig
parentdrm/client: Fix memory leak in drm_client_modeset_probe (diff)
downloadlinux-ea33cb6fc2788f9fe248d49e1c0b2553a58436ef.tar.gz
linux-ea33cb6fc2788f9fe248d49e1c0b2553a58436ef.tar.bz2
linux-ea33cb6fc2788f9fe248d49e1c0b2553a58436ef.zip
accel/qaic: tighten bounds checking in encode_message()
There are several issues in this code. The check at the start of the loop: if (user_len >= user_msg->len) { This check does not ensure that we have enough space for the trans_hdr (8 bytes). Instead the check needs to be: if (user_len > user_msg->len - sizeof(*trans_hdr)) { That subtraction is done as an unsigned long we want to avoid negatives. Add a lower bound to the start of the function. if (user_msg->len < sizeof(*trans_hdr)) There is a second integer underflow which can happen if trans_hdr->len is zero inside the encode_passthrough() function. memcpy(out_trans->data, in_trans->data, in_trans->hdr.len - sizeof(in_trans->hdr)); Instead of adding a check to encode_passthrough() it's better to check in this central place. Add that check: if (trans_hdr->len < sizeof(trans_hdr) The final concern is that the "user_len + trans_hdr->len" might have an integer overflow bug. Use size_add() to prevent that. - if (user_len + trans_hdr->len > user_msg->len) { + if (size_add(user_len, trans_hdr->len) > user_msg->len) { Fixes: 129776ac2e38 ("accel/qaic: Add control path") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com> Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Cc: stable@vger.kernel.org # 6.4.x Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Link: https://patchwork.freedesktop.org/patch/msgid/9a0cb0c1-a974-4f10-bc8d-94437983639a@moroto.mountain
Diffstat (limited to '.cocciconfig')
0 files changed, 0 insertions, 0 deletions