Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2957365imu; Mon, 19 Nov 2018 08:36:43 -0800 (PST) X-Google-Smtp-Source: AJdET5dgrf4PwB/uEN83yNskLSezrxC3PJg6FIztKZK4+OUUaJ6IiEh5OIyPOFyZIsIEoiYkWk1B X-Received: by 2002:a62:5504:: with SMTP id j4-v6mr23784958pfb.166.1542645403327; Mon, 19 Nov 2018 08:36:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542645403; cv=none; d=google.com; s=arc-20160816; b=MWX8uhCUpRvYVAR+Yf+aiY+5FeDyAMK3amN+vIv0ov1pyUmGup11EAaeW25LAfZDQ+ HpUO2/SCwRLAvsjRoB+2wjgtK4aCuPMu87kyDAVFSWylMVzqyQtf17n4Zg6F28lzi/wf UwNIt9IQ0Jr6JunmTOk58Ysyusev6xPPiHht4YLMD6Unj6zBm1ocGjcspnlf1BoRgErU cP+sYA5wmqxgkjzz3o86RkeN2/c6n8yjFdR+uCriCYWyxS04E5Tz5q1+ENIZHFOHUHB+ p/R1/bNwUwttVbLJwsxEWXGU+e6jIHrrMC8Egdz+l6QVPbLIob0iTYhEilrYVmhGkGt0 SBUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=szXTR3/z1eNrTzi8FRW1juiiyF4zPR8FdE6QcFdBrPc=; b=tUBJN8GXNfAc/JqtJRjo2dvfRz7ypMnd5aiSFkh3+xk57Je2MEoOWbDaoSKCL+nODQ CiM0iGxHokiymXJzHo14NJ5pXSK2b5bmP2dO133+Rf7Ifm5wwdBx6YxAzzfWa2sYweAe 1isSmo1vJmTvawBkYsC/nR01mb/z0NWvssEPrj3bM1FlSsKjLMu/6KWuwRX2ESxbMw2/ QKwKG/Bem9aH9Z/HS52iW6CSLAH2LQWPbXhy0wseTWDB1ZrcegokFjyFTR4+1Mtgm7C2 IrVY1haNIZxrID+Jnev8JF01m6uM7TTcyesabpFWZFEqnSCHD8R/qUtueVV7OZOih96O rGsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FTr1HOMv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24si34985834pgd.248.2018.11.19.08.36.27; Mon, 19 Nov 2018 08:36:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FTr1HOMv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731163AbeKTC5r (ORCPT + 99 others); Mon, 19 Nov 2018 21:57:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:56590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731102AbeKTC5q (ORCPT ); Mon, 19 Nov 2018 21:57:46 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 875432089F; Mon, 19 Nov 2018 16:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645218; bh=eDz9yOCw/i4g4BljvVfTyeK8knJvcVG7VKXnt8QhAVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FTr1HOMvKvCy6l/JBqatTvwFBHqlSJymijqbxkXdqzWdssAy5rHSutqPovE6T42I+ KYuUITUDUvaLogSCVZ6qoHFv7VR26T4gCC5xnMD/p9QPGQBaaG1cARb37moWfA5cRY aZSRgCOP1OnvPlxYl5ETOuP18le1oMH3wffV5JIY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+4e975615ca01f2277bdd@syzkaller.appspotmail.com, Kirill Tkhai , Miklos Szeredi Subject: [PATCH 4.19 064/205] fuse: Fix use-after-free in fuse_dev_do_read() Date: Mon, 19 Nov 2018 17:26:11 +0100 Message-Id: <20181119162628.575127199@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kirill Tkhai commit bc78abbd55dd28e2287ec6d6502b842321a17c87 upstream. We may pick freed req in this way: [cpu0] [cpu1] fuse_dev_do_read() fuse_dev_do_write() list_move_tail(&req->list, ...); ... spin_unlock(&fpq->lock); ... ... request_end(fc, req); ... fuse_put_request(fc, req); if (test_bit(FR_INTERRUPTED, ...)) queue_interrupt(fiq, req); Fix that by keeping req alive until we finish all manipulations. Reported-by: syzbot+4e975615ca01f2277bdd@syzkaller.appspotmail.com Signed-off-by: Kirill Tkhai Signed-off-by: Miklos Szeredi Fixes: 46c34a348b0a ("fuse: no fc->lock for pqueue parts") Cc: # v4.2 Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dev.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1311,12 +1311,14 @@ static ssize_t fuse_dev_do_read(struct f goto out_end; } list_move_tail(&req->list, &fpq->processing); + __fuse_get_request(req); spin_unlock(&fpq->lock); set_bit(FR_SENT, &req->flags); /* matches barrier in request_wait_answer() */ smp_mb__after_atomic(); if (test_bit(FR_INTERRUPTED, &req->flags)) queue_interrupt(fiq, req); + fuse_put_request(fc, req); return reqsize;