Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1987618imu; Fri, 14 Dec 2018 04:07:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/UU7KUPmliuaBdA6/K1jf7PeHH6GqmiH6Uf8oYp8b1yJmQXKrI/OVoFWMLQ8Ie4zg8cxOg5 X-Received: by 2002:a63:6704:: with SMTP id b4mr2511601pgc.100.1544789261551; Fri, 14 Dec 2018 04:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789261; cv=none; d=google.com; s=arc-20160816; b=pdTctOtIpjWkcFWlBsj8GnAm8iGRUYt8+XRgtdnRtdBp7t2LWRY+WybsN66U8UE7MV Zjb/fKiDNOuFu4mH0VpCiLayeFTycK8JiFyfo7k9XgCHzXJzVFV0jujRRoZCOMoTwt3d GTIastg0LfZyv5Ws/l5E833C6XpJ609a9uPDeDnazJarFX5RJEWU/BcBAtFQWoCQ5/wT i9h17akrrvvCSHk9p9YcLRd+pkd06Hd1su+HlZr83zhxr3pXwnRlFrf8LTeHL6qxoMLj 6EERj0iM7YMpLe9OPTIaja8comfqXJC5feOvVmu19kxvAcLcGHDyWv/WkMFhz1tHdlzD uYcQ== 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=n9VUOE46kZk7yjeLB0GjeUCvtXmdmdPgvxIqVafhLeU=; b=R5Z7xs9CyIdjNILjrNiVHQ2kRkyMyMjSZQ08VkYLCVLvalJrS/4ZMGClmFdZCheufI bPldpkC4z9xQMb12kSkSqqbTY5FE3G7rW263qgotofvAc4rUO1JBsUyfKfSvYO4255nf V0mmqPLjW4Pik6CYU7KG1QgCGFkoGeY7g7SzabONf1zucMGUFGN10muhdnynhXyDoqpM lRVcHfQGMVtGe2HmskroZgz+yQ83qsHyLJqmkqNpvcfari6ywbavfTl63J77JS+wxwwJ MkE75rFIqOmncboO+tBPSHB3PBypH5i/DZF2mx7Cg5nWck7+p7RbnQ9BEKr3ZH+2tlxu sagQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="MW/UhI0U"; 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 h5si3967703pgg.230.2018.12.14.04.07.26; Fri, 14 Dec 2018 04:07:41 -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="MW/UhI0U"; 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 S1730707AbeLNMF3 (ORCPT + 99 others); Fri, 14 Dec 2018 07:05:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:50264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730698AbeLNMF0 (ORCPT ); Fri, 14 Dec 2018 07:05:26 -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 E744A21486; Fri, 14 Dec 2018 12:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789125; bh=w4d8c//xKQoFD/GX3KylrBSR/vDnUxgUeskBmyrMBTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MW/UhI0UP5d07xTGps1zXApzD0Fbuo11dH/T99Pn3EzLVUhMJeh/4fJb/zhbUHCkc JDC9mRmRf+BwtGoCDh4Gpd+u3UJgfhySvJsna3OKy3ddbafWnzU0QKtWgy3SY9LNXF 9TZC67yKngC8IwJ4akVU/WP4f2H+ekVyg51CqHs4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhibin Li , David Howells , Sasha Levin Subject: [PATCH 4.19 104/142] cachefiles: Fix an assertion failure when trying to update a failed object Date: Fri, 14 Dec 2018 12:59:49 +0100 Message-Id: <20181214115751.218924732@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115747.053633987@linuxfoundation.org> References: <20181214115747.053633987@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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. ------------------ [ Upstream commit e6bc06faf64a83384cc0abc537df954c9d3ff942 ] If cachefiles gets an error other then ENOENT when trying to look up an object in the cache (in this case, EACCES), the object state machine will eventually transition to the DROP_OBJECT state. This state invokes fscache_drop_object() which tries to sync the auxiliary data with the cache (this is done lazily since commit 402cb8dda949d) on an incomplete cache object struct. The problem comes when cachefiles_update_object_xattr() is called to rewrite the xattr holding the data. There's an assertion there that the cache object points to a dentry as we're going to update its xattr. The assertion trips, however, as dentry didn't get set. Fix the problem by skipping the update in cachefiles if the object doesn't refer to a dentry. A better way to do it could be to skip the update from the DROP_OBJECT state handler in fscache, but that might deny the cache the opportunity to update intermediate state. If this error occurs, the kernel log includes lines that look like the following: CacheFiles: Lookup failed error -13 CacheFiles: CacheFiles: Assertion failed ------------[ cut here ]------------ kernel BUG at fs/cachefiles/xattr.c:138! ... Workqueue: fscache_object fscache_object_work_func [fscache] RIP: 0010:cachefiles_update_object_xattr.cold.4+0x18/0x1a [cachefiles] ... Call Trace: cachefiles_update_object+0xdd/0x1c0 [cachefiles] fscache_update_aux_data+0x23/0x30 [fscache] fscache_drop_object+0x18e/0x1c0 [fscache] fscache_object_work_func+0x74/0x2b0 [fscache] process_one_work+0x18d/0x340 worker_thread+0x2e/0x390 ? pwq_unbound_release_workfn+0xd0/0xd0 kthread+0x112/0x130 ? kthread_bind+0x30/0x30 ret_from_fork+0x35/0x40 Note that there are actually two issues here: (1) EACCES happened on a cache object and (2) an oops occurred. I think that the second is a consequence of the first (it certainly looks like it ought to be). This patch only deals with the second. Fixes: 402cb8dda949 ("fscache: Attach the index key and aux data to the cookie") Reported-by: Zhibin Li Signed-off-by: David Howells Signed-off-by: Sasha Levin --- fs/cachefiles/xattr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c index 0a29a00aed2e..511e6c68156a 100644 --- a/fs/cachefiles/xattr.c +++ b/fs/cachefiles/xattr.c @@ -135,7 +135,8 @@ int cachefiles_update_object_xattr(struct cachefiles_object *object, struct dentry *dentry = object->dentry; int ret; - ASSERT(dentry); + if (!dentry) + return -ESTALE; _enter("%p,#%d", object, auxdata->len); -- 2.19.1