Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2972132imu; Mon, 19 Nov 2018 08:49:06 -0800 (PST) X-Google-Smtp-Source: AJdET5cJvKENA5p8pRUSHpjF01j+EsQjkddoW/jfgb1m/EzmV3p2sgqxZd4apdEnYCbWNOsaqflY X-Received: by 2002:a17:902:e002:: with SMTP id ca2mr19603858plb.103.1542646146836; Mon, 19 Nov 2018 08:49:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542646146; cv=none; d=google.com; s=arc-20160816; b=1GAwPMeiBGvmwk784BGtWU2JecTSYoJu2iRGtFXnfdHDsMTz5DvUTqJvp7IkXYAuSN drLKcQAbDS8Bx+GReD+iVN3M5sv0GLxVMQQRkPp+TF49bKJFBbYqLrqTgEs31pP96fD8 jgxuKvPXaoar3WebncFim46QqK7AgTDE3Xo0HnkEES3YtQa+5XpvKetaPERWYtifAqVF I2XqzQV3D1aar95Dg5Rf4sryTcSzAylPWlo25E3v66et8kCeTGRpa10hkKHYFMmhbS8s Zi2BAOr4cE01tlyZxuCm1+iz4KunxI6lk74ks6rcKSjGxov3WxV8JkBn05BTUFHlhVAv RFCg== 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=GnlWYeYvsBHNH9KzuHjQOuqB+wFaXgDwNbB3hjj/23g=; b=0w26ARBzQWbUk03aDtIoIxmJK7QHQeX0kt6MDdJJEK+fcJYUnD8/9Yvu1YDvbu/ELL 0xG/+wNh73BMOOfbIMxstAtkaIm3A0oJ5ITtft+Crkjprgq8aLZ0z/RhpBPQfP/tazJm 5x08hkR1sx3TFermVHYmDGenlkw9phptP/PmHXd17Hn7SjoqwwFfRKnbY0zhVJ4taIDm ouP0pL5v/f8MptCFEZUhO2aDeLEh0WiObE8wHfRl23OkY46E7iAcgSU5GSK5+WbJYAWj P+g717/G6WnZP4YYv+ZeE22gDDYzwT8D44PkrAPbz/FkLfnt/HDRVIMqw6ZyXVBlEnbq nSog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UOSD0gNp; 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 j66-v6si30176034pfb.284.2018.11.19.08.48.51; Mon, 19 Nov 2018 08:49:06 -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=UOSD0gNp; 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 S2389325AbeKTDMX (ORCPT + 99 others); Mon, 19 Nov 2018 22:12:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:48592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387988AbeKTDMW (ORCPT ); Mon, 19 Nov 2018 22:12:22 -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 19ABA206BA; Mon, 19 Nov 2018 16:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646090; bh=NyXhIZttS037cV/vNc6OFp2UVVp1zhrVJIBGtBqpfbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UOSD0gNpm3eApIay+nURcXjif1OAnWVfcS1Dim3DYnmESbWYBewZuXRsrsWItMD1V /puokBf3ncVu8W8qYfa/srr2fFu99ySSxzNp3mlNV1nFrpkbG5+TPL5TJp13YHoX16 xocxZeE+38mhrlbJqpCvT5cAKLX+ng/C7S+UZqlY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kirill Tkhai , Miklos Szeredi Subject: [PATCH 4.14 031/124] fuse: Fix use-after-free in fuse_dev_do_write() Date: Mon, 19 Nov 2018 17:28:05 +0100 Message-Id: <20181119162619.641268958@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162612.951907286@linuxfoundation.org> References: <20181119162612.951907286@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kirill Tkhai commit d2d2d4fb1f54eff0f3faa9762d84f6446a4bc5d0 upstream. After we found req in request_find() and released the lock, everything may happen with the req in parallel: cpu0 cpu1 fuse_dev_do_write() fuse_dev_do_write() req = request_find(fpq, ...) ... spin_unlock(&fpq->lock) ... ... req = request_find(fpq, oh.unique) ... spin_unlock(&fpq->lock) queue_interrupt(&fc->iq, req); ... ... ... ... ... request_end(fc, req); fuse_put_request(fc, req); ... queue_interrupt(&fc->iq, req); 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1874,16 +1874,20 @@ static ssize_t fuse_dev_do_write(struct /* Is it an interrupt reply? */ if (req->intr_unique == oh.unique) { + __fuse_get_request(req); spin_unlock(&fpq->lock); err = -EINVAL; - if (nbytes != sizeof(struct fuse_out_header)) + if (nbytes != sizeof(struct fuse_out_header)) { + fuse_put_request(fc, req); goto err_finish; + } if (oh.error == -ENOSYS) fc->no_interrupt = 1; else if (oh.error == -EAGAIN) queue_interrupt(&fc->iq, req); + fuse_put_request(fc, req); fuse_copy_finish(cs); return nbytes;