Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3086910ybt; Mon, 29 Jun 2020 15:01:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKXTaTLaVNknj1+MCOfVyP5nGcNYzM8wGzLP0d7e+DutLMfD4sjO5nckblvSV/PgT9sljM X-Received: by 2002:aa7:db4f:: with SMTP id n15mr4205003edt.193.1593468103516; Mon, 29 Jun 2020 15:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593468103; cv=none; d=google.com; s=arc-20160816; b=xusqjRvADSRdSER4+qBG+kcakjOKeQI986/N2dJ97B53NX6NP+Fo/TeSgJZkWLuB5P MDo1VGw5f+SLQ4Ul9EQGEyWG6Ugq2eoAmwGC7eAC83UVlGb0pRElcwxfewgOaR8uFlZt 8nb2U3Vjgg/b0C5cpmWX4lGHiEPlwrQFvpqkxy3efZx6APY7a2nOOEOxi3hV9FVXNIp0 WKSZt0c5uuEerCekiDwmY7c9RfdiatdXpWl02UFD93uI7Bz6aayBPHQO6PvR+/y1i4qL jzgS2P7HNuKXavJ7fFiYJxi+WSz3NssDCLHimnbQa6ZVgyt6/gcqU4Ts+V6d2tpXnoVF FiIA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7iMxB+ifYxcVvRSbOl0GHa/7OFEEI7YktVKKIJpcEu4=; b=XACX4gxDFquR1aY5igMyeBOzcpWJ62UjDqzWGMGwXoDDaIHh+XC7FWKHSS8rtUqex3 2C9D7KtWt/1w2+BNjCcGrrra2UYFvRKFo2vpI9XZBPMJULlbik/AyO/bddVYtWmhHnA+ nwoY6RySeIhZB5yydM4dQxAugpzNaeTyvojmsqx8qtaevsQYy3E92CZcrV4pbZTREFzW SIRXzJe1qW5eenIaR1JXP88k4x1tL0FfYM6xXDEjOH4d/39OS94Fxe/70oymZ85sDUQ8 AiWYwoA0aDhbfMH+4lHaJLZ/FbfTPRiYjfCziS0PigQiOzJlQ9cv86xBYJ3dIKzwkAzV q1uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n85OXHkF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m27si518938edj.431.2020.06.29.15.01.20; Mon, 29 Jun 2020 15:01:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@kernel.org header.s=default header.b=n85OXHkF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404687AbgF2V7o (ORCPT + 99 others); Mon, 29 Jun 2020 17:59:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:56786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbgF2Sf0 (ORCPT ); Mon, 29 Jun 2020 14:35:26 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7850F247BD; Mon, 29 Jun 2020 15:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444126; bh=C9k1s+ImQZhFLYcZjvmoOEJvDi0OY8NulpkwBF9MZ3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n85OXHkFnHNgwKuj3y27LPgnlQCFfTGnZVZlY2UpPanDI4MmAsGexEgRpGpPIX2Ji EsXi+V7CTFZ5x7U0Qd1OIVRGKbZaelP/FEp8jQKO1+5hqOdqkePdKvcS2fYg9zF9IM Bj1kicURRI3+2Lu/WFRhkxw5SWciSsd5w0NVAgE8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Junxiao Bi , Joseph Qi , Changwei Ge , Gang He , Joel Becker , Jun Piao , Mark Fasheh , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman Subject: [PATCH 5.7 234/265] ocfs2: fix panic on nfs server over ocfs2 Date: Mon, 29 Jun 2020 11:17:47 -0400 Message-Id: <20200629151818.2493727-235-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629151818.2493727-1-sashal@kernel.org> References: <20200629151818.2493727-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.7.7-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.7.7-rc1 X-KernelTest-Deadline: 2020-07-01T15:14+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Junxiao Bi commit e5a15e17a78d58f933d17cafedfcf7486a29f5b4 upstream. The following kernel panic was captured when running nfs server over ocfs2, at that time ocfs2_test_inode_bit() was checking whether one inode locating at "blkno" 5 was valid, that is ocfs2 root inode, its "suballoc_slot" was OCFS2_INVALID_SLOT(65535) and it was allocted from //global_inode_alloc, but here it wrongly assumed that it was got from per slot inode alloctor which would cause array overflow and trigger kernel panic. BUG: unable to handle kernel paging request at 0000000000001088 IP: [] _raw_spin_lock+0x18/0xf0 PGD 1e06ba067 PUD 1e9e7d067 PMD 0 Oops: 0002 [#1] SMP CPU: 6 PID: 24873 Comm: nfsd Not tainted 4.1.12-124.36.1.el6uek.x86_64 #2 Hardware name: Huawei CH121 V3/IT11SGCA1, BIOS 3.87 02/02/2018 RIP: _raw_spin_lock+0x18/0xf0 RSP: e02b:ffff88005ae97908 EFLAGS: 00010206 RAX: ffff88005ae98000 RBX: 0000000000001088 RCX: 0000000000000000 RDX: 0000000000020000 RSI: 0000000000000009 RDI: 0000000000001088 RBP: ffff88005ae97928 R08: 0000000000000000 R09: ffff880212878e00 R10: 0000000000007ff0 R11: 0000000000000000 R12: 0000000000001088 R13: ffff8800063c0aa8 R14: ffff8800650c27d0 R15: 000000000000ffff FS: 0000000000000000(0000) GS:ffff880218180000(0000) knlGS:ffff880218180000 CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000001088 CR3: 00000002033d0000 CR4: 0000000000042660 Call Trace: igrab+0x1e/0x60 ocfs2_get_system_file_inode+0x63/0x3a0 [ocfs2] ocfs2_test_inode_bit+0x328/0xa00 [ocfs2] ocfs2_get_parent+0xba/0x3e0 [ocfs2] reconnect_path+0xb5/0x300 exportfs_decode_fh+0xf6/0x2b0 fh_verify+0x350/0x660 [nfsd] nfsd4_putfh+0x4d/0x60 [nfsd] nfsd4_proc_compound+0x3d3/0x6f0 [nfsd] nfsd_dispatch+0xe0/0x290 [nfsd] svc_process_common+0x412/0x6a0 [sunrpc] svc_process+0x123/0x210 [sunrpc] nfsd+0xff/0x170 [nfsd] kthread+0xcb/0xf0 ret_from_fork+0x61/0x90 Code: 83 c2 02 0f b7 f2 e8 18 dc 91 ff 66 90 eb bf 0f 1f 40 00 55 48 89 e5 41 56 41 55 41 54 53 0f 1f 44 00 00 48 89 fb ba 00 00 02 00 0f c1 17 89 d0 45 31 e4 45 31 ed c1 e8 10 66 39 d0 41 89 c6 RIP _raw_spin_lock+0x18/0xf0 CR2: 0000000000001088 ---[ end trace 7264463cd1aac8f9 ]--- Kernel panic - not syncing: Fatal exception Link: http://lkml.kernel.org/r/20200616183829.87211-4-junxiao.bi@oracle.com Signed-off-by: Junxiao Bi Reviewed-by: Joseph Qi Cc: Changwei Ge Cc: Gang He Cc: Joel Becker Cc: Jun Piao Cc: Mark Fasheh Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/suballoc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 4836becb7578a..45745cc3408a5 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -2825,9 +2825,12 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res) goto bail; } - inode_alloc_inode = - ocfs2_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE, - suballoc_slot); + if (suballoc_slot == (u16)OCFS2_INVALID_SLOT) + inode_alloc_inode = ocfs2_get_system_file_inode(osb, + GLOBAL_INODE_ALLOC_SYSTEM_INODE, suballoc_slot); + else + inode_alloc_inode = ocfs2_get_system_file_inode(osb, + INODE_ALLOC_SYSTEM_INODE, suballoc_slot); if (!inode_alloc_inode) { /* the error code could be inaccurate, but we are not able to * get the correct one. */ -- 2.25.1