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 2150649 - systemd, luks, gdm-autologin, pam_gnome_keyring interaction pass-through of credential
Summary: systemd, luks, gdm-autologin, pam_gnome_keyring interaction pass-through of c...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gdm
Version: CentOS Stream
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Ray Strode [halfline]
QA Contact: Michael Boisvert
URL:
Whiteboard: OtherQA
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-12-04 19:49 UTC by Leon Fauster
Modified: 2023-05-16 09:25 UTC (History)
8 users (show)

Fixed In Version: gdm-40.0-27.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-16 08:27:13 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Fix LUKS password handling (14.55 KB, patch)
2022-12-12 21:07 UTC, Ray Strode [halfline]
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-141253 0 None None None 2022-12-04 19:54:27 UTC
Red Hat Product Errata RHBA-2023:2779 0 None None None 2023-05-16 08:27:21 UTC

Description Leon Fauster 2022-12-04 19:49:37 UTC
Description of problem:

GDM with AutomaticLoginEnable=True boots into users account. 
The workstation itself has LUKS configured and systemd passes 
the manually provided credentials along to kernels keyring as
shown by "keyctl show".
I would expect that PAM passes this further to pam_gnome_keyring
to unlock the gnome keyring of the user. This works for EL9 and Fedora Linux
and seems not to work under EL8. The gnome keyring of the user remains locked.
(of course the credentials of LUKS == credentials of users gnome keyring).




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

$ rpm -q gnome-keyring-pam gdm systemd
gnome-keyring-pam-3.28.2-1.el8.x86_64
gdm-40.0-25.el8.x86_64
systemd-239-69.el8.x86_64



How reproducible:
#/etc/gdm/custom.conf
[daemon]
AutomaticLoginEnable=True
AutomaticLogin=testuser


Steps to Reproduce:
1. System with LUKS unlock request while booting
2. GDM autologin setup
3. users gnome keyring with the same pass as LUKS volume

Actual results:
gnome keyring of the user remains locked

Expected results:
gnome keyring of the user unlocked

Comment 1 Tomas Popela 2022-12-05 11:06:45 UTC
Ray, any idea?

Comment 2 Ray Strode [halfline] 2022-12-05 15:04:51 UTC
It should work. Two possibilities come to mind:

1. In RHEL-8 it's not very tolerant of typos. If the user types the wrong password first, and then the right password second, GDM assumes systemd will purge the wrong password from the kernel keyring, but it doesn't, so GDM then passes the first (wrong) password onto gnome-keyring. In RHEL 9 GDM always passes the last password, not the first password. We could backport that bug fix.

2. Maybe an selinux issue? It would be interesting to know if enforcing=0 works.

Comment 3 Leon Fauster 2022-12-07 20:34:47 UTC
Hi Ray, thanks for the explanation. I see what you mean (concatenated passwords in kernel keyring) but thats not the problem. The password in kernel's keyring is the right one. For the sake of reducing complexity I have setup four vm (cs8, cs9, f36, f37). All are working as expected only the cs8 one _not_.


CS9 says:

# journalctl -b |grep autologin
Dez 07 20:14:35 c9.localdomain gdm-autologin][1163]: gkr-pam: unable to locate daemon control file
Dez 07 20:14:35 c9.localdomain gdm-autologin][1163]: gkr-pam: stashed password to try later in open session
Dez 07 20:14:36 c9.localdomain gdm-autologin][1163]: pam_unix(gdm-autologin:session): session opened for user test(uid=1202) by (uid=0)
Dez 07 20:14:36 c9.localdomain gdm-autologin][1163]: gkr-pam: gnome-keyring-daemon started properly and unlocked keyring

and users gnome keyring IS unlocked.



CS8 says:

# journalctl -b|grep autolog
Dez 07 20:06:08 c8.localdomain gdm-autologin][1286]: pam_unix(gdm-autologin:session): session opened for user test by (uid=0)

[root@c8 ~]# ausearch -m avc
<no matches>

and users gnome keyring is NOT unlocked.

So, the same behaviour as on the workstation.

Are you sure that RHEL8 does support this login chain? 

/etc/pam.d/gdm-autologin and /etc/pam.d/system-auth are in CS8 and CS9 exactly the same also

# LANG=C authselect current 
Profile ID: sssd
Enabled features:
- without-nullok



c9 ~]# rpm -q gdm pam
gdm-40.1-18.el9.x86_64
pam-1.5.1-14.el9.x86_64


c8 ~]# rpm -q gdm pam
gdm-40.0-25.el8.x86_64
pam-1.3.1-24.el8.x86_64

Comment 4 Ray Strode [halfline] 2022-12-07 20:58:05 UTC
thanks for the clarification and detailed explanation. it *should* work by design, but it's possible a defect snuck in and that feature is generally broken at the moment (or less likely it's only broken in certain configurations).

I'm currently on medical leave but should be back on friday and will try to reproduce then and give further feedback.

Comment 7 Leon Fauster 2022-12-08 10:09:01 UTC
JFI: I took a look into vanilla source code of gdm 40.0 (CS8) and 40.1 (CS9) and indeed as you said pam_gdm.c has the mentioned loop
to iterate through multiple passwords. Just for clarification; I use just one password (with one input attempt at boot LUKS prompt). 
Get well soon.

Comment 8 Ray Strode [halfline] 2022-12-12 20:27:00 UTC
I reproduced the issue. Looking at the code, the function is this:

int•
pam_sm_authenticate (pam_handle_t  *pamh,•
                     int            flags,•
                     int            argc,•
                     const char   **argv)•
{•
#ifdef HAVE_KEYUTILS•
        int r;•
        void *cached_password = NULL;•
        key_serial_t serial;•
•
        serial = find_key_by_type_and_desc ("user", "cryptsetup", 0);•
        if (serial == 0)•
                return PAM_AUTHINFO_UNAVAIL;•
•
        r = keyctl_read_alloc (serial, &cached_password);•
        if (r < 0 || r != strlen (cached_password))•
                return PAM_AUTHINFO_UNAVAIL;•
•
        r = pam_set_item (pamh, PAM_AUTHTOK, cached_password);•
•
        free (cached_password);•
•
        if (r < 0)•
                return PAM_AUTH_ERR;•
        else•
                return PAM_SUCCESS;•
#endif•
•
        return PAM_AUTHINFO_UNAVAIL;•
}•

My first guess was then... Maybe HAVE_KEYUTILS isn't defined?

Indeed running

╎❯ objdump --disassemble /lib64/security/pam_gdm.so

shows pam_sm_authenticate is basically just returning PAM_AUTHINFO_UNAVAIL (which has value 0x9)

0000000000000700 <pam_sm_authenticate@@Base>:
 700:   f3 0f 1e fa             endbr64 
 704:   b8 09 00 00 00          mov    $0x9,%eax
 709:   c3                      retq   
 70a:   66 0f 1f 44 00 00       nopw   0x0(%rax,%rax,1)

So there must be a build system snafu. It probably got introduced when switching from autotools to meson.

Comment 9 Ray Strode [halfline] 2022-12-12 20:30:32 UTC
It seems keyutils doesn't ship a pkgconfig file:

╎❯ rpm -ql keyutils-libs-devel |grep pkgconfig
╎❯

Comment 10 Ray Strode [halfline] 2022-12-12 20:34:17 UTC
Looks like a pkgconfig file wasn't added until version 1.6 of keyutils, and we ship 1.5.10 .

We should be able to make GDM look for it a different.

Comment 11 Ray Strode [halfline] 2022-12-12 21:07:47 UTC
Created attachment 1932209 [details]
Fix LUKS password handling

This attachment adds the two fixes discussed in this bug.

Comment 12 Michael Boisvert 2022-12-12 21:15:41 UTC
Leon, would you mind testing the new package once it's available?

Comment 13 Ray Strode [halfline] 2022-12-12 21:41:33 UTC
For convenience, I've put a scratch build here: https://people.redhat.com/rstrode/2150649/

Comment 14 Leon Fauster 2022-12-12 22:59:10 UTC
(In reply to Michael Boisvert from comment #12)
> Leon, would you mind testing the new package once it's available?

A quick test shows that the keyring of the user gets unlocked.
Also, mistyping at the LUKS prompt and enter the correct one afterwards works.

Looks great! Thanks!

Comment 15 Michael Boisvert 2022-12-13 13:15:59 UTC
(In reply to Leon Fauster from comment #14)
> (In reply to Michael Boisvert from comment #12)
> > Leon, would you mind testing the new package once it's available?
> 
> A quick test shows that the keyring of the user gets unlocked.
> Also, mistyping at the LUKS prompt and enter the correct one afterwards
> works.
> 
> Looks great! Thanks!

Thank you for your timely testing!

Comment 23 Leon Fauster 2022-12-22 12:01:35 UTC
I am still using this patched gdm version and noticed two things. Albeit not sure how related it is:

## 1 ##

SElinux alerts since then. A lot of entries looking like:

# ausearch -m avc |tail -5
----
time->Thu Dec 22 12:34:49 2022
type=PROCTITLE msg=audit(1671708889.353:54): proctitle=67646D2D73657373696F6E2D776F726B6572205B70616D2F67646D2D6175746F6C6F67696E5D
type=SYSCALL msg=audit(1671708889.353:54): arch=c000003e syscall=250 success=yes exit=23 a0=b a1=201e571c a2=55d1e1897d20 a3=17 items=0 ppid=2897 pid=2909 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="gdm-session-wor" exe="/usr/libexec/gdm-session-worker" subj=system_u:system_r:xdm_t:s0-s0:c0.c1023 key=(null)
type=AVC msg=audit(1671708889.353:54): avc:  denied  { read } for  pid=2909 comm="gdm-session-wor" scontext=system_u:system_r:xdm_t:s0-s0:c0.c1023 tcontext=system_u:system_r:kernel_t:s0 tclass=key permissive=0

# rpm -qf /usr/libexec/gdm-session-worker
gdm-40.0-27.el8.x86_64


## 2 ##

Setup/gnome keyring

My local setup has a user/password pair that uses a password different to the luks one. Just the keyring of the user has the password manually changed to the LUKS one. Booting up, autologin and keyring unlock worked as said. 
Off and on I switch the user session to work with a different user/gnome-session, and then back the "autologin" user. This is all done without rebooting. 

Now, I noticed that the password of the (autologin) user's keyring is set to the account password somewhow back again! Two questions raises up; does the PAM layer resets the keyring password automagically? And how can this happen without the original LUKS password to change it back to the local system password? Because the content of the gnome keyring are still there and accessible. Is such setup with different passwords supported?

Its weird, I hope that its understandable.

Comment 25 errata-xmlrpc 2023-05-16 08:27:13 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 (gdm 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:2779


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