The patch titled revert "Support piping into commands in /proc/sys/kernel/core_pattern" has been removed from the -mm tree. Its filename is revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern.patch This patch was dropped because it is obsolete ------------------------------------------------------ Subject: revert "Support piping into commands in /proc/sys/kernel/core_pattern" From: Andrew Morton <akpm@xxxxxxxx> Revert d025c9db7f31fc0554ce7fb2dfc78d35a77f3487 due to http://bugzilla.kernel.org/show_bug.cgi?id=7358 - it broke regular core dumping. Cc: Daniel Jacobowitz <drow@xxxxxxxxx> Cc: Andi Kleen <ak@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- fs/binfmt_elf.c | 75 +++++++++++++++++++--------------------------- fs/exec.c | 23 +++----------- kernel/kmod.c | 4 -- kernel/sysctl.c | 2 - 4 files changed, 37 insertions(+), 67 deletions(-) diff -puN fs/binfmt_elf.c~revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern fs/binfmt_elf.c --- a/fs/binfmt_elf.c~revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern +++ a/fs/binfmt_elf.c @@ -1151,23 +1151,11 @@ static int dump_write(struct file *file, static int dump_seek(struct file *file, loff_t off) { - if (file->f_op->llseek && file->f_op->llseek != no_llseek) { - if (file->f_op->llseek(file, off, 1) != off) + if (file->f_op->llseek) { + if (file->f_op->llseek(file, off, 0) != off) return 0; - } else { - char *buf = (char *)get_zeroed_page(GFP_KERNEL); - if (!buf) - return 0; - while (off > 0) { - unsigned long n = off; - if (n > PAGE_SIZE) - n = PAGE_SIZE; - if (!dump_write(file, buf, n)) - return 0; - off -= n; - } - free_page((unsigned long)buf); - } + } else + file->f_pos = off; return 1; } @@ -1215,35 +1203,30 @@ static int notesize(struct memelfnote *e return sz; } -#define DUMP_WRITE(addr, nr, foffset) \ - do { if (!dump_write(file, (addr), (nr))) return 0; *foffset += (nr); } while(0) - -static int alignfile(struct file *file, loff_t *foffset) -{ - char buf[4] = { 0, }; - DUMP_WRITE(buf, roundup(*foffset, 4) - *foffset, foffset); - return 1; -} +#define DUMP_WRITE(addr, nr) \ + do { if (!dump_write(file, (addr), (nr))) return 0; } while(0) +#define DUMP_SEEK(off) \ + do { if (!dump_seek(file, (off))) return 0; } while(0) -static int writenote(struct memelfnote *men, struct file *file, - loff_t *foffset) +static int writenote(struct memelfnote *men, struct file *file) { struct elf_note en; + en.n_namesz = strlen(men->name) + 1; en.n_descsz = men->datasz; en.n_type = men->type; - DUMP_WRITE(&en, sizeof(en), foffset); - DUMP_WRITE(men->name, en.n_namesz, foffset); - if (!alignfile(file, foffset)) - return 0; - DUMP_WRITE(men->data, men->datasz, foffset); - if (!alignfile(file, foffset)) - return 0; + DUMP_WRITE(&en, sizeof(en)); + DUMP_WRITE(men->name, en.n_namesz); + /* XXX - cast from long long to long to avoid need for libgcc.a */ + DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */ + DUMP_WRITE(men->data, men->datasz); + DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */ return 1; } #undef DUMP_WRITE +#undef DUMP_SEEK #define DUMP_WRITE(addr, nr) \ if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \ @@ -1443,7 +1426,7 @@ static int elf_core_dump(long signr, str int i; struct vm_area_struct *vma; struct elfhdr *elf = NULL; - loff_t offset = 0, dataoff, foffset; + loff_t offset = 0, dataoff; unsigned long limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; int numnote; struct memelfnote *notes = NULL; @@ -1586,8 +1569,7 @@ static int elf_core_dump(long signr, str DUMP_WRITE(&phdr, sizeof(phdr)); } - foffset = offset; - + /* Page-align dumped data */ dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); /* Write program headers for segments dump */ @@ -1612,7 +1594,6 @@ static int elf_core_dump(long signr, str phdr.p_align = ELF_EXEC_PAGESIZE; DUMP_WRITE(&phdr, sizeof(phdr)); - foffset += sizeof(phdr); } #ifdef ELF_CORE_WRITE_EXTRA_PHDRS @@ -1621,7 +1602,7 @@ static int elf_core_dump(long signr, str /* write out the notes section */ for (i = 0; i < numnote; i++) - if (!writenote(notes + i, file, &foffset)) + if (!writenote(notes + i, file)) goto end_coredump; /* write out the thread status notes section */ @@ -1630,12 +1611,11 @@ static int elf_core_dump(long signr, str list_entry(t, struct elf_thread_status, list); for (i = 0; i < tmp->num_notes; i++) - if (!writenote(&tmp->notes[i], file, &foffset)) + if (!writenote(&tmp->notes[i], file)) goto end_coredump; } - /* Align to page */ - DUMP_SEEK(dataoff - foffset); + DUMP_SEEK(dataoff); for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) { unsigned long addr; @@ -1651,10 +1631,10 @@ static int elf_core_dump(long signr, str if (get_user_pages(current, current->mm, addr, 1, 0, 1, &page, &vma) <= 0) { - DUMP_SEEK(PAGE_SIZE); + DUMP_SEEK(file->f_pos + PAGE_SIZE); } else { if (page == ZERO_PAGE(addr)) { - DUMP_SEEK(PAGE_SIZE); + DUMP_SEEK(file->f_pos + PAGE_SIZE); } else { void *kaddr; flush_cache_page(vma, addr, @@ -1678,6 +1658,13 @@ static int elf_core_dump(long signr, str ELF_CORE_WRITE_EXTRA_DATA; #endif + if (file->f_pos != offset) { + /* Sanity check */ + printk(KERN_WARNING + "elf_core_dump: file->f_pos (%Ld) != offset (%Ld)\n", + file->f_pos, offset); + } + end_coredump: set_fs(fs); diff -puN fs/exec.c~revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern fs/exec.c --- a/fs/exec.c~revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern +++ a/fs/exec.c @@ -58,7 +58,7 @@ #endif int core_uses_pid; -char core_pattern[128] = "core"; +char core_pattern[65] = "core"; int suid_dumpable = 0; EXPORT_SYMBOL(suid_dumpable); @@ -1463,7 +1463,6 @@ int do_coredump(long signr, int exit_cod int retval = 0; int fsuid = current->fsuid; int flag = 0; - int ispipe = 0; binfmt = current->binfmt; if (!binfmt || !binfmt->core_dump) @@ -1505,34 +1504,22 @@ int do_coredump(long signr, int exit_cod lock_kernel(); format_corename(corename, core_pattern, signr); unlock_kernel(); - if (corename[0] == '|') { - /* SIGPIPE can happen, but it's just never processed */ - if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) { - printk(KERN_INFO "Core dump to %s pipe failed\n", - corename); - goto fail_unlock; - } - ispipe = 1; - } else - file = filp_open(corename, - O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE, 0600); + file = filp_open(corename, O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, 0600); if (IS_ERR(file)) goto fail_unlock; inode = file->f_dentry->d_inode; if (inode->i_nlink > 1) goto close_fail; /* multiple links - don't dump */ - if (!ispipe && d_unhashed(file->f_dentry)) + if (d_unhashed(file->f_dentry)) goto close_fail; - /* AK: actually i see no reason to not allow this for named pipes etc., - but keep the previous behaviour for now. */ - if (!ispipe && !S_ISREG(inode->i_mode)) + if (!S_ISREG(inode->i_mode)) goto close_fail; if (!file->f_op) goto close_fail; if (!file->f_op->write) goto close_fail; - if (!ispipe && do_truncate(file->f_dentry, 0, 0, file) != 0) + if (do_truncate(file->f_dentry, 0, 0, file) != 0) goto close_fail; retval = binfmt->core_dump(signr, regs, file); diff -puN kernel/kmod.c~revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern kernel/kmod.c --- a/kernel/kmod.c~revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern +++ a/kernel/kmod.c @@ -33,7 +33,6 @@ #include <linux/mount.h> #include <linux/kernel.h> #include <linux/init.h> -#include <linux/resource.h> #include <asm/uaccess.h> extern int max_threads; @@ -157,9 +156,6 @@ static int ____call_usermodehelper(void FD_SET(0, fdt->open_fds); FD_CLR(0, fdt->close_on_exec); spin_unlock(&f->file_lock); - - /* and disallow core files too */ - current->signal->rlim[RLIMIT_CORE] = (struct rlimit){0, 0}; } /* We can run anywhere, unlike our parent keventd(). */ diff -puN kernel/sysctl.c~revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern kernel/sysctl.c --- a/kernel/sysctl.c~revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern +++ a/kernel/sysctl.c @@ -340,7 +340,7 @@ static ctl_table kern_table[] = { .ctl_name = KERN_CORE_PATTERN, .procname = "core_pattern", .data = core_pattern, - .maxlen = 128, + .maxlen = 64, .mode = 0644, .proc_handler = &proc_dostring, .strategy = &sysctl_string, _ Patches currently in -mm which might be from akpm@xxxxxxxx are origin.patch revert-pci-quirk-for-ibm-dock-ii-cardbus-controllers.patch remove_mapping-fix.patch proc_numbuf-is-wrong.patch rename-net_random-to-random32-fixes.patch revert-support-piping-into-commands-in-proc-sys-kernel-core_pattern.patch git-acpi.patch i386-acpi-build-fix.patch acpi-asus-s3-resume-fix.patch sony_apci-resume.patch git-cifs-fixup.patch cifs-kconfig-dont-select-connector.patch git-dvb-build-fix.patch w1-kconfig-fix.patch git-geode-fixup.patch git-gfs2.patch git-infiniband.patch git-input-fixup.patch git-input-build-fix.patch git-libata-all.patch mtd-maps-support-for-bios-flash-chips-on-intel-esb2-southbridge.patch git-netdev-all.patch libphy-dont-do-that.patch drivers-net-ns83820c-add-paramter-to-disable-auto.patch git-pcmcia-fixup.patch git-serial-fixup.patch git-scsi-target-fixup.patch git-scsi-target-vs-git-block.patch fix-gregkh-usb-usbatm-fix-tiny-race.patch xpad-dance-pad-support.patch git-watchdog.patch x86_64-dump_trace-atomicity-fix.patch spinlock-debug-all-cpu-backtrace.patch spinlock-debug-all-cpu-backtrace-fix.patch spinlock-debug-all-cpu-backtrace-fix-2.patch spinlock-debug-all-cpu-backtrace-fix-3.patch xfs-rename-uio_read.patch touchkit-ps-2-touchscreen-driver-regs-fix.patch get-rid-of-zone_table.patch new-scheme-to-preempt-swap-token-tidy.patch radix-tree-rcu-lockless-readside.patch acx1xx-wireless-driver.patch swsusp-add-resume_offset-command-line-parameter-rev-2.patch deprecate-smbfs-in-favour-of-cifs.patch edac-new-opteron-athlon64-memory-controller-driver.patch add-address_space_operationsbatch_write.patch add-config_headers_check-option-to-automatically-run-make-headers_check-nobble.patch kbuild-dont-put-temp-files-in-the-source-tree.patch lockdep-annotate-nfs-nfsd-in-kernel-sockets-tidy.patch bug-test-1.patch log2-implement-a-general-integer-log2-facility-in-the-kernel-fix.patch fs-cache-provide-a-filesystem-specific-syncable-page-bit-ext4.patch fs-cache-make-kafs-use-fs-cache-fix.patch fs-cache-make-kafs-use-fs-cache-vs-streamline-generic_file_-interfaces-and-filemap.patch nfs-use-local-caching-12-fix.patch fs-cache-cachefiles-a-cache-that-backs-onto-a-mounted-filesystem-log2-fix.patch swap_prefetch-vs-zoned-counters.patch readahead-sysctl-parameters.patch make-copy_from_user_inatomic-not-zero-the-tail-on-i386-vs-reiser4.patch make-kmem_cache_destroy-return-void-reiser4.patch reiser4-hardirq-include-fix.patch reiser4-run-truncate_inode_pages-in-reiser4_delete_inode.patch reiser4-get_sb_dev-fix.patch reiser4-vs-zoned-allocator.patch reiser4-rename-generic_sounding_globalspatch-fix.patch hpt3xx-rework-rate-filtering-tidy.patch gtod-persistent-clock-support-i386.patch hrtimers-state-tracking.patch clockevents-drivers-for-i386.patch gtod-mark-tsc-unusable-for-highres-timers.patch round_jiffies-infrastructure-fix.patch kevent-core-files-fix.patch kevent-core-files-s390-hack.patch kevent-socket-notifications-fix-2.patch kevent-socket-notifications-fix-4.patch kevent-timer-notifications-fix.patch nr_blockdev_pages-in_interrupt-warning.patch device-suspend-debug.patch mutex-subsystem-synchro-test-module-fix.patch slab-leaks3-default-y.patch x86-kmap_atomic-debugging.patch restore-rogue-readahead-printk.patch put_bh-debug.patch acpi_format_exception-debug.patch warn-if-setting-non-uptodate-page-dirty.patch jmicron-warning-fix.patch squash-ipc-warnings.patch squash-udf-warnings.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html