Another process may have overwritten the cached entry, so pututline needs to revalidate the cache after acquiring the write lock. (The cache is still useful for finding the right file position.)
The master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=be6b16d975683e6cca57852cd4cfe715b2a9d8b1 commit be6b16d975683e6cca57852cd4cfe715b2a9d8b1 Author: Florian Weimer <fweimer@redhat.com> Date: Thu Nov 7 18:15:18 2019 +0100 login: Acquire write lock early in pututline [BZ #24882] It has been reported that due to lack of fairness in POSIX file locking, the current reader-to-writer lock upgrade can result in lack of forward progress. Acquiring the write lock directly hopefully avoids this issue if there are only writers. This also fixes bug 24882 due to the cache revalidation in __libc_pututline. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Change-Id: I57e31ae30719e609a53505a0924dda101d46372e
Fixed in glibc 2.31.
The master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=76a7c103eb9060f9e3ba01d073ae4621a17d8b46 commit 76a7c103eb9060f9e3ba01d073ae4621a17d8b46 Author: Florian Weimer <fweimer@redhat.com> Date: Tue Nov 12 12:02:57 2019 +0100 login: Introduce matches_last_entry to utmp processing This simplifies internal_getut_nolock and fixes a regression, introduced in commit be6b16d975683e6cca57852cd4cfe715b2a9d8b1 ("login: Acquire write lock early in pututline [BZ #24882]") in pututxline because __utmp_equal can only compare process-related utmp entries. Fixes: be6b16d975683e6cca57852cd4cfe715b2a9d8b1 Change-Id: Ib8a85002f7f87ee41590846d16d7e52bdb82f5a5
The release/2.30/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=83f793e6a63c4bdd1b2f39618040a8317562a1f7 commit 83f793e6a63c4bdd1b2f39618040a8317562a1f7 Author: Florian Weimer <fweimer@redhat.com> Date: Thu Nov 7 18:15:18 2019 +0100 login: Acquire write lock early in pututline [BZ #24882] It has been reported that due to lack of fairness in POSIX file locking, the current reader-to-writer lock upgrade can result in lack of forward progress. Acquiring the write lock directly hopefully avoids this issue if there are only writers. This also fixes bug 24882 due to the cache revalidation in __libc_pututline. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Change-Id: I57e31ae30719e609a53505a0924dda101d46372e (cherry picked from commit be6b16d975683e6cca57852cd4cfe715b2a9d8b1)
The release/2.30/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dfa1f9fe0df169cd099a6f5cc0c43ccdd73590d0 commit dfa1f9fe0df169cd099a6f5cc0c43ccdd73590d0 Author: Florian Weimer <fweimer@redhat.com> Date: Tue Nov 12 12:02:57 2019 +0100 login: Introduce matches_last_entry to utmp processing This simplifies internal_getut_nolock and fixes a regression, introduced in commit be6b16d975683e6cca57852cd4cfe715b2a9d8b1 ("login: Acquire write lock early in pututline [BZ #24882]") in pututxline because __utmp_equal can only compare process-related utmp entries. Fixes: be6b16d975683e6cca57852cd4cfe715b2a9d8b1 Change-Id: Ib8a85002f7f87ee41590846d16d7e52bdb82f5a5 (cherry picked from commit 76a7c103eb9060f9e3ba01d073ae4621a17d8b46)