#2726 Long living applicantion can use removed memory cache.
Closed: Fixed Opened by lslebodn.

File descriptor to memory cache is opened just once and used for all getpw/getgr calls. The cached file descriptor can be used even after removing fast memory cache. Moreover, we do not have a way how to invalidate memory cache after removing files.

Workaround is to invalidate fast memory cache before removing files.
The all fast memory caches are invalidated after calling (sss_cache -U or sss_cache -G).

Fortunately, problem is not visible with calling "service sssd restart" instead of "service sssd stop; rm $mem_cache; service sssd start"

Reproducer:

Python 2.7.10 (default, Jul  5 2015, 14:15:43) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getpid()
8121
>>> 
>>> import pwd
>>> from subprocess import call
>>> pwd.getpwnam('jhrozek')
pwd.struct_passwd(pw_name='jhrozek', pw_passwd='x', pw_uid=10327, pw_gid=10327, pw_gecos='Jakub Hrozek', pw_dir='/home/remote/jhrozek', pw_shell='/bin/bash')
>>> call(["service", "sssd", "stop"])
Redirecting to /bin/systemctl stop  sssd.service
0
>>> call(["rm", "-f", "/var/lib/sss/mc/passwd"])
0
>>> pwd.getpwnam('jhrozek')
pwd.struct_passwd(pw_name='jhrozek', pw_passwd='x', pw_uid=10327, pw_gid=10327, pw_gecos='Jakub Hrozek', pw_dir='/home/remote/jhrozek', pw_shell='/bin/bash')
>>> call(["sss_cache", "-E"])
0
>>> pwd.getpwnam('jhrozek')
pwd.struct_passwd(pw_name='jhrozek', pw_passwd='x', pw_uid=10327, pw_gid=10327, pw_gecos='Jakub Hrozek', pw_dir='/home/remote/jhrozek', pw_shell='/bin/bash')
>>> 
>>> #reason
... 
>>> call(["ls", "-l", "/proc/" + str(os.getpid()) + "/fd/"])
total 0
lrwx------. 1 root root 64 Jul 22 09:17 0 -> /dev/pts/9
lrwx------. 1 root root 64 Jul 22 09:17 1 -> /dev/pts/9
lr-x------. 1 root root 64 Jul 22 09:17 10 -> /dev/urandom
lrwx------. 1 root root 64 Jul 22 09:17 2 -> /dev/pts/9
lr-x------. 1 root root 64 Jul 22 09:17 3 -> /var/lib/sss/mc/passwd (deleted)
lrwx------. 1 root root 64 Jul 22 09:17 4 -> socket:[3301198]
lrwx------. 1 root root 64 Jul 22 09:17 5 -> socket:[3304690]
0

Fields changed

owner: somebody => lslebodn
status: new => assigned

Fields changed

rhbz: => todo

Lower priority than downstream bugzillas, though.

milestone: NEEDS_TRIAGE => SSSD 1.13.2

TODO:

Remove workaround in the commit 586f512ab8b6e5a03349598846141f43c1d505b8

Fields changed

patch: 0 => 1

Even though the patches are under review, we would like to release 1.13.2 tarball soon, therefore I'm moving the ticket out of 1.13.2 for now.

We can move the ticket back if the patches are acked before the 1.13.2 release.

milestone: SSSD 1.13.2 => SSSD 1.13.3

  • master:
    • 782d39e3916d16b8dbba6ae97aca1db2f3c35d76
    • b28f5fb097e06a97a45e0ae348e506d9d1432cc8
    • c269ca2669706bddb25c5938b50277b0c0a94ea4
    • d4ff84434265dc959098ccfd4e8cd5d61d9052c9

We also need a sssd-1-13 backport.

sssd-1-13:

  • c54c097445cdcbc2774c97a18549d516fc0b63cb
  • 87af3a1e57e8ddbffe847748b170a9a4f2ac8c1e
  • e360fa6e91ee3500435e85b9c51c4932d2b99f33
  • 01c888be345ed8e77d97a83ed0bf4f57b3e5c740

milestone: SSSD 1.13.3 => SSSD 1.13.2
resolution: => fixed
status: assigned => closed

Fields changed

rhbz: todo => 0

Metadata Update from @lslebodn:
- Issue assigned to lslebodn
- Issue set to the milestone: SSSD 1.13.2

SSSD is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in SSSD's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/SSSD/sssd/issues/3767

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata