sudo-project / sudo

Utility to execute a command as another user
https://www.sudo.ws
Other
1.15k stars 208 forks source link

ASAN 2 locations #306

Closed freedom1b2830 closed 9 months ago

freedom1b2830 commented 9 months ago

sudo id uid=0(root) gid=0(root) группы=0(root) контекст=root:sysadm_r:sysadm_t:s0-s0:c0.c1023

=================================================================
==1661367==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 768 byte(s) in 3 object(s) allocated from:
    #0 0x56302d762af4 in __interceptor_reallocarray (/usr/bin/sudo+0x10faf4) (BuildId: 9b15fb0dc7adf977a038556d800ccd688add5428)
    #1 0x56302d7cb7f9 in format_plugin_settings /usr/src/debug/sudo-selinux/sudo-1.9.14p3/src/./sudo.c:1099:23

Indirect leak of 713 byte(s) in 19 object(s) allocated from:
    #0 0x56302d7638b9 in malloc (/usr/bin/sudo+0x1108b9) (BuildId: 9b15fb0dc7adf977a038556d800ccd688add5428)
    #1 0x7f8118129346 in sudo_new_key_val_v1 /usr/src/debug/sudo-selinux/sudo-1.9.14p3/lib/util/./key_val.c:45:16

SUMMARY: AddressSanitizer: 1481 byte(s) leaked in 22 allocation(s).
millert commented 9 months ago

Do you still see a leak when you configure sudo with --disable-leaks?

freedom1b2830 commented 9 months ago

1.What does this argument do? (--disable-leaks) 2.I will now build a program with these flags:

  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib \
    --with-rundir=/run/sudo \
    --with-vardir=/var/db/sudo \
    --with-logfac=auth \
    --enable-tmpfiles.d \
    --with-pam \
    --with-sssd \
    --with-ldap \
    --with-ldap-conf-file=/etc/openldap/ldap.conf \
    --with-env-editor \
    --with-passprompt="[sudo] password for %p: " \
    --with-all-insults \
    --with-selinux \
    --disable-leak
millert commented 9 months ago

From INSTALL.md:

Avoid leaking memory even when we are headed for exit, which helps reduce the noise from static and active analyzers. This option should only be used for testing and not in a production environment.

If would have been enabled for you automatically if you had used the --enable-sanitizer configure option instead of whatever you are doing.

freedom1b2830 commented 9 months ago

No memory leaks are present when: --enable-sanitizer --disable-leaks

Open issue for no reason.<