From patchwork Fri Jun 26 19:34:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changming X-Patchwork-Id: 214796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0FF5C433E0 for ; Fri, 26 Jun 2020 19:34:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A29372070A for ; Fri, 26 Jun 2020 19:34:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="utggEOsC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725834AbgFZTep (ORCPT ); Fri, 26 Jun 2020 15:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgFZTeo (ORCPT ); Fri, 26 Jun 2020 15:34:44 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69936C03E979 for ; Fri, 26 Jun 2020 12:34:44 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id i16so8338177qtr.7 for ; Fri, 26 Jun 2020 12:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ENqSB2KB/CeM9iS01usBB6lLaHyXVXxv1vzIJAdOhcg=; b=utggEOsC0cBCuZn0rVM3UIX2pC59ZIHrfQVZ/XPDBM2xP2LwlV8DdVjiJx+Ig7dPp8 PFmWHDuNUzRb1QbNq1Q+TAQ1S5uuCtYhJVjebqWSTQle4eAxzESURuq0O8rL0svjy/nM D1IlGfI0ucYIYWE/SOUy3ELCR6qOlHoudN+2YeLZAjQSLw4C+B5ehpj1AL88+pqSObsl GvuJX5lTUZFobnRUZWWWPwIyc7QifdLQqUq0dx7k9yD2FeWhcqeZfdCDBxhyit9lo4db EkyaVCoArPBUZCPE1sLlOAxaDvYh9AWYdhg/m9vue60rlzdBQyFuCYJgRxDW953UJt40 T4tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ENqSB2KB/CeM9iS01usBB6lLaHyXVXxv1vzIJAdOhcg=; b=ADU4/qMBZ3aYmIUhlj6U1UxnIuflW4A00NrPZ2K/G0fa6oQyUiPwQ9tNzPnq0J7BCw +6dQkdhAd8fHM/rrtmtnrIsYYeARcaUe9ofnaLmtSuCny1J7Q4RsWyKPAg6Q6GAi922a 0ObElNXchhofVhbmMPiN6k97TfxhY6Drog8k6O2cPwUDhBKJbflsMHjDz3b3nLA/xM4j 2JuPXN39dbHqF0MqtG/baWVYWnrggukFPl94eGZd7xkTOwce03dW3+ybfMrV2C075q+X KVo5T+hvFCy33Ri3yTSjivhfEsVPcdGIZF94B4dJ5wpFDcfGHDk6VKFPHxN9kTibqsYI D63g== X-Gm-Message-State: AOAM530RC7oRpjxmgTPoxnTt+jqAOHwVM11CQDIe8rZcti5eTk/TrBvB 4oFihHmtmFKlKL7flycXzN4= X-Google-Smtp-Source: ABdhPJz4o394EFHNQZ1azUr1p8+O8B9WW+dl7/7+/jSoCjss8x235ActI4mEJSDUVdQut3IK3Wr7RQ== X-Received: by 2002:aed:3403:: with SMTP id w3mr4355139qtd.356.1593200083696; Fri, 26 Jun 2020 12:34:43 -0700 (PDT) Received: from DESKTOP-JC0RTV5.neu.edu ([155.33.134.7]) by smtp.gmail.com with ESMTPSA id u124sm1089990qkf.83.2020.06.26.12.34.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2020 12:34:43 -0700 (PDT) From: Changming Liu To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, thomas@winischhofer.net, Changming Liu Subject: [PATCH 2/4] USB: sisusbvga: change the buffer members in sisusb_usb_data from char to u8 Date: Fri, 26 Jun 2020 15:34:15 -0400 Message-Id: <1593200057-245-3-git-send-email-charley.ashbringer@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593200057-245-1-git-send-email-charley.ashbringer@gmail.com> References: <1593200057-245-1-git-send-email-charley.ashbringer@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch changes the buffer within struct sisusb_usb_data, namely, ibuf,obuf and font_backup from char* to unsigned char* to avoid any related UB. Thia patch also changes the buffer declared in the code that gets assigned to by these buffers from char to u8 as well. Signed-off-by: Changming Liu --- drivers/usb/misc/sisusbvga/sisusb.c | 4 ++-- drivers/usb/misc/sisusbvga/sisusb.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 4aa717a..8878c28 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -335,7 +335,7 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, int fromuser = (userbuffer != NULL) ? 1 : 0; int fromkern = (kernbuffer != NULL) ? 1 : 0; unsigned int pipe; - char *buffer; + u8 *buffer; (*bytes_written) = 0; @@ -454,7 +454,7 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, int result = 0, retry, count = len; int bufsize, thispass, transferred_len; unsigned int pipe; - char *buffer; + u8 *buffer; (*bytes_read) = 0; diff --git a/drivers/usb/misc/sisusbvga/sisusb.h b/drivers/usb/misc/sisusbvga/sisusb.h index c0fb9e1..8fe5d07 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.h +++ b/drivers/usb/misc/sisusbvga/sisusb.h @@ -109,7 +109,7 @@ struct sisusb_usb_data { int present; /* !=0 if device is present on the bus */ int ready; /* !=0 if device is ready for userland */ int numobufs; /* number of obufs = number of out urbs */ - char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */ + unsigned char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */ int obufsize, ibufsize; struct urb *sisurbout[NUMOBUFS]; struct urb *sisurbin; @@ -140,7 +140,7 @@ struct sisusb_usb_data { int sisusb_cursor_size_to; int current_font_height, current_font_512; int font_backup_size, font_backup_height, font_backup_512; - char *font_backup; + unsigned char *font_backup; int font_slot; struct vc_data *sisusb_display_fg; int is_gfx; From patchwork Fri Jun 26 19:34:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changming X-Patchwork-Id: 214795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D463C433E0 for ; Fri, 26 Jun 2020 19:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8C332070A for ; Fri, 26 Jun 2020 19:34:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z4UfUU8J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725847AbgFZTes (ORCPT ); Fri, 26 Jun 2020 15:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgFZTer (ORCPT ); Fri, 26 Jun 2020 15:34:47 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92ABDC03E979 for ; Fri, 26 Jun 2020 12:34:47 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id v19so8313817qtq.10 for ; Fri, 26 Jun 2020 12:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V93KBbiqYgLQgxuCNYgxQaFkpJp0j4u3rwW0p2x9ALc=; b=Z4UfUU8JvxEVmQLRNNIfJOjt0Q/4DyNLk3PxaaqVWVeeRDQVQpK+XqRGIuqT969nJI 5J8yWFeqhuiCEdJX2K68W38LwBQ1kp7Uidu8H69iMtt7HhT75LaeXZbEyXsOxb23lfh8 0MLt3coZlRokOTuhwk0e98WAAt69u7DEp7H3Rk/v3FP4ZDWAR5NrPhSXewFnjmHFBlnX v+eP5bAA1l7O16LPM470awkgJOi4VmtLhhBxvAuM/jTsuy+vJgUZtuJ7aUU9o8WlFTkH EX+yMdkwd6XZEeBVpjWibyIY2pbq7vGSpa0aL6atprnq4BqnKJiWtdS6pPKXJ9gTbg3p OujQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V93KBbiqYgLQgxuCNYgxQaFkpJp0j4u3rwW0p2x9ALc=; b=G8OK1/F/eO1+RFZz2Z3v1/Q/Yxa1N3E8ac4PD3b0KF9JZwDwGWEeobjqsCgJZOMIYW hSTo3xcs/Px6XCbwr3TApQV2l//ASsCRlFcH8Qo4HEqeYiOchFKO5R2DOOmvFUX+h95x 0diS3N07OKLRwdbptmdGJnAYZsBM4i52F0dSRcnt5k2kE5jdHNHKzgoZl7Od0vFcDCz5 II9bPJsy4Tss5vTKbDX69o4H5Xx+c1dwZbvJFZHd+pgNwVhb9JrosTQJEOEv/TELniwO SGZoiplTEOqNpc+mGblTsCYi06x5uG9+lExpJK9mv04I++suEfv0s2LLnpaZFYILvwqE LR9Q== X-Gm-Message-State: AOAM531lczxbfUFc8H34szpJizwkS3shjblFnloIFW9WOMfld/ISeITe RoALCJ75CnC3imZRtvO6xsE= X-Google-Smtp-Source: ABdhPJx4CwIXueNyvGETvcLwT3roW0eUftclFSR1xsWjcIll70233qqmnWLThRaEgoow9RVKOg2hzQ== X-Received: by 2002:ac8:2256:: with SMTP id p22mr4335341qtp.75.1593200086783; Fri, 26 Jun 2020 12:34:46 -0700 (PDT) Received: from DESKTOP-JC0RTV5.neu.edu ([155.33.134.7]) by smtp.gmail.com with ESMTPSA id u124sm1089990qkf.83.2020.06.26.12.34.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2020 12:34:45 -0700 (PDT) From: Changming Liu To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, thomas@winischhofer.net, Changming Liu Subject: [PATCH 4/4] USB: sisusbvga: change the buffers in sisusb_read_mem_bulk from char to u8 Date: Fri, 26 Jun 2020 15:34:17 -0400 Message-Id: <1593200057-245-5-git-send-email-charley.ashbringer@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593200057-245-1-git-send-email-charley.ashbringer@gmail.com> References: <1593200057-245-1-git-send-email-charley.ashbringer@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch changes the userbuffer,kernbuffer in the header of sisusb_read_mem_bulk from char to u8 to avoid related UB. Also a local buffer, buf, in sisusb_read_mem_bulk is changed from char to u8. Since sisusb_read_mem_bulk is called by sisusb_read_memory sisusb_testreadwrite and sisusb_read, change their passed-in parameters types from char to u8 accordingly. Signed-off-by: Changming Liu --- drivers/usb/misc/sisusbvga/sisusb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 86638c1..f1b46b5 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -1108,7 +1108,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, ssize_t *bytes_read) { int ret = 0; - char buf[4]; + u8 buf[4]; u16 swap16; u32 swap32; @@ -1293,7 +1293,7 @@ int sisusb_copy_memory(struct sisusb_usb_data *sisusb, char *src, } #ifdef SISUSBENDIANTEST -static int sisusb_read_memory(struct sisusb_usb_data *sisusb, char *dest, +static int sisusb_read_memory(struct sisusb_usb_data *sisusb, u8 *dest, u32 src, int length) { size_t dummy; @@ -1308,7 +1308,7 @@ static int sisusb_read_memory(struct sisusb_usb_data *sisusb, char *dest, static void sisusb_testreadwrite(struct sisusb_usb_data *sisusb) { static char srcbuffer[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; - char destbuffer[10]; + u8 destbuffer[10]; int i, j; sisusb_copy_memory(sisusb, srcbuffer, sisusb->vrambase, 7); @@ -2561,7 +2561,7 @@ static ssize_t sisusb_read(struct file *file, char __user *buffer, * Remember: Data delivered is never endian-corrected */ errno = sisusb_read_mem_bulk(sisusb, address, - NULL, count, buffer, &bytes_read); + NULL, count, (u8 __user *)buffer, &bytes_read); if (bytes_read) errno = bytes_read; @@ -2577,7 +2577,7 @@ static ssize_t sisusb_read(struct file *file, char __user *buffer, * Remember: Data delivered is never endian-corrected */ errno = sisusb_read_mem_bulk(sisusb, address, - NULL, count, buffer, &bytes_read); + NULL, count, (u8 __user *)buffer, &bytes_read); if (bytes_read) errno = bytes_read;