Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 521C825228D for ; Wed, 22 Oct 2025 19:51:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761162709; cv=none; b=KKsvnyAzDGmvXibSe6sO9nF1nmcwvWx+DGsaC0bP2IihEiNfKJMSuXhRV58Wqq4KY7sn1TlPNbpAvZubsYsPYRUkitakVe/3eZfSwQqHHbwObRdpfMaP4eey+SPNSqcjbzveJm/Cysv0/Qw2LPyU6h8nlQllKn3KNC2f6JGXXNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761162709; c=relaxed/simple; bh=4zGAxqTFsJxA/8sBxQ2uCuOI1Zx8M5lSfmEWjnOStFQ=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=sLKYY6X5Ux2MXJ9v/vvZ3JcDT7l0116PiO3H7jFcWt0TG+djzBd15+PqUb0gflLoPQUZXF/WzcqfsZkijRG2gqA6Y2jrIPuLQhEbF/CyVvKmCIR/p6bnTdL51yJnNfpe4/V1JMSCzxv0djYC7ksdkb9uclMEomCLba9ljenN/+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jWgFib/q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jWgFib/q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E566C4CEE7; Wed, 22 Oct 2025 19:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761162708; bh=4zGAxqTFsJxA/8sBxQ2uCuOI1Zx8M5lSfmEWjnOStFQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=jWgFib/q3WOiXLicZay4n6gbZ6vEkoMAHWAf473Vk1ova7YzEMDyiszKGdZ3b6xhu 5pypVka0J3t/pPJPZ964nf3kWFHqiZUNj/1SsY6CL7kY+FYSDbLCz4ezPXWOLPIwlv 9UGBQqMjnXs2FblkShGg/PrXNHi6mEQF1K57M9w/6Dhih9dtACHr8/gh0R8ZVgraFx Rehb5RfY4+xf0hGFe8x9d5LzCvJcati8vN4W3lwuMn6XeMQkwb3H9LgmvcctJ0OG8m s6Gg0FZGBWY+9OdqGvZXG/TSfD9SuXAizMfVJABa3CA+mm/Oj/j3CMlBM83i+Y0J2L +Bu0G14P+E50A== Message-ID: Subject: Re: [RFC PATCH 1/1] lockd: prevent UAF in nlm4svc_proc_test in reexport NLM From: Jeff Layton To: Olga Kornievskaia Cc: Olga Kornievskaia , chuck.lever@oracle.com, linux-nfs@vger.kernel.org, neilb@brown.name, Dai.Ngo@oracle.com, tom@talpey.com Date: Wed, 22 Oct 2025 15:51:47 -0400 In-Reply-To: References: <20251021130506.45065-1-okorniev@redhat.com> <33ba39d2ff01eb0e52c80aa7015d27e34dde7fd2.camel@kernel.org> Autocrypt: addr=jlayton@kernel.org; prefer-encrypt=mutual; keydata=mQINBE6V0TwBEADXhJg7s8wFDwBMEvn0qyhAnzFLTOCHooMZyx7XO7dAiIhDSi7G1NPxw n8jdFUQMCR/GlpozMFlSFiZXiObE7sef9rTtM68ukUyZM4pJ9l0KjQNgDJ6Fr342Htkjxu/kFV1Wv egyjnSsFt7EGoDjdKqr1TS9syJYFjagYtvWk/UfHlW09X+jOh4vYtfX7iYSx/NfqV3W1D7EDi0PqV T2h6v8i8YqsATFPwO4nuiTmL6I40ZofxVd+9wdRI4Db8yUNA4ZSP2nqLcLtFjClYRBoJvRWvsv4lm 0OX6MYPtv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VisAbJmC0 BhZ/Ab4sph3EaiZfdXKhiQqSGdK4La3OTJOJYZphPdGgnkvDV9Pl1QZ0ijXQrVIy3zd6VCNaKYq7B AKidn5g/2Q8oio9Tf4XfdZ9dtwcB+bwDJFgvvDYaZ5bI3ln4V3EyW5i2NfXazz/GA/I/ZtbsigCFc 8ftCBKZWZmIExheXRvbiA8amxheXRvbkBrZXJuZWwub3JnPokCOAQTAQIAIgUCWe8u6AIbAwYLCQg HAwIGFQgCCQoLBBYCAwECHgECF4AACgkQAA5oQRlWghUuCg/+Lb/xGxZD2Q1oJVAE37uW308UpVSD 2tAMJUvFTdDbfe3zKlPDTuVsyNsALBGclPLagJ5ZTP+Vp2irAN9uwBuacBOTtmOdz4ZN2tdvNgozz uxp4CHBDVzAslUi2idy+xpsp47DWPxYFIRP3M8QG/aNW052LaPc0cedYxp8+9eiVUNpxF4SiU4i9J DfX/sn9XcfoVZIxMpCRE750zvJvcCUz9HojsrMQ1NFc7MFT1z3MOW2/RlzPcog7xvR5ENPH19ojRD CHqumUHRry+RF0lH00clzX/W8OrQJZtoBPXv9ahka/Vp7kEulcBJr1cH5Wz/WprhsIM7U9pse1f1g Yy9YbXtWctUz8uvDR7shsQxAhX3qO7DilMtuGo1v97I/Kx4gXQ52syh/w6EBny71CZrOgD6kJwPVV AaM1LRC28muq91WCFhs/nzHozpbzcheyGtMUI2Ao4K6mnY+3zIuXPygZMFr9KXE6fF7HzKxKuZMJO aEZCiDOq0anx6FmOzs5E6Jqdpo/mtI8beK+BE7Va6ni7YrQlnT0i3vaTVMTiCThbqsB20VrbMjlhp f8lfK1XVNbRq/R7GZ9zHESlsa35ha60yd/j3pu5hT2xyy8krV8vGhHvnJ1XRMJBAB/UYb6FyC7S+m QZIQXVeAA+smfTT0tDrisj1U5x6ZB9b3nBg65kc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2025-10-22 at 13:56 -0400, Olga Kornievskaia wrote: > On Wed, Oct 22, 2025 at 12:06=E2=80=AFPM Jeff Layton = wrote: > >=20 > > On Wed, 2025-10-22 at 11:38 -0400, Olga Kornievskaia wrote: > > > On Tue, Oct 21, 2025 at 1:45=E2=80=AFPM Jeff Layton wrote: > > > >=20 > > > > On Tue, 2025-10-21 at 13:15 -0400, Jeff Layton wrote: > > > > > On Tue, 2025-10-21 at 13:03 -0400, Jeff Layton wrote: > > > > > > On Tue, 2025-10-21 at 12:17 -0400, Olga Kornievskaia wrote: > > > > > > > On Tue, Oct 21, 2025 at 11:59=E2=80=AFAM Jeff Layton wrote: > > > > > > > >=20 > > > > > > > > On Tue, 2025-10-21 at 11:23 -0400, Olga Kornievskaia wrote: > > > > > > > > > On Tue, Oct 21, 2025 at 9:40=E2=80=AFAM Jeff Layton wrote: > > > > > > > > > >=20 > > > > > > > > > > On Tue, 2025-10-21 at 09:05 -0400, Olga Kornievskaia wr= ote: > > > > > > > > > > > When knfsd is a reexport nfs server, it nlm4svc_proc_= test() in > > > > > > > > > > > calling nlmsvc_testlock() with a lock conflict lock_r= elease_private() > > > > > > > > > > > call would end up calling nlmsvc_put_lockowner() and = then back in > > > > > > > > > > > nlm4svc_proc_test() function there will be another ca= ll to > > > > > > > > > > > nlmsvc_put_lockowner() for the same owner leading to = use-after-free > > > > > > > > > > > violation (below). > > > > > > > > > > >=20 > > > > > > > > > > > The problem only arises when the underlying file syst= em has been > > > > > > > > > > > re-exported as different paths are taken in vfs_test_= lock(). > > > > > > > > > > > When it's reexport, filp->f_op->lock is set and when = vfs_test_lock() > > > > > > > > > > > is done fl_lmops pointer is non-null. When it's regul= ar export, > > > > > > > > > > > vfs_test_lock() calls posix_test_lock() which ends up= calling > > > > > > > > > > > locks_copy_conflock() and it copies NULL into fl_lmop= s and then > > > > > > > > > > > calling into lock_release_private() does not call > > > > > > > > > > > nlmsvc_put_lockowner(). > > > > > > > > > > >=20 > > > > > > > > > > > The proposed solution is to intentionally clear fl_lm= ops pointer to > > > > > > > > > > > make sure that if there is a conflict (be it a local = file system > > > > > > > > > > > or reexport), lock_release_private() would not call > > > > > > > > > > > nlmsvc_put_lockowner(). > > > > > > > > > > >=20 > > > > > > > > > > > kernel: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > > > > > > > > > > > kernel: BUG: KASAN: slab-use-after-free in nlmsvc_put= _lockowner+0x30/0x250 [lockd] > > > > > > > > > > > kernel: Read of size 4 at addr ffff0000bf3bca10 by ta= sk lockd/6092 > > > > > > > > > > > kernel: > > > > > > > > > > > kernel: CPU: 0 UID: 0 PID: 6092 Comm: lockd Kdump: lo= aded Not tainted 6.18.0-rc1+ #23 PREEMPT(voluntary) > > > > > > > > > > > kernel: Hardware name: VMware, Inc. VMware20,1/VBSA, = BIOS VMW201.00V.24006586.BA64.2406042154 06/04/2024 > > > > > > > > > > > kernel: Call trace: > > > > > > > > > > > kernel: show_stack+0x34/0x98 (C) > > > > > > > > > > > kernel: dump_stack_lvl+0x80/0xa8 > > > > > > > > > > > kernel: print_address_description.constprop.0+0x90/0= x310 > > > > > > > > > > > kernel: print_report+0x108/0x1f8 > > > > > > > > > > > kernel: kasan_report+0xc8/0x120 > > > > > > > > > > > kernel: kasan_check_range+0xe8/0x190 > > > > > > > > > > > kernel: __kasan_check_read+0x20/0x30 > > > > > > > > > > > kernel: nlmsvc_put_lockowner+0x30/0x250 [lockd] > > > > > > > > > > > kernel: __nlm4svc_proc_test+0x2a8/0x318 [lockd] > > > > > > > > > > > kernel: nlm4svc_proc_test+0x44/0xb78 [lockd] > > > > > > > > > > > kernel: nlmsvc_dispatch+0xb0/0x200 [lockd] > > > > > > > > > > > kernel: svc_process_common+0xb20/0x17b0 [sunrpc] > > > > > > > > > > > kernel: svc_process+0x414/0x900 [sunrpc] > > > > > > > > > > > kernel: svc_handle_xprt+0x5c8/0xd60 [sunrpc] > > > > > > > > > > > kernel: svc_recv+0x1a4/0x520 [sunrpc] > > > > > > > > > > > kernel: lockd+0x154/0x298 [lockd] > > > > > > > > > > > kernel: kthread+0x2f8/0x398 > > > > > > > > > > > kernel: ret_from_fork+0x10/0x20 > > > > > > > > > > > kernel: > > > > > > > > > > > kernel: Allocated by task 6092: > > > > > > > > > > > kernel: kasan_save_stack+0x3c/0x70 > > > > > > > > > > > kernel: kasan_save_track+0x20/0x40 > > > > > > > > > > > kernel: kasan_save_alloc_info+0x40/0x58 > > > > > > > > > > > kernel: __kasan_kmalloc+0xd4/0xd8 > > > > > > > > > > > kernel: __kmalloc_cache_noprof+0x1a8/0x5c0 > > > > > > > > > > > kernel: nlmsvc_locks_init_private+0xe4/0x520 [lockd] > > > > > > > > > > > kernel: nlm4svc_retrieve_args+0x38c/0x530 [lockd] > > > > > > > > > > > kernel: __nlm4svc_proc_test+0x194/0x318 [lockd] > > > > > > > > > > > kernel: nlm4svc_proc_test+0x44/0xb78 [lockd] > > > > > > > > > > > kernel: nlmsvc_dispatch+0xb0/0x200 [lockd] > > > > > > > > > > > kernel: svc_process_common+0xb20/0x17b0 [sunrpc] > > > > > > > > > > > kernel: svc_process+0x414/0x900 [sunrpc] > > > > > > > > > > > kernel: svc_handle_xprt+0x5c8/0xd60 [sunrpc] > > > > > > > > > > > kernel: svc_recv+0x1a4/0x520 [sunrpc] > > > > > > > > > > > kernel: lockd+0x154/0x298 [lockd] > > > > > > > > > > > kernel: kthread+0x2f8/0x398 > > > > > > > > > > > kernel: ret_from_fork+0x10/0x20 > > > > > > > > > > > kernel: > > > > > > > > > > > kernel: Freed by task 6092: > > > > > > > > > > > kernel: kasan_save_stack+0x3c/0x70 > > > > > > > > > > > kernel: kasan_save_track+0x20/0x40 > > > > > > > > > > > kernel: __kasan_save_free_info+0x4c/0x80 > > > > > > > > > > > kernel: __kasan_slab_free+0x88/0xc0 > > > > > > > > > > > kernel: kfree+0x110/0x480 > > > > > > > > > > > kernel: nlmsvc_put_lockowner+0x1b4/0x250 [lockd] > > > > > > > > > > > kernel: nlmsvc_put_owner+0x18/0x30 [lockd] > > > > > > > > > > > kernel: locks_release_private+0x190/0x2a8 > > > > > > > > > > > kernel: nlmsvc_testlock+0x2e0/0x648 [lockd] > > > > > > > > > > > kernel: __nlm4svc_proc_test+0x244/0x318 [lockd] > > > > > > > > > > > kernel: nlm4svc_proc_test+0x44/0xb78 [lockd] > > > > > > > > > > > kernel: nlmsvc_dispatch+0xb0/0x200 [lockd] > > > > > > > > > > > kernel: svc_process_common+0xb20/0x17b0 [sunrpc] > > > > > > > > > > > kernel: svc_process+0x414/0x900 [sunrpc] > > > > > > > > > > > kernel: svc_handle_xprt+0x5c8/0xd60 [sunrpc] > > > > > > > > > > > kernel: svc_recv+0x1a4/0x520 [sunrpc] > > > > > > > > > > > kernel: lockd+0x154/0x298 [lockd] > > > > > > > > > > > kernel: kthread+0x2f8/0x398 > > > > > > > > > > > kernel: ret_from_fork+0x10/0x20 > > > > > > > > > > > kernel: > > > > > > > > > > > kernel: The buggy address belongs to the object at ff= ff0000bf3bca00 > > > > > > > > > > > which belongs to the cache kmalloc-64 of size= 64 > > > > > > > > > > > kernel: The buggy address is located 16 bytes inside = of > > > > > > > > > > > freed 64-byte region [ffff0000bf3bca00, ffff0= 000bf3bca40) > > > > > > > > > > > kernel: > > > > > > > > > > > kernel: The buggy address belongs to the physical pag= e: > > > > > > > > > > > kernel: page: refcount:0 mapcount:0 mapping:000000000= 0000000 index:0x0 pfn:0x13f3bc > > > > > > > > > > > kernel: flags: 0x2fffff00000000(node=3D0|zone=3D2|las= tcpupid=3D0xfffff) > > > > > > > > > > > kernel: page_type: f5(slab) > > > > > > > > > > > kernel: raw: 002fffff00000000 ffff0000800028c0 dead00= 0000000122 0000000000000000 > > > > > > > > > > > kernel: raw: 0000000000000000 0000000080200020 000000= 00f5000000 0000000000000000 > > > > > > > > > > > kernel: page dumped because: kasan: bad access detect= ed > > > > > > > > > > > kernel: > > > > > > > > > > > kernel: Memory state around the buggy address: > > > > > > > > > > > kernel: ffff0000bf3bc900: fa fb fb fb fb fb fb fb fc= fc fc fc fc fc fc fc > > > > > > > > > > > kernel: ffff0000bf3bc980: fa fb fb fb fb fb fb fb fc= fc fc fc fc fc fc fc > > > > > > > > > > > kernel: >ffff0000bf3bca00: fa fb fb fb fb fb fb fb fc= fc fc fc fc fc fc fc > > > > > > > > > > > kernel: ^ > > > > > > > > > > > kernel: ffff0000bf3bca80: fa fb fb fb fb fb fb fb fc= fc fc fc fc fc fc fc > > > > > > > > > > > kernel: ffff0000bf3bcb00: fc fc fc fc fc fc fc fc fc= fc fc fc fc fc fc fc > > > > > > > > > > > kernel: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > > > > > > > > > > > kernel: Disabling lock debugging due to kernel taint > > > > > > > > > > > kernel: AGLO: nlmsvc_put_lockowner 00000000028055fb c= ount=3D0 > > > > > > > > > > > kernel: CPU: 0 UID: 0 PID: 6092 Comm: lockd Kdump: lo= aded Tainted: G B 6.18.0-rc1+ #23 PREEMPT(voluntary) > > > > > > > > > > > kernel: Tainted: [B]=3DBAD_PAGE > > > > > > > > > > > kernel: Hardware name: VMware, Inc. VMware20,1/VBSA, = BIOS VMW201.00V.24006586.BA64.2406042154 06/04/2024 > > > > > > > > > > > kernel: Call trace: > > > > > > > > > > > kernel: show_stack+0x34/0x98 (C) > > > > > > > > > > > kernel: dump_stack_lvl+0x80/0xa8 > > > > > > > > > > > kernel: dump_stack+0x1c/0x30 > > > > > > > > > > > kernel: nlmsvc_put_lockowner+0x7c/0x250 [lockd] > > > > > > > > > > > kernel: __nlm4svc_proc_test+0x2a8/0x318 [lockd] > > > > > > > > > > > kernel: nlm4svc_proc_test+0x44/0xb78 [lockd] > > > > > > > > > > > kernel: nlmsvc_dispatch+0xb0/0x200 [lockd] > > > > > > > > > > > kernel: svc_process_common+0xb20/0x17b0 [sunrpc] > > > > > > > > > > > kernel: svc_process+0x414/0x900 [sunrpc] > > > > > > > > > > > kernel: svc_handle_xprt+0x5c8/0xd60 [sunrpc] > > > > > > > > > > > kernel: svc_recv+0x1a4/0x520 [sunrpc] > > > > > > > > > > > kernel: lockd+0x154/0x298 [lockd] > > > > > > > > > > > kernel: kthread+0x2f8/0x398 > > > > > > > > > > > kernel: ret_from_fork+0x10/0x20 > > > > > > > > > > > kernel: ------------[ cut here ]------------ > > > > > > > > > > > kernel: refcount_t: underflow; use-after-free. > > > > > > > > > > > kernel: WARNING: CPU: 0 PID: 6092 at lib/refcount.c:8= 7 refcount_dec_not_one+0x198/0x1b0 > > > > > > > > > > > kernel: Modules linked in: rpcrdma rdma_cm iw_cm ib_c= m ib_core nfsd nfsv3 nfs_acl nfs lockd grace nfs_localio netfs ext4 crc16 m= bcache jbd2 overlay uinput snd_seq_dummy snd_hrtimer qrtr rfkill vfat fat u= vcvideo snd_hda_codec_generic videobuf2_vmalloc videobuf2_memops uvc snd_hd= a_intel videobuf2_v4l2 videobuf2_common snd_intel_dspcfg videodev snd_hda_c= odec snd_hda_core mc snd_hwdep snd_seq snd_seq_device snd_pcm snd_timer snd= soundcore sg loop auth_rpcgss vsock_loopback vmw_vsock_virtio_transport_co= mmon vmw_vsock_vmci_transport vmw_vmci vsock xfs 8021q garp stp llc mrp nvm= e nvme_core nvme_keyring nvme_auth ghash_ce hkdf e1000e sr_mod cdrom vmwgfx= drm_ttm_helper ttm sunrpc dm_mirror dm_region_hash dm_log iscsi_tcp libisc= si_tcp libiscsi scsi_transport_iscsi fuse dm_multipath dm_mod nfnetlink > > > > > > > > > > > kernel: CPU: 0 UID: 0 PID: 6092 Comm: lockd Kdump: lo= aded Tainted: G B 6.18.0-rc1+ #23 PREEMPT(voluntary) > > > > > > > > > > > kernel: Tainted: [B]=3DBAD_PAGE > > > > > > > > > > > kernel: Hardware name: VMware, Inc. VMware20,1/VBSA, = BIOS VMW201.00V.24006586.BA64.2406042154 06/04/2024 > > > > > > > > > > > kernel: pstate: 61400005 (nZCv daif +PAN -UAO -TCO +D= IT -SSBS BTYPE=3D--) > > > > > > > > > > > kernel: pc : refcount_dec_not_one+0x198/0x1b0 > > > > > > > > > > > kernel: lr : refcount_dec_not_one+0x198/0x1b0 > > > > > > > > > > > kernel: sp : ffff80008a627930 > > > > > > > > > > > kernel: x29: ffff80008a627990 x28: ffff0000bf3bca00 x= 27: ffff0000ba5c7000 > > > > > > > > > > > kernel: x26: 1fffe000191eeb84 x25: 1ffff000114c4f48 x= 24: ffff0000c8f75c24 > > > > > > > > > > > kernel: x23: 0000000000000007 x22: ffff80008a627950 x= 21: 1ffff000114c4f26 > > > > > > > > > > > kernel: x20: 00000000ffffffff x19: ffff0000bf3bca10 x= 18: 0000000000000310 > > > > > > > > > > > kernel: x17: 0000000000000000 x16: 0000000000000000 x= 15: 0000000000000000 > > > > > > > > > > > kernel: x14: 0000000000000000 x13: 0000000000000001 x= 12: ffff60004fd90aa3 > > > > > > > > > > > kernel: x11: 1fffe0004fd90aa2 x10: ffff60004fd90aa2 x= 9 : dfff800000000000 > > > > > > > > > > > kernel: x8 : 00009fffb026f55e x7 : ffff00027ec85513 x= 6 : 0000000000000001 > > > > > > > > > > > kernel: x5 : ffff00027ec85510 x4 : ffff60004fd90aa3 x= 3 : ffff800080787bc0 > > > > > > > > > > > kernel: x2 : 0000000000000000 x1 : 0000000000000000 x= 0 : ffff0000a75a8000 > > > > > > > > > > > kernel: Call trace: > > > > > > > > > > > kernel: refcount_dec_not_one+0x198/0x1b0 (P) > > > > > > > > > > > kernel: refcount_dec_and_lock+0x1c/0xb8 > > > > > > > > > > > kernel: nlmsvc_put_lockowner+0x9c/0x250 [lockd] > > > > > > > > > > > kernel: __nlm4svc_proc_test+0x2a8/0x318 [lockd] > > > > > > > > > > > kernel: nlm4svc_proc_test+0x44/0xb78 [lockd] > > > > > > > > > > > kernel: nlmsvc_dispatch+0xb0/0x200 [lockd] > > > > > > > > > > > kernel: svc_process_common+0xb20/0x17b0 [sunrpc] > > > > > > > > > > > kernel: svc_process+0x414/0x900 [sunrpc] > > > > > > > > > > > kernel: svc_handle_xprt+0x5c8/0xd60 [sunrpc] > > > > > > > > > > > kernel: svc_recv+0x1a4/0x520 [sunrpc] > > > > > > > > > > > kernel: lockd+0x154/0x298 [lockd] > > > > > > > > > > > kernel: kthread+0x2f8/0x398 > > > > > > > > > > > kernel: ret_from_fork+0x10/0x20 > > > > > > > > > > > kernel: ---[ end trace 0000000000000000 ]--- > > > > > > > > > > >=20 > > > > > > > > > > > Signed-off-by: Olga Kornievskaia > > > > > > > > > > > --- > > > > > > > > > > > fs/lockd/svclock.c | 1 + > > > > > > > > > > > 1 file changed, 1 insertion(+) > > > > > > > > > > >=20 > > > > > > > > > > > diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c > > > > > > > > > > > index a31dc9588eb8..1dd0fec186de 100644 > > > > > > > > > > > --- a/fs/lockd/svclock.c > > > > > > > > > > > +++ b/fs/lockd/svclock.c > > > > > > > > > > > @@ -652,6 +652,7 @@ nlmsvc_testlock(struct svc_rqst *= rqstp, struct nlm_file *file, > > > > > > > > > > > conflock->fl.c.flc_type =3D lock->fl.c.flc_type= ; > > > > > > > > > > > conflock->fl.fl_start =3D lock->fl.fl_start; > > > > > > > > > > > conflock->fl.fl_end =3D lock->fl.fl_end; > > > > > > > > > > > + conflock->fl.fl_lmops =3D NULL; > > > > > > > > > > > locks_release_private(&lock->fl); > > > > > > > > > > >=20 > > > > > > > > > > > ret =3D nlm_lck_denied; > > > > > > > > > >=20 > > > > > > > > > > The problem sounds real, but I'm not sure I like this s= olution. > > > > > > > > >=20 > > > > > > > > > I have no claim that this solution is the best. I was con= templating on > > > > > > > > > setting this to NULL only in the case when ->f_ops->lock(= ) is NULL > > > > > > > > > thus restricting it to the path that does not call posix_= test_lock(). > > > > > > > > >=20 > > > > > > > > > > It seems like this is gaming the refcounting such that = we take a > > > > > > > > > > reference in locks_copy_conflock() but then you zero ou= t fl_lmops > > > > > > > > > > before that reference can be put. > > > > > > > > >=20 > > > > > > > > > IF lock_copy_conflock() is called then fl_lmops is alread= y NULL. > > > > > > > > >=20 > > > > > > > > > Let me try to lay out the sequence of steps for both case= s. > > > > > > > > >=20 > > > > > > > > > Reexport > > > > > > > > > 1. when nlmsvc_test_lock() is called file->f_file[mode]->= f_ops->lock > > > > > > > > > is set (fl_lmops is set too) prior to calling vfs_test_lo= ck. > > > > > > > > > 2. Because ->lock is set vfs_test_lock() calls the ->lock= function > > > > > > > > > (instead of posix_test_lock) > > > > > > > > > 3. After vfs_test_lock() fl_lmops is still set so lock_re= lease_private > > > > > > > > > is called and calls nlmscv_put_lockowner(). > > > > > > > > >=20 > > > > > > > > > Normal export > > > > > > > > > 1. when nlmsvc_test_lock() is called ->lock is not set (f= l_lmops is > > > > > > > > > set) prior to calling vfs_test_lock > > > > > > > > > 2. Because -> is not set posix_test_lock() is called whic= h will call > > > > > > > > > local_copy_conflock() which will set fl_lmops to NULL. > > > > > > > > > 3. Since fl_lmops is NULL put_lockowner isn't called. > > > > > > > > >=20 > > > > > > > > > Reexport is where I'm hazy. I'm assuming that reexported = server opened > > > > > > > > > a file and the "file" is the NFS file object and that's w= hy > > > > > > > > > file->f_file[mode]->f_ops->lock is set? So perhaps if we = take the > > > > > > > > > presence of ->lock to mean reexport, we can do as I did (= ie., set > > > > > > > > > fl_lmops to null), or maybe we can take an extra referenc= e knowing > > > > > > > > > that we'd need to put it in lock_release_private() ( -- t= his > > > > > > > > > suggestion ties to your next question). I don't see any d= ifference to > > > > > > > > > either setting it to NULL or taking an extra reference fo= r when > > > > > > > > > ->lock() is set . Both are confusing and I would say warr= ant a comment > > > > > > > > > for why we are doing it. > > > > > > > > >=20 > > > > > > > >=20 > > > > > > > > To be clear, there is nothing "special" about NFS reexport = here. The > > > > > > > > NFS client just has some limitations as to what it can do w= hen it's > > > > > > > > being (re)exported. Exporting other sorts of network or clu= stered > > > > > > > > filesystems can also be problematic for similar reasons. > > > > > > > >=20 > > > > > > > > So, we should focus on making this generically work, and no= t take - > > > > > > > > > lock being set to mean that this is an NFS reexport. > > > > > > >=20 > > > > > > > I guess it doesn't matter what kind of re-export but the fact= that if > > > > > > > ->lock is set we know that posix_test_lock and then > > > > > > > local_copy_conflock won't be called and thus there is a great= chance > > > > > > > that fl_lmops will still be set on return from vfs_test_lock(= ). > > > > > > >=20 > > > > > > > > A question: you mentioned this is a reexporting server. Are= you > > > > > > > > reexporting an NFSv4 mount as NFSv3? Or is this a v3->v3 re= export? > > > > > > >=20 > > > > > > > v3->v3 reexport. > > > > > > >=20 > > > > > > >=20 > > > > > >=20 > > > > > > Ok, looking now: > > > > > >=20 > > > > > > The test_owner in __nlm4svc_proc_test() comes from the args, wh= ich > > > > > > happens during the decode phase. That gets a valid reference to= an NLM > > > > > > lockowner in nlmsvc_locks_init_private(). Therefore, this call = in > > > > > > __nlm4svc_proc_test() seems legit. > > > > > >=20 > > > > > > nlmsvc_put_lockowner(test_owner); > > > > > >=20 > > > > > > Now, between those two gets/puts, there is the call to vfs_test= _lock() > > > > > > in nlmsvc_testlock(). That uses the same file_lock argument str= ucture > > > > > > to represent both the lock and the conflock. > > > > > >=20 > > > > > > error =3D vfs_test_lock(file->f_file[mode], &lock->fl); > > > > > >=20 > > > > > > ...so the flc_owner field at this point is still set to the (or= iginal) > > > > > > nlmclient's owner. > > > > > >=20 > > > > > > In this case, that call ends up calling down in nlmclnt_test(),= which > > > > > > ignores the flc_owner field. It also ends up overwriting the ot= her > > > > > > fields in &fl with conflock info. > > > > > >=20 > > > > > > I think the bug is actually there. Before nlmclnt_test() overwr= ites the > > > > > > fields in "fl", it needs to release the owner reference (and ze= ro out > > > > > > the owner). Would this patch fix the bug? > > > > > >=20 > > > > > > ---------------------8------------------------ > > > > > >=20 > > > > > > diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c > > > > > > index cebcc283b7ce..200309ee1a74 100644 > > > > > > --- a/fs/lockd/clntproc.c > > > > > > +++ b/fs/lockd/clntproc.c > > > > > > @@ -438,6 +438,8 @@ nlmclnt_test(struct nlm_rqst *req, struct f= ile_lock > > > > > > *fl) > > > > > > if (status < 0) > > > > > > goto out; > > > > > >=20 > > > > > > + locks_release_private(&fl); > > > > > > + > > > > > > switch (req->a_res.status) { > > > > > > case nlm_granted: > > > > > > fl->c.flc_type =3D F_UNLCK; > > > > >=20 > > > > >=20 > > > > > Sorry, I take it back. That alone won't fix it because of the poi= nter- > > > > > saving shenanigans in __nlm4svc_proc_test. We'll need to do this = a bit > > > > > more carefully, I think. > > > >=20 > > > > How about this patch? The changelog still needs some work, but I th= ink > > > > this is the most correct way to handle it: > > > >=20 > > > > -------------------------8<---------------------------- > > > >=20 > > > > [PATCH] nlm: fix handling of conflocks by NLM > > > >=20 > > > > The handling of conflocks can result in a refcount overput on the > > > > flc_owner in the case of a reexported NFSv3 fs. > > > >=20 > > > > lockd will pass down a file_lock structure in its arguments with > > > > flc_owner set to an NLM owner and a valid reference. Once that gets > > > > down to the reexported NFS client, it will ignore that field and le= ave > > > > it intact when copying in conflock info. > > > >=20 > > > > The NLM server code will then end up releasing the conflock, and th= en > > > > releasing the one from the arguments, not realizing that the lock h= as > > > > already been released. > > > >=20 > > > > The owner info in the arguments to vfs_test_lock() is there to give > > > > information about the requestor. Once nlmclnt_test() is going to co= py in > > > > the conflock info however, it needs to release the old owner. > > > >=20 > > > > Have nlmclnt_test() do call locks_release_private() after testing t= he > > > > lock to release any info that was in the old file_lock structure. > > > >=20 > > > > This creates another problem: __nlm4svc_proc_test() and > > > > __nlmsvc_proc_test() both call nlmsvc_put_lockowner() unconditional= ly on > > > > the original lockowner that it got from decoding the args. Switch t= hem > > > > both to just call locks_release_private() on &argp->lock instead, w= hich > > > > should handle the case properly where the info in argp->lock has al= ready > > > > been released. > > > >=20 > > > > With that changed, we can also eliminate the call to > > > > locks_release_private() in nlmsvc_testlock() since the callers will= now > > > > handle that. > > > >=20 > > > > Reported-by: Olga Kornievskaia > > > > Signed-off-by: Jeff Layton > > > > --- > > > > fs/lockd/clntproc.c | 3 +++ > > > > fs/lockd/svc4proc.c | 4 +--- > > > > fs/lockd/svclock.c | 1 - > > > > fs/lockd/svcproc.c | 5 +---- > > > > 4 files changed, 5 insertions(+), 8 deletions(-) > > > >=20 > > > > diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c > > > > index cebcc283b7ce..d3dd04137677 100644 > > > > --- a/fs/lockd/clntproc.c > > > > +++ b/fs/lockd/clntproc.c > > > > @@ -438,6 +438,9 @@ nlmclnt_test(struct nlm_rqst *req, struct file_= lock *fl) > > > > if (status < 0) > > > > goto out; > > > >=20 > > > > + /* Release any references held by fl before copying in conf= lock info */ > > > > + locks_release_private(fl); > > > > + > > > > switch (req->a_res.status) { > > > > case nlm_granted: > > > > fl->c.flc_type =3D F_UNLCK; > > > > diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c > > > > index 109e5caae8c7..cbfec12296a4 100644 > > > > --- a/fs/lockd/svc4proc.c > > > > +++ b/fs/lockd/svc4proc.c > > > > @@ -97,7 +97,6 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struc= t nlm_res *resp) > > > > struct nlm_args *argp =3D rqstp->rq_argp; > > > > struct nlm_host *host; > > > > struct nlm_file *file; > > > > - struct nlm_lockowner *test_owner; > > > > __be32 rc =3D rpc_success; > > > >=20 > > > > dprintk("lockd: TEST4 called\n"); > > > > @@ -107,7 +106,6 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, str= uct nlm_res *resp) > > > > if ((resp->status =3D nlm4svc_retrieve_args(rqstp, argp, &h= ost, &file))) > > > > return resp->status =3D=3D nlm_drop_reply ? rpc_dro= p_reply :rpc_success; > > > >=20 > > > > - test_owner =3D argp->lock.fl.c.flc_owner; > > > > /* Now check for conflicting locks */ > > > > resp->status =3D nlmsvc_testlock(rqstp, file, host, &argp->= lock, > > > > &resp->lock); > > > > @@ -116,7 +114,7 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, str= uct nlm_res *resp) > > > > else > > > > dprintk("lockd: TEST4 status %d\n", ntohl(re= sp->status)); > > > >=20 > > > > - nlmsvc_put_lockowner(test_owner); > > > > + locks_release_private(&argp->lock.fl); > > > > nlmsvc_release_host(host); > > > > nlm_release_file(file); > > > > return rc; > > >=20 > > > Aren't these svc4proc changes defeat the purpose of the following com= mit: > > >=20 > > > commit 184cefbe62627730c30282df12bcff9aae4816ea > > > Author: Benjamin Coddington > > > Date: Mon Jun 13 09:40:06 2022 -0400 > > >=20 > > > NLM: Defend against file_lock changes after vfs_test_lock() > > >=20 > > > Instead of trusting that struct file_lock returns completely unch= anged > > > after vfs_test_lock() when there's no conflicting lock, stash awa= y our > > > nlm_lockowner reference so we can properly release it for all cas= es. > > >=20 > > >=20 > > > This defends against another file_lock implementation overwriting= fl_owner > > > when the return type is F_UNLCK. > > >=20 > > > Not that they are the cause of the crash but I would imagine it would > > > cause a problem fixed by the patch.... > > >=20 > >=20 > > Yes, it would. I'm not sure that patch is correct. >=20 > But it seems wrong that we are now considering putting a patch that > fixes one issue (ie crash on reexport) but re-introduces another issue > (that the reverted code fixed be it not in a correct manner). >=20 I'm not sure what you mean by reintroducing another issue? What bug would be reintroduced? My main concern is that when you clear fl_lmops pointer in the way that you were suggesting, you're making assumptions about the lockowner that eventually ends up in flc_owner. Calling vfs_test_lock() may populate flc_owner with a valid reference. Maybe it ends up returning an nfsd4 lock in that field. At that point you've just leaked that reference. The right fix here is doing what Neil suggested -- adding a separate conflock argument to the ->lock operation. That would fix all of this. A lot of filesystems have ->lock operations though and they will all need to be touched. How about we just do this: Make lockd's client side respect EXPORT_OP_NOLOCKS just like the nfs4 client does. That would prevent this particular problem (albeit with a heavy hammer). That should be easy to backport to stable too. Then we do a separate patch series that adds a separate conflock parameter to the ->lock f_op and vfs_test_lock() Thoughts? --=20 Jeff Layton