Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'loginctl terminate-session ' sometimes return error: Failed to issue method call: Resource deadlock avoided #16702

Closed
yanjinjq opened this issue Aug 10, 2020 · 1 comment · Fixed by #17028
Labels
Milestone

Comments

@yanjinjq
Copy link

yanjinjq commented Aug 10, 2020

systemd version the issue has been seen with

systemd 243
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID -ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=legacy

Used distribution

aarch64 GNU/Linux

Expected behaviour you didn't see

teminate session successfully

Unexpected behaviour you saw

failed, return error: Failed to issue method call: Resource deadlock avoided

Steps to reproduce the problem
1.create new user logind_test1234
2. ssh logind_test1234@localhost sleep200
3.session=$(loginctl list-sessions | grep -w logind_test1234 | awk '{print $1}')
4.loginctl terminate-session "$session"

Additional log info
(I guess that when session of user logind_test1234 is still creating but session id have been generated,at this time loginctl terminate-session failed。 Is there a way to slove this problem?)

Aug 10 03:51:04 localhost.localdomain systemd[1]: Created slice User Slice of UID 1000.
Aug 10 03:51:04 localhost.localdomain sshd[15331]: Accepted password for logind_test1234 from ::1 port 38532 ssh2
Aug 10 03:51:04 localhost.localdomain systemd[1]: Starting User Runtime Directory /run/user/1000...
Aug 10 03:51:04 localhost.localdomain systemd-logind[15178]: New session 49 of user logind_test1234.
Aug 10 03:51:04 localhost.localdomain systemd[1]: Started User Runtime Directory /run/user/1000.
Aug 10 03:51:04 localhost.localdomain systemd[1]: Starting User Manager for UID 1000...
Aug 10 03:51:05 localhost.localdomain audit[15336]: AVC avc:  denied  { setattr } for  pid=15336 comm="(systemd)" name="logind_test1234" dev="tmpfs" ino=331763 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:faillog_t:s0 tclass=file permissive=0
Aug 10 03:51:05 localhost.localdomain audit[15336]: SYSCALL arch=c00000b7 syscall=55 success=no exit=-13 a0=7 a1=3e8 a2=ffffffff a3=aaaac85726d0 items=0 ppid=1 pid=15336 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="(systemd)" exe="/usr/lib/systemd/systemd" subj=system_u:system_r:init_t:s0 key=(null)
Aug 10 03:51:05 localhost.localdomain audit: PROCTITLE proctitle="(systemd)"
Aug 10 03:51:05 localhost.localdomain audit[15336]: USER_ACCT pid=15336 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='op=PAM:accounting grantors=pam_unix,pam_faillock,pam_localuser acct="logind_test1234" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 10 03:51:05 localhost.localdomain audit[15336]: USER_ROLE_CHANGE pid=15336 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='pam: default-context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 selected-context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 10 03:51:05 localhost.localdomain audit[15336]: USER_START pid=15336 uid=0 auid=1000 ses=50 subj=system_u:system_r:init_t:s0 msg='op=PAM:session_open grantors=pam_selinux,pam_selinux,pam_loginuid,pam_keyinit,pam_limits,pam_systemd,pam_unix acct="logind_test1234" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 10 03:51:05 localhost.localdomain systemd[15336]: pam_unix(systemd-user:session): session opened for user logind_test1234 by (uid=0)
Aug 10 03:51:05 localhost.localdomain systemd[1]: Requested transaction contradicts existing jobs: Transaction for session-49.scope/stop is destructive (session-49.scope has 'start' job queued, but 'stop' is included in transaction).
Aug 10 03:51:05 localhost.localdomain systemd-logind[15178]: Failed to stop session scope: Transaction for session-49.scope/stop is destructive (session-49.scope has 'start' job queued, but 'stop' is included in transaction).
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Started Mark boot as successful after the user session has run 2 minutes.
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Reached target Paths.
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Reached target Timers.
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Starting D-Bus User Message Bus Socket.
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Listening on D-Bus User Message Bus Socket.
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Reached target Sockets.
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Reached target Basic System.
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Reached target Main User Target.
Aug 10 03:51:05 localhost.localdomain systemd[15336]: Startup finished in 320ms.
Aug 10 03:51:05 localhost.localdomain systemd[1]: Started User Manager for UID 1000.
Aug 10 03:51:05 localhost.localdomain systemd[1]: Started Session 49 of user logind_test1234
@poettering
Copy link
Member

Hmm, so this stems from the fact that logind's manager_stop_unit() routine always uses "fail" job mode. It should probably use "replace" for some cases at least, so that we can reverse the jobs on terminate

@poettering poettering added this to the v247 milestone Aug 28, 2020
poettering added a commit to poettering/systemd that referenced this issue Sep 11, 2020
…ser/seat to use "replace" job mode

Otherwise our request will possibly fail if something else is already
enqeued, but given this is an explicit user request, let's not allow
things to fail.

Fixes: systemd#16702
ssahani pushed a commit to ssahani/systemd that referenced this issue Oct 5, 2020
…ser/seat to use "replace" job mode

Otherwise our request will possibly fail if something else is already
enqeued, but given this is an explicit user request, let's not allow
things to fail.

Fixes: systemd#16702
ssahani pushed a commit to ssahani/systemd that referenced this issue Oct 5, 2020
…ser/seat to use "replace" job mode

Otherwise our request will possibly fail if something else is already
enqeued, but given this is an explicit user request, let's not allow
things to fail.

Fixes: systemd#16702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants