Bug 24882 - login: pututline uses potentially outdated cache
Summary: login: pututline uses potentially outdated cache
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: 2.31
Assignee: Florian Weimer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-05 16:17 UTC by Florian Weimer
Modified: 2020-01-17 14:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2019-08-05 16:17:05 UTC
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.)
Comment 1 Sourceware Commits 2019-11-07 22:10:37 UTC
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
Comment 2 Florian Weimer 2019-11-08 07:44:29 UTC
Fixed in glibc 2.31.
Comment 3 Sourceware Commits 2019-11-12 16:17:29 UTC
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
Comment 4 Sourceware Commits 2020-01-17 14:02:53 UTC
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)
Comment 5 Sourceware Commits 2020-01-17 14:02:59 UTC
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)