3.18.63-stable review
Subsystems (2)
Greg Kroah-Hartman
maintainercover 3.18.63-stable review
This is the start of the stable review cycle for the 3.18.63 release. There are 60 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 Thu Jul 27 19:15:49 UTC 2017. 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.x/stable-review/patch-3.18.63-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-3.18.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 3.18.63-rc1
Maciej W. Rozycki <[email protected]>
MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn'
Greg Hackmann <[email protected]>
alarmtimer: don't rate limit one-shot timers
Chunyu Hu <[email protected]>
tracing: Fix kmemleak in instance_rmdir
Bjorn Andersson <[email protected]>
spmi: Include OF based modalias in device uevent
Stephen Boyd <[email protected]>
of: device: Export of_device_{get_modalias, uvent_modalias} to modules
Paul Mackerras <[email protected]>
KVM: PPC: Book3S HV: Context-switch EBB registers properly
Imre Deak <[email protected]>
drm/mst: Avoid processing partially received up/down message transactions
Imre Deak <[email protected]>
drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req()
Imre Deak <[email protected]>
drm/mst: Fix error handling during MST sideband message reception
Michael Gugino <[email protected]>
staging: rtl8188eu: add TL-WN722N v2 support
Ingo Molnar <[email protected]>
Revert "perf/core: Drop kernel samples even though :u is specified"
Jin Yao <[email protected]>
perf annotate: Fix broken arrow at row 0 connecting jmp instruction to its target
Jiang Yi <[email protected]>
target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce
Jan Kara <[email protected]>
udf: Fix deadlock between writeback and udf_setsize()
NeilBrown <[email protected]>
NFS: only invalidate dentrys that are clearly invalid.
Chen Hong <[email protected]>
Input: i8042 - fix crash at boot time
Maciej W. Rozycki <[email protected]>
MIPS: math-emu: Prevent wrong ISA mode instruction emulation
Maciej W. Rozycki <[email protected]>
MIPS: Fix unaligned PC interpretation in `compute_return_epc'
Maciej W. Rozycki <[email protected]>
MIPS: Actually decode JALX in `__compute_return_epc_for_insn'
James Hogan <[email protected]>
MIPS: Save static registers before sysmips
Seunghun Han <[email protected]>
x86/acpi: Prevent out of bound access caused by broken ACPI tables
James Hogan <[email protected]>
MIPS: Negate error syscall return in trace
James Hogan <[email protected]>
MIPS: Fix mips_atomic_set() with EVA
James Hogan <[email protected]>
MIPS: Fix mips_atomic_set() retry condition
Alex Williamson <[email protected]>
vfio: New external user group/file match
Alex Williamson <[email protected]>
vfio: Fix group release deadlock
Jaegeuk Kim <[email protected]>
f2fs: Don't clear SGID when inheriting ACLs
Alex Deucher <[email protected]>
drm/radeon/ci: disable mclk switching for high refresh rates (v2)
Jiri Olsa <[email protected]>
s390/syscalls: Fix out of bounds arguments access
Xiao Ni <[email protected]>
Raid5 should update rdev->sectors after reshape
Mikulas Patocka <[email protected]>
md: don't use flush_signals in userspace processes
Yoshihiro Shimoda <[email protected]>
usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL
Johan Hovold <[email protected]>
USB: cdc-acm: add device-id for quirky printer
Colin Ian King <[email protected]>
usb: storage: return on error to avoid a null pointer dereference
Mathias Nyman <[email protected]>
xhci: Fix NULL pointer dereference when cleaning up streams for removed host
Mathias Nyman <[email protected]>
xhci: fix 20000ms port resume timeout
Chen Yu <[email protected]>
PCI/PM: Restore the status of PCI devices across hibernation
Herbert Xu <[email protected]>
af_key: Fix sadb_x_ipsecrequest parsing
Oliver O'Halloran <[email protected]>
powerpc/asm: Mark cr0 as clobbered in mftb()
Anton Blanchard <[email protected]>
powerpc: Fix emulation of mfocrf in emulate_step()
Anton Blanchard <[email protected]>
powerpc: Fix emulation of mcrf in emulate_step()
Michael Ellerman <[email protected]>
powerpc/64: Fix atomic64_inc_not_zero() to return an int
Maurizio Lombardi <[email protected]>
scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails.
Krzysztof Kozlowski <[email protected]>
PM / Domains: Fix unsafe iteration over modified list of domain providers
Krzysztof Kozlowski <[email protected]>
PM / Domains: Fix unsafe iteration over modified list of device links
Satish Babu Patakokila <[email protected]>
ASoC: compress: Derive substream from stream based on direction
Jason A. Donenfeld <[email protected]>
Bluetooth: use constant time memory comparison for secret values
Mateusz Jurczyk <[email protected]>
NFC: Add sockaddr length checks before accessing sa_family in bind handlers
Joe Perches <[email protected]>
stddef.h: move offsetofend inside #ifndef/#endif guard, neaten
Denys Vlasenko <[email protected]>
include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header
Mateusz Jurczyk <[email protected]>
nfc: Fix the sockaddr length sanitization in llcp_sock_connect
Mateusz Jurczyk <[email protected]>
nfc: Ensure presence of required attributes in the activate_target handler
Johan Hovold <[email protected]>
NFC: fix broken device allocation
Miaoqing Pan <[email protected]>
ath9k: fix tx99 bus error
Miaoqing Pan <[email protected]>
ath9k: fix tx99 use after free
Pavel Shilovsky <[email protected]>
CIFS: Fix handle_cancelled_mid callback initialization
Arnd Bergmann <[email protected]>
ir-core: fix gcc-7 warning on bool arithmetic
Colin King <[email protected]>
x86/rtc: Remove duplicate const specifier
Jiri Slaby <[email protected]>
kvm: x86: memset whole irq_eoi
Linus Torvalds <[email protected]>
disable new gcc-7.1.1 warnings for now
-------------
Diffstat:
Makefile | 7 +++-- arch/mips/include/asm/branch.h | 5 +-- arch/mips/kernel/branch.c | 8 +++-- arch/mips/kernel/ptrace.c | 2 +- arch/mips/kernel/scall32-o32.S | 2 +- arch/mips/kernel/scall64-64.S | 2 +- arch/mips/kernel/scall64-n32.S | 2 +- arch/mips/kernel/scall64-o32.S | 2 +- arch/mips/kernel/syscall.c | 15 +++++++-- arch/mips/math-emu/cp1emu.c | 38 +++++++++++++++++++++++ arch/powerpc/include/asm/atomic.h | 4 +-- arch/powerpc/include/asm/reg.h | 2 +- arch/powerpc/kvm/book3s_hv.c | 16 ++++++++++ arch/powerpc/lib/sstep.c | 19 ++++++++++-- arch/s390/include/asm/syscall.h | 6 ++++ arch/x86/kernel/acpi/boot.c | 8 +++++ arch/x86/kernel/rtc.c | 2 +- drivers/base/power/domain.c | 8 ++--- drivers/gpu/drm/drm_dp_mst_topology.c | 41 ++++++++++++++++++++----- drivers/gpu/drm/radeon/ci_dpm.c | 6 ++++ drivers/input/serio/i8042.c | 12 ++++++-- drivers/md/raid1.c | 5 ++- drivers/md/raid5.c | 9 +++--- drivers/media/rc/imon.c | 2 +- drivers/misc/enclosure.c | 14 ++++++--- drivers/net/wireless/ath/ath9k/ar9003_phy.c | 2 -- drivers/net/wireless/ath/ath9k/tx99.c | 13 +++++--- drivers/of/device.c | 2 ++ drivers/pci/pci-driver.c | 1 + drivers/spmi/spmi.c | 12 ++++++++ drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + drivers/target/target_core_transport.c | 9 ++++++ drivers/usb/class/cdc-acm.c | 3 ++ drivers/usb/host/xhci-hub.c | 3 ++ drivers/usb/host/xhci-ring.c | 11 ++++--- drivers/usb/renesas_usbhs/common.c | 4 ++- drivers/usb/storage/isd200.c | 5 ++- drivers/vfio/vfio.c | 46 +++++++++++++++++++++++++++- fs/cifs/smb2ops.c | 3 +- fs/f2fs/acl.c | 2 +- fs/nfs/dir.c | 12 +++++--- fs/nfs/inode.c | 4 +-- fs/udf/inode.c | 4 +-- include/linux/stddef.h | 15 +++++++-- include/linux/vfio.h | 15 ++------- kernel/events/core.c | 21 ------------- kernel/time/alarmtimer.c | 3 +- kernel/trace/trace.c | 1 + net/bluetooth/smp.c | 5 +-- net/key/af_key.c | 47 ++++++++++++++++------------- net/nfc/core.c | 31 +++++++++++-------- net/nfc/llcp_sock.c | 9 +++--- net/nfc/netlink.c | 4 ++- sound/soc/soc-compress.c | 6 ++-- tools/perf/ui/browser.c | 2 +- virt/kvm/ioapic.c | 2 +- virt/kvm/vfio.c | 27 ++++++++++++----- 57 files changed, 399 insertions(+), 163 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/60 disable new gcc-7.1.1 warnings for now
3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit bd664f6b3e376a8ef4990f87d08271cc2d01ba9a upstream.
I made the mistake of upgrading my desktop to the new Fedora 26 that comes with gcc-7.1.1.
There's nothing wrong per se that I've noticed, but I now have 1500 lines of warnings, mostly from the new format-truncation warning triggering all over the tree.
We use 'snprintf()' and friends in a lot of places, and often know that the numbers are fairly small (ie a controller index or similar), but gcc doesn't know that, and sees an 'int', and thinks that it could be some huge number. And then complains when our buffers are not able to fit the name for the ten millionth controller.
These warnings aren't necessarily bad per se, and we probably want to look through them subsystem by subsystem, but at least during the merge window they just mean that I can't even see if somebody is introducing any *real* problems when I pull.
So warnings disabled for now.
--- Makefile | 3 +++ 1 file changed, 3 insertions(+)
Makefile +3 -0
@@ -611,6 +611,9 @@ include $(srctree)/arch/$(SRCARCH)/Makef KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) +KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) +KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) +KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) KBUILD_CFLAGS += $(call cc-option,-fno-PIE) KBUILD_AFLAGS += $(call cc-option,-fno-PIE)
Greg Kroah-Hartman
maintainerPATCH 3/60 x86/rtc: Remove duplicate const specifier
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin King <[email protected]>
commit d505ad1d66c9cd31db5ab0d2c7bcb2a47e5bb29e upstream.
Building with clang:
CC arch/x86/kernel/rtc.oarch/x86/kernel/rtc.c:173:29: warning: duplicate 'const' declaration
specifier [-Wduplicate-decl-specifier]
static const char * const const ids[] __initconst =
Remove the duplicate const, it is not needed and causes a warning.
--- arch/x86/kernel/rtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/rtc.c +1 -1
@@ -170,7 +170,7 @@ static struct platform_device rtc_devicestatic __init int add_rtc_cmos (void ) {#ifdef CONFIG_PNP -static const char *const const ids[]__initconst = +static const char *const ids[]__initconst = {"PNP0b00" ,"PNP0b01" ,"PNP0b02" , };struct pnp_dev *dev;struct pnp_id *id;
Greg Kroah-Hartman
maintainerPATCH 4/60 ir-core: fix gcc-7 warning on bool arithmetic
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit bd7e31bbade02bc1e92aa00d5cf2cee2da66838a upstream.
gcc-7 suggests that an expression using a bitwise not and a bitmask on a 'bool' variable is better written using boolean logic:
drivers/media/rc/imon.c: In function 'imon_incoming_scancode':drivers/media/rc/imon.c:1725:22: error: '~' on a boolean expression [-Werror=bool-operation]
ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1;
^drivers/media/rc/imon.c:1725:22: note: did you mean to use logical not?
I agree.
--- drivers/media/rc/imon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/imon.c +1 -1
@@ -1629,7 +1629,7 @@ static void imon_incoming_packet(structif (kc ==KEY_KEYBOARD && !ictx->release_code) { ictx->last_keycode = kc;if (!nomouse) { - ictx->pad_mouse = ~(ictx->pad_mouse) &0x1 ; + ictx->pad_mouse = !ictx->pad_mouse;dev_dbg (dev,"toggling to %s mode\n" , ictx->pad_mouse ?"mouse" :"keyboard" );spin_unlock_irqrestore (&ictx->kc_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 5/60 CIFS: Fix handle_cancelled_mid callback initialization
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Shilovsky <[email protected]>
Commit 99e214e006cf ("Handle mismatched open calls") was applied with errors that result in initializing handle_cancelled_mid callback twice in smb21_operations and smb30_operations structures but not initializing it in smb20_operations structure.
--- fs/cifs/smb2ops.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/cifs/smb2ops.c +1 -2
@@ -1383,6 +1383,7 @@ struct smb_version_operations smb20_oper .clear_stats = smb2_clear_stats, .print_stats = smb2_print_stats, .is_oplock_break = smb2_is_valid_oplock_break, + .handle_cancelled_mid = smb2_handle_cancelled_mid, .downgrade_oplock = smb2_downgrade_oplock, .need_neg = smb2_need_neg, .negotiate = smb2_negotiate,
@@ -1462,7 +1463,6 @@ struct smb_version_operations smb21_oper .print_stats = smb2_print_stats, .is_oplock_break = smb2_is_valid_oplock_break, .handle_cancelled_mid = smb2_handle_cancelled_mid, - .handle_cancelled_mid = smb2_handle_cancelled_mid, .downgrade_oplock = smb2_downgrade_oplock, .need_neg = smb2_need_neg, .negotiate = smb2_negotiate,
@@ -1545,7 +1545,6 @@ struct smb_version_operations smb30_oper .dump_share_caps = smb2_dump_share_caps, .is_oplock_break = smb2_is_valid_oplock_break, .handle_cancelled_mid = smb2_handle_cancelled_mid, - .handle_cancelled_mid = smb2_handle_cancelled_mid, .downgrade_oplock = smb2_downgrade_oplock, .need_neg = smb2_need_neg, .negotiate = smb2_negotiate,
Greg Kroah-Hartman
maintainerPATCH 6/60 ath9k: fix tx99 use after free
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqing Pan <[email protected]>
commit cf8ce1ea61b75712a154c93e40f2a5af2e4dd997 upstream.
One scenario that could lead to UAF is two threads writing simultaneously to the "tx99" debug file. One of them would set the "start" value to true and follow to ath9k_tx99_init(). Inside the function it would set the sc->tx99_state to true after allocating sc->tx99skb. Then, the other thread would execute write_file_tx99() and call ath9k_tx99_deinit(). sc->tx99_state would be freed. After that, the first thread would continue inside ath9k_tx99_init() and call
r = ath9k_tx99_send(sc, sc->tx99_skb, &txctl);
that would make use of the freed sc->tx99_skb memory.
--- drivers/net/wireless/ath/ath9k/tx99.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/tx99.c +9 -4
@@ -190,22 +190,27 @@ static ssize_t write_file_tx99(struct fiif (strtobool (buf, &start))return -EINVAL ; +mutex_lock (&sc->mutex); +if (start == sc->tx99_state) {if (!start) -return count; + goto out;ath_dbg (common,XMIT ,"Resetting TX99\n" );ath9k_tx99_deinit (sc); }if (!start) {ath9k_tx99_deinit (sc); -return count; + goto out; } r =ath9k_tx99_init (sc); -if (r) +if (r) { +mutex_unlock (&sc->mutex);return r; - + } +out: +mutex_unlock (&sc->mutex);return count; }
Greg Kroah-Hartman
maintainerPATCH 7/60 ath9k: fix tx99 bus error
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqing Pan <[email protected]>
commit bde717ab473668377fc65872398a102d40cb2d58 upstream.
The hard coded register 0x9864 and 0x9924 are invalid for ar9300 chips.
--- drivers/net/wireless/ath/ath9k/ar9003_phy.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_phy.c +0 -2
@@ -1707,8 +1707,6 @@ static void ar9003_hw_spectral_scan_waitstatic void ar9003_hw_tx99_start (struct ath_hw *ah,u32 qnum) {REG_SET_BIT (ah,AR_PHY_TEST ,PHY_AGC_CLR ); -REG_SET_BIT (ah,0x9864 ,0x7f000 ); -REG_SET_BIT (ah,0x9924 ,0x7f00fe );REG_CLR_BIT (ah,AR_DIAG_SW ,AR_DIAG_RX_DIS );REG_WRITE (ah,AR_CR ,AR_CR_RXD );REG_WRITE (ah,AR_DLCL_IFS (qnum),0 );
Greg Kroah-Hartman
maintainerPATCH 8/60 NFC: fix broken device allocation
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 20777bc57c346b6994f465e0d8261a7fbf213a09 upstream.
Commit 7eda8b8e9677 ("NFC: Use IDR library to assing NFC devices IDs") moved device-id allocation and struct-device initialisation from nfc_allocate_device() to nfc_register_device().
This broke just about every nfc-device-registration error path, which continue to call nfc_free_device() that tries to put the device reference of the now uninitialised (but zeroed) struct device:
kobject: '(null)' (ce316420): is not initialized, yet kobject_put() is being called.
The late struct-device initialisation also meant that various work queues whose names are derived from the nfc device name were also misnamed:
421 root 0 SW< [(null)_nci_cmd_] 422 root 0 SW< [(null)_nci_rx_w] 423 root 0 SW< [(null)_nci_tx_w]
Move the id-allocation and struct-device initialisation back to nfc_allocate_device() and fix up the single call site which did not use nfc_free_device() in its error path.
--- net/nfc/core.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
net/nfc/core.c +18 -13
@@ -950,6 +950,8 @@ static void nfc_release(struct device *dkfree (se); } +ida_simple_remove (&nfc_index_ida, dev->idx); +kfree (dev); }
@@ -1024,6 +1026,7 @@ struct nfc_dev *nfc_allocate_device(stru int tx_headroom, int tx_tailroom) {struct nfc_dev *dev; +int rc;if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || !ops->deactivate_target || !ops->im_transceive)
@@ -1036,6 +1039,15 @@ struct nfc_dev *nfc_allocate_device(struif (!dev)return NULL ; + rc =ida_simple_get (&nfc_index_ida,0 ,0 ,GFP_KERNEL ); +if (rc <0 ) + goto err_free_dev; + dev->idx = rc; + + dev->dev.class = &nfc_class; +dev_set_name (&dev->dev,"nfc%d" , dev->idx); +device_initialize (&dev->dev); + dev->ops = ops; dev->supported_protocols = supported_protocols; dev->tx_headroom = tx_headroom;
@@ -1058,6 +1070,11 @@ struct nfc_dev *nfc_allocate_device(stru }return dev; + +err_free_dev: +kfree (dev); + +return ERR_PTR (rc); }EXPORT_SYMBOL (nfc_allocate_device);
@@ -1072,14 +1089,6 @@ int nfc_register_device(struct nfc_dev *pr_debug ("dev_name=%s\n" ,dev_name (&dev->dev)); - dev->idx =ida_simple_get (&nfc_index_ida,0 ,0 ,GFP_KERNEL ); -if (dev->idx <0 ) -return dev->idx; - - dev->dev.class = &nfc_class; -dev_set_name (&dev->dev,"nfc%d" , dev->idx); -device_initialize (&dev->dev); -mutex_lock (&nfc_devlist_mutex); nfc_devlist_generation++; rc =device_add (&dev->dev);
@@ -1117,12 +1126,10 @@ EXPORT_SYMBOL(nfc_register_device);*/ void nfc_unregister_device (struct nfc_dev *dev) { -int rc, id; +int rc;pr_debug ("dev_name=%s\n" ,dev_name (&dev->dev)); - id = dev->idx; -if (dev->rfkill) {rfkill_unregister (dev->rfkill);rfkill_destroy (dev->rfkill);
@@ -1147,8 +1154,6 @@ void nfc_unregister_device(struct nfc_de nfc_devlist_generation++;device_del (&dev->dev);mutex_unlock (&nfc_devlist_mutex); - -ida_simple_remove (&nfc_index_ida, id); }EXPORT_SYMBOL (nfc_unregister_device);
Greg Kroah-Hartman
maintainerPATCH 9/60 nfc: Ensure presence of required attributes in the activate_target handler
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Jurczyk <[email protected]>
commit a0323b979f81ad2deb2c8836eab506534891876a upstream.
Check that the NFC_ATTR_TARGET_INDEX and NFC_ATTR_PROTOCOLS attributes (in addition to NFC_ATTR_DEVICE_INDEX) are provided by the netlink client prior to accessing them. This prevents potential unhandled NULL pointer dereference exceptions which can be triggered by malicious user-mode programs, if they omit one or both of these attributes.
--- net/nfc/netlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/nfc/netlink.c +3 -1
@@ -899,7 +899,9 @@ static int nfc_genl_llc_get_params(strucstruct sk_buff *msg =NULL ;u32 idx; -if (!info->attrs[NFC_ATTR_DEVICE_INDEX ]) +if (!info->attrs[NFC_ATTR_DEVICE_INDEX ] || + !info->attrs[NFC_ATTR_TARGET_INDEX ] || + !info->attrs[NFC_ATTR_PROTOCOLS ])return -EINVAL ; idx =nla_get_u32 (info->attrs[NFC_ATTR_DEVICE_INDEX ]);
Greg Kroah-Hartman
maintainerPATCH 10/60 nfc: Fix the sockaddr length sanitization in llcp_sock_connect
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Jurczyk <[email protected]>
commit 608c4adfcabab220142ee335a2a003ccd1c0b25b upstream.
Fix the sockaddr length verification in the connect() handler of NFC/LLCP sockets, to compare against the size of the actual structure expected on input (sockaddr_nfc_llcp) instead of its shorter version (sockaddr_nfc).
Both structures are defined in include/uapi/linux/nfc.h. The fields specific to the _llcp extended struct are as follows:
276 __u8 dsap; /* Destination SAP, if known */
277 __u8 ssap; /* Source SAP to be bound to */
278 char service_name[NFC_LLCP_MAX_SERVICE_NAME]; /* Service name URI */;
279 size_t service_name_len;
If the caller doesn't provide a sufficiently long sockaddr buffer, these fields remain uninitialized (and they currently originate from the stack frame of the top-level sys_connect handler). They are then copied by llcp_sock_connect() into internal storage (nfc_llcp_sock structure), and could be subsequently read back through the user-mode getsockname() function (handled by llcp_sock_getname()). This would result in the disclosure of up to ~70 uninitialized bytes from the kernel stack to user-mode clients capable of creating AFC_NFC sockets.
--- net/nfc/llcp_sock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/nfc/llcp_sock.c +1 -2
@@ -655,8 +655,7 @@ static int llcp_sock_connect(struct sockpr_debug ("sock %p sk %p flags 0x%x\n" , sock, sk, flags); -if (!addr || len <sizeof (struct sockaddr_nfc ) || - addr->sa_family !=AF_NFC ) +if (!addr || len <sizeof (*addr) || addr->sa_family !=AF_NFC )return -EINVAL ;if (addr->service_name_len ==0 && addr->dsap ==0 )
Greg Kroah-Hartman
maintainerPATCH 11/60 include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denys Vlasenko <[email protected]>
commit 3876488444e71238e287459c39d7692b6f718c3e upstream.
Suggested by Andy.
--- include/linux/stddef.h | 9 +++++++++ include/linux/vfio.h | 13 ------------- 2 files changed, 9 insertions(+), 13 deletions(-)
include/linux/stddef.h +9 -0
@@ -19,3 +19,12 @@ enum {#define offsetof (TYPE ,MEMBER ) ((size_t) &((TYPE *)0)->MEMBER)#endif #endif + +/** +* offsetofend(TYPE, MEMBER) +* +* @TYPE: The type of the structure +* @MEMBER: The member within the structure to get the end offset of +*/ +#define offsetofend (TYPE ,MEMBER ) \ + (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))
include/linux/vfio.h +0 -13
@@ -76,19 +76,6 @@ extern int vfio_register_iommu_driver(coextern void vfio_unregister_iommu_driver (const struct vfio_iommu_driver_ops *ops); -/** -* offsetofend(TYPE, MEMBER) -* -* @TYPE: The type of the structure -* @MEMBER: The member within the structure to get the end offset of -* -* Simple helper macro for dealing with variable sized structures passed -* from user space. This allows us to easily determine if the provided -* structure is sized to include various fields. -*/ -#define offsetofend (TYPE ,MEMBER ) \ - (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER)) -/* * External user API */
Greg Kroah-Hartman
maintainerPATCH 12/60 stddef.h: move offsetofend inside #ifndef/#endif guard, neaten
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Perches <[email protected]>
commit 8c7fbe5795a016259445a61e072eb0118aaf6a61 upstream.
Commit 3876488444e7 ("include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header") added offsetofend outside the normal include #ifndef/#endif guard. Move it inside.
Miscellanea:
o remove unnecessary blank line
o standardize offsetof macros whitespace style
--- include/linux/stddef.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/stddef.h +4 -4
@@ -3,7 +3,6 @@#include <uapi/linux/stddef.h> -#undef NULL#define NULL ((void *)0)
@@ -14,10 +13,9 @@ enum {#undef offsetof#ifdef __compiler_offsetof -#define offsetof (TYPE ,MEMBER ) __compiler_offsetof(TYPE,MEMBER) +#define offsetof (TYPE ,MEMBER ) __compiler_offsetof(TYPE, MEMBER)#else -#define offsetof (TYPE ,MEMBER ) ((size_t) &((TYPE *)0)->MEMBER) -#endif +#define offsetof (TYPE ,MEMBER ) ((size_t)&((TYPE *)0)->MEMBER)#endif /**
@@ -28,3 +26,5 @@ enum {*/ #define offsetofend (TYPE ,MEMBER ) \ (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER)) + +#endif
Greg Kroah-Hartman
maintainerPATCH 13/60 NFC: Add sockaddr length checks before accessing sa_family in bind handlers
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Jurczyk <[email protected]>
commit f6a5885fc4d68e7f25ffb42b9d8d80aebb3bacbb upstream.
Verify that the caller-provided sockaddr structure is large enough to contain the sa_family field, before accessing it in bind() handlers of the AF_NFC socket. Since the syscall doesn't enforce a minimum size of the corresponding memory region, very short sockaddrs (zero or one byte long) result in operating on uninitialized memory while referencing .sa_family.
--- net/nfc/llcp_sock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/nfc/llcp_sock.c +4 -2
@@ -76,7 +76,8 @@ static int llcp_sock_bind(struct socketstruct sockaddr_nfc_llcp llcp_addr;int len, ret =0 ; -if (!addr || addr->sa_family !=AF_NFC ) + if (!addr || alen < offsetofend(struct sockaddr, sa_family) || + addr->sa_family !=AF_NFC )return -EINVAL ;pr_debug ("sk %p addr %p family %d\n" , sk, addr, addr->sa_family);
@@ -150,7 +151,8 @@ static int llcp_raw_sock_bind(struct socstruct sockaddr_nfc_llcp llcp_addr;int len, ret =0 ; -if (!addr || addr->sa_family !=AF_NFC ) + if (!addr || alen < offsetofend(struct sockaddr, sa_family) || + addr->sa_family !=AF_NFC )return -EINVAL ;pr_debug ("sk %p addr %p family %d\n" , sk, addr, addr->sa_family);
Greg Kroah-Hartman
maintainerPATCH 14/60 Bluetooth: use constant time memory comparison for secret values
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
commit 329d82309824ff1082dc4a91a5bbed8c3bec1580 upstream.
This file is filled with complex cryptography. Thus, the comparisons of MACs and secret keys and curve points and so forth should not add timing attacks, which could either result in a direct forgery, or, given the complexity, some other type of attack.
--- net/bluetooth/smp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/bluetooth/smp.c +3 -2
@@ -22,6 +22,7 @@#include <linux/crypto.h> #include <linux/scatterlist.h> +#include <crypto/algapi.h> #include <crypto/b128ops.h> #include <net/bluetooth/bluetooth.h>
@@ -163,7 +164,7 @@ bool smp_irk_matches(struct hci_dev *hdeif (err)return false; -return !memcmp (bdaddr->b, hash,3 ); +return !crypto_memneq (bdaddr->b, hash,3 ); }int smp_generate_rpa (struct hci_dev *hdev,u8 irk[16 ],bdaddr_t *rpa)
@@ -584,7 +585,7 @@ static u8 smp_random(struct smp_chan *smif (ret)return SMP_UNSPECIFIED ; -if (memcmp (smp->pcnf, confirm,sizeof (smp->pcnf)) !=0 ) { +if (crypto_memneq (smp->pcnf, confirm,sizeof (smp->pcnf))) {BT_ERR ("Pairing failed (confirmation values mismatch)" );return SMP_CONFIRM_FAILED ; }
Greg Kroah-Hartman
maintainerPATCH 15/60 ASoC: compress: Derive substream from stream based on direction
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Satish Babu Patakokila <[email protected]>
commit 01b8cedfd0422326caae308641dcadaa85e0ca72 upstream.
Currently compress driver hardcodes direction as playback to get substream from the stream. This results in getting the incorrect substream for compressed capture usecase.
To fix this, remove the hardcoding and derive substream based on the stream direction.
--- sound/soc/soc-compress.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/soc-compress.c +4 -2
@@ -68,7 +68,8 @@ out:static int soc_compr_open_fe (struct snd_compr_stream *cstream) {struct snd_soc_pcm_runtime *fe = cstream->private_data; -struct snd_pcm_substream *fe_substream = fe->pcm->streams[0 ].substream; +struct snd_pcm_substream *fe_substream = + fe->pcm->streams[cstream->direction].substream;struct snd_soc_platform *platform = fe->platform;struct snd_soc_dpcm *dpcm;struct snd_soc_dapm_widget_list *list;
@@ -415,7 +416,8 @@ static int soc_compr_set_params_fe(struc struct snd_compr_params *params) {struct snd_soc_pcm_runtime *fe = cstream->private_data; -struct snd_pcm_substream *fe_substream = fe->pcm->streams[0 ].substream; +struct snd_pcm_substream *fe_substream = + fe->pcm->streams[cstream->direction].substream;struct snd_soc_platform *platform = fe->platform;int ret =0 , stream;
Greg Kroah-Hartman
maintainerPATCH 16/60 PM / Domains: Fix unsafe iteration over modified list of device links
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit c6e83cac3eda5f7dd32ee1453df2f7abb5c6cd46 upstream.
pm_genpd_remove_subdomain() iterates over domain's master_links list and removes matching element thus it has to use safe version of list iteration.
--- drivers/base/power/domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/power/domain.c +2 -2
@@ -1673,7 +1673,7 @@ int pm_genpd_add_subdomain_names(const cint pm_genpd_remove_subdomain (struct generic_pm_domain *genpd,struct generic_pm_domain *subdomain) { -struct gpd_link *link; +struct gpd_link *l, *link;int ret = -EINVAL ;if (IS_ERR_OR_NULL (genpd) ||IS_ERR_OR_NULL (subdomain))
@@ -1682,7 +1682,7 @@ int pm_genpd_remove_subdomain(struct gen start:genpd_acquire_lock (genpd); -list_for_each_entry (link, &genpd->master_links, master_node) { +list_for_each_entry_safe (link, l, &genpd->master_links, master_node) {if (link->slave != subdomain)continue ;
Greg Kroah-Hartman
maintainerPATCH 17/60 PM / Domains: Fix unsafe iteration over modified list of domain providers
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit b556b15dc04e9b9b98790f04c21acf5e24f994b2 upstream.
of_genpd_del_provider() iterates over list of domain provides and removes matching element thus it has to use safe version of list iteration.
--- drivers/base/power/domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/power/domain.c +2 -2
@@ -2056,10 +2056,10 @@ EXPORT_SYMBOL_GPL(__of_genpd_add_provide*/ void of_genpd_del_provider (struct device_node *np) { -struct of_genpd_provider *cp; +struct of_genpd_provider *cp, *tmp;mutex_lock (&of_genpd_mutex); -list_for_each_entry (cp, &of_genpd_providers, link) { +list_for_each_entry_safe (cp, tmp, &of_genpd_providers, link) {if (cp->node == np) {list_del (&cp->link);of_node_put (cp->node);
Greg Kroah-Hartman
maintainerPATCH 18/60 scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails.
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
commit 62e62ffd95539b9220894a7900a619e0f3ef4756 upstream.
The enclosure_add_device() function should fail if it can't create the relevant sysfs links.
--- drivers/misc/enclosure.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/misc/enclosure.c +10 -4
@@ -320,6 +320,7 @@ int enclosure_add_device(struct enclosur struct device *dev) {struct enclosure_component *cdev; +int err;if (!edev || component >= edev->components)return -EINVAL ;
@@ -329,12 +330,17 @@ int enclosure_add_device(struct enclosurif (cdev->dev == dev)return -EEXIST ; -if (cdev->dev) +if (cdev->dev) {enclosure_remove_links (cdev); - -put_device (cdev->dev); +put_device (cdev->dev); + } cdev->dev =get_device (dev); -return enclosure_add_links (cdev); + err =enclosure_add_links (cdev); +if (err) { +put_device (cdev->dev); + cdev->dev =NULL ; + } +return err; }EXPORT_SYMBOL_GPL (enclosure_add_device);
Greg Kroah-Hartman
maintainerPATCH 19/60 powerpc/64: Fix atomic64_inc_not_zero() to return an int
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit 01e6a61aceb82e13bec29502a8eb70d9574f97ad upstream.
Although it's not documented anywhere, there is an expectation that atomic64_inc_not_zero() returns a result which fits in an int. This is the behaviour implemented on all arches except powerpc.
This has caused at least one bug in practice, in the percpu-refcount code, where the long result from our atomic64_inc_not_zero() was truncated to an int leading to lost references and stuck systems. That was worked around in that code in commit 966d2b04e070 ("percpu-refcount:
fix reference leak during percpu-atomic transition").
To the best of my grepping abilities there are no other callers in-tree which truncate the value, but we should fix it anyway. Because the breakage is subtle and potentially very harmful I'm also tagging it for stable.
Code generation is largely unaffected because in most cases the callers are just using the result for a test anyway. In particular the case of fget() that was mentioned in commit a6cf7ed5119f ("powerpc/atomic: Implement atomic*_inc_not_zero") generates exactly the same code.
--- arch/powerpc/include/asm/atomic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/atomic.h +2 -2
@@ -453,7 +453,7 @@ static __inline__ int atomic64_add_unles* Atomically increments @v by 1, so long as @v is non-zero. * Returns non-zero if @v was non-zero, and zero otherwise. */ -static __inline__long atomic64_inc_not_zero (atomic64_t *v) +static __inline__int atomic64_inc_not_zero (atomic64_t *v) {long t1, t2;
@@ -472,7 +472,7 @@ static __inline__ long atomic64_inc_not_ : "r" (&v->counter) : "cc", "xer", "memory"); - return t1; + return t1 != 0; }#endif /* __powerpc64__ */
Greg Kroah-Hartman
maintainerPATCH 20/60 powerpc: Fix emulation of mcrf in emulate_step()
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Blanchard <[email protected]>
commit 87c4b83e0fe234a1f0eed131ab6fa232036860d5 upstream.
The mcrf emulation code was using the CR field number directly as the shift value, without taking into account that CR fields are numbered from 0-7 starting at the high bits. That meant it was looking at the CR fields in the reverse order.
--- arch/powerpc/lib/sstep.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/lib/sstep.c +4 -2
@@ -687,8 +687,10 @@ int __kprobes analyse_instr(struct instrcase 19 :switch ((instr >>1 ) &0x3ff ) {case 0 :/* mcrf */ - rd = (instr >>21 ) &0x1c ; - ra = (instr >>16 ) &0x1c ; + rd =7 - ((instr >>23 ) &0x7 ); + ra =7 - ((instr >>18 ) &0x7 ); + rd *=4 ; + ra *=4 ; val = (regs->ccr >> ra) &0xf ; regs->ccr = (regs->ccr & ~(0xfUL << rd)) | (val << rd); goto instr_done;
Greg Kroah-Hartman
maintainerPATCH 21/60 powerpc: Fix emulation of mfocrf in emulate_step()
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Blanchard <[email protected]>
commit 64e756c55aa46fc18fd53e8f3598b73b528d8637 upstream.
Quoted 1 line
Quoted 1 line
From POWER4 onwards,
mfocrf()only places the specified CR field into
the destination GPR, and the rest of it is set to 0. The PowerPC AS from version 3.0 now requires this behaviour.
The emulation code currently puts the entire CR into the destination GPR. Fix it.
--- arch/powerpc/lib/sstep.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/powerpc/lib/sstep.c +13 -0
@@ -969,6 +969,19 @@ int __kprobes analyse_instr(struct instr#endif case 19 :/* mfcr */ +if ((instr >>20 ) &1 ) { + imm =0xf0000000UL ; +for (sh =0 ; sh <8 ; ++sh) { +if (instr & (0x80000 >> sh)) { + regs->gpr[rd] = regs->ccr & imm; +break ; + } + imm >>=4 ; + } + + goto instr_done; + } + regs->gpr[rd] = regs->ccr; regs->gpr[rd] &=0xffffffffUL ; goto instr_done;
Greg Kroah-Hartman
maintainerPATCH 22/60 powerpc/asm: Mark cr0 as clobbered in mftb()
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver O'Halloran <[email protected]>
commit 2400fd822f467cb4c886c879d8ad99feac9cf319 upstream.
The workaround for the CELL timebase bug does not correctly mark cr0 as being clobbered. This means GCC doesn't know that the asm block changes cr0 and might leave the result of an unrelated comparison in cr0 across the block, which we then trash, leading to basically random behaviour.
--- arch/powerpc/include/asm/reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/reg.h +1 -1
@@ -1231,7 +1231,7 @@ static inline unsigned long mfvtb (void) " .llong 0\n" \ ".previous" \ : "=r" (rval) \ - : "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL)); \ + : "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL) : "cr0"); \ rval;}) #else #define mftb() ({unsigned long rval; \
Greg Kroah-Hartman
maintainerPATCH 23/60 af_key: Fix sadb_x_ipsecrequest parsing
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit 096f41d3a8fcbb8dde7f71379b1ca85fe213eded upstream.
The parsing of sadb_x_ipsecrequest is broken in a number of ways. First of all we're not verifying sadb_x_ipsecrequest_len. This is needed when the structure carries addresses at the end. Worse we don't even look at the length when we parse those optional addresses.
The migration code had similar parsing code that's better but it also has some deficiencies. The length is overcounted first of all as it includes the header itself. It also fails to check the length before dereferencing the sa_family field.
This patch fixes those problems in parse_sockaddr_pair and then uses it in parse_ipsecrequest.
--- net/key/af_key.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
net/key/af_key.c +26 -21
@@ -65,6 +65,10 @@ struct pfkey_sock { } dump; }; +static int parse_sockaddr_pair (struct sockaddr *sa,int ext_len, +xfrm_address_t *saddr,xfrm_address_t *daddr, +u16 *family); +static inline struct pfkey_sock *pfkey_sk (struct sock *sk) {return (struct pfkey_sock *)sk;
@@ -1921,19 +1925,14 @@ parse_ipsecrequest(struct xfrm_policy *x/* addresses present only in tunnel mode */ if (t->mode ==XFRM_MODE_TUNNEL ) { -u8 *sa = (u8 *) (rq +1 ); -int family, socklen; +int err; - family =pfkey_sockaddr_extract ((struct sockaddr *)sa, - &t->saddr); -if (!family) -return -EINVAL ; - - socklen =pfkey_sockaddr_len (family); -if (pfkey_sockaddr_extract ((struct sockaddr *)(sa + socklen), - &t->id.daddr) != family) -return -EINVAL ; - t->encap_family = family; + err =parse_sockaddr_pair ( + (struct sockaddr *)(rq +1 ), + rq->sadb_x_ipsecrequest_len -sizeof (*rq), + &t->saddr, &t->id.daddr, &t->encap_family); +if (err) +return err; }else t->encap_family = xp->family;
@@ -1953,7 +1952,11 @@ parse_ipsecrequests(struct xfrm_policy *if (pol->sadb_x_policy_len *8 <sizeof (struct sadb_x_policy ))return -EINVAL ; -while (len >=sizeof (struct sadb_x_ipsecrequest )) { +while (len >=sizeof (*rq)) { +if (len < rq->sadb_x_ipsecrequest_len || + rq->sadb_x_ipsecrequest_len <sizeof (*rq)) +return -EINVAL ; +if ((err =parse_ipsecrequest (xp, rq)) <0 )return err; len -= rq->sadb_x_ipsecrequest_len;
@@ -2416,7 +2419,6 @@ out:return err; } -#ifdef CONFIG_NET_KEY_MIGRATE static int pfkey_sockaddr_pair_size (sa_family_t family) {return PFKEY_ALIGN8 (pfkey_sockaddr_len (family) *2 );
@@ -2428,7 +2430,7 @@ static int parse_sockaddr_pair(struct so {int af, socklen; -if (ext_len <pfkey_sockaddr_pair_size (sa->sa_family)) +if (ext_len <2 || ext_len <pfkey_sockaddr_pair_size (sa->sa_family))return -EINVAL ; af =pfkey_sockaddr_extract (sa, saddr);
@@ -2444,6 +2446,7 @@ static int parse_sockaddr_pair(struct soreturn 0 ; } +#ifdef CONFIG_NET_KEY_MIGRATE static int ipsecrequests_to_migrate (struct sadb_x_ipsecrequest *rq1,int len,struct xfrm_migrate *m) {
@@ -2451,13 +2454,14 @@ static int ipsecrequests_to_migrate(strustruct sadb_x_ipsecrequest *rq2;int mode; -if (len <=sizeof (struct sadb_x_ipsecrequest ) || - len < rq1->sadb_x_ipsecrequest_len) +if (len <sizeof (*rq1) || + len < rq1->sadb_x_ipsecrequest_len || + rq1->sadb_x_ipsecrequest_len <sizeof (*rq1))return -EINVAL ;/* old endoints */ err =parse_sockaddr_pair ((struct sockaddr *)(rq1 +1 ), - rq1->sadb_x_ipsecrequest_len, + rq1->sadb_x_ipsecrequest_len -sizeof (*rq1), &m->old_saddr, &m->old_daddr, &m->old_family);if (err)
@@ -2466,13 +2470,14 @@ static int ipsecrequests_to_migrate(stru rq2 = (struct sadb_x_ipsecrequest *)((u8 *)rq1 + rq1->sadb_x_ipsecrequest_len); len -= rq1->sadb_x_ipsecrequest_len; -if (len <=sizeof (struct sadb_x_ipsecrequest ) || - len < rq2->sadb_x_ipsecrequest_len) +if (len <=sizeof (*rq2) || + len < rq2->sadb_x_ipsecrequest_len || + rq2->sadb_x_ipsecrequest_len <sizeof (*rq2))return -EINVAL ;/* new endpoints */ err =parse_sockaddr_pair ((struct sockaddr *)(rq2 +1 ), - rq2->sadb_x_ipsecrequest_len, + rq2->sadb_x_ipsecrequest_len -sizeof (*rq2), &m->new_saddr, &m->new_daddr, &m->new_family);if (err)
Greg Kroah-Hartman
maintainerPATCH 24/60 PCI/PM: Restore the status of PCI devices across hibernation
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Yu <[email protected]>
commit e60514bd4485c0c7c5a7cf779b200ce0b95c70d6 upstream.
Currently we saw a lot of "No irq handler" errors during hibernation, which caused the system hang finally:
ata4.00: qc timeout (cmd 0xec)
ata4.00: failed to IDENTIFY (I/O error, err_mask=0x4) ata4.00: revalidation failed (errno=-5)
ata4: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
do_IRQ: 31.151 No irq handler for vector
According to above logs, there is an interrupt triggered and it is dispatched to CPU31 with a vector number 151, but there is no handler for it, thus this IRQ will not get acked and will cause an IRQ flood which kills the system. To be more specific, the 31.151 is an interrupt from the AHCI host controller.
After some investigation, the reason why this issue is triggered is because the thaw_noirq() function does not restore the MSI/MSI-X settings across hibernation.
The scenario is illustrated below:
1. Before hibernation, IRQ 34 is the handler for the AHCI device, which is bound to CPU31.
2. Hibernation starts, the AHCI device is put into low power state.
3. All the nonboot CPUs are put offline, so IRQ 34 has to be migrated to the last alive one - CPU0.
4. After the snapshot has been created, all the nonboot CPUs are brought up again; IRQ 34 remains bound to CPU0.
5. AHCI devices are put into D0.
6. The snapshot is written to the disk.
The issue is triggered in step 6. The AHCI interrupt should be delivered to CPU0, however it is delivered to the original CPU31 instead, which causes the "No irq handler" issue.
Ying Huang has provided a clue that, in step 3 it is possible that writing to the register might not take effect as the PCI devices have been suspended.
In step 3, the IRQ 34 affinity should be modified from CPU31 to CPU0, but in fact it is not. In __pci_write_msi_msg(), if the device is already in low power state, the low level MSI message entry will not be updated but cached. During the device restore process after a normal suspend/resume, pci_restore_msi_state() writes the cached MSI back to the hardware.
But this is not the case for hibernation. pci_restore_msi_state() is not currently called in pci_pm_thaw_noirq(), although pci_save_state() has saved the necessary PCI cached information in pci_pm_freeze_noirq().
Restore the PCI status for the device during hibernation. Otherwise the status might be lost across hibernation (for example, settings for MSI, MSI-X, ATS, ACS, IOV, etc.), which might cause problems during hibernation.
--- drivers/pci/pci-driver.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/pci-driver.c +1 -0
@@ -925,6 +925,7 @@ static int pci_pm_thaw_noirq(struct devireturn pci_legacy_resume_early (dev);pci_update_current_state (pci_dev,PCI_D0 ); +pci_restore_state (pci_dev);if (drv && drv->pm && drv->pm->thaw_noirq) error = drv->pm->thaw_noirq (dev);
Greg Kroah-Hartman
maintainerPATCH 25/60 xhci: fix 20000ms port resume timeout
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit a54408d0a004757789863d74e29c2297edae0b4d upstream.
A uncleared PLC (port link change) bit will prevent furuther port event interrupts for that port. Leaving it uncleared caused get_port_status() to timeout after 20000ms while waiting to get the final port event interrupt for resume -> U0 state change.
This is a targeted fix for a specific case where we get a port resume event racing with xhci resume. The port event interrupt handler notices xHC is not yet running and bails out early, leaving PLC uncleared.
The whole xhci port resuming needs more attention, but while working on it it anyways makes sense to always ensure PLC is cleared in get_port_status before setting a new link state and waiting for its completion.
--- drivers/usb/host/xhci-hub.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-hub.c +3 -0
@@ -651,6 +651,9 @@ static u32 xhci_get_port_status(struct uclear_bit (wIndex, &bus_state->resuming_ports);set_bit (wIndex, &bus_state->rexit_ports); + +xhci_test_and_clear_bit (xhci, port_array, wIndex, +PORT_PLC );xhci_set_link_state (xhci, port_array, wIndex,XDEV_U0 );
Greg Kroah-Hartman
maintainerPATCH 26/60 xhci: Fix NULL pointer dereference when cleaning up streams for removed host
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 4b895868bb2da60a386a17cde3bf9ecbc70c79f4 upstream.
This off by one in stream_id indexing caused NULL pointer dereference and soft lockup on machines with USB attached SCSI devices connected to a hotpluggable xhci controller.
The code that cleans up pending URBs for dead hosts tried to dereference a stream ring at the invalid stream_id 0. ep->stream_info->stream_rings[0] doesn't point to a ring.
Start looping stream_id from 1 like in all the other places in the driver, and check that the ring exists before trying to kill URBs on it.
--- drivers/usb/host/xhci-ring.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-ring.c +7 -4
@@ -782,13 +782,16 @@ static void xhci_kill_endpoint_urbs(stru (ep->ep_state & EP_GETTING_NO_STREAMS)) {int stream_id; -for (stream_id =0 ; stream_id < ep->stream_info->num_streams; +for (stream_id =1 ; stream_id < ep->stream_info->num_streams; stream_id++) { + ring = ep->stream_info->stream_rings[stream_id]; +if (!ring) +continue ; +xhci_dbg_trace (xhci, trace_xhci_dbg_cancel_urb,"Killing URBs for slot ID %u, ep index %u, stream %u" , - slot_id, ep_index, stream_id +1 ); -xhci_kill_ring_urbs (xhci, - ep->stream_info->stream_rings[stream_id]); + slot_id, ep_index, stream_id); +xhci_kill_ring_urbs (xhci, ring); } } else { ring = ep->ring;
Greg Kroah-Hartman
maintainerPATCH 27/60 usb: storage: return on error to avoid a null pointer dereference
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit 446230f52a5bef593554510302465eabab45a372 upstream.
When us->extra is null the driver is not initialized, however, a later call to osd200_scsi_to_ata is made that dereferences us->extra, causing a null pointer dereference. The code currently detects and reports that the driver is not initialized; add a return to avoid the subsequent dereference issue in this check.
Thanks to Alan Stern for pointing out that srb->result needs setting to DID_ERROR << 16
Detected by CoverityScan, CID#100308 ("Dereference after null check")
--- drivers/usb/storage/isd200.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/storage/isd200.c +4 -1
@@ -1522,8 +1522,11 @@ static void isd200_ata_command(struct sc/* Make sure driver was initialized */ -if (us->extra ==NULL ) +if (us->extra ==NULL ) {usb_stor_dbg (us,"ERROR Driver not initialized\n" ); + srb->result =DID_ERROR <<16 ; +return ; + }scsi_set_resid (srb,0 );/* scsi_bufflen might change in protocol translation to ata */
Greg Kroah-Hartman
maintainerPATCH 28/60 USB: cdc-acm: add device-id for quirky printer
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit fe855789d605590e57f9cd968d85ecce46f5c3fd upstream.
Add device-id entry for DATECS FP-2000 fiscal printer needing the NO_UNION_NORMAL quirk.
--- drivers/usb/class/cdc-acm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/class/cdc-acm.c +3 -0
@@ -1776,6 +1776,9 @@ static const struct usb_device_id acm_id { USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */ .driver_info =NO_UNION_NORMAL ,/* reports zero length descriptor */ }, + { USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */ + .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ + }, { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */ .driver_info = CLEAR_HALT_CONDITIONS,
Greg Kroah-Hartman
maintainerPATCH 29/60 usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yoshihiro Shimoda <[email protected]>
commit 59a0879a0e17b2e43ecdc5e3299da85b8410d7ce upstream.
This patch fixes an issue that some registers may be not initialized after resume if the USBHSF_RUNTIME_PWCTRL is not set. Otherwise, if a cable is not connected, the driver will not enable INTENB0.VBSE after resume. And then, the driver cannot detect the VBUS.
--- drivers/usb/renesas_usbhs/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/renesas_usbhs/common.c +3 -1
@@ -699,8 +699,10 @@ static int usbhsc_resume(struct device *struct usbhs_priv *priv =dev_get_drvdata (dev);struct platform_device *pdev =usbhs_priv_to_pdev (priv); -if (!usbhsc_flags_has (priv,USBHSF_RUNTIME_PWCTRL )) +if (!usbhsc_flags_has (priv,USBHSF_RUNTIME_PWCTRL )) {usbhsc_power_ctrl (priv,1 ); +usbhs_mod_autonomy_mode (priv); + }usbhs_platform_call (priv, phy_reset, pdev);
Greg Kroah-Hartman
maintainerPATCH 30/60 md: dont use flush_signals in userspace processes
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit f9c79bc05a2a91f4fba8bfd653579e066714b1ec upstream.
The function flush_signals clears all pending signals for the process. It may be used by kernel threads when we need to prepare a kernel thread for responding to signals. However using this function for an userspaces processes is incorrect - clearing signals without the program expecting it can cause misbehavior.
The raid1 and raid5 code uses flush_signals in its request routine because it wants to prepare for an interruptible wait. This patch drops flush_signals and uses sigprocmask instead to block all signals (including SIGKILL) around the schedule() call. The signals are not lost, but the schedule() call won't respond to them.
--- drivers/md/raid1.c | 5 ++++- drivers/md/raid5.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/md/raid1.c +4 -1
@@ -1120,13 +1120,16 @@ static void make_request(struct mddev *m*/ DEFINE_WAIT (w);for (;;) { -flush_signals (current); +sigset_t full, old;prepare_to_wait (&conf->wait_barrier, &w,TASK_INTERRUPTIBLE );if (bio_end_sector (bio) <= mddev->suspend_lo || bio->bi_iter.bi_sector >= mddev->suspend_hi)break ; +sigfillset (&full); +sigprocmask (SIG_BLOCK , &full, &old);schedule (); +sigprocmask (SIG_SETMASK , &old,NULL ); }finish_wait (&conf->wait_barrier, &w); }
drivers/md/raid5.c +4 -1
@@ -4705,12 +4705,15 @@ static void make_request(struct mddev *m* userspace, we want an interruptible * wait. */ -flush_signals (current);prepare_to_wait (&conf->wait_for_overlap, &w,TASK_INTERRUPTIBLE );if (logical_sector >= mddev->suspend_lo && logical_sector < mddev->suspend_hi) { +sigset_t full, old; +sigfillset (&full); +sigprocmask (SIG_BLOCK , &full, &old);schedule (); +sigprocmask (SIG_SETMASK , &old,NULL ); do_prepare = true; } goto retry;
Greg Kroah-Hartman
maintainerPATCH 31/60 Raid5 should update rdev->sectors after reshape
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiao Ni <[email protected]>
commit b5d27718f38843a74552e9a93d32e2391fd3999f upstream.
The raid5 md device is created by the disks which we don't use the total size. For example, the size of the device is 5G and it just uses 3G of the devices to create one raid5 device. Then change the chunksize and wait reshape to finish. After reshape finishing stop the raid and assemble it again. It fails.
mdadm -CR /dev/md0 -l5 -n3 /dev/loop[0-2] --size=3G --chunk=32 --assume-clean mdadm /dev/md0 --grow --chunk=64
wait reshape to finish
mdadm -S /dev/md0
mdadm -As
The error messages:
[197519.814302] md: loop1 does not have a valid v1.2 superblock, not importing! [197519.821686] md: md_import_device returned -22
After reshape the data offset is changed. It selects backwards direction in this condition. In function super_1_load it compares the available space of the underlying device with sb->data_size. The new data offset gets bigger after reshape. So super_1_load returns -EINVAL. rdev->sectors is updated in md_finish_reshape. Then sb->data_size is set in super_1_sync based on rdev->sectors. So add md_finish_reshape in end_reshape.
--- drivers/md/raid5.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/md/raid5.c +1 -3
@@ -6722,12 +6722,10 @@ static void end_reshape(struct r5conf *c {if (!test_bit (MD_RECOVERY_INTR , &conf->mddev->recovery)) { -struct md_rdev *rdev;spin_lock_irq (&conf->device_lock); conf->previous_raid_disks = conf->raid_disks; -rdev_for_each (rdev, conf->mddev) - rdev->data_offset = rdev->new_data_offset; +md_finish_reshape (conf->mddev);smp_wmb (); conf->reshape_progress = MaxSector;spin_unlock_irq (&conf->device_lock);
Greg Kroah-Hartman
maintainerPATCH 32/60 s390/syscalls: Fix out of bounds arguments access
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
commit c46fc0424ced3fb71208e72bd597d91b9169a781 upstream.
Zorro reported following crash while having enabled syscall tracing (CONFIG_FTRACE_SYSCALLS):
Unable to handle kernel pointer dereference at virtual ... Oops: 0011 [#1] SMP DEBUG_PAGEALLOC
SNIP
Call Trace: ([<000000000024d79c>] ftrace_syscall_enter+0xec/0x1d8) [<00000000001099c6>] do_syscall_trace_enter+0x236/0x2f8 [<0000000000730f1c>] sysc_tracesys+0x1a/0x32 [<000003fffcf946a2>] 0x3fffcf946a2 INFO: lockdep is turned off. Last Breaking-Event-Address: [<000000000022dd44>] rb_event_data+0x34/0x40 ---[ end trace 8c795f86b1b3f7b9 ]---
The crash happens in syscall_get_arguments function for syscalls with zero arguments, that will try to access first argument (args[0]) in event entry, but it's not allocated.
Bail out of there are no arguments.
--- arch/s390/include/asm/syscall.h | 6 ++++++ 1 file changed, 6 insertions(+)
arch/s390/include/asm/syscall.h +6 -0
@@ -64,6 +64,12 @@ static inline void syscall_get_arguments {unsigned long mask =-1UL ; +/* +* No arguments for this syscall, there's nothing to do. +*/ +if (!n) +return ; +BUG_ON (i + n >6 );#ifdef CONFIG_COMPAT if (test_tsk_thread_flag (task,TIF_31BIT ))
Greg Kroah-Hartman
maintainerPATCH 34/60 f2fs: Dont clear SGID when inheriting ACLs
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
commit c925dc162f770578ff4a65ec9b08270382dba9e6 upstream.
This patch copies commit b7f8a09f80:
"btrfs: Don't clear SGID when inheriting ACLs" written by Jan.
--- fs/f2fs/acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/acl.c +1 -1
@@ -206,7 +206,7 @@ static int __f2fs_set_acl(struct inode *switch (type) {case ACL_TYPE_ACCESS : name_index =F2FS_XATTR_INDEX_POSIX_ACL_ACCESS ; -if (acl) { +if (acl && !ipage) { error =posix_acl_update_mode (inode, &inode->i_mode, &acl);if (error)return error;
Greg Kroah-Hartman
maintainerPATCH 35/60 vfio: Fix group release deadlock
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit 811642d8d8a82c0cce8dc2debfdaf23c5a144839 upstream.
If vfio_iommu_group_notifier() acquires a group reference and that reference becomes the last reference to the group, then vfio_group_put introduces a deadlock code path where we're trying to unregister from the iommu notifier chain from within a callout of that chain. Use a work_struct to release this reference asynchronously.
--- drivers/vfio/vfio.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/vfio/vfio.c +36 -1
@@ -278,6 +278,34 @@ static void vfio_group_put(struct vfio_gkref_put_mutex (&group->kref, vfio_group_release, &vfio.group_lock); } +struct vfio_group_put_work { +struct work_struct work; +struct vfio_group *group; +}; + +static void vfio_group_put_bg (struct work_struct *work) +{ +struct vfio_group_put_work *do_work; + + do_work = container_of(work, struct vfio_group_put_work, work); + +vfio_group_put (do_work->group); +kfree (do_work); +} + +static void vfio_group_schedule_put (struct vfio_group *group) +{ +struct vfio_group_put_work *do_work; + + do_work =kmalloc (sizeof (*do_work),GFP_KERNEL ); +if (WARN_ON (!do_work)) +return ; + +INIT_WORK (&do_work->work, vfio_group_put_bg); + do_work->group = group; +schedule_work (&do_work->work); +} +/* Assume group_lock or group reference is held */ static void vfio_group_get (struct vfio_group *group) {
@@ -553,7 +581,14 @@ static int vfio_iommu_group_notifier(strbreak ; } -vfio_group_put (group); +/* +* If we're the last reference to the group, the group will be +* released, which includes unregistering the iommu group notifier. +* We hold a read-lock on that notifier list, unregistering needs +* a write-lock... deadlock. Release our reference asynchronously +* to avoid that situation. +*/ +vfio_group_schedule_put (group);return NOTIFY_OK ; }
Greg Kroah-Hartman
maintainerPATCH 36/60 vfio: New external user group/file match
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit 5d6dee80a1e94cc284d03e06d930e60e8d3ecf7d upstream.
At the point where the kvm-vfio pseudo device wants to release its vfio group reference, we can't always acquire a new reference to make that happen. The group can be in a state where we wouldn't allow a new reference to be added. This new helper function allows a caller to match a file to a group to facilitate this. Given a file and group, report if they match. Thus the caller needs to already have a group reference to match to the file. This allows the deletion of a group without acquiring a new reference.
--- drivers/vfio/vfio.c | 9 +++++++++ include/linux/vfio.h | 2 ++ virt/kvm/vfio.c | 27 +++++++++++++++++++-------- 3 files changed, 30 insertions(+), 8 deletions(-)
drivers/vfio/vfio.c +9 -0
@@ -1436,6 +1436,15 @@ void vfio_group_put_external_user(struct }EXPORT_SYMBOL_GPL (vfio_group_put_external_user); +bool vfio_external_group_match_file (struct vfio_group *test_group, +struct file *filep) +{ +struct vfio_group *group = filep->private_data; + +return (filep->f_op == &vfio_group_fops) && (group == test_group); +} +EXPORT_SYMBOL_GPL (vfio_external_group_match_file); +int vfio_external_user_iommu_id (struct vfio_group *group) {return iommu_group_id (group->iommu_group);
include/linux/vfio.h +2 -0
@@ -81,6 +81,8 @@ extern void vfio_unregister_iommu_driver*/ extern struct vfio_group *vfio_group_get_external_user (struct file *filep);extern void vfio_group_put_external_user (struct vfio_group *group); +extern bool vfio_external_group_match_file (struct vfio_group *group, +struct file *filep);extern int vfio_external_user_iommu_id (struct vfio_group *group);extern long vfio_external_check_extension (struct vfio_group *group,unsigned long arg);
virt/kvm/vfio.c +19 -8
@@ -47,6 +47,22 @@ static struct vfio_group *kvm_vfio_groupreturn vfio_group; } +static bool kvm_vfio_external_group_match_file (struct vfio_group *group, +struct file *filep) +{ +bool ret, (*fn)(struct vfio_group *,struct file *); + + fn =symbol_get (vfio_external_group_match_file); +if (!fn) +return false; + + ret =fn (group, filep); + +symbol_put (vfio_external_group_match_file); + +return ret; +} +static void kvm_vfio_group_put_external_user (struct vfio_group *vfio_group) {void (*fn)(struct vfio_group *);
@@ -169,18 +185,13 @@ static int kvm_vfio_set_group(struct kvmif (!f.file)return -EBADF ; - vfio_group =kvm_vfio_group_get_external_user (f.file); -fdput (f); - -if (IS_ERR (vfio_group)) -return PTR_ERR (vfio_group); - ret = -ENOENT ;mutex_lock (&kv->lock);list_for_each_entry (kvg, &kv->group_list, node) { -if (kvg->vfio_group != vfio_group) +if (!kvm_vfio_external_group_match_file (kvg->vfio_group, + f.file))continue ;list_del (&kvg->node);
@@ -192,7 +203,7 @@ static int kvm_vfio_set_group(struct kvmmutex_unlock (&kv->lock); -kvm_vfio_group_put_external_user (vfio_group); +fdput (f);kvm_vfio_update_coherency (dev);
Greg Kroah-Hartman
maintainerPATCH 37/60 MIPS: Fix mips_atomic_set() retry condition
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 2ec420b26f7b6ff332393f0bb5a7d245f7ad87f0 upstream.
The inline asm retry check in the MIPS_ATOMIC_SET operation of the sysmips system call has been backwards since commit f1e39a4a616c ("MIPS:
Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler") merged in v2.6.32, resulting in the non R10000_LLSC_WAR case retrying until the operation was inatomic, before returning the new value that was probably just written multiple times instead of the old value.
Invert the branch condition to fix that particular issue.
Patchwork: https://patchwork.linux-mips.org/patch/16148/
--- arch/mips/kernel/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/syscall.c +1 -1
@@ -140,7 +140,7 @@ static inline int mips_atomic_set(unsign"1: ll %[old], (%[addr]) \n" " move %[tmp], %[new] \n" "2: sc %[tmp], (%[addr]) \n" -" bnez %[tmp], 4f \n" +" beqz %[tmp], 4f \n" "3: \n" " .subsection 2 \n" "4: b 1b \n"
Greg Kroah-Hartman
maintainerPATCH 38/60 MIPS: Fix mips_atomic_set() with EVA
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 4915e1b043d6286928207b1f6968197b50407294 upstream.
EVA linked loads (LLE) and conditional stores (SCE) should be used on EVA kernels for the MIPS_ATOMIC_SET operation of the sysmips system call, or else the atomic set will apply to the kernel view of the virtual address space (potentially unmapped on EVA kernels) rather than the user view (TLB mapped).
Patchwork: https://patchwork.linux-mips.org/patch/16151/
--- arch/mips/kernel/syscall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/mips/kernel/syscall.c +5 -2
@@ -28,6 +28,7 @@#include <linux/elf.h> #include <asm/asm.h> +#include <asm/asm-eva.h> #include <asm/branch.h> #include <asm/cachectl.h> #include <asm/cacheflush.h>
@@ -137,9 +138,11 @@ static inline int mips_atomic_set(unsign __asm__ __volatile__ (" .set arch=r4000 \n" " li %[err], 0 \n" -"1: ll %[old], (%[addr]) \n" +"1: \n" + user_ll("%[old]", "(%[addr])")" move %[tmp], %[new] \n" -"2: sc %[tmp], (%[addr]) \n" +"2: \n" + user_sc("%[tmp]", "(%[addr])")" beqz %[tmp], 4f \n" "3: \n" " .subsection 2 \n"
Greg Kroah-Hartman
maintainerPATCH 39/60 MIPS: Negate error syscall return in trace
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 4f32a39d49b25eaa66d2420f1f03d371ea4cd906 upstream.
The sys_exit trace event takes a single return value for the system call, which MIPS passes the value of the $v0 (result) register, however MIPS returns positive error codes in $v0 with $a3 specifying that $v0 contains an error code. As a result erroring system calls are traced returning positive error numbers that can't always be distinguished from success.
Use regs_return_value() to negate the error code if $a3 is set.
Patchwork: https://patchwork.linux-mips.org/patch/16651/
--- arch/mips/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +1 -1
@@ -802,7 +802,7 @@ asmlinkage void syscall_trace_leave(struaudit_syscall_exit (regs);if (unlikely (test_thread_flag (TIF_SYSCALL_TRACEPOINT ))) -trace_sys_exit (regs, regs->regs[2 ]); +trace_sys_exit (regs,regs_return_value (regs));if (test_thread_flag (TIF_SYSCALL_TRACE ))tracehook_report_syscall_exit (regs,0 );
Greg Kroah-Hartman
maintainerPATCH 40/60 x86/acpi: Prevent out of bound access caused by broken ACPI tables
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seunghun Han <[email protected]>
commit dad5ab0db8deac535d03e3fe3d8f2892173fa6a4 upstream.
The bus_irq argument of mp_override_legacy_irq() is used as the index into the isa_irq_to_gsi[] array. The bus_irq argument originates from ACPI_MADT_TYPE_IO_APIC and ACPI_MADT_TYPE_INTERRUPT items in the ACPI tables, but is nowhere sanity checked.
That allows broken or malicious ACPI tables to overwrite memory, which might cause malfunction, panic or arbitrary code execution.
Add a sanity check and emit a warning when that triggers.
[ tglx: Added warning and rewrote changelog ]
--- arch/x86/kernel/acpi/boot.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/x86/kernel/acpi/boot.c +8 -0
@@ -316,6 +316,14 @@ static void __init mp_override_legacy_irstruct mpc_intsrc mp_irq;/* +* Check bus_irq boundary. +*/ +if (bus_irq >=NR_IRQS_LEGACY ) { +pr_warn ("Invalid bus_irq %u for legacy override\n" , bus_irq); +return ; + } + +/* * Convert 'gsi' to 'ioapic.pin'. */ ioapic =mp_find_ioapic (gsi);
Greg Kroah-Hartman
maintainerPATCH 41/60 MIPS: Save static registers before sysmips
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 49955d84cd9ccdca5a16a495e448e1a06fad9e49 upstream.
The MIPS sysmips system call handler may return directly from the MIPS_ATOMIC_SET case (mips_atomic_set()) to syscall_exit. This path restores the static (callee saved) registers, however they won't have been saved on entry to the system call.
Use the save_static_function() macro to create a __sys_sysmips wrapper function which saves the static registers before calling sys_sysmips, so that the correct static register state is restored by syscall_exit.
Patchwork: https://patchwork.linux-mips.org/patch/16149/
--- arch/mips/kernel/scall32-o32.S | 2 +- arch/mips/kernel/scall64-64.S | 2 +- arch/mips/kernel/scall64-n32.S | 2 +- arch/mips/kernel/scall64-o32.S | 2 +- arch/mips/kernel/syscall.c | 6 ++++++ 5 files changed, 10 insertions(+), 4 deletions(-)
arch/mips/kernel/scall32-o32.S +1 -1
@@ -361,7 +361,7 @@ EXPORT(sys_call_table) PTR sys_writev PTR sys_cacheflush PTR sys_cachectl - PTR sys_sysmips + PTR __sys_sysmips PTR sys_ni_syscall /* 4150 */ PTR sys_getsid PTR sys_fdatasync
arch/mips/kernel/scall64-64.S +1 -1
@@ -318,7 +318,7 @@ EXPORT(sys_call_table) PTR sys_sched_getaffinity PTR sys_cacheflush PTR sys_cachectl - PTR sys_sysmips + PTR __sys_sysmips PTR sys_io_setup /* 5200 */ PTR sys_io_destroy PTR sys_io_getevents
arch/mips/kernel/scall64-n32.S +1 -1
@@ -307,7 +307,7 @@ EXPORT(sysn32_call_table) PTR compat_sys_sched_getaffinity PTR sys_cacheflush PTR sys_cachectl - PTR sys_sysmips + PTR __sys_sysmips PTR compat_sys_io_setup /* 6200 */ PTR sys_io_destroy PTR compat_sys_io_getevents
arch/mips/kernel/scall64-o32.S +1 -1
@@ -358,7 +358,7 @@ EXPORT(sys32_call_table) PTR compat_sys_writev PTR sys_cacheflush PTR sys_cachectl - PTR sys_sysmips + PTR __sys_sysmips PTR sys_ni_syscall /* 4150 */ PTR sys_getsid PTR sys_fdatasync
arch/mips/kernel/syscall.c +6 -0
@@ -200,6 +200,12 @@ static inline int mips_atomic_set(unsignunreachable (); } +/* +* mips_atomic_set() normally returns directly via syscall_exit potentially +* clobbering static registers, so be sure to preserve them. +*/ +save_static_function (sys_sysmips); + SYSCALL_DEFINE3(sysmips, long, cmd, long, arg1, long, arg2) {switch (cmd) {
Greg Kroah-Hartman
maintainerPATCH 42/60 MIPS: Actually decode JALX in `__compute_return_epc_for_insn
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit a9db101b735a9d49295326ae41f610f6da62b08c upstream.
Complement commit fb6883e5809c ("MIPS: microMIPS: Support handling of delay slots.") and actually decode the regular MIPS JALX major instruction opcode, the handling of which has been added with the said commit for EPC calculation in `__compute_return_epc_for_insn'.
Patchwork: https://patchwork.linux-mips.org/patch/16394/
--- arch/mips/kernel/branch.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/branch.c +1 -0
@@ -493,6 +493,7 @@ int __compute_return_epc_for_insn(struct/* * These are unconditional and in j_format. */ +case jalx_op:case jal_op: regs->regs[31 ] = regs->cp0_epc +8 ;case j_op:
Greg Kroah-Hartman
maintainerPATCH 43/60 MIPS: Fix unaligned PC interpretation in `compute_return_epc
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 11a3799dbeb620bf0400b1fda5cc2c6bea55f20a upstream.
Fix a regression introduced with commit fb6883e5809c ("MIPS: microMIPS:
Support handling of delay slots.") and defer to `__compute_return_epc' if the ISA bit is set in EPC with non-MIPS16, non-microMIPS hardware, which will then arrange for a SIGBUS due to an unaligned instruction reference. Returning EPC here is never correct as the API defines this function's result to be either a negative error code on failure or one of 0 and BRANCH_LIKELY_TAKEN on success.
Patchwork: https://patchwork.linux-mips.org/patch/16395/
--- arch/mips/include/asm/branch.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/mips/include/asm/branch.h +1 -4
@@ -74,10 +74,7 @@ static inline int compute_return_epc(strreturn __microMIPS_compute_return_epc (regs);if (cpu_has_mips16)return __MIPS16e_compute_return_epc (regs); -return regs->cp0_epc; - } - -if (!delay_slot (regs)) { + }else if (!delay_slot (regs)) { regs->cp0_epc +=4 ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 44/60 MIPS: math-emu: Prevent wrong ISA mode instruction emulation
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 13769ebad0c42738831787e27c7c7f982e7da579 upstream.
Terminate FPU emulation immediately whenever an ISA mode switch has been observed. This is so that we do not interpret machine code in the wrong mode, for example when a regular MIPS FPU instruction has been placed in a delay slot of a jump that switches into the MIPS16 mode, as with the following code (taken from a GCC test suite case):
00400650 <set_fast_math>:
400650: 3c020100 lui v0,0x100
400654: 03e00008 jr ra
400658: 44c2f800 ctc1 v0,c1_fcsr
40065c: 00000000 nop
[...]
004012d0 <__libc_csu_init>:
4012d0: f000 6a02 li v0,2
4012d4: f150 0b1c la v1,3f9430 <_DYNAMIC-0x6df0>
4012d8: f400 3240 sll v0,16
4012dc: e269 addu v0,v1
4012de: 659a move gp,v0
4012e0: f00c 64f6 save a0-a2,48,ra,s0-s1
4012e4: 673c move s1,gp
4012e6: f010 9978 lw v1,-32744(s1)
4012ea: d204 sw v0,16(sp) 4012ec: eb40 jalr v1 4012ee: 653b move t9,v1 4012f0: f010 997c lw v1,-32740(s1) 4012f4: f030 9920 lw s1,-32736(s1) 4012f8: e32f subu v1,s1 4012fa: 326b sra v0,v1,2 4012fc: d206 sw v0,24(sp) 4012fe: 220c beqz v0,401318 <__libc_csu_init+0x48> 401300: 6800 li s0,0 401302: 99e0 lw a3,0(s1) 401304: 4801 addiu s0,1 401306: 960e lw a2,56(sp) 401308: 4904 addiu s1,4 40130a: 950d lw a1,52(sp) 40130c: 940c lw a0,48(sp) 40130e: ef40 jalr a3 401310: 653f move t9,a3 401312: 9206 lw v0,24(sp) 401314: ea0a cmp v0,s0 401316: 61f5 btnez 401302 <__libc_csu_init+0x32> 401318: 6476 restore 48,ra,s0-s1 40131a: e8a0 jrc ra
Here set_fast_math' is called from 40130e' (40130f' with the ISA bit) and emulation triggers for the CTC1 instruction. As it is in a jump delay slot emulation continues from 401312' (`401313' with the ISA bit). However we have no path to handle MIPS16 FPU code emulation, because there are no MIPS16 FPU instructions. So the default emulation path is taken, interpreting a 32-bit word fetched by get_user' from 401313' as a regular MIPS instruction, which is:
401313: f5ea0a92 sdc1 $f10,2706(t7)
This makes the FPU emulator proceed with the supposed SDC1 instruction and consequently makes the program considered here terminate with SIGSEGV.
A similar although less severe issue exists with pure-microMIPS processors in the case where similarly an FPU instruction is emulated in a delay slot of a register jump that (incorrectly) switches into the regular MIPS mode. A subsequent instruction fetch from the jump's target is supposed to cause an Address Error exception, however instead we proceed with regular MIPS FPU emulation.
For simplicity then, always terminate the emulation loop whenever a mode change is detected, denoted by an ISA mode bit flip. As from commit 377cb1b6c16a ("MIPS: Disable MIPS16/microMIPS crap for platforms not supporting these ASEs.") the result of `get_isa16_mode' can be hardcoded to 0, so we need to examine the ISA mode bit by hand.
This complements commit 102cedc32a6e ("MIPS: microMIPS: Floating point support.") which added JALX decoding to FPU emulation.
Patchwork: https://patchwork.linux-mips.org/patch/16393/
--- arch/mips/math-emu/cp1emu.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/mips/math-emu/cp1emu.c +38 -0
@@ -1856,6 +1856,35 @@ dcopuop:return 0 ; } +/* +* Emulate FPU instructions. +* +* If we use FPU hardware, then we have been typically called to handle +* an unimplemented operation, such as where an operand is a NaN or +* denormalized. In that case exit the emulation loop after a single +* iteration so as to let hardware execute any subsequent instructions. +* +* If we have no FPU hardware or it has been disabled, then continue +* emulating floating-point instructions until one of these conditions +* has occurred: +* +* - a non-FPU instruction has been encountered, +* +* - an attempt to emulate has ended with a signal, +* +* - the ISA mode has been switched. +* +* We need to terminate the emulation loop if we got switched to the +* MIPS16 mode, whether supported or not, so that we do not attempt +* to emulate a MIPS16 instruction as a regular MIPS FPU instruction. +* Similarly if we got switched to the microMIPS mode and only the +* regular MIPS mode is supported, so that we do not attempt to emulate +* a microMIPS instruction as a regular MIPS FPU instruction. Or if +* we got switched to the regular MIPS mode and only the microMIPS mode +* is supported, so that we do not attempt to emulate a regular MIPS +* instruction that should cause an Address Error exception instead. +* For simplicity we always terminate upon an ISA mode switch. +*/ int fpu_emulator_cop1Handler (struct pt_regs *xcp,struct mips_fpu_struct *ctx,int has_fpu,void *__user *fault_addr) {
@@ -1943,6 +1972,15 @@ int fpu_emulator_cop1Handler(struct pt_rbreak ;if (sig)break ; +/* +* We have to check for the ISA bit explicitly here, +* because `get_isa16_mode' may return 0 if support +* for code compression has been globally disabled, +* or otherwise we may produce the wrong signal or +* even proceed successfully where we must not. +*/ +if ((xcp->cp0_epc ^ prevepc) &0x1 ) +break ;cond_resched (); }while (xcp->cp0_epc > prevepc);
Greg Kroah-Hartman
maintainerPATCH 45/60 Input: i8042 - fix crash at boot time
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Hong <[email protected]>
commit 340d394a789518018f834ff70f7534fc463d3226 upstream.
The driver checks port->exists twice in i8042_interrupt(), first when trying to assign temporary "serio" variable, and second time when deciding whether it should call serio_interrupt(). The value of port->exists may change between the 2 checks, and we may end up calling serio_interrupt() with a NULL pointer:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000050 IP: [<ffffffff8150feaf>] _spin_lock_irqsave+0x1f/0x40 PGD 0 Oops: 0002 [#1] SMP last sysfs file: CPU 0 Modules linked in:
Pid: 1, comm: swapper Not tainted 2.6.32-358.el6.x86_64 #1 QEMU Standard PC (i440FX + PIIX, 1996)
RIP: 0010:[<ffffffff8150feaf>] [<ffffffff8150feaf>] _spin_lock_irqsave+0x1f/0x40 RSP: 0018:ffff880028203cc0 EFLAGS: 00010082 RAX: 0000000000010000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000282 RSI: 0000000000000098 RDI: 0000000000000050 RBP: ffff880028203cc0 R08: ffff88013e79c000 R09: ffff880028203ee0 R10: 0000000000000298 R11: 0000000000000282 R12: 0000000000000050 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000098 FS: 0000000000000000(0000) GS:ffff880028200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b CR2: 0000000000000050 CR3: 0000000001a85000 CR4: 00000000001407f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process swapper (pid: 1, threadinfo ffff88013e79c000, task ffff88013e79b500) Stack: ffff880028203d00 ffffffff813de186 ffffffffffffff02 0000000000000000 <d> 0000000000000000 0000000000000000 0000000000000000 0000000000000098 <d> ffff880028203d70 ffffffff813e0162 ffff880028203d20 ffffffff8103b8ac Call Trace: <IRQ> [<ffffffff813de186>] serio_interrupt+0x36/0xa0 [<ffffffff813e0162>] i8042_interrupt+0x132/0x3a0 [<ffffffff8103b8ac>] ? kvm_clock_read+0x1c/0x20 [<ffffffff8103b8b9>] ? kvm_clock_get_cycles+0x9/0x10 [<ffffffff810e1640>] handle_IRQ_event+0x60/0x170 [<ffffffff8103b154>] ? kvm_guest_apic_eoi_write+0x44/0x50 [<ffffffff810e3d8e>] handle_edge_irq+0xde/0x180 [<ffffffff8100de89>] handle_irq+0x49/0xa0 [<ffffffff81516c8c>] do_IRQ+0x6c/0xf0 [<ffffffff8100b9d3>] ret_from_intr+0x0/0x11 [<ffffffff81076f63>] ? __do_softirq+0x73/0x1e0 [<ffffffff8109b75b>] ? hrtimer_interrupt+0x14b/0x260 [<ffffffff8100c1cc>] ? call_softirq+0x1c/0x30 [<ffffffff8100de05>] ? do_softirq+0x65/0xa0 [<ffffffff81076d95>] ? irq_exit+0x85/0x90 [<ffffffff81516d80>] ? smp_apic_timer_interrupt+0x70/0x9b [<ffffffff8100bb93>] ? apic_timer_interrupt+0x13/0x20
To avoid the issue let's change the second check to test whether serio is NULL or not.
Also, let's take i8042_lock in i8042_start() and i8042_stop() instead of trying to be overly smart and using memory barriers.
--- drivers/input/serio/i8042.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/input/serio/i8042.c +9 -3
@@ -397,8 +397,10 @@ static int i8042_start(struct serio *ser {struct i8042_port *port = serio->port_data; +spin_lock_irq (&i8042_lock); port->exists = true; -mb (); +spin_unlock_irq (&i8042_lock); +return 0 ; }
@@ -411,16 +413,20 @@ static void i8042_stop(struct serio *ser {struct i8042_port *port = serio->port_data; +spin_lock_irq (&i8042_lock); port->exists = false; + port->serio =NULL ; +spin_unlock_irq (&i8042_lock);/* +* We need to make sure that interrupt handler finishes using +* our serio port before we return from this function. * We synchronize with both AUX and KBD IRQs because there is * a (very unlikely) chance that AUX IRQ is raised for KBD port * and vice versa. */ synchronize_irq (I8042_AUX_IRQ );synchronize_irq (I8042_KBD_IRQ ); - port->serio =NULL ; }/*
@@ -537,7 +543,7 @@ static irqreturn_t i8042_interrupt(int ispin_unlock_irqrestore (&i8042_lock, flags); -if (likely (port->exists && !filtered)) +if (likely (serio && !filtered))serio_interrupt (serio, data, dfl); out:
Greg Kroah-Hartman
maintainerPATCH 46/60 NFS: only invalidate dentrys that are clearly invalid.
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit cc89684c9a265828ce061037f1f79f4a68ccd3f7 upstream.
Since commit bafc9b754f75 ("vfs: More precise tests in d_invalidate") in v3.18, a return of '0' from ->d_revalidate() will cause the dentry to be invalidated even if it has filesystems mounted on or it or on a descendant. The mounted filesystem is unmounted.
This means we need to be careful not to return 0 unless the directory referred to truly is invalid. So -ESTALE or -ENOENT should invalidate the directory. Other errors such a -EPERM or -ERESTARTSYS should be returned from ->d_revalidate() so they are propagated to the caller.
A particular problem can be demonstrated by:
1/ mount an NFS filesystem using NFSv3 on /mnt
2/ mount any other filesystem on /mnt/foo
3/ ls /mnt/foo
4/ turn off network, or otherwise make the server unable to respond 5/ ls /mnt/foo &
6/ cat /proc/$!/stack # note that nfs_lookup_revalidate is in the call stack 7/ kill -9 $! # this results in -ERESTARTSYS being returned
8/ observe that /mnt/foo has been unmounted.
This patch changes nfs_lookup_revalidate() to only treat
-ESTALE from nfs_lookup_verify_inode() and -ESTALE or -ENOENT from ->lookup()
as indicating an invalid inode. Other errors are returned.
Also nfs_check_inode_attributes() is changed to return -ESTALE rather than -EIO. This is consistent with the error returned in similar circumstances from nfs_update_inode().
As this bug allows any user to unmount a filesystem mounted on an NFS filesystem, this fix is suitable for stable kernels.
--- fs/nfs/dir.c | 12 ++++++++---- fs/nfs/inode.c | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-)
fs/nfs/dir.c +8 -4
@@ -1141,11 +1141,13 @@ static int nfs_lookup_revalidate(struct/* Force a full look up iff the parent directory has changed */ if (!nfs_is_exclusive_create (dir, flags) &&nfs_check_verifier (dir, dentry, flags &LOOKUP_RCU )) { - -if (nfs_lookup_verify_inode (inode, flags)) { + error =nfs_lookup_verify_inode (inode, flags); +if (error) {if (flags &LOOKUP_RCU )return -ECHILD ; - goto out_zap_parent; +if (error == -ESTALE ) + goto out_zap_parent; + goto out_error; } goto out_valid; }
@@ -1169,8 +1171,10 @@ static int nfs_lookup_revalidate(structtrace_nfs_lookup_revalidate_enter (dir, dentry, flags); error =NFS_PROTO (dir)->lookup (dir, &dentry->d_name, fhandle, fattr, label);trace_nfs_lookup_revalidate_exit (dir, dentry, flags, error); -if (error) +if (error == -ESTALE || error == -ENOENT ) goto out_bad; +if (error) + goto out_error;if (nfs_compare_fh (NFS_FH (inode), fhandle)) goto out_bad;if ((error =nfs_refresh_inode (inode, fattr)) !=0 )
fs/nfs/inode.c +2 -2
@@ -1177,9 +1177,9 @@ static int nfs_check_inode_attributes(streturn 0 ;/* Has the inode gone and changed behind our back? */ if ((fattr->valid &NFS_ATTR_FATTR_FILEID ) && nfsi->fileid != fattr->fileid) -return -EIO ; +return -ESTALE ;if ((fattr->valid &NFS_ATTR_FATTR_TYPE ) && (inode->i_mode &S_IFMT ) != (fattr->mode &S_IFMT )) -return -EIO ; +return -ESTALE ;if ((fattr->valid &NFS_ATTR_FATTR_CHANGE ) !=0 && inode->i_version != fattr->change_attr)
Greg Kroah-Hartman
maintainerPATCH 47/60 udf: Fix deadlock between writeback and udf_setsize()
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit f2e95355891153f66d4156bf3a142c6489cd78c6 upstream.
udf_setsize() called truncate_setsize() with i_data_sem held. Thus truncate_pagecache() called from truncate_setsize() could lock a page under i_data_sem which can deadlock as page lock ranks below i_data_sem - e. g. writeback can hold page lock and try to acquire i_data_sem to map a block.
Fix the problem by moving truncate_setsize() calls from under i_data_sem. It is safe for us to change i_size without holding i_data_sem as all the places that depend on i_size being stable already hold inode_lock.
--- fs/udf/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/udf/inode.c +2 -2
@@ -1237,8 +1237,8 @@ int udf_setsize(struct inode *inode, lofreturn err; } set_size: -truncate_setsize (inode, newsize);up_write (&iinfo->i_data_sem); +truncate_setsize (inode, newsize); }else {if (iinfo->i_alloc_type ==ICBTAG_FLAG_AD_IN_ICB ) {down_write (&iinfo->i_data_sem);
@@ -1255,9 +1255,9 @@ set_size: udf_get_block);if (err)return err; +truncate_setsize (inode, newsize);down_write (&iinfo->i_data_sem);udf_clear_extent_cache (inode); -truncate_setsize (inode, newsize);udf_truncate_extents (inode);up_write (&iinfo->i_data_sem); }
Greg Kroah-Hartman
maintainerPATCH 48/60 target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiang Yi <[email protected]>
commit 1d6ef276594a781686058802996e09c8550fd767 upstream.
This patch addresses a COMPARE_AND_WRITE se_device->caw_sem leak, that would be triggered during normal se_cmd shutdown or abort via __transport_wait_for_tasks().
This would occur because target_complete_cmd() would catch this early and do complete_all(&cmd->t_transport_stop_comp), but since target_complete_ok_work() or target_complete_failure_work() are never called to invoke se_cmd->transport_complete_callback(), the COMPARE_AND_WRITE specific callbacks never release caw_sem.
To address this special case, go ahead and release caw_sem directly from target_complete_cmd().
(Remove '&& success' from check, to release caw_sem regardless
of scsi_status - nab)
--- drivers/target/target_core_transport.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/target/target_core_transport.c +9 -0
@@ -693,6 +693,15 @@ void target_complete_cmd(struct se_cmd *if (cmd->transport_state &CMD_T_ABORTED || cmd->transport_state &CMD_T_STOP ) {spin_unlock_irqrestore (&cmd->t_state_lock, flags); +/* +* If COMPARE_AND_WRITE was stopped by __transport_wait_for_tasks(), +* release se_device->caw_sem obtained by sbc_compare_and_write() +* since target_complete_ok_work() or target_complete_failure_work() +* won't be called to invoke the normal CAW completion callbacks. +*/ +if (cmd->se_cmd_flags &SCF_COMPARE_AND_WRITE ) { +up (&dev->caw_sem); + }complete_all (&cmd->t_transport_stop_comp);return ; }else if (!success) {
Greg Kroah-Hartman
maintainerPATCH 50/60 Revert "perf/core: Drop kernel samples even though :u is specified"
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ingo Molnar <[email protected]>
commit 6a8a75f3235724c5941a33e287b2f98966ad14c5 upstream.
This reverts commit cc1582c231ea041fbc68861dfaf957eaf902b829.
This commit introduced a regression that broke rr-project, which uses sampling events to receive a signal on overflow (but does not care about the contents of the sample). These signals are critical to the correct operation of rr.
There's been some back and forth about how to fix it - but to not keep applications in limbo queue up a revert.
--- kernel/events/core.c | 21 --------------------- 1 file changed, 21 deletions(-)
kernel/events/core.c +0 -21
@@ -5761,21 +5761,6 @@ static void perf_log_throttle(struct perperf_output_end (&handle); } -static bool sample_is_allowed (struct perf_event *event,struct pt_regs *regs) -{ -/* -* Due to interrupt latency (AKA "skid"), we may enter the -* kernel before taking an overflow, even if the PMU is only -* counting user events. -* To avoid leaking information to userspace, we must always -* reject kernel samples when exclude_kernel is set. -*/ -if (event->attr.exclude_kernel && !user_mode (regs)) -return false; - -return true; -} -/* * Generic event overflow handling, sampling. */
@@ -5823,12 +5808,6 @@ static int __perf_event_overflow(struct }/* -* For security, drop the skid kernel samples if necessary. -*/ -if (!sample_is_allowed (event, regs)) -return ret; - -/* * XXX event_limit might not quite work as expected on inherited * events */
Greg Kroah-Hartman
maintainerPATCH 51/60 staging: rtl8188eu: add TL-WN722N v2 support
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Gugino <[email protected]>
commit 5a1d4c5dd4eb2f1f8a9b30e61762f3b3b564df70 upstream.
Add support for USB Device TP-Link TL-WN722N v2.
VendorID: 0x2357, ProductID: 0x010c
--- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/os_dep/usb_intf.c +1 -0
@@ -48,6 +48,7 @@ static struct usb_device_id rtw_usb_id_t {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */ + {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */ {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ {} /* Terminating entry */ };
Greg Kroah-Hartman
maintainerPATCH 52/60 drm/mst: Fix error handling during MST sideband message reception
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit 448421b5e93b9177c5698f0cf6f5e72d2995eeca upstream.
Handle any error due to partial reads, timeouts etc. to avoid parsing uninitialized data subsequently. Also bail out if the parsing itself fails.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +8 -2
@@ -2081,11 +2081,17 @@ static void drm_dp_get_one_sb_msg(struct ret =drm_dp_dpcd_read (mgr->aux, basereg + curreply, replyblock, len);if (ret != len) { -DRM_DEBUG_KMS ("failed to read a chunk\n" ); +DRM_DEBUG_KMS ("failed to read a chunk (len %d, ret %d)\n" , + len, ret); +return ; } + ret =drm_dp_sideband_msg_build (msg, replyblock, len, false); -if (ret == false) +if (!ret) {DRM_DEBUG_KMS ("failed to build sideband msg\n" ); +return ; + } + curreply += len; replylen -= len; }
Greg Kroah-Hartman
maintainerPATCH 53/60 drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req()
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit 7f8b3987da54cb4d41ad2545cd4d7958b9a36bdf upstream.
In case of an unknown broadcast message is sent mstb will remain unset, so check for this.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_mst_topology.c +3 -1
@@ -2209,7 +2209,9 @@ static int drm_dp_mst_handle_up_req(struDRM_DEBUG_KMS ("Got RSN: pn: %d avail_pbn %d\n" , msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn); } -drm_dp_put_mst_branch_device (mstb); +if (mstb) +drm_dp_put_mst_branch_device (mstb); +memset (&mgr->up_req_recv,0 ,sizeof (struct drm_dp_sideband_msg_rx )); }return ret;
Greg Kroah-Hartman
maintainerPATCH 54/60 drm/mst: Avoid processing partially received up/down message transactions
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit 636c4c3e762b62aa93632c645ca65879285b16e3 upstream.
Currently we may process up/down message transactions containing uninitialized data. This can happen if there was an error during the reception of any message in the transaction, but we happened to receive the last message correctly with the end-of-message flag set.
To avoid this abort the reception of the transaction when the first error is detected, rejecting any messages until a message with the start-of-message flag is received (which will start a new transaction). This is also what the DP 1.4 spec 2.11.8.2 calls for in this case.
In addtion this also prevents receiving bogus transactions without the first message with the the start-of-message flag set.
v2:
- unchanged
v3:
- git add the part that actually skips messages after an error in drm_dp_sideband_msg_build()
--- drivers/gpu/drm/drm_dp_mst_topology.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +24 -7
@@ -330,6 +330,13 @@ static bool drm_dp_sideband_msg_build(streturn false; } +/* +* ignore out-of-order messages or messages that are part of a +* failed transaction +*/ +if (!recv_hdr.somt && !msg->have_somt) +return false; +/* get length contained in this portion */ msg->curchunk_len = recv_hdr.msg_len; msg->curchunk_hdrlen = hdrlen;
@@ -2049,7 +2056,7 @@ out_unlock: }EXPORT_SYMBOL (drm_dp_mst_topology_mgr_resume); -static void drm_dp_get_one_sb_msg (struct drm_dp_mst_topology_mgr *mgr,bool up) +static bool drm_dp_get_one_sb_msg (struct drm_dp_mst_topology_mgr *mgr,bool up) {int len;u8 replyblock[32 ];
@@ -2064,12 +2071,12 @@ static void drm_dp_get_one_sb_msg(struct replyblock, len);if (ret != len) {DRM_DEBUG_KMS ("failed to read DPCD down rep %d %d\n" , len, ret); -return ; +return false; } ret =drm_dp_sideband_msg_build (msg, replyblock, len, true);if (!ret) {DRM_DEBUG_KMS ("sideband msg build failed %d\n" , replyblock[0 ]); -return ; +return false; } replylen = msg->curchunk_len + msg->curchunk_hdrlen;
@@ -2083,25 +2090,30 @@ static void drm_dp_get_one_sb_msg(structif (ret != len) {DRM_DEBUG_KMS ("failed to read a chunk (len %d, ret %d)\n" , len, ret); -return ; +return false; } ret =drm_dp_sideband_msg_build (msg, replyblock, len, false);if (!ret) {DRM_DEBUG_KMS ("failed to build sideband msg\n" ); -return ; +return false; } curreply += len; replylen -= len; } +return true; }static int drm_dp_mst_handle_down_rep (struct drm_dp_mst_topology_mgr *mgr) {int ret =0 ; -drm_dp_get_one_sb_msg (mgr, false); +if (!drm_dp_get_one_sb_msg (mgr, false)) { +memset (&mgr->down_rep_recv,0 , +sizeof (struct drm_dp_sideband_msg_rx )); +return 0 ; + }if (mgr->down_rep_recv.have_eomt) {struct drm_dp_sideband_msg_tx *txmsg;
@@ -2157,7 +2169,12 @@ static int drm_dp_mst_handle_down_rep(ststatic int drm_dp_mst_handle_up_req (struct drm_dp_mst_topology_mgr *mgr) {int ret =0 ; -drm_dp_get_one_sb_msg (mgr, true); + +if (!drm_dp_get_one_sb_msg (mgr, true)) { +memset (&mgr->up_req_recv,0 , +sizeof (struct drm_dp_sideband_msg_rx )); +return 0 ; + }if (mgr->up_req_recv.have_eomt) {struct drm_dp_sideband_msg_req_body msg;
Greg Kroah-Hartman
maintainerPATCH 55/60 KVM: PPC: Book3S HV: Context-switch EBB registers properly
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Mackerras <[email protected]>
commit ca8efa1df1d15a1795a2da57f9f6aada6ed6b946 upstream.
This adds code to save the values of three SPRs (special-purpose registers) used by userspace to control event-based branches (EBBs), which are essentially interrupts that get delivered directly to userspace. These registers are loaded up with guest values when entering the guest, and their values are saved when exiting the guest, but we were not saving the host values and restoring them before going back to userspace.
On POWER8 this would only affect userspace programs which explicitly request the use of EBBs and also use the KVM_RUN ioctl, since the only source of EBBs on POWER8 is the PMU, and there is an explicit enable bit in the PMU registers (and those PMU registers do get properly context-switched between host and guest). On POWER9 there is provision for externally-generated EBBs, and these are not subject to the control in the PMU registers.
Since these registers only affect userspace, we can save them when we first come in from userspace and restore them before returning to userspace, rather than saving/restoring the host values on every guest entry/exit. Similarly, we don't need to worry about their values on offline secondary threads since they execute in the context of the idle task, which never executes in userspace.
--- arch/powerpc/kvm/book3s_hv.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/powerpc/kvm/book3s_hv.c +16 -0
@@ -1950,6 +1950,7 @@ static int kvmppc_vcpu_run_hv(struct kvm {int r;int srcu_idx; +unsigned long ebb_regs[3 ] = {};/* shut up GCC */ if (!vcpu->arch.sane) { run->exit_reason =KVM_EXIT_INTERNAL_ERROR ;
@@ -1999,6 +2000,14 @@ static int kvmppc_vcpu_run_hv(struct kvmflush_fp_to_thread (current);flush_altivec_to_thread (current);flush_vsx_to_thread (current); + +/* Save userspace EBB register values */ +if (cpu_has_feature (CPU_FTR_ARCH_207S )) { + ebb_regs[0 ] =mfspr (SPRN_EBBHR ); + ebb_regs[1 ] =mfspr (SPRN_EBBRR ); + ebb_regs[2 ] =mfspr (SPRN_BESCR ); + } + vcpu->arch.wqp = &vcpu->arch.vcore->wq; vcpu->arch.pgdir = current->mm->pgd; vcpu->arch.state =KVMPPC_VCPU_BUSY_IN_HOST ;
@@ -2018,6 +2027,13 @@ static int kvmppc_vcpu_run_hv(struct kvm } }while (is_kvmppc_resume_guest (r)); +/* Restore userspace EBB register values */ +if (cpu_has_feature (CPU_FTR_ARCH_207S )) { +mtspr (SPRN_EBBHR , ebb_regs[0 ]); +mtspr (SPRN_EBBRR , ebb_regs[1 ]); +mtspr (SPRN_BESCR , ebb_regs[2 ]); + } + out: vcpu->arch.state =KVMPPC_VCPU_NOTREADY ;atomic_dec (&vcpu->kvm->arch.vcpus_running);
Greg Kroah-Hartman
maintainerPATCH 56/60 of: device: Export of_device_{get_modalias, uvent_modalias} to modules
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Boyd <[email protected]>
commit 7a3b7cd332db08546f3cdd984f11773e0d1999e7 upstream.
The ULPI bus can be built as a module, and it will soon be calling these functions when it supports probing devices from DT. Export them so they can be used by the ULPI module.
--- drivers/of/device.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/device.c +2 -0
@@ -128,6 +128,7 @@ ssize_t of_device_get_modalias(struct dereturn tsize; } +EXPORT_SYMBOL_GPL (of_device_get_modalias);/** * of_device_uevent - Display OF related uevent information
@@ -190,3 +191,4 @@ int of_device_uevent_modalias(struct devreturn 0 ; } +EXPORT_SYMBOL_GPL (of_device_uevent_modalias);
Greg Kroah-Hartman
maintainerPATCH 57/60 spmi: Include OF based modalias in device uevent
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
commit d50daa2af2618dab6d21634e65a5fbcf4ae437d6 upstream.
Include the OF-based modalias in the uevent sent when registering SPMI devices, so that user space has a chance to autoload the kernel module for the device.
--- drivers/spmi/spmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/spmi/spmi.c +12 -0
@@ -353,11 +353,23 @@ static int spmi_drv_remove(struct devicereturn 0 ; } +static int spmi_drv_uevent (struct device *dev,struct kobj_uevent_env *env) +{ +int ret; + + ret =of_device_uevent_modalias (dev, env); +if (ret != -ENODEV ) +return ret; + +return 0 ; +} +static struct bus_type spmi_bus_type = { .name ="spmi" , .match = spmi_device_match, .probe = spmi_drv_probe, .remove = spmi_drv_remove, + .uevent = spmi_drv_uevent, };/**
Greg Kroah-Hartman
maintainerPATCH 58/60 tracing: Fix kmemleak in instance_rmdir
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chunyu Hu <[email protected]>
commit db9108e054700c96322b0f0028546aa4e643cf0b upstream.
Hit the kmemleak when executing instance_rmdir, it forgot releasing mem of tracing_cpumask. With this fix, the warn does not appear any more.
unreferenced object 0xffff93a8dfaa7c18 (size 8):
comm "mkdir", pid 1436, jiffies 4294763622 (age 9134.308s) hex dump (first 8 bytes):
ff ff ff ff ff ff ff ff ........
backtrace:
[<ffffffff88b6567a>] kmemleak_alloc+0x4a/0xa0
[<ffffffff8861ea41>] __kmalloc_node+0xf1/0x280
[<ffffffff88b505d3>] alloc_cpumask_var_node+0x23/0x30
[<ffffffff88b5060e>] alloc_cpumask_var+0xe/0x10
[<ffffffff88571ab0>] instance_mkdir+0x90/0x240
[<ffffffff886e5100>] tracefs_syscall_mkdir+0x40/0x70
[<ffffffff886565c9>] vfs_mkdir+0x109/0x1b0
[<ffffffff8865b1d0>] SyS_mkdir+0xd0/0x100
[<ffffffff88403857>] do_syscall_64+0x67/0x150
[<ffffffff88b710e7>] return_from_SYSCALL_64+0x0/0x6a
[<ffffffffffffffff>] 0xffffffffffffffff--- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace.c +1 -0
@@ -6405,6 +6405,7 @@ static int instance_delete(const char *ndebugfs_remove_recursive (tr->dir);free_trace_buffers (tr); +free_cpumask_var (tr->tracing_cpumask);kfree (tr->name);kfree (tr);
Greg Kroah-Hartman
maintainerPATCH 59/60 alarmtimer: dont rate limit one-shot timers
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Hackmann <[email protected]>
Commit ff86bf0c65f1 ("alarmtimer: Rate limit periodic intervals") sets a minimum bound on the alarm timer interval. This minimum bound shouldn't be applied if the interval is 0. Otherwise, one-shot timers will be converted into periodic ones.
--- kernel/time/alarmtimer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/time/alarmtimer.c +2 -1
@@ -619,7 +619,8 @@ static int alarm_timer_set(struct k_itim* Rate limit to the tick as a hot fix to prevent DOS. Will be * mopped up later. */ -if (ktime_to_ns (timr->it.alarm.interval) <TICK_NSEC ) +if (timr->it.alarm.interval.tv64 && +ktime_to_ns (timr->it.alarm.interval) <TICK_NSEC ) timr->it.alarm.interval =ktime_set (0 ,TICK_NSEC ); exp =timespec_to_ktime (new_setting->it_value);
Greg Kroah-Hartman
maintainerPATCH 60/60 MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn
In reply to Greg Kroah-Hartman3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 7b82c1058ac1f8f8b9f2b8786b1f710a57a870a8 upstream.
Fix commit e50c0a8fa60d ("Support the MIPS32 / MIPS64 DSP ASE.") and send SIGILL rather than SIGBUS whenever an unimplemented BPOSGE32 DSP ASE instruction has been encountered in `__compute_return_epc_for_insn' as our Reserved Instruction exception handler would in response to an attempt to actually execute the instruction. Sending SIGBUS only makes sense for the unaligned PC case, since moved to __compute_return_epc'. Adjust function documentation accordingly, correct formatting and use pr_info' rather than `printk' as the other exit path already does.
Patchwork: https://patchwork.linux-mips.org/patch/16396/
--- arch/mips/kernel/branch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/mips/kernel/branch.c +4 -3
@@ -396,7 +396,7 @@ int __MIPS16e_compute_return_epc(struct* * @regs: Pointer to pt_regs * @insn: branch instruction to decode -* @returns: -EFAULT on error and forces SIGBUS, and on success +* @returns: -EFAULT on error and forces SIGILL, and on success * returns 0 or BRANCH_LIKELY_TAKEN as appropriate after * evaluating the branch. */
@@ -633,8 +633,9 @@ int __compute_return_epc_for_insn(structreturn ret; sigill: -printk ("%s: DSP branch but not DSP ASE - sending SIGBUS.\n" , current->comm); -force_sig (SIGBUS , current); +pr_info ("%s: DSP branch but not DSP ASE - sending SIGILL.\n" , + current->comm); +force_sig (SIGILL , current);return -EFAULT ; }EXPORT_SYMBOL_GPL (__compute_return_epc_for_insn);
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.18.63 release. There are 60 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 Thu Jul 27 19:15:49 UTC 2017. Anything received after that time might be too late.
Build results:
total: 135 pass: 135 fail: 0 Qemu test results: total: 111 pass: 111 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.18.63 release. There are 60 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 Thu Jul 27 19:15:49 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
kernel.org/pub/linux/kernel/v3.x/stable-review/patch-3.18.63-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-3.18.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah