mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.11 08/93] net: filter: s390: fix JIT address randomization
Date: Mon, 23 Jun 2014 14:01:47 +0100	[thread overview]
Message-ID: <1403528592-2163-9-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1403528592-2163-1-git-send-email-luis.henriques@canonical.com>

3.11.10.12 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Heiko Carstens <heiko.carstens@de.ibm.com>

commit e84d2f8d2ae33c8215429824e1ecf24cbca9645e upstream.

This is the s390 variant of Alexei's JIT bug fix.
(patch description below stolen from Alexei's patch)

bpf_alloc_binary() adds 128 bytes of room to JITed program image
and rounds it up to the nearest page size. If image size is close
to page size (like 4000), it is rounded to two pages:
round_up(4000 + 4 + 128) == 8192
then 'hole' is computed as 8192 - (4000 + 4) = 4188
If prandom_u32() % hole selects a number >= PAGE_SIZE - sizeof(*header)
then kernel will crash during bpf_jit_free():

kernel BUG at arch/x86/mm/pageattr.c:887!
Call Trace:
 [<ffffffff81037285>] change_page_attr_set_clr+0x135/0x460
 [<ffffffff81694cc0>] ? _raw_spin_unlock_irq+0x30/0x50
 [<ffffffff810378ff>] set_memory_rw+0x2f/0x40
 [<ffffffffa01a0d8d>] bpf_jit_free_deferred+0x2d/0x60
 [<ffffffff8106bf98>] process_one_work+0x1d8/0x6a0
 [<ffffffff8106bf38>] ? process_one_work+0x178/0x6a0
 [<ffffffff8106c90c>] worker_thread+0x11c/0x370

since bpf_jit_free() does:
  unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
  struct bpf_binary_header *header = (void *)addr;
to compute start address of 'bpf_binary_header'
and header->pages will pass junk to:
  set_memory_rw(addr, header->pages);

Fix it by making sure that &header->image[prandom_u32() % hole] and &header
are in the same page.

Fixes: aa2d2c73c21f2 ("s390/bpf,jit: address randomize and write protect jit code")

Reported-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/s390/net/bpf_jit_comp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 8ccd6a669804..63c527eb096f 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -811,7 +811,7 @@ static struct bpf_binary_header *bpf_alloc_binary(unsigned int bpfsize,
 		return NULL;
 	memset(header, 0, sz);
 	header->pages = sz / PAGE_SIZE;
-	hole = sz - (bpfsize + sizeof(*header));
+	hole = min(sz - (bpfsize + sizeof(*header)), PAGE_SIZE - sizeof(*header));
 	/* Insert random number of illegal instructions before BPF code
 	 * and make sure the first instruction starts at an even address.
 	 */
-- 
1.9.1


  parent reply	other threads:[~2014-06-23 13:37 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 13:01 [3.11.y.z extended stable] Linux 3.11.10.12 stable review Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 01/93] cfg80211: free sme on connection failures Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 02/93] sched: Sanitize irq accounting madness Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 03/93] sched: Use CPUPRI_NR_PRIORITIES instead of MAX_RT_PRIO in cpupri check Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 04/93] net: cpsw: fix null dereference at probe Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 05/93] mac80211: fix suspend vs. association race Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 06/93] mac80211: fix on-channel remain-on-channel Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 07/93] af_iucv: wrong mapping of sent and confirmed skbs Luis Henriques
2014-06-23 13:01 ` Luis Henriques [this message]
2014-06-23 13:01 ` [PATCH 3.11 09/93] perf: Limit perf_event_attr::sample_period to 63 bits Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 10/93] perf: Prevent false warning in perf_swevent_add Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 11/93] drm/gf119-/disp: fix nasty bug which can clobber SOR0's clock setup Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 12/93] drm/radeon: also try GART for CPU accessed buffers Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 13/93] drm/radeon: handle non-VGA class pci devices with ATRM Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 14/93] drm/radeon: fix register typo on si Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 15/93] drm/radeon: avoid segfault on device open when accel is not working Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 16/93] can: peak_pci: prevent use after free at netdev removal Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 17/93] nfsd4: remove lockowner when removing lock stateid Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 18/93] nfsd4: warn on finding lockowner without stateid's Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 19/93] hwpoison, hugetlb: lock_page/unlock_page does not match for handling a free hugepage Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 20/93] mm/memory-failure.c: fix memory leak by race between poison and unpoison Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 21/93] netfilter: ipv4: defrag: set local_df flag on defragmented skb Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 22/93] ARM: OMAP3: clock: Back-propagate rate change from cam_mclk to dpll4_m5 on all OMAP3 platforms Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 23/93] dma: dw: allow shared interrupts Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 24/93] dmaengine: dw: went back to plain {request,free}_irq() calls Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 25/93] ARM: omap5: hwmod_data: Correct IDLEMODE for McPDM Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 26/93] Input: synaptics - add min/max quirk for the ThinkPad W540 Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 27/93] futex: Add another early deadlock detection check Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 28/93] futex: Prevent attaching to kernel threads Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 29/93] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 30/93] cpufreq: remove race while accessing cur_policy Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 31/93] cpufreq: cpu0: drop wrong devm usage Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 32/93] ARM: imx: fix error handling in ipu device registration Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 33/93] ALSA: hda - Fix onboard audio on Intel H97/Z97 chipsets Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 34/93] ARM: 8051/1: put_user: fix possible data corruption in put_user Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 35/93] ARM: 8064/1: fix v7-M signal return Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 36/93] Input: synaptics - T540p - unify with other LEN0034 models Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 37/93] drm/i915: Only copy back the modified fields to userspace from execbuffer Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 38/93] dm cache: always split discards on cache block boundaries Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 39/93] powerpc: Fix 64 bit builds with binutils 2.24 Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 40/93] powerpc, kexec: Fix "Processor X is stuck" issue during kexec from ST mode Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 41/93] rtmutex: Fix deadlock detector for real Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 42/93] drm/radeon: don't allow RADEON_GEM_DOMAIN_CPU for command submission Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 43/93] audit: restore order of tty and ses fields in log output Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 44/93] drm/nouveau/pm/fan: drop the fan lock in fan_update() before rescheduling Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 45/93] leds: leds-pwm: properly clean up after probe failure Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 46/93] clk: vexpress: NULL dereference on error path Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 47/93] [SCSI] fix our current target reap infrastructure Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 48/93] [SCSI] dual scan thread bug fix Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 49/93] genirq: Provide irq_force_affinity fallback for non-SMP Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 50/93] i2c: designware: Mask all interrupts during i2c controller enable Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 51/93] crypto: s390 - fix aes,des ctr mode concurrency finding Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 52/93] Staging: speakup: Move pasting into a work item Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 53/93] USB: Avoid runtime suspend loops for HCDs that can't handle suspend/resume Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 54/93] can: only rename enabled led triggers when changing the netdev name Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 55/93] USB: io_ti: fix firmware download on big-endian machines (part 2) Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 56/93] USB: ftdi_sio: add NovaTech OrionLXm product ID Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 57/93] USB: serial: option: add support for Novatel E371 PCIe card Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 58/93] USB: cdc-wdm: properly include types.h Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 59/93] md: always set MD_RECOVERY_INTR when aborting a reshape or other "resync" Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 60/93] xhci: delete endpoints from bandwidth list before freeing whole device Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 61/93] md: always set MD_RECOVERY_INTR when interrupting a reshape thread Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 62/93] ALSA: hda/analog - Fix silent output on ASUS A8JN Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 63/93] ALSA: hda/realtek - Correction of fixup codes for PB V7900 laptop Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 64/93] ALSA: hda/realtek - Fix COEF widget NID for ALC260 replacer fixup Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 65/93] iser-target: Add missing target_put_sess_cmd for ImmedateData failure Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 66/93] iscsi-target: Fix wrong buffer / buffer overrun in iscsi_change_param_value() Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 67/93] percpu-refcount: fix usage of this_cpu_ops Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 68/93] futex-prevent-requeue-pi-on-same-futex.patch futex: Forbid uaddr == uaddr2 in futex_requeue(..., requeue_pi=1) Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 69/93] futex: Validate atomic acquisition in futex_lock_pi_atomic() Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 70/93] futex: Always cleanup owner tid in unlock_pi Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 71/93] futex: Make lookup_pi_state more robust Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 72/93] target: Fix alua_access_state attribute OOPs for un-configured devices Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 73/93] mm: rmap: fix use-after-free in __put_anon_vma Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 74/93] usb: cdc-wdm: export cdc-wdm uapi header Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 75/93] staging: comedi: ni_daq_700: add mux settling delay Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 76/93] kvm: free resources after canceling async_pf Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 77/93] kvm: remove .done from struct kvm_async_pf Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 78/93] KVM: async_pf: mm->mm_users can not pin apf->mm Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 79/93] mm/page-writeback.c: fix divide by zero in pos_ratio_polynom Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 80/93] dma: mv_xor: Flush descriptors before activating a channel Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 81/93] skbuff: skb_segment: orphan frags before copying Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 82/93] Target/iscsi,iser: Avoid accepting transport connections during stop stage Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 83/93] iser-target: Fix multi network portal shutdown regression Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 84/93] target: Allow READ_CAPACITY opcode in ALUA Standby access state Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 85/93] mm: compaction: reset cached scanner pfn's before reading them Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 86/93] mm: compaction: detect when scanners meet in isolate_freepages Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 87/93] MIPS: asm: thread_info: Add _TIF_SECCOMP flag Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 88/93] perf: Fix race in removing an event Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 89/93] hwmon: (ntc_thermistor) Fix dependencies Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 90/93] hwmon: (ntc_thermistor) Fix OF device ID mapping Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 91/93] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 92/93] auditsc: audit_krule mask accesses need bounds checking Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 93/93] [SCSI] megaraid: Use resource_size_t for PCI resources, not long Luis Henriques

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=1403528592-2163-9-git-send-email-luis.henriques@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=davem@davemloft.net \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®