From patchwork Tue Sep 1 15:10:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 310252 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=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 A6AA3C433E7 for ; Tue, 1 Sep 2020 16:57:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A9AA214F1 for ; Tue, 1 Sep 2020 16:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598979454; bh=kmamFZ2shPcWg1K0wauWkZZ2BELptm1EAJQ2DNJ4tiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=oIZf/vGAxpFdguwdhQ05qurlsMzlYwqsQiQRIeJgJp15Ack/LibVpoVBNj7C5W6Zj /upcK6It6GmEcZPTi5X2i7lKa0mUSUVFXdj44sOqGkP9GudDAZSdx8vWLa5abOXIL1 wprCNBZ8fT4euSqlqVlDqH8sPM/r9upPwQFTMIiw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729646AbgIAQ5d (ORCPT ); Tue, 1 Sep 2020 12:57:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:46184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729795AbgIAPXR (ORCPT ); Tue, 1 Sep 2020 11:23:17 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA79C2100A; Tue, 1 Sep 2020 15:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973797; bh=kmamFZ2shPcWg1K0wauWkZZ2BELptm1EAJQ2DNJ4tiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Oa7EtPclgELkbmuBtHeO/S0hUyddfKpIhYONlzDlFaXPNa+lToqBlHgNZ6H6kB4l FCa3yLYaYHwV4pgqf/l243RTItM4HcflZnmcn/GhlHtxQDU+85FAJeUu5RaGHTEpuX NWRMpdLKPK5RO1td+sEfGazVi47rLgzRr4uMcknQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Changming Liu , Sasha Levin Subject: [PATCH 4.19 050/125] USB: sisusbvga: Fix a potential UB casued by left shifting a negative value Date: Tue, 1 Sep 2020 17:10:05 +0200 Message-Id: <20200901150937.001525313@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150934.576210879@linuxfoundation.org> References: <20200901150934.576210879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Changming Liu [ Upstream commit 2b53a19284f537168fb506f2f40d7fda40a01162 ] The char buffer buf, receives data directly from user space, so its content might be negative and its elements are left shifted to form an unsigned integer. Since left shifting a negative value is undefined behavior, thus change the char to u8 to elimintate this UB. Signed-off-by: Changming Liu Link: https://lore.kernel.org/r/20200711043018.928-1-charley.ashbringer@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/misc/sisusbvga/sisusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 6376be1f5fd22..4877bf82ad395 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -761,7 +761,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, u8 swap8, fromkern = kernbuffer ? 1 : 0; u16 swap16; u32 swap32, flag = (length >> 28) & 1; - char buf[4]; + u8 buf[4]; /* if neither kernbuffer not userbuffer are given, assume * data in obuf