Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp724544pxb; Fri, 21 Jan 2022 01:35:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCjcNZn/tbxw5O/oeKZsaW7xUAeVGx964+WMTp5wcamyPCHcitfCv8UbsXR+F9QEsn8YqY X-Received: by 2002:aa7:9188:0:b0:4be:3d3a:c6d0 with SMTP id x8-20020aa79188000000b004be3d3ac6d0mr3226031pfa.4.1642757730954; Fri, 21 Jan 2022 01:35:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642757730; cv=none; d=google.com; s=arc-20160816; b=F4zEUA5Zm+f/19Pch3KBqG65sdYRcm1SGU69hsTJICAP7XF15jR5X848oDGfI8Boqz wtI2O8ghaY/F89CX+bQWkrrCFISfp/jmmslPbk3OzaT0YgM1P4DlaJwKHtA5wP+s4xgd 2Q0CppFWP110NlUj7N/o2lLK5fgiVZjBLIBQRWgFhvrsYG5+rsozHL2uVATPs2n5iZ8A wDAQBQ8ik//jziDGdBnBlKZTLEy7VECGrr2Y/ucZwe+8AzvialjdaXngdPO6X1fwUKT5 6fglvf81tO8Xe1gOyMINPEPIz3TMnNugwvU5IKY66xyM3HIHLJO1PQUYNBvGygEapDEA V8rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=MmPaJ7SQ/ZgnQfvgzMR+1YqgblqtTeDgmqRRh+vB2+g=; b=uVNiDHxTfi4Obq1vasLyhhcUL2gJkCsjjIZfVEhQFKecU/hi2/p2Hmg+wBm6wWo9Lq P2QxTjcAJnjRxiOz12sGcAzB3VO0lz1cZP4KrpnyYBwGAaEWbBJcM5KWkRsHuzxYQwTK uGMj66R7q8MSeUsm9/tE1rSgblRUKN50KpQhdun9a5uaIhoK3lZ4JRnz6UF4GtKI02OR 2WgxI4Dpvk+2wxM4VqQbys4++6LNobOaUAqbt78o9SvRkabh78SwvFkmxBT53sahbGSg FQJz1Ol65XSqOEHEbAknPti9Q0izaE0DnjfPpcBwlm0agGDu0hPQXUgl6NAeSNz0btnk 7lDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=KxO4E+xK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si4814377pgv.244.2022.01.21.01.35.17; Fri, 21 Jan 2022 01:35:30 -0800 (PST) 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=@fieldses.org header.s=default header.b=KxO4E+xK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349293AbiARWAT (ORCPT + 99 others); Tue, 18 Jan 2022 17:00:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234970AbiARWAT (ORCPT ); Tue, 18 Jan 2022 17:00:19 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D837DC061574 for ; Tue, 18 Jan 2022 14:00:18 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id F22986C0C; Tue, 18 Jan 2022 17:00:16 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org F22986C0C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1642543216; bh=MmPaJ7SQ/ZgnQfvgzMR+1YqgblqtTeDgmqRRh+vB2+g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KxO4E+xKAkWLKfofbLKYVIlWuNhnXy07/LqDId2t2pklLGb1aaWRsF0WHLaZpzQIw THDWEB6+J0Ul9wvqCT7pOsJXt/xNvZFj77qIcF44fyG98YzX6I2NtEoSLx89iHCeso SFrTDSIsL8PGwJ+s8g3EzpXzjU0a1F7OzoHQ4Ap4= Date: Tue, 18 Jan 2022 17:00:16 -0500 From: Bruce Fields To: Jonathan Woithe Cc: Chuck Lever III , Linux NFS Mailing List Subject: [PATCH 1/2] lockd: fix server crash on reboot of client holding lock Message-ID: <20220118220016.GB16108@fieldses.org> References: <20220114103901.GA22009@marvin.atrad.com.au> <20220115081420.GB8808@marvin.atrad.com.au> <927EED04-840E-4DA6-B2B1-B604A7577B4E@oracle.com> <20220115212336.GB30050@marvin.atrad.com.au> <20220116220627.GA19813@marvin.atrad.com.au> <1E71316C-9EE8-4C71-ADA1-71E2910CA070@oracle.com> <20220117074430.GA22026@marvin.atrad.com.au> <20220117220851.GA8494@marvin.atrad.com.au> <20220117221156.GB3090@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220117221156.GB3090@fieldses.org> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: "J. Bruce Fields" I thought I was iterating over the array when actually the iteration is over the values contained in the array? Ugh, keep it simple. Symptoms were a null deference in vfs_lock_file() when an NFSv3 client that previously held a lock came back up and sent a notify. Reported-by: Jonathan Woithe Fixes: 7f024fcd5c97 ("Keep read and write fds with each nlm_file") Signed-off-by: J. Bruce Fields --- fs/lockd/svcsubs.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index cb3a7512c33e..54c2e42130ca 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -179,19 +179,20 @@ nlm_delete_file(struct nlm_file *file) static int nlm_unlock_files(struct nlm_file *file) { struct file_lock lock; - struct file *f; lock.fl_type = F_UNLCK; lock.fl_start = 0; lock.fl_end = OFFSET_MAX; - for (f = file->f_file[0]; f <= file->f_file[1]; f++) { - if (f && vfs_lock_file(f, F_SETLK, &lock, NULL) < 0) { - pr_warn("lockd: unlock failure in %s:%d\n", - __FILE__, __LINE__); - return 1; - } - } + if (file->f_file[O_RDONLY] && + vfs_lock_file(file->f_file[O_RDONLY], F_SETLK, &lock, NULL)) + goto out_err; + if (file->f_file[O_WRONLY] && + vfs_lock_file(file->f_file[O_WRONLY], F_SETLK, &lock, NULL)) + goto out_err; return 0; +out_err: + pr_warn("lockd: unlock failure in %s:%d\n", __FILE__, __LINE__); + return 1; } /* -- 2.34.1