From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Dan Aloni <alonid@stratoscale.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Denys Vlasenko <vda.linux@googlemail.com>,
Martin MOKREJS <mmokrejs@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [ 044/110] fs/binfmt_elf.c: prevent a coredump with a large vm_map_count from Oopsing
Date: Fri, 11 Oct 2013 12:38:24 -0700 [thread overview]
Message-ID: <20131011193812.624643080@linuxfoundation.org> (raw)
In-Reply-To: <20131011193807.584188672@linuxfoundation.org>
3.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Aloni <alonid@stratoscale.com>
commit 72023656961b8c81a168a7a6762d589339d0d7ec upstream.
A high setting of max_map_count, and a process core-dumping with a large
enough vm_map_count could result in an NT_FILE note not being written,
and the kernel crashing immediately later because it has assumed
otherwise.
Reproduction of the oops-causing bug described here:
https://lkml.org/lkml/2013/8/30/50
Rge ussue originated in commit 2aa362c49c31 ("coredump: extend core dump
note section to contain file names of mapped file") from Oct 4, 2012.
This patch make that section optional in that case. fill_files_note()
should signify the error, and also let the info struct in
elf_core_dump() be zero-initialized so that we can check for the
optionally written note.
[akpm@linux-foundation.org: avoid abusing E2BIG, remove a couple of not-really-needed local variables]
[akpm@linux-foundation.org: fix sparse warning]
Signed-off-by: Dan Aloni <alonid@stratoscale.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Reported-by: Martin MOKREJS <mmokrejs@gmail.com>
Tested-by: Martin MOKREJS <mmokrejs@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/binfmt_elf.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1415,7 +1415,7 @@ static void fill_siginfo_note(struct mem
* long file_ofs
* followed by COUNT filenames in ASCII: "FILE1" NUL "FILE2" NUL...
*/
-static void fill_files_note(struct memelfnote *note)
+static int fill_files_note(struct memelfnote *note)
{
struct vm_area_struct *vma;
unsigned count, size, names_ofs, remaining, n;
@@ -1430,11 +1430,11 @@ static void fill_files_note(struct memel
names_ofs = (2 + 3 * count) * sizeof(data[0]);
alloc:
if (size >= MAX_FILE_NOTE_SIZE) /* paranoia check */
- goto err;
+ return -EINVAL;
size = round_up(size, PAGE_SIZE);
data = vmalloc(size);
if (!data)
- goto err;
+ return -ENOMEM;
start_end_ofs = data + 2;
name_base = name_curpos = ((char *)data) + names_ofs;
@@ -1487,7 +1487,7 @@ static void fill_files_note(struct memel
size = name_curpos - (char *)data;
fill_note(note, "CORE", NT_FILE, size, data);
- err: ;
+ return 0;
}
#ifdef CORE_DUMP_USE_REGSET
@@ -1688,8 +1688,8 @@ static int fill_note_info(struct elfhdr
fill_auxv_note(&info->auxv, current->mm);
info->size += notesize(&info->auxv);
- fill_files_note(&info->files);
- info->size += notesize(&info->files);
+ if (fill_files_note(&info->files) == 0)
+ info->size += notesize(&info->files);
return 1;
}
@@ -1721,7 +1721,8 @@ static int write_note_info(struct elf_no
return 0;
if (first && !writenote(&info->auxv, file, foffset))
return 0;
- if (first && !writenote(&info->files, file, foffset))
+ if (first && info->files.data &&
+ !writenote(&info->files, file, foffset))
return 0;
for (i = 1; i < info->thread_notes; ++i)
@@ -1808,6 +1809,7 @@ static int elf_dump_thread_status(long s
struct elf_note_info {
struct memelfnote *notes;
+ struct memelfnote *notes_files;
struct elf_prstatus *prstatus; /* NT_PRSTATUS */
struct elf_prpsinfo *psinfo; /* NT_PRPSINFO */
struct list_head thread_list;
@@ -1898,9 +1900,12 @@ static int fill_note_info(struct elfhdr
fill_siginfo_note(info->notes + 2, &info->csigdata, siginfo);
fill_auxv_note(info->notes + 3, current->mm);
- fill_files_note(info->notes + 4);
+ info->numnote = 4;
- info->numnote = 5;
+ if (fill_files_note(info->notes + info->numnote) == 0) {
+ info->notes_files = info->notes + info->numnote;
+ info->numnote++;
+ }
/* Try to dump the FPU. */
info->prstatus->pr_fpvalid = elf_core_copy_task_fpregs(current, regs,
@@ -1962,8 +1967,9 @@ static void free_note_info(struct elf_no
kfree(list_entry(tmp, struct elf_thread_status, list));
}
- /* Free data allocated by fill_files_note(): */
- vfree(info->notes[4].data);
+ /* Free data possibly allocated by fill_files_note(): */
+ if (info->notes_files)
+ vfree(info->notes_files->data);
kfree(info->prstatus);
kfree(info->psinfo);
@@ -2046,7 +2052,7 @@ static int elf_core_dump(struct coredump
struct vm_area_struct *vma, *gate_vma;
struct elfhdr *elf = NULL;
loff_t offset = 0, dataoff, foffset;
- struct elf_note_info info;
+ struct elf_note_info info = { };
struct elf_phdr *phdr4note = NULL;
struct elf_shdr *shdr4extnum = NULL;
Elf_Half e_phnum;
next prev parent reply other threads:[~2013-10-11 19:38 UTC|newest]
Thread overview: 114+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-11 19:37 [ 000/110] 3.10.16-stable review Greg Kroah-Hartman
2013-10-11 19:37 ` [ 001/110] mwifiex: fix memory corruption when unsetting multicast list Greg Kroah-Hartman
2013-10-11 19:37 ` [ 002/110] cpqarray: fix info leak in ida_locked_ioctl() Greg Kroah-Hartman
2013-10-11 19:37 ` [ 003/110] cciss: fix info leak in cciss_ioctl32_passthru() Greg Kroah-Hartman
2013-10-11 19:37 ` [ 004/110] HID: fix data access in implement() Greg Kroah-Hartman
2013-10-11 19:37 ` [ 005/110] HID: fix unused rsize usage Greg Kroah-Hartman
2013-10-11 19:37 ` [ 006/110] caif: Add missing braces to multiline if in cfctrl_linkup_request Greg Kroah-Hartman
2013-10-11 19:37 ` [ 007/110] tcp: Add missing braces to do_tcp_setsockopt Greg Kroah-Hartman
2013-10-11 19:37 ` [ 008/110] ipv6/exthdrs: accept tlv which includes only padding Greg Kroah-Hartman
2013-10-11 19:37 ` [ 009/110] net: fib: fib6_add: fix potential NULL pointer dereference Greg Kroah-Hartman
2013-10-11 19:37 ` [ 010/110] net: sctp: fix bug in sctp_poll for SOCK_SELECT_ERR_QUEUE Greg Kroah-Hartman
2013-10-11 19:37 ` [ 011/110] net: sctp: fix smatch warning in sctp_send_asconf_del_ip Greg Kroah-Hartman
2013-10-11 19:37 ` [ 012/110] net: fix multiqueue selection Greg Kroah-Hartman
2013-10-11 19:37 ` [ 013/110] net: flow_dissector: fix thoff for IPPROTO_AH Greg Kroah-Hartman
2013-10-11 19:37 ` [ 014/110] net_sched: htb: fix a typo in htb_change_class() Greg Kroah-Hartman
2013-10-11 19:37 ` [ 015/110] r8169: enforce RX_MULTI_EN for the 8168f Greg Kroah-Hartman
2013-10-11 19:37 ` [ 016/110] netpoll: Should handle ETH_P_ARP other than ETH_P_IP in netpoll_neigh_reply Greg Kroah-Hartman
2013-10-11 19:37 ` [ 017/110] netpoll: fix NULL pointer dereference in netpoll_cleanup Greg Kroah-Hartman
2013-10-11 19:37 ` [ 018/110] tuntap: correctly handle error in tun_set_iff() Greg Kroah-Hartman
2013-10-11 19:37 ` [ 019/110] net: sctp: fix ipv6 ipsec encryption bug in sctp_v6_xmit Greg Kroah-Hartman
2013-10-11 19:38 ` [ 020/110] xen-netback: count number required slots for an skb more carefully Greg Kroah-Hartman
2013-10-11 19:38 ` [ 021/110] resubmit bridge: fix message_age_timer calculation Greg Kroah-Hartman
2013-10-11 19:38 ` [ 022/110] bridge: Clamp forward_delay when enabling STP Greg Kroah-Hartman
2013-10-11 19:38 ` [ 023/110] bridge: use br_port_get_rtnl within rtnl lock Greg Kroah-Hartman
2013-10-11 19:38 ` [ 024/110] bridge: fix NULL pointer deref of br_port_get_rcu Greg Kroah-Hartman
2013-10-11 19:38 ` [ 025/110] ip6_tunnels: raddr and laddr are inverted in nl msg Greg Kroah-Hartman
2013-10-11 19:38 ` [ 026/110] net: sctp: rfc4443: do not report ICMP redirects to user space Greg Kroah-Hartman
2013-10-11 19:38 ` [ 027/110] net:dccp: " Greg Kroah-Hartman
2013-10-11 19:38 ` [ 028/110] ip: use ip_hdr() in __ip_make_skb() to retrieve IP header Greg Kroah-Hartman
2013-10-11 19:38 ` [ 029/110] ip: generate unique IP identificator if local fragmentation is allowed Greg Kroah-Hartman
2013-10-11 19:38 ` [ 030/110] ipv6: udp packets following an UFO enqueued packet need also be handled by UFO Greg Kroah-Hartman
2013-10-11 19:38 ` [ 031/110] via-rhine: fix VLAN priority field (PCP, IEEE 802.1p) Greg Kroah-Hartman
2013-10-11 19:38 ` [ 032/110] IPv6 NAT: Do not drop DNATed 6to4/6rd packets Greg Kroah-Hartman
2013-10-11 19:38 ` [ 033/110] net: net_secret should not depend on TCP Greg Kroah-Hartman
2013-10-11 19:38 ` [ 034/110] dm9601: fix IFF_ALLMULTI handling Greg Kroah-Hartman
2013-10-11 19:38 ` [ 035/110] bonding: Fix broken promiscuity reference counting issue Greg Kroah-Hartman
2013-10-11 19:38 ` [ 036/110] ipv6: gre: correct calculation of max_headroom Greg Kroah-Hartman
2013-10-11 19:38 ` [ 037/110] ipv4 igmp: use in_dev_put in timer handlers instead of __in_dev_put Greg Kroah-Hartman
2013-10-11 19:38 ` [ 038/110] ipv6 mcast: use in6_dev_put in timer handlers instead of __in6_dev_put Greg Kroah-Hartman
2013-10-11 19:38 ` [ 039/110] ll_temac: Reset dma descriptors indexes on ndo_open Greg Kroah-Hartman
2013-10-11 19:38 ` [ 040/110] ip_tunnel: Fix a memory corruption in ip_tunnel_xmit Greg Kroah-Hartman
2013-10-11 19:38 ` [ 041/110] sit: allow to use rtnl ops on fb tunnel Greg Kroah-Hartman
2013-10-11 19:38 ` [ 042/110] ip6tnl: " Greg Kroah-Hartman
2013-10-11 19:38 ` [ 043/110] avr32: fix clockevents kernel warning Greg Kroah-Hartman
2013-10-11 19:38 ` Greg Kroah-Hartman [this message]
2013-10-11 19:38 ` [ 045/110] gpio/omap: maintain GPIO and IRQ usage separately Greg Kroah-Hartman
2013-10-11 19:38 ` [ 046/110] gpio/omap: auto-setup a GPIO when used as an IRQ Greg Kroah-Hartman
2013-10-11 19:38 ` [ 047/110] ASoC: max98095: a couple array underflows Greg Kroah-Hartman
2013-10-11 19:38 ` [ 048/110] ASoC: 88pm860x: array overflow in snd_soc_put_volsw_2r_st() Greg Kroah-Hartman
2013-10-11 19:38 ` [ 049/110] ASoC: ab8500-codec: info leak in anc_status_control_put() Greg Kroah-Hartman
2013-10-11 19:38 ` [ 050/110] powerpc/iommu: Use GFP_KERNEL instead of GFP_ATOMIC in iommu_init_table() Greg Kroah-Hartman
2013-10-11 19:38 ` [ 051/110] powerpc/perf: Fix handling of FAB events Greg Kroah-Hartman
2013-10-11 19:38 ` [ 052/110] powerpc/tm: Switch out userspace PPR and DSCR sooner Greg Kroah-Hartman
2013-10-11 19:38 ` [ 053/110] powerpc/vio: Fix modalias_show return values Greg Kroah-Hartman
2013-10-11 19:38 ` [ 054/110] powerpc: Fix parameter clobber in csum_partial_copy_generic() Greg Kroah-Hartman
2013-10-11 19:38 ` [ 055/110] powerpc/sysfs: Disable writing to PURR in guest mode Greg Kroah-Hartman
2013-10-11 19:38 ` [ 056/110] powerpc: Restore registers on error exit from csum_partial_copy_generic() Greg Kroah-Hartman
2013-10-11 19:38 ` [ 057/110] fuse: wait for writeback in fuse_file_fallocate() Greg Kroah-Hartman
2013-10-11 19:38 ` [ 058/110] fuse: fix fallocate vs. ftruncate race Greg Kroah-Hartman
2013-10-11 19:38 ` [ 059/110] brcmfmac: obtain platform data upon module initialization Greg Kroah-Hartman
2013-10-11 19:38 ` [ 060/110] Bluetooth: Fix security level for peripheral role Greg Kroah-Hartman
2013-10-11 19:38 ` [ 061/110] Bluetooth: Fix encryption key size " Greg Kroah-Hartman
2013-10-11 19:38 ` [ 062/110] Bluetooth: Add a new PID/VID 0cf3/e005 for AR3012 Greg Kroah-Hartman
2013-10-11 19:38 ` [ 063/110] Bluetooth: Add support for BCM20702A0 [0b05, 17cb] Greg Kroah-Hartman
2013-10-11 19:38 ` [ 064/110] Bluetooth: Introduce a new HCI_RFKILLED flag Greg Kroah-Hartman
2013-10-11 19:38 ` [ 065/110] Bluetooth: Fix rfkill functionality during the HCI setup stage Greg Kroah-Hartman
2013-10-11 19:38 ` [ 066/110] nilfs2: fix issue with race condition of competition between segments for dirty blocks Greg Kroah-Hartman
2013-10-11 19:38 ` [ 067/110] esp_scsi: Fix tag state corruption when autosensing Greg Kroah-Hartman
2013-10-11 19:38 ` [ 068/110] sparc64: Fix ITLB handler of null page Greg Kroah-Hartman
2013-10-11 19:38 ` [ 069/110] sparc64: Remove RWSEM export leftovers Greg Kroah-Hartman
2013-10-11 19:38 ` [ 070/110] sparc64: Fix buggy strlcpy() conversion in ldom_reboot() Greg Kroah-Hartman
2013-10-11 19:38 ` [ 071/110] sparc: fix ldom_reboot buffer overflow harder Greg Kroah-Hartman
2013-10-11 19:38 ` [ 072/110] sparc64: Fix off by one in trampoline TLB mapping installation loop Greg Kroah-Hartman
2013-10-11 19:38 ` [ 073/110] sparc64: Fix not SRAed %o5 in 32-bit traced syscall Greg Kroah-Hartman
2013-10-11 19:38 ` [ 074/110] sparc32: Fix exit flag passed from traced sys_sigreturn Greg Kroah-Hartman
2013-10-11 19:38 ` [ 075/110] mm: Fix generic hugetlb pte check return type Greg Kroah-Hartman
2013-10-11 19:38 ` [ 076/110] mm/bounce.c: fix a regression where MS_SNAP_STABLE (stable pages snapshotting) was ignored Greg Kroah-Hartman
2013-10-11 19:38 ` [ 077/110] kernel/kmod.c: check for NULL in call_usermodehelper_exec() Greg Kroah-Hartman
2013-10-11 22:36 ` Tetsuo Handa
2013-10-11 19:38 ` [ 078/110] staging: comedi: ni_65xx: (bug fix) confine insn_bits to one subdevice Greg Kroah-Hartman
2013-10-11 19:38 ` [ 079/110] NFSv4.1: nfs4_fl_prepare_ds - fix bugs when the connect attempt fails Greg Kroah-Hartman
2013-10-11 19:39 ` [ 080/110] mwifiex: fix NULL pointer dereference in usb suspend handler Greg Kroah-Hartman
2013-10-11 19:39 ` [ 081/110] mwifiex: fix hang issue for USB chipsets Greg Kroah-Hartman
2013-10-11 19:39 ` [ 082/110] mwifiex: fix PCIe hs_cfg cancel cmd timeout Greg Kroah-Hartman
2013-10-11 19:39 ` [ 083/110] USB: serial: option: Ignore card reader interface on Huawei E1750 Greg Kroah-Hartman
2013-10-11 19:39 ` [ 084/110] xen/hvc: allow xenboot console to be used again Greg Kroah-Hartman
2013-10-11 19:39 ` [ 085/110] ib_srpt: Destroy cm_id before destroying QP Greg Kroah-Hartman
2013-10-11 19:39 ` [ 086/110] ib_srpt: always set response for task management Greg Kroah-Hartman
2013-10-11 19:39 ` [ 087/110] rtlwifi: Align private space in rtl_priv struct Greg Kroah-Hartman
2013-10-11 19:39 ` [ 088/110] p54usb: add USB ID for Corega WLUSB2GTST USB adapter Greg Kroah-Hartman
2013-10-11 19:39 ` [ 089/110] mm: avoid reinserting isolated balloon pages into LRU lists Greg Kroah-Hartman
2013-10-11 19:39 ` [ 090/110] iscsi-target: Only perform wait_for_tasks when performing shutdown Greg Kroah-Hartman
2013-10-11 19:39 ` [ 091/110] net: Update the sysctl permissions handler to test effective uid/gid Greg Kroah-Hartman
2013-10-11 19:39 ` [ 092/110] irq: Force hardirq exits softirq processing on its own stack Greg Kroah-Hartman
2013-10-11 19:39 ` [ 093/110] Revert "drm/radeon: add missing hdmi callbacks for rv6xx" Greg Kroah-Hartman
2013-10-11 19:39 ` [ 094/110] dmaengine: imx-dma: fix lockdep issue between irqhandler and tasklet Greg Kroah-Hartman
2013-10-11 19:39 ` [ 095/110] dmaengine: imx-dma: fix callback path in tasklet Greg Kroah-Hartman
2013-10-11 19:39 ` [ 096/110] dmaengine: imx-dma: fix slow path issue in prep_dma_cyclic Greg Kroah-Hartman
2013-10-11 19:39 ` [ 097/110] ACPI / IPMI: Fix atomic context requirement of ipmi_msg_handler() Greg Kroah-Hartman
2013-10-11 19:39 ` [ 098/110] xfs: fix node forward in xfs_node_toosmall Greg Kroah-Hartman
2013-10-11 19:39 ` [ 099/110] drm/nouveau/bios/init: stub opcode 0xaa Greg Kroah-Hartman
2013-10-11 19:39 ` [ 100/110] ALSA: hda - Fix GPIO for Acer Aspire 3830TG Greg Kroah-Hartman
2013-10-11 19:39 ` [ 101/110] tile: use a more conservative __my_cpu_offset in CONFIG_PREEMPT Greg Kroah-Hartman
2013-10-11 19:39 ` [ 102/110] s390: fix system call restart after inferior call Greg Kroah-Hartman
2013-10-11 19:39 ` [ 103/110] Btrfs: change how we queue blocks for backref checking Greg Kroah-Hartman
2013-10-11 19:39 ` [ 104/110] Btrfs: skip subvol entries when checking if weve created a dir already Greg Kroah-Hartman
2013-10-11 19:39 ` [ 105/110] Btrfs: remove ourselves from the cluster list under lock Greg Kroah-Hartman
2013-10-11 19:39 ` [ 106/110] HID: roccat: add support for KonePureOptical v2 Greg Kroah-Hartman
2013-10-11 19:39 ` [ 107/110] HID: uhid: add devname module alias Greg Kroah-Hartman
2013-10-11 19:39 ` [ 108/110] HID: uhid: allocate static minor Greg Kroah-Hartman
2013-10-11 19:39 ` [ 109/110] net: qmi_wwan: add new Qualcomm devices Greg Kroah-Hartman
2013-10-11 19:39 ` [ 110/110] bcache: Fix a null ptr deref regression Greg Kroah-Hartman
2013-10-11 21:49 ` [ 000/110] 3.10.16-stable review Guenter Roeck
2013-10-11 22:08 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131011193812.624643080@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=alonid@stratoscale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mmokrejs@gmail.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=vda.linux@googlemail.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).