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

3.0.7: build fails (and compile time warnings) #236

Closed
kloczek opened this issue Feb 20, 2022 · 5 comments
Closed

3.0.7: build fails (and compile time warnings) #236

kloczek opened this issue Feb 20, 2022 · 5 comments

Comments

@kloczek
Copy link

kloczek commented Feb 20, 2022

Looks like 3.0.7 is not gcc 12.0.1 ready
Summary stats:

[tkloczko@devel-g2v SPECS]$ rpmbuild -ba --with check --with failing_tests audit.spec --quiet 2>&1 | grep -- -W | sed 's/.*\[//; s/\]//' | sort | uniq -c | sort -nr
      8 -Wunused-but-set-variable
      5 -Wdiscarded-qualifiers
      3 -Wunused-result
      2 -Wunused-value
      1 -Wreturn-type
      1 -Woverflow
      1 -Wdeprecated-declarations
      1 -Waddress

end extracted stderr on running make -k

../lib/gen_tables.c:89:22: warning: overflow in conversion from 'long long unsigned int' to 'int' changes value from '4294967296' to '0' [-Woverflow]
   89 | #define _S(VAL, S) { (VAL), (S), 0, 0 },
      |                      ^
./clone-flagtab.h:47:1: note: in expansion of macro '_S'
   47 | _S(0x100000000ULL,      "CLONE_CLEAR_SIGHAND")
      | ^~
zos-remote-plugin.c: In function 'submission_thread_main':
zos-remote-plugin.c:106:30: warning: passing argument 1 of 'zos_remote_init' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
  106 |         rc = zos_remote_init(&zos_remote_inst, conf.server,
      |                              ^~~~~~~~~~~~~~~~
In file included from zos-remote-log.h:27,
                 from zos-remote-plugin.c:44:
zos-remote-ldap.h:297:21: note: expected 'ZOS_REMOTE *' {aka 'struct opaque *'} but argument is of type 'volatile ZOS_REMOTE *' {aka 'volatile struct opaque *'}
  297 | int zos_remote_init(ZOS_REMOTE *, const char *, int, const char *,
      |                     ^~~~~~~~~~~~
zos-remote-plugin.c:128:39: warning: passing argument 1 of 'submit_request_s' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
  128 |                 rc = submit_request_s(&zos_remote_inst, ber);
      |                                       ^~~~~~~~~~~~~~~~
zos-remote-ldap.h:309:22: note: expected 'ZOS_REMOTE *' {aka 'struct opaque *'} but argument is of type 'volatile ZOS_REMOTE *' {aka 'volatile struct opaque *'}
  309 | int submit_request_s(ZOS_REMOTE *, BerElement *);
      |                      ^~~~~~~~~~~~
zos-remote-plugin.c:141:28: warning: passing argument 1 of 'zos_remote_destroy' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
  141 |         zos_remote_destroy(&zos_remote_inst);
      |                            ^~~~~~~~~~~~~~~~
zos-remote-ldap.h:303:25: note: expected 'ZOS_REMOTE *' {aka 'struct opaque *'} but argument is of type 'volatile ZOS_REMOTE *' {aka 'volatile struct opaque *'}
  303 | void zos_remote_destroy(ZOS_REMOTE *);
      |                         ^~~~~~~~~~~~
ev.c:2146:31: warning: 'ev_default_loop_ptr' initialized and declared 'extern'
 2146 |   EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
      |                               ^~~~~~~~~~~~~~~~~~~
In file included from ev.c:3108:
ev_iouring.c: In function 'iouring_sqe_submit':
ev_iouring.c:300:1: warning: no return statement in function returning non-void [-Wreturn-type]
  300 | }
      | ^
In file included from ev.c:222:
ev_iouring.c: In function 'iouring_fork':
ev.h:180:20: warning: left-hand operand of comma expression has no effect [-Wunused-value]
  180 | # define EV_A_ EV_A,                              /* a loop as first of multiple arguments */
      |                    ^
ev.h:698:52: note: in definition of macro 'ev_io_set'
  698 | #define ev_io_set(ev,fd_,events_)            do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0)
      |                                                    ^~
ev_iouring.c:428:16: note: in expansion of macro 'EV_A_'
  428 |   ev_io_set   (EV_A_ &iouring_tfd_w, iouring_tfd, EV_READ);
      |                ^~~~~
ev.h:180:20: warning: left-hand operand of comma expression has no effect [-Wunused-value]
  180 | # define EV_A_ EV_A,                              /* a loop as first of multiple arguments */
      |                    ^
ev.h:698:70: note: in definition of macro 'ev_io_set'
  698 | #define ev_io_set(ev,fd_,events_)            do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0)
      |                                                                      ^~
ev_iouring.c:428:16: note: in expansion of macro 'EV_A_'
  428 |   ev_io_set   (EV_A_ &iouring_tfd_w, iouring_tfd, EV_READ);
      |                ^~~~~
auditd.c: In function 'reconfig_ready':
auditd.c:585:9: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
  585 |         write(pipefds[1], msg, strlen(msg));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
auditd.c: In function 'pipe_handler':
auditd.c:577:9: warning: ignoring return value of 'read' declared with attribute 'warn_unused_result' [-Wunused-result]
  577 |         read(pipefds[0], buf, sizeof(buf));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ausearch.c: In function 'process_stdin':
ausearch.c:524:13: warning: 'siginterrupt' is deprecated: Use sigaction with SA_RESTART instead [-Wdeprecated-declarations]
  524 |             siginterrupt(SIGALRM, 1) == -1)
      |             ^~~~~~~~~~~~
In file included from /usr/include/sys/param.h:28,
                 from ausearch.c:37:
/usr/include/signal.h:324:12: note: declared here
  324 | extern int siginterrupt (int __sig, int __interrupt) __THROW
      |            ^~~~~~~~~~~~
auditd-event.c: In function 'fix_disk_permissions':
auditd-event.c:1060:9: warning: ignoring return value of 'chown' declared with attribute 'warn_unused_result' [-Wunused-result]
 1060 |         chown(dir, 0, config->log_group ? config->log_group : 0);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
auditd-listen.c: In function 'client_ack':
auditd-listen.c:500:21: warning: variable 'rc' set but not used [-Wunused-but-set-variable]
  500 |                 int rc, mlen;
      |                     ^~
auditd-listen.c: In function 'client_message':
auditd-listen.c:546:19: warning: variable 'mver' set but not used [-Wunused-but-set-variable]
  546 |         int hver, mver;
      |                   ^~~~
auditd-listen.c:546:13: warning: variable 'hver' set but not used [-Wunused-but-set-variable]
  546 |         int hver, mver;
      |             ^~~~
auditd-listen.c:545:24: warning: variable 'mlen' set but not used [-Wunused-but-set-variable]
  545 |         uint32_t type, mlen, seq;
      |                        ^~~~
auditd-listen.c: In function 'auditd_tcp_client_handler':
auditd-listen.c:678:27: warning: variable 'mver' set but not used [-Wunused-but-set-variable]
  678 |                 int hver, mver;
      |                           ^~~~
auditd-listen.c:678:21: warning: variable 'hver' set but not used [-Wunused-but-set-variable]
  678 |                 int hver, mver;
      |                     ^~~~
auditd-listen.c:677:37: warning: variable 'seq' set but not used [-Wunused-but-set-variable]
  677 |                 uint32_t type, len, seq;
      |                                     ^~~
auditd-listen.c:677:26: warning: variable 'type' set but not used [-Wunused-but-set-variable]
  677 |                 uint32_t type, len, seq;
      |                          ^~~~
../../../bindings/python/auparse_python.c: In function 'AuParser_init':
../../../bindings/python/auparse_python.c:375:31: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  375 |                 if ((files[i] = PYSTR_ASSTRING(item)) == NULL) {
      |                               ^
../../../bindings/python/auparse_python.c:418:33: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  418 |                 if ((buffers[i] = PYSTR_ASSTRING(item)) == NULL) {
      |                                 ^
Deprecated command line option: -modern. This option is now always on.
audit_wrap.c: In function '_wrap_audit_rule_data_buf_set':
audit_wrap.c:4698:7: warning: the comparison will always evaluate as 'true' for the address of 'buf' will never be NULL [-Waddress]
 4698 |   if (arg1->buf) free((char*)arg1->buf);
      |       ^~~~
In file included from ../../../lib/../lib/libaudit.h:42,
                 from audit_wrap.c:2729:
/usr/include/linux/audit.h:517:25: note: 'buf' declared here
  517 |         char            buf[];  /* string fields buffer */
      |                         ^~~
audit_wrap.c:4701:17: error: cast specifies array type
 4701 |     arg1->buf = (char [])(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size));
      |                 ^
audit_wrap.c:4701:15: error: invalid use of flexible array member
 4701 |     arg1->buf = (char [])(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size));
      |               ^
audit_wrap.c:4703:15: error: invalid use of flexible array member
 4703 |     arg1->buf = 0;
      |               ^
make[4]: *** [Makefile:518: _audit_la-audit_wrap.lo] Error 1
make[4]: Target 'all' not remade because of errors.
@stevegrubb
Copy link
Member

This is known. It's being worked as https://bugzilla.redhat.com/show_bug.cgi?id=2049096
The main issue is SWIG generates code that gcc 12 doesn't like.
In general, I'd rather have pull requests fixing warnings. I have my own build logs with these same warnings. :-)

@kloczek
Copy link
Author

kloczek commented Feb 20, 2022

Did someone opened swig ticket?

@stevegrubb
Copy link
Member

stevegrubb commented Feb 21, 2022

I think I'll reopen this issue now that I know the root cause

Upstream SWIG has not yet been contacted. SWIG has 400 open issues - which is discouraging. The root cause of the problem is this:

KSPP/linux#78

SWIG apparently doesn't know how to generate good code from a flexible array member. The options are:

  1. Contact upstream SWIG and wait
  2. Rewrite the bindings not to use SWIG (like the auparse bindings)
  3. Ask upstream kernel to go back to buf[0];
  4. Do some build time patch to copy audit.h to the build directory and use the gcc buf[0] extension

4 would be a short term fix. 2 would probably be the only viable long term fix. And 2 is going to take some time.

@stevegrubb stevegrubb reopened this Feb 21, 2022
@stevegrubb stevegrubb changed the title 3.0.7: build fails (and compile time warnimngs) 3.0.7: build fails (and compile time warnings) Feb 22, 2022
@stevegrubb
Copy link
Member

A workaround was posted to the Linux audit mail list:
https://listman.redhat.com/archives/linux-audit/2022-February/msg00085.html
Any compiler warnings will be fixed as normal maintenance. Pull requests are welcome.

I'll leave this issue open a little while longer in case someone else has the same problem.

@stevegrubb
Copy link
Member

OK, the mail list has pointers to patches and explanation of problems. I am going to close this. The ultimate solution is rewriting the python bindings.

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