Path: csiph.com!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod From: Ben Hutchings Newsgroups: linux.debian.bugs.dist,linux.debian.kernel Subject: Bug#1128861: [PATCH] lockd: fix TEST handling when not all permissions are available. Date: Wed, 25 Mar 2026 21:40:01 +0100 Message-ID: References: X-Original-To: NeilBrown , 1128861@bugs.debian.org, Chuck Lever X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Wed Mar 25 20:31:08 2026 Old-Return-Path: X-Spam-Flag: NO X-Spam-Score: -1.65 Reply-To: Ben Hutchings , 1128861@bugs.debian.org Resent-To: debian-bugs-dist@lists.debian.org Resent-Cc: debian-kernel@lists.debian.org X-Debian-Pr-Message: followup 1128861 X-Debian-Pr-Package: src:linux X-Debian-Pr-Keywords: upstream X-Debian-Pr-Source: linux Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-StOfTySkQjzSGJ9fd77x" User-Agent: Evolution 3.56.2-9 MIME-Version: 1.0 X-Sa-Exim-Connect-IP: 2a02:1810:1d14:e000:db6f:81d2:6624:c91c X-Sa-Exim-Mail-From: ben@decadent.org.uk X-Sa-Exim-Scanned: No (on maynard); SAEximRunCond expanded to false X-Debian-Message: from BTS X-Mailing-List: archive/latest/1960636 List-ID: List-URL: Approved: robomod@news.nic.it Lines: 94 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: Jeff Layton , Thorsten Leemhuis , Tj , linux-nfs@vger.kernel.org, Olga Kornievskaia , stable@vger.kernel.org X-Original-Date: Wed, 25 Mar 2026 21:29:09 +0100 X-Original-Message-ID: X-Original-References: , <177266540127.7472.3460090956713656639@noble.neil.brown.name> , <6ba41798-9c69-44f5-9a4e-09336c75a4b9@leemhuis.info> , , <177434721528.7102.13514118512738778346@noble.neil.brown.name> , <177187492815.425331.14320091315652332093.reportbug@nimble> <177442248735.2237155.773724155681455344@noble.neil.brown.name> <177187492815.425331.14320091315652332093.reportbug@nimble> <177442248735.2237155.773724155681455344@noble.neil.brown.name> Xref: csiph.com linux.debian.bugs.dist:1287331 linux.debian.kernel:91799 --=-StOfTySkQjzSGJ9fd77x Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2026-03-25 at 18:08 +1100, NeilBrown wrote: > On Wed, 25 Mar 2026, Chuck Lever wrote: > >=20 > > On Tue, Mar 24, 2026, at 6:13 AM, NeilBrown wrote: > > > From: NeilBrown > > >=20 > > > The F_GETLK fcntl can work with either read access or write access or > > > both. It can query F_RDLCK and F_WRLCK locks in either case. > > >=20 > > > However lockd currently treats F_GETLK similar to F_SETLK in that rea= d > > > access is required to query an F_RDLCK lock and write access is requi= red > > > to query a F_WRLCK lock. > > >=20 > > > This is wrong and can cause problem - e.g. when qemu accesses a > > > read-only (e.g. iso) filesystem image over NFS (though why it queries > > > if it can get a write lock - I don't know. But it does, and this wor= ks > > > with local filesystems). > > >=20 > > > So we need TEST requests to be handled differently. To do this: > > >=20 > > > - change nlm_do_fopen() to accept O_RDWR as a mode and in that case > > > succeed if either a O_RDONLY or O_WRONLY file can be opened. > > > - change nlm_lookup_file() to accept a mode argument from caller, > > > instead of deducing base on lock time, and pass that on to nlm_do_f= open() > > > - change nlm4svc_retrieve_args() and nlmsvc_retrieve_args() to detect > > > TEST requests and pass O_RDWR as a mode to nlm_lookup_file, passing > > > the same mode as before for other requests. Also set > > > lock->fl.c.flc_file to whichever file is available for TEST reques= ts. > > > - change nlmsvc_testlock() to also not calculate the mode, but to use > > > whenever was stored in lock->fl.c.flc_file. > > >=20 > > > Reported-by: Tj > > > Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D1128861 > > > Fixes: 7f024fcd5c97 ("Keep read and write fds with each nlm_file") > > > Signed-off-by: NeilBrown > >=20 > > Hi Neil, which kernels should this fix apply to? > >=20 >=20 > v6.13 and later. So linux-6.18.y and linux-6.19.y 6.12.y is also affected since commit 4cc9b9f2bf4d was backported there (triggering this bug report). Ben. >=20 > The Fixes: tag is actually wrong. This bug has been present forever. > However a different bug that=20 > Commit: 4cc9b9f2bf4d ("nfsd: refine and rename NFSD_MAY_LOCK") > fixed was hiding the bug. >=20 > So it should probably be marked > Fixes: 4cc9b9f2bf4d ("nfsd: refine and rename NFSD_MAY_LOCK") > with an explanation. >=20 > NeilBrown --=20 Ben Hutchings Theory and practice are closer in theory than in practice - John Levine --=-StOfTySkQjzSGJ9fd77x Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEErCspvTSmr92z9o8157/I7JWGEQkFAmnERZYACgkQ57/I7JWG EQkcsA/+P9OPKkweOPNqOeCWouseIy/CyJKqNhLGjkCMsT/c+K3UtHKmioGin2Zu 2qKNGyPkfvdGfhlMZGcjE/0ZA6N/HD24fnNTH0p0xzcIE3U6OJ+lcaqbdOvs45y8 wcLF/v8B4KD3HwzcxqIEty/yJjuzzvgii7xOHzeah59yhY2sElxYyZrNrxDaQ8hZ SeTGvVWWJEgm3zYTykG5Yu0pdCWgj2rkbJFBebRWw41fnHBbEw28zINjQRs5usaA 40ZGQkM1F0QSOABWzuakN50XJfvs/XfKgiRAUzifeH0qaUXE2mC4Zdx+GGSwTRb8 8l/ASuz3at8lDSNglY+E956o8zekI0TUN3jrv5ViO2dwvBfh3zIYXNHytroJNjBV ZiL+XpW94rWOSTvpSQd0a6W/2jbyiIy2brdqj71BbrbdpPcuoaEVOFodKqbcqmsd uBm6vApisOzLX5jwOUgfnYBdpj4XQh3gGgbTm6k3khLt0Ok6I7fWCJb3gHEHHFGU UfD185p1E1YdPXFYj8aWkKdO6RJnOIQKZ4w+s9PJDFl9h8wifCIqMOGlMIVbrWSN ZdU1Xs/lT6xH6NDY8z+iIJkrE6LBjO2+rS4GjqXk8I4FoFgP5BCP7TlZKnBwTczc XvNJ5reVXnDaFOcO9v420KZ8u2BbYjzk6f0jPe1omz9WJ9YJ82M= =Dg/J -----END PGP SIGNATURE----- --=-StOfTySkQjzSGJ9fd77x--