logind session ID not used due to race condition

Bug #1364725 reported by Ricardo Salveti
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Light Display Manager
Fix Released
High
Robert Ancell
1.10
Fix Released
High
Robert Ancell
lightdm (Ubuntu)
Fix Released
Critical
Robert Ancell
Trusty
Fix Released
High
Robert Ancell
Utopic
Fix Released
Critical
Robert Ancell

Bug Description

[Impact]
Sometimes a session will fail to get the logind session ID to pass back to the LightDM daemon. This appears to be due to a race using the D-Bus method org.freedesktop.login1.Manager.GetSessionByPID instead of getting the environment variable XDG_SESSION_ID as set in PAM.

This bug was detected by a bug in LightDM 1.11.7 where the daemon would attempt to read both a logind and ConsoleKit ID when this D-Bus call failed.

The solution is to use the XDG_SESSION_ID environment variable and not GetSessionByPID() and to fix the passing of the session id(s) from the session to the daemon to be unambiguous.

[Test Case]
Check the LightDM log always contains lines like:
[+0.78s] DEBUG: Activating login1 session c1
for each session.

[Regression Potential]
Change is non-trivial and could cause other bugs. Regression tests confirm existing test cases work.

Changed in lightdm (Ubuntu):
importance: Undecided → High
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

root@ubuntu-phablet:/var/log/lightdm# cat lightdm.log
[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
[+0.00s] DEBUG: Starting Light Display Manager 1.11.7, UID=0 PID=1323
[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/52-ubuntu-touch.conf
[+0.00s] DEBUG: Loading configuration dirs from /custom/xdg/data/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf.d/90-phablet.conf
[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
[+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager
[+0.01s] DEBUG: Registered seat module xlocal
[+0.01s] DEBUG: Registered seat module xremote
[+0.01s] DEBUG: Registered seat module unity
[+0.06s] DEBUG: Monitoring logind for seats
[+0.06s] DEBUG: New seat added from logind: seat0
[+0.06s] DEBUG: Seat seat0: Starting
[+0.07s] DEBUG: Using VT 1
[+0.07s] DEBUG: DisplayServer: Logging to /var/log/lightdm/unity-system-compositor.log
[+0.07s] DEBUG: Launching process 1369: /usr/share/ubuntu-touch-session/usc-wrapper --file '/run/mir_socket' --from-dm-fd 10 --to-dm-fd 13 --vt 1
[+0.07s] DEBUG: DisplayServer: Waiting for system compositor for 60s
[+0.07s] DEBUG: Acquired bus name org.freedesktop.DisplayManager
[+0.07s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0
[+0.30s] DEBUG: Loading users from org.freedesktop.Accounts
[+0.30s] DEBUG: User /org/freedesktop/Accounts/User32011 added
[+1.43s] DEBUG: DisplayServer: READY
[+1.43s] DEBUG: DisplayServer: Compositor ready
[+1.43s] DEBUG: Seat seat0: Compositor ready
[+1.43s] DEBUG: Seat seat0: Creating user session
[+1.43s] DEBUG: Seat seat0: Creating display server of type mir
[+1.44s] DEBUG: Seat seat0: Display server ready, starting session authentication
[+1.44s] DEBUG: Session pid=1623: Started with service 'lightdm-autologin', username 'phablet'
[+1.50s] DEBUG: Session pid=1623: Authentication complete with return value 0: Success
[+1.50s] DEBUG: Seat seat0: Session authenticated, running command
[+1.50s] DEBUG: Registering session with bus path /org/freedesktop/DisplayManager/Session0
[+1.51s] DEBUG: Session pid=1623: Running command /usr/sbin/ubuntu-touch-lightdm-session ubuntu-touch-session
[+1.51s] DEBUG: Creating shared data directory /var/lib/lightdm-data/phablet
[+1.51s] DEBUG: Session pid=1623: Logging to .xsession-errors
root@ubuntu-phablet:/var/log/lightdm# cat unity-system-compositor.log
Warning: ignoring unrecognised arguments: --vt 1
GL_VENDOR = ARM
GL_RENDERER = Mali-400 MP
GL_VERSION = OpenGL ES 2.0
dm_connection_start
WARNING: QApplication was not created in the main() thread.
initialized brightness parameters
Opening session session-0

Revision history for this message
Ricardo Salveti (rsalveti) wrote :
Download full text (5.3 KiB)

And the diff between 11.6 and 11.7:
root@ubuntu-phablet:/var/log/lightdm# diff -Naur lightdm.log.old lightdm.log
--- lightdm.log.old 2014-09-03 02:57:18.492387008 +0000
+++ lightdm.log 2014-09-03 02:57:38.370000001 +0000
@@ -1,5 +1,5 @@
 [+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
-[+0.00s] DEBUG: Starting Light Display Manager 1.11.6, UID=0 PID=1309
+[+0.00s] DEBUG: Starting Light Display Manager 1.11.7, UID=0 PID=1323
 [+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
 [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf
 [+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf
@@ -10,36 +10,30 @@
 [+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf.d/90-phablet.conf
 [+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
 [+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager
-[+0.00s] DEBUG: Registered seat module xlocal
-[+0.00s] DEBUG: Registered seat module xremote
-[+0.00s] DEBUG: Registered seat module unity
-[+0.00s] DEBUG: Registered seat module surfaceflinger
-[+0.04s] DEBUG: Adding default seat
-[+0.04s] DEBUG: Seat: Starting
-[+0.05s] DEBUG: Using VT 1
-[+0.05s] DEBUG: DisplayServer: Logging to /var/log/lightdm/unity-system-compositor.log
-[+0.06s] DEBUG: Launching process 1355: /usr/share/ubuntu-touch-session/usc-wrapper --file '/run/mir_socket' --from-dm-fd 10 --to-dm-fd 13 --vt 1
-[+0.06s] DEBUG: DisplayServer: Waiting for system compositor for 60s
-[+0.06s] DEBUG: Acquired bus name org.freedesktop.DisplayManager
-[+0.06s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0
-[+0.27s] DEBUG: Loading users from org.freedesktop.Accounts
-[+0.27s] DEBUG: User /org/freedesktop/Accounts/User32011 added
-[+1.83s] DEBUG: DisplayServer: READY
-[+1.83s] DEBUG: DisplayServer: Compositor ready
-[+1.83s] DEBUG: Seat: Compositor ready
-[+1.83s] DEBUG: Seat: Creating user session
-[+1.83s] DEBUG: Seat: Creating display server of type mir
-[+1.85s] DEBUG: Seat: Display server ready, starting session authentication
-[+1.85s] DEBUG: Session pid=1685: Started with service 'lightdm-autologin', username 'phablet'
-[+1.94s] DEBUG: Session pid=1685: Authentication complete with return value 0: Success
-[+1.94s] DEBUG: Seat: Session authenticated, running command
-[+1.94s] DEBUG: Registering session with bus path /org/freedesktop/DisplayManager/Session0
-[+1.95s] DEBUG: Session pid=1685: Running command /usr/sbin/ubuntu-touch-lightdm-session ubuntu-touch-session
-[+1.95s] DEBUG: Creating shared data directory /var/lib/lightdm-data/phablet
-[+1.95s] DEBUG: Session pid=1685: Logging to .xsession-errors
-[+2.00s] DEBUG: Seat: Switching to Mir session session-0
-[+2.00s] DEBUG: Activating login1 session /org/freedesktop/login1/session/c2
-[+2.85s] DEBUG: User /org/freedesktop/Accounts/User32011 changed
-[+7.06s] DEBUG: User /org/freedesktop/Accounts/User0 added
-[+58.92s] DEBUG: User /org/freedesktop/Accounts/User32011 changed
-[+110.40s] DEBUG: User /org/freedesktop/Accounts/User32011 changed
+[+0.01s] DEBUG: Registered seat module xlocal
+[+0.01s] DEBUG: Re...

Read more...

Revision history for this message
Ricardo Salveti (rsalveti) wrote :
Revision history for this message
Ricardo Salveti (rsalveti) wrote :
Revision history for this message
Ricardo Salveti (rsalveti) wrote :
Revision history for this message
Ricardo Salveti (rsalveti) wrote :
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

root@ubuntu-phablet:~# lightdm --show-config
   [SeatDefaults]
A greeter-wrapper=/usr/lib/lightdm/lightdm-greeter-session
B guest-wrapper=/usr/lib/lightdm/lightdm-guest-session
C xserver-command=X -core
D type=unity
D user-session=ubuntu-touch
D session-wrapper=/usr/sbin/ubuntu-touch-lightdm-session
D unity-compositor-command=/usr/share/ubuntu-touch-session/usc-wrapper
E autologin-user=phablet

   [LightDM]
D minimum-vt=1

Sources:
A /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf
B /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf
C /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf
D /usr/share/lightdm/lightdm.conf.d/52-ubuntu-touch.conf
E /etc/lightdm/lightdm.conf.d/90-phablet.conf

description: updated
Revision history for this message
Ricardo Salveti (rsalveti) wrote :
Changed in lightdm (Ubuntu):
assignee: nobody → Robert Ancell (robert-ancell)
importance: High → Critical
status: New → Triaged
Changed in lightdm:
status: New → Triaged
importance: Undecided → High
assignee: nobody → Robert Ancell (robert-ancell)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lightdm - 1.11.8-0ubuntu1

---------------
lightdm (1.11.8-0ubuntu1) utopic; urgency=medium

  * New upstream release:
    - Rework logind code that gets session ID. The previous method was racy
      and a change in lightdm 1.11.7 led to a lockup when this race occurred.
      (LP: #1364725)
    - Handle CanGraphical property on logind seats
 -- Robert Ancell <email address hidden> Wed, 03 Sep 2014 17:26:36 +1200

Changed in lightdm (Ubuntu):
status: Triaged → Fix Released
Changed in lightdm:
milestone: none → 1.11.8
status: Triaged → Fix Released
summary: - Krillin fails to display spinner/unity8 after upgrade to 1.11.7-0ubuntu1
+ logind session ID not used due to race condition
Changed in lightdm (Ubuntu Trusty):
importance: Undecided → Medium
status: New → In Progress
assignee: nobody → Robert Ancell (robert-ancell)
importance: Medium → High
description: updated
description: updated
description: updated
Revision history for this message
Robert Ancell (robert-ancell) wrote :

r2028 is the revision that caused the crash if the race condition occurred.

Revision history for this message
Mathew Hodson (mhodson) wrote :

https://launchpad.net/ubuntu/+source/lightdm/1.10.3-0ubuntu2 is available in trusty-proposed.

---------------
lightdm (1.10.3-0ubuntu2) trusty; urgency=medium

  * Refresh patches

 -- Robert Ancell <email address hidden> Fri, 10 Oct 2014 21:24:51 +1300

lightdm (1.10.3-0ubuntu1) trusty; urgency=medium

  * New upstream release:
    - Fix crash when having configuration keys defined in multiple places
      (LP: #1377373)
    - Allow user switching in multi-seat until bug stopping greeter showing on
      logout is fixed
    - Don't access .dmrc files until information from these files is required
      (LP: #1370852)
    - Do timed autologin each time you are returned to the greeter
      (LP: #1302491)

 -- Robert Ancell <email address hidden> Thu, 09 Oct 2014 09:01:21 +1300

lightdm (1.10.2-0ubuntu1) trusty; urgency=medium

  * New upstream release:
    - Use logind to provide the list of seats to use. This is disabled unless
      logind-load-seats (in [LightDM] section) is set to true. This is the
      default behaviour in lightdm 1.12. (LP: #1190581)
    - Fix crash if running script hooks with non-X display servers.
      (LP: #1305006)
    - Add a seat option 'allow-user-switching' that can disable all user
      switching for that seat. (LP: #1350357)
    - Make PAM services configurable. (LP: #1348251)
    - Add liblightdm method to get user UID. (LP: #1370327)
    - Add a new session type 'mir-container' that allows the session to run
      inside a custom system compositor. (LP: #1359332)
    - Add --show-config option that shows combined configuration.
    - Use XDG_SESSION_ID from PAM instead of using the logind D-Bus API.
      (LP: #1364725)
    - Make socket writing code used between greeter and daemon more robust to
      errors.
    - Correct section name in default users.conf file.
    - Fix tests failing with Qt 5.3 due to it checking getuid/geteuid which we
      are faking.
    - Fix small memory leaks.
    - Test improvements

 -- Robert Ancell <email address hidden> Wed, 17 Sep 2014 16:27:53 +1200

Changed in lightdm (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Mathew Hodson (mhodson) wrote :

lightdm is available in the trusty-proposed repository and at https://launchpad.net/ubuntu/+source/lightdm/1.10.3-0ubuntu2 .

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Confirmed fixed in 1.10.3-0ubuntu2

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lightdm - 1.10.3-0ubuntu2

---------------
lightdm (1.10.3-0ubuntu2) trusty; urgency=medium

  * Refresh patches
 -- Robert Ancell <email address hidden> Fri, 10 Oct 2014 21:24:51 +1300

Changed in lightdm (Ubuntu Trusty):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.