Summary: | pututline_file() corrupts utmp file when internal_getut_r() returns -1 due to LOCK_FILE timeout. | ||
---|---|---|---|
Product: | glibc | Reporter: | Ryan S. Arnold <rsa> |
Component: | libc | Assignee: | Ulrich Drepper <drepper.fsp> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | fweimer, garyhade, glibc-bugs, suzuki |
Priority: | P2 | Flags: | fweimer:
security-
|
Version: | unspecified | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: |
pututline() currupts the utmp file on fcntl() lock time out
Patch for the pututline() for fcntl() lock time out |
Description
Ryan S. Arnold
2008-06-11 21:19:32 UTC
Created attachment 2800 [details]
pututline() currupts the utmp file on fcntl() lock time out
In some scenarios pututline (3) may corrupt the utmp like with heavy system
load environment and using pututline frequently.
The failure analysis is in login/utmp_file.c internal_getut_r() function is not
retaining the lock error because of fcntl() failure so, pututline() is failing
to differentiate between utline not exists and utmp lock time out. As its
returning -1 in both cases. In both cases it treats as utline not found it
appends at the last.
Copy /var/run/utmp to current directory where you are executing tests.
who o/p Before Executing tests
==============================
$ who ./utmp
chill tty1 May 15 18:53
halesh pts/2 Jun 20 12:28
halesh pts/4 Jun 20 13:00
who o/p After executing tests
=============================
$ who ./utmp
chill tty1 May 15 18:53
halesh pts/2 Jun 20 12:28
halesh pts/4 Jun 20 13:00
chill tty1 May 15 18:53 <- ** THE FIRST LOGIN HAS BEEN APPENDED.
**utmp got currupted becuase of adding firstlogin entry again at the last
instead of replacing it.
If you are not able to reproduce please increase the LOOP macro in testcase.
Created attachment 2802 [details]
Patch for the pututline() for fcntl() lock time out
After applaying the attached patch..
who o/p Before Executing tests
==============================
$who ./utmp
chill tty1 May 15 18:53
halesh pts/4 Jun 20 13:00 (43.88.101.161)
who o/p After executing tests
=============================
$who ./utmp
chill tty1 May 15 18:53
halesh pts/4 Jun 20 13:00
I have tested regression tests for adding new entry and replacing entries using
pututline() with patch and wroking fine.
(In reply to comment #2) > Created an attachment (id=2802) > Patch for the pututline() for fcntl() lock time out > > > After applaying the attached patch.. > > who o/p Before Executing tests > ============================== > $who ./utmp > chill tty1 May 15 18:53 > halesh pts/4 Jun 20 13:00 (43.88.101.161) > > > who o/p After executing tests > ============================= > $who ./utmp > chill tty1 May 15 18:53 > halesh pts/4 Jun 20 13:00 Last part of who(1) o/p of second entry got missed while copying in text box... who o/p After Executing tests ============================== $who ./utmp chill tty1 May 15 18:53 halesh pts/4 Jun 20 13:00 (43.88.101.161) > > I have tested regression tests for adding new entry and replacing entries using > pututline() with patch and wroking fine. I checked in a slightly modified patch. Thanks. |