From patchwork Mon Dec 13 09:30:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 524217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B460FC433EF for ; Mon, 13 Dec 2021 09:33:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232321AbhLMJdZ (ORCPT ); Mon, 13 Dec 2021 04:33:25 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:58064 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233885AbhLMJdP (ORCPT ); Mon, 13 Dec 2021 04:33:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id B68F1CE0E6B; Mon, 13 Dec 2021 09:33:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61F77C00446; Mon, 13 Dec 2021 09:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1639387991; bh=3HWsN2RFtBrUxlWtXazhc9PegL69XzYtaKlCzUGCkd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wbbhch3zhDEE/KiFVxOLgwO5vYAHAbsFF1nMhhnntZDmJ5H7LaQOmyCGyosmusgWl Zn1lqAMY/k6JHTMbMoRyV07+1elB00f+PycHss4NHaBr1T1zA5r6hOSVBo7Af9fbge MSStdPxcrbwenC+0837ftlSS6omOzdw3soyP6Hn0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Szymon Heidrich Subject: [PATCH 4.4 29/37] USB: gadget: zero allocate endpoint 0 buffers Date: Mon, 13 Dec 2021 10:30:07 +0100 Message-Id: <20211213092926.328618176@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211213092925.380184671@linuxfoundation.org> References: <20211213092925.380184671@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Greg Kroah-Hartman commit 86ebbc11bb3f60908a51f3e41a17e3f477c2eaa3 upstream. Under some conditions, USB gadget devices can show allocated buffer contents to a host. Fix this up by zero-allocating them so that any extra data will all just be zeros. Reported-by: Szymon Heidrich Tested-by: Szymon Heidrich Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/composite.c | 2 +- drivers/usb/gadget/legacy/dbgp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -2018,7 +2018,7 @@ int composite_dev_prepare(struct usb_com if (!cdev->req) return -ENOMEM; - cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL); + cdev->req->buf = kzalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL); if (!cdev->req->buf) goto fail; --- a/drivers/usb/gadget/legacy/dbgp.c +++ b/drivers/usb/gadget/legacy/dbgp.c @@ -136,7 +136,7 @@ static int dbgp_enable_ep_req(struct usb goto fail_1; } - req->buf = kmalloc(DBGP_REQ_LEN, GFP_KERNEL); + req->buf = kzalloc(DBGP_REQ_LEN, GFP_KERNEL); if (!req->buf) { err = -ENOMEM; stp = 2;