Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp105606ybk; Fri, 8 May 2020 15:17:40 -0700 (PDT) X-Google-Smtp-Source: APiQypLWJL3hZsyL7YNGVn1RquK/F4sQa/hborKuwEQ684kVdg8ucFhZtsNa60LN2H8W26ArDJHf X-Received: by 2002:a17:906:6441:: with SMTP id l1mr3928333ejn.148.1588976260145; Fri, 08 May 2020 15:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588976260; cv=none; d=google.com; s=arc-20160816; b=VYUPg2kjOwV4D4R8iEXy3slefoxmR/brXiYHQt33M02dnFc5n7w6Lb0i68sPv/Yr8b oj2g6SwDatCdl6Ggf1W0DbtOiT1CIBynuCwhTkAQ1lZhot9pn/qFkQ9KcdUrT+gq9lFQ IB2iC946VAg9JvkKiDrBVe/Gr7VyRUAwby8AZfj3h2wA06y2IjIIDkxWx4yhiezwI93X IoYM4MwUhDmcwj1/ZF6MY/bq5vtbaocml75ZPCUVu6ByoLzem4Y9/6MuGPFHRAssePLp ujAiMeJmvkqY1QPcI+R9sUprKRFEtkvtTv//aQjbB4Jh9TBAogtn6tP/QSeI+g/n2r09 JMmw== 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:cc:to:from :subject:organization:dkim-signature; bh=a1nuPRTr7zkCHMa6FVvgv5uLC2rFZUxwckBQ7tiqwpY=; b=0yDG6blskoNI7Qe8tvTygPja8HQjhDWHOthbmKTsbjhH41aSRZ8rNfjcVXCsPyYdC9 oL0PaPsrtW/bSTrpd47nPHyEoD8R6zzp/OCAYciAKAm/Zz7HE4tcQ1WVWAMJSWKpfjji I/Z0tBusH1ZiWqpCsa2sW5NKvSip6JxQwyGUZZ7VxCimdJxLFyu3G7Ca8pmj78i/trnh 0IjIQ+ln54jqkGidheeRRGxnhtxtHwQ0kCkDh+oNtj566mKtXrJvemdveS8uKbjwOjHx DxesFMoO8P/quptt3ThuP0kAnjAWdEDWWrDwZ80YfMwBo2vkJrvL6GveglzsKAj2+xVm vOow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ikzxJolJ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d60si1622805edc.337.2020.05.08.15.17.16; Fri, 08 May 2020 15:17:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ikzxJolJ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728102AbgEHWRB (ORCPT + 99 others); Fri, 8 May 2020 18:17:01 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:34003 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727828AbgEHWRB (ORCPT ); Fri, 8 May 2020 18:17:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588976220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a1nuPRTr7zkCHMa6FVvgv5uLC2rFZUxwckBQ7tiqwpY=; b=ikzxJolJyvH767Jgnw3V2C2qcbXwaeLhlwXOtxmQ/udC55QL9TM8y4MWLPiu4v5yT2k1Nt amcLQDQm07h340q+Gg2fa2wJaZTZDt4LbGghFqhdltRrQLws9gR712U0igbVBS4CMT/62S aL8w4a8X8Lox0AxnxjtkZEPb2164pxY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-EMC-1vvgPd63c3-JyquyNw-1; Fri, 08 May 2020 18:16:58 -0400 X-MC-Unique: EMC-1vvgPd63c3-JyquyNw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77AB6464; Fri, 8 May 2020 22:16:57 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-118-225.rdu2.redhat.com [10.10.118.225]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DF775C28E; Fri, 8 May 2020 22:16:50 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 1/5] cachefiles: Fix corruption of the return value in cachefiles_read_or_alloc_pages() From: David Howells To: torvalds@linux-foundation.org, Trond Myklebust Cc: David Wysochanski , David Wysochanski , Carlos Maiolino , dhowells@redhat.com, Anna Schumaker , linux-nfs@vger.kernel.org, linux-cachefs@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 08 May 2020 23:16:49 +0100 Message-ID: <158897620966.1119820.74747109024841084.stgit@warthog.procyon.org.uk> In-Reply-To: <158897619675.1119820.2203023452686054109.stgit@warthog.procyon.org.uk> References: <158897619675.1119820.2203023452686054109.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.21 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The patch which changed cachefiles from calling ->bmap() to using the bmap() wrapper overwrote the running return value with the result of calling bmap(). This causes an assertion failure elsewhere in the code. Fix this by using ret2 rather than ret to hold the return value. The oops looks like: kernel BUG at fs/nfs/fscache.c:468! ... RIP: 0010:__nfs_readpages_from_fscache+0x18b/0x190 [nfs] ... Call Trace: nfs_readpages+0xbf/0x1c0 [nfs] ? __alloc_pages_nodemask+0x16c/0x320 read_pages+0x67/0x1a0 __do_page_cache_readahead+0x1cf/0x1f0 ondemand_readahead+0x172/0x2b0 page_cache_async_readahead+0xaa/0xe0 generic_file_buffered_read+0x852/0xd50 ? mem_cgroup_commit_charge+0x6e/0x140 ? nfs4_have_delegation+0x19/0x30 [nfsv4] generic_file_read_iter+0x100/0x140 ? nfs_revalidate_mapping+0x176/0x2b0 [nfs] nfs_file_read+0x6d/0xc0 [nfs] new_sync_read+0x11a/0x1c0 __vfs_read+0x29/0x40 vfs_read+0x8e/0x140 ksys_read+0x61/0xd0 __x64_sys_read+0x1a/0x20 do_syscall_64+0x60/0x1e0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f5d148267e0 Fixes: 10d83e11a582 ("cachefiles: drop direct usage of ->bmap method.") Reported-by: David Wysochanski Signed-off-by: David Howells Tested-by: David Wysochanski cc: Carlos Maiolino --- fs/cachefiles/rdwr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index 1dc97f2d6201..d3d78176b23c 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c @@ -398,7 +398,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op, struct inode *inode; sector_t block; unsigned shift; - int ret; + int ret, ret2; object = container_of(op->op.object, struct cachefiles_object, fscache); @@ -430,8 +430,8 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op, block = page->index; block <<= shift; - ret = bmap(inode, &block); - ASSERT(ret < 0); + ret2 = bmap(inode, &block); + ASSERT(ret2 == 0); _debug("%llx -> %llx", (unsigned long long) (page->index << shift), @@ -739,8 +739,8 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op, block = page->index; block <<= shift; - ret = bmap(inode, &block); - ASSERT(!ret); + ret2 = bmap(inode, &block); + ASSERT(ret2 == 0); _debug("%llx -> %llx", (unsigned long long) (page->index << shift),