RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2012871 - pam_lastlog doesn't handle time related errors
Summary: pam_lastlog doesn't handle time related errors
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: pam
Version: 8.4
Hardware: All
OS: Linux
medium
high
Target Milestone: rc
: ---
Assignee: Iker Pedrosa
QA Contact: Anuj Borah
URL:
Whiteboard:
Depends On:
Blocks: 2130124
TreeView+ depends on / blocked
 
Reported: 2021-10-11 13:47 UTC by Renaud Métrich
Modified: 2023-05-16 10:57 UTC (History)
2 users (show)

Fixed In Version: pam-1.3.1-25.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2130124 (view as bug list)
Environment:
Last Closed: 2023-05-16 09:02:48 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-100088 0 None None None 2021-10-18 07:12:08 UTC
Red Hat Issue Tracker SSSD-4037 0 None None None 2021-10-21 08:17:17 UTC
Red Hat Product Errata RHBA-2023:2954 0 None None None 2023-05-16 09:03:00 UTC

Description Renaud Métrich 2021-10-11 13:47:24 UTC
Description of problem:

We got a customer report of a command going through PAM crashing for a given user.
It appears that the pam_lastlog code doesn't check the result of localtime_r(), which leads to crashing in glibc's strftime():

~~~
494 static int
495 last_login_failed(pam_handle_t *pamh, int announce, const char *user, time_t lltime)
496 {
 :
502     char the_time[256];
 :
535     if (failed) {
536         /* we want the date? */
537         if (announce & LASTLOG_DATE) {
538             struct tm *tm, tm_buf;
539             time_t lf_time;
540 
541             lf_time = utuser.ut_tv.tv_sec;
542             tm = localtime_r (&lf_time, &tm_buf);
543             strftime (the_time, sizeof (the_time),
544                 /* TRANSLATORS: "strftime options for date of last login" */
545                 _(" %a %b %e %H:%M:%S %Z %Y"), tm);
546 
547             date = the_time;
548         }
~~~

Here above, assuming "lf_time" is very large, due to a corruption in btmp database, this leads to:
1. having "tm" = NULL
2. calling strftime(..., NULL), which crashes

Hence, checking the result is mandatory.


Version-Release number of selected component (if applicable):

PAM from RHEL7 and later


How reproducible:

Don't know, need to have a corrupted "btmp" entry

Comment 1 Iker Pedrosa 2021-10-18 07:08:52 UTC
It would help us if you could ask the customer for the reproduction steps

Comment 2 Renaud Métrich 2021-10-18 07:51:50 UTC
The customer gave me his btmp database but unfortunately I couldn't reproduce with it either: PAM was detecting the corruption for me, whereas not for the customer.

Comment 3 Iker Pedrosa 2022-09-27 09:22:53 UTC
master:
    pam_lastlog: check localtime_r() return value - 40c271164dbcebfc5304d0537a42fb42e6b6803c

Comment 9 errata-xmlrpc 2023-05-16 09:02:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (pam bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2954


Note You need to log in before you can comment on or make changes to this bug.