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=-11.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 53E4EC43331 for ; Thu, 26 Mar 2020 14:06:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2949C2073E for ; Thu, 26 Mar 2020 14:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585231616; bh=jJU/swcvG1TnA6bS29KfNmxxVgb3h5N1MN38nRmkTbI=; h=Subject:To:From:Date:List-ID:From; b=isPCTkPcZbfDH8Nb+prF/ZefqC4S9TUYYn9TxboSi8XHjCmzNzYk05oQAlqdfZAVx EtzcWD+Gsx8w2OzShxahHH0c06TWvfKRm66m+2c21oujEtjvZkrFZxEfD5TTs9FnWH MD82I07e6rboLFT2+f46iy4VSqrtOzeaG8T+65Mw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727996AbgCZOGz (ORCPT ); Thu, 26 Mar 2020 10:06:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:55324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727981AbgCZOGz (ORCPT ); Thu, 26 Mar 2020 10:06:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 42E08206F8; Thu, 26 Mar 2020 14:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585231614; bh=jJU/swcvG1TnA6bS29KfNmxxVgb3h5N1MN38nRmkTbI=; h=Subject:To:From:Date:From; b=RruB4qIxID5UvDfKggVNQEsOn6/Pd5Bept+aVp/CoQeOYPhN8O8IHymHZFLq7uuZx ePPp8ooqnkBx3cKhnmwlkTLNNx/3SXetTrXXLZDTD6VC6Wh3XcSIZ0uLX/KX0TtVbr 888odlkpXUICjeiPvjkivS2XoaIMaTQbaoxXLqiw= Subject: patch "usb: gadget: f_fs: Fix use after free issue as part of queue failure" added to usb-testing To: sallenki@codeaurora.org, gregkh@linuxfoundation.org, peter.chen@nxp.com, stable@vger.kernel.org From: Date: Thu, 26 Mar 2020 15:06:33 +0100 Message-ID: <1585231593210223@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is a note to let you know that I've just added the patch titled usb: gadget: f_fs: Fix use after free issue as part of queue failure to my usb git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git in the usb-testing branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will be merged to the usb-next branch sometime soon, after it passes testing, and the merge window is open. If you have any questions about this process, please let me know. From f63ec55ff904b2f2e126884fcad93175f16ab4bb Mon Sep 17 00:00:00 2001 From: Sriharsha Allenki Date: Thu, 26 Mar 2020 17:26:20 +0530 Subject: usb: gadget: f_fs: Fix use after free issue as part of queue failure In AIO case, the request is freed up if ep_queue fails. However, io_data->req still has the reference to this freed request. In the case of this failure if there is aio_cancel call on this io_data it will lead to an invalid dequeue operation and a potential use after free issue. Fix this by setting the io_data->req to NULL when the request is freed as part of queue failure. Fixes: 2e4c7553cd6f ("usb: gadget: f_fs: add aio support") Signed-off-by: Sriharsha Allenki CC: stable Reviewed-by: Peter Chen Link: https://lore.kernel.org/r/20200326115620.12571-1-sallenki@codeaurora.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 571917677d35..767f30b86645 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1120,6 +1120,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC); if (unlikely(ret)) { + io_data->req = NULL; usb_ep_free_request(ep->ep, req); goto error_lock; } -- 2.26.0