From: Changming Liu <charley.ashbringer@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, thomas@winischhofer.net,
Changming Liu <charley.ashbringer@gmail.com>
Subject: [PATCH 0/4] USB: sisusbvga: cleaning up char buffers to u8 buffer
Date: Fri, 26 Jun 2020 15:34:13 -0400 [thread overview]
Message-ID: <1593200057-245-1-git-send-email-charley.ashbringer@gmail.com> (raw)
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(-)
--
2.7.4
next reply other threads:[~2020-06-26 19:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 19:34 Changming Liu [this message]
2020-06-26 19:34 ` [PATCH 1/4] USB: sisusbvga: change the char buffer from char to u8 for sisusb_write_mem_bulk and sisusb_send_bulk_msg Changming Liu
2020-06-27 11:28 ` Greg KH
2020-07-10 5:23 ` charley.ashbringer
2020-06-26 19:34 ` [PATCH 2/4] USB: sisusbvga: change the buffer members in sisusb_usb_data from char to u8 Changming Liu
2020-06-27 11:29 ` Greg KH
2020-06-26 19:34 ` [PATCH 3/4] USB: sisusbvga: change the buffer in sisusb_recv_bulk_msg " Changming Liu
2020-06-27 11:30 ` Greg KH
2020-06-26 19:34 ` [PATCH 4/4] USB: sisusbvga: change the buffers in sisusb_read_mem_bulk " Changming Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1593200057-245-1-git-send-email-charley.ashbringer@gmail.com \
--to=charley.ashbringer@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=thomas@winischhofer.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).