Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 484732 - sys-libs/pam-1.1.7: segfault in pam_unix.so
Summary: sys-libs/pam-1.1.7: segfault in pam_unix.so
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: PAM Gentoo Team (OBSOLETE)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-13 09:15 UTC by Michał Górny
Modified: 2014-05-08 22:47 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-09-13 09:15:13 UTC
I've been able to consistently reproduce this by building pam-1.1.7 twice. After downgrading to pam-1.1.6-r2, everything works fine again.

Since this makes it impossible to log in into the system without using some kind of recovery, I will take the freedom of masking it. I will start debugging the issue now and get back with more information in a few minutes.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-09-13 09:29:16 UTC
(gdb) bt
#0  0x00007f4cb3d8e4f7 in _set_ctrl (pamh=pamh@entry=0x75a900, flags=0, 
    remember=remember@entry=0x0, rounds=rounds@entry=0x0, pass_min_len=pass_min_len@entry=0x0, 
    argc=0, argv=0x75bfb0)
    at /usr/src/debug/sys-libs/pam-1.1.7/Linux-PAM-1.1.7/modules/pam_unix/support.c:183
#1  0x00007f4cb3d8c740 in pam_sm_acct_mgmt (pamh=0x75a900, flags=<optimized out>, 
    argc=<optimized out>, argv=<optimized out>)
    at /usr/src/debug/sys-libs/pam-1.1.7/Linux-PAM-1.1.7/modules/pam_unix/pam_unix_acct.c:200
#2  0x00007f4cb57eacab in _pam_dispatch_aux (pamh=pamh@entry=0x75a900, flags=flags@entry=0, 
    h=0x75bfd0, resumed=<optimized out>, use_cached_chain=0)
    at /usr/src/debug/sys-libs/pam-1.1.7/Linux-PAM-1.1.7/libpam/pam_dispatch.c:110
#3  0x00007f4cb57eb0c9 in _pam_dispatch (pamh=0x75a900, flags=0, choice=choice@entry=3)
    at /usr/src/debug/sys-libs/pam-1.1.7/Linux-PAM-1.1.7/libpam/pam_dispatch.c:407
#4  0x00007f4cb57ea5d6 in pam_acct_mgmt (pamh=<optimized out>, flags=<optimized out>)
    at /usr/src/debug/sys-libs/pam-1.1.7/Linux-PAM-1.1.7/libpam/pam_account.c:20
#5  0x0000000000403974 in ?? ()
#6  0x0000000000402715 in ?? ()
#7  0x00007f4cb5260955 in __libc_start_main () from /lib64/libc.so.6
#8  0x000000000040325d in ?? ()


Looking at it, we have an explicit case where pam_unix_acct.c:200 calls:

    ctrl = _set_ctrl(pamh, flags, NULL, NULL, NULL, argc, argv);

with:

int _set_ctrl(pam_handle_t *pamh, int flags, int *remember, int *rounds,
          int *pass_min_len, int argc, const char **argv)

which writes to '*rounds' unconditionally to whether it is provided or NULL:

      if (on(UNIX_SHA256_PASS, ctrl) || on(UNIX_SHA512_PASS, ctrl)) {
        val=search_key ("SHA_CRYPT_MAX_ROUNDS", LOGIN_DEFS);

        if (val) {
          *rounds = strtol(val, NULL, 10);
          free (val);
        }
      }

I don't see any obvious conditionals that would make this any kind of special.
Comment 2 Holger Hoffstätte 2013-09-13 11:48:52 UTC
(In reply to Michał Górny from comment #1)
> which writes to '*rounds' unconditionally to whether it is provided or NULL:
> 
>       if (on(UNIX_SHA256_PASS, ctrl) || on(UNIX_SHA512_PASS, ctrl)) {
>         val=search_key ("SHA_CRYPT_MAX_ROUNDS", LOGIN_DEFS);
> 
>         if (val) {
>           *rounds = strtol(val, NULL, 10);
>           free (val);
>         }
>       }

Since all this works fine for me it seems to me that you explicitly set SHA_CRYPT_MAX_ROUNDS in login.defs (it's uncommented on my systems) and it only then pokes into an empty *rounds. Looks like a generic upstream bug. Since the check for the env is in _set_ctrl the best fix is probably to ensure that callers always provide a rounds parameter. Adding only a conditional check for (rounds != NULL) in _set_ctrl seems the wrong way to fix it but could help as additional safety measure/shortcut, implying that the caller doesn't care for explicitly configured rounds.
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2013-09-13 16:57:17 UTC
Thanks for masking it. Unfortunately it worked fine here when I tried logging in here, but indeed that's a big issue.

Another issue is selinux failing to build :/
Comment 4 Arfrever Frehtes Taifersar Arahesis 2013-09-14 11:33:27 UTC
Please restore pam-1.1.6-r4.ebuild.
Comment 5 Holger Hoffstätte 2013-10-08 10:18:33 UTC
1.1.8 is out, so if that works maybe we can just close this bug and nuke 1.1.7.
Comment 6 SpanKY gentoo-dev 2014-05-08 22:39:06 UTC
pam-1.1.8 is in the tree now and unmasked.  is this still an issue ?
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-05-08 22:47:14 UTC
No, it seems to have been fixed.