Bug #90999 Bad usage of ppoll in libmysql
Submitted: 23 May 2018 22:06 Modified: 1 Jun 2018 18:16
Reporter: Manuel Ung Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[23 May 2018 22:06] Manuel Ung
It seems like https://github.com/mysql/mysql-server/commit/92e525f added usage of ppoll so the SIGUSR1 signal can be listened to. However, the implementation unblocks all signals, which could break applications that relies on blocking certain signals.

How to repeat:
In application code on the client side, block SIGHUP:

int main() {
  sigset_t sigs;
  sigaddset(&sigs, SIGHUP);
  pthread_sigmask(SIG_BLOCK, &sigs, nullptr);

Observe that when ppoll is running, vio->signal_mask is left empty, which means that all signals (including SIGHUP) is unblocked. This could adversely affect applications that rely on SIGHUP being set.

Suggested fix:
Since ppoll is only used to listen for the SIGUSR1 signal, only that signal should be unblocked.

Alternatively, it seems like this fix was intended mainly for the server, since a pthread_kill is only sent if vio->thread_id != 0. A possible fix is to only use sigmask in ppoll if thread_id != 0.
[24 May 2018 11:41] Chiranjeevi Battula
Hello Manuel Ung,

Thank you for the bug report.

[1 Jun 2018 18:16] Paul Dubois
Posted by developer:
Fixed in 8.0.13.

In the client library, signals were incorrectly unblocked for
ppoll(). Thanks to Facebook for the patch.