Closed likunyur closed 2 years ago
Hello,
Even though your patch works on your machine, it is actually introducing a bug which could be triggered on other systems/CPU. free_hashtab_entry
is used in a call to function hashtab_map
, which actually checks the return value of the function: https://github.com/SELinuxProject/selinux/blob/0a8c177dacdc1df96ea11bb8aa75e16c4fa82285/libsepol/src/hashtab.c#L234-L236
Your patch makes this return value undefined, which is an issue.
cc -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/home/christian/destdir/usr/include -DVERSION=\"3.4\" -DUSE_NLS -DLOCALEDIR="\"/home/christian/destdir/usr/share/locale\"" -DPACKAGE="\"policycoreutils\"" -DUSE_PAM -DUSE_AUDIT -c -o newrole.o newrole.c
newrole.c: In function ‘main’:
newrole.c:1248:48: error: passing argument 2 of ‘hashtab_map’ from incompatible pointer type [-Werror=incompatible-pointer-types]
1248 | hashtab_map(app_service_names, free_hashtab_entry, NULL);
| ^~~~~~~~~~~~~~~~~~
| |
| void (*)(char *, void *, void *)
In file included from newrole.c:220:
hashtab.h:109:30: note: expected ‘int (*)(char *, void *, void *)’ but argument is of type ‘void (*)(char *, void *, void *)’
109 | int (*apply) (hashtab_key_t k,
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
110 | hashtab_datum_t d,
| ~~~~~~~~~~~~~~~~~~
111 | void *args), void *args);
| ~~~~~~~~~~~
newrole.c:1376:48: error: passing argument 2 of ‘hashtab_map’ from incompatible pointer type [-Werror=incompatible-pointer-types]
1376 | hashtab_map(app_service_names, free_hashtab_entry, NULL);
| ^~~~~~~~~~~~~~~~~~
| |
| void (*)(char *, void *, void *)
In file included from newrole.c:220:
hashtab.h:109:30: note: expected ‘int (*)(char *, void *, void *)’ but argument is of type ‘void (*)(char *, void *, void *)’
109 | int (*apply) (hashtab_key_t k,
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
110 | hashtab_datum_t d,
| ~~~~~~~~~~~~~~~~~~
111 | void *args), void *args);
| ~~~~~~~~~~~
Omit the eax register step