[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#631888: eglibc: spurious return from pause(3) when setuid() is called from another thread



Package: eglibc
Severity: normal

setuid() causes a SIGRT_1 signal to be sent to all threads in the process.
The pause() syscall should ignore this signal and not return to the caller.
The test program below demonstrates that calling setuid()
in one thread will cause pause() to return unexpectedly.

/*
 * Copyright (c) 2011 Mark Heily <mark@heily.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * This test demonstrates a spurious wakeup from pause() when another
 * thread calls setuid().
 */

#include <err.h>
#include <signal.h>
#include <sys/types.h>
#include <pthread.h>

void * worker_main(void *arg)
{
    sleep(2);
    setuid(1);
}

int main()
{
    pthread_t tid;
    sigset_t mask;

    sigfillset(&mask);
    pthread_sigmask(SIG_SETMASK, &mask, NULL);

    pthread_create(&tid, NULL, worker_main, NULL);
    pause();
    puts("ERROR -- RETURNED FROM PAUSE()");
}

-- System Information:
Debian Release: 6.0.1
  APT prefers stable
APT policy: (700, 'stable'), (650, 'testing'), (600, 'unstable'), (500, 'stable-updates'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/6 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash




Reply to: