Skip to content

USB: sisusbvga: cleaning up char buffers to u8 buffer

Changming Liu linux-usb 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4USB: sisusbvga: change the char buffer from char to u8 for sisusb_write_mem_bulk and sisusb_send_bulk_msgdrivers/usb/misc/sisusbvga/sisusb.c+7 -72 replies
2/4USB: sisusbvga: change the buffer members in sisusb_usb_data from char to u8drivers/usb/misc/sisusbvga/sisusb.c drivers/usb/misc/sisusbvga/sisusb.h+4 -41 reply
3/4USB: sisusbvga: change the buffer in sisusb_recv_bulk_msg from char to u8drivers/usb/misc/sisusbvga/sisusb.c+3 -31 reply
4/4USB: sisusbvga: change the buffers in sisusb_read_mem_bulk from char to u8drivers/usb/misc/sisusbvga/sisusb.c+5 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] USB: sisusbvga: cleaning up char buffers to u8 buffer

The purpose of this patch series is to prevent undefined behavior caused by arithemetic operations on the content of the char buffer.This is achieved through converting all char buffers to u8 when there is no need for the content to be negative value(which is the case for all touched buffer in this patch series).

Converting these char buffers to u8 buffers will make certain types of UB from producing undefined result to well-defined intended (modular) result, and will not introduce any unintended side effect.

As an example, changing the local char buf[4] in sisusb_write_mem_bulk to u8 fixes an UB: since buf is filled with data from user space, thus can be negative. Left-shifting this negative value produces undefined result, this can be fixed by changing it from char to u8.

This however doesn't apply to ioctl interfaces functions, since the types for buffer of ioctl-like functions need to be char* instead of u8* for compatibility reason.
In these cases, the buffer declared as char* will be force cast to u8* when being used.

Changming Liu (4):
USB: sisusbvga: change sisusb_write_mem_bulk
USB: sisusbvga: change the buffers of sisusb from char to u8
USB: sisusbvga: change userbuffer for sisusb_recv_bulk_msg to u8
USB: sisusbvga: change sisusb_read_mem_bulk

 drivers/usb/misc/sisusbvga/sisusb.c | 34 +++++++++++++++++-----------------
 drivers/usb/misc/sisusbvga/sisusb.h |  4 ++--
 2 files changed, 19 insertions(+), 19 deletions(-)
Signature · 1 line
2.7.4