13 Dec, 2008

1 commit

  • Impact: restructure, clean up code

    k_itimer holds the ref to the ->it_process until sys_timer_delete(). This
    allows to pin up to RLIMIT_SIGPENDING dead task_struct's. Change the code
    to use "struct pid *" instead.

    The patch doesn't kill ->it_process, it places ->it_pid into the union.
    ->it_process is still used by do_cpu_nanosleep() as before. It would be
    trivial to change the nanosleep code as well, but since it uses it_process
    in a special way I think it is better to keep this field for grep.

    The patch bloats the kernel by 104 bytes and it also adds the new pointer,
    ->it_signal, to k_itimer. It is used by lock_timer() to verify that the
    found timer was not created by another process. It is not clear why do we
    use the global database (and thus the global idr_lock) for posix timers.
    We still need the signal_struct->posix_timers which contains all useable
    timers, perhaps it is better to use some form of per-process array
    instead.

    Signed-off-by: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Oleg Nesterov
     

11 Dec, 2008

35 commits

  • This reverts commit b1ee26bab14886350ba12a5c10cbc0696ac679bf, along with
    the "fixes" for it that all just caused problems:

    - c4c6fa9891f3d1bcaae4f39fb751d5302965b566 "radeonfb: fix problem with
    color expansion & alignment"

    - f3179748a157c21d44d929fd3779421ebfbeaa93 "radeonfb: Disable new color
    expand acceleration unless explicitely enabled"

    because even when disabled, it breaks for people. See

    http://bugzilla.kernel.org/show_bug.cgi?id=12191

    for the latest example.

    Acked-by: Benjamin Herrenschmidt
    Acked-by: David S. Miller
    Cc: Krzysztof Halasa
    Cc: James Cloos
    Cc: "Rafael J. Wysocki"
    Cc: Krzysztof Helt
    Cc: Jean-Luc Coulon
    Cc: Andrew Morton
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Linus Torvalds
     
  • …l/git/tip/linux-2.6-tip

    * 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    sched: CPU remove deadlock fix

    Linus Torvalds
     
  • Lee Schermerhorn noticed yesterday that I broke the mapping_writably_mapped
    test in 2.6.7! Bad bad bug, good good find.

    The i_mmap_writable count must be incremented for VM_SHARED (just as
    i_writecount is for VM_DENYWRITE, but while holding the i_mmap_lock)
    when dup_mmap() copies the vma for fork: it has its own more optimal
    version of __vma_link_file(), and I missed this out. So the count
    was later going down to 0 (dangerous) when one end unmapped, then
    wrapping negative (inefficient) when the other end unmapped.

    The only impact on x86 would have been that setting a mandatory lock on
    a file which has at some time been opened O_RDWR and mapped MAP_SHARED
    (but not necessarily PROT_WRITE) across a fork, might fail with -EAGAIN
    when it should succeed, or succeed when it should fail.

    But those architectures which rely on flush_dcache_page() to flush
    userspace modifications back into the page before the kernel reads it,
    may in some cases have skipped the flush after such a fork - though any
    repetitive test will soon wrap the count negative, in which case it will
    flush_dcache_page() unnecessarily.

    Fix would be a two-liner, but mapping variable added, and comment moved.

    Reported-by: Lee Schermerhorn
    Signed-off-by: Hugh Dickins
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • * 'to-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/frob/linux-2.6-roland:
    tracehook: exec double-reporting fix

    Linus Torvalds
     
  • The last patch to lib/idr.c caused a bug if idr_get_new_above() was
    called on an empty idr.

    Usually, nodes stay on the same layer. New layers are added to the top
    of the tree.

    The exception is idr_get_new_above() on an empty tree: In this case, the
    new root node is first added on layer 0, then moved upwards. p->layer
    was not updated.

    As usual: You shall never rely on the source code comments, they will
    only mislead you.

    Signed-off-by: Manfred Spraul
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     
  • Give the correct size when reserving the interrupt vector table. It should be
    a page not a single byte.

    Signed-off-by: Akira Takeuchi
    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    Akira Takeuchi
     
  • Fix __put_user_asm8() by jumping to the end label (3:) from the exception
    handler, rather than jumping back to retry the second store instruction (label
    2:).

    Signed-off-by: Akira Takeuchi
    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    Akira Takeuchi
     
  • Fix the preemption resume_kernel() routine by inverting the test to see
    whether interrupts are off (IM7 is all enabled, not all disabled).

    Furthermore, interrupts should be disabled on entry to resume_kernel() so that
    they're correctly set for jumping to restore_all() and doing the need
    reschedule test.

    Signed-off-by: Akira Takeuchi
    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    Akira Takeuchi
     
  • Discard low-prioriy Tx interrupts when closing an MN10300 on-chip serial port.

    The MN10300 on-chip serial port uses three interrupts to manage its serial
    ports:

    (1) A very high priority interrupt that drives virtual DMA for Rx.

    (2) A very high priority interrupt that drives virtual DMA for Tx.

    (3) A normal priority virtual interrupt that does the normal UART interrupt
    stuff and is shared between Rx and Tx.

    mn10300_serial_stop_tx() only disables the high priority Tx interrupt. It
    doesn't also disable the normal priority one because it is shared with Rx.

    However, the high priority interrupt may interrupt local_irq_disabled()
    sections, and so may have queued up a low priority virtual interrupt whilst the
    UART driver is asking for the Tx interrupt to be disabled.

    The result of this can be an oops when we try to process the interrupt in
    mn10300_serial_transmit_interrupt() as port->uart.info and port->uart.info->tty
    may have gone away.

    To deal with this, if either of those pointers is NULL, we make sure the
    high-priority Tx interrupt is disabled and discard the interrupt. The low
    priority interrupt is disabled by the mn10300_serial_pic irq_chip table.

    Signed-off-by: Akira Takeuchi
    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    Akira Takeuchi
     
  • Include the linux/page.h header into the MN10300 kernel linker script thus
    allowing us to use PAGE_SIZE macro instead of a numeric constant.

    Also use the PERCPU macro instead of an explicit section definition.

    Signed-off-by: Cyrill Gorcunov
    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    Cyrill Gorcunov
     
  • * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
    crypto: api - Disallow cryptomgr as a module if algorithms are built-in

    Linus Torvalds
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6:
    PCIe: ASPM: Break out of endless loop waiting for PCI config bits to switch
    PCI: stop leaking 'slot_name' in pci_create_slot

    Linus Torvalds
     
  • * 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6:
    [IA64] SN: prevent IRQ retargetting in request_irq()
    [IA64] Fix section mismatch ioc3uart_init()/ioc3uart_submodule
    [IA64] Clear up section mismatch for ioc4_ide_attach_one.
    [IA64] Clear up section mismatch with arch_unregister_cpu()
    [IA64] Clear up section mismatch for sn_check_wars.
    [IA64] Updated the generic_defconfig to work with the 2.6.28-rc7 kernel.
    [IA64] Fix GRU compile error w/o CONFIG_HUGETLB_PAGE
    [IA64] eliminate NULL test and memset after alloc_bootmem
    [IA64] remove BUILD_BUG_ON from paravirt_getreg()

    Linus Torvalds
     
  • * 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus:
    MIPS: Better than nothing implementation of PCI mmap to fix X.

    Linus Torvalds
     
  • The pktcdvd created class devices only export some sysfs files,
    but have no char dev_t registered in the driver.

    At class device creation time they copy the dev_t value of the
    block device to the char device, wich will register a new char
    device in the driver core and userspace, with a conflicting dev_t
    value.

    In many cases the class devices dev_t just points to a random
    USB device. This fixes the sysfs "duplicate entry" errors.

    Signed-off-by: Kay Sievers
    Acked-by: Peter Osterlund
    Cc: Al Viro
    Signed-off-by: Linus Torvalds

    Kay Sievers
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
    firewire: fw-ohci: fix IOMMU resource exhaustion
    ieee1394: node manager causes up to ~3.25s delay in freezing tasks

    Linus Torvalds
     
  • sparc64:

    drivers/video/mb862xx/mb862xxfb.c:929: warning: long long unsigned int format, resource_size_t arg (arg 4)
    drivers/video/mb862xx/mb862xxfb.c:931: warning: long long unsigned int format, resource_size_t arg (arg 4)

    We don't know what type the architecture uses to implement u64, hence they
    cannot be printed.

    Cc: Anatolij Gustschin
    Cc: Dmitry Baryshkov
    Cc: Anton Vorontsov
    Cc: Matteo Fortini
    Cc: Krzysztof Helt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • Miles Lane tailing /sys files hit a BUG which Pekka Enberg has tracked
    to my 966c8c12dc9e77f931e2281ba25d2f0244b06949 sprint_symbol(): use
    less stack exposing a bug in slub's list_locations() -
    kallsyms_lookup() writes a 0 to namebuf[KSYM_NAME_LEN-1], but that was
    beyond the end of page provided.

    The 100 slop which list_locations() allows at end of page looks roughly
    enough for all the other stuff it might print after the symbol before
    it checks again: break out KSYM_SYMBOL_LEN earlier than before.

    Latencytop and ftrace and are using KSYM_NAME_LEN buffers where they
    need KSYM_SYMBOL_LEN buffers, and vmallocinfo a 2*KSYM_NAME_LEN buffer
    where it wants a KSYM_SYMBOL_LEN buffer: fix those before anyone copies
    them.

    [akpm@linux-foundation.org: ftrace.h needs module.h]
    Signed-off-by: Hugh Dickins
    Cc: Christoph Lameter
    Cc Miles Lane
    Acked-by: Pekka Enberg
    Acked-by: Steven Rostedt
    Acked-by: Frederic Weisbecker
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • On umount two event will be dispatched to watcher:

    1: inotify_dev_queue_event(.., IN_UNMOUNT,..)
    2: remove_watch(watch, dev)
    ->inotify_dev_queue_event(.., IN_IGNORED, ..)

    But if watcher has IN_ONESHOT bit set then the watcher will be released
    inside first event. Which result in accessing invalid object later. IMHO
    it is not pure regression. This bug wasn't triggered while initial
    inotify interface testing phase because of another bug in IN_ONESHOT
    handling logic :)

    commit ac74c00e499ed276a965e5b5600667d5dc04a84a
    Author: Ulisses Furquim
    Date: Fri Feb 8 04:18:16 2008 -0800
    inotify: fix check for one-shot watches before destroying them
    As the IN_ONESHOT bit is never set when an event is sent we must check it
    in the watch's mask and not in the event's mask.

    TESTCASE:
    mkdir mnt
    mount -ttmpfs none mnt
    mkdir mnt/d
    ./inotify mnt/d&
    umount mnt ## << lockup or crash here

    TESTSOURCE:
    /* gcc -oinotify inotify.c */
    #include
    #include
    #include

    int main(int argc, char **argv)
    {
    char buf[1024];
    struct inotify_event *ie;
    char *p;
    int i;
    ssize_t l;

    p = argv[1];
    i = inotify_init();
    inotify_add_watch(i, p, ~0);

    l = read(i, buf, sizeof(buf));
    printf("read %d bytes\n", l);
    ie = (struct inotify_event *) buf;
    printf("event mask: %d\n", ie->mask);
    return 0;
    }

    Signed-off-by: Dmitri Monakhov
    Cc: John McCutchan
    Cc: Al Viro
    Cc: Robert Love
    Cc: Ulisses Furquim
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dmitri Monakhov
     
  • atomic_long_xchg() is not correctly defined for 32bit arches.

    Signed-off-by: Eric Dumazet
    Cc: Mathieu Desnoyers
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Dumazet
     
  • Since commit 2f007e74bb85b9fc4eab28524052161703300f1a, do_pages_stat()
    gets the page address from user-space and puts the corresponding status
    back while holding the mmap_sem for read. There is no need to hold
    mmap_sem there while some page-faults may occur.

    This patch adds a temporary address and status buffer so as to only
    hold mmap_sem while working on these kernel buffers. This is
    implemented by extracting do_pages_stat_array() out of do_pages_stat().

    Signed-off-by: Brice Goglin
    Cc: Christoph Lameter
    Cc: KAMEZAWA Hiroyuki
    Cc: Nick Piggin
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Brice Goglin
     
  • Signed-off-by: Balaji Rao
    Acked-by: Ben Dooks
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Balaji Rao
     
  • The large pages fix from bcf8039ed45 broke 32-bit pagemap by pulling the
    pagemap entry code out into a function with the wrong return type.
    Pagemap entries are 64 bits on all systems and unsigned long is only 32
    bits on 32-bit systems.

    Signed-off-by: Matt Mackall
    Reported-by: Doug Graham
    Cc: Alexey Dobriyan
    Cc: Dave Hansen
    Cc: [2.6.26.x, 2.6.27.x]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matt Mackall
     
  • Fix a total bootup freeze on ia64.

    Signed-off-by: KAMEZAWA Hiroyuki
    Tested-by: Li Zefan
    Reported-by: Li Zefan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • Fix build error when RTC_INTF_DEV=n:

    drivers/rtc/rtc-twl4030.c:402: error: 'twl4030_rtc_ioctl' undeclared here (not in a function)
    make[3]: *** [drivers/rtc/rtc-twl4030.o] Error 1

    Signed-off-by: Randy Dunlap
    Cc: David Brownell
    Cc: Tony Lindgren
    Cc: Samuel Ortiz
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     
  • Add a call to cancel_work_sync() in fbcon_exit() to cancel any pending
    work in the fbcon workqueue.

    The current implementation of fbcon_exit() sets the fbcon workqueue
    function info->queue.func to NULL, but does not assure that there is no
    work pending when it does so. On occasion, depending on system timing,
    there will still be pending work in the queue when fbcon_exit() is
    called. This results in a null pointer deference when run_workqueue()
    tries to call the queue's work function.

    Fixes errors on shutdown similar to these:

    Console: switching to colour dummy device 80x25
    Unable to handle kernel paging request for data at address 0x00000000

    Signed-off-by: Geoff Levand
    Cc: Krzysztof Helt
    Cc: Geert Uytterhoeven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Geoff Levand
     
  • Currently, lru_add_drain_all() has two version.
    (1) use schedule_on_each_cpu()
    (2) don't use schedule_on_each_cpu()

    Gerald Schaefer reported it doesn't work well on SMP (not NUMA) S390
    machine.

    offline_pages() calls lru_add_drain_all() followed by drain_all_pages().
    While drain_all_pages() works on each cpu, lru_add_drain_all() only runs
    on the current cpu for architectures w/o CONFIG_NUMA. This let us run
    into the BUG_ON(!PageBuddy(page)) in __offline_isolated_pages() during
    memory hotplug stress test on s390. The page in question was still on the
    pcp list, because of a race with lru_add_drain_all() and drain_all_pages()
    on different cpus.

    Actually, Almost machine has CONFIG_UNEVICTABLE_LRU=y. Then almost machine use
    (1) version lru_add_drain_all although the machine is UP.

    Then this ifdef is not valueable.
    simple removing is better.

    Signed-off-by: KOSAKI Motohiro
    Cc: Christoph Lameter
    Cc: Lee Schermerhorn
    Acked-by: Gerald Schaefer
    Cc: Dave Hansen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Revert

    commit e8ced39d5e8911c662d4d69a342b9d053eaaac4e
    Author: Mingming Cao
    Date: Fri Jul 11 19:27:31 2008 -0400

    percpu_counter: new function percpu_counter_sum_and_set

    As described in

    revert "percpu counter: clean up percpu_counter_sum_and_set()"

    the new percpu_counter_sum_and_set() is racy against updates to the
    cpu-local accumulators on other CPUs. Revert that change.

    This means that ext4 will be slow again. But correct.

    Reported-by: Eric Dumazet
    Cc: "David S. Miller"
    Cc: Peter Zijlstra
    Cc: Mingming Cao
    Cc:
    Cc: [2.6.27.x]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • Revert

    commit 1f7c14c62ce63805f9574664a6c6de3633d4a354
    Author: Mingming Cao
    Date: Thu Oct 9 12:50:59 2008 -0400

    percpu counter: clean up percpu_counter_sum_and_set()

    Before this patch we had the following:

    percpu_counter_sum(): return the percpu_counter's value

    percpu_counter_sum_and_set(): return the percpu_counter's value, copying
    that value into the central value and zeroing the per-cpu counters before
    returning.

    After this patch, percpu_counter_sum_and_set() has gone, and
    percpu_counter_sum() gets the old percpu_counter_sum_and_set()
    functionality.

    Problem is, as Eric points out, the old percpu_counter_sum_and_set()
    functionality was racy and wrong. It zeroes out counters on "other" cpus,
    without holding any locks which will prevent races agaist updates from
    those other CPUS.

    This patch reverts 1f7c14c62ce63805f9574664a6c6de3633d4a354. This means
    that percpu_counter_sum_and_set() still has the race, but
    percpu_counter_sum() does not.

    Note that this is not a simple revert - ext4 has since started using
    percpu_counter_sum() for its dirty_blocks counter as well.

    Note that this revert patch changes percpu_counter_sum() semantics.

    Before the patch, a call to percpu_counter_sum() will bring the counter's
    central counter mostly up-to-date, so a following percpu_counter_read()
    will return a close value.

    After this patch, a call to percpu_counter_sum() will leave the counter's
    central accumulator unaltered, so a subsequent call to
    percpu_counter_read() can now return a significantly inaccurate result.

    If there is any code in the tree which was introduced after
    e8ced39d5e8911c662d4d69a342b9d053eaaac4e was merged, and which depends
    upon the new percpu_counter_sum() semantics, that code will break.

    Reported-by: Eric Dumazet
    Cc: "David S. Miller"
    Cc: Peter Zijlstra
    Cc: Mingming Cao
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • We should first delete the counter from percpu_counters list
    before freeing memory, or a percpu_counter_hotcpu_callback()
    could dereference a NULL pointer.

    Signed-off-by: Eric Dumazet
    Acked-by: David S. Miller
    Cc: Peter Zijlstra
    Cc: Mingming Cao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Dumazet
     
  • Add missing id_table to the drivers in subject. Patch is against the
    latest git. It should go in with 2.6.28 if possible, the drivers won't
    work without the id_table bits.

    Signed-off-by: Alessandro Zummo
    Reported-by: Imre Kaloz
    Tested-by: Imre Kaloz
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alessandro Zummo
     
  • Running kmemtraced, which uses splice() on relayfs, causes a hard lock on
    x86-64 SMP. As described by Tom Zanussi:

    It looks like you hit the same problem as described here:

    commit 8191ecd1d14c6914c660dfa007154860a7908857

    splice: fix infinite loop in generic_file_splice_read()

    relay uses the same loop but it never got noticed or fixed.

    Cc: Mathieu Desnoyers
    Tested-by: Pekka Enberg
    Signed-off-by: Tom Zanussi
    Signed-off-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tom Zanussi
     
  • mconsole_init() passed 256 bytes as length in os_create_unix_socket, while
    the sizeof UNIX_PATH_MAX is 108. This patch fixes that problem and avoids
    a big overrun bug reported on UML bootup.

    sockaddr_un.sun_path is UNIX_PATH_MAX long which causes the problem.
    Reported-by: Vikas K Managutte
    Reported-by: Sarvesh Kumar Lal Das
    Signed-off-by: Balbir Singh
    Reviewed-by: Pekka Enberg
    Reviewed-by: WANG Cong
    Cc: Jeff Dike
    Cc: [please check with Jeff]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Balbir Singh
     
  • On second thoughts, this is just going to disturb people while telling us
    things which we already knew.

    Cc: Peter Korsgaard
    Cc: Peter Zijlstra
    Cc: Kay Sievers
    Cc: David Woodhouse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

10 Dec, 2008

4 commits

  • If we have at least one algorithm built-in then it no longer makes
    sense to have the testing framework, and hence cryptomgr to be a
    module. It should be either on or off, i.e., built-in or disabled.

    This just happens to stop a potential runaway modprobe loop that
    seems to trigger on at least one distro.

    With fixes from Evgeniy Polyakov.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • There is a DMA map/ unmap imbalance whenever a block write request
    packet is sent and then dequeued with ohci_cancel_packet. The latter
    may happen frequently if the AR resp tasklet is executed before the AT
    req tasklet for the same transaction.

    Add the missing dma_unmap_single. This fixes
    https://bugzilla.redhat.com/show_bug.cgi?id=475156

    Reported-by: Emmanuel Kowalski
    Tested-by: Emmanuel Kowalski
    Signed-off-by: Stefan Richter

    Stefan Richter
     
  • The patch 6341c39 "tracehook: exec" introduced a small regression in
    2.6.27 regarding binfmt_misc exec event reporting. Since the reporting
    is now done in the common search_binary_handler() function, an exec
    of a misc binary will result in two (or possibly multiple) exec events
    being reported, instead of just a single one, because the misc handler
    contains a recursive call to search_binary_handler.

    To add to the confusion, if PTRACE_O_TRACEEXEC is not active, the multiple
    SIGTRAP signals will in fact cause only a single ptrace intercept, as the
    signals are not queued. However, if PTRACE_O_TRACEEXEC is on, the debugger
    will actually see multiple ptrace intercepts (PTRACE_EVENT_EXEC).

    The test program included below demonstrates the problem.

    This change fixes the bug by calling tracehook_report_exec() only in the
    outermost search_binary_handler() call (bprm->recursion_depth == 0).

    The additional change to restore bprm->recursion_depth after each binfmt
    load_binary call is actually superfluous for this bug, since we test the
    value saved on entry to search_binary_handler(). But it keeps the use of
    of the depth count to its most obvious expected meaning. Depending on what
    binfmt handlers do in certain cases, there could have been false-positive
    tests for recursion limits before this change.

    /* Test program using PTRACE_O_TRACEEXEC.
    This forks and exec's the first argument with the rest of the arguments,
    while ptrace'ing. It expects to see one PTRACE_EVENT_EXEC stop and
    then a successful exit, with no other signals or events in between.

    Test for kernel doing two PTRACE_EVENT_EXEC stops for a binfmt_misc exec:

    $ gcc -g traceexec.c -o traceexec
    $ sudo sh -c 'echo :test:M::foobar::/bin/cat: > /proc/sys/fs/binfmt_misc/register'
    $ echo 'foobar test' > ./foobar
    $ chmod +x ./foobar
    $ ./traceexec ./foobar; echo $?
    ==> good bad
    #include
    #include
    #include
    #include
    #include
    #include

    static void
    wait_for (pid_t child, int expect)
    {
    int status;
    pid_t p = wait (&status);
    if (p != child)
    {
    perror ("wait");
    exit (2);
    }
    if (status != expect)
    {
    fprintf (stderr, "unexpected status %#x != %#x\n", status, expect);
    exit (3);
    }
    }

    int
    main (int argc, char **argv)
    {
    pid_t child = fork ();

    if (child < 0)
    {
    perror ("fork");
    return 127;
    }
    else if (child == 0)
    {
    ptrace (PTRACE_TRACEME);
    raise (SIGUSR1);
    execv (argv[1], &argv[1]);
    perror ("execve");
    _exit (127);
    }

    wait_for (child, W_STOPCODE (SIGUSR1));

    if (ptrace (PTRACE_SETOPTIONS, child,
    0L, (void *) (long) PTRACE_O_TRACEEXEC) != 0)
    {
    perror ("PTRACE_SETOPTIONS");
    return 4;
    }

    if (ptrace (PTRACE_CONT, child, 0L, 0L) != 0)
    {
    perror ("PTRACE_CONT");
    return 5;
    }

    wait_for (child, W_STOPCODE (SIGTRAP | (PTRACE_EVENT_EXEC << 8)));

    if (ptrace (PTRACE_CONT, child, 0L, 0L) != 0)
    {
    perror ("PTRACE_CONT");
    return 6;
    }

    wait_for (child, W_EXITCODE (0, 0));

    return 0;
    }

    Reported-by: Arnd Bergmann
    CC: Ulrich Weigand
    Signed-off-by: Roland McGrath

    Roland McGrath
     
  • Makes a Compaq 6735s boot reliably again. It used to hang in the loop
    on some boots. Give the link one second to train, otherwise break out
    of the loop and reset the previously set clock bits.

    Cc: stable@vger.kernel.org
    Signed-off-by: Thomas Renninger
    Signed-off-by: Shaohua Li
    Signed-off-by: Matthew Garrett
    Signed-off-by: Jesse Barnes

    Thomas Renninger