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

useradd aborts in 4.9 #394

Closed
dm0- opened this issue Jul 26, 2021 · 1 comment
Closed

useradd aborts in 4.9 #394

dm0- opened this issue Jul 26, 2021 · 1 comment

Comments

@dm0-
Copy link
Contributor

dm0- commented Jul 26, 2021

When I try to add a user in a prefix, I get this:

free(): invalid pointer

Program received signal SIGABRT, Aborted.
0x00007ffff7e20d11 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7e20d11 in raise () from /lib64/libc.so.6
#1  0x00007ffff7e0a538 in abort () from /lib64/libc.so.6
#2  0x00007ffff7e62a07 in ?? () from /lib64/libc.so.6
#3  0x00007ffff7e6a4bc in ?? () from /lib64/libc.so.6
#4  0x00007ffff7e6b894 in ?? () from /lib64/libc.so.6
#5  0x00007ffff7e6f554 in free () from /lib64/libc.so.6
#6  0x0000555555566279 in gr_free (grent=0x7ffff7fa23a0) at groupmem.c:107
#7  0x000055555555c492 in get_defaults () at useradd.c:418
#8  0x0000555555559b7e in main (argc=7, argv=0x7fffffffe2a8) at useradd.c:2451

It happens when freeing the default group entry, which is GROUP=100 corresponding to the line users::100: in this case. (The specific free call that fails is for gr_passwd which is "", but I don't think that's relevant. It fails in the same place with different passwd values.) The group being freed is returned from prefix_getgr_nam_gid, which seems to just be returned from fgetgrent.

According to glibc documentation, the return value of fgetgrent is statically allocated, so it should not be freed.

@hallyn
Copy link
Member

hallyn commented Aug 15, 2021

Thanks. Yeah, unfortunately in some cases it will be a free-able value (in particular in getgr_nam_gid path).

Since useradd always exits and is not a library, "memory leaks" are not really worth worrying about, so I'll revert c44b71c which introduced this.

Thanks for reporting this.

@hallyn hallyn closed this as completed in 4624e9f Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants