linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3.18 00/84] 3.18.2-stable review
@ 2015-01-07  1:49 Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 01/84] isofs: Fix infinite looping over CE entries Greg Kroah-Hartman
                   ` (84 more replies)
  0 siblings, 85 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, torvalds, akpm, linux, satoru.takeuchi,
	shuah.kh, stable

This is the start of the stable review cycle for the 3.18.2 release.
There are 84 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Fri Jan  9 01:40:07 UTC 2015.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.18.2-rc1.gz
and the diffstat can be found below.

thanks,

greg k-h

-------------
Pseudo-Shortlog of commits:

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Linux 3.18.2-rc1

Filipe Manana <fdmanana@suse.com>
    Btrfs: fix fs corruption on transaction abort if device supports discard

Josef Bacik <jbacik@fb.com>
    Btrfs: make sure logged extents complete in the current transaction V3

Josef Bacik <jbacik@fb.com>
    Btrfs: do not move em to modified list when unpinning

David Sterba <dsterba@suse.cz>
    btrfs: fix wrong accounting of raid1 data profile in statfs

Josef Bacik <jbacik@fb.com>
    Btrfs: make sure we wait on logged extents when fsycning two subvols

Michael Halcrow <mhalcrow@google.com>
    eCryptfs: Remove buggy and unnecessary write in file name decode routine

Tyler Hicks <tyhicks@canonical.com>
    eCryptfs: Force RO mount when encrypted view is enabled

Jan Kara <jack@suse.cz>
    udf: Check component length before reading it

Jan Kara <jack@suse.cz>
    udf: Verify symlink size before loading it

Jan Kara <jack@suse.cz>
    udf: Verify i_size when loading inode

Jan Kara <jack@suse.cz>
    udf: Check path length when reading symlink

Oleg Nesterov <oleg@redhat.com>
    exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting

Joonsoo Kim <iamjoonsoo.kim@lge.com>
    mm/CMA: fix boot regression due to physical address of high_memory

Jan Kara <jack@suse.cz>
    ncpfs: return proper error from NCP_IOC_SETROOT ioctl

Rabin Vincent <rabin.vincent@axis.com>
    crypto: af_alg - fix backlog handling

Richard Guy Briggs <rgb@redhat.com>
    audit: restore AUDIT_LOGINUID unset ABI

Paul Moore <pmoore@redhat.com>
    audit: don't attempt to lookup PIDs when changing PID filtering audit rules

Richard Guy Briggs <rgb@redhat.com>
    audit: use supplied gfp_mask from audit_buffer in kauditd_send_multicast_skb

Eric W. Biederman <ebiederm@xmission.com>
    userns: Unbreak the unprivileged remount tests

Eric W. Biederman <ebiederm@xmission.com>
    userns: Allow setting gid_maps without privilege when setgroups is disabled

Eric W. Biederman <ebiederm@xmission.com>
    userns: Add a knob to disable setgroups on a per user namespace basis

Eric W. Biederman <ebiederm@xmission.com>
    userns: Rename id_map_mutex to userns_state_mutex

Eric W. Biederman <ebiederm@xmission.com>
    userns: Only allow the creator of the userns unprivileged mappings

Eric W. Biederman <ebiederm@xmission.com>
    userns: Check euid no fsuid when establishing an unprivileged uid mapping

Eric W. Biederman <ebiederm@xmission.com>
    userns: Don't allow unprivileged creation of gid mappings

Eric W. Biederman <ebiederm@xmission.com>
    userns: Don't allow setgroups until a gid mapping has been setablished

Eric W. Biederman <ebiederm@xmission.com>
    userns: Document what the invariant required for safe unprivileged mappings.

Eric W. Biederman <ebiederm@xmission.com>
    groups: Consolidate the setgroups permission checks

Eric W. Biederman <ebiederm@xmission.com>
    umount: Disallow unprivileged mount force

Eric W. Biederman <ebiederm@xmission.com>
    mnt: Update unprivileged remount test

Eric W. Biederman <ebiederm@xmission.com>
    mnt: Implicitly add MNT_NODEV on remount when it was implicitly added by mount

Luis Henriques <luis.henriques@canonical.com>
    thermal: Fix error path in thermal_init()

Eric W. Biederman <ebiederm@xmission.com>
    mnt: Fix a memory stomp in umount

Johannes Berg <johannes.berg@intel.com>
    mac80211: free management frame keys when removing station

Andreas Müller <goo@stapelspeicher.org>
    mac80211: fix multicast LED blinking and counter

Jes Sorensen <Jes.Sorensen@redhat.com>
    mac80211: avoid using uninitialized stack data

Felix Fietkau <nbd@openwrt.org>
    mac80211: copy chandef from AP vif to VLANs

Takashi Iwai <tiwai@suse.de>
    KEYS: Fix stale key registration at error path

Borislav Petkov <bp@suse.de>
    x86/microcode/intel: Fish out the stashed microcode for the BSP

Borislav Petkov <bp@suse.de>
    x86, microcode: Reload microcode on resume

Boris Ostrovsky <boris.ostrovsky@oracle.com>
    x86, microcode: Don't initialize microcode code on paravirt

Borislav Petkov <bp@suse.de>
    x86, microcode, intel: Drop unused parameter

Borislav Petkov <bp@suse.de>
    x86, microcode, AMD: Do not use smp_processor_id() in preemtible context

Jan Kara <jack@suse.cz>
    isofs: Fix unchecked printing of ER records

Andy Lutomirski <luto@amacapital.net>
    x86/tls: Don't validate lm in set_thread_area() after all

Andy Lutomirski <luto@amacapital.net>
    x86/asm/traps: Disable tracing and kprobes in fixup_bad_iret and sync_regs

Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    ARM: mvebu: fix ordering in Armada 370 .dtsi

Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
    ARM: mvebu: remove conflicting muxing on Armada 370 DB

Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
    ARM: mvebu: disable I/O coherency on non-SMP situations on Armada 370/375/38x/XP

Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
    ARM: mvebu: make the coherency_ll.S functions work with no coherency fabric

Dmitry Osipenko <digetx@gmail.com>
    ARM: tegra: Re-add removed SoC id macro to tegra_resume()

Thierry Reding <treding@nvidia.com>
    drm/tegra: gem: dumb: pitch and size are outputs

Zi Shen Lim <zlim.lnx@gmail.com>
    arm64: bpf: lift restriction on last instruction

Catalin Marinas <catalin.marinas@arm.com>
    arm64: Add COMPAT_HWCAP_LPAE

Mikulas Patocka <mpatocka@redhat.com>
    dm thin: fix a race in thin_dtr

Joe Thornber <ejt@redhat.com>
    dm thin: fix missing out-of-data-space to write mode transition if blocks are released

Joe Thornber <ejt@redhat.com>
    dm thin: fix inability to discard blocks when in out-of-data-space mode

Dan Carpenter <dan.carpenter@oracle.com>
    dm space map metadata: fix sm_bootstrap_get_nr_blocks()

Joe Thornber <ejt@redhat.com>
    dm cache: fix spurious cell_defer when dealing with partial block at end of device

Joe Thornber <ejt@redhat.com>
    dm cache: dirty flag was mistakenly being cleared when promoting via overwrite

Joe Thornber <ejt@redhat.com>
    dm cache: only use overwrite optimisation for promotion when in writeback mode

Milan Broz <gmazyland@gmail.com>
    dm crypt: use memzero_explicit for on-stack buffer

Darrick J. Wong <darrick.wong@oracle.com>
    dm bufio: fix memleak when using a dm_buffer's inline bio

Mikulas Patocka <mpatocka@redhat.com>
    dcache: fix kmemcheck warning in switch_names

Peng Tao <tao.peng@primarydata.com>
    nfs41: fix nfs4_proc_layoutget error handling

Jan Kara <jack@suse.cz>
    f2fs: fix possible data corruption in f2fs_write_begin()

Jan Kara <jack@suse.cz>
    f2fs: avoid returning uninitialized value to userspace from f2fs_trim_fs()

Hannes Reinecke <hare@suse.de>
    scsi: correct return values for .eh_abort_handler implementations

Markus Pargmann <mpa@pengutronix.de>
    regulator: anatop: Set default voltage selector for vddpu

Sumit.Saxena@avagotech.com <Sumit.Saxena@avagotech.com>
    megaraid_sas: dndinaness related bug fixes

Sumit.Saxena@avagotech.com <Sumit.Saxena@avagotech.com>
    megaraid_sas: corrected return of wait_event from abort frame path

Peter Guo <peter.guo@bayhubtech.com>
    mmc: sdhci-pci-o2micro: Fix Dell E5440 issue

Baruch Siach <baruch@tkos.co.il>
    mmc: block: add newline to sysfs display of force_ro

Ulf Hansson <ulf.hansson@linaro.org>
    mmc: omap_hsmmc: Fix UHS card with DDR50 support

James Hogan <james.hogan@imgtec.com>
    mmc: dw_mmc: avoid write to CDTHRCTL on older versions

Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
    mfd: tc6393xb: Fail ohci suspend if full state restore is required

Tony Lindgren <tony@atomide.com>
    mfd: twl4030-power: Fix regression with missing compatible flag

Sonny Rao <sonnyrao@chromium.org>
    clocksource: arch_timer: Fix code to use physical timers when requested

Hante Meuleman <meuleman@broadcom.com>
    brcmfmac: Fix bitmap malloc bug in msgbuf.

Andy Lutomirski <luto@amacapital.net>
    x86, kvm: Clear paravirt_enabled on KVM guests for espfix32's benefit

Andy Lutomirski <luto@amacapital.net>
    x86_64, switch_to(): Load TLS descriptors before switching DS and ES

Andy Lutomirski <luto@amacapital.net>
    x86/tls: Disallow unusual TLS segments

Andy Lutomirski <luto@amacapital.net>
    x86/tls: Validate TLS entries to protect espfix

Jan Kara <jack@suse.cz>
    isofs: Fix infinite looping over CE entries


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

Diffstat:

 Makefile                                           |   4 +-
 arch/arm/boot/dts/armada-370-db.dts                |  24 ---
 arch/arm/boot/dts/armada-370.dtsi                  |  10 +-
 arch/arm/include/asm/arch_timer.h                  |   9 +
 arch/arm/mach-mvebu/coherency.c                    |  44 +++--
 arch/arm/mach-mvebu/coherency_ll.S                 |  21 ++-
 arch/arm/mach-tegra/reset-handler.S                |   1 +
 arch/arm64/include/asm/arch_timer.h                |   9 +
 arch/arm64/include/asm/hwcap.h                     |   1 +
 arch/arm64/kernel/setup.c                          |   3 +-
 arch/arm64/net/bpf_jit_comp.c                      |  13 +-
 arch/s390/kernel/compat_linux.c                    |   2 +-
 arch/x86/include/asm/microcode.h                   |   2 +
 arch/x86/include/asm/microcode_amd.h               |   4 +-
 arch/x86/include/asm/microcode_intel.h             |   2 +
 arch/x86/include/uapi/asm/ldt.h                    |   7 +
 arch/x86/kernel/cpu/microcode/amd.c                |   8 +-
 arch/x86/kernel/cpu/microcode/amd_early.c          |  20 +-
 arch/x86/kernel/cpu/microcode/core.c               |  12 +-
 arch/x86/kernel/cpu/microcode/core_early.c         |  21 +++
 arch/x86/kernel/cpu/microcode/intel_early.c        |  42 ++++-
 arch/x86/kernel/kvm.c                              |   9 +-
 arch/x86/kernel/kvmclock.c                         |   1 -
 arch/x86/kernel/process_64.c                       | 101 +++++++---
 arch/x86/kernel/tls.c                              |  39 ++++
 arch/x86/kernel/traps.c                            |   5 +-
 crypto/af_alg.c                                    |   3 +
 drivers/clocksource/arm_arch_timer.c               |   5 +-
 drivers/gpu/drm/tegra/gem.c                        |  10 +-
 drivers/md/dm-bufio.c                              |  20 +-
 drivers/md/dm-cache-target.c                       |  17 +-
 drivers/md/dm-crypt.c                              |   2 +-
 drivers/md/dm-thin.c                               |  30 ++-
 drivers/md/persistent-data/dm-space-map-metadata.c |   4 +-
 drivers/mfd/tc6393xb.c                             |  13 +-
 drivers/mfd/twl4030-power.c                        |   3 +
 drivers/mmc/card/block.c                           |   2 +-
 drivers/mmc/host/dw_mmc.c                          |   7 +
 drivers/mmc/host/omap_hsmmc.c                      |   4 +-
 drivers/mmc/host/sdhci-pci-o2micro.c               |   2 -
 drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   |   1 +
 drivers/regulator/anatop-regulator.c               |   8 +
 drivers/scsi/NCR5380.c                             |  12 +-
 drivers/scsi/aha1740.c                             |   2 +-
 drivers/scsi/atari_NCR5380.c                       |   2 +-
 drivers/scsi/esas2r/esas2r_main.c                  |   2 +-
 drivers/scsi/megaraid.c                            |   8 +-
 drivers/scsi/megaraid/megaraid_sas_base.c          |   2 +-
 drivers/scsi/megaraid/megaraid_sas_fp.c            |  17 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c        |  13 +-
 drivers/scsi/sun3_NCR5380.c                        |  10 +-
 drivers/thermal/thermal_core.c                     |   4 +-
 fs/btrfs/disk-io.c                                 |  26 ++-
 fs/btrfs/extent-tree.c                             |  10 +-
 fs/btrfs/extent_map.c                              |   2 -
 fs/btrfs/ordered-data.c                            |   9 +-
 fs/btrfs/ordered-data.h                            |   8 +-
 fs/btrfs/super.c                                   |   2 +-
 fs/btrfs/transaction.c                             |  33 ++++
 fs/btrfs/transaction.h                             |   2 +
 fs/btrfs/tree-log.c                                |   6 +-
 fs/dcache.c                                        |   2 +
 fs/ecryptfs/crypto.c                               |   1 -
 fs/ecryptfs/file.c                                 |  12 --
 fs/ecryptfs/main.c                                 |  16 +-
 fs/f2fs/data.c                                     |  24 ++-
 fs/f2fs/segment.c                                  |   2 +-
 fs/isofs/rock.c                                    |   9 +
 fs/namespace.c                                     |  13 +-
 fs/ncpfs/ioctl.c                                   |   1 -
 fs/nfs/nfs4proc.c                                  |   6 +-
 fs/proc/base.c                                     |  53 ++++++
 fs/udf/dir.c                                       |   3 +-
 fs/udf/inode.c                                     |  14 ++
 fs/udf/namei.c                                     |   3 +-
 fs/udf/symlink.c                                   |  57 ++++--
 fs/udf/udfdecl.h                                   |   3 +-
 fs/udf/unicode.c                                   |  28 +--
 include/linux/audit.h                              |   4 +
 include/linux/cred.h                               |   1 +
 include/linux/user_namespace.h                     |  12 ++
 kernel/audit.c                                     |   8 +-
 kernel/auditfilter.c                               |  23 +--
 kernel/groups.c                                    |  11 +-
 kernel/pid.c                                       |   2 +
 kernel/uid16.c                                     |   2 +-
 kernel/user.c                                      |   1 +
 kernel/user_namespace.c                            | 122 +++++++++++-
 mm/cma.c                                           |  14 +-
 net/mac80211/chan.c                                |  23 ++-
 net/mac80211/iface.c                               |   1 +
 net/mac80211/key.c                                 |   2 +-
 net/mac80211/mlme.c                                |   1 +
 net/mac80211/rx.c                                  |  11 +-
 security/keys/encrypted-keys/encrypted.c           |   5 +-
 .../selftests/mount/unprivileged-remount-test.c    | 204 +++++++++++++++++----
 96 files changed, 1077 insertions(+), 332 deletions(-)



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 01/84] isofs: Fix infinite looping over CE entries
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 02/84] x86/tls: Validate TLS entries to protect espfix Greg Kroah-Hartman
                   ` (83 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, P J P, Jan Kara

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

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

From: Jan Kara <jack@suse.cz>

commit f54e18f1b831c92f6512d2eedb224cd63d607d3d upstream.

Rock Ridge extensions define so called Continuation Entries (CE) which
define where is further space with Rock Ridge data. Corrupted isofs
image can contain arbitrarily long chain of these, including a one
containing loop and thus causing kernel to end in an infinite loop when
traversing these entries.

Limit the traversal to 32 entries which should be more than enough space
to store all the Rock Ridge data.

Reported-by: P J P <ppandit@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/isofs/rock.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -30,6 +30,7 @@ struct rock_state {
 	int cont_size;
 	int cont_extent;
 	int cont_offset;
+	int cont_loops;
 	struct inode *inode;
 };
 
@@ -73,6 +74,9 @@ static void init_rock_state(struct rock_
 	rs->inode = inode;
 }
 
+/* Maximum number of Rock Ridge continuation entries */
+#define RR_MAX_CE_ENTRIES 32
+
 /*
  * Returns 0 if the caller should continue scanning, 1 if the scan must end
  * and -ve on error.
@@ -105,6 +109,8 @@ static int rock_continue(struct rock_sta
 			goto out;
 		}
 		ret = -EIO;
+		if (++rs->cont_loops >= RR_MAX_CE_ENTRIES)
+			goto out;
 		bh = sb_bread(rs->inode->i_sb, rs->cont_extent);
 		if (bh) {
 			memcpy(rs->buffer, bh->b_data + rs->cont_offset,



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 02/84] x86/tls: Validate TLS entries to protect espfix
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 01/84] isofs: Fix infinite looping over CE entries Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 03/84] x86/tls: Disallow unusual TLS segments Greg Kroah-Hartman
                   ` (82 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, H. Peter Anvin,
	Konrad Rzeszutek Wilk, Linus Torvalds, Willy Tarreau,
	Ingo Molnar

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

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

From: Andy Lutomirski <luto@amacapital.net>

commit 41bdc78544b8a93a9c6814b8bbbfef966272abbe upstream.

Installing a 16-bit RW data segment into the GDT defeats espfix.
AFAICT this will not affect glibc, Wine, or dosemu at all.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/tls.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -27,6 +27,21 @@ static int get_free_idx(void)
 	return -ESRCH;
 }
 
+static bool tls_desc_okay(const struct user_desc *info)
+{
+	if (LDT_empty(info))
+		return true;
+
+	/*
+	 * espfix is required for 16-bit data segments, but espfix
+	 * only works for LDT segments.
+	 */
+	if (!info->seg_32bit)
+		return false;
+
+	return true;
+}
+
 static void set_tls_desc(struct task_struct *p, int idx,
 			 const struct user_desc *info, int n)
 {
@@ -66,6 +81,9 @@ int do_set_thread_area(struct task_struc
 	if (copy_from_user(&info, u_info, sizeof(info)))
 		return -EFAULT;
 
+	if (!tls_desc_okay(&info))
+		return -EINVAL;
+
 	if (idx == -1)
 		idx = info.entry_number;
 
@@ -192,6 +210,7 @@ int regset_tls_set(struct task_struct *t
 {
 	struct user_desc infobuf[GDT_ENTRY_TLS_ENTRIES];
 	const struct user_desc *info;
+	int i;
 
 	if (pos >= GDT_ENTRY_TLS_ENTRIES * sizeof(struct user_desc) ||
 	    (pos % sizeof(struct user_desc)) != 0 ||
@@ -205,6 +224,10 @@ int regset_tls_set(struct task_struct *t
 	else
 		info = infobuf;
 
+	for (i = 0; i < count / sizeof(struct user_desc); i++)
+		if (!tls_desc_okay(info + i))
+			return -EINVAL;
+
 	set_tls_desc(target,
 		     GDT_ENTRY_TLS_MIN + (pos / sizeof(struct user_desc)),
 		     info, count / sizeof(struct user_desc));



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 03/84] x86/tls: Disallow unusual TLS segments
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 01/84] isofs: Fix infinite looping over CE entries Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 02/84] x86/tls: Validate TLS entries to protect espfix Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 04/84] x86_64, switch_to(): Load TLS descriptors before switching DS and ES Greg Kroah-Hartman
                   ` (81 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, H. Peter Anvin,
	Konrad Rzeszutek Wilk, Linus Torvalds, Willy Tarreau,
	Ingo Molnar

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

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

From: Andy Lutomirski <luto@amacapital.net>

commit 0e58af4e1d2166e9e33375a0f121e4867010d4f8 upstream.

Users have no business installing custom code segments into the
GDT, and segments that are not present but are otherwise valid
are a historical source of interesting attacks.

For completeness, block attempts to set the L bit.  (Prior to
this patch, the L bit would have been silently dropped.)

This is an ABI break.  I've checked glibc, musl, and Wine, and
none of them look like they'll have any trouble.

Note to stable maintainers: this is a hardening patch that fixes
no known bugs.  Given the possibility of ABI issues, this
probably shouldn't be backported quickly.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/tls.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -39,6 +39,28 @@ static bool tls_desc_okay(const struct u
 	if (!info->seg_32bit)
 		return false;
 
+	/* Only allow data segments in the TLS array. */
+	if (info->contents > 1)
+		return false;
+
+	/*
+	 * Non-present segments with DPL 3 present an interesting attack
+	 * surface.  The kernel should handle such segments correctly,
+	 * but TLS is very difficult to protect in a sandbox, so prevent
+	 * such segments from being created.
+	 *
+	 * If userspace needs to remove a TLS entry, it can still delete
+	 * it outright.
+	 */
+	if (info->seg_not_present)
+		return false;
+
+#ifdef CONFIG_X86_64
+	/* The L bit makes no sense for data. */
+	if (info->lm)
+		return false;
+#endif
+
 	return true;
 }
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 04/84] x86_64, switch_to(): Load TLS descriptors before switching DS and ES
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 03/84] x86/tls: Disallow unusual TLS segments Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07 15:26   ` Jiri Slaby
  2015-01-07  1:49 ` [PATCH 3.18 05/84] x86, kvm: Clear paravirt_enabled on KVM guests for espfix32s benefit Greg Kroah-Hartman
                   ` (80 subsequent siblings)
  84 siblings, 1 reply; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Andi Kleen,
	Linus Torvalds, Ingo Molnar

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

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

From: Andy Lutomirski <luto@amacapital.net>

commit f647d7c155f069c1a068030255c300663516420e upstream.

Otherwise, if buggy user code points DS or ES into the TLS
array, they would be corrupted after a context switch.

This also significantly improves the comments and documents some
gotchas in the code.

Before this patch, the both tests below failed.  With this
patch, the es test passes, although the gsbase test still fails.

 ----- begin es test -----

/*
 * Copyright (c) 2014 Andy Lutomirski
 * GPL v2
 */

static unsigned short GDT3(int idx)
{
	return (idx << 3) | 3;
}

static int create_tls(int idx, unsigned int base)
{
	struct user_desc desc = {
		.entry_number    = idx,
		.base_addr       = base,
		.limit           = 0xfffff,
		.seg_32bit       = 1,
		.contents        = 0, /* Data, grow-up */
		.read_exec_only  = 0,
		.limit_in_pages  = 1,
		.seg_not_present = 0,
		.useable         = 0,
	};

	if (syscall(SYS_set_thread_area, &desc) != 0)
		err(1, "set_thread_area");

	return desc.entry_number;
}

int main()
{
	int idx = create_tls(-1, 0);
	printf("Allocated GDT index %d\n", idx);

	unsigned short orig_es;
	asm volatile ("mov %%es,%0" : "=rm" (orig_es));

	int errors = 0;
	int total = 1000;
	for (int i = 0; i < total; i++) {
		asm volatile ("mov %0,%%es" : : "rm" (GDT3(idx)));
		usleep(100);

		unsigned short es;
		asm volatile ("mov %%es,%0" : "=rm" (es));
		asm volatile ("mov %0,%%es" : : "rm" (orig_es));
		if (es != GDT3(idx)) {
			if (errors == 0)
				printf("[FAIL]\tES changed from 0x%hx to 0x%hx\n",
				       GDT3(idx), es);
			errors++;
		}
	}

	if (errors) {
		printf("[FAIL]\tES was corrupted %d/%d times\n", errors, total);
		return 1;
	} else {
		printf("[OK]\tES was preserved\n");
		return 0;
	}
}

 ----- end es test -----

 ----- begin gsbase test -----

/*
 * gsbase.c, a gsbase test
 * Copyright (c) 2014 Andy Lutomirski
 * GPL v2
 */

static unsigned char *testptr, *testptr2;

static unsigned char read_gs_testvals(void)
{
	unsigned char ret;
	asm volatile ("movb %%gs:%1, %0" : "=r" (ret) : "m" (*testptr));
	return ret;
}

int main()
{
	int errors = 0;

	testptr = mmap((void *)0x200000000UL, 1, PROT_READ | PROT_WRITE,
		       MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
	if (testptr == MAP_FAILED)
		err(1, "mmap");

	testptr2 = mmap((void *)0x300000000UL, 1, PROT_READ | PROT_WRITE,
		       MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
	if (testptr2 == MAP_FAILED)
		err(1, "mmap");

	*testptr = 0;
	*testptr2 = 1;

	if (syscall(SYS_arch_prctl, ARCH_SET_GS,
		    (unsigned long)testptr2 - (unsigned long)testptr) != 0)
		err(1, "ARCH_SET_GS");

	usleep(100);

	if (read_gs_testvals() == 1) {
		printf("[OK]\tARCH_SET_GS worked\n");
	} else {
		printf("[FAIL]\tARCH_SET_GS failed\n");
		errors++;
	}

	asm volatile ("mov %0,%%gs" : : "r" (0));

	if (read_gs_testvals() == 0) {
		printf("[OK]\tWriting 0 to gs worked\n");
	} else {
		printf("[FAIL]\tWriting 0 to gs failed\n");
		errors++;
	}

	usleep(100);

	if (read_gs_testvals() == 0) {
		printf("[OK]\tgsbase is still zero\n");
	} else {
		printf("[FAIL]\tgsbase was corrupted\n");
		errors++;
	}

	return errors == 0 ? 0 : 1;
}

 ----- end gsbase test -----

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/509d27c9fec78217691c3dad91cec87e1006b34a.1418075657.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/process_64.c |  101 +++++++++++++++++++++++++++++++------------
 1 file changed, 73 insertions(+), 28 deletions(-)

--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -283,24 +283,9 @@ __switch_to(struct task_struct *prev_p,
 
 	fpu = switch_fpu_prepare(prev_p, next_p, cpu);
 
-	/*
-	 * Reload esp0, LDT and the page table pointer:
-	 */
+	/* Reload esp0 and ss1. */
 	load_sp0(tss, next);
 
-	/*
-	 * Switch DS and ES.
-	 * This won't pick up thread selector changes, but I guess that is ok.
-	 */
-	savesegment(es, prev->es);
-	if (unlikely(next->es | prev->es))
-		loadsegment(es, next->es);
-
-	savesegment(ds, prev->ds);
-	if (unlikely(next->ds | prev->ds))
-		loadsegment(ds, next->ds);
-
-
 	/* We must save %fs and %gs before load_TLS() because
 	 * %fs and %gs may be cleared by load_TLS().
 	 *
@@ -309,41 +294,101 @@ __switch_to(struct task_struct *prev_p,
 	savesegment(fs, fsindex);
 	savesegment(gs, gsindex);
 
+	/*
+	 * Load TLS before restoring any segments so that segment loads
+	 * reference the correct GDT entries.
+	 */
 	load_TLS(next, cpu);
 
 	/*
-	 * Leave lazy mode, flushing any hypercalls made here.
-	 * This must be done before restoring TLS segments so
-	 * the GDT and LDT are properly updated, and must be
-	 * done before math_state_restore, so the TS bit is up
-	 * to date.
+	 * Leave lazy mode, flushing any hypercalls made here.  This
+	 * must be done after loading TLS entries in the GDT but before
+	 * loading segments that might reference them, and and it must
+	 * be done before math_state_restore, so the TS bit is up to
+	 * date.
 	 */
 	arch_end_context_switch(next_p);
 
+	/* Switch DS and ES.
+	 *
+	 * Reading them only returns the selectors, but writing them (if
+	 * nonzero) loads the full descriptor from the GDT or LDT.  The
+	 * LDT for next is loaded in switch_mm, and the GDT is loaded
+	 * above.
+	 *
+	 * We therefore need to write new values to the segment
+	 * registers on every context switch unless both the new and old
+	 * values are zero.
+	 *
+	 * Note that we don't need to do anything for CS and SS, as
+	 * those are saved and restored as part of pt_regs.
+	 */
+	savesegment(es, prev->es);
+	if (unlikely(next->es | prev->es))
+		loadsegment(es, next->es);
+
+	savesegment(ds, prev->ds);
+	if (unlikely(next->ds | prev->ds))
+		loadsegment(ds, next->ds);
+
 	/*
 	 * Switch FS and GS.
 	 *
-	 * Segment register != 0 always requires a reload.  Also
-	 * reload when it has changed.  When prev process used 64bit
-	 * base always reload to avoid an information leak.
+	 * These are even more complicated than FS and GS: they have
+	 * 64-bit bases are that controlled by arch_prctl.  Those bases
+	 * only differ from the values in the GDT or LDT if the selector
+	 * is 0.
+	 *
+	 * Loading the segment register resets the hidden base part of
+	 * the register to 0 or the value from the GDT / LDT.  If the
+	 * next base address zero, writing 0 to the segment register is
+	 * much faster than using wrmsr to explicitly zero the base.
+	 *
+	 * The thread_struct.fs and thread_struct.gs values are 0
+	 * if the fs and gs bases respectively are not overridden
+	 * from the values implied by fsindex and gsindex.  They
+	 * are nonzero, and store the nonzero base addresses, if
+	 * the bases are overridden.
+	 *
+	 * (fs != 0 && fsindex != 0) || (gs != 0 && gsindex != 0) should
+	 * be impossible.
+	 *
+	 * Therefore we need to reload the segment registers if either
+	 * the old or new selector is nonzero, and we need to override
+	 * the base address if next thread expects it to be overridden.
+	 *
+	 * This code is unnecessarily slow in the case where the old and
+	 * new indexes are zero and the new base is nonzero -- it will
+	 * unnecessarily write 0 to the selector before writing the new
+	 * base address.
+	 *
+	 * Note: This all depends on arch_prctl being the only way that
+	 * user code can override the segment base.  Once wrfsbase and
+	 * wrgsbase are enabled, most of this code will need to change.
 	 */
 	if (unlikely(fsindex | next->fsindex | prev->fs)) {
 		loadsegment(fs, next->fsindex);
+
 		/*
-		 * Check if the user used a selector != 0; if yes
-		 *  clear 64bit base, since overloaded base is always
-		 *  mapped to the Null selector
+		 * If user code wrote a nonzero value to FS, then it also
+		 * cleared the overridden base address.
+		 *
+		 * XXX: if user code wrote 0 to FS and cleared the base
+		 * address itself, we won't notice and we'll incorrectly
+		 * restore the prior base address next time we reschdule
+		 * the process.
 		 */
 		if (fsindex)
 			prev->fs = 0;
 	}
-	/* when next process has a 64bit base use it */
 	if (next->fs)
 		wrmsrl(MSR_FS_BASE, next->fs);
 	prev->fsindex = fsindex;
 
 	if (unlikely(gsindex | next->gsindex | prev->gs)) {
 		load_gs_index(next->gsindex);
+
+		/* This works (and fails) the same way as fsindex above. */
 		if (gsindex)
 			prev->gs = 0;
 	}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 05/84] x86, kvm: Clear paravirt_enabled on KVM guests for espfix32s benefit
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 04/84] x86_64, switch_to(): Load TLS descriptors before switching DS and ES Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 06/84] brcmfmac: Fix bitmap malloc bug in msgbuf Greg Kroah-Hartman
                   ` (79 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Konrad Rzeszutek Wilk,
	Andy Lutomirski, Paolo Bonzini

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

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

From: Andy Lutomirski <luto@amacapital.net>

commit 29fa6825463c97e5157284db80107d1bfac5d77b upstream.

paravirt_enabled has the following effects:

 - Disables the F00F bug workaround warning.  There is no F00F bug
   workaround any more because Linux's standard IDT handling already
   works around the F00F bug, but the warning still exists.  This
   is only cosmetic, and, in any event, there is no such thing as
   KVM on a CPU with the F00F bug.

 - Disables 32-bit APM BIOS detection.  On a KVM paravirt system,
   there should be no APM BIOS anyway.

 - Disables tboot.  I think that the tboot code should check the
   CPUID hypervisor bit directly if it matters.

 - paravirt_enabled disables espfix32.  espfix32 should *not* be
   disabled under KVM paravirt.

The last point is the purpose of this patch.  It fixes a leak of the
high 16 bits of the kernel stack address on 32-bit KVM paravirt
guests.  Fixes CVE-2014-8134.

Suggested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/kvm.c      |    9 ++++++++-
 arch/x86/kernel/kvmclock.c |    1 -
 2 files changed, 8 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -283,7 +283,14 @@ NOKPROBE_SYMBOL(do_async_page_fault);
 static void __init paravirt_ops_setup(void)
 {
 	pv_info.name = "KVM";
-	pv_info.paravirt_enabled = 1;
+
+	/*
+	 * KVM isn't paravirt in the sense of paravirt_enabled.  A KVM
+	 * guest kernel works like a bare metal kernel with additional
+	 * features, and paravirt_enabled is about features that are
+	 * missing.
+	 */
+	pv_info.paravirt_enabled = 0;
 
 	if (kvm_para_has_feature(KVM_FEATURE_NOP_IO_DELAY))
 		pv_cpu_ops.io_delay = kvm_io_delay;
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -263,7 +263,6 @@ void __init kvmclock_init(void)
 #endif
 	kvm_get_preset_lpj();
 	clocksource_register_hz(&kvm_clock, NSEC_PER_SEC);
-	pv_info.paravirt_enabled = 1;
 	pv_info.name = "KVM";
 
 	if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE_STABLE_BIT))



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 06/84] brcmfmac: Fix bitmap malloc bug in msgbuf.
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 05/84] x86, kvm: Clear paravirt_enabled on KVM guests for espfix32s benefit Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 07/84] clocksource: arch_timer: Fix code to use physical timers when requested Greg Kroah-Hartman
                   ` (78 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Arend Van Spriel,
	Pieter-Paul Giesberts, Hante Meuleman, John W. Linville

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

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

From: Hante Meuleman <meuleman@broadcom.com>

commit 333c2aa029b847051a2db76a6ca59f699a520030 upstream.

Reviewed-by: Arend Van Spriel <arend@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
@@ -1355,6 +1355,7 @@ int brcmf_proto_msgbuf_attach(struct brc
 	}
 	INIT_WORK(&msgbuf->txflow_work, brcmf_msgbuf_txflow_worker);
 	count = BITS_TO_LONGS(if_msgbuf->nrof_flowrings);
+	count = count * sizeof(unsigned long);
 	msgbuf->flow_map = kzalloc(count, GFP_KERNEL);
 	if (!msgbuf->flow_map)
 		goto fail;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 07/84] clocksource: arch_timer: Fix code to use physical timers when requested
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 06/84] brcmfmac: Fix bitmap malloc bug in msgbuf Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 08/84] mfd: twl4030-power: Fix regression with missing compatible flag Greg Kroah-Hartman
                   ` (77 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Sonny Rao, Catalin Marinas,
	Daniel Lezcano, Olof Johansson

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

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

From: Sonny Rao <sonnyrao@chromium.org>

commit 0b46b8a718c6e90910a1b1b0fe797be3c167e186 upstream.

This is a bug fix for using physical arch timers when
the arch_timer_use_virtual boolean is false.  It restores the
arch_counter_get_cntpct() function after removal in

0d651e4e "clocksource: arch_timer: use virtual counters"

We need this on certain ARMv7 systems which are architected like this:

* The firmware doesn't know and doesn't care about hypervisor mode and
  we don't want to add the complexity of hypervisor there.

* The firmware isn't involved in SMP bringup or resume.

* The ARCH timer come up with an uninitialized offset between the
  virtual and physical counters.  Each core gets a different random
  offset.

* The device boots in "Secure SVC" mode.

* Nothing has touched the reset value of CNTHCTL.PL1PCEN or
  CNTHCTL.PL1PCTEN (both default to 1 at reset)

One example of such as system is RK3288 where it is much simpler to
use the physical counter since there's nobody managing the offset and
each time a core goes down and comes back up it will get reinitialized
to some other random value.

Fixes: 0d651e4e65e9 ("clocksource: arch_timer: use virtual counters")
Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/include/asm/arch_timer.h    |    9 +++++++++
 arch/arm64/include/asm/arch_timer.h  |    9 +++++++++
 drivers/clocksource/arm_arch_timer.c |    5 ++++-
 3 files changed, 22 insertions(+), 1 deletion(-)

--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -78,6 +78,15 @@ static inline u32 arch_timer_get_cntfrq(
 	return val;
 }
 
+static inline u64 arch_counter_get_cntpct(void)
+{
+	u64 cval;
+
+	isb();
+	asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (cval));
+	return cval;
+}
+
 static inline u64 arch_counter_get_cntvct(void)
 {
 	u64 cval;
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -104,6 +104,15 @@ static inline void arch_timer_set_cntkct
 	asm volatile("msr	cntkctl_el1, %0" : : "r" (cntkctl));
 }
 
+static inline u64 arch_counter_get_cntpct(void)
+{
+	/*
+	 * AArch64 kernel and user space mandate the use of CNTVCT.
+	 */
+	BUG();
+	return 0;
+}
+
 static inline u64 arch_counter_get_cntvct(void)
 {
 	u64 cval;
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -462,7 +462,10 @@ static void __init arch_counter_register
 
 	/* Register the CP15 based counter if we have one */
 	if (type & ARCH_CP15_TIMER) {
-		arch_timer_read_counter = arch_counter_get_cntvct;
+		if (arch_timer_use_virtual)
+			arch_timer_read_counter = arch_counter_get_cntvct;
+		else
+			arch_timer_read_counter = arch_counter_get_cntpct;
 	} else {
 		arch_timer_read_counter = arch_counter_get_cntvct_mem;
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 08/84] mfd: twl4030-power: Fix regression with missing compatible flag
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 07/84] clocksource: arch_timer: Fix code to use physical timers when requested Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 09/84] mfd: tc6393xb: Fail ohci suspend if full state restore is required Greg Kroah-Hartman
                   ` (76 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dr. H. Nikolaus Schaller,
	Tony Lindgren, Lee Jones

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

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

From: Tony Lindgren <tony@atomide.com>

commit 1b9b46d05f887aec418b3a5f4f55abf79316fcda upstream.

Commit e7cd1d1eb16f ("mfd: twl4030-power: Add generic reset
configuration") accidentally removed the compatible flag for
"ti,twl4030-power" that should be there as documented in the
binding.

If "ti,twl4030-power" only the poweroff configuration is done
by the driver.

Fixes: e7cd1d1eb16f ("mfd: twl4030-power: Add generic reset configuration")
Reported-by: "Dr. H. Nikolaus Schaller" <hns@goldelico.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mfd/twl4030-power.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -831,6 +831,9 @@ static struct twl4030_power_data osc_off
 
 static struct of_device_id twl4030_power_of_match[] = {
 	{
+		.compatible = "ti,twl4030-power",
+	},
+	{
 		.compatible = "ti,twl4030-power-reset",
 		.data = &omap3_reset,
 	},



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 09/84] mfd: tc6393xb: Fail ohci suspend if full state restore is required
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (7 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 08/84] mfd: twl4030-power: Fix regression with missing compatible flag Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 10/84] mmc: dw_mmc: avoid write to CDTHRCTL on older versions Greg Kroah-Hartman
                   ` (75 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dmitry Eremin-Solenikov, Lee Jones

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

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

From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

commit 1a5fb99de4850cba710d91becfa2c65653048589 upstream.

Some boards with TC6393XB chip require full state restore during system
resume thanks to chip's VCC being cut off during suspend (Sharp SL-6000
tosa is one of them). Failing to do so would result in ohci Oops on
resume due to internal memory contentes being changed. Fail ohci suspend
on tc6393xb is full state restore is required.

Recommended workaround is to unbind tmio-ohci driver before suspend and
rebind it after resume.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mfd/tc6393xb.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

--- a/drivers/mfd/tc6393xb.c
+++ b/drivers/mfd/tc6393xb.c
@@ -263,6 +263,17 @@ static int tc6393xb_ohci_disable(struct
 	return 0;
 }
 
+static int tc6393xb_ohci_suspend(struct platform_device *dev)
+{
+	struct tc6393xb_platform_data *tcpd = dev_get_platdata(dev->dev.parent);
+
+	/* We can't properly store/restore OHCI state, so fail here */
+	if (tcpd->resume_restore)
+		return -EBUSY;
+
+	return tc6393xb_ohci_disable(dev);
+}
+
 static int tc6393xb_fb_enable(struct platform_device *dev)
 {
 	struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
@@ -403,7 +414,7 @@ static struct mfd_cell tc6393xb_cells[]
 		.num_resources = ARRAY_SIZE(tc6393xb_ohci_resources),
 		.resources = tc6393xb_ohci_resources,
 		.enable = tc6393xb_ohci_enable,
-		.suspend = tc6393xb_ohci_disable,
+		.suspend = tc6393xb_ohci_suspend,
 		.resume = tc6393xb_ohci_enable,
 		.disable = tc6393xb_ohci_disable,
 	},



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 10/84] mmc: dw_mmc: avoid write to CDTHRCTL on older versions
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (8 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 09/84] mfd: tc6393xb: Fail ohci suspend if full state restore is required Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 11/84] mmc: omap_hsmmc: Fix UHS card with DDR50 support Greg Kroah-Hartman
                   ` (74 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, James Hogan, Jaehoon Chung, Ulf Hansson

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

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

From: James Hogan <james.hogan@imgtec.com>

commit 66dfd10173159cafa9cb0d39936b8daeaab8e3e0 upstream.

Commit f1d2736c8156 (mmc: dw_mmc: control card read threshold) added
dw_mci_ctrl_rd_thld() with an unconditional write to the CDTHRCTL
register at offset 0x100. However before version 240a, the FIFO region
started at 0x100, so the write messes with the FIFO and completely
breaks the driver.

If the version id < 240A, return early from dw_mci_ctl_rd_thld() so as
not to hit this problem.

Fixes: f1d2736c8156 (mmc: dw_mmc: control card read threshold)
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mmc/host/dw_mmc.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -626,6 +626,13 @@ static void dw_mci_ctrl_rd_thld(struct d
 
 	WARN_ON(!(data->flags & MMC_DATA_READ));
 
+	/*
+	 * CDTHRCTL doesn't exist prior to 240A (in fact that register offset is
+	 * in the FIFO region, so we really shouldn't access it).
+	 */
+	if (host->verid < DW_MMC_240A)
+		return;
+
 	if (host->timing != MMC_TIMING_MMC_HS200 &&
 	    host->timing != MMC_TIMING_UHS_SDR104)
 		goto disable;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 11/84] mmc: omap_hsmmc: Fix UHS card with DDR50 support
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (9 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 10/84] mmc: dw_mmc: avoid write to CDTHRCTL on older versions Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 12/84] mmc: block: add newline to sysfs display of force_ro Greg Kroah-Hartman
                   ` (73 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Kishon Vijay Abraham I, Ulf Hansson

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

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

From: Ulf Hansson <ulf.hansson@linaro.org>

commit 903101a83949d6fc77c092cef07e9c1e10c07e46 upstream.

The commit, mmc: omap: clarify DDR timing mode between SD-UHS and eMMC,
switched omap_hsmmc to support MMC DDR mode instead of UHS DDR50 mode.

Add UHS DDR50 mode again and this time let's also keep the MMC DDR mode.

Fixes: 5438ad95a57c (mmc: omap: clarify DDR timing mode between SD-UHS and eMMC)
Reported-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mmc/host/omap_hsmmc.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -609,6 +609,7 @@ static void omap_hsmmc_set_clock(struct
 	 */
 	if ((mmc_slot(host).features & HSMMC_HAS_HSPE_SUPPORT) &&
 	    (ios->timing != MMC_TIMING_MMC_DDR52) &&
+	    (ios->timing != MMC_TIMING_UHS_DDR50) &&
 	    ((OMAP_HSMMC_READ(host->base, CAPA) & HSS) == HSS)) {
 		regval = OMAP_HSMMC_READ(host->base, HCTL);
 		if (clkdiv && (clk_get_rate(host->fclk)/clkdiv) > 25000000)
@@ -628,7 +629,8 @@ static void omap_hsmmc_set_bus_width(str
 	u32 con;
 
 	con = OMAP_HSMMC_READ(host->base, CON);
-	if (ios->timing == MMC_TIMING_MMC_DDR52)
+	if (ios->timing == MMC_TIMING_MMC_DDR52 ||
+	    ios->timing == MMC_TIMING_UHS_DDR50)
 		con |= DDR;	/* configure in DDR mode */
 	else
 		con &= ~DDR;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 12/84] mmc: block: add newline to sysfs display of force_ro
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (10 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 11/84] mmc: omap_hsmmc: Fix UHS card with DDR50 support Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 13/84] mmc: sdhci-pci-o2micro: Fix Dell E5440 issue Greg Kroah-Hartman
                   ` (72 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andrei Warkentin, Baruch Siach, Ulf Hansson

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

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

From: Baruch Siach <baruch@tkos.co.il>

commit 0031a98a85e9fca282624bfc887f9531b2768396 upstream.

Make force_ro consistent with other sysfs entries.

Fixes: 371a689f64b0d ('mmc: MMC boot partitions support')
Cc: Andrei Warkentin <andrey.warkentin@gmail.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mmc/card/block.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -260,7 +260,7 @@ static ssize_t force_ro_show(struct devi
 	int ret;
 	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
 
-	ret = snprintf(buf, PAGE_SIZE, "%d",
+	ret = snprintf(buf, PAGE_SIZE, "%d\n",
 		       get_disk_ro(dev_to_disk(dev)) ^
 		       md->read_only);
 	mmc_blk_put(md);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 13/84] mmc: sdhci-pci-o2micro: Fix Dell E5440 issue
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (11 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 12/84] mmc: block: add newline to sysfs display of force_ro Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 14/84] megaraid_sas: corrected return of wait_event from abort frame path Greg Kroah-Hartman
                   ` (71 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Peter Guo, Ulf Hansson

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

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

From: Peter Guo <peter.guo@bayhubtech.com>

commit 6380ea099cdd46d7377b6fbec0291cf2aa387bad upstream.

Fix Dell E5440 when reboot Linux, can't find o2micro sd host chip issue.

Fixes: 01acf6917aed (mmc: sdhci-pci: add support of O2Micro/BayHubTech SD hosts)
Signed-off-by: Peter Guo <peter.guo@bayhubtech.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mmc/host/sdhci-pci-o2micro.c |    2 --
 1 file changed, 2 deletions(-)

--- a/drivers/mmc/host/sdhci-pci-o2micro.c
+++ b/drivers/mmc/host/sdhci-pci-o2micro.c
@@ -127,8 +127,6 @@ void sdhci_pci_o2_fujin2_pci_init(struct
 		return;
 	scratch_32 &= ~((1 << 21) | (1 << 30));
 
-	/* Set RTD3 function disabled */
-	scratch_32 |= ((1 << 29) | (1 << 28));
 	pci_write_config_dword(chip->pdev, O2_SD_FUNC_REG3, scratch_32);
 
 	/* Set L1 Entrance Timer */



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 14/84] megaraid_sas: corrected return of wait_event from abort frame path
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (12 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 13/84] mmc: sdhci-pci-o2micro: Fix Dell E5440 issue Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 15/84] megaraid_sas: dndinaness related bug fixes Greg Kroah-Hartman
                   ` (70 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Sumit Saxena, Kashyap Desai,
	Tomas Henzl, Christoph Hellwig

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

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

From: "Sumit.Saxena@avagotech.com" <Sumit.Saxena@avagotech.com>

commit 170c238701ec38b1829321b17c70671c101bac55 upstream.

Corrected wait_event() call which was waiting for wrong completion
status (0xFF).

Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/megaraid/megaraid_sas_base.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1008,7 +1008,7 @@ megasas_issue_blocked_abort_cmd(struct m
 		cpu_to_le32(upper_32_bits(cmd_to_abort->frame_phys_addr));
 
 	cmd->sync_cmd = 1;
-	cmd->cmd_status = 0xFF;
+	cmd->cmd_status = ENODATA;
 
 	instance->instancet->issue_dcmd(instance, cmd);
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 15/84] megaraid_sas: dndinaness related bug fixes
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (13 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 14/84] megaraid_sas: corrected return of wait_event from abort frame path Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 16/84] regulator: anatop: Set default voltage selector for vddpu Greg Kroah-Hartman
                   ` (69 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Sumit Saxena, Kashyap Desai,
	Tomas Henzl, Christoph Hellwig

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

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

From: "Sumit.Saxena@avagotech.com" <Sumit.Saxena@avagotech.com>

commit 6e755ddc2935d970574263db3eca547eb70e67d7 upstream.

This patch addresses few endianness related bug fixes.

Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/megaraid/megaraid_sas_fp.c     |   17 +++++++++--------
 drivers/scsi/megaraid/megaraid_sas_fusion.c |   13 +++++++------
 2 files changed, 16 insertions(+), 14 deletions(-)

--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -183,14 +183,15 @@ void MR_PopulateDrvRaidMap(struct megasa
 		/* New Raid map will not set totalSize, so keep expected value
 		 * for legacy code in ValidateMapInfo
 		 */
-		pDrvRaidMap->totalSize = sizeof(struct MR_FW_RAID_MAP_EXT);
+		pDrvRaidMap->totalSize =
+			cpu_to_le32(sizeof(struct MR_FW_RAID_MAP_EXT));
 	} else {
 		fw_map_old = (struct MR_FW_RAID_MAP_ALL *)
 			fusion->ld_map[(instance->map_id & 1)];
 		pFwRaidMap = &fw_map_old->raidMap;
 
 #if VD_EXT_DEBUG
-		for (i = 0; i < pFwRaidMap->ldCount; i++) {
+		for (i = 0; i < le16_to_cpu(pFwRaidMap->ldCount); i++) {
 			dev_dbg(&instance->pdev->dev, "(%d) :Index 0x%x "
 				"Target Id 0x%x Seq Num 0x%x Size 0/%llx\n",
 				instance->unique_id, i,
@@ -202,12 +203,12 @@ void MR_PopulateDrvRaidMap(struct megasa
 
 		memset(drv_map, 0, fusion->drv_map_sz);
 		pDrvRaidMap->totalSize = pFwRaidMap->totalSize;
-		pDrvRaidMap->ldCount = pFwRaidMap->ldCount;
+		pDrvRaidMap->ldCount = (__le16)pFwRaidMap->ldCount;
 		pDrvRaidMap->fpPdIoTimeoutSec = pFwRaidMap->fpPdIoTimeoutSec;
 		for (i = 0; i < MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS; i++)
 			pDrvRaidMap->ldTgtIdToLd[i] =
 				(u8)pFwRaidMap->ldTgtIdToLd[i];
-		for (i = 0; i < pDrvRaidMap->ldCount; i++) {
+		for (i = 0; i < le16_to_cpu(pDrvRaidMap->ldCount); i++) {
 			pDrvRaidMap->ldSpanMap[i] = pFwRaidMap->ldSpanMap[i];
 #if VD_EXT_DEBUG
 			dev_dbg(&instance->pdev->dev,
@@ -268,7 +269,7 @@ u8 MR_ValidateMapInfo(struct megasas_ins
 	else
 		expected_size =
 			(sizeof(struct MR_FW_RAID_MAP) - sizeof(struct MR_LD_SPAN_MAP) +
-			(sizeof(struct MR_LD_SPAN_MAP) * le32_to_cpu(pDrvRaidMap->ldCount)));
+			(sizeof(struct MR_LD_SPAN_MAP) * le16_to_cpu(pDrvRaidMap->ldCount)));
 
 	if (le32_to_cpu(pDrvRaidMap->totalSize) != expected_size) {
 		dev_err(&instance->pdev->dev, "map info structure size 0x%x is not matching with ld count\n",
@@ -284,7 +285,7 @@ u8 MR_ValidateMapInfo(struct megasas_ins
 
 	mr_update_load_balance_params(drv_map, lbInfo);
 
-	num_lds = le32_to_cpu(drv_map->raidMap.ldCount);
+	num_lds = le16_to_cpu(drv_map->raidMap.ldCount);
 
 	/*Convert Raid capability values to CPU arch */
 	for (ldCount = 0; ldCount < num_lds; ldCount++) {
@@ -457,7 +458,7 @@ u32 mr_spanset_get_span_block(struct meg
 				quad = &map->raidMap.ldSpanMap[ld].
 					spanBlock[span].
 					block_span_info.quad[info];
-				if (le32_to_cpu(quad->diff == 0))
+				if (le32_to_cpu(quad->diff) == 0)
 					return SPAN_INVALID;
 				if (le64_to_cpu(quad->logStart) <= row  &&
 					row <= le64_to_cpu(quad->logEnd)  &&
@@ -520,7 +521,7 @@ static u64  get_row_from_strip(struct me
 				span_set->span_row_data_width) * span_set->diff;
 		for (span = 0, span_offset = 0; span < raid->spanDepth; span++)
 			if (le32_to_cpu(map->raidMap.ldSpanMap[ld].spanBlock[span].
-				block_span_info.noElements >= info+1)) {
+				block_span_info.noElements) >= info+1) {
 				if (strip_offset >=
 					span_set->strip_offset[span])
 					span_offset++;
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -880,7 +880,7 @@ megasas_sync_map_info(struct megasas_ins
 
 	map = fusion->ld_drv_map[instance->map_id & 1];
 
-	num_lds = le32_to_cpu(map->raidMap.ldCount);
+	num_lds = le16_to_cpu(map->raidMap.ldCount);
 
 	dcmd = &cmd->frame->dcmd;
 
@@ -1173,9 +1173,10 @@ megasas_fire_cmd_fusion(struct megasas_i
 			struct megasas_register_set __iomem *regs)
 {
 #if defined(writeq) && defined(CONFIG_64BIT)
-	u64 req_data = (((u64)req_desc_hi << 32) | (u32)req_desc_lo);
+	u64 req_data = (((u64)le32_to_cpu(req_desc_hi) << 32) |
+			le32_to_cpu(req_desc_lo));
 
-	writeq(le64_to_cpu(req_data), &(regs)->inbound_low_queue_port);
+	writeq(req_data, &(regs)->inbound_low_queue_port);
 #else
 	unsigned long flags;
 
@@ -1373,7 +1374,7 @@ megasas_set_pd_lba(struct MPI2_RAID_SCSI
 		/* Logical block reference tag */
 		io_request->CDB.EEDP32.PrimaryReferenceTag =
 			cpu_to_be32(ref_tag);
-		io_request->CDB.EEDP32.PrimaryApplicationTagMask = 0xffff;
+		io_request->CDB.EEDP32.PrimaryApplicationTagMask = cpu_to_be16(0xffff);
 		io_request->IoFlags = cpu_to_le16(32); /* Specify 32-byte cdb */
 
 		/* Transfer length */
@@ -1769,7 +1770,7 @@ megasas_build_dcdb_fusion(struct megasas
 
 		/* set RAID context values */
 		pRAID_Context->regLockFlags     = REGION_TYPE_SHARED_READ;
-		pRAID_Context->timeoutValue     = raid->fpIoTimeoutForLd;
+		pRAID_Context->timeoutValue     = cpu_to_le16(raid->fpIoTimeoutForLd);
 		pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id);
 		pRAID_Context->regLockRowLBA    = 0;
 		pRAID_Context->regLockLength    = 0;
@@ -2254,7 +2255,7 @@ build_mpt_mfi_pass_thru(struct megasas_i
 	 * megasas_complete_cmd
 	 */
 
-	if (frame_hdr->flags & MFI_FRAME_DONT_POST_IN_REPLY_QUEUE)
+	if (frame_hdr->flags & cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE))
 		cmd->flags = MFI_FRAME_DONT_POST_IN_REPLY_QUEUE;
 
 	fusion = instance->ctrl_context;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 16/84] regulator: anatop: Set default voltage selector for vddpu
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (14 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 15/84] megaraid_sas: dndinaness related bug fixes Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 17/84] scsi: correct return values for .eh_abort_handler implementations Greg Kroah-Hartman
                   ` (68 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Markus Pargmann, Mark Brown

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

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

From: Markus Pargmann <mpa@pengutronix.de>

commit fe08be3ec8672ed92b3ed1b85810df9fa0f98931 upstream.

The code reads the default voltage selector from its register. If the
bootloader disables the regulator, the default voltage selector will be
0 which results in faulty behaviour of this regulator driver.

This patch sets a default voltage selector for vddpu if it is not set in
the register.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/regulator/anatop-regulator.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -283,6 +283,14 @@ static int anatop_regulator_probe(struct
 			sreg->sel = 0;
 			sreg->bypass = true;
 		}
+
+		/*
+		 * In case vddpu was disabled by the bootloader, we need to set
+		 * a sane default until imx6-cpufreq was probed and changes the
+		 * voltage to the correct value. In this case we set 1.25V.
+		 */
+		if (!sreg->sel && !strcmp(sreg->name, "vddpu"))
+			sreg->sel = 22;
 	} else {
 		rdesc->ops = &anatop_rops;
 	}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 17/84] scsi: correct return values for .eh_abort_handler implementations
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (15 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 16/84] regulator: anatop: Set default voltage selector for vddpu Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 18/84] f2fs: avoid returning uninitialized value to userspace from f2fs_trim_fs() Greg Kroah-Hartman
                   ` (67 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Robert Elliott, Hannes Reinecke,
	Christoph Hellwig

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

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

From: Hannes Reinecke <hare@suse.de>

commit b6c92b7e0af575e2b8b05bdf33633cf9e1661cbf upstream.

The .eh_abort_handler needs to return SUCCESS, FAILED, or
FAST_IO_FAIL. So fixup all callers to adhere to this requirement.

Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/NCR5380.c            |   12 ++++++------
 drivers/scsi/aha1740.c            |    2 +-
 drivers/scsi/atari_NCR5380.c      |    2 +-
 drivers/scsi/esas2r/esas2r_main.c |    2 +-
 drivers/scsi/megaraid.c           |    8 ++++----
 drivers/scsi/sun3_NCR5380.c       |   10 +++++-----
 6 files changed, 18 insertions(+), 18 deletions(-)

--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -2647,14 +2647,14 @@ static void NCR5380_dma_complete(NCR5380
  *
  * Purpose : abort a command
  *
- * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the 
- *      host byte of the result field to, if zero DID_ABORTED is 
+ * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the
+ *      host byte of the result field to, if zero DID_ABORTED is
  *      used.
  *
- * Returns : 0 - success, -1 on failure.
+ * Returns : SUCCESS - success, FAILED on failure.
  *
- *	XXX - there is no way to abort the command that is currently 
- *	connected, you have to wait for it to complete.  If this is 
+ *	XXX - there is no way to abort the command that is currently
+ *	connected, you have to wait for it to complete.  If this is
  *	a problem, we could implement longjmp() / setjmp(), setjmp()
  *	called where the loop started in NCR5380_main().
  *
@@ -2704,7 +2704,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd
  * aborted flag and get back into our main loop.
  */
 
-		return 0;
+		return SUCCESS;
 	}
 #endif
 
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -531,7 +531,7 @@ static int aha1740_eh_abort_handler (Scs
  * quiet as possible...
  */
 
-	return 0;
+	return SUCCESS;
 }
 
 static struct scsi_host_template aha1740_template = {
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -2607,7 +2607,7 @@ static void NCR5380_reselect(struct Scsi
  *	host byte of the result field to, if zero DID_ABORTED is
  *	used.
  *
- * Returns : 0 - success, -1 on failure.
+ * Returns : SUCCESS - success, FAILED on failure.
  *
  * XXX - there is no way to abort the command that is currently
  *	 connected, you have to wait for it to complete.  If this is
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -1057,7 +1057,7 @@ int esas2r_eh_abort(struct scsi_cmnd *cm
 
 		cmd->scsi_done(cmd);
 
-		return 0;
+		return SUCCESS;
 	}
 
 	spin_lock_irqsave(&a->queue_lock, flags);
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -1945,7 +1945,7 @@ megaraid_abort_and_reset(adapter_t *adap
 	     cmd->device->id, (u32)cmd->device->lun);
 
 	if(list_empty(&adapter->pending_list))
-		return FALSE;
+		return FAILED;
 
 	list_for_each_safe(pos, next, &adapter->pending_list) {
 
@@ -1968,7 +1968,7 @@ megaraid_abort_and_reset(adapter_t *adap
 					(aor==SCB_ABORT) ? "ABORTING":"RESET",
 					scb->idx);
 
-				return FALSE;
+				return FAILED;
 			}
 			else {
 
@@ -1993,12 +1993,12 @@ megaraid_abort_and_reset(adapter_t *adap
 				list_add_tail(SCSI_LIST(cmd),
 						&adapter->completed_list);
 
-				return TRUE;
+				return SUCCESS;
 			}
 		}
 	}
 
-	return FALSE;
+	return FAILED;
 }
 
 static inline int
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -2590,15 +2590,15 @@ static void NCR5380_reselect (struct Scs
  * Purpose : abort a command
  *
  * Inputs : cmd - the struct scsi_cmnd to abort, code - code to set the
- * 	host byte of the result field to, if zero DID_ABORTED is 
+ *	host byte of the result field to, if zero DID_ABORTED is
  *	used.
  *
- * Returns : 0 - success, -1 on failure.
+ * Returns : SUCCESS - success, FAILED on failure.
  *
- * XXX - there is no way to abort the command that is currently 
- * 	 connected, you have to wait for it to complete.  If this is 
+ * XXX - there is no way to abort the command that is currently
+ *	 connected, you have to wait for it to complete.  If this is
  *	 a problem, we could implement longjmp() / setjmp(), setjmp()
- * 	 called where the loop started in NCR5380_main().
+ *	 called where the loop started in NCR5380_main().
  */
 
 static int NCR5380_abort(struct scsi_cmnd *cmd)



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 18/84] f2fs: avoid returning uninitialized value to userspace from f2fs_trim_fs()
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (16 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 17/84] scsi: correct return values for .eh_abort_handler implementations Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 19/84] f2fs: fix possible data corruption in f2fs_write_begin() Greg Kroah-Hartman
                   ` (66 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jan Kara, Jaegeuk Kim

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

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

From: Jan Kara <jack@suse.cz>

commit 9bd27ae4aafc9bfee6c8791f7d801ea16cc5622b upstream.

If user specifies too low end sector for trimming, f2fs_trim_fs() will
use uninitialized value as a number of trimmed blocks and returns it to
userspace. Initialize number of trimmed blocks early to avoid the
problem.

Coverity-id: 1248809
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/f2fs/segment.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1004,6 +1004,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sb
 						range->len < sbi->blocksize)
 		return -EINVAL;
 
+	cpc.trimmed = 0;
 	if (end <= MAIN_BLKADDR(sbi))
 		goto out;
 
@@ -1015,7 +1016,6 @@ int f2fs_trim_fs(struct f2fs_sb_info *sb
 	cpc.trim_start = start_segno;
 	cpc.trim_end = end_segno;
 	cpc.trim_minlen = range->minlen >> sbi->log_blocksize;
-	cpc.trimmed = 0;
 
 	/* do checkpoint to issue discard commands safely */
 	write_checkpoint(sbi, &cpc);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 19/84] f2fs: fix possible data corruption in f2fs_write_begin()
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (17 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 18/84] f2fs: avoid returning uninitialized value to userspace from f2fs_trim_fs() Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 20/84] nfs41: fix nfs4_proc_layoutget error handling Greg Kroah-Hartman
                   ` (65 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Changman Lee, Jan Kara, Jaegeuk Kim

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

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

From: Jan Kara <jack@suse.cz>

commit 9234f3190bf8b25b11b105191d408ac50a107948 upstream.

f2fs_write_begin() doesn't initialize the 'dn' variable if the inode has
inline data. However it uses its contents to decide whether it should
just zero out the page or load data to it. Thus if we are unlucky we can
zero out page contents instead of loading inline data into a page.

CC: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/f2fs/data.c |   24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1007,21 +1007,19 @@ inline_data:
 		goto out;
 	}
 
-	if (dn.data_blkaddr == NEW_ADDR) {
+	if (f2fs_has_inline_data(inode)) {
+		err = f2fs_read_inline_data(inode, page);
+		if (err) {
+			page_cache_release(page);
+			goto fail;
+		}
+	} else if (dn.data_blkaddr == NEW_ADDR) {
 		zero_user_segment(page, 0, PAGE_CACHE_SIZE);
 	} else {
-		if (f2fs_has_inline_data(inode)) {
-			err = f2fs_read_inline_data(inode, page);
-			if (err) {
-				page_cache_release(page);
-				goto fail;
-			}
-		} else {
-			err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
-							READ_SYNC);
-			if (err)
-				goto fail;
-		}
+		err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
+					   READ_SYNC);
+		if (err)
+			goto fail;
 
 		lock_page(page);
 		if (unlikely(!PageUptodate(page))) {



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 20/84] nfs41: fix nfs4_proc_layoutget error handling
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (18 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 19/84] f2fs: fix possible data corruption in f2fs_write_begin() Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 21/84] dcache: fix kmemcheck warning in switch_names Greg Kroah-Hartman
                   ` (64 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Peng Tao, Trond Myklebust

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

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

From: Peng Tao <tao.peng@primarydata.com>

commit 4bd5a980de87d2b5af417485bde97b8eb3d6cf6a upstream.

nfs4_layoutget_release() drops layout hdr refcnt. Grab the refcnt
early so that it is safe to call .release in case nfs4_alloc_pages
fails.

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Fixes: a47970ff78147 ("NFSv4.1: Hold reference to layout hdr in layoutget")
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/nfs/nfs4proc.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7704,6 +7704,9 @@ nfs4_proc_layoutget(struct nfs4_layoutge
 
 	dprintk("--> %s\n", __func__);
 
+	/* nfs4_layoutget_release calls pnfs_put_layout_hdr */
+	pnfs_get_layout_hdr(NFS_I(inode)->layout);
+
 	lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags);
 	if (!lgp->args.layout.pages) {
 		nfs4_layoutget_release(lgp);
@@ -7716,9 +7719,6 @@ nfs4_proc_layoutget(struct nfs4_layoutge
 	lgp->res.seq_res.sr_slot = NULL;
 	nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0);
 
-	/* nfs4_layoutget_release calls pnfs_put_layout_hdr */
-	pnfs_get_layout_hdr(NFS_I(inode)->layout);
-
 	task = rpc_run_task(&task_setup_data);
 	if (IS_ERR(task))
 		return ERR_CAST(task);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 21/84] dcache: fix kmemcheck warning in switch_names
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (19 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 20/84] nfs41: fix nfs4_proc_layoutget error handling Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 22/84] dm bufio: fix memleak when using a dm_buffers inline bio Greg Kroah-Hartman
                   ` (63 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Mikulas Patocka, Al Viro

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

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

From: Mikulas Patocka <mpatocka@redhat.com>

commit 08d4f7722268755ee34ed1c9e8afee7dfff022bb upstream.

This patch fixes kmemcheck warning in switch_names. The function
switch_names swaps inline names of two dentries. It swaps full arrays
d_iname, no matter how many bytes are really used by the strings. Reading
data beyond string ends results in kmemcheck warning.

We fix the bug by marking both arrays as fully initialized.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/dcache.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2393,6 +2393,8 @@ static void swap_names(struct dentry *de
 			 */
 			unsigned int i;
 			BUILD_BUG_ON(!IS_ALIGNED(DNAME_INLINE_LEN, sizeof(long)));
+			kmemcheck_mark_initialized(dentry->d_iname, DNAME_INLINE_LEN);
+			kmemcheck_mark_initialized(target->d_iname, DNAME_INLINE_LEN);
 			for (i = 0; i < DNAME_INLINE_LEN / sizeof(long); i++) {
 				swap(((long *) &dentry->d_iname)[i],
 				     ((long *) &target->d_iname)[i]);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 22/84] dm bufio: fix memleak when using a dm_buffers inline bio
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (20 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 21/84] dcache: fix kmemcheck warning in switch_names Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 23/84] dm crypt: use memzero_explicit for on-stack buffer Greg Kroah-Hartman
                   ` (62 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Darrick J. Wong, Mikulas Patocka,
	Mike Snitzer

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

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

From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 445559cdcb98a141f5de415b94fd6eaccab87e6d upstream.

When dm-bufio sets out to use the bio built into a struct dm_buffer to
issue an IO, it needs to call bio_reset after it's done with the bio
so that we can free things attached to the bio such as the integrity
payload.  Therefore, inject our own endio callback to take care of
the bio_reset after calling submit_io's end_io callback.

Test case:
1. modprobe scsi_debug delay=0 dif=1 dix=199 ato=1 dev_size_mb=300
2. Set up a dm-bufio client, e.g. dm-verity, on the scsi_debug device
3. Repeatedly read metadata and watch kmalloc-192 leak!

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-bufio.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -532,6 +532,19 @@ static void use_dmio(struct dm_buffer *b
 		end_io(&b->bio, r);
 }
 
+static void inline_endio(struct bio *bio, int error)
+{
+	bio_end_io_t *end_fn = bio->bi_private;
+
+	/*
+	 * Reset the bio to free any attached resources
+	 * (e.g. bio integrity profiles).
+	 */
+	bio_reset(bio);
+
+	end_fn(bio, error);
+}
+
 static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block,
 			   bio_end_io_t *end_io)
 {
@@ -543,7 +556,12 @@ static void use_inline_bio(struct dm_buf
 	b->bio.bi_max_vecs = DM_BUFIO_INLINE_VECS;
 	b->bio.bi_iter.bi_sector = block << b->c->sectors_per_block_bits;
 	b->bio.bi_bdev = b->c->bdev;
-	b->bio.bi_end_io = end_io;
+	b->bio.bi_end_io = inline_endio;
+	/*
+	 * Use of .bi_private isn't a problem here because
+	 * the dm_buffer's inline bio is local to bufio.
+	 */
+	b->bio.bi_private = end_io;
 
 	/*
 	 * We assume that if len >= PAGE_SIZE ptr is page-aligned.



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 23/84] dm crypt: use memzero_explicit for on-stack buffer
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (21 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 22/84] dm bufio: fix memleak when using a dm_buffers inline bio Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 24/84] dm cache: only use overwrite optimisation for promotion when in writeback mode Greg Kroah-Hartman
                   ` (61 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Milan Broz, Mike Snitzer

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

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

From: Milan Broz <gmazyland@gmail.com>

commit 1a71d6ffe18c0d0f03fc8531949cc8ed41d702ee upstream.

Use memzero_explicit to cleanup sensitive data allocated on stack
to prevent the compiler from optimizing and removing memset() calls.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-crypt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -705,7 +705,7 @@ static int crypt_iv_tcw_whitening(struct
 	for (i = 0; i < ((1 << SECTOR_SHIFT) / 8); i++)
 		crypto_xor(data + i * 8, buf, 8);
 out:
-	memset(buf, 0, sizeof(buf));
+	memzero_explicit(buf, sizeof(buf));
 	return r;
 }
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 24/84] dm cache: only use overwrite optimisation for promotion when in writeback mode
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (22 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 23/84] dm crypt: use memzero_explicit for on-stack buffer Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 25/84] dm cache: dirty flag was mistakenly being cleared when promoting via overwrite Greg Kroah-Hartman
                   ` (60 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Joe Thornber, Mike Snitzer

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

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

From: Joe Thornber <ejt@redhat.com>

commit f29a3147e251d7ae20d3194ff67f109d71e501b4 upstream.

Overwrite causes the cache block and origin blocks to diverge, which
is only allowed in writeback mode.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-cache-target.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -1070,7 +1070,8 @@ static void issue_copy(struct dm_cache_m
 
 		avoid = is_discarded_oblock(cache, mg->new_oblock);
 
-		if (!avoid && bio_writes_complete_block(cache, bio)) {
+		if (writeback_mode(&cache->features) &&
+		    !avoid && bio_writes_complete_block(cache, bio)) {
 			issue_overwrite(mg, bio);
 			return;
 		}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 25/84] dm cache: dirty flag was mistakenly being cleared when promoting via overwrite
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (23 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 24/84] dm cache: only use overwrite optimisation for promotion when in writeback mode Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 26/84] dm cache: fix spurious cell_defer when dealing with partial block at end of device Greg Kroah-Hartman
                   ` (59 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Joe Thornber, Mike Snitzer

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

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

From: Joe Thornber <ejt@redhat.com>

commit 1e32134a5a404e80bfb47fad8a94e9bbfcbdacc5 upstream.

If the incoming bio is a WRITE and completely covers a block then we
don't bother to do any copying for a promotion operation.  Once this is
done the cache block and origin block will be different, so we need to
set it to 'dirty'.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-cache-target.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -951,10 +951,14 @@ static void migration_success_post_commi
 		}
 
 	} else {
-		clear_dirty(cache, mg->new_oblock, mg->cblock);
-		if (mg->requeue_holder)
+		if (mg->requeue_holder) {
+			clear_dirty(cache, mg->new_oblock, mg->cblock);
 			cell_defer(cache, mg->new_ocell, true);
-		else {
+		} else {
+			/*
+			 * The block was promoted via an overwrite, so it's dirty.
+			 */
+			set_dirty(cache, mg->new_oblock, mg->cblock);
 			bio_endio(mg->new_ocell->holder, 0);
 			cell_defer(cache, mg->new_ocell, false);
 		}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 26/84] dm cache: fix spurious cell_defer when dealing with partial block at end of device
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (24 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 25/84] dm cache: dirty flag was mistakenly being cleared when promoting via overwrite Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 27/84] dm space map metadata: fix sm_bootstrap_get_nr_blocks() Greg Kroah-Hartman
                   ` (58 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Joe Thornber, Mike Snitzer

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

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

From: Joe Thornber <ejt@redhat.com>

commit f824a2af3dfbbb766c02e19df21f985bceadf0ee upstream.

We never bother caching a partial block that is at the back end of the
origin device.  No cell ever gets locked, but the calling code was
assuming it was and trying to release it.

Now the code only releases if the cell has been set to a non NULL
value.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-cache-target.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2554,11 +2554,11 @@ static int __cache_map(struct cache *cac
 static int cache_map(struct dm_target *ti, struct bio *bio)
 {
 	int r;
-	struct dm_bio_prison_cell *cell;
+	struct dm_bio_prison_cell *cell = NULL;
 	struct cache *cache = ti->private;
 
 	r = __cache_map(cache, bio, &cell);
-	if (r == DM_MAPIO_REMAPPED) {
+	if (r == DM_MAPIO_REMAPPED && cell) {
 		inc_ds(cache, bio, cell);
 		cell_defer(cache, cell, false);
 	}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 27/84] dm space map metadata: fix sm_bootstrap_get_nr_blocks()
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (25 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 26/84] dm cache: fix spurious cell_defer when dealing with partial block at end of device Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 28/84] dm thin: fix inability to discard blocks when in out-of-data-space mode Greg Kroah-Hartman
                   ` (57 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dan Carpenter, Joe Thornber, Mike Snitzer

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

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

From: Dan Carpenter <dan.carpenter@oracle.com>

commit c1c6156fe4d4577444b769d7edd5dd503e57bbc9 upstream.

This function isn't right and it causes a static checker warning:

	drivers/md/dm-thin.c:3016 maybe_resize_data_dev()
	error: potentially using uninitialized 'sb_data_size'.

It should set "*count" and return zero on success the same as the
sm_metadata_get_nr_blocks() function does earlier.

Fixes: 3241b1d3e0aa ('dm: add persistent data library')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/persistent-data/dm-space-map-metadata.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/md/persistent-data/dm-space-map-metadata.c
+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
@@ -564,7 +564,9 @@ static int sm_bootstrap_get_nr_blocks(st
 {
 	struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
 
-	return smm->ll.nr_blocks;
+	*count = smm->ll.nr_blocks;
+
+	return 0;
 }
 
 static int sm_bootstrap_get_nr_free(struct dm_space_map *sm, dm_block_t *count)



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 28/84] dm thin: fix inability to discard blocks when in out-of-data-space mode
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (26 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 27/84] dm space map metadata: fix sm_bootstrap_get_nr_blocks() Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 29/84] dm thin: fix missing out-of-data-space to write mode transition if blocks are released Greg Kroah-Hartman
                   ` (56 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Eric Sandeen, Joe Thornber, Mike Snitzer

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

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

From: Joe Thornber <ejt@redhat.com>

commit 45ec9bd0fd7abf8705e7cf12205ff69fe9d51181 upstream.

When the pool was in PM_OUT_OF_SPACE mode its process_prepared_discard
function pointer was incorrectly being set to
process_prepared_discard_passdown rather than process_prepared_discard.

This incorrect function pointer meant the discard was being passed down,
but not effecting the mapping.  As such any discard that was issued, in
an attempt to reclaim blocks, would not successfully free data space.

Reported-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-thin.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1824,7 +1824,7 @@ static void set_pool_mode(struct pool *p
 		pool->process_bio = process_bio_read_only;
 		pool->process_discard = process_discard;
 		pool->process_prepared_mapping = process_prepared_mapping;
-		pool->process_prepared_discard = process_prepared_discard_passdown;
+		pool->process_prepared_discard = process_prepared_discard;
 
 		if (!pool->pf.error_if_no_space && no_space_timeout)
 			queue_delayed_work(pool->wq, &pool->no_space_timeout, no_space_timeout);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 29/84] dm thin: fix missing out-of-data-space to write mode transition if blocks are released
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (27 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 28/84] dm thin: fix inability to discard blocks when in out-of-data-space mode Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 30/84] dm thin: fix a race in thin_dtr Greg Kroah-Hartman
                   ` (55 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Joe Thornber, Mike Snitzer

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

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

From: Joe Thornber <ejt@redhat.com>

commit 2c43fd26e46734430122b8d2ad3024bb532df3ef upstream.

Discard bios and thin device deletion have the potential to release data
blocks.  If the thin-pool is in out-of-data-space mode, and blocks were
released, transition the thin-pool back to full write mode.

The correct time to do this is just after the thin-pool metadata commit.
It cannot be done before the commit because the space maps will not
allow immediate reuse of the data blocks in case there's a rollback
following power failure.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-thin.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -990,6 +990,24 @@ static void schedule_external_copy(struc
 		schedule_zero(tc, virt_block, data_dest, cell, bio);
 }
 
+static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
+
+static void check_for_space(struct pool *pool)
+{
+	int r;
+	dm_block_t nr_free;
+
+	if (get_pool_mode(pool) != PM_OUT_OF_DATA_SPACE)
+		return;
+
+	r = dm_pool_get_free_block_count(pool->pmd, &nr_free);
+	if (r)
+		return;
+
+	if (nr_free)
+		set_pool_mode(pool, PM_WRITE);
+}
+
 /*
  * A non-zero return indicates read_only or fail_io mode.
  * Many callers don't care about the return value.
@@ -1004,6 +1022,8 @@ static int commit(struct pool *pool)
 	r = dm_pool_commit_metadata(pool->pmd);
 	if (r)
 		metadata_operation_failed(pool, "dm_pool_commit_metadata", r);
+	else
+		check_for_space(pool);
 
 	return r;
 }
@@ -1022,8 +1042,6 @@ static void check_low_water_mark(struct
 	}
 }
 
-static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
-
 static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
 {
 	int r;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 30/84] dm thin: fix a race in thin_dtr
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (28 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 29/84] dm thin: fix missing out-of-data-space to write mode transition if blocks are released Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 31/84] arm64: Add COMPAT_HWCAP_LPAE Greg Kroah-Hartman
                   ` (54 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Mikulas Patocka, Mike Snitzer

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

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

From: Mikulas Patocka <mpatocka@redhat.com>

commit 17181fb7a0c3a279196c0eeb2caba65a1519614b upstream.

As long as struct thin_c is in the list, anyone can grab a reference of
it.  Consequently, we must wait for the reference count to drop to zero
*after* we remove the structure from the list, not before.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-thin.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -3266,14 +3266,14 @@ static void thin_dtr(struct dm_target *t
 	struct thin_c *tc = ti->private;
 	unsigned long flags;
 
-	thin_put(tc);
-	wait_for_completion(&tc->can_destroy);
-
 	spin_lock_irqsave(&tc->pool->lock, flags);
 	list_del_rcu(&tc->list);
 	spin_unlock_irqrestore(&tc->pool->lock, flags);
 	synchronize_rcu();
 
+	thin_put(tc);
+	wait_for_completion(&tc->can_destroy);
+
 	mutex_lock(&dm_thin_pool_table.mutex);
 
 	__pool_dec(tc->pool);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 31/84] arm64: Add COMPAT_HWCAP_LPAE
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (29 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 30/84] dm thin: fix a race in thin_dtr Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 32/84] arm64: bpf: lift restriction on last instruction Greg Kroah-Hartman
                   ` (53 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Catalin Marinas, Will Deacon

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

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

From: Catalin Marinas <catalin.marinas@arm.com>

commit 7d57511d2dba03a8046c8b428dd9192a4bfc1e73 upstream.

Commit a469abd0f868 (ARM: elf: add new hwcap for identifying atomic
ldrd/strd instructions) introduces HWCAP_ELF for 32-bit ARM
applications. As LPAE is always present on arm64, report the
corresponding compat HWCAP to user space.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/include/asm/hwcap.h |    1 +
 arch/arm64/kernel/setup.c      |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

--- a/arch/arm64/include/asm/hwcap.h
+++ b/arch/arm64/include/asm/hwcap.h
@@ -30,6 +30,7 @@
 #define COMPAT_HWCAP_IDIVA	(1 << 17)
 #define COMPAT_HWCAP_IDIVT	(1 << 18)
 #define COMPAT_HWCAP_IDIV	(COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT)
+#define COMPAT_HWCAP_LPAE	(1 << 20)
 #define COMPAT_HWCAP_EVTSTRM	(1 << 21)
 
 #define COMPAT_HWCAP2_AES	(1 << 0)
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -72,7 +72,8 @@ EXPORT_SYMBOL_GPL(elf_hwcap);
 				 COMPAT_HWCAP_FAST_MULT|COMPAT_HWCAP_EDSP|\
 				 COMPAT_HWCAP_TLS|COMPAT_HWCAP_VFP|\
 				 COMPAT_HWCAP_VFPv3|COMPAT_HWCAP_VFPv4|\
-				 COMPAT_HWCAP_NEON|COMPAT_HWCAP_IDIV)
+				 COMPAT_HWCAP_NEON|COMPAT_HWCAP_IDIV|\
+				 COMPAT_HWCAP_LPAE)
 unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT;
 unsigned int compat_elf_hwcap2 __read_mostly;
 #endif



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 32/84] arm64: bpf: lift restriction on last instruction
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (30 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 31/84] arm64: Add COMPAT_HWCAP_LPAE Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 33/84] drm/tegra: gem: dumb: pitch and size are outputs Greg Kroah-Hartman
                   ` (52 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Alexei Starovoitov, Zi Shen Lim, Will Deacon

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

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

From: Zi Shen Lim <zlim.lnx@gmail.com>

commit 51c9fbb1b146f3336a93d398c439b6fbfe5ab489 upstream.

Earlier implementation assumed last instruction is BPF_EXIT.
Since this is no longer a restriction in eBPF, we remove this
limitation.

Per Alexei Starovoitov [1]:
> classic BPF has a restriction that last insn is always BPF_RET.
> eBPF doesn't have BPF_RET instruction and this restriction.
> It has BPF_EXIT insn which can appear anywhere in the program
> one or more times and it doesn't have to be last insn.

[1] https://lkml.org/lkml/2014/11/27/2

Fixes: e54bcde3d69d ("arm64: eBPF JIT compiler")
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/net/bpf_jit_comp.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -60,7 +60,7 @@ struct jit_ctx {
 	const struct bpf_prog *prog;
 	int idx;
 	int tmp_used;
-	int body_offset;
+	int epilogue_offset;
 	int *offset;
 	u32 *image;
 };
@@ -130,8 +130,8 @@ static void jit_fill_hole(void *area, un
 
 static inline int epilogue_offset(const struct jit_ctx *ctx)
 {
-	int to = ctx->offset[ctx->prog->len - 1];
-	int from = ctx->idx - ctx->body_offset;
+	int to = ctx->epilogue_offset;
+	int from = ctx->idx;
 
 	return to - from;
 }
@@ -463,6 +463,8 @@ emit_cond_jmp:
 	}
 	/* function return */
 	case BPF_JMP | BPF_EXIT:
+		/* Optimization: when last instruction is EXIT,
+		   simply fallthrough to epilogue. */
 		if (i == ctx->prog->len - 1)
 			break;
 		jmp_offset = epilogue_offset(ctx);
@@ -685,11 +687,13 @@ void bpf_int_jit_compile(struct bpf_prog
 
 	/* 1. Initial fake pass to compute ctx->idx. */
 
-	/* Fake pass to fill in ctx->offset. */
+	/* Fake pass to fill in ctx->offset and ctx->tmp_used. */
 	if (build_body(&ctx))
 		goto out;
 
 	build_prologue(&ctx);
+
+	ctx.epilogue_offset = ctx.idx;
 	build_epilogue(&ctx);
 
 	/* Now we know the actual image size. */
@@ -706,7 +710,6 @@ void bpf_int_jit_compile(struct bpf_prog
 
 	build_prologue(&ctx);
 
-	ctx.body_offset = ctx.idx;
 	if (build_body(&ctx)) {
 		bpf_jit_binary_free(header);
 		goto out;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 33/84] drm/tegra: gem: dumb: pitch and size are outputs
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (31 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 32/84] arm64: bpf: lift restriction on last instruction Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 34/84] ARM: tegra: Re-add removed SoC id macro to tegra_resume() Greg Kroah-Hartman
                   ` (51 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Thierry Reding

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

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

From: Thierry Reding <treding@nvidia.com>

commit dc6057ecb39edb34b0461ca55382094410bd257a upstream.

When creating a dumb buffer object using the DRM_IOCTL_MODE_CREATE_DUMB
IOCTL, only the width, height, bpp and flags parameters are inputs. The
caller is not guaranteed to zero out or set handle, pitch and size, so
the driver must not treat these values as possible inputs.

Fixes a bug where running the Weston compositor on Tegra DRM would cause
an attempt to allocate a 3 GiB framebuffer to be allocated.

Fixes: de2ba664c30f ("gpu: host1x: drm: Add memory manager and fb")
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/tegra/gem.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -259,16 +259,12 @@ void tegra_bo_free_object(struct drm_gem
 int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
 			 struct drm_mode_create_dumb *args)
 {
-	int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+	unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
 	struct tegra_drm *tegra = drm->dev_private;
 	struct tegra_bo *bo;
 
-	min_pitch = round_up(min_pitch, tegra->pitch_align);
-	if (args->pitch < min_pitch)
-		args->pitch = min_pitch;
-
-	if (args->size < args->pitch * args->height)
-		args->size = args->pitch * args->height;
+	args->pitch = round_up(min_pitch, tegra->pitch_align);
+	args->size = args->pitch * args->height;
 
 	bo = tegra_bo_create_with_handle(file, drm, args->size, 0,
 					 &args->handle);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 34/84] ARM: tegra: Re-add removed SoC id macro to tegra_resume()
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (32 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 33/84] drm/tegra: gem: dumb: pitch and size are outputs Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 35/84] ARM: mvebu: make the coherency_ll.S functions work with no coherency fabric Greg Kroah-Hartman
                   ` (50 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Felipe Balbi, Dmitry Osipenko,
	Thierry Reding

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

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

From: Dmitry Osipenko <digetx@gmail.com>

commit e4a680099a6e97ecdbb81081cff9e4a489a4dc44 upstream.

Commit d127e9c ("ARM: tegra: make tegra_resume can work with current and later
chips") removed tegra_get_soc_id macro leaving used cpu register corrupted after
branching to v7_invalidate_l1() and as result causing execution of unintended
code on tegra20. Possibly it was expected that r6 would be SoC id func argument
since common cpu reset handler is setting r6 before branching to tegra_resume(),
but neither tegra20_lp1_reset() nor tegra30_lp1_reset() aren't setting r6
register before jumping to resume function. Fix it by re-adding macro.

Fixes: d127e9c (ARM: tegra: make tegra_resume can work with current and later chips)
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/mach-tegra/reset-handler.S |    1 +
 1 file changed, 1 insertion(+)

--- a/arch/arm/mach-tegra/reset-handler.S
+++ b/arch/arm/mach-tegra/reset-handler.S
@@ -51,6 +51,7 @@ ENTRY(tegra_resume)
  THUMB(	it	ne )
 	bne	cpu_resume			@ no
 
+	tegra_get_soc_id TEGRA_APB_MISC_BASE, r6
 	/* Are we on Tegra20? */
 	cmp	r6, #TEGRA20
 	beq	1f				@ Yes



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 35/84] ARM: mvebu: make the coherency_ll.S functions work with no coherency fabric
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (33 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 34/84] ARM: tegra: Re-add removed SoC id macro to tegra_resume() Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 36/84] ARM: mvebu: disable I/O coherency on non-SMP situations on Armada 370/375/38x/XP Greg Kroah-Hartman
                   ` (49 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Thomas Petazzoni, Gregory CLEMENT,
	Jason Cooper

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

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

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

commit 30cdef97107370a7f63ab5d80fd2de30540750c8 upstream.

The ll_add_cpu_to_smp_group(), ll_enable_coherency() and
ll_disable_coherency() are used on Armada XP to control the coherency
fabric. However, they make the assumption that the coherency fabric is
always available, which is currently a correct assumption but will no
longer be true with a followup commit that disables the usage of the
coherency fabric when the conditions are not met to use it.

Therefore, this commit modifies those functions so that they check the
return value of ll_get_coherency_base(), and if the return value is 0,
they simply return without configuring anything in the coherency
fabric.

The ll_get_coherency_base() function is also modified to properly
return 0 when the function is called with the MMU disabled. In this
case, it normally returns the physical address of the coherency
fabric, but we now check if the virtual address is 0, and if that's
case, return a physical address of 0 to indicate that the coherency
fabric is not enabled.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Link: https://lkml.kernel.org/r/1415871540-20302-2-git-send-email-thomas.petazzoni@free-electrons.com
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/mach-mvebu/coherency_ll.S |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

--- a/arch/arm/mach-mvebu/coherency_ll.S
+++ b/arch/arm/mach-mvebu/coherency_ll.S
@@ -24,7 +24,10 @@
 #include <asm/cp15.h>
 
 	.text
-/* Returns the coherency base address in r1 (r0 is untouched) */
+/*
+ * Returns the coherency base address in r1 (r0 is untouched), or 0 if
+ * the coherency fabric is not enabled.
+ */
 ENTRY(ll_get_coherency_base)
 	mrc	p15, 0, r1, c1, c0, 0
 	tst	r1, #CR_M @ Check MMU bit enabled
@@ -32,8 +35,13 @@ ENTRY(ll_get_coherency_base)
 
 	/*
 	 * MMU is disabled, use the physical address of the coherency
-	 * base address.
+	 * base address. However, if the coherency fabric isn't mapped
+	 * (i.e its virtual address is zero), it means coherency is
+	 * not enabled, so we return 0.
 	 */
+	ldr	r1, =coherency_base
+	cmp	r1, #0
+	beq	2f
 	adr	r1, 3f
 	ldr	r3, [r1]
 	ldr	r1, [r1, r3]
@@ -85,6 +93,9 @@ ENTRY(ll_add_cpu_to_smp_group)
 	 */
 	mov 	r0, lr
 	bl	ll_get_coherency_base
+	/* Bail out if the coherency is not enabled */
+	cmp	r1, #0
+	reteq	r0
 	bl	ll_get_coherency_cpumask
 	mov 	lr, r0
 	add	r0, r1, #ARMADA_XP_CFB_CFG_REG_OFFSET
@@ -107,6 +118,9 @@ ENTRY(ll_enable_coherency)
 	 */
 	mov r0, lr
 	bl	ll_get_coherency_base
+	/* Bail out if the coherency is not enabled */
+	cmp	r1, #0
+	reteq	r0
 	bl	ll_get_coherency_cpumask
 	mov lr, r0
 	add	r0, r1, #ARMADA_XP_CFB_CTL_REG_OFFSET
@@ -131,6 +145,9 @@ ENTRY(ll_disable_coherency)
 	 */
 	mov 	r0, lr
 	bl	ll_get_coherency_base
+	/* Bail out if the coherency is not enabled */
+	cmp	r1, #0
+	reteq	r0
 	bl	ll_get_coherency_cpumask
 	mov 	lr, r0
 	add	r0, r1, #ARMADA_XP_CFB_CTL_REG_OFFSET



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 36/84] ARM: mvebu: disable I/O coherency on non-SMP situations on Armada 370/375/38x/XP
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (34 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 35/84] ARM: mvebu: make the coherency_ll.S functions work with no coherency fabric Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 37/84] ARM: mvebu: remove conflicting muxing on Armada 370 DB Greg Kroah-Hartman
                   ` (48 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Thomas Petazzoni, Gregory CLEMENT,
	Jason Cooper

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

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

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

commit e55355453600a33bb5ca4f71f2d7214875f3b061 upstream.

Enabling the hardware I/O coherency on Armada 370, Armada 375, Armada
38x and Armada XP requires a certain number of conditions:

 - On Armada 370, the cache policy must be set to write-allocate.

 - On Armada 375, 38x and XP, the cache policy must be set to
   write-allocate, the pages must be mapped with the shareable
   attribute, and the SMP bit must be set

Currently, on Armada XP, when CONFIG_SMP is enabled, those conditions
are met. However, when Armada XP is used in a !CONFIG_SMP kernel, none
of these conditions are met. With Armada 370, the situation is worse:
since the processor is single core, regardless of whether CONFIG_SMP
or !CONFIG_SMP is used, the cache policy will be set to write-back by
the kernel and not write-allocate.

Since solving this problem turns out to be quite complicated, and we
don't want to let users with a mainline kernel known to have
infrequent but existing data corruptions, this commit proposes to
simply disable hardware I/O coherency in situations where it is known
not to work.

And basically, the is_smp() function of the kernel tells us whether it
is OK to enable hardware I/O coherency or not, so this commit slightly
refactors the coherency_type() function to return
COHERENCY_FABRIC_TYPE_NONE when is_smp() is false, or the appropriate
type of the coherency fabric in the other case.

Thanks to this, the I/O coherency fabric will no longer be used at all
in !CONFIG_SMP configurations. It will continue to be used in
CONFIG_SMP configurations on Armada XP, Armada 375 and Armada 38x
(which are multiple cores processors), but will no longer be used on
Armada 370 (which is a single core processor).

In the process, it simplifies the implementation of the
coherency_type() function, and adds a missing call to of_node_put().

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fixes: e60304f8cb7bb545e79fe62d9b9762460c254ec2 ("arm: mvebu: Add hardware I/O Coherency support")
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Link: https://lkml.kernel.org/r/1415871540-20302-3-git-send-email-thomas.petazzoni@free-electrons.com
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/mach-mvebu/coherency.c |   46 ++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 15 deletions(-)

--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -361,25 +361,41 @@ static int coherency_type(void)
 {
 	struct device_node *np;
 	const struct of_device_id *match;
+	int type;
+
+	/*
+	 * The coherency fabric is needed:
+	 * - For coherency between processors on Armada XP, so only
+	 *   when SMP is enabled.
+	 * - For coherency between the processor and I/O devices, but
+	 *   this coherency requires many pre-requisites (write
+	 *   allocate cache policy, shareable pages, SMP bit set) that
+	 *   are only meant in SMP situations.
+	 *
+	 * Note that this means that on Armada 370, there is currently
+	 * no way to use hardware I/O coherency, because even when
+	 * CONFIG_SMP is enabled, is_smp() returns false due to the
+	 * Armada 370 being a single-core processor. To lift this
+	 * limitation, we would have to find a way to make the cache
+	 * policy set to write-allocate (on all Armada SoCs), and to
+	 * set the shareable attribute in page tables (on all Armada
+	 * SoCs except the Armada 370). Unfortunately, such decisions
+	 * are taken very early in the kernel boot process, at a point
+	 * where we don't know yet on which SoC we are running.
+
+	 */
+	if (!is_smp())
+		return COHERENCY_FABRIC_TYPE_NONE;
 
 	np = of_find_matching_node_and_match(NULL, of_coherency_table, &match);
-	if (np) {
-		int type = (int) match->data;
+	if (!np)
+		return COHERENCY_FABRIC_TYPE_NONE;
+
+	type = (int) match->data;
 
-		/* Armada 370/XP coherency works in both UP and SMP */
-		if (type == COHERENCY_FABRIC_TYPE_ARMADA_370_XP)
-			return type;
-
-		/* Armada 375 coherency works only on SMP */
-		else if (type == COHERENCY_FABRIC_TYPE_ARMADA_375 && is_smp())
-			return type;
-
-		/* Armada 380 coherency works only on SMP */
-		else if (type == COHERENCY_FABRIC_TYPE_ARMADA_380 && is_smp())
-			return type;
-	}
+	of_node_put(np);
 
-	return COHERENCY_FABRIC_TYPE_NONE;
+	return type;
 }
 
 int coherency_available(void)



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 37/84] ARM: mvebu: remove conflicting muxing on Armada 370 DB
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (35 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 36/84] ARM: mvebu: disable I/O coherency on non-SMP situations on Armada 370/375/38x/XP Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 39/84] x86/asm/traps: Disable tracing and kprobes in fixup_bad_iret and sync_regs Greg Kroah-Hartman
                   ` (47 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ezequiel Garcia, Thomas Petazzoni,
	Andrew Lunn, Jason Cooper

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

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

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

commit b4607572ef86b288a856b9df410ea593c5371dec upstream.

Back when audio was enabled, the muxing of some MPP pins was causing
problems. However, since commit fea038ed55ae ("ARM: mvebu: Add proper
pin muxing on the Armada 370 DB board"), those problematic MPP pins
have been assigned a proper muxing for the Ethernet interfaces. This
proper muxing is now conflicting with the hog pins muxing that had
been added as part of 249f3822509b ("ARM: mvebu: add audio support to
Armada 370 DB").

Therefore, this commit simply removes the hog pins muxing, which
solves a warning a boot time due to the conflicting muxing
requirements.

Fixes: fea038ed55ae ("ARM: mvebu: Add proper pin muxing on the Armada 370 DB board")
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lkml.kernel.org/r/1414512524-24466-5-git-send-email-thomas.petazzoni@free-electrons.com
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/boot/dts/armada-370-db.dts |   24 ------------------------
 1 file changed, 24 deletions(-)

--- a/arch/arm/boot/dts/armada-370-db.dts
+++ b/arch/arm/boot/dts/armada-370-db.dts
@@ -102,30 +102,6 @@
 				broken-cd;
 			};
 
-			pinctrl {
-				/*
-				 * These pins might be muxed as I2S by
-				 * the bootloader, but it conflicts
-				 * with the real I2S pins that are
-				 * muxed using i2s_pins. We must mux
-				 * those pins to a function other than
-				 * I2S.
-				 */
-				pinctrl-0 = <&hog_pins1 &hog_pins2>;
-				pinctrl-names = "default";
-
-				hog_pins1: hog-pins1 {
-					marvell,pins = "mpp6",  "mpp8", "mpp10",
-						       "mpp12", "mpp13";
-					marvell,function = "gpio";
-				};
-
-				hog_pins2: hog-pins2 {
-					marvell,pins = "mpp5", "mpp7", "mpp9";
-					marvell,function = "gpo";
-				};
-			};
-
 			usb@50000 {
 				status = "okay";
 			};



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 39/84] x86/asm/traps: Disable tracing and kprobes in fixup_bad_iret and sync_regs
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (36 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 37/84] ARM: mvebu: remove conflicting muxing on Armada 370 DB Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 40/84] x86/tls: Dont validate lm in set_thread_area() after all Greg Kroah-Hartman
                   ` (46 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Linus Torvalds,
	Steven Rostedt, Ingo Molnar

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

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

From: Andy Lutomirski <luto@amacapital.net>

commit 7ddc6a2199f1da405a2fb68c40db8899b1a8cd87 upstream.

These functions can be executed on the int3 stack, so kprobes
are dangerous. Tracing is probably a bad idea, too.

Fixes: b645af2d5905 ("x86_64, traps: Rework bad_iret")
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/50e33d26adca60816f3ba968875801652507d0c4.1416870125.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/traps.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -387,7 +387,7 @@ NOKPROBE_SYMBOL(do_int3);
  * for scheduling or signal handling. The actual stack switch is done in
  * entry.S
  */
-asmlinkage __visible struct pt_regs *sync_regs(struct pt_regs *eregs)
+asmlinkage __visible notrace struct pt_regs *sync_regs(struct pt_regs *eregs)
 {
 	struct pt_regs *regs = eregs;
 	/* Did already sync */
@@ -413,7 +413,7 @@ struct bad_iret_stack {
 	struct pt_regs regs;
 };
 
-asmlinkage __visible
+asmlinkage __visible notrace
 struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s)
 {
 	/*
@@ -436,6 +436,7 @@ struct bad_iret_stack *fixup_bad_iret(st
 	BUG_ON(!user_mode_vm(&new_stack->regs));
 	return new_stack;
 }
+NOKPROBE_SYMBOL(fixup_bad_iret);
 #endif
 
 /*



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 40/84] x86/tls: Dont validate lm in set_thread_area() after all
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (37 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 39/84] x86/asm/traps: Disable tracing and kprobes in fixup_bad_iret and sync_regs Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 41/84] isofs: Fix unchecked printing of ER records Greg Kroah-Hartman
                   ` (45 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Thomas Gleixner,
	Linus Torvalds, Ingo Molnar

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

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

From: Andy Lutomirski <luto@amacapital.net>

commit 3fb2f4237bb452eb4e98f6a5dbd5a445b4fed9d0 upstream.

It turns out that there's a lurking ABI issue.  GCC, when
compiling this in a 32-bit program:

struct user_desc desc = {
	.entry_number    = idx,
	.base_addr       = base,
	.limit           = 0xfffff,
	.seg_32bit       = 1,
	.contents        = 0, /* Data, grow-up */
	.read_exec_only  = 0,
	.limit_in_pages  = 1,
	.seg_not_present = 0,
	.useable         = 0,
};

will leave .lm uninitialized.  This means that anything in the
kernel that reads user_desc.lm for 32-bit tasks is unreliable.

Revert the .lm check in set_thread_area().  The value never did
anything in the first place.

Fixes: 0e58af4e1d21 ("x86/tls: Disallow unusual TLS segments")
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/d7875b60e28c512f6a6fc0baf5714d58e7eaadbb.1418856405.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/uapi/asm/ldt.h |    7 +++++++
 arch/x86/kernel/tls.c           |    6 ------
 2 files changed, 7 insertions(+), 6 deletions(-)

--- a/arch/x86/include/uapi/asm/ldt.h
+++ b/arch/x86/include/uapi/asm/ldt.h
@@ -28,6 +28,13 @@ struct user_desc {
 	unsigned int  seg_not_present:1;
 	unsigned int  useable:1;
 #ifdef __x86_64__
+	/*
+	 * Because this bit is not present in 32-bit user code, user
+	 * programs can pass uninitialized values here.  Therefore, in
+	 * any context in which a user_desc comes from a 32-bit program,
+	 * the kernel must act as though lm == 0, regardless of the
+	 * actual value.
+	 */
 	unsigned int  lm:1;
 #endif
 };
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -55,12 +55,6 @@ static bool tls_desc_okay(const struct u
 	if (info->seg_not_present)
 		return false;
 
-#ifdef CONFIG_X86_64
-	/* The L bit makes no sense for data. */
-	if (info->lm)
-		return false;
-#endif
-
 	return true;
 }
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 41/84] isofs: Fix unchecked printing of ER records
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (38 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 40/84] x86/tls: Dont validate lm in set_thread_area() after all Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 42/84] x86, microcode, AMD: Do not use smp_processor_id() in preemtible context Greg Kroah-Hartman
                   ` (44 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jan Kara

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

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

From: Jan Kara <jack@suse.cz>

commit 4e2024624e678f0ebb916e6192bd23c1f9fdf696 upstream.

We didn't check length of rock ridge ER records before printing them.
Thus corrupted isofs image can cause us to access and print some memory
behind the buffer with obvious consequences.

Reported-and-tested-by: Carl Henrik Lunde <chlunde@ping.uio.no>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/isofs/rock.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -362,6 +362,9 @@ repeat:
 			rs.cont_size = isonum_733(rr->u.CE.size);
 			break;
 		case SIG('E', 'R'):
+			/* Invalid length of ER tag id? */
+			if (rr->u.ER.len_id + offsetof(struct rock_ridge, u.ER.data) > rr->len)
+				goto out;
 			ISOFS_SB(inode->i_sb)->s_rock = 1;
 			printk(KERN_DEBUG "ISO 9660 Extensions: ");
 			{



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 42/84] x86, microcode, AMD: Do not use smp_processor_id() in preemtible context
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (39 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 41/84] isofs: Fix unchecked printing of ER records Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 43/84] x86, microcode, intel: Drop unused parameter Greg Kroah-Hartman
                   ` (43 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Borislav Petkov, Thomas Gleixner

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

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

From: Borislav Petkov <bp@suse.de>

commit 2ef84b3bb97f03332f0c1edb4466b1750dcf97b5 upstream.

Hand down the cpu number instead, otherwise lockdep screams when doing

echo 1 > /sys/devices/system/cpu/microcode/reload.

BUG: using smp_processor_id() in preemptible [00000000] code: amd64-microcode/2470
caller is debug_smp_processor_id+0x12/0x20
CPU: 1 PID: 2470 Comm: amd64-microcode Not tainted 3.18.0-rc6+ #26
...

Signed-off-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/1417428741-4501-1-git-send-email-bp@alien8.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/asm/microcode_amd.h      |    2 +-
 arch/x86/kernel/cpu/microcode/amd.c       |    8 ++++----
 arch/x86/kernel/cpu/microcode/amd_early.c |    2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

--- a/arch/x86/include/asm/microcode_amd.h
+++ b/arch/x86/include/asm/microcode_amd.h
@@ -59,7 +59,7 @@ static inline u16 find_equiv_id(struct e
 
 extern int __apply_microcode_amd(struct microcode_amd *mc_amd);
 extern int apply_microcode_amd(int cpu);
-extern enum ucode_state load_microcode_amd(u8 family, const u8 *data, size_t size);
+extern enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, size_t size);
 
 #define PATCH_MAX_SIZE PAGE_SIZE
 extern u8 amd_ucode_patch[PATCH_MAX_SIZE];
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -376,7 +376,7 @@ static enum ucode_state __load_microcode
 	return UCODE_OK;
 }
 
-enum ucode_state load_microcode_amd(u8 family, const u8 *data, size_t size)
+enum ucode_state load_microcode_amd(int cpu, u8 family, const u8 *data, size_t size)
 {
 	enum ucode_state ret;
 
@@ -390,8 +390,8 @@ enum ucode_state load_microcode_amd(u8 f
 
 #if defined(CONFIG_MICROCODE_AMD_EARLY) && defined(CONFIG_X86_32)
 	/* save BSP's matching patch for early load */
-	if (cpu_data(smp_processor_id()).cpu_index == boot_cpu_data.cpu_index) {
-		struct ucode_patch *p = find_patch(smp_processor_id());
+	if (cpu_data(cpu).cpu_index == boot_cpu_data.cpu_index) {
+		struct ucode_patch *p = find_patch(cpu);
 		if (p) {
 			memset(amd_ucode_patch, 0, PATCH_MAX_SIZE);
 			memcpy(amd_ucode_patch, p->data, min_t(u32, ksize(p->data),
@@ -444,7 +444,7 @@ static enum ucode_state request_microcod
 		goto fw_release;
 	}
 
-	ret = load_microcode_amd(c->x86, fw->data, fw->size);
+	ret = load_microcode_amd(cpu, c->x86, fw->data, fw->size);
 
  fw_release:
 	release_firmware(fw);
--- a/arch/x86/kernel/cpu/microcode/amd_early.c
+++ b/arch/x86/kernel/cpu/microcode/amd_early.c
@@ -389,7 +389,7 @@ int __init save_microcode_in_initrd_amd(
 	eax   = cpuid_eax(0x00000001);
 	eax   = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
 
-	ret = load_microcode_amd(eax, container, container_size);
+	ret = load_microcode_amd(smp_processor_id(), eax, container, container_size);
 	if (ret != UCODE_OK)
 		retval = -EINVAL;
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 43/84] x86, microcode, intel: Drop unused parameter
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (40 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 42/84] x86, microcode, AMD: Do not use smp_processor_id() in preemtible context Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 44/84] x86, microcode: Dont initialize microcode code on paravirt Greg Kroah-Hartman
                   ` (42 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Borislav Petkov

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

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

From: Borislav Petkov <bp@suse.de>

commit 47768626c6db42cd06ff077ba12dd2cb10ab818b upstream.

apply_microcode_early() doesn't use mc_saved_data, kill it.

Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/cpu/microcode/intel_early.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--- a/arch/x86/kernel/cpu/microcode/intel_early.c
+++ b/arch/x86/kernel/cpu/microcode/intel_early.c
@@ -650,8 +650,7 @@ static inline void print_ucode(struct uc
 }
 #endif
 
-static int apply_microcode_early(struct mc_saved_data *mc_saved_data,
-				 struct ucode_cpu_info *uci)
+static int apply_microcode_early(struct ucode_cpu_info *uci)
 {
 	struct microcode_intel *mc_intel;
 	unsigned int val[2];
@@ -720,7 +719,7 @@ _load_ucode_intel_bsp(struct mc_saved_da
 		       mc_saved_in_initrd, uci);
 	load_microcode(mc_saved_data, mc_saved_in_initrd,
 		       initrd_start_early, uci);
-	apply_microcode_early(mc_saved_data, uci);
+	apply_microcode_early(uci);
 }
 
 void __init
@@ -783,5 +782,5 @@ void load_ucode_intel_ap(void)
 	collect_cpu_info_early(&uci);
 	load_microcode(mc_saved_data_p, mc_saved_in_initrd_p,
 		       initrd_start_addr, &uci);
-	apply_microcode_early(mc_saved_data_p, &uci);
+	apply_microcode_early(&uci);
 }



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 44/84] x86, microcode: Dont initialize microcode code on paravirt
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (41 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 43/84] x86, microcode, intel: Drop unused parameter Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 45/84] x86, microcode: Reload microcode on resume Greg Kroah-Hartman
                   ` (41 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Boris Ostrovsky, Borislav Petkov

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

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

From: Boris Ostrovsky <boris.ostrovsky@oracle.com>

commit a18a0f6850d4b286a5ebf02cd5b22fe496b86349 upstream.

Paravirtual guests are not expected to load microcode into processors
and therefore it is not necessary to initialize microcode loading
logic.

In fact, under certain circumstances initializing this logic may cause
the guest to crash. Specifically, 32-bit kernels use __pa_nodebug()
macro which does not work in Xen (the code path that leads to this macro
happens during resume when we call mc_bp_resume()->load_ucode_ap()
->check_loader_disabled_ap())

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: http://lkml.kernel.org/r/1417469264-31470-1-git-send-email-boris.ostrovsky@oracle.com
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/cpu/microcode/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -559,7 +559,7 @@ static int __init microcode_init(void)
 	struct cpuinfo_x86 *c = &cpu_data(0);
 	int error;
 
-	if (dis_ucode_ldr)
+	if (paravirt_enabled() || dis_ucode_ldr)
 		return 0;
 
 	if (c->x86_vendor == X86_VENDOR_INTEL)



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 45/84] x86, microcode: Reload microcode on resume
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (42 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 44/84] x86, microcode: Dont initialize microcode code on paravirt Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 46/84] x86/microcode/intel: Fish out the stashed microcode for the BSP Greg Kroah-Hartman
                   ` (40 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Borislav Petkov

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

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

From: Borislav Petkov <bp@suse.de>

commit fbae4ba8c4a387e306adc9c710e5c225cece7678 upstream.

Normally, we do reapply microcode on resume. However, in the cases where
that microcode comes from the early loader and the late loader hasn't
been utilized yet, there's no easy way for us to go and apply the patch
applied during boot by the early loader.

Thus, reuse the patch stashed by the early loader for the BSP.

Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/asm/microcode.h            |    2 +
 arch/x86/include/asm/microcode_amd.h        |    2 +
 arch/x86/include/asm/microcode_intel.h      |    2 +
 arch/x86/kernel/cpu/microcode/amd_early.c   |   18 ++++++++++
 arch/x86/kernel/cpu/microcode/core.c        |   10 -----
 arch/x86/kernel/cpu/microcode/core_early.c  |   21 ++++++++++++
 arch/x86/kernel/cpu/microcode/intel_early.c |   47 ++++++++++++++++++++++------
 7 files changed, 84 insertions(+), 18 deletions(-)

--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -78,6 +78,7 @@ static inline void __exit exit_amd_micro
 extern void __init load_ucode_bsp(void);
 extern void load_ucode_ap(void);
 extern int __init save_microcode_in_initrd(void);
+void reload_early_microcode(void);
 #else
 static inline void __init load_ucode_bsp(void) {}
 static inline void load_ucode_ap(void) {}
@@ -85,6 +86,7 @@ static inline int __init save_microcode_
 {
 	return 0;
 }
+static inline void reload_early_microcode(void) {}
 #endif
 
 #endif /* _ASM_X86_MICROCODE_H */
--- a/arch/x86/include/asm/microcode_amd.h
+++ b/arch/x86/include/asm/microcode_amd.h
@@ -68,10 +68,12 @@ extern u8 amd_ucode_patch[PATCH_MAX_SIZE
 extern void __init load_ucode_amd_bsp(void);
 extern void load_ucode_amd_ap(void);
 extern int __init save_microcode_in_initrd_amd(void);
+void reload_ucode_amd(void);
 #else
 static inline void __init load_ucode_amd_bsp(void) {}
 static inline void load_ucode_amd_ap(void) {}
 static inline int __init save_microcode_in_initrd_amd(void) { return -EINVAL; }
+void reload_ucode_amd(void) {}
 #endif
 
 #endif /* _ASM_X86_MICROCODE_AMD_H */
--- a/arch/x86/include/asm/microcode_intel.h
+++ b/arch/x86/include/asm/microcode_intel.h
@@ -68,11 +68,13 @@ extern void __init load_ucode_intel_bsp(
 extern void load_ucode_intel_ap(void);
 extern void show_ucode_info_early(void);
 extern int __init save_microcode_in_initrd_intel(void);
+void reload_ucode_intel(void);
 #else
 static inline __init void load_ucode_intel_bsp(void) {}
 static inline void load_ucode_intel_ap(void) {}
 static inline void show_ucode_info_early(void) {}
 static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; }
+static inline void reload_ucode_intel(void) {}
 #endif
 
 #if defined(CONFIG_MICROCODE_INTEL_EARLY) && defined(CONFIG_HOTPLUG_CPU)
--- a/arch/x86/kernel/cpu/microcode/amd_early.c
+++ b/arch/x86/kernel/cpu/microcode/amd_early.c
@@ -402,3 +402,21 @@ int __init save_microcode_in_initrd_amd(
 
 	return retval;
 }
+
+void reload_ucode_amd(void)
+{
+	struct microcode_amd *mc;
+	u32 rev, eax;
+
+	rdmsr(MSR_AMD64_PATCH_LEVEL, rev, eax);
+
+	mc = (struct microcode_amd *)amd_ucode_patch;
+
+	if (mc && rev < mc->hdr.patch_id) {
+		if (!__apply_microcode_amd(mc)) {
+			ucode_new_rev = mc->hdr.patch_id;
+			pr_info("microcode: reload patch_level=0x%08x\n",
+				ucode_new_rev);
+		}
+	}
+}
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -465,16 +465,8 @@ static void mc_bp_resume(void)
 
 	if (uci->valid && uci->mc)
 		microcode_ops->apply_microcode(cpu);
-#ifdef CONFIG_X86_64
 	else if (!uci->mc)
-		/*
-		 * We might resume and not have applied late microcode but still
-		 * have a newer patch stashed from the early loader. We don't
-		 * have it in uci->mc so we have to load it the same way we're
-		 * applying patches early on the APs.
-		 */
-		load_ucode_ap();
-#endif
+		reload_early_microcode();
 }
 
 static struct syscore_ops mc_syscore_ops = {
--- a/arch/x86/kernel/cpu/microcode/core_early.c
+++ b/arch/x86/kernel/cpu/microcode/core_early.c
@@ -176,3 +176,24 @@ int __init save_microcode_in_initrd(void
 
 	return 0;
 }
+
+void reload_early_microcode(void)
+{
+	int vendor, x86;
+
+	vendor = x86_vendor();
+	x86 = x86_family();
+
+	switch (vendor) {
+	case X86_VENDOR_INTEL:
+		if (x86 >= 6)
+			reload_ucode_intel();
+		break;
+	case X86_VENDOR_AMD:
+		if (x86 >= 0x10)
+			reload_ucode_amd();
+		break;
+	default:
+		break;
+	}
+}
--- a/arch/x86/kernel/cpu/microcode/intel_early.c
+++ b/arch/x86/kernel/cpu/microcode/intel_early.c
@@ -34,6 +34,8 @@ static struct mc_saved_data {
 	struct microcode_intel **mc_saved;
 } mc_saved_data;
 
+static struct microcode_intel bsp_patch;
+
 static enum ucode_state
 generic_load_microcode_early(struct microcode_intel **mc_saved_p,
 			     unsigned int mc_saved_count,
@@ -650,7 +652,7 @@ static inline void print_ucode(struct uc
 }
 #endif
 
-static int apply_microcode_early(struct ucode_cpu_info *uci)
+static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
 {
 	struct microcode_intel *mc_intel;
 	unsigned int val[2];
@@ -679,7 +681,10 @@ static int apply_microcode_early(struct
 #endif
 	uci->cpu_sig.rev = val[1];
 
-	print_ucode(uci);
+	if (early)
+		print_ucode(uci);
+	else
+		print_ucode_info(uci, mc_intel->hdr.date);
 
 	return 0;
 }
@@ -712,14 +717,22 @@ _load_ucode_intel_bsp(struct mc_saved_da
 		      unsigned long *mc_saved_in_initrd,
 		      unsigned long initrd_start_early,
 		      unsigned long initrd_end_early,
-		      struct ucode_cpu_info *uci)
+		      struct ucode_cpu_info *uci,
+		      struct microcode_intel *bsp)
 {
+	enum ucode_state ret;
+
 	collect_cpu_info_early(uci);
 	scan_microcode(initrd_start_early, initrd_end_early, mc_saved_data,
 		       mc_saved_in_initrd, uci);
-	load_microcode(mc_saved_data, mc_saved_in_initrd,
-		       initrd_start_early, uci);
-	apply_microcode_early(uci);
+
+	ret = load_microcode(mc_saved_data, mc_saved_in_initrd,
+			     initrd_start_early, uci);
+
+	if (ret == UCODE_OK) {
+		apply_microcode_early(uci, true);
+		memcpy(bsp, uci->mc, sizeof(*bsp));
+	}
 }
 
 void __init
@@ -728,10 +741,12 @@ load_ucode_intel_bsp(void)
 	u64 ramdisk_image, ramdisk_size;
 	unsigned long initrd_start_early, initrd_end_early;
 	struct ucode_cpu_info uci;
+	struct microcode_intel *bsp_p;
 #ifdef CONFIG_X86_32
 	struct boot_params *boot_params_p;
 
 	boot_params_p = (struct boot_params *)__pa_nodebug(&boot_params);
+	bsp_p	      = (struct microcode_intel *)__pa_nodebug(&bsp_patch);
 	ramdisk_image = boot_params_p->hdr.ramdisk_image;
 	ramdisk_size  = boot_params_p->hdr.ramdisk_size;
 	initrd_start_early = ramdisk_image;
@@ -740,15 +755,17 @@ load_ucode_intel_bsp(void)
 	_load_ucode_intel_bsp(
 		(struct mc_saved_data *)__pa_nodebug(&mc_saved_data),
 		(unsigned long *)__pa_nodebug(&mc_saved_in_initrd),
-		initrd_start_early, initrd_end_early, &uci);
+		initrd_start_early, initrd_end_early, &uci, bsp_p);
 #else
+	bsp_p	      = &bsp_patch;
 	ramdisk_image = boot_params.hdr.ramdisk_image;
 	ramdisk_size  = boot_params.hdr.ramdisk_size;
 	initrd_start_early = ramdisk_image + PAGE_OFFSET;
 	initrd_end_early = initrd_start_early + ramdisk_size;
 
 	_load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd,
-			      initrd_start_early, initrd_end_early, &uci);
+			      initrd_start_early, initrd_end_early,
+			      &uci, bsp_p);
 #endif
 }
 
@@ -782,5 +799,17 @@ void load_ucode_intel_ap(void)
 	collect_cpu_info_early(&uci);
 	load_microcode(mc_saved_data_p, mc_saved_in_initrd_p,
 		       initrd_start_addr, &uci);
-	apply_microcode_early(&uci);
+	apply_microcode_early(&uci, true);
+}
+
+void reload_ucode_intel(void)
+{
+	struct ucode_cpu_info uci;
+
+	if (!bsp_patch.hdr.rev)
+		return;
+
+	uci.mc = &bsp_patch;
+
+	apply_microcode_early(&uci, false);
 }



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 46/84] x86/microcode/intel: Fish out the stashed microcode for the BSP
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (43 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 45/84] x86, microcode: Reload microcode on resume Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 47/84] KEYS: Fix stale key registration at error path Greg Kroah-Hartman
                   ` (39 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Borislav Petkov, Linus Torvalds, Ingo Molnar

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

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

From: Borislav Petkov <bp@suse.de>

commit 25cdb9c86826f8d035d8aaa07fc36832e76bd8a0 upstream.

I'm such a moron! The simple solution of saving the BSP patch
for use on resume was too simple (and wrong!), hint:
sizeof(struct microcode_intel).

What needs to be done instead is to fish out the microcode patch
we have stashed previously and apply that on the BSP in case the
late loader hasn't been utilized.

So do that instead.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20141208110820.GB20057@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/cpu/microcode/intel_early.c |   26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

--- a/arch/x86/kernel/cpu/microcode/intel_early.c
+++ b/arch/x86/kernel/cpu/microcode/intel_early.c
@@ -34,8 +34,6 @@ static struct mc_saved_data {
 	struct microcode_intel **mc_saved;
 } mc_saved_data;
 
-static struct microcode_intel bsp_patch;
-
 static enum ucode_state
 generic_load_microcode_early(struct microcode_intel **mc_saved_p,
 			     unsigned int mc_saved_count,
@@ -717,8 +715,7 @@ _load_ucode_intel_bsp(struct mc_saved_da
 		      unsigned long *mc_saved_in_initrd,
 		      unsigned long initrd_start_early,
 		      unsigned long initrd_end_early,
-		      struct ucode_cpu_info *uci,
-		      struct microcode_intel *bsp)
+		      struct ucode_cpu_info *uci)
 {
 	enum ucode_state ret;
 
@@ -729,10 +726,8 @@ _load_ucode_intel_bsp(struct mc_saved_da
 	ret = load_microcode(mc_saved_data, mc_saved_in_initrd,
 			     initrd_start_early, uci);
 
-	if (ret == UCODE_OK) {
+	if (ret == UCODE_OK)
 		apply_microcode_early(uci, true);
-		memcpy(bsp, uci->mc, sizeof(*bsp));
-	}
 }
 
 void __init
@@ -741,12 +736,10 @@ load_ucode_intel_bsp(void)
 	u64 ramdisk_image, ramdisk_size;
 	unsigned long initrd_start_early, initrd_end_early;
 	struct ucode_cpu_info uci;
-	struct microcode_intel *bsp_p;
 #ifdef CONFIG_X86_32
 	struct boot_params *boot_params_p;
 
 	boot_params_p = (struct boot_params *)__pa_nodebug(&boot_params);
-	bsp_p	      = (struct microcode_intel *)__pa_nodebug(&bsp_patch);
 	ramdisk_image = boot_params_p->hdr.ramdisk_image;
 	ramdisk_size  = boot_params_p->hdr.ramdisk_size;
 	initrd_start_early = ramdisk_image;
@@ -755,9 +748,8 @@ load_ucode_intel_bsp(void)
 	_load_ucode_intel_bsp(
 		(struct mc_saved_data *)__pa_nodebug(&mc_saved_data),
 		(unsigned long *)__pa_nodebug(&mc_saved_in_initrd),
-		initrd_start_early, initrd_end_early, &uci, bsp_p);
+		initrd_start_early, initrd_end_early, &uci);
 #else
-	bsp_p	      = &bsp_patch;
 	ramdisk_image = boot_params.hdr.ramdisk_image;
 	ramdisk_size  = boot_params.hdr.ramdisk_size;
 	initrd_start_early = ramdisk_image + PAGE_OFFSET;
@@ -765,7 +757,7 @@ load_ucode_intel_bsp(void)
 
 	_load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd,
 			      initrd_start_early, initrd_end_early,
-			      &uci, bsp_p);
+			      &uci);
 #endif
 }
 
@@ -805,11 +797,17 @@ void load_ucode_intel_ap(void)
 void reload_ucode_intel(void)
 {
 	struct ucode_cpu_info uci;
+	enum ucode_state ret;
 
-	if (!bsp_patch.hdr.rev)
+	if (!mc_saved_data.mc_saved_count)
 		return;
 
-	uci.mc = &bsp_patch;
+	collect_cpu_info_early(&uci);
+
+	ret = generic_load_microcode_early(mc_saved_data.mc_saved,
+					   mc_saved_data.mc_saved_count, &uci);
+	if (ret != UCODE_OK)
+		return;
 
 	apply_microcode_early(&uci, false);
 }



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 47/84] KEYS: Fix stale key registration at error path
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (44 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 46/84] x86/microcode/intel: Fish out the stashed microcode for the BSP Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 48/84] mac80211: copy chandef from AP vif to VLANs Greg Kroah-Hartman
                   ` (38 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Takashi Iwai, Mimi Zohar

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

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

From: Takashi Iwai <tiwai@suse.de>

commit b26bdde5bb27f3f900e25a95e33a0c476c8c2c48 upstream.

When loading encrypted-keys module, if the last check of
aes_get_sizes() in init_encrypted() fails, the driver just returns an
error without unregistering its key type.  This results in the stale
entry in the list.  In addition to memory leaks, this leads to a kernel
crash when registering a new key type later.

This patch fixes the problem by swapping the calls of aes_get_sizes()
and register_key_type(), and releasing resources properly at the error
paths.

Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=908163
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 security/keys/encrypted-keys/encrypted.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/security/keys/encrypted-keys/encrypted.c
+++ b/security/keys/encrypted-keys/encrypted.c
@@ -1017,10 +1017,13 @@ static int __init init_encrypted(void)
 	ret = encrypted_shash_alloc();
 	if (ret < 0)
 		return ret;
+	ret = aes_get_sizes();
+	if (ret < 0)
+		goto out;
 	ret = register_key_type(&key_type_encrypted);
 	if (ret < 0)
 		goto out;
-	return aes_get_sizes();
+	return 0;
 out:
 	encrypted_shash_release();
 	return ret;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 48/84] mac80211: copy chandef from AP vif to VLANs
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (45 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 47/84] KEYS: Fix stale key registration at error path Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 49/84] mac80211: avoid using uninitialized stack data Greg Kroah-Hartman
                   ` (37 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Felix Fietkau, Johannes Berg

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

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

From: Felix Fietkau <nbd@openwrt.org>

commit 2967e031d4d737d9cc8252d878a17924d7b704f0 upstream.

Instead of keeping track of all those special cases where
VLAN interfaces have no bss_conf.chandef, just make sure
they have the same as the AP interface they belong to.

Among others, this fixes a crash getting a VLAN's channel
from userspace since a NULL channel is returned as a good
result (return value 0) for VLANs since the commit below.

Fixes: c12bc4885f4b3 ("mac80211: return the vif's chandef in ieee80211_cfg_get_channel()")
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
[rewrite commit log]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/mac80211/chan.c  |   23 +++++++++++++++++++----
 net/mac80211/iface.c |    1 +
 2 files changed, 20 insertions(+), 4 deletions(-)

--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -929,6 +929,21 @@ ieee80211_vif_chanctx_reservation_comple
 	}
 }
 
+static void
+ieee80211_vif_update_chandef(struct ieee80211_sub_if_data *sdata,
+			     const struct cfg80211_chan_def *chandef)
+{
+	struct ieee80211_sub_if_data *vlan;
+
+	sdata->vif.bss_conf.chandef = *chandef;
+
+	if (sdata->vif.type != NL80211_IFTYPE_AP)
+		return;
+
+	list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
+		vlan->vif.bss_conf.chandef = *chandef;
+}
+
 static int
 ieee80211_vif_use_reserved_reassign(struct ieee80211_sub_if_data *sdata)
 {
@@ -991,7 +1006,7 @@ ieee80211_vif_use_reserved_reassign(stru
 	if (sdata->vif.bss_conf.chandef.width != sdata->reserved_chandef.width)
 		changed = BSS_CHANGED_BANDWIDTH;
 
-	sdata->vif.bss_conf.chandef = sdata->reserved_chandef;
+	ieee80211_vif_update_chandef(sdata, &sdata->reserved_chandef);
 
 	if (changed)
 		ieee80211_bss_info_change_notify(sdata, changed);
@@ -1333,7 +1348,7 @@ static int ieee80211_vif_use_reserved_sw
 			    sdata->reserved_chandef.width)
 				changed = BSS_CHANGED_BANDWIDTH;
 
-			sdata->vif.bss_conf.chandef = sdata->reserved_chandef;
+			ieee80211_vif_update_chandef(sdata, &sdata->reserved_chandef);
 			if (changed)
 				ieee80211_bss_info_change_notify(sdata,
 								 changed);
@@ -1504,7 +1519,7 @@ int ieee80211_vif_use_channel(struct iee
 		goto out;
 	}
 
-	sdata->vif.bss_conf.chandef = *chandef;
+	ieee80211_vif_update_chandef(sdata, chandef);
 
 	ret = ieee80211_assign_vif_chanctx(sdata, ctx);
 	if (ret) {
@@ -1646,7 +1661,7 @@ int ieee80211_vif_change_bandwidth(struc
 		break;
 	}
 
-	sdata->vif.bss_conf.chandef = *chandef;
+	ieee80211_vif_update_chandef(sdata, chandef);
 
 	ieee80211_recalc_chanctx_chantype(local, ctx);
 
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -511,6 +511,7 @@ int ieee80211_do_open(struct wireless_de
 		sdata->vif.cab_queue = master->vif.cab_queue;
 		memcpy(sdata->vif.hw_queue, master->vif.hw_queue,
 		       sizeof(sdata->vif.hw_queue));
+		sdata->vif.bss_conf.chandef = master->vif.bss_conf.chandef;
 		break;
 		}
 	case NL80211_IFTYPE_AP:



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 49/84] mac80211: avoid using uninitialized stack data
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (46 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 48/84] mac80211: copy chandef from AP vif to VLANs Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 51/84] mac80211: free management frame keys when removing station Greg Kroah-Hartman
                   ` (36 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Jes Sorensen, Johannes Berg

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

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

From: Jes Sorensen <Jes.Sorensen@redhat.com>

commit 7e6225a1604d0c6aa4140289bf5761868ffc9c83 upstream.

Avoid a case where we would access uninitialized stack data if the AP
advertises HT support without 40MHz channel support.

Fixes: f3000e1b43f1 ("mac80211: fix broken use of VHT/20Mhz with some APs")
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/mac80211/mlme.c |    1 +
 1 file changed, 1 insertion(+)

--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -174,6 +174,7 @@ ieee80211_determine_chantype(struct ieee
 	if (!(ht_cap->cap_info &
 	      cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40))) {
 		ret = IEEE80211_STA_DISABLE_40MHZ;
+		vht_chandef = *chandef;
 		goto out;
 	}
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 51/84] mac80211: free management frame keys when removing station
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (47 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 49/84] mac80211: avoid using uninitialized stack data Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 52/84] mnt: Fix a memory stomp in umount Greg Kroah-Hartman
                   ` (35 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Johannes Berg

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

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

From: Johannes Berg <johannes.berg@intel.com>

commit 28a9bc68124c319b2b3dc861e80828a8865fd1ba upstream.

When writing the code to allow per-station GTKs, I neglected to
take into account the management frame keys (index 4 and 5) when
freeing the station and only added code to free the first four
data frame keys.

Fix this by iterating the array of keys over the right length.

Fixes: e31b82136d1a ("cfg80211/mac80211: allow per-station GTKs")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/mac80211/key.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -647,7 +647,7 @@ void ieee80211_free_sta_keys(struct ieee
 	int i;
 
 	mutex_lock(&local->key_mtx);
-	for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
+	for (i = 0; i < ARRAY_SIZE(sta->gtk); i++) {
 		key = key_mtx_dereference(local, sta->gtk[i]);
 		if (!key)
 			continue;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 52/84] mnt: Fix a memory stomp in umount
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (48 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 51/84] mac80211: free management frame keys when removing station Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 53/84] thermal: Fix error path in thermal_init() Greg Kroah-Hartman
                   ` (34 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Eric W. Biederman, Linus Torvalds

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit c297abfdf15b4480704d6b566ca5ca9438b12456 upstream.

While reviewing the code of umount_tree I realized that when we append
to a preexisting unmounted list we do not change pprev of the former
first item in the list.

Which means later in namespace_unlock hlist_del_init(&mnt->mnt_hash) on
the former first item of the list will stomp unmounted.first leaving
it set to some random mount point which we are likely to free soon.

This isn't likely to hit, but if it does I don't know how anyone could
track it down.

[ This happened because we don't have all the same operations for
  hlist's as we do for normal doubly-linked lists. In particular,
  list_splice() is easy on our standard doubly-linked lists, while
  hlist_splice() doesn't exist and needs both start/end entries of the
  hlist.  And commit 38129a13e6e7 incorrectly open-coded that missing
  hlist_splice().

  We should think about making these kinds of "mindless" conversions
  easier to get right by adding the missing hlist helpers   - Linus ]

Fixes: 38129a13e6e71f666e0468e99fdd932a687b4d7e switch mnt_hash to hlist
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/namespace.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1369,6 +1369,8 @@ void umount_tree(struct mount *mnt, int
 	}
 	if (last) {
 		last->mnt_hash.next = unmounted.first;
+		if (unmounted.first)
+			unmounted.first->pprev = &last->mnt_hash.next;
 		unmounted.first = tmp_list.first;
 		unmounted.first->pprev = &unmounted.first;
 	}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 53/84] thermal: Fix error path in thermal_init()
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (49 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 52/84] mnt: Fix a memory stomp in umount Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 54/84] mnt: Implicitly add MNT_NODEV on remount when it was implicitly added by mount Greg Kroah-Hartman
                   ` (33 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Luis Henriques, Zhang Rui

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

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

From: Luis Henriques <luis.henriques@canonical.com>

commit 9d367e5e7b05c71a8c1ac4e9b6e00ba45a79f2fc upstream.

thermal_unregister_governors() and class_unregister() were being called in
the wrong order.

Fixes: 80a26a5c22b9 ("Thermal: build thermal governors into thermal_sys module")
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/thermal/thermal_core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1835,10 +1835,10 @@ static int __init thermal_init(void)
 
 exit_netlink:
 	genetlink_exit();
-unregister_governors:
-	thermal_unregister_governors();
 unregister_class:
 	class_unregister(&thermal_class);
+unregister_governors:
+	thermal_unregister_governors();
 error:
 	idr_destroy(&thermal_tz_idr);
 	idr_destroy(&thermal_cdev_idr);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 54/84] mnt: Implicitly add MNT_NODEV on remount when it was implicitly added by mount
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (50 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 53/84] thermal: Fix error path in thermal_init() Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 55/84] mnt: Update unprivileged remount test Greg Kroah-Hartman
                   ` (32 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Cedric Bosdonnat, Richard Weinberger,
	Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 3e1866410f11356a9fd869beb3e95983dc79c067 upstream.

Now that remount is properly enforcing the rule that you can't remove
nodev at least sandstorm.io is breaking when performing a remount.

It turns out that there is an easy intuitive solution implicitly
add nodev on remount when nodev was implicitly added on mount.

Tested-by: Cedric Bosdonnat <cbosdonnat@suse.com>
Tested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/namespace.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2100,7 +2100,13 @@ static int do_remount(struct path *path,
 	}
 	if ((mnt->mnt.mnt_flags & MNT_LOCK_NODEV) &&
 	    !(mnt_flags & MNT_NODEV)) {
-		return -EPERM;
+		/* Was the nodev implicitly added in mount? */
+		if ((mnt->mnt_ns->user_ns != &init_user_ns) &&
+		    !(sb->s_type->fs_flags & FS_USERNS_DEV_MOUNT)) {
+			mnt_flags |= MNT_NODEV;
+		} else {
+			return -EPERM;
+		}
 	}
 	if ((mnt->mnt.mnt_flags & MNT_LOCK_NOSUID) &&
 	    !(mnt_flags & MNT_NOSUID)) {



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 55/84] mnt: Update unprivileged remount test
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (51 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 54/84] mnt: Implicitly add MNT_NODEV on remount when it was implicitly added by mount Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:49 ` [PATCH 3.18 56/84] umount: Disallow unprivileged mount force Greg Kroah-Hartman
                   ` (31 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 4a44a19b470a886997d6647a77bb3e38dcbfa8c5 upstream.

- MNT_NODEV should be irrelevant except when reading back mount flags,
  no longer specify MNT_NODEV on remount.

- Test MNT_NODEV on devpts where it is meaningful even for unprivileged mounts.

- Add a test to verify that remount of a prexisting mount with the same flags
  is allowed and does not change those flags.

- Cleanup up the definitions of MS_REC, MS_RELATIME, MS_STRICTATIME that are used
  when the code is built in an environment without them.

- Correct the test error messages when tests fail.  There were not 5 tests
  that tested MS_RELATIME.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 tools/testing/selftests/mount/unprivileged-remount-test.c |  172 +++++++++++---
 1 file changed, 142 insertions(+), 30 deletions(-)

--- a/tools/testing/selftests/mount/unprivileged-remount-test.c
+++ b/tools/testing/selftests/mount/unprivileged-remount-test.c
@@ -6,6 +6,8 @@
 #include <sys/types.h>
 #include <sys/mount.h>
 #include <sys/wait.h>
+#include <sys/vfs.h>
+#include <sys/statvfs.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -32,11 +34,14 @@
 # define CLONE_NEWPID 0x20000000
 #endif
 
+#ifndef MS_REC
+# define MS_REC 16384
+#endif
 #ifndef MS_RELATIME
-#define MS_RELATIME (1 << 21)
+# define MS_RELATIME (1 << 21)
 #endif
 #ifndef MS_STRICTATIME
-#define MS_STRICTATIME (1 << 24)
+# define MS_STRICTATIME (1 << 24)
 #endif
 
 static void die(char *fmt, ...)
@@ -87,6 +92,45 @@ static void write_file(char *filename, c
 	}
 }
 
+static int read_mnt_flags(const char *path)
+{
+	int ret;
+	struct statvfs stat;
+	int mnt_flags;
+
+	ret = statvfs(path, &stat);
+	if (ret != 0) {
+		die("statvfs of %s failed: %s\n",
+			path, strerror(errno));
+	}
+	if (stat.f_flag & ~(ST_RDONLY | ST_NOSUID | ST_NODEV | \
+			ST_NOEXEC | ST_NOATIME | ST_NODIRATIME | ST_RELATIME | \
+			ST_SYNCHRONOUS | ST_MANDLOCK)) {
+		die("Unrecognized mount flags\n");
+	}
+	mnt_flags = 0;
+	if (stat.f_flag & ST_RDONLY)
+		mnt_flags |= MS_RDONLY;
+	if (stat.f_flag & ST_NOSUID)
+		mnt_flags |= MS_NOSUID;
+	if (stat.f_flag & ST_NODEV)
+		mnt_flags |= MS_NODEV;
+	if (stat.f_flag & ST_NOEXEC)
+		mnt_flags |= MS_NOEXEC;
+	if (stat.f_flag & ST_NOATIME)
+		mnt_flags |= MS_NOATIME;
+	if (stat.f_flag & ST_NODIRATIME)
+		mnt_flags |= MS_NODIRATIME;
+	if (stat.f_flag & ST_RELATIME)
+		mnt_flags |= MS_RELATIME;
+	if (stat.f_flag & ST_SYNCHRONOUS)
+		mnt_flags |= MS_SYNCHRONOUS;
+	if (stat.f_flag & ST_MANDLOCK)
+		mnt_flags |= ST_MANDLOCK;
+
+	return mnt_flags;
+}
+
 static void create_and_enter_userns(void)
 {
 	uid_t uid;
@@ -118,7 +162,8 @@ static void create_and_enter_userns(void
 }
 
 static
-bool test_unpriv_remount(int mount_flags, int remount_flags, int invalid_flags)
+bool test_unpriv_remount(const char *fstype, const char *mount_options,
+			 int mount_flags, int remount_flags, int invalid_flags)
 {
 	pid_t child;
 
@@ -151,9 +196,11 @@ bool test_unpriv_remount(int mount_flags
 			strerror(errno));
 	}
 
-	if (mount("testing", "/tmp", "ramfs", mount_flags, NULL) != 0) {
-		die("mount of /tmp failed: %s\n",
-			strerror(errno));
+	if (mount("testing", "/tmp", fstype, mount_flags, mount_options) != 0) {
+		die("mount of %s with options '%s' on /tmp failed: %s\n",
+		    fstype,
+		    mount_options? mount_options : "",
+		    strerror(errno));
 	}
 
 	create_and_enter_userns();
@@ -181,62 +228,127 @@ bool test_unpriv_remount(int mount_flags
 
 static bool test_unpriv_remount_simple(int mount_flags)
 {
-	return test_unpriv_remount(mount_flags, mount_flags, 0);
+	return test_unpriv_remount("ramfs", NULL, mount_flags, mount_flags, 0);
 }
 
 static bool test_unpriv_remount_atime(int mount_flags, int invalid_flags)
 {
-	return test_unpriv_remount(mount_flags, mount_flags, invalid_flags);
+	return test_unpriv_remount("ramfs", NULL, mount_flags, mount_flags,
+				   invalid_flags);
+}
+
+static bool test_priv_mount_unpriv_remount(void)
+{
+	pid_t child;
+	int ret;
+	const char *orig_path = "/dev";
+	const char *dest_path = "/tmp";
+	int orig_mnt_flags, remount_mnt_flags;
+
+	child = fork();
+	if (child == -1) {
+		die("fork failed: %s\n",
+			strerror(errno));
+	}
+	if (child != 0) { /* parent */
+		pid_t pid;
+		int status;
+		pid = waitpid(child, &status, 0);
+		if (pid == -1) {
+			die("waitpid failed: %s\n",
+				strerror(errno));
+		}
+		if (pid != child) {
+			die("waited for %d got %d\n",
+				child, pid);
+		}
+		if (!WIFEXITED(status)) {
+			die("child did not terminate cleanly\n");
+		}
+		return WEXITSTATUS(status) == EXIT_SUCCESS ? true : false;
+	}
+
+	orig_mnt_flags = read_mnt_flags(orig_path);
+
+	create_and_enter_userns();
+	ret = unshare(CLONE_NEWNS);
+	if (ret != 0) {
+		die("unshare(CLONE_NEWNS) failed: %s\n",
+			strerror(errno));
+	}
+
+	ret = mount(orig_path, dest_path, "bind", MS_BIND | MS_REC, NULL);
+	if (ret != 0) {
+		die("recursive bind mount of %s onto %s failed: %s\n",
+			orig_path, dest_path, strerror(errno));
+	}
+
+	ret = mount(dest_path, dest_path, "none",
+		    MS_REMOUNT | MS_BIND | orig_mnt_flags , NULL);
+	if (ret != 0) {
+		/* system("cat /proc/self/mounts"); */
+		die("remount of /tmp failed: %s\n",
+		    strerror(errno));
+	}
+
+	remount_mnt_flags = read_mnt_flags(dest_path);
+	if (orig_mnt_flags != remount_mnt_flags) {
+		die("Mount flags unexpectedly changed during remount of %s originally mounted on %s\n",
+			dest_path, orig_path);
+	}
+	exit(EXIT_SUCCESS);
 }
 
 int main(int argc, char **argv)
 {
-	if (!test_unpriv_remount_simple(MS_RDONLY|MS_NODEV)) {
+	if (!test_unpriv_remount_simple(MS_RDONLY)) {
 		die("MS_RDONLY malfunctions\n");
 	}
-	if (!test_unpriv_remount_simple(MS_NODEV)) {
+	if (!test_unpriv_remount("devpts", "newinstance", MS_NODEV, MS_NODEV, 0)) {
 		die("MS_NODEV malfunctions\n");
 	}
-	if (!test_unpriv_remount_simple(MS_NOSUID|MS_NODEV)) {
+	if (!test_unpriv_remount_simple(MS_NOSUID)) {
 		die("MS_NOSUID malfunctions\n");
 	}
-	if (!test_unpriv_remount_simple(MS_NOEXEC|MS_NODEV)) {
+	if (!test_unpriv_remount_simple(MS_NOEXEC)) {
 		die("MS_NOEXEC malfunctions\n");
 	}
-	if (!test_unpriv_remount_atime(MS_RELATIME|MS_NODEV,
-				       MS_NOATIME|MS_NODEV))
+	if (!test_unpriv_remount_atime(MS_RELATIME,
+				       MS_NOATIME))
 	{
 		die("MS_RELATIME malfunctions\n");
 	}
-	if (!test_unpriv_remount_atime(MS_STRICTATIME|MS_NODEV,
-				       MS_NOATIME|MS_NODEV))
+	if (!test_unpriv_remount_atime(MS_STRICTATIME,
+				       MS_NOATIME))
 	{
 		die("MS_STRICTATIME malfunctions\n");
 	}
-	if (!test_unpriv_remount_atime(MS_NOATIME|MS_NODEV,
-				       MS_STRICTATIME|MS_NODEV))
+	if (!test_unpriv_remount_atime(MS_NOATIME,
+				       MS_STRICTATIME))
 	{
-		die("MS_RELATIME malfunctions\n");
+		die("MS_NOATIME malfunctions\n");
 	}
-	if (!test_unpriv_remount_atime(MS_RELATIME|MS_NODIRATIME|MS_NODEV,
-				       MS_NOATIME|MS_NODEV))
+	if (!test_unpriv_remount_atime(MS_RELATIME|MS_NODIRATIME,
+				       MS_NOATIME))
 	{
-		die("MS_RELATIME malfunctions\n");
+		die("MS_RELATIME|MS_NODIRATIME malfunctions\n");
 	}
-	if (!test_unpriv_remount_atime(MS_STRICTATIME|MS_NODIRATIME|MS_NODEV,
-				       MS_NOATIME|MS_NODEV))
+	if (!test_unpriv_remount_atime(MS_STRICTATIME|MS_NODIRATIME,
+				       MS_NOATIME))
 	{
-		die("MS_RELATIME malfunctions\n");
+		die("MS_STRICTATIME|MS_NODIRATIME malfunctions\n");
 	}
-	if (!test_unpriv_remount_atime(MS_NOATIME|MS_NODIRATIME|MS_NODEV,
-				       MS_STRICTATIME|MS_NODEV))
+	if (!test_unpriv_remount_atime(MS_NOATIME|MS_NODIRATIME,
+				       MS_STRICTATIME))
 	{
-		die("MS_RELATIME malfunctions\n");
+		die("MS_NOATIME|MS_DIRATIME malfunctions\n");
 	}
-	if (!test_unpriv_remount(MS_STRICTATIME|MS_NODEV, MS_NODEV,
-				 MS_NOATIME|MS_NODEV))
+	if (!test_unpriv_remount("ramfs", NULL, MS_STRICTATIME, 0, MS_NOATIME))
 	{
 		die("Default atime malfunctions\n");
 	}
+	if (!test_priv_mount_unpriv_remount()) {
+		die("Mount flags unexpectedly changed after remount\n");
+	}
 	return EXIT_SUCCESS;
 }



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 56/84] umount: Disallow unprivileged mount force
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (52 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 55/84] mnt: Update unprivileged remount test Greg Kroah-Hartman
@ 2015-01-07  1:49 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 57/84] groups: Consolidate the setgroups permission checks Greg Kroah-Hartman
                   ` (30 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit b2f5d4dc38e034eecb7987e513255265ff9aa1cf upstream.

Forced unmount affects not just the mount namespace but the underlying
superblock as well.  Restrict forced unmount to the global root user
for now.  Otherwise it becomes possible a user in a less privileged
mount namespace to force the shutdown of a superblock of a filesystem
in a more privileged mount namespace, allowing a DOS attack on root.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/namespace.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1546,6 +1546,9 @@ SYSCALL_DEFINE2(umount, char __user *, n
 		goto dput_and_out;
 	if (mnt->mnt.mnt_flags & MNT_LOCKED)
 		goto dput_and_out;
+	retval = -EPERM;
+	if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN))
+		goto dput_and_out;
 
 	retval = do_umount(mnt, flags);
 dput_and_out:



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 57/84] groups: Consolidate the setgroups permission checks
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (53 preceding siblings ...)
  2015-01-07  1:49 ` [PATCH 3.18 56/84] umount: Disallow unprivileged mount force Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 58/84] userns: Document what the invariant required for safe unprivileged mappings Greg Kroah-Hartman
                   ` (29 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 7ff4d90b4c24a03666f296c3d4878cd39001e81e upstream.

Today there are 3 instances of setgroups and due to an oversight their
permission checking has diverged.  Add a common function so that
they may all share the same permission checking code.

This corrects the current oversight in the current permission checks
and adds a helper to avoid this in the future.

A user namespace security fix will update this new helper, shortly.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/s390/kernel/compat_linux.c |    2 +-
 include/linux/cred.h            |    1 +
 kernel/groups.c                 |    9 ++++++++-
 kernel/uid16.c                  |    2 +-
 4 files changed, 11 insertions(+), 3 deletions(-)

--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -249,7 +249,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setgroups16,
 	struct group_info *group_info;
 	int retval;
 
-	if (!capable(CAP_SETGID))
+	if (!may_setgroups())
 		return -EPERM;
 	if ((unsigned)gidsetsize > NGROUPS_MAX)
 		return -EINVAL;
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -68,6 +68,7 @@ extern void groups_free(struct group_inf
 extern int set_current_groups(struct group_info *);
 extern void set_groups(struct cred *, struct group_info *);
 extern int groups_search(const struct group_info *, kgid_t);
+extern bool may_setgroups(void);
 
 /* access the groups "array" with this macro */
 #define GROUP_AT(gi, i) \
--- a/kernel/groups.c
+++ b/kernel/groups.c
@@ -213,6 +213,13 @@ out:
 	return i;
 }
 
+bool may_setgroups(void)
+{
+	struct user_namespace *user_ns = current_user_ns();
+
+	return ns_capable(user_ns, CAP_SETGID);
+}
+
 /*
  *	SMP: Our groups are copy-on-write. We can set them safely
  *	without another task interfering.
@@ -223,7 +230,7 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsi
 	struct group_info *group_info;
 	int retval;
 
-	if (!ns_capable(current_user_ns(), CAP_SETGID))
+	if (!may_setgroups())
 		return -EPERM;
 	if ((unsigned)gidsetsize > NGROUPS_MAX)
 		return -EINVAL;
--- a/kernel/uid16.c
+++ b/kernel/uid16.c
@@ -176,7 +176,7 @@ SYSCALL_DEFINE2(setgroups16, int, gidset
 	struct group_info *group_info;
 	int retval;
 
-	if (!ns_capable(current_user_ns(), CAP_SETGID))
+	if (!may_setgroups())
 		return -EPERM;
 	if ((unsigned)gidsetsize > NGROUPS_MAX)
 		return -EINVAL;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 58/84] userns: Document what the invariant required for safe unprivileged mappings.
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (54 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 57/84] groups: Consolidate the setgroups permission checks Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 59/84] userns: Dont allow setgroups until a gid mapping has been setablished Greg Kroah-Hartman
                   ` (28 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 0542f17bf2c1f2430d368f44c8fcf2f82ec9e53e upstream.

The rule is simple.  Don't allow anything that wouldn't be allowed
without unprivileged mappings.

It was previously overlooked that establishing gid mappings would
allow dropping groups and potentially gaining permission to files and
directories that had lesser permissions for a specific group than for
all other users.

This is the rule needed to fix CVE-2014-8989 and prevent any other
security issues with new_idmap_permitted.

The reason for this rule is that the unix permission model is old and
there are programs out there somewhere that take advantage of every
little corner of it.  So allowing a uid or gid mapping to be
established without privielge that would allow anything that would not
be allowed without that mapping will result in expectations from some
code somewhere being violated.  Violated expectations about the
behavior of the OS is a long way to say a security issue.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/user_namespace.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -812,7 +812,9 @@ static bool new_idmap_permitted(const st
 				struct user_namespace *ns, int cap_setid,
 				struct uid_gid_map *new_map)
 {
-	/* Allow mapping to your own filesystem ids */
+	/* Don't allow mappings that would allow anything that wouldn't
+	 * be allowed without the establishment of unprivileged mappings.
+	 */
 	if ((new_map->nr_extents == 1) && (new_map->extent[0].count == 1)) {
 		u32 id = new_map->extent[0].lower_first;
 		if (cap_setid == CAP_SETUID) {



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 59/84] userns: Dont allow setgroups until a gid mapping has been setablished
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (55 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 58/84] userns: Document what the invariant required for safe unprivileged mappings Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 60/84] userns: Dont allow unprivileged creation of gid mappings Greg Kroah-Hartman
                   ` (27 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 273d2c67c3e179adb1e74f403d1e9a06e3f841b5 upstream.

setgroups is unique in not needing a valid mapping before it can be called,
in the case of setgroups(0, NULL) which drops all supplemental groups.

The design of the user namespace assumes that CAP_SETGID can not actually
be used until a gid mapping is established.  Therefore add a helper function
to see if the user namespace gid mapping has been established and call
that function in the setgroups permission check.

This is part of the fix for CVE-2014-8989, being able to drop groups
without privilege using user namespaces.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/user_namespace.h |    5 +++++
 kernel/groups.c                |    4 +++-
 kernel/user_namespace.c        |   14 ++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -63,6 +63,7 @@ extern const struct seq_operations proc_
 extern ssize_t proc_uid_map_write(struct file *, const char __user *, size_t, loff_t *);
 extern ssize_t proc_gid_map_write(struct file *, const char __user *, size_t, loff_t *);
 extern ssize_t proc_projid_map_write(struct file *, const char __user *, size_t, loff_t *);
+extern bool userns_may_setgroups(const struct user_namespace *ns);
 #else
 
 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
@@ -87,6 +88,10 @@ static inline void put_user_ns(struct us
 {
 }
 
+static inline bool userns_may_setgroups(const struct user_namespace *ns)
+{
+	return true;
+}
 #endif
 
 #endif /* _LINUX_USER_H */
--- a/kernel/groups.c
+++ b/kernel/groups.c
@@ -6,6 +6,7 @@
 #include <linux/slab.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
+#include <linux/user_namespace.h>
 #include <asm/uaccess.h>
 
 /* init to 2 - one for init_task, one to ensure it is never freed */
@@ -217,7 +218,8 @@ bool may_setgroups(void)
 {
 	struct user_namespace *user_ns = current_user_ns();
 
-	return ns_capable(user_ns, CAP_SETGID);
+	return ns_capable(user_ns, CAP_SETGID) &&
+		userns_may_setgroups(user_ns);
 }
 
 /*
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -843,6 +843,20 @@ static bool new_idmap_permitted(const st
 	return false;
 }
 
+bool userns_may_setgroups(const struct user_namespace *ns)
+{
+	bool allowed;
+
+	mutex_lock(&id_map_mutex);
+	/* It is not safe to use setgroups until a gid mapping in
+	 * the user namespace has been established.
+	 */
+	allowed = ns->gid_map.nr_extents != 0;
+	mutex_unlock(&id_map_mutex);
+
+	return allowed;
+}
+
 static void *userns_get(struct task_struct *task)
 {
 	struct user_namespace *user_ns;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 60/84] userns: Dont allow unprivileged creation of gid mappings
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (56 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 59/84] userns: Dont allow setgroups until a gid mapping has been setablished Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 61/84] userns: Check euid no fsuid when establishing an unprivileged uid mapping Greg Kroah-Hartman
                   ` (26 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit be7c6dba2332cef0677fbabb606e279ae76652c3 upstream.

As any gid mapping will allow and must allow for backwards
compatibility dropping groups don't allow any gid mappings to be
established without CAP_SETGID in the parent user namespace.

For a small class of applications this change breaks userspace
and removes useful functionality.  This small class of applications
includes tools/testing/selftests/mount/unprivilged-remount-test.c

Most of the removed functionality will be added back with the addition
of a one way knob to disable setgroups.  Once setgroups is disabled
setting the gid_map becomes as safe as setting the uid_map.

For more common applications that set the uid_map and the gid_map
with privilege this change will have no affect.

This is part of a fix for CVE-2014-8989.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/user_namespace.c |    4 ----
 1 file changed, 4 deletions(-)

--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -821,10 +821,6 @@ static bool new_idmap_permitted(const st
 			kuid_t uid = make_kuid(ns->parent, id);
 			if (uid_eq(uid, file->f_cred->fsuid))
 				return true;
-		} else if (cap_setid == CAP_SETGID) {
-			kgid_t gid = make_kgid(ns->parent, id);
-			if (gid_eq(gid, file->f_cred->fsgid))
-				return true;
 		}
 	}
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 61/84] userns: Check euid no fsuid when establishing an unprivileged uid mapping
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (57 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 60/84] userns: Dont allow unprivileged creation of gid mappings Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 62/84] userns: Only allow the creator of the userns unprivileged mappings Greg Kroah-Hartman
                   ` (25 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 80dd00a23784b384ccea049bfb3f259d3f973b9d upstream.

setresuid allows the euid to be set to any of uid, euid, suid, and
fsuid.  Therefor it is safe to allow an unprivileged user to map
their euid and use CAP_SETUID privileged with exactly that uid,
as no new credentials can be obtained.

I can not find a combination of existing system calls that allows setting
uid, euid, suid, and fsuid from the fsuid making the previous use
of fsuid for allowing unprivileged mappings a bug.

This is part of a fix for CVE-2014-8989.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/user_namespace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -819,7 +819,7 @@ static bool new_idmap_permitted(const st
 		u32 id = new_map->extent[0].lower_first;
 		if (cap_setid == CAP_SETUID) {
 			kuid_t uid = make_kuid(ns->parent, id);
-			if (uid_eq(uid, file->f_cred->fsuid))
+			if (uid_eq(uid, file->f_cred->euid))
 				return true;
 		}
 	}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 62/84] userns: Only allow the creator of the userns unprivileged mappings
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (58 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 61/84] userns: Check euid no fsuid when establishing an unprivileged uid mapping Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 63/84] userns: Rename id_map_mutex to userns_state_mutex Greg Kroah-Hartman
                   ` (24 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit f95d7918bd1e724675de4940039f2865e5eec5fe upstream.

If you did not create the user namespace and are allowed
to write to uid_map or gid_map you should already have the necessary
privilege in the parent user namespace to establish any mapping
you want so this will not affect userspace in practice.

Limiting unprivileged uid mapping establishment to the creator of the
user namespace makes it easier to verify all credentials obtained with
the uid mapping can be obtained without the uid mapping without
privilege.

Limiting unprivileged gid mapping establishment (which is temporarily
absent) to the creator of the user namespace also ensures that the
combination of uid and gid can already be obtained without privilege.

This is part of the fix for CVE-2014-8989.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/user_namespace.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -812,14 +812,16 @@ static bool new_idmap_permitted(const st
 				struct user_namespace *ns, int cap_setid,
 				struct uid_gid_map *new_map)
 {
+	const struct cred *cred = file->f_cred;
 	/* Don't allow mappings that would allow anything that wouldn't
 	 * be allowed without the establishment of unprivileged mappings.
 	 */
-	if ((new_map->nr_extents == 1) && (new_map->extent[0].count == 1)) {
+	if ((new_map->nr_extents == 1) && (new_map->extent[0].count == 1) &&
+	    uid_eq(ns->owner, cred->euid)) {
 		u32 id = new_map->extent[0].lower_first;
 		if (cap_setid == CAP_SETUID) {
 			kuid_t uid = make_kuid(ns->parent, id);
-			if (uid_eq(uid, file->f_cred->euid))
+			if (uid_eq(uid, cred->euid))
 				return true;
 		}
 	}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 63/84] userns: Rename id_map_mutex to userns_state_mutex
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (59 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 62/84] userns: Only allow the creator of the userns unprivileged mappings Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 64/84] userns: Add a knob to disable setgroups on a per user namespace basis Greg Kroah-Hartman
                   ` (23 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit f0d62aec931e4ae3333c797d346dc4f188f454ba upstream.

Generalize id_map_mutex so it can be used for more state of a user namespace.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/user_namespace.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -24,6 +24,7 @@
 #include <linux/fs_struct.h>
 
 static struct kmem_cache *user_ns_cachep __read_mostly;
+static DEFINE_MUTEX(userns_state_mutex);
 
 static bool new_idmap_permitted(const struct file *file,
 				struct user_namespace *ns, int cap_setid,
@@ -583,9 +584,6 @@ static bool mappings_overlap(struct uid_
 	return false;
 }
 
-
-static DEFINE_MUTEX(id_map_mutex);
-
 static ssize_t map_write(struct file *file, const char __user *buf,
 			 size_t count, loff_t *ppos,
 			 int cap_setid,
@@ -602,7 +600,7 @@ static ssize_t map_write(struct file *fi
 	ssize_t ret = -EINVAL;
 
 	/*
-	 * The id_map_mutex serializes all writes to any given map.
+	 * The userns_state_mutex serializes all writes to any given map.
 	 *
 	 * Any map is only ever written once.
 	 *
@@ -620,7 +618,7 @@ static ssize_t map_write(struct file *fi
 	 * order and smp_rmb() is guaranteed that we don't have crazy
 	 * architectures returning stale data.
 	 */
-	mutex_lock(&id_map_mutex);
+	mutex_lock(&userns_state_mutex);
 
 	ret = -EPERM;
 	/* Only allow one successful write to the map */
@@ -750,7 +748,7 @@ static ssize_t map_write(struct file *fi
 	*ppos = count;
 	ret = count;
 out:
-	mutex_unlock(&id_map_mutex);
+	mutex_unlock(&userns_state_mutex);
 	if (page)
 		free_page(page);
 	return ret;
@@ -845,12 +843,12 @@ bool userns_may_setgroups(const struct u
 {
 	bool allowed;
 
-	mutex_lock(&id_map_mutex);
+	mutex_lock(&userns_state_mutex);
 	/* It is not safe to use setgroups until a gid mapping in
 	 * the user namespace has been established.
 	 */
 	allowed = ns->gid_map.nr_extents != 0;
-	mutex_unlock(&id_map_mutex);
+	mutex_unlock(&userns_state_mutex);
 
 	return allowed;
 }



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 64/84] userns: Add a knob to disable setgroups on a per user namespace basis
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (60 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 63/84] userns: Rename id_map_mutex to userns_state_mutex Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 65/84] userns: Allow setting gid_maps without privilege when setgroups is disabled Greg Kroah-Hartman
                   ` (22 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 9cc46516ddf497ea16e8d7cb986ae03a0f6b92f8 upstream.

- Expose the knob to user space through a proc file /proc/<pid>/setgroups

  A value of "deny" means the setgroups system call is disabled in the
  current processes user namespace and can not be enabled in the
  future in this user namespace.

  A value of "allow" means the segtoups system call is enabled.

- Descendant user namespaces inherit the value of setgroups from
  their parents.

- A proc file is used (instead of a sysctl) as sysctls currently do
  not allow checking the permissions at open time.

- Writing to the proc file is restricted to before the gid_map
  for the user namespace is set.

  This ensures that disabling setgroups at a user namespace
  level will never remove the ability to call setgroups
  from a process that already has that ability.

  A process may opt in to the setgroups disable for itself by
  creating, entering and configuring a user namespace or by calling
  setns on an existing user namespace with setgroups disabled.
  Processes without privileges already can not call setgroups so this
  is a noop.  Prodcess with privilege become processes without
  privilege when entering a user namespace and as with any other path
  to dropping privilege they would not have the ability to call
  setgroups.  So this remains within the bounds of what is possible
  without a knob to disable setgroups permanently in a user namespace.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/proc/base.c                 |   53 +++++++++++++++++++++++++
 include/linux/user_namespace.h |    7 +++
 kernel/user.c                  |    1 
 kernel/user_namespace.c        |   85 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 146 insertions(+)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2464,6 +2464,57 @@ static const struct file_operations proc
 	.llseek		= seq_lseek,
 	.release	= proc_id_map_release,
 };
+
+static int proc_setgroups_open(struct inode *inode, struct file *file)
+{
+	struct user_namespace *ns = NULL;
+	struct task_struct *task;
+	int ret;
+
+	ret = -ESRCH;
+	task = get_proc_task(inode);
+	if (task) {
+		rcu_read_lock();
+		ns = get_user_ns(task_cred_xxx(task, user_ns));
+		rcu_read_unlock();
+		put_task_struct(task);
+	}
+	if (!ns)
+		goto err;
+
+	if (file->f_mode & FMODE_WRITE) {
+		ret = -EACCES;
+		if (!ns_capable(ns, CAP_SYS_ADMIN))
+			goto err_put_ns;
+	}
+
+	ret = single_open(file, &proc_setgroups_show, ns);
+	if (ret)
+		goto err_put_ns;
+
+	return 0;
+err_put_ns:
+	put_user_ns(ns);
+err:
+	return ret;
+}
+
+static int proc_setgroups_release(struct inode *inode, struct file *file)
+{
+	struct seq_file *seq = file->private_data;
+	struct user_namespace *ns = seq->private;
+	int ret = single_release(inode, file);
+	put_user_ns(ns);
+	return ret;
+}
+
+static const struct file_operations proc_setgroups_operations = {
+	.open		= proc_setgroups_open,
+	.write		= proc_setgroups_write,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= proc_setgroups_release,
+};
 #endif /* CONFIG_USER_NS */
 
 static int proc_pid_personality(struct seq_file *m, struct pid_namespace *ns,
@@ -2572,6 +2623,7 @@ static const struct pid_entry tgid_base_
 	REG("uid_map",    S_IRUGO|S_IWUSR, proc_uid_map_operations),
 	REG("gid_map",    S_IRUGO|S_IWUSR, proc_gid_map_operations),
 	REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
+	REG("setgroups",  S_IRUGO|S_IWUSR, proc_setgroups_operations),
 #endif
 #ifdef CONFIG_CHECKPOINT_RESTORE
 	REG("timers",	  S_IRUGO, proc_timers_operations),
@@ -2913,6 +2965,7 @@ static const struct pid_entry tid_base_s
 	REG("uid_map",    S_IRUGO|S_IWUSR, proc_uid_map_operations),
 	REG("gid_map",    S_IRUGO|S_IWUSR, proc_gid_map_operations),
 	REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
+	REG("setgroups",  S_IRUGO|S_IWUSR, proc_setgroups_operations),
 #endif
 };
 
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -17,6 +17,10 @@ struct uid_gid_map {	/* 64 bytes -- 1 ca
 	} extent[UID_GID_MAP_MAX_EXTENTS];
 };
 
+#define USERNS_SETGROUPS_ALLOWED 1UL
+
+#define USERNS_INIT_FLAGS USERNS_SETGROUPS_ALLOWED
+
 struct user_namespace {
 	struct uid_gid_map	uid_map;
 	struct uid_gid_map	gid_map;
@@ -27,6 +31,7 @@ struct user_namespace {
 	kuid_t			owner;
 	kgid_t			group;
 	unsigned int		proc_inum;
+	unsigned long		flags;
 
 	/* Register of per-UID persistent keyrings for this namespace */
 #ifdef CONFIG_PERSISTENT_KEYRINGS
@@ -63,6 +68,8 @@ extern const struct seq_operations proc_
 extern ssize_t proc_uid_map_write(struct file *, const char __user *, size_t, loff_t *);
 extern ssize_t proc_gid_map_write(struct file *, const char __user *, size_t, loff_t *);
 extern ssize_t proc_projid_map_write(struct file *, const char __user *, size_t, loff_t *);
+extern ssize_t proc_setgroups_write(struct file *, const char __user *, size_t, loff_t *);
+extern int proc_setgroups_show(struct seq_file *m, void *v);
 extern bool userns_may_setgroups(const struct user_namespace *ns);
 #else
 
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -51,6 +51,7 @@ struct user_namespace init_user_ns = {
 	.owner = GLOBAL_ROOT_UID,
 	.group = GLOBAL_ROOT_GID,
 	.proc_inum = PROC_USER_INIT_INO,
+	.flags = USERNS_INIT_FLAGS,
 #ifdef CONFIG_PERSISTENT_KEYRINGS
 	.persistent_keyring_register_sem =
 	__RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem),
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -100,6 +100,11 @@ int create_user_ns(struct cred *new)
 	ns->owner = owner;
 	ns->group = group;
 
+	/* Inherit USERNS_SETGROUPS_ALLOWED from our parent */
+	mutex_lock(&userns_state_mutex);
+	ns->flags = parent_ns->flags;
+	mutex_unlock(&userns_state_mutex);
+
 	set_cred_user_ns(new, ns);
 
 #ifdef CONFIG_PERSISTENT_KEYRINGS
@@ -839,6 +844,84 @@ static bool new_idmap_permitted(const st
 	return false;
 }
 
+int proc_setgroups_show(struct seq_file *seq, void *v)
+{
+	struct user_namespace *ns = seq->private;
+	unsigned long userns_flags = ACCESS_ONCE(ns->flags);
+
+	seq_printf(seq, "%s\n",
+		   (userns_flags & USERNS_SETGROUPS_ALLOWED) ?
+		   "allow" : "deny");
+	return 0;
+}
+
+ssize_t proc_setgroups_write(struct file *file, const char __user *buf,
+			     size_t count, loff_t *ppos)
+{
+	struct seq_file *seq = file->private_data;
+	struct user_namespace *ns = seq->private;
+	char kbuf[8], *pos;
+	bool setgroups_allowed;
+	ssize_t ret;
+
+	/* Only allow a very narrow range of strings to be written */
+	ret = -EINVAL;
+	if ((*ppos != 0) || (count >= sizeof(kbuf)))
+		goto out;
+
+	/* What was written? */
+	ret = -EFAULT;
+	if (copy_from_user(kbuf, buf, count))
+		goto out;
+	kbuf[count] = '\0';
+	pos = kbuf;
+
+	/* What is being requested? */
+	ret = -EINVAL;
+	if (strncmp(pos, "allow", 5) == 0) {
+		pos += 5;
+		setgroups_allowed = true;
+	}
+	else if (strncmp(pos, "deny", 4) == 0) {
+		pos += 4;
+		setgroups_allowed = false;
+	}
+	else
+		goto out;
+
+	/* Verify there is not trailing junk on the line */
+	pos = skip_spaces(pos);
+	if (*pos != '\0')
+		goto out;
+
+	ret = -EPERM;
+	mutex_lock(&userns_state_mutex);
+	if (setgroups_allowed) {
+		/* Enabling setgroups after setgroups has been disabled
+		 * is not allowed.
+		 */
+		if (!(ns->flags & USERNS_SETGROUPS_ALLOWED))
+			goto out_unlock;
+	} else {
+		/* Permanently disabling setgroups after setgroups has
+		 * been enabled by writing the gid_map is not allowed.
+		 */
+		if (ns->gid_map.nr_extents != 0)
+			goto out_unlock;
+		ns->flags &= ~USERNS_SETGROUPS_ALLOWED;
+	}
+	mutex_unlock(&userns_state_mutex);
+
+	/* Report a successful write */
+	*ppos = count;
+	ret = count;
+out:
+	return ret;
+out_unlock:
+	mutex_unlock(&userns_state_mutex);
+	goto out;
+}
+
 bool userns_may_setgroups(const struct user_namespace *ns)
 {
 	bool allowed;
@@ -848,6 +931,8 @@ bool userns_may_setgroups(const struct u
 	 * the user namespace has been established.
 	 */
 	allowed = ns->gid_map.nr_extents != 0;
+	/* Is setgroups allowed? */
+	allowed = allowed && (ns->flags & USERNS_SETGROUPS_ALLOWED);
 	mutex_unlock(&userns_state_mutex);
 
 	return allowed;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 65/84] userns: Allow setting gid_maps without privilege when setgroups is disabled
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (61 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 64/84] userns: Add a knob to disable setgroups on a per user namespace basis Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 66/84] userns: Unbreak the unprivileged remount tests Greg Kroah-Hartman
                   ` (21 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Andy Lutomirski, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit 66d2f338ee4c449396b6f99f5e75cd18eb6df272 upstream.

Now that setgroups can be disabled and not reenabled, setting gid_map
without privielge can now be enabled when setgroups is disabled.

This restores most of the functionality that was lost when unprivileged
setting of gid_map was removed.  Applications that use this functionality
will need to check to see if they use setgroups or init_groups, and if they
don't they can be fixed by simply disabling setgroups before writing to
gid_map.

Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/user_namespace.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -826,6 +826,11 @@ static bool new_idmap_permitted(const st
 			kuid_t uid = make_kuid(ns->parent, id);
 			if (uid_eq(uid, cred->euid))
 				return true;
+		} else if (cap_setid == CAP_SETGID) {
+			kgid_t gid = make_kgid(ns->parent, id);
+			if (!(ns->flags & USERNS_SETGROUPS_ALLOWED) &&
+			    gid_eq(gid, cred->egid))
+				return true;
 		}
 	}
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 66/84] userns: Unbreak the unprivileged remount tests
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (62 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 65/84] userns: Allow setting gid_maps without privilege when setgroups is disabled Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 67/84] audit: use supplied gfp_mask from audit_buffer in kauditd_send_multicast_skb Greg Kroah-Hartman
                   ` (20 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric W. Biederman

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

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

From: "Eric W. Biederman" <ebiederm@xmission.com>

commit db86da7cb76f797a1a8b445166a15cb922c6ff85 upstream.

A security fix in caused the way the unprivileged remount tests were
using user namespaces to break.  Tweak the way user namespaces are
being used so the test works again.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 tools/testing/selftests/mount/unprivileged-remount-test.c |   32 ++++++++++----
 1 file changed, 24 insertions(+), 8 deletions(-)

--- a/tools/testing/selftests/mount/unprivileged-remount-test.c
+++ b/tools/testing/selftests/mount/unprivileged-remount-test.c
@@ -53,17 +53,14 @@ static void die(char *fmt, ...)
 	exit(EXIT_FAILURE);
 }
 
-static void write_file(char *filename, char *fmt, ...)
+static void vmaybe_write_file(bool enoent_ok, char *filename, char *fmt, va_list ap)
 {
 	char buf[4096];
 	int fd;
 	ssize_t written;
 	int buf_len;
-	va_list ap;
 
-	va_start(ap, fmt);
 	buf_len = vsnprintf(buf, sizeof(buf), fmt, ap);
-	va_end(ap);
 	if (buf_len < 0) {
 		die("vsnprintf failed: %s\n",
 		    strerror(errno));
@@ -74,6 +71,8 @@ static void write_file(char *filename, c
 
 	fd = open(filename, O_WRONLY);
 	if (fd < 0) {
+		if ((errno == ENOENT) && enoent_ok)
+			return;
 		die("open of %s failed: %s\n",
 		    filename, strerror(errno));
 	}
@@ -92,6 +91,26 @@ static void write_file(char *filename, c
 	}
 }
 
+static void maybe_write_file(char *filename, char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vmaybe_write_file(true, filename, fmt, ap);
+	va_end(ap);
+
+}
+
+static void write_file(char *filename, char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vmaybe_write_file(false, filename, fmt, ap);
+	va_end(ap);
+
+}
+
 static int read_mnt_flags(const char *path)
 {
 	int ret;
@@ -144,13 +163,10 @@ static void create_and_enter_userns(void
 			strerror(errno));
 	}
 
+	maybe_write_file("/proc/self/setgroups", "deny");
 	write_file("/proc/self/uid_map", "0 %d 1", uid);
 	write_file("/proc/self/gid_map", "0 %d 1", gid);
 
-	if (setgroups(0, NULL) != 0) {
-		die("setgroups failed: %s\n",
-			strerror(errno));
-	}
 	if (setgid(0) != 0) {
 		die ("setgid(0) failed %s\n",
 			strerror(errno));



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 67/84] audit: use supplied gfp_mask from audit_buffer in kauditd_send_multicast_skb
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (63 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 66/84] userns: Unbreak the unprivileged remount tests Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 68/84] audit: dont attempt to lookup PIDs when changing PID filtering audit rules Greg Kroah-Hartman
                   ` (19 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Valdis Kletnieks, Richard Guy Briggs,
	Paul Moore

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

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

From: Richard Guy Briggs <rgb@redhat.com>

commit 54dc77d974a50147d6639dac6f59cb2c29207161 upstream.

Eric Paris explains: Since kauditd_send_multicast_skb() gets called in
audit_log_end(), which can come from any context (aka even a sleeping context)
GFP_KERNEL can't be used.  Since the audit_buffer knows what context it should
use, pass that down and use that.

See: https://lkml.org/lkml/2014/12/16/542

BUG: sleeping function called from invalid context at mm/slab.c:2849
in_atomic(): 1, irqs_disabled(): 0, pid: 885, name: sulogin
2 locks held by sulogin/885:
  #0:  (&sig->cred_guard_mutex){+.+.+.}, at: [<ffffffff91152e30>] prepare_bprm_creds+0x28/0x8b
  #1:  (tty_files_lock){+.+.+.}, at: [<ffffffff9123e787>] selinux_bprm_committing_creds+0x55/0x22b
CPU: 1 PID: 885 Comm: sulogin Not tainted 3.18.0-next-20141216 #30
Hardware name: Dell Inc. Latitude E6530/07Y85M, BIOS A15 06/20/2014
  ffff880223744f10 ffff88022410f9b8 ffffffff916ba529 0000000000000375
  ffff880223744f10 ffff88022410f9e8 ffffffff91063185 0000000000000006
  0000000000000000 0000000000000000 0000000000000000 ffff88022410fa38
Call Trace:
  [<ffffffff916ba529>] dump_stack+0x50/0xa8
  [<ffffffff91063185>] ___might_sleep+0x1b6/0x1be
  [<ffffffff910632a6>] __might_sleep+0x119/0x128
  [<ffffffff91140720>] cache_alloc_debugcheck_before.isra.45+0x1d/0x1f
  [<ffffffff91141d81>] kmem_cache_alloc+0x43/0x1c9
  [<ffffffff914e148d>] __alloc_skb+0x42/0x1a3
  [<ffffffff914e2b62>] skb_copy+0x3e/0xa3
  [<ffffffff910c263e>] audit_log_end+0x83/0x100
  [<ffffffff9123b8d3>] ? avc_audit_pre_callback+0x103/0x103
  [<ffffffff91252a73>] common_lsm_audit+0x441/0x450
  [<ffffffff9123c163>] slow_avc_audit+0x63/0x67
  [<ffffffff9123c42c>] avc_has_perm+0xca/0xe3
  [<ffffffff9123dc2d>] inode_has_perm+0x5a/0x65
  [<ffffffff9123e7ca>] selinux_bprm_committing_creds+0x98/0x22b
  [<ffffffff91239e64>] security_bprm_committing_creds+0xe/0x10
  [<ffffffff911515e6>] install_exec_creds+0xe/0x79
  [<ffffffff911974cf>] load_elf_binary+0xe36/0x10d7
  [<ffffffff9115198e>] search_binary_handler+0x81/0x18c
  [<ffffffff91153376>] do_execveat_common.isra.31+0x4e3/0x7b7
  [<ffffffff91153669>] do_execve+0x1f/0x21
  [<ffffffff91153967>] SyS_execve+0x25/0x29
  [<ffffffff916c61a9>] stub_execve+0x69/0xa0

Reported-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Tested-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/audit.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -429,7 +429,7 @@ static void kauditd_send_skb(struct sk_b
  * This function doesn't consume an skb as might be expected since it has to
  * copy it anyways.
  */
-static void kauditd_send_multicast_skb(struct sk_buff *skb)
+static void kauditd_send_multicast_skb(struct sk_buff *skb, gfp_t gfp_mask)
 {
 	struct sk_buff		*copy;
 	struct audit_net	*aunet = net_generic(&init_net, audit_net_id);
@@ -448,11 +448,11 @@ static void kauditd_send_multicast_skb(s
 	 * no reason for new multicast clients to continue with this
 	 * non-compliance.
 	 */
-	copy = skb_copy(skb, GFP_KERNEL);
+	copy = skb_copy(skb, gfp_mask);
 	if (!copy)
 		return;
 
-	nlmsg_multicast(sock, copy, 0, AUDIT_NLGRP_READLOG, GFP_KERNEL);
+	nlmsg_multicast(sock, copy, 0, AUDIT_NLGRP_READLOG, gfp_mask);
 }
 
 /*
@@ -1949,7 +1949,7 @@ void audit_log_end(struct audit_buffer *
 		struct nlmsghdr *nlh = nlmsg_hdr(ab->skb);
 
 		nlh->nlmsg_len = ab->skb->len;
-		kauditd_send_multicast_skb(ab->skb);
+		kauditd_send_multicast_skb(ab->skb, ab->gfp_mask);
 
 		/*
 		 * The original kaudit unicast socket sends up messages with



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 68/84] audit: dont attempt to lookup PIDs when changing PID filtering audit rules
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (64 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 67/84] audit: use supplied gfp_mask from audit_buffer in kauditd_send_multicast_skb Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 69/84] audit: restore AUDIT_LOGINUID unset ABI Greg Kroah-Hartman
                   ` (18 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Richard Guy Briggs, Paul Moore, Eric Paris

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

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

From: Paul Moore <pmoore@redhat.com>

commit 3640dcfa4fd00cd91d88bb86250bdb496f7070c0 upstream.

Commit f1dc4867 ("audit: anchor all pid references in the initial pid
namespace") introduced a find_vpid() call when adding/removing audit
rules with PID/PPID filters; unfortunately this is problematic as
find_vpid() only works if there is a task with the associated PID
alive on the system.  The following commands demonstrate a simple
reproducer.

	# auditctl -D
	# auditctl -l
	# autrace /bin/true
	# auditctl -l

This patch resolves the problem by simply using the PID provided by
the user without any additional validation, e.g. no calls to check to
see if the task/PID exists.

Cc: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Paul Moore <pmoore@redhat.com>
Acked-by: Eric Paris <eparis@redhat.com>
Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/auditfilter.c |   13 -------------
 1 file changed, 13 deletions(-)

--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -444,19 +444,6 @@ static struct audit_entry *audit_data_to
 			f->val = 0;
 		}
 
-		if ((f->type == AUDIT_PID) || (f->type == AUDIT_PPID)) {
-			struct pid *pid;
-			rcu_read_lock();
-			pid = find_vpid(f->val);
-			if (!pid) {
-				rcu_read_unlock();
-				err = -ESRCH;
-				goto exit_free;
-			}
-			f->val = pid_nr(pid);
-			rcu_read_unlock();
-		}
-
 		err = audit_field_valid(entry, f);
 		if (err)
 			goto exit_free;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 69/84] audit: restore AUDIT_LOGINUID unset ABI
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (65 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 68/84] audit: dont attempt to lookup PIDs when changing PID filtering audit rules Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 70/84] crypto: af_alg - fix backlog handling Greg Kroah-Hartman
                   ` (17 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Richard Guy Briggs, Paul Moore

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

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

From: Richard Guy Briggs <rgb@redhat.com>

commit 041d7b98ffe59c59fdd639931dea7d74f9aa9a59 upstream.

A regression was caused by commit 780a7654cee8:
	 audit: Make testing for a valid loginuid explicit.
(which in turn attempted to fix a regression caused by e1760bd)

When audit_krule_to_data() fills in the rules to get a listing, there was a
missing clause to convert back from AUDIT_LOGINUID_SET to AUDIT_LOGINUID.

This broke userspace by not returning the same information that was sent and
expected.

The rule:
	auditctl -a exit,never -F auid=-1
gives:
	auditctl -l
		LIST_RULES: exit,never f24=0 syscall=all
when it should give:
		LIST_RULES: exit,never auid=-1 (0xffffffff) syscall=all

Tag it so that it is reported the same way it was set.  Create a new
private flags audit_krule field (pflags) to store it that won't interact with
the public one from the API.

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/audit.h |    4 ++++
 kernel/auditfilter.c  |   10 ++++++++++
 2 files changed, 14 insertions(+)

--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -47,6 +47,7 @@ struct sk_buff;
 
 struct audit_krule {
 	int			vers_ops;
+	u32			pflags;
 	u32			flags;
 	u32			listnr;
 	u32			action;
@@ -64,6 +65,9 @@ struct audit_krule {
 	u64			prio;
 };
 
+/* Flag to indicate legacy AUDIT_LOGINUID unset usage */
+#define AUDIT_LOGINUID_LEGACY		0x1
+
 struct audit_field {
 	u32				type;
 	union {
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -442,6 +442,7 @@ static struct audit_entry *audit_data_to
 		if ((f->type == AUDIT_LOGINUID) && (f->val == AUDIT_UID_UNSET)) {
 			f->type = AUDIT_LOGINUID_SET;
 			f->val = 0;
+			entry->rule.pflags |= AUDIT_LOGINUID_LEGACY;
 		}
 
 		err = audit_field_valid(entry, f);
@@ -617,6 +618,13 @@ static struct audit_rule_data *audit_kru
 			data->buflen += data->values[i] =
 				audit_pack_string(&bufp, krule->filterkey);
 			break;
+		case AUDIT_LOGINUID_SET:
+			if (krule->pflags & AUDIT_LOGINUID_LEGACY && !f->val) {
+				data->fields[i] = AUDIT_LOGINUID;
+				data->values[i] = AUDIT_UID_UNSET;
+				break;
+			}
+			/* fallthrough if set */
 		default:
 			data->values[i] = f->val;
 		}
@@ -633,6 +641,7 @@ static int audit_compare_rule(struct aud
 	int i;
 
 	if (a->flags != b->flags ||
+	    a->pflags != b->pflags ||
 	    a->listnr != b->listnr ||
 	    a->action != b->action ||
 	    a->field_count != b->field_count)
@@ -751,6 +760,7 @@ struct audit_entry *audit_dupe_rule(stru
 	new = &entry->rule;
 	new->vers_ops = old->vers_ops;
 	new->flags = old->flags;
+	new->pflags = old->pflags;
 	new->listnr = old->listnr;
 	new->action = old->action;
 	for (i = 0; i < AUDIT_BITMASK_SIZE; i++)



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 70/84] crypto: af_alg - fix backlog handling
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (66 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 69/84] audit: restore AUDIT_LOGINUID unset ABI Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 71/84] ncpfs: return proper error from NCP_IOC_SETROOT ioctl Greg Kroah-Hartman
                   ` (16 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Rabin Vincent, Herbert Xu

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

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

From: Rabin Vincent <rabin.vincent@axis.com>

commit 7e77bdebff5cb1e9876c561f69710b9ab8fa1f7e upstream.

If a request is backlogged, it's complete() handler will get called
twice: once with -EINPROGRESS, and once with the final error code.

af_alg's complete handler, unlike other users, does not handle the
-EINPROGRESS but instead always completes the completion that recvmsg()
is waiting on.  This can lead to a return to user space while the
request is still pending in the driver.  If userspace closes the sockets
before the requests are handled by the driver, this will lead to
use-after-frees (and potential crashes) in the kernel due to the tfm
having been freed.

The crashes can be easily reproduced (for example) by reducing the max
queue length in cryptod.c and running the following (from
http://www.chronox.de/libkcapi.html) on AES-NI capable hardware:

 $ while true; do kcapi -x 1 -e -c '__ecb-aes-aesni' \
    -k 00000000000000000000000000000000 \
    -p 00000000000000000000000000000000 >/dev/null & done

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 crypto/af_alg.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -449,6 +449,9 @@ void af_alg_complete(struct crypto_async
 {
 	struct af_alg_completion *completion = req->data;
 
+	if (err == -EINPROGRESS)
+		return;
+
 	completion->err = err;
 	complete(&completion->completion);
 }



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 71/84] ncpfs: return proper error from NCP_IOC_SETROOT ioctl
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (67 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 70/84] crypto: af_alg - fix backlog handling Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 72/84] mm/CMA: fix boot regression due to physical address of high_memory Greg Kroah-Hartman
                   ` (15 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jan Kara, Petr Vandrovec,
	Andrew Morton, Linus Torvalds

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

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

From: Jan Kara <jack@suse.cz>

commit a682e9c28cac152e6e54c39efcf046e0c8cfcf63 upstream.

If some error happens in NCP_IOC_SETROOT ioctl, the appropriate error
return value is then (in most cases) just overwritten before we return.
This can result in reporting success to userspace although error happened.

This bug was introduced by commit 2e54eb96e2c8 ("BKL: Remove BKL from
ncpfs").  Propagate the errors correctly.

Coverity id: 1226925.

Fixes: 2e54eb96e2c80 ("BKL: Remove BKL from ncpfs")
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Petr Vandrovec <petr@vandrovec.name>
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/ncpfs/ioctl.c |    1 -
 1 file changed, 1 deletion(-)

--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -447,7 +447,6 @@ static long __ncp_ioctl(struct inode *in
 						result = -EIO;
 					}
 				}
-				result = 0;
 			}
 			mutex_unlock(&server->root_setup_lock);
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 72/84] mm/CMA: fix boot regression due to physical address of high_memory
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (68 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 71/84] ncpfs: return proper error from NCP_IOC_SETROOT ioctl Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 73/84] exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting Greg Kroah-Hartman
                   ` (14 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Joonsoo Kim, Ingo Molnar,
	Marek Szyprowski, Russell King, Andrew Morton, Linus Torvalds

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

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

From: Joonsoo Kim <iamjoonsoo.kim@lge.com>

commit 6b101e2a3ce4d2a0312087598bd1ab4a1db2ac40 upstream.

high_memory isn't direct mapped memory so retrieving it's physical address
isn't appropriate.  But, it would be useful to check physical address of
highmem boundary so it's justfiable to get physical address from it.  In
x86, there is a validation check if CONFIG_DEBUG_VIRTUAL and it triggers
following boot failure reported by Ingo.

  ...
  BUG: Int 6: CR2 00f06f53
  ...
  Call Trace:
    dump_stack+0x41/0x52
    early_idt_handler+0x6b/0x6b
    cma_declare_contiguous+0x33/0x212
    dma_contiguous_reserve_area+0x31/0x4e
    dma_contiguous_reserve+0x11d/0x125
    setup_arch+0x7b5/0xb63
    start_kernel+0xb8/0x3e6
    i386_start_kernel+0x79/0x7d

To fix boot regression, this patch implements workaround to avoid
validation check in x86 when retrieving physical address of high_memory.
__pa_nodebug() used by this patch is implemented only in x86 so there is
no choice but to use dirty #ifdef.

[akpm@linux-foundation.org: tweak comment]
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Reported-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Ingo Molnar <mingo@kernel.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Russell King <rmk@arm.linux.org.uk>
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>

---
 mm/cma.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

--- a/mm/cma.c
+++ b/mm/cma.c
@@ -215,9 +215,21 @@ int __init cma_declare_contiguous(phys_a
 			bool fixed, struct cma **res_cma)
 {
 	phys_addr_t memblock_end = memblock_end_of_DRAM();
-	phys_addr_t highmem_start = __pa(high_memory);
+	phys_addr_t highmem_start;
 	int ret = 0;
 
+#ifdef CONFIG_X86
+	/*
+	 * high_memory isn't direct mapped memory so retrieving its physical
+	 * address isn't appropriate.  But it would be useful to check the
+	 * physical address of the highmem boundary so it's justfiable to get
+	 * the physical address from it.  On x86 there is a validation check for
+	 * this case, so the following workaround is needed to avoid it.
+	 */
+	highmem_start = __pa_nodebug(high_memory);
+#else
+	highmem_start = __pa(high_memory);
+#endif
 	pr_debug("%s(size %pa, base %pa, limit %pa alignment %pa)\n",
 		__func__, &size, &base, &limit, &alignment);
 



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 73/84] exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (69 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 72/84] mm/CMA: fix boot regression due to physical address of high_memory Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 74/84] udf: Check path length when reading symlink Greg Kroah-Hartman
                   ` (13 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Oleg Nesterov, Eric W. Biederman,
	Aaron Tomlin, Pavel Emelyanov, Serge Hallyn, Sterling Alexander,
	Andrew Morton, Linus Torvalds

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

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

From: Oleg Nesterov <oleg@redhat.com>

commit 24c037ebf5723d4d9ab0996433cee4f96c292a4d upstream.

alloc_pid() does get_pid_ns() beforehand but forgets to put_pid_ns() if it
fails because disable_pid_allocation() was called by the exiting
child_reaper.

We could simply move get_pid_ns() down to successful return, but this fix
tries to be as trivial as possible.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Aaron Tomlin <atomlin@redhat.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Serge Hallyn <serge.hallyn@ubuntu.com>
Cc: Sterling Alexander <stalexan@redhat.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>

---
 kernel/pid.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -341,6 +341,8 @@ out:
 
 out_unlock:
 	spin_unlock_irq(&pidmap_lock);
+	put_pid_ns(ns);
+
 out_free:
 	while (++i <= ns->level)
 		free_pidmap(pid->numbers + i);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 74/84] udf: Check path length when reading symlink
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (70 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 73/84] exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 75/84] udf: Verify i_size when loading inode Greg Kroah-Hartman
                   ` (12 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Carl Henrik Lunde, Jan Kara

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

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

From: Jan Kara <jack@suse.cz>

commit 0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14 upstream.

Symlink reading code does not check whether the resulting path fits into
the page provided by the generic code. This isn't as easy as just
checking the symlink size because of various encoding conversions we
perform on path. So we have to check whether there is still enough space
in the buffer on the fly.

Reported-by: Carl Henrik Lunde <chlunde@ping.uio.no>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/udf/dir.c     |    3 ++-
 fs/udf/namei.c   |    3 ++-
 fs/udf/symlink.c |   31 ++++++++++++++++++++++++++-----
 fs/udf/udfdecl.h |    3 ++-
 fs/udf/unicode.c |   28 ++++++++++++++++------------
 5 files changed, 48 insertions(+), 20 deletions(-)

--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -167,7 +167,8 @@ static int udf_readdir(struct file *file
 			continue;
 		}
 
-		flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi);
+		flen = udf_get_filename(dir->i_sb, nameptr, lfi, fname,
+					UDF_NAME_LEN);
 		if (!flen)
 			continue;
 
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -233,7 +233,8 @@ static struct fileIdentDesc *udf_find_en
 		if (!lfi)
 			continue;
 
-		flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi);
+		flen = udf_get_filename(dir->i_sb, nameptr, lfi, fname,
+					UDF_NAME_LEN);
 		if (flen && udf_match(flen, fname, child->len, child->name))
 			goto out_ok;
 	}
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -30,13 +30,16 @@
 #include <linux/buffer_head.h>
 #include "udf_i.h"
 
-static void udf_pc_to_char(struct super_block *sb, unsigned char *from,
-			   int fromlen, unsigned char *to)
+static int udf_pc_to_char(struct super_block *sb, unsigned char *from,
+			  int fromlen, unsigned char *to, int tolen)
 {
 	struct pathComponent *pc;
 	int elen = 0;
+	int comp_len;
 	unsigned char *p = to;
 
+	/* Reserve one byte for terminating \0 */
+	tolen--;
 	while (elen < fromlen) {
 		pc = (struct pathComponent *)(from + elen);
 		switch (pc->componentType) {
@@ -49,22 +52,37 @@ static void udf_pc_to_char(struct super_
 				break;
 			/* Fall through */
 		case 2:
+			if (tolen == 0)
+				return -ENAMETOOLONG;
 			p = to;
 			*p++ = '/';
+			tolen--;
 			break;
 		case 3:
+			if (tolen < 3)
+				return -ENAMETOOLONG;
 			memcpy(p, "../", 3);
 			p += 3;
+			tolen -= 3;
 			break;
 		case 4:
+			if (tolen < 2)
+				return -ENAMETOOLONG;
 			memcpy(p, "./", 2);
 			p += 2;
+			tolen -= 2;
 			/* that would be . - just ignore */
 			break;
 		case 5:
-			p += udf_get_filename(sb, pc->componentIdent, p,
-					      pc->lengthComponentIdent);
+			comp_len = udf_get_filename(sb, pc->componentIdent,
+						    pc->lengthComponentIdent,
+						    p, tolen);
+			p += comp_len;
+			tolen -= comp_len;
+			if (tolen == 0)
+				return -ENAMETOOLONG;
 			*p++ = '/';
+			tolen--;
 			break;
 		}
 		elen += sizeof(struct pathComponent) + pc->lengthComponentIdent;
@@ -73,6 +91,7 @@ static void udf_pc_to_char(struct super_
 		p[-1] = '\0';
 	else
 		p[0] = '\0';
+	return 0;
 }
 
 static int udf_symlink_filler(struct file *file, struct page *page)
@@ -100,8 +119,10 @@ static int udf_symlink_filler(struct fil
 		symlink = bh->b_data;
 	}
 
-	udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p);
+	err = udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p, PAGE_SIZE);
 	brelse(bh);
+	if (err)
+		goto out_unlock_inode;
 
 	up_read(&iinfo->i_data_sem);
 	SetPageUptodate(page);
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -211,7 +211,8 @@ udf_get_lb_pblock(struct super_block *sb
 }
 
 /* unicode.c */
-extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int);
+extern int udf_get_filename(struct super_block *, uint8_t *, int, uint8_t *,
+			    int);
 extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
 			    int);
 extern int udf_build_ustr(struct ustr *, dstring *, int);
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -28,7 +28,8 @@
 
 #include "udf_sb.h"
 
-static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int);
+static int udf_translate_to_linux(uint8_t *, int, uint8_t *, int, uint8_t *,
+				  int);
 
 static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen)
 {
@@ -333,8 +334,8 @@ try_again:
 	return u_len + 1;
 }
 
-int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
-		     int flen)
+int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
+		     uint8_t *dname, int dlen)
 {
 	struct ustr *filename, *unifilename;
 	int len = 0;
@@ -347,7 +348,7 @@ int udf_get_filename(struct super_block
 	if (!unifilename)
 		goto out1;
 
-	if (udf_build_ustr_exact(unifilename, sname, flen))
+	if (udf_build_ustr_exact(unifilename, sname, slen))
 		goto out2;
 
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
@@ -366,7 +367,8 @@ int udf_get_filename(struct super_block
 	} else
 		goto out2;
 
-	len = udf_translate_to_linux(dname, filename->u_name, filename->u_len,
+	len = udf_translate_to_linux(dname, dlen,
+				     filename->u_name, filename->u_len,
 				     unifilename->u_name, unifilename->u_len);
 out2:
 	kfree(unifilename);
@@ -403,10 +405,12 @@ int udf_put_filename(struct super_block
 #define EXT_MARK		'.'
 #define CRC_MARK		'#'
 #define EXT_SIZE 		5
+/* Number of chars we need to store generated CRC to make filename unique */
+#define CRC_LEN			5
 
-static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName,
-				  int udfLen, uint8_t *fidName,
-				  int fidNameLen)
+static int udf_translate_to_linux(uint8_t *newName, int newLen,
+				  uint8_t *udfName, int udfLen,
+				  uint8_t *fidName, int fidNameLen)
 {
 	int index, newIndex = 0, needsCRC = 0;
 	int extIndex = 0, newExtIndex = 0, hasExt = 0;
@@ -439,7 +443,7 @@ static int udf_translate_to_linux(uint8_
 					newExtIndex = newIndex;
 				}
 			}
-			if (newIndex < 256)
+			if (newIndex < newLen)
 				newName[newIndex++] = curr;
 			else
 				needsCRC = 1;
@@ -467,13 +471,13 @@ static int udf_translate_to_linux(uint8_
 				}
 				ext[localExtIndex++] = curr;
 			}
-			maxFilenameLen = 250 - localExtIndex;
+			maxFilenameLen = newLen - CRC_LEN - localExtIndex;
 			if (newIndex > maxFilenameLen)
 				newIndex = maxFilenameLen;
 			else
 				newIndex = newExtIndex;
-		} else if (newIndex > 250)
-			newIndex = 250;
+		} else if (newIndex > newLen - CRC_LEN)
+			newIndex = newLen - CRC_LEN;
 		newName[newIndex++] = CRC_MARK;
 		valueCRC = crc_itu_t(0, fidName, fidNameLen);
 		newName[newIndex++] = hex_asc_upper_hi(valueCRC >> 8);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 75/84] udf: Verify i_size when loading inode
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (71 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 74/84] udf: Check path length when reading symlink Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 76/84] udf: Verify symlink size before loading it Greg Kroah-Hartman
                   ` (11 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Carl Henrik Lunde, Jan Kara

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

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

From: Jan Kara <jack@suse.cz>

commit e159332b9af4b04d882dbcfe1bb0117f0a6d4b58 upstream.

Verify that inode size is sane when loading inode with data stored in
ICB. Otherwise we may get confused later when working with the inode and
inode size is too big.

Reported-by: Carl Henrik Lunde <chlunde@ping.uio.no>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/udf/inode.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1489,6 +1489,20 @@ reread:
 	}
 	inode->i_generation = iinfo->i_unique;
 
+	/* Sanity checks for files in ICB so that we don't get confused later */
+	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
+		/*
+		 * For file in ICB data is stored in allocation descriptor
+		 * so sizes should match
+		 */
+		if (iinfo->i_lenAlloc != inode->i_size)
+			goto out;
+		/* File in ICB has to fit in there... */
+		if (inode->i_size > inode->i_sb->s_blocksize -
+					udf_file_entry_alloc_offset(inode))
+			goto out;
+	}
+
 	switch (fe->icbTag.fileType) {
 	case ICBTAG_FILE_TYPE_DIRECTORY:
 		inode->i_op = &udf_dir_inode_operations;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 76/84] udf: Verify symlink size before loading it
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (72 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 75/84] udf: Verify i_size when loading inode Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 77/84] udf: Check component length before reading it Greg Kroah-Hartman
                   ` (10 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Carl Henrik Lunde, Jan Kara

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

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

From: Jan Kara <jack@suse.cz>

commit a1d47b262952a45aae62bd49cfaf33dd76c11a2c upstream.

UDF specification allows arbitrarily large symlinks. However we support
only symlinks at most one block large. Check the length of the symlink
so that we don't access memory beyond end of the symlink block.

Reported-by: Carl Henrik Lunde <chlunde@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/udf/symlink.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -99,11 +99,17 @@ static int udf_symlink_filler(struct fil
 	struct inode *inode = page->mapping->host;
 	struct buffer_head *bh = NULL;
 	unsigned char *symlink;
-	int err = -EIO;
+	int err;
 	unsigned char *p = kmap(page);
 	struct udf_inode_info *iinfo;
 	uint32_t pos;
 
+	/* We don't support symlinks longer than one block */
+	if (inode->i_size > inode->i_sb->s_blocksize) {
+		err = -ENAMETOOLONG;
+		goto out_unmap;
+	}
+
 	iinfo = UDF_I(inode);
 	pos = udf_block_map(inode, 0);
 
@@ -113,8 +119,10 @@ static int udf_symlink_filler(struct fil
 	} else {
 		bh = sb_bread(inode->i_sb, pos);
 
-		if (!bh)
-			goto out;
+		if (!bh) {
+			err = -EIO;
+			goto out_unlock_inode;
+		}
 
 		symlink = bh->b_data;
 	}
@@ -130,9 +138,10 @@ static int udf_symlink_filler(struct fil
 	unlock_page(page);
 	return 0;
 
-out:
+out_unlock_inode:
 	up_read(&iinfo->i_data_sem);
 	SetPageError(page);
+out_unmap:
 	kunmap(page);
 	unlock_page(page);
 	return err;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 77/84] udf: Check component length before reading it
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (73 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 76/84] udf: Verify symlink size before loading it Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 78/84] eCryptfs: Force RO mount when encrypted view is enabled Greg Kroah-Hartman
                   ` (9 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Carl Henrik Lunde, Jan Kara

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

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

From: Jan Kara <jack@suse.cz>

commit e237ec37ec154564f8690c5bd1795339955eeef9 upstream.

Check that length specified in a component of a symlink fits in the
input buffer we are reading. Also properly ignore component length for
component types that do not use it. Otherwise we read memory after end
of buffer for corrupted udf image.

Reported-by: Carl Henrik Lunde <chlunde@ping.uio.no>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/udf/symlink.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -42,14 +42,17 @@ static int udf_pc_to_char(struct super_b
 	tolen--;
 	while (elen < fromlen) {
 		pc = (struct pathComponent *)(from + elen);
+		elen += sizeof(struct pathComponent);
 		switch (pc->componentType) {
 		case 1:
 			/*
 			 * Symlink points to some place which should be agreed
  			 * upon between originator and receiver of the media. Ignore.
 			 */
-			if (pc->lengthComponentIdent > 0)
+			if (pc->lengthComponentIdent > 0) {
+				elen += pc->lengthComponentIdent;
 				break;
+			}
 			/* Fall through */
 		case 2:
 			if (tolen == 0)
@@ -74,6 +77,9 @@ static int udf_pc_to_char(struct super_b
 			/* that would be . - just ignore */
 			break;
 		case 5:
+			elen += pc->lengthComponentIdent;
+			if (elen > fromlen)
+				return -EIO;
 			comp_len = udf_get_filename(sb, pc->componentIdent,
 						    pc->lengthComponentIdent,
 						    p, tolen);
@@ -85,7 +91,6 @@ static int udf_pc_to_char(struct super_b
 			tolen--;
 			break;
 		}
-		elen += sizeof(struct pathComponent) + pc->lengthComponentIdent;
 	}
 	if (p > to + 1)
 		p[-1] = '\0';



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 78/84] eCryptfs: Force RO mount when encrypted view is enabled
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (74 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 77/84] udf: Check component length before reading it Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 79/84] eCryptfs: Remove buggy and unnecessary write in file name decode routine Greg Kroah-Hartman
                   ` (8 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Tyler Hicks, Priya Bansal

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

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

From: Tyler Hicks <tyhicks@canonical.com>

commit 332b122d39c9cbff8b799007a825d94b2e7c12f2 upstream.

The ecryptfs_encrypted_view mount option greatly changes the
functionality of an eCryptfs mount. Instead of encrypting and decrypting
lower files, it provides a unified view of the encrypted files in the
lower filesystem. The presence of the ecryptfs_encrypted_view mount
option is intended to force a read-only mount and modifying files is not
supported when the feature is in use. See the following commit for more
information:

  e77a56d [PATCH] eCryptfs: Encrypted passthrough

This patch forces the mount to be read-only when the
ecryptfs_encrypted_view mount option is specified by setting the
MS_RDONLY flag on the superblock. Additionally, this patch removes some
broken logic in ecryptfs_open() that attempted to prevent modifications
of files when the encrypted view feature was in use. The check in
ecryptfs_open() was not sufficient to prevent file modifications using
system calls that do not operate on a file descriptor.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Priya Bansal <p.bansal@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ecryptfs/file.c |   12 ------------
 fs/ecryptfs/main.c |   16 +++++++++++++---
 2 files changed, 13 insertions(+), 15 deletions(-)

--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -190,23 +190,11 @@ static int ecryptfs_open(struct inode *i
 {
 	int rc = 0;
 	struct ecryptfs_crypt_stat *crypt_stat = NULL;
-	struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
 	struct dentry *ecryptfs_dentry = file->f_path.dentry;
 	/* Private value of ecryptfs_dentry allocated in
 	 * ecryptfs_lookup() */
 	struct ecryptfs_file_info *file_info;
 
-	mount_crypt_stat = &ecryptfs_superblock_to_private(
-		ecryptfs_dentry->d_sb)->mount_crypt_stat;
-	if ((mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)
-	    && ((file->f_flags & O_WRONLY) || (file->f_flags & O_RDWR)
-		|| (file->f_flags & O_CREAT) || (file->f_flags & O_TRUNC)
-		|| (file->f_flags & O_APPEND))) {
-		printk(KERN_WARNING "Mount has encrypted view enabled; "
-		       "files may only be read\n");
-		rc = -EPERM;
-		goto out;
-	}
 	/* Released in ecryptfs_release or end of function if failure */
 	file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL);
 	ecryptfs_set_file_private(file, file_info);
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -493,6 +493,7 @@ static struct dentry *ecryptfs_mount(str
 {
 	struct super_block *s;
 	struct ecryptfs_sb_info *sbi;
+	struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
 	struct ecryptfs_dentry_info *root_info;
 	const char *err = "Getting sb failed";
 	struct inode *inode;
@@ -511,6 +512,7 @@ static struct dentry *ecryptfs_mount(str
 		err = "Error parsing options";
 		goto out;
 	}
+	mount_crypt_stat = &sbi->mount_crypt_stat;
 
 	s = sget(fs_type, NULL, set_anon_super, flags, NULL);
 	if (IS_ERR(s)) {
@@ -557,11 +559,19 @@ static struct dentry *ecryptfs_mount(str
 
 	/**
 	 * Set the POSIX ACL flag based on whether they're enabled in the lower
-	 * mount. Force a read-only eCryptfs mount if the lower mount is ro.
-	 * Allow a ro eCryptfs mount even when the lower mount is rw.
+	 * mount.
 	 */
 	s->s_flags = flags & ~MS_POSIXACL;
-	s->s_flags |= path.dentry->d_sb->s_flags & (MS_RDONLY | MS_POSIXACL);
+	s->s_flags |= path.dentry->d_sb->s_flags & MS_POSIXACL;
+
+	/**
+	 * Force a read-only eCryptfs mount when:
+	 *   1) The lower mount is ro
+	 *   2) The ecryptfs_encrypted_view mount option is specified
+	 */
+	if (path.dentry->d_sb->s_flags & MS_RDONLY ||
+	    mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)
+		s->s_flags |= MS_RDONLY;
 
 	s->s_maxbytes = path.dentry->d_sb->s_maxbytes;
 	s->s_blocksize = path.dentry->d_sb->s_blocksize;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 79/84] eCryptfs: Remove buggy and unnecessary write in file name decode routine
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (75 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 78/84] eCryptfs: Force RO mount when encrypted view is enabled Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 80/84] Btrfs: make sure we wait on logged extents when fsycning two subvols Greg Kroah-Hartman
                   ` (7 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Michael Halcrow, Dmitry Chernenkov,
	Kees Cook, Tyler Hicks

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

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

From: Michael Halcrow <mhalcrow@google.com>

commit 942080643bce061c3dd9d5718d3b745dcb39a8bc upstream.

Dmitry Chernenkov used KASAN to discover that eCryptfs writes past the
end of the allocated buffer during encrypted filename decoding. This
fix corrects the issue by getting rid of the unnecessary 0 write when
the current bit offset is 2.

Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Reported-by: Dmitry Chernenkov <dmitryc@google.com>
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ecryptfs/crypto.c |    1 -
 1 file changed, 1 deletion(-)

--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1917,7 +1917,6 @@ ecryptfs_decode_from_filename(unsigned c
 			break;
 		case 2:
 			dst[dst_byte_offset++] |= (src_byte);
-			dst[dst_byte_offset] = 0;
 			current_bit_offset = 0;
 			break;
 		}



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 80/84] Btrfs: make sure we wait on logged extents when fsycning two subvols
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (76 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 79/84] eCryptfs: Remove buggy and unnecessary write in file name decode routine Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 81/84] btrfs: fix wrong accounting of raid1 data profile in statfs Greg Kroah-Hartman
                   ` (6 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Josef Bacik, Chris Mason

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

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

From: Josef Bacik <jbacik@fb.com>

commit 9dba8cf128ef98257ca719722280c9634e7e9dc7 upstream.

If we have two fsync()'s race on different subvols one will do all of its work
to get into the log_tree, wait on it's outstanding IO, and then allow the
log_tree to finish it's commit.  The problem is we were just free'ing that
subvols logged extents instead of waiting on them, so whoever lost the race
wouldn't really have their data on disk.  Fix this by waiting properly instead
of freeing the logged extents.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/btrfs/tree-log.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2600,9 +2600,9 @@ int btrfs_sync_log(struct btrfs_trans_ha
 	if (atomic_read(&log_root_tree->log_commit[index2])) {
 		blk_finish_plug(&plug);
 		btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
+		btrfs_wait_logged_extents(log, log_transid);
 		wait_log_commit(trans, log_root_tree,
 				root_log_ctx.log_transid);
-		btrfs_free_logged_extents(log, log_transid);
 		mutex_unlock(&log_root_tree->log_mutex);
 		ret = root_log_ctx.log_ret;
 		goto out;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 81/84] btrfs: fix wrong accounting of raid1 data profile in statfs
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (77 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 80/84] Btrfs: make sure we wait on logged extents when fsycning two subvols Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 82/84] Btrfs: do not move em to modified list when unpinning Greg Kroah-Hartman
                   ` (5 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Martin Steigerwald, David Sterba,
	Chris Mason

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

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

From: David Sterba <dsterba@suse.cz>

commit 0d95c1bec906dd1ad951c9c001e798ca52baeb0f upstream.

The sizes that are obtained from space infos are in raw units and have
to be adjusted according to the raid factor. This was missing for
f_bavail and df reported doubled size for raid1.

Reported-by: Martin Steigerwald <Martin@lichtvoll.de>
Fixes: ba7b6e62f420 ("btrfs: adjust statfs calculations according to raid profiles")
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/btrfs/super.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1824,7 +1824,7 @@ static int btrfs_statfs(struct dentry *d
 	buf->f_bfree -= block_rsv->size >> bits;
 	spin_unlock(&block_rsv->lock);
 
-	buf->f_bavail = total_free_data;
+	buf->f_bavail = div_u64(total_free_data, factor);
 	ret = btrfs_calc_avail_data_space(fs_info->tree_root, &total_free_data);
 	if (ret) {
 		mutex_unlock(&fs_info->chunk_mutex);



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 82/84] Btrfs: do not move em to modified list when unpinning
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (78 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 81/84] btrfs: fix wrong accounting of raid1 data profile in statfs Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 83/84] Btrfs: make sure logged extents complete in the current transaction V3 Greg Kroah-Hartman
                   ` (4 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Josef Bacik, Chris Mason

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

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

From: Josef Bacik <jbacik@fb.com>

commit a28046956c71985046474283fa3bcd256915fb72 upstream.

We use the modified list to keep track of which extents have been modified so we
know which ones are candidates for logging at fsync() time.  Newly modified
extents are added to the list at modification time, around the same time the
ordered extent is created.  We do this so that we don't have to wait for ordered
extents to complete before we know what we need to log.  The problem is when
something like this happens

log extent 0-4k on inode 1
copy csum for 0-4k from ordered extent into log
sync log
commit transaction
log some other extent on inode 1
ordered extent for 0-4k completes and adds itself onto modified list again
log changed extents
see ordered extent for 0-4k has already been logged
	at this point we assume the csum has been copied
sync log
crash

On replay we will see the extent 0-4k in the log, drop the original 0-4k extent
which is the same one that we are replaying which also drops the csum, and then
we won't find the csum in the log for that bytenr.  This of course causes us to
have errors about not having csums for certain ranges of our inode.  So remove
the modified list manipulation in unpin_extent_cache, any modified extents
should have been added well before now, and we don't want them re-logged.  This
fixes my test that I could reliably reproduce this problem with.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/btrfs/extent_map.c |    2 --
 1 file changed, 2 deletions(-)

--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -287,8 +287,6 @@ int unpin_extent_cache(struct extent_map
 	if (!em)
 		goto out;
 
-	if (!test_bit(EXTENT_FLAG_LOGGING, &em->flags))
-		list_move(&em->list, &tree->modified_extents);
 	em->generation = gen;
 	clear_bit(EXTENT_FLAG_PINNED, &em->flags);
 	em->mod_start = em->start;



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 83/84] Btrfs: make sure logged extents complete in the current transaction V3
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (79 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 82/84] Btrfs: do not move em to modified list when unpinning Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07  1:50 ` [PATCH 3.18 84/84] Btrfs: fix fs corruption on transaction abort if device supports discard Greg Kroah-Hartman
                   ` (3 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Josef Bacik, Chris Mason

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

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

From: Josef Bacik <jbacik@fb.com>

commit 50d9aa99bd35c77200e0e3dd7a72274f8304701f upstream.

Liu Bo pointed out that my previous fix would lose the generation update in the
scenario I described.  It is actually much worse than that, we could lose the
entire extent if we lose power right after the transaction commits.  Consider
the following

write extent 0-4k
log extent in log tree
commit transaction
	< power fail happens here
ordered extent completes

We would lose the 0-4k extent because it hasn't updated the actual fs tree, and
the transaction commit will reset the log so it isn't replayed.  If we lose
power before the transaction commit we are save, otherwise we are not.

Fix this by keeping track of all extents we logged in this transaction.  Then
when we go to commit the transaction make sure we wait for all of those ordered
extents to complete before proceeding.  This will make sure that if we lose
power after the transaction commit we still have our data.  This also fixes the
problem of the improperly updated extent generation.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/btrfs/disk-io.c      |   20 ++++++++++++++++++++
 fs/btrfs/ordered-data.c |    9 +++++++--
 fs/btrfs/ordered-data.h |    8 +++++++-
 fs/btrfs/transaction.c  |   33 +++++++++++++++++++++++++++++++++
 fs/btrfs/transaction.h  |    2 ++
 fs/btrfs/tree-log.c     |    6 +++---
 6 files changed, 72 insertions(+), 6 deletions(-)

--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4129,6 +4129,25 @@ again:
 	return 0;
 }
 
+static void btrfs_free_pending_ordered(struct btrfs_transaction *cur_trans,
+				       struct btrfs_fs_info *fs_info)
+{
+	struct btrfs_ordered_extent *ordered;
+
+	spin_lock(&fs_info->trans_lock);
+	while (!list_empty(&cur_trans->pending_ordered)) {
+		ordered = list_first_entry(&cur_trans->pending_ordered,
+					   struct btrfs_ordered_extent,
+					   trans_list);
+		list_del_init(&ordered->trans_list);
+		spin_unlock(&fs_info->trans_lock);
+
+		btrfs_put_ordered_extent(ordered);
+		spin_lock(&fs_info->trans_lock);
+	}
+	spin_unlock(&fs_info->trans_lock);
+}
+
 void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
 				   struct btrfs_root *root)
 {
@@ -4140,6 +4159,7 @@ void btrfs_cleanup_one_transaction(struc
 	cur_trans->state = TRANS_STATE_UNBLOCKED;
 	wake_up(&root->fs_info->transaction_wait);
 
+	btrfs_free_pending_ordered(cur_trans, root->fs_info);
 	btrfs_destroy_delayed_inodes(root);
 	btrfs_assert_delayed_root_empty(root);
 
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -220,6 +220,7 @@ static int __btrfs_add_ordered_extent(st
 	INIT_LIST_HEAD(&entry->work_list);
 	init_completion(&entry->completion);
 	INIT_LIST_HEAD(&entry->log_list);
+	INIT_LIST_HEAD(&entry->trans_list);
 
 	trace_btrfs_ordered_extent_add(inode, entry);
 
@@ -443,6 +444,8 @@ void btrfs_get_logged_extents(struct ino
 		ordered = rb_entry(n, struct btrfs_ordered_extent, rb_node);
 		if (!list_empty(&ordered->log_list))
 			continue;
+		if (test_bit(BTRFS_ORDERED_LOGGED, &ordered->flags))
+			continue;
 		list_add_tail(&ordered->log_list, logged_list);
 		atomic_inc(&ordered->refs);
 	}
@@ -472,7 +475,8 @@ void btrfs_submit_logged_extents(struct
 	spin_unlock_irq(&log->log_extents_lock[index]);
 }
 
-void btrfs_wait_logged_extents(struct btrfs_root *log, u64 transid)
+void btrfs_wait_logged_extents(struct btrfs_trans_handle *trans,
+			       struct btrfs_root *log, u64 transid)
 {
 	struct btrfs_ordered_extent *ordered;
 	int index = transid % 2;
@@ -497,7 +501,8 @@ void btrfs_wait_logged_extents(struct bt
 		wait_event(ordered->wait, test_bit(BTRFS_ORDERED_IO_DONE,
 						   &ordered->flags));
 
-		btrfs_put_ordered_extent(ordered);
+		if (!test_and_set_bit(BTRFS_ORDERED_LOGGED, &ordered->flags))
+			list_add_tail(&ordered->trans_list, &trans->ordered);
 		spin_lock_irq(&log->log_extents_lock[index]);
 	}
 	spin_unlock_irq(&log->log_extents_lock[index]);
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -71,6 +71,8 @@ struct btrfs_ordered_sum {
 				       ordered extent */
 #define BTRFS_ORDERED_TRUNCATED 9 /* Set when we have to truncate an extent */
 
+#define BTRFS_ORDERED_LOGGED 10 /* Set when we've waited on this ordered extent
+				 * in the logging code. */
 struct btrfs_ordered_extent {
 	/* logical offset in the file */
 	u64 file_offset;
@@ -121,6 +123,9 @@ struct btrfs_ordered_extent {
 	/* If we need to wait on this to be done */
 	struct list_head log_list;
 
+	/* If the transaction needs to wait on this ordered extent */
+	struct list_head trans_list;
+
 	/* used to wait for the BTRFS_ORDERED_COMPLETE bit */
 	wait_queue_head_t wait;
 
@@ -197,7 +202,8 @@ void btrfs_get_logged_extents(struct ino
 void btrfs_put_logged_extents(struct list_head *logged_list);
 void btrfs_submit_logged_extents(struct list_head *logged_list,
 				 struct btrfs_root *log);
-void btrfs_wait_logged_extents(struct btrfs_root *log, u64 transid);
+void btrfs_wait_logged_extents(struct btrfs_trans_handle *trans,
+			       struct btrfs_root *log, u64 transid);
 void btrfs_free_logged_extents(struct btrfs_root *log, u64 transid);
 int __init ordered_data_init(void);
 void ordered_data_exit(void);
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -220,6 +220,7 @@ loop:
 	INIT_LIST_HEAD(&cur_trans->pending_snapshots);
 	INIT_LIST_HEAD(&cur_trans->pending_chunks);
 	INIT_LIST_HEAD(&cur_trans->switch_commits);
+	INIT_LIST_HEAD(&cur_trans->pending_ordered);
 	list_add_tail(&cur_trans->list, &fs_info->trans_list);
 	extent_io_tree_init(&cur_trans->dirty_pages,
 			     fs_info->btree_inode->i_mapping);
@@ -488,6 +489,7 @@ again:
 	h->sync = false;
 	INIT_LIST_HEAD(&h->qgroup_ref_list);
 	INIT_LIST_HEAD(&h->new_bgs);
+	INIT_LIST_HEAD(&h->ordered);
 
 	smp_mb();
 	if (cur_trans->state >= TRANS_STATE_BLOCKED &&
@@ -719,6 +721,12 @@ static int __btrfs_end_transaction(struc
 	if (!list_empty(&trans->new_bgs))
 		btrfs_create_pending_block_groups(trans, root);
 
+	if (!list_empty(&trans->ordered)) {
+		spin_lock(&info->trans_lock);
+		list_splice(&trans->ordered, &cur_trans->pending_ordered);
+		spin_unlock(&info->trans_lock);
+	}
+
 	trans->delayed_ref_updates = 0;
 	if (!trans->sync) {
 		must_run_delayed_refs =
@@ -1652,6 +1660,28 @@ static inline void btrfs_wait_delalloc_f
 		btrfs_wait_ordered_roots(fs_info, -1);
 }
 
+static inline void
+btrfs_wait_pending_ordered(struct btrfs_transaction *cur_trans,
+			   struct btrfs_fs_info *fs_info)
+{
+	struct btrfs_ordered_extent *ordered;
+
+	spin_lock(&fs_info->trans_lock);
+	while (!list_empty(&cur_trans->pending_ordered)) {
+		ordered = list_first_entry(&cur_trans->pending_ordered,
+					   struct btrfs_ordered_extent,
+					   trans_list);
+		list_del_init(&ordered->trans_list);
+		spin_unlock(&fs_info->trans_lock);
+
+		wait_event(ordered->wait, test_bit(BTRFS_ORDERED_COMPLETE,
+						   &ordered->flags));
+		btrfs_put_ordered_extent(ordered);
+		spin_lock(&fs_info->trans_lock);
+	}
+	spin_unlock(&fs_info->trans_lock);
+}
+
 int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
 			     struct btrfs_root *root)
 {
@@ -1702,6 +1732,7 @@ int btrfs_commit_transaction(struct btrf
 	}
 
 	spin_lock(&root->fs_info->trans_lock);
+	list_splice(&trans->ordered, &cur_trans->pending_ordered);
 	if (cur_trans->state >= TRANS_STATE_COMMIT_START) {
 		spin_unlock(&root->fs_info->trans_lock);
 		atomic_inc(&cur_trans->use_count);
@@ -1754,6 +1785,8 @@ int btrfs_commit_transaction(struct btrf
 
 	btrfs_wait_delalloc_flush(root->fs_info);
 
+	btrfs_wait_pending_ordered(cur_trans, root->fs_info);
+
 	btrfs_scrub_pause(root);
 	/*
 	 * Ok now we need to make sure to block out any other joins while we
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -56,6 +56,7 @@ struct btrfs_transaction {
 	wait_queue_head_t commit_wait;
 	struct list_head pending_snapshots;
 	struct list_head pending_chunks;
+	struct list_head pending_ordered;
 	struct list_head switch_commits;
 	struct btrfs_delayed_ref_root delayed_refs;
 	int aborted;
@@ -105,6 +106,7 @@ struct btrfs_trans_handle {
 	 */
 	struct btrfs_root *root;
 	struct seq_list delayed_ref_elem;
+	struct list_head ordered;
 	struct list_head qgroup_ref_list;
 	struct list_head new_bgs;
 };
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2600,7 +2600,7 @@ int btrfs_sync_log(struct btrfs_trans_ha
 	if (atomic_read(&log_root_tree->log_commit[index2])) {
 		blk_finish_plug(&plug);
 		btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
-		btrfs_wait_logged_extents(log, log_transid);
+		btrfs_wait_logged_extents(trans, log, log_transid);
 		wait_log_commit(trans, log_root_tree,
 				root_log_ctx.log_transid);
 		mutex_unlock(&log_root_tree->log_mutex);
@@ -2645,7 +2645,7 @@ int btrfs_sync_log(struct btrfs_trans_ha
 	btrfs_wait_marked_extents(log_root_tree,
 				  &log_root_tree->dirty_log_pages,
 				  EXTENT_NEW | EXTENT_DIRTY);
-	btrfs_wait_logged_extents(log, log_transid);
+	btrfs_wait_logged_extents(trans, log, log_transid);
 
 	btrfs_set_super_log_root(root->fs_info->super_for_commit,
 				log_root_tree->node->start);
@@ -3766,7 +3766,7 @@ static int log_one_extent(struct btrfs_t
 	fi = btrfs_item_ptr(leaf, path->slots[0],
 			    struct btrfs_file_extent_item);
 
-	btrfs_set_token_file_extent_generation(leaf, fi, em->generation,
+	btrfs_set_token_file_extent_generation(leaf, fi, trans->transid,
 					       &token);
 	if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags))
 		btrfs_set_token_file_extent_type(leaf, fi,



^ permalink raw reply	[flat|nested] 90+ messages in thread

* [PATCH 3.18 84/84] Btrfs: fix fs corruption on transaction abort if device supports discard
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (80 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 83/84] Btrfs: make sure logged extents complete in the current transaction V3 Greg Kroah-Hartman
@ 2015-01-07  1:50 ` Greg Kroah-Hartman
  2015-01-07 13:47 ` [PATCH 3.18 00/84] 3.18.2-stable review Guenter Roeck
                   ` (2 subsequent siblings)
  84 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Filipe Manana, Chris Mason

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

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

From: Filipe Manana <fdmanana@suse.com>

commit 678886bdc6378c1cbd5072da2c5a3035000214e3 upstream.

When we abort a transaction we iterate over all the ranges marked as dirty
in fs_info->freed_extents[0] and fs_info->freed_extents[1], clear them
from those trees, add them back (unpin) to the free space caches and, if
the fs was mounted with "-o discard", perform a discard on those regions.
Also, after adding the regions to the free space caches, a fitrim ioctl call
can see those ranges in a block group's free space cache and perform a discard
on the ranges, so the same issue can happen without "-o discard" as well.

This causes corruption, affecting one or multiple btree nodes (in the worst
case leaving the fs unmountable) because some of those ranges (the ones in
the fs_info->pinned_extents tree) correspond to btree nodes/leafs that are
referred by the last committed super block - breaking the rule that anything
that was committed by a transaction is untouched until the next transaction
commits successfully.

I ran into this while running in a loop (for several hours) the fstest that
I recently submitted:

  [PATCH] fstests: add btrfs test to stress chunk allocation/removal and fstrim

The corruption always happened when a transaction aborted and then fsck complained
like this:

   _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent
   *** fsck.btrfs output ***
   Check tree block failed, want=94945280, have=0
   Check tree block failed, want=94945280, have=0
   Check tree block failed, want=94945280, have=0
   Check tree block failed, want=94945280, have=0
   Check tree block failed, want=94945280, have=0
   read block failed check_tree_block
   Couldn't open file system

In this case 94945280 corresponded to the root of a tree.
Using frace what I observed was the following sequence of steps happened:

   1) transaction N started, fs_info->pinned_extents pointed to
      fs_info->freed_extents[0];

   2) node/eb 94945280 is created;

   3) eb is persisted to disk;

   4) transaction N commit starts, fs_info->pinned_extents now points to
      fs_info->freed_extents[1], and transaction N completes;

   5) transaction N + 1 starts;

   6) eb is COWed, and btrfs_free_tree_block() called for this eb;

   7) eb range (94945280 to 94945280 + 16Kb) is added to
      fs_info->pinned_extents (fs_info->freed_extents[1]);

   8) Something goes wrong in transaction N + 1, like hitting ENOSPC
      for example, and the transaction is aborted, turning the fs into
      readonly mode. The stack trace I got for example:

      [112065.253935]  [<ffffffff8140c7b6>] dump_stack+0x4d/0x66
      [112065.254271]  [<ffffffff81042984>] warn_slowpath_common+0x7f/0x98
      [112065.254567]  [<ffffffffa0325990>] ? __btrfs_abort_transaction+0x50/0x10b [btrfs]
      [112065.261674]  [<ffffffff810429e5>] warn_slowpath_fmt+0x48/0x50
      [112065.261922]  [<ffffffffa032949e>] ? btrfs_free_path+0x26/0x29 [btrfs]
      [112065.262211]  [<ffffffffa0325990>] __btrfs_abort_transaction+0x50/0x10b [btrfs]
      [112065.262545]  [<ffffffffa036b1d6>] btrfs_remove_chunk+0x537/0x58b [btrfs]
      [112065.262771]  [<ffffffffa033840f>] btrfs_delete_unused_bgs+0x1de/0x21b [btrfs]
      [112065.263105]  [<ffffffffa0343106>] cleaner_kthread+0x100/0x12f [btrfs]
      (...)
      [112065.264493] ---[ end trace dd7903a975a31a08 ]---
      [112065.264673] BTRFS: error (device sdc) in btrfs_remove_chunk:2625: errno=-28 No space left
      [112065.264997] BTRFS info (device sdc): forced readonly

   9) The clear kthread sees that the BTRFS_FS_STATE_ERROR bit is set in
      fs_info->fs_state and calls btrfs_cleanup_transaction(), which in
      turn calls btrfs_destroy_pinned_extent();

   10) Then btrfs_destroy_pinned_extent() iterates over all the ranges
       marked as dirty in fs_info->freed_extents[], and for each one
       it calls discard, if the fs was mounted with "-o discard", and
       adds the range to the free space cache of the respective block
       group;

   11) btrfs_trim_block_group(), invoked from the fitrim ioctl code path,
       sees the free space entries and performs a discard;

   12) After an umount and mount (or fsck), our eb's location on disk was full
       of zeroes, and it should have been untouched, because it was marked as
       dirty in the fs_info->pinned_extents tree, and therefore used by the
       trees that the last committed superblock points to.

Fix this by not performing a discard and not adding the ranges to the free space
caches - it's useless from this point since the fs is now in readonly mode and
we won't write free space caches to disk anymore (otherwise we would leak space)
nor any new superblock. By not adding the ranges to the free space caches, it
prevents other code paths from allocating that space and write to it as well,
therefore being safer and simpler.

This isn't a new problem, as it's been present since 2011 (git commit
acce952b0263825da32cf10489413dec78053347).

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/btrfs/disk-io.c     |    6 ------
 fs/btrfs/extent-tree.c |   10 ++++++----
 2 files changed, 6 insertions(+), 10 deletions(-)

--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4106,12 +4106,6 @@ again:
 		if (ret)
 			break;
 
-		/* opt_discard */
-		if (btrfs_test_opt(root, DISCARD))
-			ret = btrfs_error_discard_extent(root, start,
-							 end + 1 - start,
-							 NULL);
-
 		clear_extent_dirty(unpin, start, end, GFP_NOFS);
 		btrfs_error_unpin_extent_range(root, start, end);
 		cond_resched();
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5715,7 +5715,8 @@ void btrfs_prepare_extent_commit(struct
 	update_global_block_rsv(fs_info);
 }
 
-static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end)
+static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end,
+			      const bool return_free_space)
 {
 	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct btrfs_block_group_cache *cache = NULL;
@@ -5739,7 +5740,8 @@ static int unpin_extent_range(struct btr
 
 		if (start < cache->last_byte_to_unpin) {
 			len = min(len, cache->last_byte_to_unpin - start);
-			btrfs_add_free_space(cache, start, len);
+			if (return_free_space)
+				btrfs_add_free_space(cache, start, len);
 		}
 
 		start += len;
@@ -5803,7 +5805,7 @@ int btrfs_finish_extent_commit(struct bt
 						   end + 1 - start, NULL);
 
 		clear_extent_dirty(unpin, start, end, GFP_NOFS);
-		unpin_extent_range(root, start, end);
+		unpin_extent_range(root, start, end, true);
 		cond_resched();
 	}
 
@@ -9585,7 +9587,7 @@ out:
 
 int btrfs_error_unpin_extent_range(struct btrfs_root *root, u64 start, u64 end)
 {
-	return unpin_extent_range(root, start, end);
+	return unpin_extent_range(root, start, end, false);
 }
 
 int btrfs_error_discard_extent(struct btrfs_root *root, u64 bytenr,



^ permalink raw reply	[flat|nested] 90+ messages in thread

* Re: [PATCH 3.18 00/84] 3.18.2-stable review
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (81 preceding siblings ...)
  2015-01-07  1:50 ` [PATCH 3.18 84/84] Btrfs: fix fs corruption on transaction abort if device supports discard Greg Kroah-Hartman
@ 2015-01-07 13:47 ` Guenter Roeck
  2015-01-07 23:33 ` Shuah Khan
  2015-01-08 10:20 ` Satoru Takeuchi
  84 siblings, 0 replies; 90+ messages in thread
From: Guenter Roeck @ 2015-01-07 13:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, satoru.takeuchi, shuah.kh, stable

On 01/06/2015 05:49 PM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 3.18.2 release.
> There are 84 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>
> Responses should be made by Fri Jan  9 01:40:07 UTC 2015.
> Anything received after that time might be too late.
>

Build results:
	total: 133 pass: 133 fail: 0
Qemu tests:
	total: 30 pass: 30 fail: 0

Details are available at http://server.roeck-us.net:8010/builders.

Guenter


^ permalink raw reply	[flat|nested] 90+ messages in thread

* Re: [PATCH 3.18 04/84] x86_64, switch_to(): Load TLS descriptors before switching DS and ES
  2015-01-07  1:49 ` [PATCH 3.18 04/84] x86_64, switch_to(): Load TLS descriptors before switching DS and ES Greg Kroah-Hartman
@ 2015-01-07 15:26   ` Jiri Slaby
  2015-01-08  1:27     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 90+ messages in thread
From: Jiri Slaby @ 2015-01-07 15:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: stable, Andy Lutomirski, Andi Kleen, Linus Torvalds, Ingo Molnar

On 01/07/2015, 02:49 AM, Greg Kroah-Hartman wrote:
> 3.18-stable review patch.  If anyone has any objections, please let me know.

Greg, Andi raised an objection against this one for 3.12 which still
holds here and for other trees:
https://www.mail-archive.com/stable@vger.kernel.org/msg106471.html

Quoting:
On 01/06/2015, 07:53 PM, Andi Kleen wrote:
> IMHO this is not stable material. Significant risk you broke
> something obscure, and it's not clear it fixes any real problem.
>
> At least wait some more time first.

Thanks.

> ------------------
> 
> From: Andy Lutomirski <luto@amacapital.net>
> 
> commit f647d7c155f069c1a068030255c300663516420e upstream.
> 
> Otherwise, if buggy user code points DS or ES into the TLS
> array, they would be corrupted after a context switch.
> 
> This also significantly improves the comments and documents some
> gotchas in the code.
> 
> Before this patch, the both tests below failed.  With this
> patch, the es test passes, although the gsbase test still fails.
> 
>  ----- begin es test -----
> 
> /*
>  * Copyright (c) 2014 Andy Lutomirski
>  * GPL v2
>  */
> 
> static unsigned short GDT3(int idx)
> {
> 	return (idx << 3) | 3;
> }
> 
> static int create_tls(int idx, unsigned int base)
> {
> 	struct user_desc desc = {
> 		.entry_number    = idx,
> 		.base_addr       = base,
> 		.limit           = 0xfffff,
> 		.seg_32bit       = 1,
> 		.contents        = 0, /* Data, grow-up */
> 		.read_exec_only  = 0,
> 		.limit_in_pages  = 1,
> 		.seg_not_present = 0,
> 		.useable         = 0,
> 	};
> 
> 	if (syscall(SYS_set_thread_area, &desc) != 0)
> 		err(1, "set_thread_area");
> 
> 	return desc.entry_number;
> }
> 
> int main()
> {
> 	int idx = create_tls(-1, 0);
> 	printf("Allocated GDT index %d\n", idx);
> 
> 	unsigned short orig_es;
> 	asm volatile ("mov %%es,%0" : "=rm" (orig_es));
> 
> 	int errors = 0;
> 	int total = 1000;
> 	for (int i = 0; i < total; i++) {
> 		asm volatile ("mov %0,%%es" : : "rm" (GDT3(idx)));
> 		usleep(100);
> 
> 		unsigned short es;
> 		asm volatile ("mov %%es,%0" : "=rm" (es));
> 		asm volatile ("mov %0,%%es" : : "rm" (orig_es));
> 		if (es != GDT3(idx)) {
> 			if (errors == 0)
> 				printf("[FAIL]\tES changed from 0x%hx to 0x%hx\n",
> 				       GDT3(idx), es);
> 			errors++;
> 		}
> 	}
> 
> 	if (errors) {
> 		printf("[FAIL]\tES was corrupted %d/%d times\n", errors, total);
> 		return 1;
> 	} else {
> 		printf("[OK]\tES was preserved\n");
> 		return 0;
> 	}
> }
> 
>  ----- end es test -----
> 
>  ----- begin gsbase test -----
> 
> /*
>  * gsbase.c, a gsbase test
>  * Copyright (c) 2014 Andy Lutomirski
>  * GPL v2
>  */
> 
> static unsigned char *testptr, *testptr2;
> 
> static unsigned char read_gs_testvals(void)
> {
> 	unsigned char ret;
> 	asm volatile ("movb %%gs:%1, %0" : "=r" (ret) : "m" (*testptr));
> 	return ret;
> }
> 
> int main()
> {
> 	int errors = 0;
> 
> 	testptr = mmap((void *)0x200000000UL, 1, PROT_READ | PROT_WRITE,
> 		       MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
> 	if (testptr == MAP_FAILED)
> 		err(1, "mmap");
> 
> 	testptr2 = mmap((void *)0x300000000UL, 1, PROT_READ | PROT_WRITE,
> 		       MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
> 	if (testptr2 == MAP_FAILED)
> 		err(1, "mmap");
> 
> 	*testptr = 0;
> 	*testptr2 = 1;
> 
> 	if (syscall(SYS_arch_prctl, ARCH_SET_GS,
> 		    (unsigned long)testptr2 - (unsigned long)testptr) != 0)
> 		err(1, "ARCH_SET_GS");
> 
> 	usleep(100);
> 
> 	if (read_gs_testvals() == 1) {
> 		printf("[OK]\tARCH_SET_GS worked\n");
> 	} else {
> 		printf("[FAIL]\tARCH_SET_GS failed\n");
> 		errors++;
> 	}
> 
> 	asm volatile ("mov %0,%%gs" : : "r" (0));
> 
> 	if (read_gs_testvals() == 0) {
> 		printf("[OK]\tWriting 0 to gs worked\n");
> 	} else {
> 		printf("[FAIL]\tWriting 0 to gs failed\n");
> 		errors++;
> 	}
> 
> 	usleep(100);
> 
> 	if (read_gs_testvals() == 0) {
> 		printf("[OK]\tgsbase is still zero\n");
> 	} else {
> 		printf("[FAIL]\tgsbase was corrupted\n");
> 		errors++;
> 	}
> 
> 	return errors == 0 ? 0 : 1;
> }
> 
>  ----- end gsbase test -----
> 
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> Cc: Andi Kleen <andi@firstfloor.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Link: http://lkml.kernel.org/r/509d27c9fec78217691c3dad91cec87e1006b34a.1418075657.git.luto@amacapital.net
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> ---
>  arch/x86/kernel/process_64.c |  101 +++++++++++++++++++++++++++++++------------
>  1 file changed, 73 insertions(+), 28 deletions(-)
> 
> --- a/arch/x86/kernel/process_64.c
> +++ b/arch/x86/kernel/process_64.c
> @@ -283,24 +283,9 @@ __switch_to(struct task_struct *prev_p,
>  
>  	fpu = switch_fpu_prepare(prev_p, next_p, cpu);
>  
> -	/*
> -	 * Reload esp0, LDT and the page table pointer:
> -	 */
> +	/* Reload esp0 and ss1. */
>  	load_sp0(tss, next);
>  
> -	/*
> -	 * Switch DS and ES.
> -	 * This won't pick up thread selector changes, but I guess that is ok.
> -	 */
> -	savesegment(es, prev->es);
> -	if (unlikely(next->es | prev->es))
> -		loadsegment(es, next->es);
> -
> -	savesegment(ds, prev->ds);
> -	if (unlikely(next->ds | prev->ds))
> -		loadsegment(ds, next->ds);
> -
> -
>  	/* We must save %fs and %gs before load_TLS() because
>  	 * %fs and %gs may be cleared by load_TLS().
>  	 *
> @@ -309,41 +294,101 @@ __switch_to(struct task_struct *prev_p,
>  	savesegment(fs, fsindex);
>  	savesegment(gs, gsindex);
>  
> +	/*
> +	 * Load TLS before restoring any segments so that segment loads
> +	 * reference the correct GDT entries.
> +	 */
>  	load_TLS(next, cpu);
>  
>  	/*
> -	 * Leave lazy mode, flushing any hypercalls made here.
> -	 * This must be done before restoring TLS segments so
> -	 * the GDT and LDT are properly updated, and must be
> -	 * done before math_state_restore, so the TS bit is up
> -	 * to date.
> +	 * Leave lazy mode, flushing any hypercalls made here.  This
> +	 * must be done after loading TLS entries in the GDT but before
> +	 * loading segments that might reference them, and and it must
> +	 * be done before math_state_restore, so the TS bit is up to
> +	 * date.
>  	 */
>  	arch_end_context_switch(next_p);
>  
> +	/* Switch DS and ES.
> +	 *
> +	 * Reading them only returns the selectors, but writing them (if
> +	 * nonzero) loads the full descriptor from the GDT or LDT.  The
> +	 * LDT for next is loaded in switch_mm, and the GDT is loaded
> +	 * above.
> +	 *
> +	 * We therefore need to write new values to the segment
> +	 * registers on every context switch unless both the new and old
> +	 * values are zero.
> +	 *
> +	 * Note that we don't need to do anything for CS and SS, as
> +	 * those are saved and restored as part of pt_regs.
> +	 */
> +	savesegment(es, prev->es);
> +	if (unlikely(next->es | prev->es))
> +		loadsegment(es, next->es);
> +
> +	savesegment(ds, prev->ds);
> +	if (unlikely(next->ds | prev->ds))
> +		loadsegment(ds, next->ds);
> +
>  	/*
>  	 * Switch FS and GS.
>  	 *
> -	 * Segment register != 0 always requires a reload.  Also
> -	 * reload when it has changed.  When prev process used 64bit
> -	 * base always reload to avoid an information leak.
> +	 * These are even more complicated than FS and GS: they have
> +	 * 64-bit bases are that controlled by arch_prctl.  Those bases
> +	 * only differ from the values in the GDT or LDT if the selector
> +	 * is 0.
> +	 *
> +	 * Loading the segment register resets the hidden base part of
> +	 * the register to 0 or the value from the GDT / LDT.  If the
> +	 * next base address zero, writing 0 to the segment register is
> +	 * much faster than using wrmsr to explicitly zero the base.
> +	 *
> +	 * The thread_struct.fs and thread_struct.gs values are 0
> +	 * if the fs and gs bases respectively are not overridden
> +	 * from the values implied by fsindex and gsindex.  They
> +	 * are nonzero, and store the nonzero base addresses, if
> +	 * the bases are overridden.
> +	 *
> +	 * (fs != 0 && fsindex != 0) || (gs != 0 && gsindex != 0) should
> +	 * be impossible.
> +	 *
> +	 * Therefore we need to reload the segment registers if either
> +	 * the old or new selector is nonzero, and we need to override
> +	 * the base address if next thread expects it to be overridden.
> +	 *
> +	 * This code is unnecessarily slow in the case where the old and
> +	 * new indexes are zero and the new base is nonzero -- it will
> +	 * unnecessarily write 0 to the selector before writing the new
> +	 * base address.
> +	 *
> +	 * Note: This all depends on arch_prctl being the only way that
> +	 * user code can override the segment base.  Once wrfsbase and
> +	 * wrgsbase are enabled, most of this code will need to change.
>  	 */
>  	if (unlikely(fsindex | next->fsindex | prev->fs)) {
>  		loadsegment(fs, next->fsindex);
> +
>  		/*
> -		 * Check if the user used a selector != 0; if yes
> -		 *  clear 64bit base, since overloaded base is always
> -		 *  mapped to the Null selector
> +		 * If user code wrote a nonzero value to FS, then it also
> +		 * cleared the overridden base address.
> +		 *
> +		 * XXX: if user code wrote 0 to FS and cleared the base
> +		 * address itself, we won't notice and we'll incorrectly
> +		 * restore the prior base address next time we reschdule
> +		 * the process.
>  		 */
>  		if (fsindex)
>  			prev->fs = 0;
>  	}
> -	/* when next process has a 64bit base use it */
>  	if (next->fs)
>  		wrmsrl(MSR_FS_BASE, next->fs);
>  	prev->fsindex = fsindex;
>  
>  	if (unlikely(gsindex | next->gsindex | prev->gs)) {
>  		load_gs_index(next->gsindex);
> +
> +		/* This works (and fails) the same way as fsindex above. */
>  		if (gsindex)
>  			prev->gs = 0;
>  	}
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
js
suse labs

^ permalink raw reply	[flat|nested] 90+ messages in thread

* Re: [PATCH 3.18 00/84] 3.18.2-stable review
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (82 preceding siblings ...)
  2015-01-07 13:47 ` [PATCH 3.18 00/84] 3.18.2-stable review Guenter Roeck
@ 2015-01-07 23:33 ` Shuah Khan
  2015-01-07 23:45   ` Greg Kroah-Hartman
  2015-01-08 10:20 ` Satoru Takeuchi
  84 siblings, 1 reply; 90+ messages in thread
From: Shuah Khan @ 2015-01-07 23:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, linux, satoru.takeuchi, shuah.kh, stable

On 01/06/2015 06:49 PM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 3.18.2 release.
> There are 84 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri Jan  9 01:40:07 UTC 2015.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
> 	kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.18.2-rc1.gz
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted on my test system. No dmesg regressions.

-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 90+ messages in thread

* Re: [PATCH 3.18 00/84] 3.18.2-stable review
  2015-01-07 23:33 ` Shuah Khan
@ 2015-01-07 23:45   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-07 23:45 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-kernel, torvalds, akpm, linux, satoru.takeuchi, shuah.kh, stable

On Wed, Jan 07, 2015 at 04:33:13PM -0700, Shuah Khan wrote:
> On 01/06/2015 06:49 PM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 3.18.2 release.
> > There are 84 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Fri Jan  9 01:40:07 UTC 2015.
> > Anything received after that time might be too late.
> > 
> > The whole patch series can be found in one patch at:
> > 	kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.18.2-rc1.gz
> > and the diffstat can be found below.
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> Compiled and booted on my test system. No dmesg regressions.

Thanks for testing all 4 of these and letting me know.

greg k-h

^ permalink raw reply	[flat|nested] 90+ messages in thread

* Re: [PATCH 3.18 04/84] x86_64, switch_to(): Load TLS descriptors before switching DS and ES
  2015-01-07 15:26   ` Jiri Slaby
@ 2015-01-08  1:27     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-08  1:27 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: linux-kernel, stable, Andy Lutomirski, Andi Kleen,
	Linus Torvalds, Ingo Molnar

On Wed, Jan 07, 2015 at 04:26:37PM +0100, Jiri Slaby wrote:
> On 01/07/2015, 02:49 AM, Greg Kroah-Hartman wrote:
> > 3.18-stable review patch.  If anyone has any objections, please let me know.
> 
> Greg, Andi raised an objection against this one for 3.12 which still
> holds here and for other trees:
> https://www.mail-archive.com/stable@vger.kernel.org/msg106471.html
> 
> Quoting:
> On 01/06/2015, 07:53 PM, Andi Kleen wrote:
> > IMHO this is not stable material. Significant risk you broke
> > something obscure, and it's not clear it fixes any real problem.
> >
> > At least wait some more time first.
> 
> Thanks.

I've now responded to that thread, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 90+ messages in thread

* Re: [PATCH 3.18 00/84] 3.18.2-stable review
  2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
                   ` (83 preceding siblings ...)
  2015-01-07 23:33 ` Shuah Khan
@ 2015-01-08 10:20 ` Satoru Takeuchi
  2015-01-08 16:33   ` Greg Kroah-Hartman
  84 siblings, 1 reply; 90+ messages in thread
From: Satoru Takeuchi @ 2015-01-08 10:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, torvalds, akpm, linux, satoru.takeuchi, shuah.kh, stable

At Tue,  6 Jan 2015 17:49:03 -0800,
Greg Kroah-Hartman wrote:
> 
> This is the start of the stable review cycle for the 3.18.2 release.
> There are 84 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri Jan  9 01:40:07 UTC 2015.
> Anything received after that time might be too late.

All 3.10.64-rc1, 3.14.28-rc1, 3.17.8-rc1, and 3.18.2-rc1 passed my test.

 - Test Cases:
   - Build this kernel.
   - Boot this kernel.
   - Build the latest mainline kernel with this kernel.

 - Test Tool:
   https://github.com/satoru-takeuchi/test-linux-stable

 - Test Result (kernel .config, ktest config and test log):
   http://satoru-takeuchi.org/test-linux-stable/results/<version>-<test datetime>.tar.xz

 - Build Environment:
   - OS: Debian Jessy x86_64
   - CPU: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz x 4
   - memory: 8GB

 - Test Target Environment:
   - Debian Jessy x86_64 (KVM guest on the Build Environment)
   - # of vCPU: 2
   - memory: 2GB

Thanks,
Satoru

> 
> The whole patch series can be found in one patch at:
> 	kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.18.2-rc1.gz
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 
> -------------
> Pseudo-Shortlog of commits:
> 
> Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>     Linux 3.18.2-rc1
> 
> Filipe Manana <fdmanana@suse.com>
>     Btrfs: fix fs corruption on transaction abort if device supports discard
> 
> Josef Bacik <jbacik@fb.com>
>     Btrfs: make sure logged extents complete in the current transaction V3
> 
> Josef Bacik <jbacik@fb.com>
>     Btrfs: do not move em to modified list when unpinning
> 
> David Sterba <dsterba@suse.cz>
>     btrfs: fix wrong accounting of raid1 data profile in statfs
> 
> Josef Bacik <jbacik@fb.com>
>     Btrfs: make sure we wait on logged extents when fsycning two subvols
> 
> Michael Halcrow <mhalcrow@google.com>
>     eCryptfs: Remove buggy and unnecessary write in file name decode routine
> 
> Tyler Hicks <tyhicks@canonical.com>
>     eCryptfs: Force RO mount when encrypted view is enabled
> 
> Jan Kara <jack@suse.cz>
>     udf: Check component length before reading it
> 
> Jan Kara <jack@suse.cz>
>     udf: Verify symlink size before loading it
> 
> Jan Kara <jack@suse.cz>
>     udf: Verify i_size when loading inode
> 
> Jan Kara <jack@suse.cz>
>     udf: Check path length when reading symlink
> 
> Oleg Nesterov <oleg@redhat.com>
>     exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting
> 
> Joonsoo Kim <iamjoonsoo.kim@lge.com>
>     mm/CMA: fix boot regression due to physical address of high_memory
> 
> Jan Kara <jack@suse.cz>
>     ncpfs: return proper error from NCP_IOC_SETROOT ioctl
> 
> Rabin Vincent <rabin.vincent@axis.com>
>     crypto: af_alg - fix backlog handling
> 
> Richard Guy Briggs <rgb@redhat.com>
>     audit: restore AUDIT_LOGINUID unset ABI
> 
> Paul Moore <pmoore@redhat.com>
>     audit: don't attempt to lookup PIDs when changing PID filtering audit rules
> 
> Richard Guy Briggs <rgb@redhat.com>
>     audit: use supplied gfp_mask from audit_buffer in kauditd_send_multicast_skb
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Unbreak the unprivileged remount tests
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Allow setting gid_maps without privilege when setgroups is disabled
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Add a knob to disable setgroups on a per user namespace basis
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Rename id_map_mutex to userns_state_mutex
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Only allow the creator of the userns unprivileged mappings
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Check euid no fsuid when establishing an unprivileged uid mapping
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Don't allow unprivileged creation of gid mappings
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Don't allow setgroups until a gid mapping has been setablished
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     userns: Document what the invariant required for safe unprivileged mappings.
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     groups: Consolidate the setgroups permission checks
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     umount: Disallow unprivileged mount force
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     mnt: Update unprivileged remount test
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     mnt: Implicitly add MNT_NODEV on remount when it was implicitly added by mount
> 
> Luis Henriques <luis.henriques@canonical.com>
>     thermal: Fix error path in thermal_init()
> 
> Eric W. Biederman <ebiederm@xmission.com>
>     mnt: Fix a memory stomp in umount
> 
> Johannes Berg <johannes.berg@intel.com>
>     mac80211: free management frame keys when removing station
> 
> Andreas Müller <goo@stapelspeicher.org>
>     mac80211: fix multicast LED blinking and counter
> 
> Jes Sorensen <Jes.Sorensen@redhat.com>
>     mac80211: avoid using uninitialized stack data
> 
> Felix Fietkau <nbd@openwrt.org>
>     mac80211: copy chandef from AP vif to VLANs
> 
> Takashi Iwai <tiwai@suse.de>
>     KEYS: Fix stale key registration at error path
> 
> Borislav Petkov <bp@suse.de>
>     x86/microcode/intel: Fish out the stashed microcode for the BSP
> 
> Borislav Petkov <bp@suse.de>
>     x86, microcode: Reload microcode on resume
> 
> Boris Ostrovsky <boris.ostrovsky@oracle.com>
>     x86, microcode: Don't initialize microcode code on paravirt
> 
> Borislav Petkov <bp@suse.de>
>     x86, microcode, intel: Drop unused parameter
> 
> Borislav Petkov <bp@suse.de>
>     x86, microcode, AMD: Do not use smp_processor_id() in preemtible context
> 
> Jan Kara <jack@suse.cz>
>     isofs: Fix unchecked printing of ER records
> 
> Andy Lutomirski <luto@amacapital.net>
>     x86/tls: Don't validate lm in set_thread_area() after all
> 
> Andy Lutomirski <luto@amacapital.net>
>     x86/asm/traps: Disable tracing and kprobes in fixup_bad_iret and sync_regs
> 
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>     ARM: mvebu: fix ordering in Armada 370 .dtsi
> 
> Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>     ARM: mvebu: remove conflicting muxing on Armada 370 DB
> 
> Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>     ARM: mvebu: disable I/O coherency on non-SMP situations on Armada 370/375/38x/XP
> 
> Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>     ARM: mvebu: make the coherency_ll.S functions work with no coherency fabric
> 
> Dmitry Osipenko <digetx@gmail.com>
>     ARM: tegra: Re-add removed SoC id macro to tegra_resume()
> 
> Thierry Reding <treding@nvidia.com>
>     drm/tegra: gem: dumb: pitch and size are outputs
> 
> Zi Shen Lim <zlim.lnx@gmail.com>
>     arm64: bpf: lift restriction on last instruction
> 
> Catalin Marinas <catalin.marinas@arm.com>
>     arm64: Add COMPAT_HWCAP_LPAE
> 
> Mikulas Patocka <mpatocka@redhat.com>
>     dm thin: fix a race in thin_dtr
> 
> Joe Thornber <ejt@redhat.com>
>     dm thin: fix missing out-of-data-space to write mode transition if blocks are released
> 
> Joe Thornber <ejt@redhat.com>
>     dm thin: fix inability to discard blocks when in out-of-data-space mode
> 
> Dan Carpenter <dan.carpenter@oracle.com>
>     dm space map metadata: fix sm_bootstrap_get_nr_blocks()
> 
> Joe Thornber <ejt@redhat.com>
>     dm cache: fix spurious cell_defer when dealing with partial block at end of device
> 
> Joe Thornber <ejt@redhat.com>
>     dm cache: dirty flag was mistakenly being cleared when promoting via overwrite
> 
> Joe Thornber <ejt@redhat.com>
>     dm cache: only use overwrite optimisation for promotion when in writeback mode
> 
> Milan Broz <gmazyland@gmail.com>
>     dm crypt: use memzero_explicit for on-stack buffer
> 
> Darrick J. Wong <darrick.wong@oracle.com>
>     dm bufio: fix memleak when using a dm_buffer's inline bio
> 
> Mikulas Patocka <mpatocka@redhat.com>
>     dcache: fix kmemcheck warning in switch_names
> 
> Peng Tao <tao.peng@primarydata.com>
>     nfs41: fix nfs4_proc_layoutget error handling
> 
> Jan Kara <jack@suse.cz>
>     f2fs: fix possible data corruption in f2fs_write_begin()
> 
> Jan Kara <jack@suse.cz>
>     f2fs: avoid returning uninitialized value to userspace from f2fs_trim_fs()
> 
> Hannes Reinecke <hare@suse.de>
>     scsi: correct return values for .eh_abort_handler implementations
> 
> Markus Pargmann <mpa@pengutronix.de>
>     regulator: anatop: Set default voltage selector for vddpu
> 
> Sumit.Saxena@avagotech.com <Sumit.Saxena@avagotech.com>
>     megaraid_sas: dndinaness related bug fixes
> 
> Sumit.Saxena@avagotech.com <Sumit.Saxena@avagotech.com>
>     megaraid_sas: corrected return of wait_event from abort frame path
> 
> Peter Guo <peter.guo@bayhubtech.com>
>     mmc: sdhci-pci-o2micro: Fix Dell E5440 issue
> 
> Baruch Siach <baruch@tkos.co.il>
>     mmc: block: add newline to sysfs display of force_ro
> 
> Ulf Hansson <ulf.hansson@linaro.org>
>     mmc: omap_hsmmc: Fix UHS card with DDR50 support
> 
> James Hogan <james.hogan@imgtec.com>
>     mmc: dw_mmc: avoid write to CDTHRCTL on older versions
> 
> Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>     mfd: tc6393xb: Fail ohci suspend if full state restore is required
> 
> Tony Lindgren <tony@atomide.com>
>     mfd: twl4030-power: Fix regression with missing compatible flag
> 
> Sonny Rao <sonnyrao@chromium.org>
>     clocksource: arch_timer: Fix code to use physical timers when requested
> 
> Hante Meuleman <meuleman@broadcom.com>
>     brcmfmac: Fix bitmap malloc bug in msgbuf.
> 
> Andy Lutomirski <luto@amacapital.net>
>     x86, kvm: Clear paravirt_enabled on KVM guests for espfix32's benefit
> 
> Andy Lutomirski <luto@amacapital.net>
>     x86_64, switch_to(): Load TLS descriptors before switching DS and ES
> 
> Andy Lutomirski <luto@amacapital.net>
>     x86/tls: Disallow unusual TLS segments
> 
> Andy Lutomirski <luto@amacapital.net>
>     x86/tls: Validate TLS entries to protect espfix
> 
> Jan Kara <jack@suse.cz>
>     isofs: Fix infinite looping over CE entries
> 
> 
> -------------
> 
> Diffstat:
> 
>  Makefile                                           |   4 +-
>  arch/arm/boot/dts/armada-370-db.dts                |  24 ---
>  arch/arm/boot/dts/armada-370.dtsi                  |  10 +-
>  arch/arm/include/asm/arch_timer.h                  |   9 +
>  arch/arm/mach-mvebu/coherency.c                    |  44 +++--
>  arch/arm/mach-mvebu/coherency_ll.S                 |  21 ++-
>  arch/arm/mach-tegra/reset-handler.S                |   1 +
>  arch/arm64/include/asm/arch_timer.h                |   9 +
>  arch/arm64/include/asm/hwcap.h                     |   1 +
>  arch/arm64/kernel/setup.c                          |   3 +-
>  arch/arm64/net/bpf_jit_comp.c                      |  13 +-
>  arch/s390/kernel/compat_linux.c                    |   2 +-
>  arch/x86/include/asm/microcode.h                   |   2 +
>  arch/x86/include/asm/microcode_amd.h               |   4 +-
>  arch/x86/include/asm/microcode_intel.h             |   2 +
>  arch/x86/include/uapi/asm/ldt.h                    |   7 +
>  arch/x86/kernel/cpu/microcode/amd.c                |   8 +-
>  arch/x86/kernel/cpu/microcode/amd_early.c          |  20 +-
>  arch/x86/kernel/cpu/microcode/core.c               |  12 +-
>  arch/x86/kernel/cpu/microcode/core_early.c         |  21 +++
>  arch/x86/kernel/cpu/microcode/intel_early.c        |  42 ++++-
>  arch/x86/kernel/kvm.c                              |   9 +-
>  arch/x86/kernel/kvmclock.c                         |   1 -
>  arch/x86/kernel/process_64.c                       | 101 +++++++---
>  arch/x86/kernel/tls.c                              |  39 ++++
>  arch/x86/kernel/traps.c                            |   5 +-
>  crypto/af_alg.c                                    |   3 +
>  drivers/clocksource/arm_arch_timer.c               |   5 +-
>  drivers/gpu/drm/tegra/gem.c                        |  10 +-
>  drivers/md/dm-bufio.c                              |  20 +-
>  drivers/md/dm-cache-target.c                       |  17 +-
>  drivers/md/dm-crypt.c                              |   2 +-
>  drivers/md/dm-thin.c                               |  30 ++-
>  drivers/md/persistent-data/dm-space-map-metadata.c |   4 +-
>  drivers/mfd/tc6393xb.c                             |  13 +-
>  drivers/mfd/twl4030-power.c                        |   3 +
>  drivers/mmc/card/block.c                           |   2 +-
>  drivers/mmc/host/dw_mmc.c                          |   7 +
>  drivers/mmc/host/omap_hsmmc.c                      |   4 +-
>  drivers/mmc/host/sdhci-pci-o2micro.c               |   2 -
>  drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   |   1 +
>  drivers/regulator/anatop-regulator.c               |   8 +
>  drivers/scsi/NCR5380.c                             |  12 +-
>  drivers/scsi/aha1740.c                             |   2 +-
>  drivers/scsi/atari_NCR5380.c                       |   2 +-
>  drivers/scsi/esas2r/esas2r_main.c                  |   2 +-
>  drivers/scsi/megaraid.c                            |   8 +-
>  drivers/scsi/megaraid/megaraid_sas_base.c          |   2 +-
>  drivers/scsi/megaraid/megaraid_sas_fp.c            |  17 +-
>  drivers/scsi/megaraid/megaraid_sas_fusion.c        |  13 +-
>  drivers/scsi/sun3_NCR5380.c                        |  10 +-
>  drivers/thermal/thermal_core.c                     |   4 +-
>  fs/btrfs/disk-io.c                                 |  26 ++-
>  fs/btrfs/extent-tree.c                             |  10 +-
>  fs/btrfs/extent_map.c                              |   2 -
>  fs/btrfs/ordered-data.c                            |   9 +-
>  fs/btrfs/ordered-data.h                            |   8 +-
>  fs/btrfs/super.c                                   |   2 +-
>  fs/btrfs/transaction.c                             |  33 ++++
>  fs/btrfs/transaction.h                             |   2 +
>  fs/btrfs/tree-log.c                                |   6 +-
>  fs/dcache.c                                        |   2 +
>  fs/ecryptfs/crypto.c                               |   1 -
>  fs/ecryptfs/file.c                                 |  12 --
>  fs/ecryptfs/main.c                                 |  16 +-
>  fs/f2fs/data.c                                     |  24 ++-
>  fs/f2fs/segment.c                                  |   2 +-
>  fs/isofs/rock.c                                    |   9 +
>  fs/namespace.c                                     |  13 +-
>  fs/ncpfs/ioctl.c                                   |   1 -
>  fs/nfs/nfs4proc.c                                  |   6 +-
>  fs/proc/base.c                                     |  53 ++++++
>  fs/udf/dir.c                                       |   3 +-
>  fs/udf/inode.c                                     |  14 ++
>  fs/udf/namei.c                                     |   3 +-
>  fs/udf/symlink.c                                   |  57 ++++--
>  fs/udf/udfdecl.h                                   |   3 +-
>  fs/udf/unicode.c                                   |  28 +--
>  include/linux/audit.h                              |   4 +
>  include/linux/cred.h                               |   1 +
>  include/linux/user_namespace.h                     |  12 ++
>  kernel/audit.c                                     |   8 +-
>  kernel/auditfilter.c                               |  23 +--
>  kernel/groups.c                                    |  11 +-
>  kernel/pid.c                                       |   2 +
>  kernel/uid16.c                                     |   2 +-
>  kernel/user.c                                      |   1 +
>  kernel/user_namespace.c                            | 122 +++++++++++-
>  mm/cma.c                                           |  14 +-
>  net/mac80211/chan.c                                |  23 ++-
>  net/mac80211/iface.c                               |   1 +
>  net/mac80211/key.c                                 |   2 +-
>  net/mac80211/mlme.c                                |   1 +
>  net/mac80211/rx.c                                  |  11 +-
>  security/keys/encrypted-keys/encrypted.c           |   5 +-
>  .../selftests/mount/unprivileged-remount-test.c    | 204 +++++++++++++++++----
>  96 files changed, 1077 insertions(+), 332 deletions(-)
> 
> 

^ permalink raw reply	[flat|nested] 90+ messages in thread

* Re: [PATCH 3.18 00/84] 3.18.2-stable review
  2015-01-08 10:20 ` Satoru Takeuchi
@ 2015-01-08 16:33   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 90+ messages in thread
From: Greg Kroah-Hartman @ 2015-01-08 16:33 UTC (permalink / raw)
  To: Satoru Takeuchi; +Cc: linux-kernel, torvalds, akpm, linux, shuah.kh, stable

On Thu, Jan 08, 2015 at 07:20:43PM +0900, Satoru Takeuchi wrote:
> At Tue,  6 Jan 2015 17:49:03 -0800,
> Greg Kroah-Hartman wrote:
> > 
> > This is the start of the stable review cycle for the 3.18.2 release.
> > There are 84 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Fri Jan  9 01:40:07 UTC 2015.
> > Anything received after that time might be too late.
> 
> All 3.10.64-rc1, 3.14.28-rc1, 3.17.8-rc1, and 3.18.2-rc1 passed my test.
> 
>  - Test Cases:
>    - Build this kernel.
>    - Boot this kernel.
>    - Build the latest mainline kernel with this kernel.
> 
>  - Test Tool:
>    https://github.com/satoru-takeuchi/test-linux-stable
> 
>  - Test Result (kernel .config, ktest config and test log):
>    http://satoru-takeuchi.org/test-linux-stable/results/<version>-<test datetime>.tar.xz
> 
>  - Build Environment:
>    - OS: Debian Jessy x86_64
>    - CPU: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz x 4
>    - memory: 8GB
> 
>  - Test Target Environment:
>    - Debian Jessy x86_64 (KVM guest on the Build Environment)
>    - # of vCPU: 2
>    - memory: 2GB

Thanks for testing and letting me know.

greg k-h

^ permalink raw reply	[flat|nested] 90+ messages in thread

end of thread, other threads:[~2015-01-08 16:33 UTC | newest]

Thread overview: 90+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-07  1:49 [PATCH 3.18 00/84] 3.18.2-stable review Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 01/84] isofs: Fix infinite looping over CE entries Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 02/84] x86/tls: Validate TLS entries to protect espfix Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 03/84] x86/tls: Disallow unusual TLS segments Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 04/84] x86_64, switch_to(): Load TLS descriptors before switching DS and ES Greg Kroah-Hartman
2015-01-07 15:26   ` Jiri Slaby
2015-01-08  1:27     ` Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 05/84] x86, kvm: Clear paravirt_enabled on KVM guests for espfix32s benefit Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 06/84] brcmfmac: Fix bitmap malloc bug in msgbuf Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 07/84] clocksource: arch_timer: Fix code to use physical timers when requested Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 08/84] mfd: twl4030-power: Fix regression with missing compatible flag Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 09/84] mfd: tc6393xb: Fail ohci suspend if full state restore is required Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 10/84] mmc: dw_mmc: avoid write to CDTHRCTL on older versions Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 11/84] mmc: omap_hsmmc: Fix UHS card with DDR50 support Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 12/84] mmc: block: add newline to sysfs display of force_ro Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 13/84] mmc: sdhci-pci-o2micro: Fix Dell E5440 issue Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 14/84] megaraid_sas: corrected return of wait_event from abort frame path Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 15/84] megaraid_sas: dndinaness related bug fixes Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 16/84] regulator: anatop: Set default voltage selector for vddpu Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 17/84] scsi: correct return values for .eh_abort_handler implementations Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 18/84] f2fs: avoid returning uninitialized value to userspace from f2fs_trim_fs() Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 19/84] f2fs: fix possible data corruption in f2fs_write_begin() Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 20/84] nfs41: fix nfs4_proc_layoutget error handling Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 21/84] dcache: fix kmemcheck warning in switch_names Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 22/84] dm bufio: fix memleak when using a dm_buffers inline bio Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 23/84] dm crypt: use memzero_explicit for on-stack buffer Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 24/84] dm cache: only use overwrite optimisation for promotion when in writeback mode Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 25/84] dm cache: dirty flag was mistakenly being cleared when promoting via overwrite Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 26/84] dm cache: fix spurious cell_defer when dealing with partial block at end of device Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 27/84] dm space map metadata: fix sm_bootstrap_get_nr_blocks() Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 28/84] dm thin: fix inability to discard blocks when in out-of-data-space mode Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 29/84] dm thin: fix missing out-of-data-space to write mode transition if blocks are released Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 30/84] dm thin: fix a race in thin_dtr Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 31/84] arm64: Add COMPAT_HWCAP_LPAE Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 32/84] arm64: bpf: lift restriction on last instruction Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 33/84] drm/tegra: gem: dumb: pitch and size are outputs Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 34/84] ARM: tegra: Re-add removed SoC id macro to tegra_resume() Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 35/84] ARM: mvebu: make the coherency_ll.S functions work with no coherency fabric Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 36/84] ARM: mvebu: disable I/O coherency on non-SMP situations on Armada 370/375/38x/XP Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 37/84] ARM: mvebu: remove conflicting muxing on Armada 370 DB Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 39/84] x86/asm/traps: Disable tracing and kprobes in fixup_bad_iret and sync_regs Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 40/84] x86/tls: Dont validate lm in set_thread_area() after all Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 41/84] isofs: Fix unchecked printing of ER records Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 42/84] x86, microcode, AMD: Do not use smp_processor_id() in preemtible context Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 43/84] x86, microcode, intel: Drop unused parameter Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 44/84] x86, microcode: Dont initialize microcode code on paravirt Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 45/84] x86, microcode: Reload microcode on resume Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 46/84] x86/microcode/intel: Fish out the stashed microcode for the BSP Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 47/84] KEYS: Fix stale key registration at error path Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 48/84] mac80211: copy chandef from AP vif to VLANs Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 49/84] mac80211: avoid using uninitialized stack data Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 51/84] mac80211: free management frame keys when removing station Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 52/84] mnt: Fix a memory stomp in umount Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 53/84] thermal: Fix error path in thermal_init() Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 54/84] mnt: Implicitly add MNT_NODEV on remount when it was implicitly added by mount Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 55/84] mnt: Update unprivileged remount test Greg Kroah-Hartman
2015-01-07  1:49 ` [PATCH 3.18 56/84] umount: Disallow unprivileged mount force Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 57/84] groups: Consolidate the setgroups permission checks Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 58/84] userns: Document what the invariant required for safe unprivileged mappings Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 59/84] userns: Dont allow setgroups until a gid mapping has been setablished Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 60/84] userns: Dont allow unprivileged creation of gid mappings Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 61/84] userns: Check euid no fsuid when establishing an unprivileged uid mapping Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 62/84] userns: Only allow the creator of the userns unprivileged mappings Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 63/84] userns: Rename id_map_mutex to userns_state_mutex Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 64/84] userns: Add a knob to disable setgroups on a per user namespace basis Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 65/84] userns: Allow setting gid_maps without privilege when setgroups is disabled Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 66/84] userns: Unbreak the unprivileged remount tests Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 67/84] audit: use supplied gfp_mask from audit_buffer in kauditd_send_multicast_skb Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 68/84] audit: dont attempt to lookup PIDs when changing PID filtering audit rules Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 69/84] audit: restore AUDIT_LOGINUID unset ABI Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 70/84] crypto: af_alg - fix backlog handling Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 71/84] ncpfs: return proper error from NCP_IOC_SETROOT ioctl Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 72/84] mm/CMA: fix boot regression due to physical address of high_memory Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 73/84] exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 74/84] udf: Check path length when reading symlink Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 75/84] udf: Verify i_size when loading inode Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 76/84] udf: Verify symlink size before loading it Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 77/84] udf: Check component length before reading it Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 78/84] eCryptfs: Force RO mount when encrypted view is enabled Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 79/84] eCryptfs: Remove buggy and unnecessary write in file name decode routine Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 80/84] Btrfs: make sure we wait on logged extents when fsycning two subvols Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 81/84] btrfs: fix wrong accounting of raid1 data profile in statfs Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 82/84] Btrfs: do not move em to modified list when unpinning Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 83/84] Btrfs: make sure logged extents complete in the current transaction V3 Greg Kroah-Hartman
2015-01-07  1:50 ` [PATCH 3.18 84/84] Btrfs: fix fs corruption on transaction abort if device supports discard Greg Kroah-Hartman
2015-01-07 13:47 ` [PATCH 3.18 00/84] 3.18.2-stable review Guenter Roeck
2015-01-07 23:33 ` Shuah Khan
2015-01-07 23:45   ` Greg Kroah-Hartman
2015-01-08 10:20 ` Satoru Takeuchi
2015-01-08 16:33   ` Greg Kroah-Hartman

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).