[klibc] Fwd: mksh-static segfaults on continued jobs

Thorsten Glaser tg at mirbsd.de
Fri Oct 3 05:12:43 PDT 2014

Hi there,

something to look at, maybe?

---------- Forwarded message ----------
From: Kacper Gutowski <mwgamera at gmail.com>
Message-ID: <20141003053550.GA8510 at gmail.com>
Date: Fri, 3 Oct 2014 07:35:50 +0200
Subject: Bug#763842: mksh-static segfaults on continued jobs

Package: mksh
Version: 50b-1
Severity: normal

Dear Maintainer,
When a job is continued after being stopped in interactive mksh-static
or lksh, they crash with segmentation fault.

The simplest way to reproduce is to call "fg" for any stopped job in
interactive mksh-static or lksh (full mksh is not affected); it results
in job being continued but shell crashing immediately after that.

The crash happens in j_print() at jobs.c:1560 where the expression
sigtraps[WSTOPSIG(p->status)] is out-of-bounds.  It seems to be introduced
with revision 1.101 of jobs.c that added WCONTINUED flag to wait(2)
and then updated the state after checking status with WIFCONTINUED.

Apparently, when compiling with klibc, WCONTINUED flag is defined but
WIFCONTINUED macro is not.  The result is that p->state and p->status
are not consistent.

This fixes it for me:

--- jobs.c  10 Jun 2014 22:17:33 -0000  1.104
+++ jobs.c  3 Oct 2014 04:33:32 -0000
@@ -1339,7 +1339,7 @@
  do {
    pid = waitpid(-1, &status, (WNOHANG |
+#if defined(WCONTINUED) && defined(WIFCONTINUED)
        WCONTINUED |

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (900, 'testing'), (700, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.14-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=pl_PL.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages mksh depends on:
ii  libc6  2.19-11

mksh recommends no packages.

Versions of packages mksh suggests:
ii  ed  1.10-2

-- no debconf information

More information about the klibc mailing list