From patchwork Tue Jan 15 10:19:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10764239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41B0013B5 for ; Tue, 15 Jan 2019 10:19:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 302602B2ED for ; Tue, 15 Jan 2019 10:19:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 243A22B2FF; Tue, 15 Jan 2019 10:19:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3FA12B2ED for ; Tue, 15 Jan 2019 10:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727452AbfAOKTW (ORCPT ); Tue, 15 Jan 2019 05:19:22 -0500 Received: from relay.sw.ru ([185.231.240.75]:36284 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726077AbfAOKTW (ORCPT ); Tue, 15 Jan 2019 05:19:22 -0500 Received: from [172.16.25.169] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gjLoW-00012W-2Z; Tue, 15 Jan 2019 13:19:20 +0300 Subject: [PATCH 1/7] fuse: Check for fc->connected in fuse_dev_alloc() From: Kirill Tkhai To: miklos@szeredi.hu, ktkhai@virtuozzo.com, linux-fsdevel@vger.kernel.org Date: Tue, 15 Jan 2019 13:19:19 +0300 Message-ID: <154754755979.4244.14965151684224631403.stgit@localhost.localdomain> In-Reply-To: <154754701031.4244.8089449938935364463.stgit@localhost.localdomain> References: <154754701031.4244.8089449938935364463.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP fuse_dev_alloc() may be called after fc->connected is dropped (from ioctl), so here we add sanity check for that case. Signed-off-by: Kirill Tkhai --- fs/fuse/inode.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 336844d0eb3a..0361a3d62356 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1054,10 +1054,19 @@ struct fuse_dev *fuse_dev_alloc(struct fuse_conn *fc) fuse_pqueue_init(&fud->pq); spin_lock(&fc->lock); + if (!fc->connected) { + spin_unlock(&fc->lock); + goto out_put; + } list_add_tail(&fud->entry, &fc->devices); spin_unlock(&fc->lock); return fud; +out_put: + fuse_conn_put(fc); + kfree(pq); + kfree(fud); + return NULL; } EXPORT_SYMBOL_GPL(fuse_dev_alloc);