Skip Menu |
 

Subject: gnu libc OFD lock bug affects krb5
In 1.14, we changed krb5_lock_file() to use OFD locks when possible
(ticket #8023). Unfortunately, a bug in gnu libc can cause this code to
fail on 32-bit Linux:

https://sourceware.org/bugzilla/show_bug.cgi?id=20251

This bug does not appear to be fixed. We can work around it by using
struct flock64 and fcntl64() in the appropriate circumstances.

This has come up on the Kerberos list (one thread with messages in two
different months) and in a Debian bug:

http://mailman.mit.edu/pipermail/kerberos/2015-December/021101.html
http://mailman.mit.edu/pipermail/kerberos/2016-August/021351.html
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=834035
It does not appear that there is a fcntl64() function in glibc, so I
think the workaround would have to use syscall().

There is a struct flock64 in the header files (for use with F_SETLK64 and
friends, I think). Passing this to unmodified fcntl() currently works on
32-bit Linux, but that seems like a bad workaround because it depends on
the buggy behavior. If the glibc bug is fixed in the future, glibc would
be committing an aliasing violation reading values from a struct flock64
as a struct flock. In practice it would probably just read the same zero
offsets as we want to set in the first place, though.

As an alternative, we could disable OFD locking on 32-bit Linux, and
later re-enable it with a __GLIBC_PREREQ() check when there a fixed
version. But there's a chance that the upstream bug will never be fixed
because of compatibility concerns, and it would be a shame to never get
OFD locking on 32-bit Linux.
From: ghudson@mit.edu
Subject: git commit

Work around glibc OFD lock bug on 32-bit Linux

A bug in Gnu libc causes OFD locking to fail unpredictably on 32-bit
Linux, typically leading to deadlocks. Work around this bug by using
the fcntl64 system call and struct flock64.

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=20251

https://github.com/krb5/krb5/commit/65110210b75d38908cdd84cb202cf013ccf6ed0e
Author: Greg Hudson <ghudson@mit.edu>
Commit: 65110210b75d38908cdd84cb202cf013ccf6ed0e
Branch: master
src/lib/krb5/os/lock_file.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
From: tlyu@mit.edu
Subject: git commit

Work around glibc OFD lock bug on 32-bit Linux

A bug in Gnu libc causes OFD locking to fail unpredictably on 32-bit
Linux, typically leading to deadlocks. Work around this bug by using
the fcntl64 system call and struct flock64.

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=20251

(cherry picked from commit 65110210b75d38908cdd84cb202cf013ccf6ed0e)

https://github.com/krb5/krb5/commit/33bed1ed3fd86f3d2c03bc3063b0023a82fa8041
Author: Greg Hudson <ghudson@mit.edu>
Committer: Tom Yu <tlyu@mit.edu>
Commit: 33bed1ed3fd86f3d2c03bc3063b0023a82fa8041
Branch: krb5-1.14
src/lib/krb5/os/lock_file.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
This bug was fixed in glibc by commit
06ab719d30b01da401150068054d3b8ea93dd12f on 2018-04-04. Based on the
date and git logs, release 2.28 is the first release with the fix.