3.16.37-rc1 review
Subsystems (3)
PATCH 3/305 ARM: dts: kirkwood: add kirkwood-nsa320.dtb to Makefile
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Heinrich Schuchardt <[email protected]>
commit 9ec423ed62b8278412400fae6c064edb6ce1bb51 upstream.
Commit be3d7d023b87 ("ARM: kirkwood: Add DTS file for NSA320") created the new file kirkwood-nsa320.dts but did not add it to the Makefile.
--- arch/arm/boot/dts/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/Makefile +1 -0
@@ -132,6 +132,7 @@ kirkwood := \ kirkwood-ns2mini.dtb \ kirkwood-nsa310.dtb \ kirkwood-nsa310a.dtb \ + kirkwood-nsa320.dtb \ kirkwood-openblocks_a6.dtb \ kirkwood-openblocks_a7.dtb \ kirkwood-openrd-base.dtb \
PATCH 5/305 ath5k: Change led pin configuration for compaq c700 laptop
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Salisbury <[email protected]>
commit 7b9bc799a445aea95f64f15e0083cb19b5789abe upstream.
Commit 09c9bae26b0d3c9472cb6ae45010460a2cee8b8d ("ath5k: add led pin configuration for compaq c700 laptop") added a pin configuration for the Compaq c700 laptop. However, the polarity of the led pin is reversed. It should be red for wifi off and blue for wifi on, but it is the opposite. This bug was reported in the following bug report:
http://pad.lv/972604
--- drivers/net/wireless/ath/ath5k/led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/led.c +1 -1
@@ -77,7 +77,7 @@ static DEFINE_PCI_DEVICE_TABLE(ath5k_led/* HP Compaq CQ60-206US ([email protected]) */ { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137a), ATH_LED(3, 1) },/* HP Compaq C700 ([email protected]) */ - { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 1) }, + { ATH_SDEVICE(PCI_VENDOR_ID_HP, 0x0137b), ATH_LED(3, 0) },/* LiteOn AR5BXB63 ([email protected]) */ { ATH_SDEVICE(PCI_VENDOR_ID_ATHEROS, 0x3067), ATH_LED(3, 0) },/* IBM-specific AR5212 (all others) */
PATCH 20/305 serial: doc: Re-add paragraph documenting uart_console_write()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit d124fd3bb36ceb40438f10c897ce642386b74b72 upstream.
Commit 834392a7d92677ff ("serial: doc: Un-document non-existing uart_write_console()") removed a paragraph about a helper function that seemed to never exist.
Peter Hurley pointed out that the function does exist, but is called differently. Re-add the paragraph, with the function name corrected.
--- Documentation/serial/driver | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/serial/driver +5 -0
@@ -28,6 +28,11 @@ The serial core provides a few helper fu the correct port structure (via uart_get_console) and decoding command line arguments (uart_parse_options). +There is also a helper function (uart_console_write) which performs a +character by character write, translating newlines to CRLF sequences. +Driver writers are recommended to use this function rather than implementing +their own version. + Locking -------
PATCH 33/305 aacraid: Fix for aac_command_thread hang
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Raghava Aditya Renukunta <[email protected]>
commit fc4bf75ea300a5e62a2419f89dd0e22189dd7ab7 upstream.
Typically under error conditions, it is possible for aac_command_thread() to miss the wakeup from kthread_stop() and go back to sleep, causing it to hang aac_shutdown.
In the observed scenario, the adapter is not functioning correctly and so aac_fib_send() never completes (or time-outs depending on how it was called). Shortly after aac_command_thread() starts it performs aac_fib_send(SendHostTime) which hangs. When aac_probe_one /aac_get_adapter_info send time outs, kthread_stop is called which breaks the command thread out of it's hang.
The code will still go back to sleep in schedule_timeout() without checking kthread_should_stop() so it causes aac_probe_one to hang until the schedule_timeout() which is 30 minutes.
Fixed by: Adding another kthread_should_stop() before schedule_timeout()
--- drivers/scsi/aacraid/commsup.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/aacraid/commsup.c +4 -0
@@ -1921,6 +1921,10 @@ int aac_command_thread(void *data)if (difference <=0 ) difference =1 ;set_current_state (TASK_INTERRUPTIBLE ); + +if (kthread_should_stop ()) +break ; +schedule_timeout (difference);if (kthread_should_stop ())
PATCH 37/305 Revert "tty: Fix pty master poll() after slave closes v2"
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Hurley <[email protected]>
commit 2ce3c10c0c3e0d418c1a7a4c838319ba42c75388 upstream.
This reverts commit c4dc304677e8d566572c4738d95c48be150c6606. This fix is superseded by commit 52bce7f8d4fc633c9a9d0646eef58ba6ae9a3b73, 'pty, n_tty: Simplify input processing on final close'.
The final close now waits for input processing to complete before destroying the pty, so poll() does not need to special case this condition.
--- drivers/tty/n_tty.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/tty/n_tty.c +2 -7
@@ -2465,17 +2465,12 @@ static unsigned int n_tty_poll(struct ttpoll_wait (file, &tty->read_wait, wait);poll_wait (file, &tty->write_wait, wait); -if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) - mask |=POLLHUP ;if (input_available_p (tty,1 )) mask |=POLLIN |POLLRDNORM ; -else if (mask &POLLHUP ) { -tty_flush_to_ldisc (tty); -if (input_available_p (tty,1 )) - mask |=POLLIN |POLLRDNORM ; - }if (tty->packet && tty->link->ctrl_status) mask |=POLLPRI |POLLIN |POLLRDNORM ; +if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) + mask |=POLLHUP ;if (tty_hung_up_p (file)) mask |=POLLHUP ;if (!(mask & (POLLHUP |POLLIN |POLLRDNORM ))) {
PATCH 38/305 Fix OpenSSH pty regression on close
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Brian Bloniarz <[email protected]>
commit 0f40fbbcc34e093255a2b2d70b6b0fb48c3f39aa upstream.
OpenSSH expects the (non-blocking) read() of pty master to return EAGAIN only if it has received all of the slave-side output after it has received SIGCHLD. This used to work on pre-3.12 kernels.
This fix effectively forces non-blocking read() and poll() to block for parallel i/o to complete for all ttys. It also unwinds these changes:
1) f8747d4a466ab2cafe56112c51b3379f9fdb7a12
tty: Fix pty master read() after slave closes
2) 52bce7f8d4fc633c9a9d0646eef58ba6ae9a3b73 pty, n_tty: Simplify input processing on final close
3) 1a48632ffed61352a7810ce089dc5a8bcd505a60
pty: Fix input race when closing
Inspired by analysis and patch from Marc Aurele La France <[email protected]>
[bwh: Backported to 3.16:
- No need to unwind commits 2 and 3
- Keep using tty_flush_to_ldisc() rather than adding tty_buffer_flush_work()]]
---
drivers/tty/n_tty.c +10 -6
@@ -2251,15 +2251,14 @@ static ssize_t n_tty_read(struct tty_str ldata->minimum_to_wake = (minimum - (b - buf));if (!input_available_p (tty,0 )) { -if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) { -up_read (&tty->termios_rwsem); -tty_flush_to_ldisc (tty); -down_read (&tty->termios_rwsem); -if (!input_available_p (tty,0 )) { +up_read (&tty->termios_rwsem); +tty_flush_to_ldisc (tty); +down_read (&tty->termios_rwsem); +if (!input_available_p (tty,0 )) { +if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) { retval = -EIO ;break ; } - }else {if (tty_hung_up_p (file))break ;if (!timeout)
@@ -2467,6 +2466,11 @@ static unsigned int n_tty_poll(struct ttpoll_wait (file, &tty->write_wait, wait);if (input_available_p (tty,1 )) mask |=POLLIN |POLLRDNORM ; +else { +tty_flush_to_ldisc (tty); +if (input_available_p (tty,1 )) + mask |=POLLIN |POLLRDNORM ; + }if (tty->packet && tty->link->ctrl_status) mask |=POLLPRI |POLLIN |POLLRDNORM ;if (test_bit (TTY_OTHER_CLOSED , &tty->flags))
PATCH 44/305 USB: serial: option: add more ZTE device ids
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: lei liu <[email protected]>
commit f0d09463c59c2d764a6c6d492cbe6d2c77f27153 upstream.
More ZTE device ids.
--- drivers/usb/serial/option.c | 75 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-)
drivers/usb/serial/option.c +74 -1
@@ -1629,7 +1629,79 @@ static const struct usb_device_id option .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff42, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff43, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff44, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff45, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff46, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff47, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff48, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff49, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4a, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4b, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4c, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4d, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4e, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff4f, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff50, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff51, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff52, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff53, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff54, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff55, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff56, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff57, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff58, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff59, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5a, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5b, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5c, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5d, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5e, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff5f, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff60, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff61, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff62, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff63, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff64, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff65, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff66, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff67, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff68, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff69, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6a, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6b, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6c, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6d, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6e, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff6f, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff70, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff71, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff72, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff73, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff74, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff75, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff76, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff77, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff78, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff79, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7a, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7b, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7c, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7d, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7e, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff7f, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff80, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff81, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff82, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff83, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff84, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff85, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff86, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff87, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff88, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff89, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8a, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8b, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8c, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff8d, 0xff, 0xff, 0xff) },
@@ -1640,6 +1712,7 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
PATCH 46/305 cpufreq: Fix GOV_LIMITS handling for the userspace governor
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sai Gurrappadi <[email protected]>
commit e43e94c1eda76dabd686ddf6f7825f54d747b310 upstream.
Currently, the userspace governor only updates frequency on GOV_LIMITS if policy->cur falls outside policy->{min/max}. However, it is also necessary to update current frequency on GOV_LIMITS to match the user requested value if it can be achieved within the new policy->{max/min}.
This was previously the behaviour in the governor until commit d1922f0 ("cpufreq: Simplify userspace governor") which incorrectly assumed that policy->cur == user requested frequency via scaling_setspeed. This won't be true if the user requested frequency falls outside policy->{min/max}.
Ex: a temporary thermal cap throttled the user requested frequency.
Fix this by storing the user requested frequency in a seperate variable. The governor will then try to achieve this request on every GOV_LIMITS change.
--- drivers/cpufreq/cpufreq_userspace.c | 43 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-)
drivers/cpufreq/cpufreq_userspace.c +38 -5
@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/slab.h> static DEFINE_PER_CPU(unsigned int, cpu_is_managed);static DEFINE_MUTEX (userspace_mutex);
@@ -31,6 +32,7 @@ static DEFINE_MUTEX(userspace_mutex);static int cpufreq_set (struct cpufreq_policy *policy,unsigned int freq) {int ret = -EINVAL ; +unsigned int *setspeed = policy->governor_data;pr_debug ("cpufreq_set for cpu %u, freq %u kHz\n" , policy->cpu, freq);
@@ -38,6 +40,8 @@ static int cpufreq_set(struct cpufreq_poif (!per_cpu (cpu_is_managed, policy->cpu)) goto err; + *setspeed = freq; + ret =__cpufreq_driver_target (policy, freq,CPUFREQ_RELATION_L ); err:mutex_unlock (&userspace_mutex);
@@ -49,19 +53,45 @@ static ssize_t show_speed(struct cpufreqreturn sprintf (buf,"%u\n" , policy->cur); } +static int cpufreq_userspace_policy_init (struct cpufreq_policy *policy) +{ +unsigned int *setspeed; + + setspeed =kzalloc (sizeof (*setspeed),GFP_KERNEL ); +if (!setspeed) +return -ENOMEM ; + + policy->governor_data = setspeed; +return 0 ; +} +static int cpufreq_governor_userspace (struct cpufreq_policy *policy,unsigned int event) { +unsigned int *setspeed = policy->governor_data;unsigned int cpu = policy->cpu;int rc =0 ; +if (event ==CPUFREQ_GOV_POLICY_INIT ) +return cpufreq_userspace_policy_init (policy); + +if (!setspeed) +return -EINVAL ; +switch (event) { +case CPUFREQ_GOV_POLICY_EXIT : +mutex_lock (&userspace_mutex); + policy->governor_data =NULL ; +kfree (setspeed); +mutex_unlock (&userspace_mutex); +break ;case CPUFREQ_GOV_START :BUG_ON (!policy->cur);pr_debug ("started managing cpu %u\n" , cpu);mutex_lock (&userspace_mutex);per_cpu (cpu_is_managed, cpu) =1 ; + *setspeed = policy->cur;mutex_unlock (&userspace_mutex);break ;case CPUFREQ_GOV_STOP :
@@ -69,20 +99,23 @@ static int cpufreq_governor_userspace(stmutex_lock (&userspace_mutex);per_cpu (cpu_is_managed, cpu) =0 ; + *setspeed =0 ;mutex_unlock (&userspace_mutex);break ;case CPUFREQ_GOV_LIMITS :mutex_lock (&userspace_mutex); -pr_debug ("limit event for cpu %u: %u - %u kHz, currently %u kHz\n" , - cpu, policy->min, policy->max, - policy->cur); +pr_debug ("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n" , + cpu, policy->min, policy->max, policy->cur, *setspeed); -if (policy->max < policy->cur) +if (policy->max < *setspeed)__cpufreq_driver_target (policy, policy->max,CPUFREQ_RELATION_H ); -else if (policy->min > policy->cur) +else if (policy->min > *setspeed)__cpufreq_driver_target (policy, policy->min,CPUFREQ_RELATION_L ); +else +__cpufreq_driver_target (policy, *setspeed, +CPUFREQ_RELATION_L );mutex_unlock (&userspace_mutex);break ; }
PATCH 52/305 MIPS: BMIPS: Fix PRID_IMP_BMIPS5000 masking for BMIPS5200
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit cbbda6e7c9c3e4532bd70a73ff9d5e6655c894dc upstream.
BMIPS5000 have a PrID value of 0x5A00 and BMIPS5200 have a PrID value of 0x5B00, which, masked with 0x5A00, returns 0x5A00. Update all conditionals on the PrID to cover both variants since we are going to need this to enable BMIPS5200 SMP. The existing check, masking with 0xFF00 would not cover BMIPS5200 at all.
Patchwork: https://patchwork.linux-mips.org/patch/12279/
--- arch/mips/kernel/bmips_vec.S | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/mips/kernel/bmips_vec.S +7 -2
@@ -93,7 +93,8 @@ NESTED(bmips_reset_nmi_vec, PT_SIZE, sp) #if defined(CONFIG_CPU_BMIPS5000) mfc0 k0, CP0_PRID li k1, PRID_IMP_BMIPS5000 - andi k0, 0xff00 + /* mask with PRID_IMP_BMIPS5000 to cover both variants */ + andi k0, PRID_IMP_BMIPS5000 bne k0, k1, 1f /* if we're not on core 0, this must be the SMP boot signal */
@@ -166,10 +167,12 @@ bmips_smp_entry: 2: #endif /* CONFIG_CPU_BMIPS4350 || CONFIG_CPU_BMIPS4380 */ #if defined(CONFIG_CPU_BMIPS5000) - /* set exception vector base */ + /* mask with PRID_IMP_BMIPS5000 to cover both variants */ li k1, PRID_IMP_BMIPS5000 + andi k0, PRID_IMP_BMIPS5000 bne k0, k1, 3f + /* set exception vector base */ la k0, ebase lw k0, 0(k0) mtc0 k0, $15, 1
@@ -264,6 +267,8 @@ LEAF(bmips_enable_xks01) #endif /* CONFIG_CPU_BMIPS4380 */ #if defined(CONFIG_CPU_BMIPS5000) li t1, PRID_IMP_BMIPS5000 + /* mask with PRID_IMP_BMIPS5000 to cover both variants */ + andi t2, PRID_IMP_BMIPS5000 bne t2, t1, 2f mfc0 t0, $22, 5
PATCH 53/305 MIPS: Don't unwind to user mode with EVA
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit a816b306c62195b7c43c92cb13330821a96bdc27 upstream.
When unwinding through IRQs and exceptions, the unwinding only continues if the PC is a kernel text address, however since EVA it is possible for user and kernel address ranges to overlap, potentially allowing unwinding to continue to user mode if the user PC happens to be in the kernel text address range.
Adjust the check to also ensure that the register state from before the exception is actually running in kernel mode, i.e. !user_mode(regs).
I don't believe any harm can come of this problem, since the PC is only output, the stack pointer is checked to ensure it resides within the task's stack page before it is dereferenced in search of the return address, and the return address register is similarly only output (if the PC is in a leaf function or the beginning of a non-leaf function).
However unwind_stack() is only meant for unwinding kernel code, so to be correct the unwind should stop there.
Patchwork: https://patchwork.linux-mips.org/patch/11700/
--- arch/mips/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/process.c +1 -1
@@ -489,7 +489,7 @@ unsigned long notrace unwind_stack_by_ad *sp + sizeof(*regs) <= stack_page + THREAD_SIZE - 32) { regs = (struct pt_regs *)*sp; pc = regs->cp0_epc; -if (__kernel_text_address (pc)) { +if (!user_mode (regs) &&__kernel_text_address (pc)) { *sp = regs->regs[29 ]; *ra = regs->regs[31 ];return pc;
PATCH 61/305 MIPS: KVM: Fix timer IRQ race when freezing timer
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 4355c44f063d3de4f072d796604c7f4ba4085cc3 upstream.
There's a particularly narrow and subtle race condition when the software emulated guest timer is frozen which can allow a guest timer interrupt to be missed.
This happens due to the hrtimer expiry being inexact, so very occasionally the freeze time will be after the moment when the emulated CP0_Count transitions to the same value as CP0_Compare (so an IRQ should be generated), but before the moment when the hrtimer is due to expire (so no IRQ is generated). The IRQ won't be generated when the timer is resumed either, since the resume CP0_Count will already match CP0_Compare.
With VZ guests in particular this is far more likely to happen, since the soft timer may be frozen frequently in order to restore the timer state to the hardware guest timer. This happens after 5-10 hours of guest soak testing, resulting in an overflow in guest kernel timekeeping calculations, hanging the guest. A more focussed test case to intentionally hit the race (with the help of a new hypcall to cause the timer state to migrated between hardware & software) hits the condition fairly reliably within around 30 seconds.
Instead of relying purely on the inexact hrtimer expiry to determine whether an IRQ should be generated, read the guest CP0_Compare and directly check whether the freeze time is before or after it. Only if CP0_Count is on or after CP0_Compare do we check the hrtimer expiry to determine whether the last IRQ has already been generated (which will have pushed back the expiry by one timer period).
--- arch/mips/kvm/kvm_mips_emul.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
arch/mips/kvm/kvm_mips_emul.c +23 -5
@@ -310,12 +310,31 @@ static inline ktime_t kvm_mips_count_tim*/ static uint32_t kvm_mips_read_count_running (struct kvm_vcpu *vcpu,ktime_t now) { -ktime_t expires; +struct mips_coproc *cop0 = vcpu->arch.cop0; +ktime_t expires, threshold; +uint32_t count, compare;int running; -/* Is the hrtimer pending? */ +/* Calculate the biased and scaled guest CP0_Count */ + count = vcpu->arch.count_bias +kvm_mips_ktime_to_count (vcpu, now); + compare =kvm_read_c0_guest_compare (cop0); + +/* +* Find whether CP0_Count has reached the closest timer interrupt. If +* not, we shouldn't inject it. +*/ +if ((int32_t )(count - compare) <0 ) +return count; + +/* +* The CP0_Count we're going to return has already reached the closest +* timer interrupt. Quickly check if it really is a new interrupt by +* looking at whether the interval until the hrtimer expiry time is +* less than 1/4 of the timer period. +*/ expires =hrtimer_get_expires (&vcpu->arch.comparecount_timer); -if (ktime_compare (now, expires) >=0 ) { + threshold =ktime_add_ns (now, vcpu->arch.count_period /4 ); +if (ktime_before (expires, threshold)) {/* * Cancel it while we handle it so there's no chance of * interference with the timeout handler.
@@ -337,8 +356,7 @@ static uint32_t kvm_mips_read_count_runn } } -/* Return the biased and scaled guest CP0_Count */ -return vcpu->arch.count_bias +kvm_mips_ktime_to_count (vcpu, now); +return count; }/**
PATCH 62/305 MIPS: KVM: Fix timer IRQ race when writing CP0_Compare
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit b45bacd2d048f405c7760e5cc9b60dd67708734f upstream.
Writing CP0_Compare clears the timer interrupt pending bit (CP0_Cause.TI), but this wasn't being done atomically. If a timer interrupt raced with the write of the guest CP0_Compare, the timer interrupt could end up being pending even though the new CP0_Compare is nowhere near CP0_Count.
We were already updating the hrtimer expiry with kvm_mips_update_hrtimer(), which used both kvm_mips_freeze_hrtimer() and kvm_mips_resume_hrtimer(). Close the race window by expanding out kvm_mips_update_hrtimer(), and clearing CP0_Cause.TI and setting CP0_Compare between the freeze and resume. Since the pending timer interrupt should not be cleared when CP0_Compare is written via the KVM user API, an ack argument is added to distinguish the source of the write.
--- arch/mips/include/asm/kvm_host.h | 2 +- arch/mips/kvm/kvm_mips_emul.c | 61 ++++++++++++++++++---------------------- arch/mips/kvm/kvm_trap_emul.c | 2 +- 3 files changed, 29 insertions(+), 36 deletions(-)
arch/mips/include/asm/kvm_host.h +1 -1
@@ -718,7 +718,7 @@ extern enum emulation_result kvm_mips_couint32_t kvm_mips_read_count (struct kvm_vcpu *vcpu);void kvm_mips_write_count (struct kvm_vcpu *vcpu,uint32_t count); -void kvm_mips_write_compare (struct kvm_vcpu *vcpu,uint32_t compare); +void kvm_mips_write_compare (struct kvm_vcpu *vcpu,uint32_t compare,bool ack);void kvm_mips_init_count (struct kvm_vcpu *vcpu);int kvm_mips_set_count_ctl (struct kvm_vcpu *vcpu,s64 count_ctl);int kvm_mips_set_count_resume (struct kvm_vcpu *vcpu,s64 count_resume);
arch/mips/kvm/kvm_mips_emul.c +27 -34
91 lines not on this page · raw message
arch/mips/kvm/kvm_trap_emul.c +1 -1
@@ -451,7 +451,7 @@ static int kvm_trap_emul_set_one_reg(strkvm_mips_write_count (vcpu, v);break ;case KVM_REG_MIPS_CP0_COMPARE : -kvm_mips_write_compare (vcpu, v); +kvm_mips_write_compare (vcpu, v, false);break ;case KVM_REG_MIPS_CP0_CAUSE :/*
PATCH 70/305 powerpc/mm/hash64: Fix subpage protection with 4K HPTE config
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit aac55d7573c5d46ed9a62818d5d3e69dd2060105 upstream.
With Linux page size of 64K and hardware only supporting 4K HPTE, if we use subpage protection, we always fail for the subpage 0 as shown below (using the selftest subpage_prot test):
520175565: (4520111850): Failed at 0x3fffad4b0000 (p=13,sp=0,w=0), want=fault, got=pass ! 4520890210: (4520826495): Failed at 0x3fffad5b0000 (p=29,sp=0,w=0), want=fault, got=pass ! 4521574251: (4521510536): Failed at 0x3fffad6b0000 (p=45,sp=0,w=0), want=fault, got=pass ! 4522258324: (4522194609): Failed at 0x3fffad7b0000 (p=61,sp=0,w=0), want=fault, got=pass !
This is because hash preload wrongly inserts the HPTE entry for subpage 0 without looking at the subpage protection information.
Fix it by teaching should_hash_preload() not to preload if we have subpage protection configured for that range.
It appears this has been broken since it was introduced in 2008.
--- arch/powerpc/mm/hash_utils_64.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/powerpc/mm/hash_utils_64.c +9 -1
@@ -1199,8 +1199,16 @@ EXPORT_SYMBOL_GPL(hash_page);#ifdef CONFIG_PPC_MM_SLICES static bool should_hash_preload (struct mm_struct *mm,unsigned long ea) { +int psize =get_slice_psize (mm, ea); +/* We only prefault standard pages for now */ -if (unlikely (get_slice_psize (mm, ea) != mm->context.user_psize)) +if (unlikely (psize != mm->context.user_psize)) +return false; + +/* +* Don't prefault if subpage protection is enabled for the EA. +*/ +if (unlikely ((psize ==MMU_PAGE_4K ) &&subpage_protection (mm, ea)))return false;return true;
PATCH 78/305 ring-buffer: Prevent overflow of size in ring_buffer_resize()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (Red Hat)" <[email protected]>
commit 59643d1535eb220668692a5359de22545af579f6 upstream.
If the size passed to ring_buffer_resize() is greater than MAX_LONG - BUF_PAGE_SIZE then the DIV_ROUND_UP() will return zero.
Here's the details:
# echo 18014398509481980 > /sys/kernel/debug/tracing/buffer_size_kb
tracing_entries_write() processes this and converts kb to bytes.
18014398509481980 << 10 = 18446744073709547520
and this is passed to ring_buffer_resize() as unsigned long size.
size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
Where DIV_ROUND_UP(a, b) is (a + b - 1)/b
BUF_PAGE_SIZE is 4080 and here
18446744073709547520 + 4080 - 1 = 18446744073709551599
where 18446744073709551599 is still smaller than 2^64
2^64 - 18446744073709551599 = 17
But now 18446744073709551599 / 4080 = 4521260802379792
and size = size * 4080 = 18446744073709551360
This is checked to make sure its still greater than 2 * 4080, which it is.
Then we convert to the number of buffer pages needed.
nr_page = DIV_ROUND_UP(size, BUF_PAGE_SIZE)
but this time size is 18446744073709551360 and
2^64 - (18446744073709551360 + 4080 - 1) = -3823
Thus it overflows and the resulting number is less than 4080, which makes
3823 / 4080 = 0
an nr_pages is set to this. As we already checked against the minimum that nr_pages may be, this causes the logic to fail as well, and we crash the kernel.
There's no reason to have the two DIV_ROUND_UP() (that's just result of historical code changes), clean up the code and fix this bug.
--- kernel/trace/ring_buffer.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
kernel/trace/ring_buffer.c +4 -5
@@ -1694,14 +1694,13 @@ int ring_buffer_resize(struct ring_buffe !cpumask_test_cpu(cpu_id, buffer->cpumask))return size; - size =DIV_ROUND_UP (size,BUF_PAGE_SIZE ); - size *=BUF_PAGE_SIZE ; + nr_pages =DIV_ROUND_UP (size,BUF_PAGE_SIZE );/* we need a minimum of two pages */ -if (size <BUF_PAGE_SIZE *2 ) - size =BUF_PAGE_SIZE *2 ; +if (nr_pages <2 ) + nr_pages =2 ; - nr_pages =DIV_ROUND_UP (size,BUF_PAGE_SIZE ); + size = nr_pages *BUF_PAGE_SIZE ;/* * Don't succeed if resizing is disabled, as a reader might be
PATCH 79/305 RDMA/iw_cxgb4: Always wake up waiter in c4iw_peer_abort_intr()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad S <[email protected]>
commit 093108cb3640844cfdabb0f506fa6b592b64272d upstream.
Currently c4iw_peer_abort_intr() does not wake up the waiter if the endpoint state indicates we're using MPAv2 and we're currently trying to connect. This was introduced with commit 7c0a33d61187a ("RDMA/cxgb4:
Don't wakeup threads for MPAv2")
However, this original fix is flawed because it introduces a race that can cause a deadlock of the iwarp stack. Here is the race:
->local side sets up an active offload connection.
->local side sends MPA_START request.
->peer sends MPA_START response.
->local side ingress cpl thread begins processing the MPA_START response, but before it changes the state from MPA_REQ_SENT to FPDU_MODE:
->peer sends a RST which results in a ABORT_REQ_RSS. This triggers peer_abort_intr() which sees the state in MPA_REQ_SENT and since mpa_rev is 2, it will avoid waking up the endpoint with -ECONNRESET, assuming the stack will re-attempt the connection using MPAv1.
->Meanwhile, the cpl thread moves the state to FPDU_MODE and calls c4iw_modify_rc_qp() which calls rdma_init() which sends a RI_WR/INIT WR to firmware. But since HW sent an abort, FW correctly drops the RI_WR/INIT WR.
->So the cpl thread is stuck waiting for a reply and cannot process the ABORT_REQ_RSS cpl sitting in its input queue. Thus everything comes to a halt because no more ingress cpls are processed by the stack...
The correct fix for the issue is to always do the wake up in c4iw_abort_intr() but reinitialize the wait object in c4iw_reconnect().
--- drivers/infiniband/hw/cxgb4/cm.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/infiniband/hw/cxgb4/cm.c +2 -10
@@ -1904,6 +1904,7 @@ static int c4iw_reconnect(struct c4iw_epPDBG ("%s qp %p cm_id %p\n" , __func__, ep->com.qp, ep->com.cm_id);init_timer (&ep->timer); +c4iw_init_wr_wait (&ep->com.wr_wait);/* * Allocate an active TID to initiate a TCP connection.
@@ -3875,16 +3876,7 @@ static int peer_abort_intr(struct c4iw_dPDBG ("%s ep %p tid %u state %u\n" , __func__, ep, ep->hwtid, ep->com.state); -/* -* Wake up any threads in rdma_init() or rdma_fini(). -* However, if we are on MPAv2 and want to retry with MPAv1 -* then, don't wake up yet. -*/ -if (mpa_rev ==2 && !ep->tried_with_mpa_v1) { -if (ep->com.state !=MPA_REQ_SENT ) -c4iw_wake_up (&ep->com.wr_wait, -ECONNRESET ); - }else -c4iw_wake_up (&ep->com.wr_wait, -ECONNRESET ); +c4iw_wake_up (&ep->com.wr_wait, -ECONNRESET );sched (dev, skb);return 0 ; }
PATCH 83/305 mmc: mmc: Fix partition switch timeout for some eMMCs
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit 1c447116d017a98c90f8f71c8c5a611e0aa42178 upstream.
Some eMMCs set the partition switch timeout too low.
Now typically eMMCs are considered a critical component (e.g. because they store the root file system) and consequently are expected to be reliable. Thus we can neglect the use case where eMMCs can't switch reliably and we might want a lower timeout to facilitate speedy recovery.
Although we could employ a quirk for the cards that are affected (if we could identify them all), as described above, there is little benefit to having a low timeout, so instead simply set a minimum timeout.
The minimum is set to 300ms somewhat arbitrarily - the examples that have been seen had a timeout of 10ms but were sometimes taking 60-70ms.
--- drivers/mmc/core/mmc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/core/mmc.c +7 -0
@@ -298,6 +298,9 @@ static void mmc_select_card_type(struct card->mmc_avail_type = avail_type; } +/* Minimum partition switch timeout in milliseconds */ +#define MMC_MIN_PART_SWITCH_TIME 300 +/* * Decode extended CSD. */
@@ -362,6 +365,10 @@ static int mmc_read_ext_csd(struct mmc_c/* EXT_CSD value is in units of 10ms, but we store in ms */ card->ext_csd.part_time =10 * ext_csd[EXT_CSD_PART_SWITCH_TIME ]; +/* Some eMMC set the value too low so set a minimum */ +if (card->ext_csd.part_time && + card->ext_csd.part_time <MMC_MIN_PART_SWITCH_TIME ) + card->ext_csd.part_time =MMC_MIN_PART_SWITCH_TIME ;/* Sleep / awake timeout in 100ns units */ if (sa_shift >0 && sa_shift <=0x17 )
PATCH 86/305 x86/PCI: Mark Broadwell-EP Home Agent 1 as having non-compliant BARs
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Prarit Bhargava <[email protected]>
commit da77b67195de1c65bef4908fa29967c4d0af2da2 upstream.
Commit b894157145e4 ("x86/PCI: Mark Broadwell-EP Home Agent & PCU as having non-compliant BARs") marked Home Agent 0 & PCU has having non-compliant BARs. Home Agent 1 also has non-compliant BARs.
Mark Home Agent 1 as having non-compliant BARs so the PCI core doesn't touch them.
The problem with these devices is documented in the Xeon v4 specification update:
BDF2 PCI BARs in the Home Agent Will Return Non-Zero Values
During Enumeration
Problem: During system initialization the Operating System may access
the standard PCI BARs (Base Address Registers). Due to this erratum, accesses to the Home Agent BAR registers (Bus 1; Device 18; Function 0,4; Offsets (0x14-0x24) will return non-zero values.
Implication: The operating system may issue a warning. Intel has not
observed any functional failures due to this erratum.
--- arch/x86/pci/fixup.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/pci/fixup.c +7 -0
@@ -554,9 +554,16 @@ static void twinhead_reserve_killing_zon }DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x27B9 , twinhead_reserve_killing_zone); +/* +* Broadwell EP Home Agent BARs erroneously return non-zero values when read. +* +* See http://www.intel.com/content/www/us/en/processors/xeon/xeon-e5-v4-spec-update.html +* entry BDF2. +*/ static void pci_bdwep_bar (struct pci_dev *dev) { dev->non_compliant_bars =1 ; } +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6f60 , pci_bdwep_bar);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6fa0 , pci_bdwep_bar);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x6fc0 , pci_bdwep_bar);
PATCH 91/305 drm/fb_helper: Fix references to dev->mode_config.num_connector
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lyude <[email protected]>
commit 255f0e7c418ad95a4baeda017ae6182ba9b3c423 upstream.
During boot, MST hotplugs are generally expected (even if no physical hotplugging occurs) and result in DRM's connector topology changing. This means that using num_connector from the current mode configuration can lead to the number of connectors changing under us. This can lead to some nasty scenarios in fbcon:
- We allocate an array to the size of dev->mode_config.num_connectors.
- MST hotplug occurs, dev->mode_config.num_connectors gets incremented.
- We try to loop through each element in the array using the new value of dev->mode_config.num_connectors, and end up going out of bounds since dev->mode_config.num_connectors is now larger then the array we allocated.
fb_helper->connector_count however, will always remain consistent while we do a modeset in fb_helper.
Note: This is just polish for 4.7, Dave Airlie's drm_connector refcounting fixed these bugs for real. But it's good enough duct-tape for stable kernel backporting, since backporting the refcounting changes is way too invasive.
[danvet: Clarify why we need this. Also remove the now unused "dev" local variable to appease gcc.]
--- drivers/gpu/drm/drm_fb_helper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +2 -3
@@ -1396,7 +1396,6 @@ static int drm_pick_crtcs(struct drm_fb_ int n, int width, int height) { int c, o; -struct drm_device *dev = fb_helper->dev;struct drm_connector *connector;struct drm_connector_helper_funcs *connector_funcs;struct drm_encoder *encoder;
@@ -1415,7 +1414,7 @@ static int drm_pick_crtcs(struct drm_fb_if (modes[n] ==NULL )return best_score; - crtcs =kzalloc (dev->mode_config.num_connector * + crtcs =kzalloc (fb_helper->connector_count *sizeof (struct drm_fb_helper_crtc *),GFP_KERNEL );if (!crtcs)return best_score;
@@ -1461,7 +1460,7 @@ static int drm_pick_crtcs(struct drm_fb_if (score > best_score) { best_score = score;memcpy (best_crtcs, crtcs, - dev->mode_config.num_connector * + fb_helper->connector_count *sizeof (struct drm_fb_helper_crtc *)); } }
PATCH 98/305 cpuidle: Fix cpuidle_state_is_coupled() argument in cpuidle_enter()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Lezcano <[email protected]>
commit e7387da52028b072489c45efeb7a916c0205ebd2 upstream.
Commit 0b89e9aa2856 (cpuidle: delay enabling interrupts until all coupled CPUs leave idle) rightfully fixed a regression by letting the coupled idle state framework to handle local interrupt enabling when the CPU is exiting an idle state.
The current code checks if the idle state is coupled and, if so, it will let the coupled code to enable interrupts. This way, it can decrement the ready-count before handling the interrupt. This mechanism prevents the other CPUs from waiting for a CPU which is handling interrupts.
But the check is done against the state index returned by the back end driver's ->enter functions which could be different from the initial index passed as parameter to the cpuidle_enter_state() function.
entered_state = target_state->enter(dev, drv, index);
[ ... ]
if (!cpuidle_state_is_coupled(drv, entered_state))
local_irq_enable();
[ ... ]
If the 'index' is referring to a coupled idle state but the 'entered_state' is *not* coupled, then the interrupts are enabled again. All CPUs blocked on the sync barrier may busy loop longer if the CPU has interrupts to handle before decrementing the ready-count. That's consuming more energy than saving.
--- drivers/cpuidle/cpuidle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/cpuidle.c +1 -1
@@ -125,7 +125,7 @@ int cpuidle_enter_state(struct cpuidle_d time_end =ktime_get (); -if (!cpuidle_state_is_coupled (dev, drv, entered_state)) +if (!cpuidle_state_is_coupled (dev, drv, index))local_irq_enable (); diff =ktime_to_us (ktime_sub (time_end, time_start));
PATCH 102/305 xfs: xfs_iflush_cluster fails to abort on error
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit b1438f477934f5a4d5a44df26f3079a7575d5946 upstream.
When a failure due to an inode buffer occurs, the error handling fails to abort the inode writeback correctly. This can result in the inode being reclaimed whilst still in the AIL, leading to use-after-free situations as well as filesystems that cannot be unmounted as the inode log items left in the AIL never get removed.
Fix this by ensuring fatal errors from xfs_imap_to_bp() result in the inode flush being aborted correctly.
--- fs/xfs/xfs_inode.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
fs/xfs/xfs_inode.c +13 -4
@@ -3151,7 +3151,7 @@ xfs_iflush( struct xfs_buf **bpp) {struct xfs_mount *mp = ip->i_mount; -struct xfs_buf *bp; +struct xfs_buf *bp =NULL ;struct xfs_dinode *dip;int error;
@@ -3193,14 +3193,22 @@ xfs_iflush( }/* -* Get the buffer containing the on-disk inode. +* Get the buffer containing the on-disk inode. We are doing a try-lock +* operation here, so we may get an EAGAIN error. In that case, we +* simply want to return with the inode still dirty. +* +* If we get any other error, we effectively have a corruption situation +* and we cannot flush the inode, so we treat it the same as failing +* xfs_iflush_int(). */ error =xfs_imap_to_bp (mp,NULL , &ip->i_imap, &dip, &bp,XBF_TRYLOCK ,0 ); -if (error || !bp) { +if (error == -EAGAIN ) {xfs_ifunlock (ip);return error; } +if (error) + goto corrupt_out;/* * First flush out the inode that xfs_iflush was called with.
@@ -3228,7 +3236,8 @@ xfs_iflush(return 0 ; corrupt_out: -xfs_buf_relse (bp); +if (bp) +xfs_buf_relse (bp);xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE ); cluster_corrupt_out: error =XFS_ERROR (EFSCORRUPTED );
PATCH 116/305 xen/events: Don't move disabled irqs
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ross Lagerwall <[email protected]>
commit f0f393877c71ad227d36705d61d1e4062bc29cf5 upstream.
Commit ff1e22e7a638 ("xen/events: Mask a moving irq") open-coded irq_move_irq() but left out checking if the IRQ is disabled. This broke resuming from suspend since it tries to move a (disabled) irq without holding the IRQ's desc->lock. Fix it by adding in a check for disabled IRQs.
The resulting stacktrace was:
kernel BUG at /build/linux-UbQGH5/linux-4.4.0/kernel/irq/migration.c:31! invalid opcode: 0000 [#1] SMP
Modules linked in: xenfs xen_privcmd ... CPU: 0 PID: 9 Comm: migration/0 Not tainted 4.4.0-22-generic #39-Ubuntu Hardware name: Xen HVM domU, BIOS 4.6.1-xs125180 05/04/2016 task: ffff88003d75ee00 ti: ffff88003d7bc000 task.ti: ffff88003d7bc000 RIP: 0010:[<ffffffff810e26e2>] [<ffffffff810e26e2>] irq_move_masked_irq+0xd2/0xe0 RSP: 0018:ffff88003d7bfc50 EFLAGS: 00010046 RAX: 0000000000000000 RBX: ffff88003d40ba00 RCX: 0000000000000001 RDX: 0000000000000001 RSI: 0000000000000100 RDI: ffff88003d40bad8 RBP: ffff88003d7bfc68 R08: 0000000000000000 R09: ffff88003d000000 R10: 0000000000000000 R11: 000000000000023c R12: ffff88003d40bad0 R13: ffffffff81f3a4a0 R14: 0000000000000010 R15: 00000000ffffffff FS: 0000000000000000(0000) GS:ffff88003da00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fd4264de624 CR3: 0000000037922000 CR4: 00000000003406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Stack: ffff88003d40ba38 0000000000000024 0000000000000000 ffff88003d7bfca0 ffffffff814c8d92 00000010813ef89d 00000000805ea732 0000000000000009 0000000000000024 ffff88003cc39b80 ffff88003d7bfce0 ffffffff814c8f66 Call Trace: [<ffffffff814c8d92>] eoi_pirq+0xb2/0xf0 [<ffffffff814c8f66>] __startup_pirq+0xe6/0x150 [<ffffffff814ca659>] xen_irq_resume+0x319/0x360 [<ffffffff814c7e75>] xen_suspend+0xb5/0x180 [<ffffffff81120155>] multi_cpu_stop+0xb5/0xe0 [<ffffffff811200a0>] ? cpu_stop_queue_work+0x80/0x80 [<ffffffff811203d0>] cpu_stopper_thread+0xb0/0x140 [<ffffffff810a94e6>] ? finish_task_switch+0x76/0x220 [<ffffffff810ca731>] ? __raw_callee_save___pv_queued_spin_unlock+0x11/0x20 [<ffffffff810a3935>] smpboot_thread_fn+0x105/0x160 [<ffffffff810a3830>] ? sort_range+0x30/0x30 [<ffffffff810a0588>] kthread+0xd8/0xf0 [<ffffffff810a04b0>] ? kthread_create_on_node+0x1e0/0x1e0 [<ffffffff8182568f>] ret_from_fork+0x3f/0x70 [<ffffffff810a04b0>] ? kthread_create_on_node+0x1e0/0x1e0
--- drivers/xen/events/events_base.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/xen/events/events_base.c +4 -2
@@ -486,7 +486,8 @@ static void eoi_pirq(struct irq_data *daif (!VALID_EVTCHN (evtchn))return ; -if (unlikely (irqd_is_setaffinity_pending (data))) { +if (unlikely (irqd_is_setaffinity_pending (data)) && +likely (!irqd_irq_disabled (data))) {int masked =test_and_set_mask (evtchn);clear_evtchn (evtchn);
@@ -1372,7 +1373,8 @@ static void ack_dynirq(struct irq_data *if (!VALID_EVTCHN (evtchn))return ; -if (unlikely (irqd_is_setaffinity_pending (data))) { +if (unlikely (irqd_is_setaffinity_pending (data)) && +likely (!irqd_irq_disabled (data))) {int masked =test_and_set_mask (evtchn);clear_evtchn (evtchn);
PATCH 117/305 UBI: do propagate positive error codes up
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Artem Bityutskiy <[email protected]>
commit 0e707ae79ba357d60b8a36025ec8968e5020d827 upstream.
UBI uses positive function return codes internally, and should not propagate them up, except in the place this path fixes. Here is the original bug report from Dan Carpenter:
The problem is really in ubi_eba_read_leb().
drivers/mtd/ubi/eba.c
412 err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1);
413 if (err && err != UBI_IO_BITFLIPS) {
414 if (err > 0) {
415 /*
416 * The header is either absent or corrupted. 417 * The former case means there is a bug - 418 * switch to read-only mode just in case. 419 * The latter case means a real corruption - we 420 * may try to recover data. FIXME: but this is 421 * not implemented. 422 */
423 if (err == UBI_IO_BAD_HDR_EBADMSG ||
424 err == UBI_IO_BAD_HDR) {
425 ubi_warn("corrupted VID header at PEB %d, LEB %d:%d",
426 pnum, vol_id, lnum);
427 err = -EBADMSG;
428 } else
429 ubi_ro_mode(ubi);
On this path we return UBI_IO_FF and UBI_IO_FF_BITFLIPS and it eventually gets passed to ERR_PTR(). We probably dereference the bad pointer and oops. At that point we've gone read only so it was already a bad situation...
430 } 431 goto out_free; 432 } else if (err == UBI_IO_BITFLIPS) 433 scrub = 1; 434
--- drivers/mtd/ubi/eba.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/ubi/eba.c +1 -0
@@ -426,6 +426,7 @@ retry: pnum, vol_id, lnum); err = -EBADMSG ; }else + err = -EINVAL ;ubi_ro_mode (ubi); } goto out_free;
PATCH 119/305 UBI: Fix static volume checks when Fastmap is used
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 1900149c835ab5b48bea31a823ea5e5a401fb560 upstream.
Ezequiel reported that he's facing UBI going into read-only mode after power cut. It turned out that this behavior happens only when updating a static volume is interrupted and Fastmap is used.
A possible trace can look like:
ubi0 warning: ubi_io_read_vid_hdr [ubi]: no VID header found at PEB 2323, only 0xFF bytes ubi0 warning: ubi_eba_read_leb [ubi]: switch to read-only mode
CPU: 0 PID: 833 Comm: ubiupdatevol Not tainted 4.6.0-rc2-ARCH #4 Hardware name: SAMSUNG ELECTRONICS CO., LTD. 300E4C/300E5C/300E7C/NP300E5C-AD8AR, BIOS P04RAP 10/15/2012 0000000000000286 00000000eba949bd ffff8800c45a7b38 ffffffff8140d841 ffff8801964be000 ffff88018eaa4800 ffff8800c45a7bb8 ffffffffa003abf6 ffffffff850e2ac0 8000000000000163 ffff8801850e2ac0 ffff8801850e2ac0 Call Trace: [<ffffffff8140d841>] dump_stack+0x63/0x82 [<ffffffffa003abf6>] ubi_eba_read_leb+0x486/0x4a0 [ubi] [<ffffffffa00453b3>] ubi_check_volume+0x83/0xf0 [ubi] [<ffffffffa0039d97>] ubi_open_volume+0x177/0x350 [ubi] [<ffffffffa00375d8>] vol_cdev_open+0x58/0xb0 [ubi] [<ffffffff8124b08e>] chrdev_open+0xae/0x1d0 [<ffffffff81243bcf>] do_dentry_open+0x1ff/0x300 [<ffffffff8124afe0>] ? cdev_put+0x30/0x30 [<ffffffff81244d36>] vfs_open+0x56/0x60 [<ffffffff812545f4>] path_openat+0x4f4/0x1190 [<ffffffff81256621>] do_filp_open+0x91/0x100 [<ffffffff81263547>] ? __alloc_fd+0xc7/0x190 [<ffffffff812450df>] do_sys_open+0x13f/0x210 [<ffffffff812451ce>] SyS_open+0x1e/0x20 [<ffffffff81a99e32>] entry_SYSCALL_64_fastpath+0x1a/0xa4
UBI checks static volumes for data consistency and reads the whole volume upon first open. If the volume is found erroneous users of UBI cannot read from it, but another volume update is possible to fix it. The check is performed by running ubi_eba_read_leb() on every allocated LEB of the volume. For static volumes ubi_eba_read_leb() computes the checksum of all data stored in a LEB. To verify the computed checksum it has to read the LEB's volume header which stores the original checksum. If the volume header is not found UBI treats this as fatal internal error and switches to RO mode. If the UBI device was attached via a full scan the assumption is correct, the volume header has to be present as it had to be there while scanning to get known as mapped. If the attach operation happened via Fastmap the assumption is no longer correct. When attaching via Fastmap UBI learns the mapping table from Fastmap's snapshot of the system state and not via a full scan. It can happen that a LEB got unmapped after a Fastmap was written to the flash. Then UBI can learn the LEB still as mapped and accessing it returns only 0xFF bytes. As UBI is not a FTL it is allowed to have mappings to empty PEBs, it assumes that the layer above takes care of LEB accounting and referencing.
UBIFS does so using the LEB property tree (LPT).
For static volumes UBI blindly assumes that all LEBs are present and therefore special actions have to be taken.
The described situation can happen when updating a static volume is interrupted, either by a user or a power cut.
The volume update code first unmaps all LEBs of a volume and then writes LEB by LEB. If the sequence of operations is interrupted UBI detects this either by the absence of LEBs, no volume header present at scan time, or corrupted payload, detected via checksum. In the Fastmap case the former method won't trigger as no scan happened and UBI automatically thinks all LEBs are present. Only by reading data from a LEB it detects that the volume header is missing and incorrectly treats this as fatal error.
To deal with the situation ubi_eba_read_leb() from now on checks whether we attached via Fastmap and handles the absence of a volume header like a data corruption error.
This way interrupted static volume updates will correctly get detected also when Fastmap is used.
--- drivers/mtd/ubi/eba.c | 21 +++++++++++++++++++-- drivers/mtd/ubi/fastmap.c | 1 + drivers/mtd/ubi/ubi.h | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/mtd/ubi/eba.c +19 -2
@@ -426,8 +426,25 @@ retry: pnum, vol_id, lnum); err = -EBADMSG ; }else { - err = -EINVAL ; -ubi_ro_mode (ubi); +/* +* Ending up here in the non-Fastmap case +* is a clear bug as the VID header had to +* be present at scan time to have it referenced. +* With fastmap the story is more complicated. +* Fastmap has the mapping info without the need +* of a full scan. So the LEB could have been +* unmapped, Fastmap cannot know this and keeps +* the LEB referenced. +* This is valid and works as the layer above UBI +* has to do bookkeeping about used/referenced +* LEBs in any case. +*/ +if (ubi->fast_attach) { + err = -EBADMSG ; + }else { + err = -EINVAL ; +ubi_ro_mode (ubi); + } } } goto out_free;
drivers/mtd/ubi/fastmap.c +1 -0
@@ -1070,6 +1070,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi_msg ("fastmap pool size: %d" , ubi->fm_pool.max_size);ubi_msg ("fastmap WL pool size: %d" , ubi->fm_wl_pool.max_size); ubi->fm_disabled =0 ; + ubi->fast_attach =1 ;ubi_free_vid_hdr (ubi, vh);kfree (ech);
drivers/mtd/ubi/ubi.h +2 -0
@@ -426,6 +426,7 @@ struct ubi_debug_info {* @fm_size: fastmap size in bytes * @fm_sem: allows ubi_update_fastmap() to block EBA table changes * @fm_work: fastmap work queue +* @fast_attach: non-zero if UBI was attached by fastmap * * @used: RB-tree of used physical eraseblocks * @erroneous: RB-tree of erroneous used physical eraseblocks
@@ -531,6 +532,7 @@ struct ubi_device {void *fm_buf;size_t fm_size;struct work_struct fm_work; +int fast_attach;/* Wear-leveling sub-system's stuff */ struct rb_root used;
PATCH 120/305 RDMA/cxgb3: device driver frees DMA memory with different size
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Honggang Li <[email protected]>
commit 0de4cbb3dddca35ecd06b95918f38439c9c6401f upstream.
[ 598.852037] ------------[ cut here ]------------ [ 598.856698] WARNING: at lib/dma-debug.c:887 check_unmap+0xf8/0x920() [ 598.863079] cxgb3 0000:01:00.0: DMA-API: device driver frees DMA memory with different size [device address=0x0000000003310000] [map size=17 bytes] [unmap size=16 bytes] [ 598.878265] Modules linked in: xprtrdma ib_isert iscsi_target_mod ib_iser libiscsi scsi_transport_iscsi ib_srpt target_core_mod ib_srp scsi_transport_srp scsi_tgt ib_ipoib rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm ib_sa ib_mad kvm_amd kvm ipmi_devintf ipmi_ssif dcdbas pcspkr ipmi_si sg ipmi_msghandler acpi_power_meter amd64_edac_mod shpchp edac_core sp5100_tco k10temp edac_mce_amd i2c_piix4 acpi_cpufreq nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c sd_mod crc_t10dif crct10dif_generic crct10dif_common ata_generic iw_cxgb3 pata_acpi ib_core ib_addr mgag200 syscopyarea sysfillrect sysimgblt i2c_algo_bit drm_kms_helper ttm pata_atiixp drm ahci libahci serio_raw i2c_core cxgb3 libata bnx2 mdio dm_mirror dm_region_hash dm_log dm_mod [ 598.946822] CPU: 3 PID: 11820 Comm: cmtime Not tainted 3.10.0-327.el7.x86_64.debug #1 [ 598.954681] Hardware name: Dell Inc. PowerEdge R415/0GXH08, BIOS 2.0.2 10/22/2012 [ 598.962193] ffff8808077479a8 000000000381a432 ffff880807747960 ffffffff81700918 [ 598.969663] ffff880807747998 ffffffff8108b6c0 ffff880807747a80 ffff8808063f55c0 [ 598.977132] ffffffff833ca850 0000000000000282 ffff88080b1bb800 ffff880807747a00 [ 598.984602] Call Trace: [ 598.987062] [<ffffffff81700918>] dump_stack+0x19/0x1b [ 598.992224] [<ffffffff8108b6c0>] warn_slowpath_common+0x70/0xb0 [ 598.998254] [<ffffffff8108b75c>] warn_slowpath_fmt+0x5c/0x80 [ 599.004033] [<ffffffff813903b8>] check_unmap+0xf8/0x920 [ 599.009369] [<ffffffff81025959>] ? sched_clock+0x9/0x10 [ 599.014702] [<ffffffff81390cee>] debug_dma_free_coherent+0x7e/0xa0 [ 599.021008] [<ffffffffa01ece2c>] cxio_destroy_cq+0xcc/0x160 [iw_cxgb3] [ 599.027654] [<ffffffffa01e8da0>] iwch_destroy_cq+0xf0/0x140 [iw_cxgb3] [ 599.034307] [<ffffffffa01c4bfe>] ib_destroy_cq+0x1e/0x30 [ib_core] [ 599.040601] [<ffffffffa04ff2d2>] ib_uverbs_close+0x302/0x4d0 [ib_uverbs] [ 599.047417] [<ffffffff812335a2>] __fput+0x102/0x310 [ 599.052401] [<ffffffff8123388e>] ____fput+0xe/0x10 [ 599.057297] [<ffffffff810bbde4>] task_work_run+0xb4/0xe0 [ 599.062719] [<ffffffff81092a84>] do_exit+0x304/0xc60 [ 599.067789] [<ffffffff81025905>] ? native_sched_clock+0x35/0x80 [ 599.073820] [<ffffffff81025959>] ? sched_clock+0x9/0x10 [ 599.079153] [<ffffffff8170a49c>] ? _raw_spin_unlock_irq+0x2c/0x50 [ 599.085358] [<ffffffff8109346c>] do_group_exit+0x4c/0xc0 [ 599.090779] [<ffffffff810a8661>] get_signal_to_deliver+0x2e1/0x960 [ 599.097071] [<ffffffff8101c497>] do_signal+0x57/0x6e0 [ 599.102229] [<ffffffff81714bd1>] ? sysret_signal+0x5/0x4e [ 599.107738] [<ffffffff8101cb7f>] do_notify_resume+0x5f/0xb0 [ 599.113418] [<ffffffff81714e7d>] int_signal+0x12/0x17 [ 599.118576] ---[ end trace 1e4653102e7e7019 ]--- [ 599.123211] Mapped at: [ 599.125577] [<ffffffff8138ed8b>] debug_dma_alloc_coherent+0x2b/0x80 [ 599.131968] [<ffffffffa01ec862>] cxio_create_cq+0xf2/0x1f0 [iw_cxgb3] [ 599.139920] [<ffffffffa01e9c05>] iwch_create_cq+0x105/0x4e0 [iw_cxgb3] [ 599.147895] [<ffffffffa0500584>] create_cq.constprop.14+0x184/0x2e0 [ib_uverbs] [ 599.156649] [<ffffffffa05027fb>] ib_uverbs_create_cq+0x10b/0x140 [ib_uverbs]
--- drivers/infiniband/hw/cxgb3/cxio_hal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/cxgb3/cxio_hal.c +1 -1
@@ -327,7 +327,7 @@ int cxio_destroy_cq(struct cxio_rdev *rdkfree (cq->sw_queue);dma_free_coherent (&(rdev_p->rnic_info.pdev->dev), (1UL << (cq->size_log2)) - *sizeof (struct t3_cqe ), cq->queue, + *sizeof (struct t3_cqe ) +1 , cq->queue,dma_unmap_addr (cq, mapping));cxio_hal_put_cqid (rdev_p->rscp, cq->cqid);return err;
PATCH 124/305 dma-debug: avoid spinlock recursion when disabling dma-debug
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 3017cd63f26fc655d56875aaf497153ba60e9edf upstream.
With netconsole (at least) the pr_err("... disablingn") call can recurse back into the dma-debug code, where it'll try to grab free_entries_lock again. Avoid the problem by doing the printk after dropping the lock.
--- lib/dma-debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dma-debug.c +1 -1
@@ -646,9 +646,9 @@ static struct dma_debug_entry *dma_entryspin_lock_irqsave (&free_entries_lock, flags);if (list_empty (&free_entries)) { -pr_err ("DMA-API: debugging out of memory - disabling\n" ); global_disable = true;spin_unlock_irqrestore (&free_entries_lock, flags); +pr_err ("DMA-API: debugging out of memory - disabling\n" );return NULL ; }
PATCH 126/305 Input: pwm-beeper - remove useless call to pwm_config()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Olivier Sobrie <[email protected]>
commit d1b12075ffa808dce33dd46b7ad035bebf8da215 upstream.
Calling pwm_config() with a period equal to zero always results in error (-EINVAL) and pwm chip config method is never called.
--- drivers/input/misc/pwm-beeper.c | 1 - 1 file changed, 1 deletion(-)
drivers/input/misc/pwm-beeper.c +0 -1
@@ -50,7 +50,6 @@ static int pwm_beeper_event(struct input }if (value ==0 ) { -pwm_config (beeper->pwm,0 ,0 );pwm_disable (beeper->pwm); }else { period =HZ_TO_NANOSECONDS (value);
PATCH 128/305 MIPS: fix read_msa_* & write_msa_* functions on non-MSA toolchains
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit 70dff4d90aab40326d1d06a331e2b07eae99d067 upstream.
Commit d96cc3d1ec5d "MIPS: Add microMIPS MSA support." attempted to use the value of a macro within an inline asm statement but instead emitted a comment leading to the cfcmsa & ctcmsa instructions being omitted. Fix that by passing CFC_MSA_INSN & CTC_MSA_INSN as arguments to the asm statements.
Patchwork: https://patchwork.linux-mips.org/patch/7305/
--- arch/mips/include/asm/msa.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/mips/include/asm/msa.h +4 -4
@@ -112,10 +112,10 @@ static inline unsigned int read_msa_##na" .set push\n" \" .set noat\n" \" .insn\n" \ - " .word #CFC_MSA_INSN | (" #cs " << 11)\n" \ + " .word %1 | (" #cs " << 11)\n" \ " move %0, $1\n" \ " .set pop\n" \ - : "=r"(reg)); \ + : "=r"(reg) : "i"(CFC_MSA_INSN)); \ return reg; \ } \ \
@@ -126,9 +126,9 @@ static inline void write_msa_##name(unsi" .set noat\n" \" move $1, %0\n" \" .insn\n" \ - " .word #CTC_MSA_INSN | (" #cs " << 6)\n" \ + " .word %1 | (" #cs " << 6)\n" \ " .set pop\n" \ - : : "r"(val)); \ + : : "r"(val), "i"(CTC_MSA_INSN)); \ }#endif /* !TOOLCHAIN_SUPPORTS_MSA */
PATCH 129/305 hpfs: fix remount failure when there are no options changed
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 44d51706b4685f965cd32acde3fe0fcc1e6198e8 upstream.
Commit ce657611baf9 ("hpfs: kstrdup() out of memory handling") checks if the kstrdup function returns NULL due to out-of-memory condition.
However, if we are remounting a filesystem with no change to filesystem-specific options, the parameter data is NULL. In this case, kstrdup returns NULL (because it was passed NULL parameter), although no out of memory condition exists. The mount syscall then fails with ENOMEM.
This patch fixes the bug. We fail with ENOMEM only if data is non-NULL.
The patch also changes the call to replace_mount_options - if we didn't pass any filesystem-specific options, we don't call replace_mount_options (thus we don't erase existing reported options).
--- fs/hpfs/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/hpfs/super.c +3 -2
@@ -428,7 +428,7 @@ static int hpfs_remount_fs(struct super_struct hpfs_sb_info *sbi =hpfs_sb (s);char *new_opts =kstrdup (data,GFP_KERNEL ); -if (!new_opts) +if (data && !new_opts)return -ENOMEM ;sync_filesystem (s);
@@ -466,7 +466,8 @@ static int hpfs_remount_fs(struct super_if (!(*flags &MS_RDONLY ))mark_dirty (s,1 ); -replace_mount_options (s, new_opts); +if (new_opts) +replace_mount_options (s, new_opts);hpfs_unlock (s);return 0 ;
PATCH 142/305 KVM: x86: fix OOPS after invalid KVM_SET_DEBUGREGS
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit d14bdb553f9196169f003058ae1cdabe514470e6 upstream.
MOV to DR6 or DR7 causes a #GP if an attempt is made to write a 1 to any of bits 63:32. However, this is not detected at KVM_SET_DEBUGREGS time, and the next KVM_RUN oopses:
general protection fault: 0000 [#1] SMP
CPU: 2 PID: 14987 Comm: a.out Not tainted 4.4.9-300.fc23.x86_64 #1
Hardware name: LENOVO 2325F51/2325F51, BIOS G2ET32WW (1.12 ) 05/30/2012
[...]
Call Trace:
[<ffffffffa072c93d>] kvm_arch_vcpu_ioctl_run+0x141d/0x14e0 [kvm]
[<ffffffffa071405d>] kvm_vcpu_ioctl+0x33d/0x620 [kvm]
[<ffffffff81241648>] do_vfs_ioctl+0x298/0x480
[<ffffffff812418a9>] SyS_ioctl+0x79/0x90
[<ffffffff817a0f2e>] entry_SYSCALL_64_fastpath+0x12/0x71
Code: 55 83 ff 07 48 89 e5 77 27 89 ff ff 24 fd 90 87 80 81 0f 23 fe 5d c3 0f 23 c6 5d c3 0f 23 ce 5d c3 0f 23 d6 5d c3 0f 23 de 5d c3 <0f> 23 f6 5d c3 0f 0b 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00
RIP [<ffffffff810639eb>] native_set_debugreg+0x2b/0x40
RSP <ffff88005836bd50>Testcase (beautified/reduced from syzkaller output):
#include <unistd.h>
#include <sys/syscall.h>
#include <string.h>
#include <stdint.h>
#include <linux/kvm.h>
#include <fcntl.h>
#include <sys/ioctl.h>
long r[8];
int main()
{
struct kvm_debugregs dr = { 0 };
r[2] = open("/dev/kvm", O_RDONLY);
r[3] = ioctl(r[2], KVM_CREATE_VM, 0);
r[4] = ioctl(r[3], KVM_CREATE_VCPU, 7);
memcpy(&dr,
"\x5d\x6a\x6b\xe8\x57\x3b\x4b\x7e\xcf\x0d\xa1\x72"
"\xa3\x4a\x29\x0c\xfc\x6d\x44\x00\xa7\x52\xc7\xd8"
"\x00\xdb\x89\x9d\x78\xb5\x54\x6b\x6b\x13\x1c\xe9"
"\x5e\xd3\x0e\x40\x6f\xb4\x66\xf7\x5b\xe3\x36\xcb",
48);
r[7] = ioctl(r[4], KVM_SET_DEBUGREGS, &dr);
r[6] = ioctl(r[4], KVM_RUN, 0);
}--- arch/x86/kvm/x86.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/x86/kvm/x86.c +5 -0
@@ -3069,6 +3069,11 @@ static int kvm_vcpu_ioctl_x86_set_debugrif (dbgregs->flags)return -EINVAL ; +if (dbgregs->dr6 & ~0xffffffffull ) +return -EINVAL ; +if (dbgregs->dr7 & ~0xffffffffull ) +return -EINVAL ; +memcpy (vcpu->arch.db, dbgregs->db,sizeof (vcpu->arch.db)); vcpu->arch.dr6 = dbgregs->dr6;kvm_update_dr6 (vcpu);
PATCH 150/305 IB/mlx5: Fix returned values of query QP
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Noa Osherovich <[email protected]>
commit 0540d8148d419bf769e5aa99c77027febd8922f0 upstream.
Some variables were not initialized properly: max_recv_wr, max_recv_sge, max_send_wr, qp_context and max_inline_data.
--- drivers/infiniband/hw/mlx5/qp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +9 -5
@@ -169,6 +169,8 @@ static int set_rq_size(struct mlx5_ib_de qp->rq.max_gs =0 ; qp->rq.wqe_cnt =0 ; qp->rq.wqe_shift =0 ; + cap->max_recv_wr =0 ; + cap->max_recv_sge =0 ; }else {if (ucmd) { qp->rq.wqe_cnt = ucmd->rq_wqe_count;
@@ -2979,17 +2981,19 @@ int mlx5_ib_query_qp(struct ib_qp *ibqp, qp_attr->cap.max_recv_sge = qp->rq.max_gs;if (!ibqp->uobject) { - qp_attr->cap.max_send_wr = qp->sq.wqe_cnt; + qp_attr->cap.max_send_wr = qp->sq.max_post; qp_attr->cap.max_send_sge = qp->sq.max_gs; + qp_init_attr->qp_context = ibqp->qp_context; }else { qp_attr->cap.max_send_wr =0 ; qp_attr->cap.max_send_sge =0 ; } -/* We don't support inline sends for kernel QPs (yet), and we -* don't know what userspace's value should be. -*/ - qp_attr->cap.max_inline_data =0 ; + qp_init_attr->qp_type = ibqp->qp_type; + qp_init_attr->recv_cq = ibqp->recv_cq; + qp_init_attr->send_cq = ibqp->send_cq; + qp_init_attr->srq = ibqp->srq; + qp_attr->cap.max_inline_data = qp->max_inline_data; qp_init_attr->cap = qp_attr->cap;
PATCH 154/305 of: fix autoloading due to broken modalias with no 'compatible'
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
commit b3c0a4dab7e35a9b6d69c0415641d2280fdefb2b upstream.
Because of an improper dereference, a stray 'C' character was output to the modalias when no 'compatible' was specified. This is the case for some old PowerMac drivers which only set the 'name' property. Fix it to let them match again.
--- scripts/mod/file2alias.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/file2alias.c +1 -1
@@ -653,7 +653,7 @@ static int do_of_entry (const char *file len =sprintf (alias,"of:N%sT%s" , (*name)[0 ] ? *name :"*" , (*type)[0 ] ? *type :"*" ); -if (compatible[0 ]) +if ((*compatible)[0 ])sprintf (&alias[len],"%sC%s" , (*type)[0 ] ?"*" :"" , *compatible);
PATCH 157/305 gpio: bcm-kona: fix bcm_kona_gpio_reset() warnings
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Dooks <[email protected]>
commit b66b2a0adf0e48973b582e055758b9907a7eee7c upstream.
The bcm_kona_gpio_reset() calls bcm_kona_gpio_write_lock_regs() with what looks like the wrong parameter. The write_lock_regs function takes a pointer to the registers, not the bcm_kona_gpio structure.
Fix the warning, and probably bug by changing the function to pass reg_base instead of kona_gpio, fixing the following warning:
drivers/gpio/gpio-bcm-kona.c:550:47: warning: incorrect type in argument 1
(different address spaces)
expected void [noderef] <asn:2>*reg_base
got struct bcm_kona_gpio *kona_gpio
warning: incorrect type in argument 1 (different address spaces) expected void [noderef] <asn:2>*reg_base
got struct bcm_kona_gpio *kona_gpio
--- drivers/gpio/gpio-bcm-kona.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-bcm-kona.c +2 -2
@@ -549,11 +549,11 @@ static void bcm_kona_gpio_reset(struct b/* disable interrupts and clear status */ for (i =0 ; i < kona_gpio->num_bank; i++) {/* Unlock the entire bank first */ -bcm_kona_gpio_write_lock_regs (kona_gpio, i,UNLOCK_CODE ); +bcm_kona_gpio_write_lock_regs (reg_base, i,UNLOCK_CODE );writel (0xffffffff , reg_base +GPIO_INT_MASK (i));writel (0xffffffff , reg_base +GPIO_INT_STATUS (i));/* Now re-lock the bank */ -bcm_kona_gpio_write_lock_regs (kona_gpio, i,LOCK_CODE ); +bcm_kona_gpio_write_lock_regs (reg_base, i,LOCK_CODE ); } }
PATCH 168/305 usb: f_fs: off by one bug in _ffs_func_bind()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 0015f9156092d07b3ec06d37d014328419d5832e upstream.
This loop is supposed to set all the .num[] values to -1 but it's off by one so it skips the first element and sets one element past the end of the array.
I've cleaned up the loop a little as well.
[bwh: Backported to 3.16:
- Adjust filename, context
- Add definition of i variable]
--- drivers/usb/gadget/f_fs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/usb/gadget/f_fs.c +5 -7
@@ -2355,7 +2355,8 @@ static int _ffs_func_bind(struct usb_conconst int super =gadget_is_superspeed (func->gadget) && func->ffs->ss_descs_count; -int fs_len, hs_len, ret; +int fs_len, hs_len, ret, i; +struct ffs_ep *eps_ptr;/* Make it a single chunk, less management later on */ vla_group (d);
@@ -2388,12 +2389,9 @@ static int _ffs_func_bind(struct usb_con ffs->raw_descs_length);memset (vla_ptr (vlabuf, d, inums),0xff , d_inums__sz); -for (ret = ffs->eps_count; ret; --ret) { -struct ffs_ep *ptr; - - ptr =vla_ptr (vlabuf, d, eps); - ptr[ret].num =-1 ; - } + eps_ptr =vla_ptr (vlabuf, d, eps); +for (i =0 ; i < ffs->eps_count; i++) + eps_ptr[i].num =-1 ;/* Save pointers * d_eps == vlabuf, func->eps used to kfree vlabuf later
PATCH 171/305 HID: elo: kill not flush the work
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit ed596a4a88bd161f868ccba078557ee7ede8a6ef upstream.
Flushing a work that reschedules itself is not a sensible operation. It needs to be killed. Failure to do so leads to a kernel panic in the timer code.
--- drivers/hid/hid-elo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-elo.c +1 -1
@@ -259,7 +259,7 @@ static void elo_remove(struct hid_devicestruct elo_priv *priv =hid_get_drvdata (hdev);hid_hw_stop (hdev); -flush_workqueue (wq); +cancel_delayed_work_sync (&priv->work);kfree (priv); }
PATCH 172/305 usb: xhci-plat: properly handle probe deferral for devm_clk_get()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Petazzoni <[email protected]>
commit de95c40d5beaa47f6dc8fe9ac4159b4672b51523 upstream.
On some platforms, the clocks might be registered by a platform driver. When this is the case, the clock platform driver may very well be probed after xhci-plat, in which case the first probe() invocation of xhci-plat will receive -EPROBE_DEFER as the return value of devm_clk_get().
The current code handles that as a normal error, and simply assumes that this means that the system doesn't have a clock for the XHCI controller, and continues probing without calling clk_prepare_enable(). Unfortunately, this doesn't work on systems where the XHCI controller does have a clock, but that clock is provided by another platform driver. In order to fix this situation, we handle the -EPROBE_DEFER error condition specially, and abort the XHCI controller probe(). It will be retried later automatically, the clock will be available, devm_clk_get() will succeed, and the probe() will continue with the clock prepared and enabled as expected.
In practice, such issue is seen on the ARM64 Marvell 7K/8K platform, where the clocks are registered by a platform driver.
--- drivers/usb/host/xhci-plat.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-plat.c +3 -0
@@ -154,6 +154,9 @@ static int xhci_plat_probe(struct platfo ret =clk_prepare_enable (clk);if (ret) goto unmap_registers; + }else if (PTR_ERR (clk) == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto unmap_registers; } if (of_device_is_compatible(pdev->dev.of_node,
PATCH 174/305 usb: quirks: Fix sorting
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 81099f97bd31e25ff2719a435b1860fc3876122f upstream.
Properly sort all the entries by vendor id.
--- drivers/usb/core/quirks.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/usb/core/quirks.c +10 -10
@@ -44,6 +44,9 @@ static const struct usb_device_id usb_qu/* Creative SB Audigy 2 NX */ { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, + /* USB3503 */ + { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME }, + /* Microsoft Wireless Laser Mouse 6000 Receiver */ { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
@@ -167,6 +170,10 @@ static const struct usb_device_id usb_qu/* MAYA44USB sound device */ { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME }, + /* ASUS Base Station(T100) */ + { USB_DEVICE(0x0b05, 0x17e0), .driver_info = + USB_QUIRK_IGNORE_REMOTE_WAKEUP }, + /* Action Semiconductor flash disk */ { USB_DEVICE(0x10d6, 0x2200), .driver_info = USB_QUIRK_STRING_FETCH_255 },
@@ -182,16 +189,6 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x1908, 0x1315), .driver_info = USB_QUIRK_HONOR_BNUMINTERFACES }, - /* INTEL VALUE SSD */ - { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, - - /* USB3503 */ - { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME }, - - /* ASUS Base Station(T100) */ - { USB_DEVICE(0x0b05, 0x17e0), .driver_info = - USB_QUIRK_IGNORE_REMOTE_WAKEUP }, - /* Protocol and OTG Electrical Test Device */ { USB_DEVICE(0x1a0a, 0x0200), .driver_info = USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
@@ -202,6 +199,9 @@ static const struct usb_device_id usb_qu/* Blackmagic Design UltraStudio SDI */ { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM }, + /* INTEL VALUE SSD */ + { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, + { }/* terminating entry must be last */ };
PATCH 176/305 USB: xhci: Add broken streams quirk for Frescologic device id 1009
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit d95815ba6a0f287213118c136e64d8c56daeaeab upstream.
I got one of these cards for testing uas with, it seems that with streams it dma-s all over the place, corrupting memory. On my first tests it managed to dma over the BIOS of the motherboard somehow and completely bricked it.
Tests on another motherboard show that it does work with streams disabled.
--- drivers/usb/host/xhci-pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/host/xhci-pci.c +5 -0
@@ -30,6 +30,7 @@/* Device for a quirk */ #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 +#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1009 0x1009#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400#define PCI_VENDOR_ID_ETRON 0x1b6f
@@ -99,6 +100,10 @@ static void xhci_pci_quirks(struct devic xhci->quirks |=XHCI_TRUST_TX_LENGTH ; } +if (pdev->vendor ==PCI_VENDOR_ID_FRESCO_LOGIC && + pdev->device ==PCI_DEVICE_ID_FRESCO_LOGIC_FL1009 ) + xhci->quirks |=XHCI_BROKEN_STREAMS ; +if (pdev->vendor ==PCI_VENDOR_ID_NEC ) xhci->quirks |=XHCI_NEC_HOST ;
PATCH 177/305 usb: musb: Ensure rx reinit occurs for shared_fifo endpoints
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Goodbody <[email protected]>
commit f3eec0cf784e0d6c47822ca6b66df3d5812af7e6 upstream.
shared_fifo endpoints would only get a previous tx state cleared out, the rx state was only cleared for non shared_fifo endpoints Change this so that the rx state is cleared for all endpoints. This addresses an issue that resulted in rx packets being dropped silently.
--- drivers/usb/musb/musb_host.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/usb/musb/musb_host.c +6 -7
@@ -583,14 +583,13 @@ musb_rx_reinit(struct musb *musb, structmusb_writew (ep->regs,MUSB_TXCSR ,0 );/* scrub all previous state, clearing toggle */ - }else { - csr =musb_readw (ep->regs,MUSB_RXCSR ); -if (csr &MUSB_RXCSR_RXPKTRDY ) -WARNING ("rx%d, packet/%d ready?\n" , ep->epnum, -musb_readw (ep->regs,MUSB_RXCOUNT )); - -musb_h_flush_rxfifo (ep,MUSB_RXCSR_CLRDATATOG ); } + csr =musb_readw (ep->regs,MUSB_RXCSR ); +if (csr &MUSB_RXCSR_RXPKTRDY ) +WARNING ("rx%d, packet/%d ready?\n" , ep->epnum, +musb_readw (ep->regs,MUSB_RXCOUNT )); + +musb_h_flush_rxfifo (ep,MUSB_RXCSR_CLRDATATOG );/* target addr and (for multipoint) hub addr/port */ if (musb->is_multipoint) {
PATCH 180/305 scsi: fix race between simultaneous decrements of ->host_failed
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wei Fang <[email protected]>
commit 72d8c36ec364c82bf1bf0c64dfa1041cfaf139f7 upstream.
sas_ata_strategy_handler() adds the works of the ata error handler to system_unbound_wq. This workqueue asynchronously runs work items, so the ata error handler will be performed concurrently on different CPUs. In this case, ->host_failed will be decreased simultaneously in scsi_eh_finish_cmd() on different CPUs, and become abnormal.
It will lead to permanently inequality between ->host_failed and ->host_busy, and scsi error handler thread won't start running. IO errors after that won't be handled.
Since all scmds must have been handled in the strategy handler, just remove the decrement in scsi_eh_finish_cmd() and zero ->host_busy after the strategy handler to fix this race.
--- Documentation/scsi/scsi_eh.txt | 8 ++++++-- drivers/ata/libata-eh.c | 2 +- drivers/scsi/scsi_error.c | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-)
Documentation/scsi/scsi_eh.txt +6 -2
@@ -263,19 +263,23 @@ scmd->allowed. 3. scmd recovered ACTION: scsi_eh_finish_cmd() is invoked to EH-finish scmd - - shost->host_failed-- - clear scmd->eh_eflags - scsi_setup_cmd_retry() - move from local eh_work_q to local eh_done_q LOCKING: none + CONCURRENCY: at most one thread per separate eh_work_q to + keep queue manipulation lockless 4. EH completes ACTION: scsi_eh_flush_done_q() retries scmds or notifies upper - layer of failure. + layer of failure. May be called concurrently but must have + a no more than one thread per separate eh_work_q to + manipulate the queue locklessly - scmd is removed from eh_done_q and scmd->eh_entry is cleared - if retry is necessary, scmd is requeued using scsi_queue_insert() - otherwise, scsi_finish_command() is invoked for scmd + - zero shost->host_failed LOCKING: queue or finish function performs appropriate locking
drivers/ata/libata-eh.c +1 -1
@@ -605,7 +605,7 @@ void ata_scsi_error(struct Scsi_Host *hoata_scsi_port_error_handler (host, ap);/* finish or retry handled scmd's and clean up */ -WARN_ON (host->host_failed || !list_empty (&eh_work_q)); +WARN_ON (!list_empty (&eh_work_q));DPRINTK ("EXIT\n" ); }
drivers/scsi/scsi_error.c +3 -1
@@ -1115,7 +1115,6 @@ static int scsi_eh_action(struct scsi_cm*/ void scsi_eh_finish_cmd (struct scsi_cmnd *scmd,struct list_head *done_q) { - scmd->device->host->host_failed--; scmd->eh_eflags =0 ;list_move_tail (&scmd->eh_entry, done_q); }
@@ -2198,6 +2197,9 @@ int scsi_error_handler(void *data)else scsi_unjam_host (shost); +/* All scmds have been handled */ + shost->host_failed =0 ; +/* * Note - if the above fails completely, the action is to take * individual devices offline and flush the queue of any
PATCH 183/305 crypto: ux500 - memmove the right size
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit 19ced623db2fe91604d69f7d86b03144c5107739 upstream.
The hash buffer is really HASH_BLOCK_SIZE bytes, someone must have thought that memmove takes n*u32 words by mistake. Tests work as good/bad as before after this patch.
--- drivers/crypto/ux500/hash/hash_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/ux500/hash/hash_core.c +2 -2
@@ -797,7 +797,7 @@ static int hash_process_data(struct hash &device_data->state);memmove (req_ctx->state.buffer, device_data->state.buffer, -HASH_BLOCK_SIZE /sizeof (u32)); +HASH_BLOCK_SIZE );if (ret) { dev_err(device_data->dev, "%s: hash_resume_state() failed!\n",
@@ -848,7 +848,7 @@ static int hash_process_data(struct hashmemmove (device_data->state.buffer, req_ctx->state.buffer, -HASH_BLOCK_SIZE /sizeof (u32)); +HASH_BLOCK_SIZE );if (ret) {dev_err (device_data->dev,"%s: hash_save_state() failed!\n" , __func__);
PATCH 184/305 drm/radeon: fix asic initialization for virtualized environments
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 05082b8bbd1a0ffc74235449c4b8930a8c240f85 upstream.
When executing in a PCI passthrough based virtuzliation environment, the hypervisor will usually attempt to send a PCIe bus reset signal to the ASIC when the VM reboots. In this scenario, the card is not correctly initialized, but we still consider it to be posted. Therefore, in a passthrough based environemnt we should always post the card to guarantee it is in a good state for driver initialization.
Ported from amdgpu commit:
amdgpu: fix asic initialization for virtualized environments
--- drivers/gpu/drm/radeon/radeon_device.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/gpu/drm/radeon/radeon_device.c +21 -0
@@ -598,6 +598,23 @@ void radeon_gtt_location(struct radeon_d/* * GPU helpers function. */ + +/** +* radeon_device_is_virtual - check if we are running is a virtual environment +* +* Check if the asic has been passed through to a VM (all asics). +* Used at driver startup. +* Returns true if virtual or false if not. +*/ +static bool radeon_device_is_virtual (void ) +{ +#ifdef CONFIG_X86 +return boot_cpu_has (X86_FEATURE_HYPERVISOR ); +#else +return false; +#endif +} +/** * radeon_card_posted - check if the hw has already been initialized *
@@ -611,6 +628,10 @@ bool radeon_card_posted(struct radeon_de {uint32_t reg; +/* for pass through, always force asic_init */ +if (radeon_device_is_virtual ()) +return false; +/* required for EFI mode on macbook2,1 which uses an r5xx asic */ if (efi_enabled(EFI_BOOT) && (rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) &&
PATCH 189/305 ipv6: fix endianness error in icmpv6_err
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Frederic Sowa <[email protected]>
commit dcb94b88c09ce82a80e188d49bcffdc83ba215a6 upstream.
IPv6 ping socket error handler doesn't correctly convert the new 32 bit mtu to host endianness before using.
--- net/ipv6/icmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/icmp.c +1 -1
@@ -97,7 +97,7 @@ static void icmpv6_err(struct sk_buff *sif (!(type &ICMPV6_INFOMSG_MASK ))if (icmp6->icmp6_type ==ICMPV6_ECHO_REQUEST ) -ping_err (skb, offset, info); +ping_err (skb, offset,ntohl (info)); }static int icmpv6_rcv (struct sk_buff *skb);
PATCH 195/305 base: make module_create_drivers_dir race-free
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby <[email protected]>
commit 7e1b1fc4dabd6ec8e28baa0708866e13fa93c9b3 upstream.
Modules which register drivers via standard path (driver_register) in parallel can cause a warning:
WARNING: CPU: 2 PID: 3492 at ../fs/sysfs/dir.c:31 sysfs_warn_dup+0x62/0x80 sysfs: cannot create duplicate filename '/module/saa7146/drivers' Modules linked in: hexium_gemini(+) mxb(+) ... ... Call Trace: ... [<ffffffff812e63a2>] sysfs_warn_dup+0x62/0x80 [<ffffffff812e6487>] sysfs_create_dir_ns+0x77/0x90 [<ffffffff8140f2c4>] kobject_add_internal+0xb4/0x340 [<ffffffff8140f5b8>] kobject_add+0x68/0xb0 [<ffffffff8140f631>] kobject_create_and_add+0x31/0x70 [<ffffffff8157a703>] module_add_driver+0xc3/0xd0 [<ffffffff8155e5d4>] bus_add_driver+0x154/0x280 [<ffffffff815604c0>] driver_register+0x60/0xe0 [<ffffffff8145bed0>] __pci_register_driver+0x60/0x70 [<ffffffffa0273e14>] saa7146_register_extension+0x64/0x90 [saa7146] [<ffffffffa0033011>] hexium_init_module+0x11/0x1000 [hexium_gemini]
...
As can be (mostly) seen, driver_register causes this call sequence:
-> bus_add_driver
-> module_add_driver
-> module_create_drivers_dirThe last one creates "drivers" directory in /sys/module/<...>. When this is done in parallel, the directory is attempted to be created twice at the same time.
This can be easily reproduced by loading mxb and hexium_gemini in parallel:
while :; do
modprobe mxb &
modprobe hexium_gemini
wait
rmmod mxb hexium_gemini saa7146_vv saa7146
done
saa7146 calls pci_register_driver for both mxb and hexium_gemini, which means /sys/module/saa7146/drivers is to be created for both of them.
Fix this by a new mutex in module_create_drivers_dir which makes the test-and-create "drivers" dir atomic.
I inverted the condition and removed 'return' to avoid multiple unlocks or a goto.
--- drivers/base/module.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/base/module.c +5 -3
@@ -24,10 +24,12 @@ static char *make_driver_name(struct devstatic void module_create_drivers_dir (struct module_kobject *mk) { -if (!mk || mk->drivers_dir) -return ; +static DEFINE_MUTEX (drivers_dir_mutex); - mk->drivers_dir =kobject_create_and_add ("drivers" , &mk->kobj); +mutex_lock (&drivers_dir_mutex); +if (mk && !mk->drivers_dir) + mk->drivers_dir =kobject_create_and_add ("drivers" , &mk->kobj); +mutex_unlock (&drivers_dir_mutex); }void module_add_driver (struct module *mod,struct device_driver *drv)
PATCH 199/305 IB/mlx4: Properly initialize GRH TClass and FlowLabel in AHs
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit 8c5122e45a10a9262f872b53f151a592e870f905 upstream.
When this code was reworked for IBoE support the order of assignments for the sl_tclass_flowlabel got flipped around resulting in TClass & FlowLabel being permanently set to 0 in the packet headers.
This breaks IB routers that rely on these headers, but only affects kernel users - libmlx4 does this properly for user space.
--- drivers/infiniband/hw/mlx4/ah.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/ah.c +1 -1
@@ -46,6 +46,7 @@ static struct ib_ah *create_ib_ah(struct ah->av.ib.port_pd =cpu_to_be32 (to_mpd (pd)->pdn | (ah_attr->port_num <<24 )); ah->av.ib.g_slid = ah_attr->src_path_bits; + ah->av.ib.sl_tclass_flowlabel =cpu_to_be32 (ah_attr->sl <<28 );if (ah_attr->ah_flags &IB_AH_GRH ) { ah->av.ib.g_slid |=0x80 ; ah->av.ib.gid_index = ah_attr->grh.sgid_index;
@@ -63,7 +64,6 @@ static struct ib_ah *create_ib_ah(struct !(1 << ah->av.ib.stat_rate & dev->caps.stat_rate_support)) --ah->av.ib.stat_rate; } - ah->av.ib.sl_tclass_flowlabel =cpu_to_be32 (ah_attr->sl <<28 );return &ah->ibah; }
PATCH 200/305 isa: Call isa_bus_init before dependent ISA bus drivers register
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: William Breathitt Gray <[email protected]>
commit 32a5a0c047343b11f581f663a2309cf43d13466f upstream.
The isa_bus_init function must be called before drivers which utilize the ISA bus driver are registered. A race condition for initilization exists if device_initcall is used (the isa_bus_init callback is placed in the same initcall level as dependent drivers which use module_init). This patch ensures that isa_bus_init is called first by utilizing postcore_initcall in favor of device_initcall.
--- drivers/base/isa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/isa.c +1 -1
@@ -180,4 +180,4 @@ static int __init isa_bus_init(void)return error; } -device_initcall (isa_bus_init); +postcore_initcall (isa_bus_init);
PATCH 205/305 arm64: mm: remove page_mapping check in __sync_icache_dcache
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Shaokun Zhang <[email protected]>
commit 20c27a4270c775d7ed661491af8ac03264d60fc6 upstream.
__sync_icache_dcache unconditionally skips the cache maintenance for anonymous pages, under the assumption that flushing is only required in the presence of D-side aliases [see 7249b79f6b4cc ("arm64: Do not flush the D-cache for anonymous pages")].
Unfortunately, this breaks migration of anonymous pages holding self-modifying code, where userspace cannot be reasonably expected to reissue maintenance instructions in response to a migration.
This patch fixes the problem by removing the broken page_mapping(page) check from the cache syncing code, otherwise we may end up fetching and executing stale instructions from the PoU.
--- arch/arm64/mm/flush.c | 4 ---- 1 file changed, 4 deletions(-)
arch/arm64/mm/flush.c +0 -4
@@ -74,10 +74,6 @@ void __sync_icache_dcache(pte_t pte, uns {struct page *page =pte_page (pte); -/* no flushing needed for anonymous pages */ -if (!page_mapping (page)) -return ; -if (!test_and_set_bit (PG_dcache_clean, &page->flags)) {__flush_dcache_area (page_address (page),PAGE_SIZE <<compound_order (page));
PATCH 208/305 ubi: Make recover_peb power cut aware
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 972228d87445dc46c0a01f5f3de673ac017626f7 upstream.
recover_peb() was never power cut aware,
if a power cut happened right after writing the VID header upon next attach UBI would blindly use the new partial written PEB and all data from the old PEB is lost.
In order to make recover_peb() power cut aware, write the new VID with a proper crc and copy_flag set such that the UBI attach process will detect whether the new PEB is completely written or not.
We cannot directly use ubi_eba_atomic_leb_change() since we'd have to unlock the LEB which is facing a write error.
---
drivers/mtd/ubi/eba.c +14 -5
@@ -521,6 +521,7 @@ static int recover_peb(struct ubi_deviceint err, idx =vol_id2idx (ubi, vol_id), new_pnum, data_size, tries =0 ;struct ubi_volume *vol = ubi->volumes[idx];struct ubi_vid_hdr *vid_hdr; +uint32_t crc; vid_hdr =ubi_zalloc_vid_hdr (ubi,GFP_NOFS );if (!vid_hdr)
@@ -542,12 +543,8 @@ retry: goto out_put; } - vid_hdr->sqnum =cpu_to_be64 (ubi_next_sqnum (ubi)); - err =ubi_io_write_vid_hdr (ubi, new_pnum, vid_hdr); -if (err) - goto write_error; +ubi_assert (vid_hdr->vol_type ==UBI_VID_DYNAMIC ); - data_size = offset + len;mutex_lock (&ubi->buf_mutex);memset (ubi->peb_buf + offset,0xFF , len);
@@ -560,6 +557,18 @@ retry:memcpy (ubi->peb_buf + offset, buf, len); + data_size = offset + len; + crc =crc32 (UBI_CRC32_INIT , ubi->peb_buf, data_size); + vid_hdr->sqnum =cpu_to_be64 (ubi_next_sqnum (ubi)); + vid_hdr->copy_flag =1 ; + vid_hdr->data_size =cpu_to_be32 (data_size); + vid_hdr->data_crc =cpu_to_be32 (crc); + err =ubi_io_write_vid_hdr (ubi, new_pnum, vid_hdr); +if (err) { +mutex_unlock (&ubi->buf_mutex); + goto write_error; + } + err =ubi_io_write_data (ubi, ubi->peb_buf, new_pnum,0 , data_size);if (err) {mutex_unlock (&ubi->buf_mutex);
PATCH 214/305 IB/mlx5: Fix post send fence logic
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eli Cohen <[email protected]>
commit c9b254955b9f8814966f5dabd34c39d0e0a2b437 upstream.
If the caller specified IB_SEND_FENCE in the send flags of the work request and no previous work request stated that the successive one should be fenced, the work request would be executed without a fence. This could result in RDMA read or atomic operations failure due to a MR being invalidated. Fix this by adding the mlx5 enumeration for fencing RDMA/atomic operations and fix the logic to apply this.
--- drivers/infiniband/hw/mlx5/qp.c | 7 ++++--- include/linux/mlx5/qp.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +4 -3
@@ -2419,10 +2419,11 @@ static u8 get_fence(u8 fence, struct ib_return MLX5_FENCE_MODE_SMALL_AND_FENCE ; else return fence; - - }else { -return 0 ; + }else if (unlikely (wr->send_flags &IB_SEND_FENCE )) { +return MLX5_FENCE_MODE_FENCE ; } + +return 0 ; } static int begin_wqe(struct mlx5_ib_qp *qp, void **seg,
include/linux/mlx5/qp.h +1 -0
@@ -140,6 +140,7 @@ enum {enum {MLX5_FENCE_MODE_NONE =0 <<5 ,MLX5_FENCE_MODE_INITIATOR_SMALL =1 <<5 , +MLX5_FENCE_MODE_FENCE =2 <<5 ,MLX5_FENCE_MODE_STRONG_ORDERING =3 <<5 ,MLX5_FENCE_MODE_SMALL_AND_FENCE =4 <<5 , };
PATCH 218/305 IB/mlx4: Fix memory leak if QP creation failed
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dotan Barak <[email protected]>
commit 5b420d9cf7382c6e1512e96e02d18842d272049c upstream.
When RC, UC, or RAW QPs are created, a qp object is allocated (kzalloc). If at a later point (in procedure create_qp_common) the qp creation fails, this qp object must be freed.
--- drivers/infiniband/hw/mlx4/qp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/qp.c +3 -1
@@ -1108,8 +1108,10 @@ struct ib_qp *mlx4_ib_create_qp(struct i { err =create_qp_common (to_mdev (pd->device), pd, init_attr, udata,0 , &qp, gfp); -if (err) +if (err) { +kfree (qp);return ERR_PTR (err); + } qp->ibqp.qp_num = qp->mqp.qpn; qp->xrcdn = xrcdn;
PATCH 222/305 cifs: dynamic allocation of ntlmssp blob
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Marchand <[email protected]>
commit b8da344b74c822e966c6d19d6b2321efe82c5d97 upstream.
In sess_auth_rawntlmssp_authenticate(), the ntlmssp blob is allocated statically and its size is an "empirical" 5*sizeof(struct _AUTHENTICATE_MESSAGE) (320B on x86_64). I don't know where this value comes from or if it was ever appropriate, but it is currently
insufficient: the user and domain name in UTF16 could take 1kB by themselves. Because of that, build_ntlmssp_auth_blob() might corrupt memory (out-of-bounds write). The size of ntlmssp_blob in SMB2_sess_setup() is too small too (sizeof(struct _NEGOTIATE_MESSAGE)
+ 500).
This patch allocates the blob dynamically inbuild_ntlmssp_auth_blob().
--- fs/cifs/ntlmssp.h | 2 +- fs/cifs/sess.c | 76 ++++++++++++++++++++++++++++++------------------------- fs/cifs/smb2pdu.c | 10 ++------ 3 files changed, 45 insertions(+), 43 deletions(-)
fs/cifs/ntlmssp.h +1 -1
@@ -133,6 +133,6 @@ typedef struct _AUTHENTICATE_MESSAGE {int decode_ntlmssp_challenge (char *bcc_ptr,int blob_len,struct cifs_ses *ses);void build_ntlmssp_negotiate_blob (unsigned char *pbuffer,struct cifs_ses *ses); -int build_ntlmssp_auth_blob (unsigned char *pbuffer,u16 *buflen, +int build_ntlmssp_auth_blob (unsigned char **pbuffer,u16 *buflen,struct cifs_ses *ses,const struct nls_table *nls_cp);
fs/cifs/sess.c +42 -35
161 lines not on this page · raw message
fs/cifs/smb2pdu.c +2 -8
@@ -550,7 +550,7 @@ SMB2_sess_setup(const unsigned int xid,struct TCP_Server_Info *server = ses->server;u16 blob_length =0 ;char *security_blob; -char *ntlmssp_blob =NULL ; +unsigned char *ntlmssp_blob =NULL ;bool use_spnego = false;/* else use raw ntlmssp */ cifs_dbg (FYI ,"Session Setup\n" );
@@ -631,13 +631,7 @@ ssetup_ntlmssp_authenticate: } }else if (phase == NtLmAuthenticate) { req->hdr.SessionId = ses->Suid; - ntlmssp_blob =kzalloc (sizeof (struct _NEGOTIATE_MESSAGE ) +500 , -GFP_KERNEL ); -if (ntlmssp_blob ==NULL ) { - rc = -ENOMEM ; - goto ssetup_exit; - } - rc =build_ntlmssp_auth_blob (ntlmssp_blob, &blob_length, ses, + rc =build_ntlmssp_auth_blob (&ntlmssp_blob, &blob_length, ses, nls_cp);if (rc) { cifs_dbg(FYI, "build_ntlmssp_auth_blob failed %d\n",
PATCH 227/305 Fix reconnect to not defer smb3 session reconnect long after socket reconnect
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 4fcd1813e6404dd4420c7d12fb483f9320f0bf93 upstream.
Azure server blocks clients that open a socket and don't do anything on it. In our reconnect scenarios, we can reconnect the tcp session and detect the socket is available but we defer the negprot and SMB3 session setup and tree connect reconnection until the next i/o is requested, but this looks suspicous to some servers who expect SMB3 negprog and session setup soon after a socket is created.
In the echo thread, reconnect SMB3 sessions and tree connections that are disconnected. A later patch will replay persistent (and resilient) handle opens.
--- fs/cifs/connect.c | 4 +++- fs/cifs/smb2pdu.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)
fs/cifs/connect.c +3 -1
@@ -410,7 +410,9 @@ cifs_echo_request(struct work_struct *wo* server->ops->need_neg() == true. Also, no need to ping if * we got a response recently. */ -if (!server->ops->need_neg || server->ops->need_neg (server) || + +if (server->tcpStatus == CifsNeedReconnect || + server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew || (server->ops->can_echo && !server->ops->can_echo (server)) ||time_before (jiffies, server->lstrp +SMB_ECHO_INTERVAL -HZ )) goto requeue_echo;
fs/cifs/smb2pdu.c +27 -0
@@ -1590,6 +1590,33 @@ SMB2_echo(struct TCP_Server_Info *servercifs_dbg (FYI ,"In echo request\n" ); +if (server->tcpStatus == CifsNeedNegotiate) { +struct list_head *tmp, *tmp2; +struct cifs_ses *ses; +struct cifs_tcon *tcon; + +cifs_dbg (FYI ,"Need negotiate, reconnecting tcons\n" ); +spin_lock (&cifs_tcp_ses_lock); +list_for_each (tmp, &server->smb_ses_list) { + ses = list_entry(tmp, struct cifs_ses, smb_ses_list); +list_for_each (tmp2, &ses->tcon_list) { + tcon = list_entry(tmp2, struct cifs_tcon, + tcon_list); +/* add check for persistent handle reconnect */ +if (tcon && tcon->need_reconnect) { +spin_unlock (&cifs_tcp_ses_lock); + rc =smb2_reconnect (SMB2_ECHO , tcon); +spin_lock (&cifs_tcp_ses_lock); + } + } + } +spin_unlock (&cifs_tcp_ses_lock); + } + +/* if no session, renegotiate failed above */ +if (server->tcpStatus == CifsNeedNegotiate) +return -EIO ; + rc =small_smb2_init (SMB2_ECHO ,NULL , (void **)&req);if (rc)return rc;
PATCH 228/305 tmpfs: don't undo fallocate past its last page
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Anthony Romano <[email protected]>
commit b9b4bb26af017dbe930cd4df7f9b2fc3a0497bfe upstream.
When fallocate is interrupted it will undo a range that extends one byte past its range of allocated pages. This can corrupt an in-use page by zeroing out its first byte. Instead, undo using the inclusive byte range.
--- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -1
@@ -1867,7 +1867,7 @@ static long shmem_fallocate(struct file/* Remove the !PageUptodate pages we added */ shmem_undo_range (inode, (loff_t )start <<PAGE_CACHE_SHIFT , - (loff_t )index <<PAGE_CACHE_SHIFT , true); + ((loff_t )index <<PAGE_CACHE_SHIFT ) -1 , true); goto undone; }
PATCH 230/305 staging: iio: accel: fix error check
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Luis de Bethencourt <[email protected]>
commit ef3149eb3ddb7f9125e11c90f8330e371b55cffd upstream.
sca3000_read_ctrl_reg() returns a negative number on failure, check for this instead of zero.
--- drivers/staging/iio/accel/sca3000_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/accel/sca3000_core.c +1 -1
@@ -619,7 +619,7 @@ static ssize_t sca3000_read_frequency(st goto error_ret_mut; ret =sca3000_read_ctrl_reg (st,SCA3000_REG_CTRL_SEL_OUT_CTRL );mutex_unlock (&st->lock); -if (ret) +if (ret <0 ) goto error_ret; val = ret;if (base_freq >0 )
PATCH 241/305 arc: unwind: warn only once if DW2_UNWIND is disabled
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Brodkin <[email protected]>
commit 9bd54517ee86cb164c734f72ea95aeba4804f10b upstream.
If CONFIG_ARC_DW2_UNWIND is disabled every time arc_unwind_core() gets called following message gets printed in debug console:
----------------->8--------------- CONFIG_ARC_DW2_UNWIND needs to be enabled ----------------->8---------------
That message makes sense if user indeed wants to see a backtrace or get nice function call-graphs in perf but what if user disabled unwinder for the purpose? Why pollute his debug console?
So instead we'll warn user about possibly missing feature once and let him decide if that was what he or she really wanted.
--- arch/arc/kernel/stacktrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/kernel/stacktrace.c +1 -1
@@ -131,7 +131,7 @@ arc_unwind_core(struct task_struct *tsk,* prelogue is setup (callee regs saved and then fp set and not other * way around */ -pr_warn ("CONFIG_ARC_DW2_UNWIND needs to be enabled\n" ); +pr_warn_once ("CONFIG_ARC_DW2_UNWIND needs to be enabled\n" );return 0 ;#endif
PATCH 256/305 batman-adv: Clean up untagged vlan when destroying via rtnl-link
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 420cb1b764f9169c5d2601b4af90e4a1702345ee upstream.
The untagged vlan object is only destroyed when the interface is removed via the legacy sysfs interface. But it also has to be destroyed when the standard rtnl-link interface is used.
--- net/batman-adv/soft-interface.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/batman-adv/soft-interface.c +9 -0
@@ -975,7 +975,9 @@ void batadv_softif_destroy_sysfs(structstatic void batadv_softif_destroy_netlink (struct net_device *soft_iface,struct list_head *head) { +struct batadv_priv *bat_priv =netdev_priv (soft_iface);struct batadv_hard_iface *hard_iface; +struct batadv_softif_vlan *vlan;list_for_each_entry (hard_iface, &batadv_hardif_list, list) {if (hard_iface->soft_iface == soft_iface)
@@ -983,6 +985,13 @@ static void batadv_softif_destroy_netlin BATADV_IF_CLEANUP_KEEP); } +/* destroy the "untagged" VLAN */ + vlan =batadv_softif_vlan_get (bat_priv,BATADV_NO_FLAGS ); +if (vlan) { +batadv_softif_destroy_vlan (bat_priv, vlan); +batadv_softif_vlan_free_ref (vlan); + } +batadv_sysfs_del_meshif (soft_iface);unregister_netdevice_queue (soft_iface, head); }
PATCH 258/305 ALSA: au88x0: Fix calculation in vortex_wtdma_bufshift()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 62db7152c924e4c060e42b34a69cd39658e8a0dc upstream.
vortex_wtdma_bufshift() function does calculate the page index wrongly, first masking then shift, which always results in zero. The proper computation is to first shift, then mask.
--- sound/pci/au88x0/au88x0_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/pci/au88x0/au88x0_core.c +2 -3
@@ -1442,9 +1442,8 @@ static int vortex_wtdma_bufshift(vortex_int page, p, pp, delta, i; page = - (hwread (vortex->mmio,VORTEX_WTDMA_STAT + (wtdma <<2 )) & -WT_SUBBUF_MASK ) - >>WT_SUBBUF_SHIFT ; + (hwread (vortex->mmio,VORTEX_WTDMA_STAT + (wtdma <<2 )) + >>WT_SUBBUF_SHIFT ) &WT_SUBBUF_MASK ;if (dma->nr_periods >=4 ) delta = (page - dma->period_real) &3 ;else {
PATCH 269/305 xenbus: don't bail early from xenbus_dev_request_and_reply()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
commit 7469be95a487319514adce2304ad2af3553d2fc9 upstream.
xenbus_dev_request_and_reply() needs to track whether a transaction is open. For XS_TRANSACTION_START messages it calls transaction_start() and for XS_TRANSACTION_END messages it calls transaction_end().
If sending an XS_TRANSACTION_START message fails or responds with an an error, the transaction is not open and transaction_end() must be called.
If sending an XS_TRANSACTION_END message fails, the transaction is still open, but if an error response is returned the transaction is closed.
Commit 027bd7e89906 ("xen/xenbus: Avoid synchronous wait on XenBus stalling shutdown/restart") introduced a regression where failed XS_TRANSACTION_START messages were leaving the transaction open. This can cause problems with suspend (and migration) as all transactions must be closed before suspending.
It appears that the problematic change was added accidentally, so just remove it.
--- drivers/xen/xenbus/xenbus_xs.c | 3 --- 1 file changed, 3 deletions(-)
drivers/xen/xenbus/xenbus_xs.c +0 -3
@@ -250,9 +250,6 @@ void *xenbus_dev_request_and_reply(strucmutex_unlock (&xs_state.request_mutex); -if (IS_ERR (ret)) -return ret; -if ((msg->type ==XS_TRANSACTION_END ) || ((req_msg.type ==XS_TRANSACTION_START ) && (msg->type ==XS_ERROR )))
PATCH 277/305 ALSA: timer: Fix leak in SNDRV_TIMER_IOCTL_PARAMS
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kangjie Lu <[email protected]>
commit cec8f96e49d9be372fdb0c3836dcf31ec71e457e upstream.
The stack object “tread” has a total size of 32 bytes. Its field “event” and “val” both contain 4 bytes padding. These 8 bytes padding bytes are sent to user without being initialized.
--- sound/core/timer.c | 1 + 1 file changed, 1 insertion(+)
sound/core/timer.c +1 -0
@@ -1750,6 +1750,7 @@ static int snd_timer_user_params(structif (tu->timeri->flags &SNDRV_TIMER_IFLG_EARLY_EVENT ) {if (tu->tread) {struct snd_timer_tread tread; +memset (&tread,0 ,sizeof (tread)); tread.event =SNDRV_TIMER_EVENT_EARLY ; tread.tstamp.tv_sec =0 ; tread.tstamp.tv_nsec =0 ;
PATCH 281/305 rds: fix an infoleak in rds_inc_info_copy
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kangjie Lu <[email protected]>
commit 4116def2337991b39919f3b448326e21c40e0dbb upstream.
The last field "flags" of object "minfo" is not initialized. Copying this object out may leak kernel stack data. Assign 0 to it to avoid leak.
--- net/rds/recv.c | 2 ++ 1 file changed, 2 insertions(+)
net/rds/recv.c +2 -0
@@ -543,5 +543,7 @@ void rds_inc_info_copy(struct rds_incomi minfo.fport = inc->i_hdr.h_dport; } + minfo.flags =0 ; +rds_info_copy (iter, &minfo,sizeof (minfo)); }
PATCH 283/305 KVM: PPC: Book3S HV: Save/restore TM state in H_CEDE
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Mackerras <[email protected]>
commit 93d17397e4e2182fdaad503e2f9da46202c0f1c3 upstream.
It turns out that if the guest does a H_CEDE while the CPU is in a transactional state, and the H_CEDE does a nap, and the nap loses the architected state of the CPU (which is is allowed to do), then we lose the checkpointed state of the virtual CPU. In addition, the transactional-memory state recorded in the MSR gets reset back to non-transactional, and when we try to return to the guest, we take a TM bad thing type of program interrupt because we are trying to transition from non-transactional to transactional with a hrfid instruction, which is not permitted.
The result of the program interrupt occurring at that point is that the host CPU will hang in an infinite loop with interrupts disabled. Thus this is a denial of service vulnerability in the host which can be triggered by any guest (and depending on the guest kernel, it can potentially triggered by unprivileged userspace in the guest).
This vulnerability has been assigned the ID CVE-2016-5412.
To fix this, we save the TM state before napping and restore it on exit from the nap, when handling a H_CEDE in real mode. The case where H_CEDE exits to host virtual mode is already OK (as are other hcalls which exit to host virtual mode) because the exit path saves the TM state.
--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/powerpc/kvm/book3s_hv_rmhandlers.S +13 -0
@@ -1954,6 +1954,13 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206) /* save FP state */ bl kvmppc_save_fp +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +BEGIN_FTR_SECTION + ld r9, HSTATE_KVM_VCPU(r13) + bl kvmppc_save_tm +END_FTR_SECTION_IFSET(CPU_FTR_TM) +#endif + /* * Take a nap until a decrementer or external or doobell interrupt * occurs, with PECE1, PECE0 and PECEDP set in LPCR. Also clear the
@@ -1993,6 +2000,12 @@ kvm_end_cede: /* Woken by external or decrementer interrupt */ ld r1, HSTATE_HOST_R1(r13) +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +BEGIN_FTR_SECTION + bl kvmppc_restore_tm +END_FTR_SECTION_IFSET(CPU_FTR_TM) +#endif + /* load up FP state */ bl kvmppc_load_fp
PATCH 288/305 netfilter: x_tables: don't move to non-existent next rule
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit f24e230d257af1ad7476c6e81a8dc3127a74204e upstream.
Ben Hawkes says:
In the mark_source_chains function (net/ipv4/netfilter/ip_tables.c) it is possible for a user-supplied ipt_entry structure to have a large next_offset field. This field is not bounds checked prior to writing a counter value at the supplied offset.
Base chains enforce absolute verdict.
User defined chains are supposed to end with an unconditional return, xtables userspace adds them automatically.
But if such return is missing we will move to non-existent next rule.
--- net/ipv4/netfilter/arp_tables.c | 8 +++++--- net/ipv4/netfilter/ip_tables.c | 4 ++++ net/ipv6/netfilter/ip6_tables.c | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-)
net/ipv4/netfilter/arp_tables.c +5 -3
@@ -435,6 +435,8 @@ static int mark_source_chains(const stru size = e->next_offset; e = (struct arpt_entry *) (entry0 + pos + size); +if (pos + size >= newinfo->size) +return 0 ; e->counters.pcnt = pos; pos += size; }else {
@@ -457,6 +459,8 @@ static int mark_source_chains(const stru }else {/* ... this is a fallthru */ newpos = pos + e->next_offset; +if (newpos >= newinfo->size) +return 0 ; } e = (struct arpt_entry *) (entry0 + newpos);
@@ -680,10 +684,8 @@ static int translate_table(struct xt_tab } } -if (!mark_source_chains (newinfo, repl->valid_hooks, entry0)) { -duprintf ("Looping hook\n" ); +if (!mark_source_chains (newinfo, repl->valid_hooks, entry0))return -ELOOP ; - }/* Finally, each sanity check must pass */ i =0 ;
net/ipv4/netfilter/ip_tables.c +4 -0
@@ -516,6 +516,8 @@ mark_source_chains(const struct xt_table size = e->next_offset; e = (struct ipt_entry *) (entry0 + pos + size); +if (pos + size >= newinfo->size) +return 0 ; e->counters.pcnt = pos; pos += size; }else {
@@ -537,6 +539,8 @@ mark_source_chains(const struct xt_table }else {/* ... this is a fallthru */ newpos = pos + e->next_offset; +if (newpos >= newinfo->size) +return 0 ; } e = (struct ipt_entry *) (entry0 + newpos);
net/ipv6/netfilter/ip6_tables.c +4 -0
@@ -526,6 +526,8 @@ mark_source_chains(const struct xt_table size = e->next_offset; e = (struct ip6t_entry *) (entry0 + pos + size); +if (pos + size >= newinfo->size) +return 0 ; e->counters.pcnt = pos; pos += size; }else {
@@ -547,6 +549,8 @@ mark_source_chains(const struct xt_table }else {/* ... this is a fallthru */ newpos = pos + e->next_offset; +if (newpos >= newinfo->size) +return 0 ; } e = (struct ip6t_entry *) (entry0 + newpos);
PATCH 290/305 netfilter: x_tables: add and use xt_check_entry_offsets
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 7d35812c3214afa5b37a675113555259cfd67b98 upstream.
Currently arp/ip and ip6tables each implement a short helper to check that the target offset is large enough to hold one xt_entry_target struct and that t->u.target_size fits within the current rule.
Unfortunately these checks are not sufficient.
To avoid adding new tests to all of ip/ip6/arptables move the current checks into a helper, then extend this helper in followup patches.
--- include/linux/netfilter/x_tables.h | 4 ++++ net/ipv4/netfilter/arp_tables.c | 11 +---------- net/ipv4/netfilter/ip_tables.c | 12 +----------- net/ipv6/netfilter/ip6_tables.c | 12 +----------- net/netfilter/x_tables.c | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 32 deletions(-)
include/linux/netfilter/x_tables.h +4 -0
@@ -239,6 +239,10 @@ void xt_unregister_match(struct xt_matchint xt_register_matches (struct xt_match *match,unsigned int n);void xt_unregister_matches (struct xt_match *match,unsigned int n); +int xt_check_entry_offsets (const void *base, +unsigned int target_offset, +unsigned int next_offset); +int xt_check_match (struct xt_mtchk_param *,unsigned int size,u_int8_t proto,bool inv_proto); int xt_check_target(struct xt_tgchk_param *, unsigned int size, u_int8_t proto,
net/ipv4/netfilter/arp_tables.c +1 -10
@@ -493,19 +493,10 @@ static int mark_source_chains(const strustatic inline int check_entry (const struct arpt_entry *e) { -const struct xt_entry_target *t; -if (!arp_checkentry (&e->arp))return -EINVAL ; -if (e->target_offset +sizeof (struct xt_entry_target ) > e->next_offset) -return -EINVAL ; - - t =arpt_get_target_c (e); -if (e->target_offset + t->u.target_size > e->next_offset) -return -EINVAL ; - -return 0 ; +return xt_check_entry_offsets (e, e->target_offset, e->next_offset); }static inline int check_target (struct arpt_entry *e,const char *name)
net/ipv4/netfilter/ip_tables.c +1 -11
@@ -587,20 +587,10 @@ static void cleanup_match(struct xt_entrstatic int check_entry (const struct ipt_entry *e) { -const struct xt_entry_target *t; -if (!ip_checkentry (&e->ip))return -EINVAL ; -if (e->target_offset +sizeof (struct xt_entry_target ) > - e->next_offset) -return -EINVAL ; - - t =ipt_get_target_c (e); -if (e->target_offset + t->u.target_size > e->next_offset) -return -EINVAL ; - -return 0 ; +return xt_check_entry_offsets (e, e->target_offset, e->next_offset); } static int
net/ipv6/netfilter/ip6_tables.c +1 -11
@@ -597,20 +597,10 @@ static void cleanup_match(struct xt_entrstatic int check_entry (const struct ip6t_entry *e) { -const struct xt_entry_target *t; -if (!ip6_checkentry (&e->ipv6))return -EINVAL ; -if (e->target_offset +sizeof (struct xt_entry_target ) > - e->next_offset) -return -EINVAL ; - - t =ip6t_get_target_c (e); -if (e->target_offset + t->u.target_size > e->next_offset) -return -EINVAL ; - -return 0 ; +return xt_check_entry_offsets (e, e->target_offset, e->next_offset); }static int check_match (struct xt_entry_match *m,struct xt_mtchk_param *par)
net/netfilter/x_tables.c +34 -0
@@ -560,6 +560,40 @@ int xt_compat_match_to_user(const structEXPORT_SYMBOL_GPL (xt_compat_match_to_user);#endif /* CONFIG_COMPAT */ +/** +* xt_check_entry_offsets - validate arp/ip/ip6t_entry +* +* @base: pointer to arp/ip/ip6t_entry +* @target_offset: the arp/ip/ip6_t->target_offset +* @next_offset: the arp/ip/ip6_t->next_offset +* +* validates that target_offset and next_offset are sane. +* +* The arp/ip/ip6t_entry structure @base must have passed following tests: +* - it must point to a valid memory location +* - base to base + next_offset must be accessible, i.e. not exceed allocated +* length. +* +* Return: 0 on success, negative errno on failure. +*/ +int xt_check_entry_offsets (const void *base, +unsigned int target_offset, +unsigned int next_offset) +{ +const struct xt_entry_target *t; +const char *e = base; + +if (target_offset +sizeof (*t) > next_offset) +return -EINVAL ; + + t = (void *)(e + target_offset); +if (target_offset + t->u.target_size > next_offset) +return -EINVAL ; + +return 0 ; +} +EXPORT_SYMBOL (xt_check_entry_offsets); +int xt_check_target (struct xt_tgchk_param *par,unsigned int size,u_int8_t proto,bool inv_proto) {
PATCH 292/305 netfilter: x_tables: assert minimum target size
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit a08e4e190b866579896c09af59b3bdca821da2cd upstream.
The target size includes the size of the xt_entry_target struct.
--- net/netfilter/x_tables.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/x_tables.c +3 -0
@@ -587,6 +587,9 @@ int xt_check_entry_offsets(const void *breturn -EINVAL ; t = (void *)(e + target_offset); +if (t->u.target_size <sizeof (*t)) +return -EINVAL ; +if (target_offset + t->u.target_size > next_offset)return -EINVAL ;
PATCH 301/305 netfilter: x_tables: xt_compat_match_from_user doesn't need a retval
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 0188346f21e6546498c2a0f84888797ad4063fc5 upstream.
Always returned 0.
--- include/linux/netfilter/x_tables.h | 2 +- net/ipv4/netfilter/arp_tables.c | 17 +++++------------ net/ipv4/netfilter/ip_tables.c | 26 +++++++++----------------- net/ipv6/netfilter/ip6_tables.c | 27 +++++++++------------------ net/netfilter/x_tables.c | 5 ++--- 5 files changed, 26 insertions(+), 51 deletions(-)
include/linux/netfilter/x_tables.h +1 -1
@@ -425,7 +425,7 @@ void xt_compat_init_offsets(u_int8_t af,int xt_compat_calc_jump (u_int8_t af,unsigned int offset);int xt_compat_match_offset (const struct xt_match *match); -int xt_compat_match_from_user (struct xt_entry_match *m,void **dstptr, +void xt_compat_match_from_user (struct xt_entry_match *m,void **dstptr,unsigned int *size);int xt_compat_match_to_user (const struct xt_entry_match *m,void __user **dstptr,unsigned int *size);
net/ipv4/netfilter/arp_tables.c +5 -12
@@ -1301,7 +1301,7 @@ out:return ret; } -static int +static void compat_copy_entry_from_user (struct compat_arpt_entry *e,void **dstptr,unsigned int *size,struct xt_table_info *newinfo,unsigned char *base)
@@ -1310,9 +1310,8 @@ compat_copy_entry_from_user(struct compastruct xt_target *target;struct arpt_entry *de;unsigned int origsize; -int ret, h; +int h; - ret =0 ; origsize = *size; de = (struct arpt_entry *)*dstptr;memcpy (de, e,sizeof (struct arpt_entry ));
@@ -1333,7 +1332,6 @@ compat_copy_entry_from_user(struct compaif ((unsigned char *)de - base < newinfo->underflow[h]) newinfo->underflow[h] -= origsize - *size; } -return ret; } static int translate_compat_table(struct xt_table_info **pinfo,
@@ -1412,16 +1410,11 @@ static int translate_compat_table(struct entry1 = newinfo->entries[raw_smp_processor_id ()]; pos = entry1; size = compatr->size; - xt_entry_foreach(iter0, entry0, compatr->size) { - ret =compat_copy_entry_from_user (iter0, &pos, &size, - newinfo, entry1); -if (ret !=0 ) -break ; - } + xt_entry_foreach(iter0, entry0, compatr->size) +compat_copy_entry_from_user (iter0, &pos, &size, + newinfo, entry1);xt_compat_flush_offsets (NFPROTO_ARP );xt_compat_unlock (NFPROTO_ARP ); -if (ret) - goto free_newinfo; ret = -ELOOP ;if (!mark_source_chains (newinfo, compatr->valid_hooks, entry1))
net/ipv4/netfilter/ip_tables.c +9 -17
@@ -1565,7 +1565,7 @@ release_matches:return ret; } -static int +static void compat_copy_entry_from_user (struct compat_ipt_entry *e,void **dstptr,unsigned int *size,struct xt_table_info *newinfo,unsigned char *base)
@@ -1574,10 +1574,9 @@ compat_copy_entry_from_user(struct compastruct xt_target *target;struct ipt_entry *de;unsigned int origsize; -int ret, h; +int h;struct xt_entry_match *ematch; - ret =0 ; origsize = *size; de = (struct ipt_entry *)*dstptr;memcpy (de, e,sizeof (struct ipt_entry ));
@@ -1586,11 +1585,9 @@ compat_copy_entry_from_user(struct compa *dstptr +=sizeof (struct ipt_entry ); *size +=sizeof (struct ipt_entry ) -sizeof (struct compat_ipt_entry ); - xt_ematch_foreach(ematch, e) { - ret =xt_compat_match_from_user (ematch, dstptr, size); -if (ret !=0 ) -return ret; - } + xt_ematch_foreach(ematch, e) +xt_compat_match_from_user (ematch, dstptr, size); + de->target_offset = e->target_offset - (origsize - *size); t =compat_ipt_get_target (e); target = t->u.kernel.target;
@@ -1603,7 +1600,6 @@ compat_copy_entry_from_user(struct compaif ((unsigned char *)de - base < newinfo->underflow[h]) newinfo->underflow[h] -= origsize - *size; } -return ret; } static int
@@ -1719,16 +1715,12 @@ translate_compat_table(struct net *net, entry1 = newinfo->entries[raw_smp_processor_id ()]; pos = entry1; size = compatr->size; - xt_entry_foreach(iter0, entry0, compatr->size) { - ret =compat_copy_entry_from_user (iter0, &pos, &size, - newinfo, entry1); -if (ret !=0 ) -break ; - } + xt_entry_foreach(iter0, entry0, compatr->size) +compat_copy_entry_from_user (iter0, &pos, &size, + newinfo, entry1); +xt_compat_flush_offsets (AF_INET );xt_compat_unlock (AF_INET ); -if (ret) - goto free_newinfo; ret = -ELOOP ;if (!mark_source_chains (newinfo, compatr->valid_hooks, entry1))
net/ipv6/netfilter/ip6_tables.c +9 -18
@@ -1578,7 +1578,7 @@ release_matches:return ret; } -static int +static void compat_copy_entry_from_user (struct compat_ip6t_entry *e,void **dstptr,unsigned int *size,struct xt_table_info *newinfo,unsigned char *base)
@@ -1586,10 +1586,9 @@ compat_copy_entry_from_user(struct compastruct xt_entry_target *t;struct ip6t_entry *de;unsigned int origsize; -int ret, h; +int h;struct xt_entry_match *ematch; - ret =0 ; origsize = *size; de = (struct ip6t_entry *)*dstptr;memcpy (de, e,sizeof (struct ip6t_entry ));
@@ -1598,11 +1597,9 @@ compat_copy_entry_from_user(struct compa *dstptr +=sizeof (struct ip6t_entry ); *size +=sizeof (struct ip6t_entry ) -sizeof (struct compat_ip6t_entry ); - xt_ematch_foreach(ematch, e) { - ret =xt_compat_match_from_user (ematch, dstptr, size); -if (ret !=0 ) -return ret; - } + xt_ematch_foreach(ematch, e) +xt_compat_match_from_user (ematch, dstptr, size); + de->target_offset = e->target_offset - (origsize - *size); t =compat_ip6t_get_target (e);xt_compat_target_from_user (t, dstptr, size);
@@ -1614,7 +1611,6 @@ compat_copy_entry_from_user(struct compaif ((unsigned char *)de - base < newinfo->underflow[h]) newinfo->underflow[h] -= origsize - *size; } -return ret; } static int compat_check_entry(struct ip6t_entry *e, struct net *net,
@@ -1729,17 +1725,12 @@ translate_compat_table(struct net *net, } entry1 = newinfo->entries[raw_smp_processor_id ()]; pos = entry1; - size = compatr->size; - xt_entry_foreach(iter0, entry0, compatr->size) { - ret =compat_copy_entry_from_user (iter0, &pos, &size, - newinfo, entry1); -if (ret !=0 ) -break ; - } + xt_entry_foreach(iter0, entry0, compatr->size) +compat_copy_entry_from_user (iter0, &pos, &size, + newinfo, entry1); +xt_compat_flush_offsets (AF_INET6 );xt_compat_unlock (AF_INET6 ); -if (ret) - goto free_newinfo; ret = -ELOOP ;if (!mark_source_chains (newinfo, compatr->valid_hooks, entry1))
net/netfilter/x_tables.c +2 -3
@@ -545,8 +545,8 @@ int xt_compat_match_offset(const struct }EXPORT_SYMBOL_GPL (xt_compat_match_offset); -int xt_compat_match_from_user (struct xt_entry_match *m,void **dstptr, -unsigned int *size) +void xt_compat_match_from_user (struct xt_entry_match *m,void **dstptr, +unsigned int *size) {const struct xt_match *match = m->u.kernel.match;struct compat_xt_entry_match *cm = (struct compat_xt_entry_match *)m;
@@ -568,7 +568,6 @@ int xt_compat_match_from_user(struct xt_ *size += off; *dstptr += msize; -return 0 ; }EXPORT_SYMBOL_GPL (xt_compat_match_from_user);
PATCH 304/305 netfilter: ensure number of counters is >0 in do_replace()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jones <[email protected]>
commit 1086bbe97a074844188c6c988fa0b1a98c3ccbb9 upstream.
After improving setsockopt() coverage in trinity, I started triggering vmalloc failures pretty reliably from this code path:
warn_alloc_failed+0xe9/0x140 __vmalloc_node_range+0x1be/0x270 vzalloc+0x4b/0x50 __do_replace+0x52/0x260 [ip_tables] do_ipt_set_ctl+0x15d/0x1d0 [ip_tables] nf_setsockopt+0x65/0x90 ip_setsockopt+0x61/0xa0 raw_setsockopt+0x16/0x60 sock_common_setsockopt+0x14/0x20 SyS_setsockopt+0x71/0xd0
It turns out we don't validate that the num_counters field in the struct we pass in from userspace is initialized.
The same problem also exists in ebtables, arptables, ipv6, and the compat variants.
--- net/bridge/netfilter/ebtables.c | 4 ++++ net/ipv4/netfilter/arp_tables.c | 6 ++++++ net/ipv4/netfilter/ip_tables.c | 6 ++++++ net/ipv6/netfilter/ip6_tables.c | 6 ++++++ 4 files changed, 22 insertions(+)
net/bridge/netfilter/ebtables.c +4 -0
@@ -1105,6 +1105,8 @@ static int do_replace(struct net *net, creturn -ENOMEM ;if (tmp.num_counters >=INT_MAX /sizeof (struct ebt_counter ))return -ENOMEM ; +if (tmp.num_counters ==0 ) +return -EINVAL ; tmp.name[sizeof (tmp.name) -1 ] =0 ;
@@ -2150,6 +2152,8 @@ static int compat_copy_ebt_replace_from_return -ENOMEM ;if (tmp.num_counters >=INT_MAX /sizeof (struct ebt_counter ))return -ENOMEM ; +if (tmp.num_counters ==0 ) +return -EINVAL ;memcpy (repl, &tmp, offsetof(struct ebt_replace , hook_entry));
net/ipv4/netfilter/arp_tables.c +6 -0
@@ -1082,6 +1082,9 @@ static int do_replace(struct net *net, c/* overflow check */ if (tmp.num_counters >=INT_MAX /sizeof (struct xt_counters ))return -ENOMEM ; +if (tmp.num_counters ==0 ) +return -EINVAL ; + tmp.name[sizeof (tmp.name)-1 ] =0 ; newinfo =xt_alloc_table_info (tmp.size);
@@ -1392,6 +1395,9 @@ static int compat_do_replace(struct netreturn -ENOMEM ;if (tmp.num_counters >=INT_MAX /sizeof (struct xt_counters ))return -ENOMEM ; +if (tmp.num_counters ==0 ) +return -EINVAL ; + tmp.name[sizeof (tmp.name)-1 ] =0 ; newinfo =xt_alloc_table_info (tmp.size);
net/ipv4/netfilter/ip_tables.c +6 -0
@@ -1268,6 +1268,9 @@ do_replace(struct net *net, const void _/* overflow check */ if (tmp.num_counters >=INT_MAX /sizeof (struct xt_counters ))return -ENOMEM ; +if (tmp.num_counters ==0 ) +return -EINVAL ; + tmp.name[sizeof (tmp.name)-1 ] =0 ; newinfo =xt_alloc_table_info (tmp.size);
@@ -1669,6 +1672,9 @@ compat_do_replace(struct net *net, voidreturn -ENOMEM ;if (tmp.num_counters >=INT_MAX /sizeof (struct xt_counters ))return -ENOMEM ; +if (tmp.num_counters ==0 ) +return -EINVAL ; + tmp.name[sizeof (tmp.name)-1 ] =0 ; newinfo =xt_alloc_table_info (tmp.size);
net/ipv6/netfilter/ip6_tables.c +6 -0
@@ -1278,6 +1278,9 @@ do_replace(struct net *net, const void _/* overflow check */ if (tmp.num_counters >=INT_MAX /sizeof (struct xt_counters ))return -ENOMEM ; +if (tmp.num_counters ==0 ) +return -EINVAL ; + tmp.name[sizeof (tmp.name)-1 ] =0 ; newinfo =xt_alloc_table_info (tmp.size);
@@ -1672,6 +1675,9 @@ compat_do_replace(struct net *net, voidreturn -ENOMEM ;if (tmp.num_counters >=INT_MAX /sizeof (struct xt_counters ))return -ENOMEM ; +if (tmp.num_counters ==0 ) +return -EINVAL ; + tmp.name[sizeof (tmp.name)-1 ] =0 ; newinfo =xt_alloc_table_info (tmp.size);
PATCH 259/305 x86/power/64: Fix kernel text mapping corruption during image restoration
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Rafael J. Wysocki" <[email protected]>
commit 65c0554b73c920023cc8998802e508b798113b46 upstream.
Logan Gunthorpe reports that hibernation stopped working reliably for him after commit ab76f7b4ab23 (x86/mm: Set NX on gap between __ex_table and rodata).
That turns out to be a consequence of a long-standing issue with the 64-bit image restoration code on x86, which is that the temporary page tables set up by it to avoid page tables corruption when the last bits of the image kernel's memory contents are copied into their original page frames re-use the boot kernel's text mapping, but that mapping may very well get corrupted just like any other part of the page tables. Of course, if that happens, the final jump to the image kernel's entry point will go to nowhere.
The exact reason why commit ab76f7b4ab23 matters here is that it sometimes causes a PMD of a large page to be split into PTEs that are allocated dynamically and get corrupted during image restoration as described above.
To fix that issue note that the code copying the last bits of the image kernel's memory contents to the page frames occupied by them previoulsy doesn't use the kernel text mapping, because it runs from a special page covered by the identity mapping set up for that code from scratch. Hence, the kernel text mapping is only needed before that code starts to run and then it will only be used just for the final jump to the image kernel's entry point.
Accordingly, the temporary page tables set up in swsusp_arch_resume() on x86-64 need to contain the kernel text mapping too. That mapping is only going to be used for the final jump to the image kernel, so it only needs to cover the image kernel's entry point, because the first thing the image kernel does after getting control back is to switch over to its own original page tables. Moreover, the virtual address of the image kernel's entry point in that mapping has to be the same as the one mapped by the image kernel's page tables.
With that in mind, modify the x86-64's arch_hibernation_header_save() and arch_hibernation_header_restore() routines to pass the physical address of the image kernel's entry point (in addition to its virtual address) to the boot kernel (a small piece of assembly code involved in passing the entry point's virtual address to the image kernel is not necessary any more after that, so drop it). Update RESTORE_MAGIC too to reflect the image header format change.
Next, in set_up_temporary_mappings(), use the physical and virtual addresses of the image kernel's entry point passed in the image header to set up a minimum kernel text mapping (using memory pages that won't be overwritten by the image kernel's memory contents) that will map those addresses to each other as appropriate.
This makes the concern about the possible corruption of the original boot kernel text mapping go away and if the the minimum kernel text mapping used for the final jump marks the image kernel's entry point memory as executable, the jump to it is guaraneed to succeed.
--- arch/x86/power/hibernate_64.c | 97 ++++++++++++++++++++++++++++++++++----- arch/x86/power/hibernate_asm_64.S | 55 ++++++++++------------ 2 files changed, 109 insertions(+), 43 deletions(-)
arch/x86/power/hibernate_64.c +85 -12
@@ -19,6 +19,7 @@#include <asm/mtrr.h> #include <asm/sections.h> #include <asm/suspend.h> +#include <asm/tlbflush.h> /* Defined in hibernate_asm_64.S */ extern asmlinkage __visible int restore_image(void);
@@ -28,6 +29,7 @@ extern asmlinkage __visible int restore_* kernel's text (this value is passed in the image header). */ unsigned long restore_jump_address __visible; +unsigned long jump_address_phys;/* * Value of the cr3 register from before the hibernation (this value is passed
@@ -37,7 +39,43 @@ unsigned long restore_cr3 __visible; pgd_t *temp_level4_pgt __visible; -void *relocated_restore_code __visible; +unsigned long relocated_restore_code __visible; + +static int set_up_temporary_text_mapping (void ) +{ +pmd_t *pmd; +pud_t *pud; + +/* +* The new mapping only has to cover the page containing the image +* kernel's entry point (jump_address_phys), because the switch over to +* it is carried out by relocated code running from a page allocated +* specifically for this purpose and covered by the identity mapping, so +* the temporary kernel text mapping is only needed for the final jump. +* Moreover, in that mapping the virtual address of the image kernel's +* entry point must be the same as its virtual address in the image +* kernel (restore_jump_address), so the image kernel's +* restore_registers() code doesn't find itself in a different area of +* the virtual address space after switching over to the original page +* tables used by the image kernel. +*/ + pud = (pud_t *)get_safe_page (GFP_ATOMIC ); +if (!pud) +return -ENOMEM ; + + pmd = (pmd_t *)get_safe_page (GFP_ATOMIC ); +if (!pmd) +return -ENOMEM ; + +set_pmd (pmd +pmd_index (restore_jump_address), +__pmd ((jump_address_phys &PMD_MASK ) | __PAGE_KERNEL_LARGE_EXEC)); +set_pud (pud +pud_index (restore_jump_address), +__pud (__pa (pmd) | _KERNPG_TABLE)); +set_pgd (temp_level4_pgt +pgd_index (restore_jump_address), +__pgd (__pa (pud) | _KERNPG_TABLE)); + +return 0 ; +}static void *alloc_pgt_page (void *context) {
@@ -59,9 +97,10 @@ static int set_up_temporary_mappings(voiif (!temp_level4_pgt)return -ENOMEM ; -/* It is safe to reuse the original kernel mapping */ -set_pgd (temp_level4_pgt +pgd_index (__START_KERNEL_map), - init_level4_pgt[pgd_index (__START_KERNEL_map)]); +/* Prepare a temporary mapping for the kernel text */ + result =set_up_temporary_text_mapping (); +if (result) +return result;/* Set up the direct mapping from scratch */ for (i =0 ; i < nr_pfn_mapped; i++) {
@@ -78,19 +117,50 @@ static int set_up_temporary_mappings(voireturn 0 ; } +static int relocate_restore_code (void ) +{ +pgd_t *pgd; +pud_t *pud; + + relocated_restore_code =get_safe_page (GFP_ATOMIC ); +if (!relocated_restore_code) +return -ENOMEM ; + +memcpy ((void *)relocated_restore_code, &core_restore_code,PAGE_SIZE ); + +/* Make the page containing the relocated code executable */ + pgd = (pgd_t *)__va (read_cr3 ()) +pgd_index (relocated_restore_code); + pud =pud_offset (pgd, relocated_restore_code); +if (pud_large (*pud)) { +set_pud (pud,__pud (pud_val (*pud) & ~_PAGE_NX)); + }else { +pmd_t *pmd =pmd_offset (pud, relocated_restore_code); + +if (pmd_large (*pmd)) { +set_pmd (pmd,__pmd (pmd_val (*pmd) & ~_PAGE_NX)); + }else { +pte_t *pte =pte_offset_kernel (pmd, relocated_restore_code); + +set_pte (pte,__pte (pte_val (*pte) & ~_PAGE_NX)); + } + } +__flush_tlb_all (); + +return 0 ; +} +int swsusp_arch_resume (void ) {int error;/* We have got enough memory and from now on we cannot recover */ -if ((error =set_up_temporary_mappings ())) + error =set_up_temporary_mappings (); +if (error)return error; - relocated_restore_code = (void *)get_safe_page (GFP_ATOMIC ); -if (!relocated_restore_code) -return -ENOMEM ; -memcpy (relocated_restore_code, &core_restore_code, - &restore_registers - &core_restore_code); + error =relocate_restore_code (); +if (error) +return error;restore_image ();return 0 ;
@@ -109,11 +179,12 @@ int pfn_is_nosave(unsigned long pfn)struct restore_data_record {unsigned long jump_address; +unsigned long jump_address_phys;unsigned long cr3;unsigned long magic; }; -#define RESTORE_MAGIC 0x0123456789ABCDEFUL +#define RESTORE_MAGIC 0x123456789ABCDEF0UL/** * arch_hibernation_header_save - populate the architecture specific part
@@ -126,7 +197,8 @@ int arch_hibernation_header_save(void *aif (max_size <sizeof (struct restore_data_record ))return -EOVERFLOW ; - rdr->jump_address = restore_jump_address; + rdr->jump_address = (unsigned long )&restore_registers; + rdr->jump_address_phys =__pa_symbol (&restore_registers); rdr->cr3 = restore_cr3; rdr->magic =RESTORE_MAGIC ;return 0 ;
@@ -142,6 +214,7 @@ int arch_hibernation_header_restore(voidstruct restore_data_record *rdr = addr; restore_jump_address = rdr->jump_address; + jump_address_phys = rdr->jump_address_phys; restore_cr3 = rdr->cr3;return (rdr->magic ==RESTORE_MAGIC ) ?0 : -EINVAL ; }
arch/x86/power/hibernate_asm_64.S +24 -31
87 lines not on this page · raw message
PATCH 133/305 powerpc: Use privileged SPR number for MMCR2
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Huth <[email protected]>
commit 8dd75ccb571f3c92c48014b3dabd3d51a115ab41 upstream.
We are already using the privileged versions of MMCR0, MMCR1 and MMCRA in the kernel, so for MMCR2, we should better use the privileged versions, too, to be consistent.
--- arch/powerpc/include/asm/reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/reg.h +1 -1
@@ -704,7 +704,7 @@#define MMCR0_FCWAIT 0x00000002UL/* freeze counter in WAIT state */ #define MMCR0_FCHV 0x00000001UL/* freeze conditions in hypervisor mode */ #define SPRN_MMCR1 798 -#define SPRN_MMCR2 769 +#define SPRN_MMCR2 785#define SPRN_MMCRA 0x312#define MMCRA_SDSYNC 0x80000000UL/* SDAR synced with SIAR */ #define MMCRA_SDAR_DCACHE_MISS 0x40000000UL
PATCH 270/305 xen/acpi: allow xen-acpi-processor driver to load on Xen 4.7
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
commit 6f2d9d99213514360034c6d52d2c3919290b3504 upstream.
As of Xen 4.7 PV CPUID doesn't expose either of CPUID[1].ECX[7] and CPUID[0x80000007].EDX[7] anymore, causing the driver to fail to load on both Intel and AMD systems. Doing any kind of hardware capability checks in the driver as a prerequisite was wrong anyway: With the hypervisor being in charge, all such checking should be done by it. If ACPI data gets uploaded despite some missing capability, the hypervisor is free to ignore part or all of that data.
Ditch the entire check_prereq() function, and do the only valid check (xen_initial_domain()) in the caller in its place.
--- drivers/xen/xen-acpi-processor.c | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-)
drivers/xen/xen-acpi-processor.c +3 -32
@@ -423,36 +423,7 @@ upload:return 0 ; } -static int __init check_prereq (void ) -{ -struct cpuinfo_x86 *c = &cpu_data (0 ); - -if (!xen_initial_domain ()) -return -ENODEV ; - -if (!acpi_gbl_FADT.smi_command) -return -ENODEV ; -if (c->x86_vendor ==X86_VENDOR_INTEL ) { -if (!cpu_has (c,X86_FEATURE_EST )) -return -ENODEV ; - -return 0 ; - } -if (c->x86_vendor ==X86_VENDOR_AMD ) { -/* Copied from powernow-k8.h, can't include ../cpufreq/powernow -* as we get compile warnings for the static functions. -*/ -#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007 -#define USE_HW_PSTATE 0x00000080 -u32 eax, ebx, ecx, edx; -cpuid (CPUID_FREQ_VOLT_CAPABILITIES , &eax, &ebx, &ecx, &edx); -if ((edx &USE_HW_PSTATE ) !=USE_HW_PSTATE ) -return -ENODEV ; -return 0 ; - } -return -ENODEV ; -}/* acpi_perf_data is a pointer to percpu data. */ static struct acpi_processor_performance __percpu *acpi_perf_data;
@@ -509,10 +480,10 @@ struct notifier_block xen_acpi_processorstatic int __init xen_acpi_processor_init (void ) {unsigned int i; -int rc =check_prereq (); +int rc; -if (rc) -return rc; +if (!xen_initial_domain ()) +return -ENODEV ; nr_acpi_bits =get_max_acpi_id () +1 ; acpi_ids_done =kcalloc (BITS_TO_LONGS (nr_acpi_bits),sizeof (unsigned long ),GFP_KERNEL );
PATCH 224/305 ALSA: dummy: Fix a use-after-free at closing
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit d5dbbe6569481bf12dcbe3e12cff72c5f78d272c upstream.
syzkaller fuzzer spotted a potential use-after-free case in snd-dummy driver when hrtimer is used as backend:
Quoted 30 lines
==================================================================
BUG: KASAN: use-after-free in rb_erase+0x1b17/0x2010 at addr ffff88005e5b6f68 Read of size 8 by task syz-executor/8984 =============================================================================BUG kmalloc-192 (Not tainted): kasan: bad access detected
-----------------------------------------------------------------------------Disabling lock debugging due to kernel taint
INFO: Allocated in0xbbbbbbbbbbbbbbbbage=18446705582212484632
....
[< none >]dummy_hrtimer_create+0x49/0x1a0sound/drivers/dummy.c:464
....
INFO: Freed in0xfffd8e09age=18446705496313138713 cpu=2164287125 pid=-1
[< none >]dummy_hrtimer_free+0x68/0x80sound/drivers/dummy.c:481
....Call Trace: [<ffffffff8179e59e>] __asan_report_load8_noabort+0x3e/0x40 mm/kasan/report.c:333 [< inline >] rb_set_parent include/linux/rbtree_augmented.h:111 [< inline >] __rb_erase_augmented include/linux/rbtree_augmented.h:218 [<ffffffff82ca5787>] rb_erase+0x1b17/0x2010 lib/rbtree.c:427 [<ffffffff82cb02e8>] timerqueue_del+0x78/0x170 lib/timerqueue.c:86 [<ffffffff814d0c80>] __remove_hrtimer+0x90/0x220 kernel/time/hrtimer.c:903 [< inline >] remove_hrtimer kernel/time/hrtimer.c:945 [<ffffffff814d23da>] hrtimer_try_to_cancel+0x22a/0x570 kernel/time/hrtimer.c:1046 [<ffffffff814d2742>] hrtimer_cancel+0x22/0x40 kernel/time/hrtimer.c:1066 [<ffffffff85420531>] dummy_hrtimer_stop+0x91/0xb0 sound/drivers/dummy.c:417 [<ffffffff854228bf>] dummy_pcm_trigger+0x17f/0x1e0 sound/drivers/dummy.c:507 [<ffffffff85392170>] snd_pcm_do_stop+0x160/0x1b0 sound/core/pcm_native.c:1106 [<ffffffff85391b26>] snd_pcm_action_single+0x76/0x120 sound/core/pcm_native.c:956 [<ffffffff85391e01>] snd_pcm_action+0x231/0x290 sound/core/pcm_native.c:974
Quoted 8 lines
[< inline >] snd_pcm_stop sound/core/pcm_native.c:1139 [<ffffffff8539754d>] snd_pcm_drop+0x12d/0x1d0 sound/core/pcm_native.c:1784 [<ffffffff8539d3be>] snd_pcm_common_ioctl1+0xfae/0x2150 sound/core/pcm_native.c:2805 [<ffffffff8539ee91>] snd_pcm_capture_ioctl1+0x2a1/0x5e0 sound/core/pcm_native.c:2976 [<ffffffff8539f2ec>] snd_pcm_kernel_ioctl+0x11c/0x160 sound/core/pcm_native.c:3020 [<ffffffff853d9a44>] snd_pcm_oss_sync+0x3a4/0xa30 sound/core/oss/pcm_oss.c:1693 [<ffffffff853da27d>] snd_pcm_oss_release+0x1ad/0x280 sound/core/oss/pcm_oss.c:2483 .....
A workaround is to call hrtimer_cancel() in dummy_hrtimer_sync() which is called certainly before other blocking ops.
--- sound/drivers/dummy.c | 1 + 1 file changed, 1 insertion(+)
sound/drivers/dummy.c +1 -0
@@ -422,6 +422,7 @@ static int dummy_hrtimer_stop(struct sndstatic inline void dummy_hrtimer_sync (struct dummy_hrtimer_pcm *dpcm) { +hrtimer_cancel (&dpcm->timer);tasklet_kill (&dpcm->tasklet); }
PATCH 201/305 hwmon: (dell-smm) Restrict fan control and serial number to CAP_SYS_ADMIN by default
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Pali Rohár <[email protected]>
commit 7613663cc186f8f3c50279390ddc60286758001c upstream.
For security reasons ordinary user must not be able to control fan speed via /proc/i8k by default. Some malicious software running under "nobody" user could be able to turn fan off and cause HW problems. So this patch changes default value of "restricted" parameter to 1.
Also restrict reading of DMI_PRODUCT_SERIAL from /proc/i8k via "restricted" parameter. It is because non root user cannot read DMI_PRODUCT_SERIAL from sysfs file /sys/class/dmi/id/product_serial.
Old non secure behaviour of file /proc/i8k can be achieved by loading this module with "restricted" parameter set to 0.
Note that this patch has effects only for kernels compiled with CONFIG_I8K and only for file /proc/i8k. Hwmon interface provided by this driver was not changed and root access for setting fan speed was needed also before.
--- drivers/char/i8k.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/char/i8k.c +12 -7
@@ -62,6 +62,7 @@static DEFINE_MUTEX (i8k_mutex);static char bios_version[4 ]; +static char bios_machineid[16 ];static struct device *i8k_hwmon_dev;static u32 i8k_hwmon_flags;static int i8k_fan_mult;
@@ -85,13 +86,13 @@ static bool ignore_dmi;module_param (ignore_dmi, bool,0 );MODULE_PARM_DESC (ignore_dmi,"Continue probing hardware even if DMI data does not match" ); -static bool restricted; +static bool restricted = true;module_param (restricted, bool,0 ); -MODULE_PARM_DESC (restricted,"Allow fan control if SYS_ADMIN capability set" ); +MODULE_PARM_DESC (restricted,"Restrict fan control and serial number to CAP_SYS_ADMIN (default: 1)" );static bool power_status;module_param (power_status, bool,0600 ); -MODULE_PARM_DESC (power_status,"Report power status in /proc/i8k" ); +MODULE_PARM_DESC (power_status,"Report power status in /proc/i8k (default: 0)" );static int fan_mult =I8K_FAN_MULT ;module_param (fan_mult, int,0 );
@@ -350,9 +351,11 @@ i8k_ioctl_unlocked(struct file *fp, unsibreak ;case I8K_MACHINE_ID : -memset (buff,0 ,16 ); -strlcpy (buff,i8k_get_dmi_data (DMI_PRODUCT_SERIAL ), -sizeof (buff)); +if (restricted && !capable (CAP_SYS_ADMIN )) +return -EPERM ; + +memset (buff,0 ,sizeof (buff)); +strlcpy (buff, bios_machineid,sizeof (buff));break ;case I8K_FN_STATUS :
@@ -469,7 +472,7 @@ static int i8k_proc_show(struct seq_filereturn seq_printf (seq,"%s %s %s %d %d %d %d %d %d %d\n" ,I8K_PROC_FMT , bios_version, -i8k_get_dmi_data (DMI_PRODUCT_SERIAL ), + (restricted && !capable (CAP_SYS_ADMIN )) ?"-1" : bios_machineid, cpu_temp, left_fan, right_fan, left_speed, right_speed, ac_power, fn_key);
@@ -765,6 +768,8 @@ static int __init i8k_probe(void)strlcpy (bios_version,i8k_get_dmi_data (DMI_BIOS_VERSION ),sizeof (bios_version)); +strlcpy (bios_machineid,i8k_get_dmi_data (DMI_PRODUCT_SERIAL ), +sizeof (bios_machineid));/* * Get SMM Dell signature
PATCH 173/305 USB: quirks: Fix entries on wrong list in 3.16.y
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
Commits ddbe1fca0bcb ("USB: Add device quirk for ASUS T100 Base Station keyboard") and e5dff0e80463 ("USB: Add OTG PET device to TPL") were wrongly backported to 3.16.y. The original commits added to usb_quirk_list but the backported versions added to usb_interface_quirk_list.
---
drivers/usb/core/quirks.c +8 -8
@@ -188,6 +188,14 @@ static const struct usb_device_id usb_qu/* USB3503 */ { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME }, + /* ASUS Base Station(T100) */ + { USB_DEVICE(0x0b05, 0x17e0), .driver_info = + USB_QUIRK_IGNORE_REMOTE_WAKEUP }, + + /* Protocol and OTG Electrical Test Device */ + { USB_DEVICE(0x1a0a, 0x0200), .driver_info = + USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, + /* Blackmagic Design Intensity Shuttle */ { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
@@ -202,14 +210,6 @@ static const struct usb_device_id usb_in { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0), .driver_info = USB_QUIRK_RESET_RESUME }, - /* ASUS Base Station(T100) */ - { USB_DEVICE(0x0b05, 0x17e0), .driver_info = - USB_QUIRK_IGNORE_REMOTE_WAKEUP }, - - /* Protocol and OTG Electrical Test Device */ - { USB_DEVICE(0x1a0a, 0x0200), .driver_info = - USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, - { }/* terminating entry must be last */ };
PATCH 51/305 MIPS: Fix siginfo.h to use strict posix types
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 5daebc477da4dfeb31ae193d83084def58fd2697 upstream.
Commit 85efde6f4e0d ("make exported headers use strict posix types") changed the asm-generic siginfo.h to use the __kernel_* types, and commit 3a471cbc081b ("remove __KERNEL_STRICT_NAMES") make the internal types accessible only to the kernel, but the MIPS implementation hasn't been updated to match.
Switch to proper types now so that the exported asm/siginfo.h won't produce quite so many compiler errors when included alone by a user program.
Patchwork: https://patchwork.linux-mips.org/patch/12477/
--- arch/mips/include/uapi/asm/siginfo.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/mips/include/uapi/asm/siginfo.h +9 -9
@@ -48,13 +48,13 @@ typedef struct siginfo {/* kill() */ struct { -pid_t _pid;/* sender's pid */ +__kernel_pid_t _pid;/* sender's pid */ __ARCH_SI_UID_T _uid;/* sender's uid */ } _kill;/* POSIX.1b timers */ struct { -timer_t _tid;/* timer id */ +__kernel_timer_t _tid;/* timer id */ int _overrun;/* overrun count */ char _pad[sizeof ( __ARCH_SI_UID_T) -sizeof (int )];sigval_t _sigval;/* same as below */
@@ -63,26 +63,26 @@ typedef struct siginfo {/* POSIX.1b signals */ struct { -pid_t _pid;/* sender's pid */ +__kernel_pid_t _pid;/* sender's pid */ __ARCH_SI_UID_T _uid;/* sender's uid */ sigval_t _sigval; } _rt;/* SIGCHLD */ struct { -pid_t _pid;/* which child */ +__kernel_pid_t _pid;/* which child */ __ARCH_SI_UID_T _uid;/* sender's uid */ int _status;/* exit code */ -clock_t _utime; -clock_t _stime; +__kernel_clock_t _utime; +__kernel_clock_t _stime; } _sigchld;/* IRIX SIGCHLD */ struct { -pid_t _pid;/* which child */ -clock_t _utime; +__kernel_pid_t _pid;/* which child */ +__kernel_clock_t _utime;int _status;/* exit code */ -clock_t _stime; +__kernel_clock_t _stime; } _irix_sigchld;/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
PATCH 75/305 MIPS: Fix race condition in lazy cache flushing.
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lars Persson <[email protected]>
commit 4d46a67a3eb827ccf1125959936fd51ba318dabc upstream.
The lazy cache flushing implemented in the MIPS kernel suffers from a race condition that is exposed by do_set_pte() in mm/memory.c.
A pre-condition is a file-system that writes to the page from the CPU in its readpage method and then calls flush_dcache_page(). One example is ubifs. Another pre-condition is that the dcache flush is postponed in __flush_dcache_page().
Upon a page fault for an executable mapping not existing in the page-cache, the following will happen:
1. Write to the page
2. flush_dcache_page
3. flush_icache_page
4. set_pte_at
5. update_mmu_cache (commits the flush of a dcache-dirty page)
Between steps 4 and 5 another thread can hit the same page and it will encounter a valid pte. Because the data still is in the L1 dcache the CPU will fetch stale data from L2 into the icache and execute garbage.
This fix moves the commit of the cache flush to step 3 to close the race window. It also reduces the amount of flushes on non-executable mappings because we never enter __flush_dcache_page() for non-aliasing CPUs.
Regressions can occur in drivers that mistakenly relies on the flush_dcache_page() in get_user_pages() for DMA operations.
[[email protected]: Folded in patch 9346 to fix highmem issue.]
Patchwork: https://patchwork.linux-mips.org/patch/9346/
Patchwork: https://patchwork.linux-mips.org/patch/9738/
--- arch/mips/include/asm/cacheflush.h | 38 +++++++++++++++++++++++--------------- arch/mips/mm/cache.c | 12 ++++++++++++ 2 files changed, 35 insertions(+), 15 deletions(-)
arch/mips/include/asm/cacheflush.h +23 -15
@@ -29,6 +29,20 @@* - flush_icache_all() flush the entire instruction cache * - flush_data_cache_page() flushes a page from the data cache */ + +/* +* This flag is used to indicate that the page pointed to by a pte +* is dirty and requires cleaning before returning it to the user. +*/ +#define PG_dcache_dirty PG_arch_1 + +#define Page_dcache_dirty (page) \ + test_bit(PG_dcache_dirty, &(page)->flags) +#define SetPageDcacheDirty (page) \ + set_bit(PG_dcache_dirty, &(page)->flags) +#define ClearPageDcacheDirty (page) \ + clear_bit(PG_dcache_dirty, &(page)->flags) +extern void (*flush_cache_all)(void );extern void (*__flush_cache_all)(void );extern void (*flush_cache_mm)(struct mm_struct *mm);
@@ -37,13 +51,15 @@ extern void (*flush_cache_range)(struct unsigned long start, unsigned long end);extern void (*flush_cache_page)(struct vm_area_struct *vma,unsigned long page,unsigned long pfn);extern void __flush_dcache_page (struct page *page); +extern void __flush_icache_page (struct vm_area_struct *vma,struct page *page);#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1static inline void flush_dcache_page (struct page *page) { -if (cpu_has_dc_aliases || !cpu_has_ic_fills_f_dc) +if (cpu_has_dc_aliases)__flush_dcache_page (page); - +else if (!cpu_has_ic_fills_f_dc) +SetPageDcacheDirty (page); }#define flush_dcache_mmap_lock (mapping) do { } while (0)
@@ -61,6 +77,11 @@ static inline void flush_anon_page(strucstatic inline void flush_icache_page (struct vm_area_struct *vma,struct page *page) { +if (!cpu_has_ic_fills_f_dc && (vma->vm_flags &VM_EXEC ) && +Page_dcache_dirty (page)) { +__flush_icache_page (vma, page); +ClearPageDcacheDirty (page); + } }extern void (*flush_icache_range)(unsigned long start,unsigned long end);
@@ -95,19 +116,6 @@ extern void (*flush_icache_all)(void);extern void (*local_flush_data_cache_page)(void * addr);extern void (*flush_data_cache_page)(unsigned long addr); -/* -* This flag is used to indicate that the page pointed to by a pte -* is dirty and requires cleaning before returning it to the user. -*/ -#define PG_dcache_dirty PG_arch_1 - -#define Page_dcache_dirty (page) \ - test_bit(PG_dcache_dirty, &(page)->flags) -#define SetPageDcacheDirty (page) \ - set_bit(PG_dcache_dirty, &(page)->flags) -#define ClearPageDcacheDirty (page) \ - clear_bit(PG_dcache_dirty, &(page)->flags) -/* Run kernel code uncached, useful for cache probing functions. */ unsigned long run_uncached (void *func);
arch/mips/mm/cache.c +12 -0
@@ -119,6 +119,18 @@ void __flush_anon_page(struct page *pageEXPORT_SYMBOL (__flush_anon_page); +void __flush_icache_page (struct vm_area_struct *vma,struct page *page) +{ +unsigned long addr; + +if (PageHighMem (page)) +return ; + + addr = (unsigned long )page_address (page); +flush_data_cache_page (addr); +} +EXPORT_SYMBOL_GPL (__flush_icache_page); +void __update_cache (struct vm_area_struct *vma,unsigned long address,pte_t pte) {
PATCH 54/305 MIPS: Avoid using unwind_stack() with usermode
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 81a76d7119f63c359750e4adeff922a31ad1135f upstream.
When showing backtraces in response to traps, for example crashes and address errors (usually unaligned accesses) when they are set in debugfs to be reported, unwind_stack will be used if the PC was in the kernel text address range. However since EVA it is possible for user and kernel address ranges to overlap, and even without EVA userland can still trigger an address error by jumping to a KSeg0 address.
Adjust the check to also ensure that it was running in kernel mode. I don't believe any harm can come of this problem, since unwind_stack() is sufficiently defensive, however it is only meant for unwinding kernel code, so to be correct it should use the raw backtracing instead.
Patchwork: https://patchwork.linux-mips.org/patch/11701/
--- arch/mips/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/traps.c +1 -1
@@ -140,7 +140,7 @@ static void show_backtrace(struct task_sif (!task) task = current; -if (raw_show_trace || !__kernel_text_address (pc)) { +if (raw_show_trace ||user_mode (regs) || !__kernel_text_address (pc)) {show_raw_backtrace (sp);return ; }
PATCH 55/305 MIPS: Adjust set_pte() SMP fix to handle R10000_LLSC_WAR
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Kinard <[email protected]>
commit 128639395b2ceacc6a56a0141d0261012bfe04d3 upstream.
Update the recent changes to set_pte() that were added in 46011e6ea392 to handle R10000_LLSC_WAR, and format the assembly to match other areas of the MIPS tree using the same WAR.
This also incorporates a patch recently sent in my Markos Chandras, "Remove local LL/SC preprocessor variants", so that patch doesn't need to be applied if this one is accepted.
Patchwork: https://patchwork.linux-mips.org/patch/11103/
[bwh: Backported to 3.2:
- Use {LL,SC}_INSN not __{LL,SC}
- Use literal arch=r4000 instead of MIPS_ISA_ARCH_LEVEL since R6 is not supported]
--- arch/mips/include/asm/pgtable.h | 45 +++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 13 deletions(-)
arch/mips/include/asm/pgtable.h +32 -13
@@ -167,20 +167,39 @@ static inline void set_pte(pte_t *ptep,unsigned long page_global = _PAGE_GLOBAL;unsigned long tmp; - __asm__ __volatile__ ( -" .set push\n" -" .set noreorder\n" -"1: " LL_INSN " %[tmp], %[buddy]\n" -" bnez %[tmp], 2f\n" -" or %[tmp], %[tmp], %[global]\n" -" " SC_INSN " %[tmp], %[buddy]\n" -" beqz %[tmp], 1b\n" -" nop\n" -"2:\n" -" .set pop" - : [buddy]"+m" (buddy->pte), - [tmp]"=&r" (tmp) +if (kernel_uses_llsc &&R10000_LLSC_WAR ) { + __asm__ __volatile__ ( +" .set arch=r4000 \n" +" .set push \n" +" .set noreorder \n" +"1:" LL_INSN " %[tmp], %[buddy] \n" +" bnez %[tmp], 2f \n" +" or %[tmp], %[tmp], %[global] \n" +SC_INSN " %[tmp], %[buddy] \n" +" beqzl %[tmp], 1b \n" +" nop \n" +"2: \n" +" .set pop \n" +" .set mips0 \n" + : [buddy]"+m" (buddy->pte), [tmp]"=&r" (tmp) : [global]"r" (page_global)); + }else if (kernel_uses_llsc) { + __asm__ __volatile__ ( +" .set arch=r4000 \n" +" .set push \n" +" .set noreorder \n" +"1:" LL_INSN " %[tmp], %[buddy] \n" +" bnez %[tmp], 2f \n" +" or %[tmp], %[tmp], %[global] \n" +SC_INSN " %[tmp], %[buddy] \n" +" beqz %[tmp], 1b \n" +" nop \n" +"2: \n" +" .set pop \n" +" .set mips0 \n" + : [buddy]"+m" (buddy->pte), [tmp]"=&r" (tmp) + : [global]"r" (page_global)); + }#else /* !CONFIG_SMP */ if (pte_none (*buddy))pte_val (*buddy) =pte_val (*buddy) | _PAGE_GLOBAL;
PATCH 76/305 MIPS: math-emu: Fix jalr emulation when rd == $0
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit ab4a92e66741b35ca12f8497896bafbe579c28a1 upstream.
When emulating a jalr instruction with rd == $0, the code in isBranchInstr was incorrectly writing to GPR $0 which should actually always remain zeroed. This would lead to any further instructions emulated which use $0 operating on a bogus value until the task is next context switched, at which point the value of $0 in the task context would be restored to the correct zero by a store in SAVE_SOME. Fix this by not writing to rd if it is $0.
Patchwork: https://patchwork.linux-mips.org/patch/13160/
--- arch/mips/math-emu/cp1emu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/mips/math-emu/cp1emu.c +5 -3
@@ -443,9 +443,11 @@ static int isBranchInstr(struct pt_regscase spec_op:switch (insn.r_format.func) {case jalr_op: - regs->regs[insn.r_format.rd] = - regs->cp0_epc + dec_insn.pc_inc + - dec_insn.next_pc_inc; +if (insn.r_format.rd !=0 ) { + regs->regs[insn.r_format.rd] = + regs->cp0_epc + dec_insn.pc_inc + + dec_insn.next_pc_inc; + }/* Fall through */ case jr_op: *contpc = regs->regs[insn.r_format.rs];
Re: [PATCH 3.16 102/305] xfs: xfs_iflush_cluster fails to abort on error
In reply to Ben HutchingsQuoted 16 lines · Ben Hutchings
3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit
b1438f477934f5a4d5a44df26f3079a7575d5946upstream.When a failure due to an inode buffer occurs, the error handling fails to abort the inode writeback correctly. This can result in the inode being reclaimed whilst still in the AIL, leading to use-after-free situations as well as filesystems that cannot be unmounted as the inode log items left in the AIL never get removed.
Fix this by ensuring fatal errors from
xfs_imap_to_bp()result in the inode flush being aborted correctly.
....
Quoted 5 lines
fs/xfs/xfs_inode.c +2
-1/* -* Get the buffer containing the on-disk inode. +* Get the buffer containing the on-disk inode. We are doing a try-lock +* operation here, so we may get an EAGAIN error. In that case, we
fs/xfs/xfs_inode.c xfs_iflush( · line 3206
Quoted 10 lines
fs/xfs/xfs_inode.c +6
-1+* simply want to return with the inode still dirty. +* +* If we get any other error, we effectively have a corruption situation +* and we cannot flush the inode, so we treat it the same as failing +* xfs_iflush_int(). */ error =xfs_imap_to_bp (mp,NULL , &ip->i_imap, &dip, &bp,XBF_TRYLOCK ,0 ); -if (error || !bp) { +if (error == -EAGAIN ) {
Wrong. As was pointed out for other -stable trees after users reported regressions, the error signs in XFS changed from positive to negative in 3.17-rc1.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 16 lines · Guenter Roeck
Quoted 9 lines · Ben Hutchings
This is the start of the stable review cycle for the 3.16.37 release.
There are 305 patches in this series, which will be posted as responses
to this one. If anyone has any issues with these being applied, please
let me know.Quoted 5 lines
As I've accumulated an unusually long patch series, I'm allowing a longer time for review. Responses should be made by Sat Aug 20 00:00:00 UTC 2016. Anything received after that time might be too late.
Quoted 6 lines
Build results:
total: 139 pass: 139 fail: 0 Qemu test results: total: 98 pass: 98 fail: 0Details are available at http://kerneltests.org/builders.
Thanks for checking.
Ben.
Signature · 3 lines
Ben Hutchings Make three consecutive correct guesses and you will be considered an expert.
PATCH 149/305 IB/mlx5: Return PORT_ERR in Active to Initializing tranisition
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Noa Osherovich <[email protected]>
commit 2788cf3bd90af3791c3195c52391bcf34fa67b40 upstream.
FW port-change events are fired on Active <-> non Active port state transitions only.
When the port state changes from Active to Initializing (Active -> Down -> Initializing), a single event is fired.
The HCA transitions from Down to Initializing unless prevented from doing so, hence the driver should also propagate events when the port state is Initializing to consumers so they'll be aware that the port is no longer Active and act accordingly.
--- drivers/infiniband/hw/mlx5/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/main.c +1 -4
@@ -1002,14 +1002,11 @@ static void mlx5_ib_event(struct mlx5_cobreak ;case MLX5_DEV_EVENT_PORT_DOWN : +case MLX5_DEV_EVENT_PORT_INITIALIZED : ibev.event =IB_EVENT_PORT_ERR ; port = *(u8 *)data;break ; -case MLX5_DEV_EVENT_PORT_INITIALIZED : -/* not used by ULPs */ -return ; -case MLX5_DEV_EVENT_LID_CHANGE : ibev.event =IB_EVENT_LID_CHANGE ; port = *(u8 *)data;
PATCH 234/305 iio:ad7266: Fix probe deferral for vref
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 68b356eb3d9f5e38910fb62e22a78e2a18d544ae upstream.
Currently the ad7266 driver treats any failure to get vref as though the regulator were not present but this means that if probe deferral is triggered the driver will act as though the regulator were not present. Instead only use the internal reference if we explicitly got -ENODEV which is what is returned for absent regulators.
--- drivers/iio/adc/ad7266.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/adc/ad7266.c +3 -0
@@ -408,6 +408,9 @@ static int ad7266_probe(struct spi_devic st->vref_mv = ret /1000 ; }else { +/* Any other error indicates that the regulator does exist */ +if (PTR_ERR (st->reg) != -ENODEV ) +return PTR_ERR (st->reg);/* Use internal reference */ st->vref_mv =2500 ; }
PATCH 284/305 s390/sclp_ctl: fix potential information leak with /dev/sclp
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Schwidefsky <[email protected]>
commit 532c34b5fbf1687df63b3fcd5b2846312ac943c6 upstream.
The sclp_ctl_ioctl_sccb function uses two copy_from_user calls to retrieve the sclp request from user space. The first copy_from_user fetches the length of the request which is stored in the first two bytes of the request. The second copy_from_user gets the complete sclp request, but this copies the length field a second time. A malicious user may have changed the length in the meantime.
--- drivers/s390/char/sclp_ctl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/s390/char/sclp_ctl.c +7 -5
@@ -56,6 +56,7 @@ static int sclp_ctl_ioctl_sccb(void __us {struct sclp_ctl_sccb ctl_sccb;struct sccb_header *sccb; +unsigned long copied;int rc;if (copy_from_user (&ctl_sccb, user_area,sizeof (ctl_sccb)))
@@ -65,14 +66,15 @@ static int sclp_ctl_ioctl_sccb(void __us sccb = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sccb)return -ENOMEM ; -if (copy_from_user (sccb,u64_to_uptr (ctl_sccb.sccb),sizeof (*sccb))) { + copied =PAGE_SIZE - +copy_from_user (sccb,u64_to_uptr (ctl_sccb.sccb),PAGE_SIZE ); +if (offsetof(struct sccb_header , length) + +sizeof (sccb->length) > copied || sccb->length > copied) { rc = -EFAULT ; goto out_free; } -if (sccb->length >PAGE_SIZE || sccb->length <8 ) -return -EINVAL ; -if (copy_from_user (sccb,u64_to_uptr (ctl_sccb.sccb), sccb->length)) { - rc = -EFAULT ; +if (sccb->length <8 ) { + rc = -EINVAL ; goto out_free; } rc =sclp_sync_request (ctl_sccb.cmdw, sccb);
PATCH 151/305 IB/IPoIB: Don't update neigh validity for unresolved entries
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Erez Shitrit <[email protected]>
commit 61c78eea9516a921799c17b4c20558e2aa780fd3 upstream.
ipoib_neigh_get unconditionally updates the "alive" variable member on any packet send. This prevents the neighbor garbage collection from cleaning out a dead neighbor entry if we are still queueing packets for it. If the queue for this neighbor is full, then don't update the alive timestamp. That way the neighbor can time out even if packets are still being queued as long as none of them are being sent.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/ipoib/ipoib_main.c +3 -1
@@ -884,7 +884,9 @@ struct ipoib_neigh *ipoib_neigh_get(stru neigh =NULL ; goto out_unlock; } - neigh->alive = jiffies; + +if (likely (skb_queue_len (&neigh->queue) <IPOIB_MAX_PATH_REC_QUEUE )) + neigh->alive = jiffies; goto out_unlock; } }
PATCH 19/305 Revert "scsi: fix soft lockup in scsi_remove_target() on module removal"
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit 305c2e71b3d733ec065cb716c76af7d554bd5571 upstream.
Now that we've done a more comprehensive fix with the intermediate target state we can remove the previous hack introduced with commit 90a88d6ef88e ("scsi: fix soft lockup in scsi_remove_target() on module removal").
--- drivers/scsi/scsi_sysfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/scsi_sysfs.c +2 -4
@@ -1148,19 +1148,17 @@ static void __scsi_remove_target(structvoid scsi_remove_target (struct device *dev) {struct Scsi_Host *shost =dev_to_shost (dev->parent); -struct scsi_target *starget, *last_target =NULL ; +struct scsi_target *starget;unsigned long flags; restart:spin_lock_irqsave (shost->host_lock, flags);list_for_each_entry (starget, &shost->__targets, siblings) {if (starget->state ==STARGET_DEL || - starget->state ==STARGET_REMOVE || - starget == last_target) + starget->state ==STARGET_REMOVE )continue ;if (starget->dev.parent == dev || &starget->dev == dev) {kref_get (&starget->reap_ref); - last_target = starget; starget->state =STARGET_REMOVE ;spin_unlock_irqrestore (shost->host_lock, flags);__scsi_remove_target (starget);
PATCH 278/305 ALSA: timer: Fix leak in events via snd_timer_user_ccallback
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kangjie Lu <[email protected]>
commit 9a47e9cff994f37f7f0dbd9ae23740d0f64f9fe6 upstream.
The stack object “r1” has a total size of 32 bytes. Its field “event” and “val” both contain 4 bytes padding. These 8 bytes padding bytes are sent to user without being initialized.
--- sound/core/timer.c | 1 + 1 file changed, 1 insertion(+)
sound/core/timer.c +1 -0
@@ -1251,6 +1251,7 @@ static void snd_timer_user_ccallback(str tu->tstamp = *tstamp;if ((tu->filter & (1 << event)) ==0 || !tu->tread)return ; +memset (&r1,0 ,sizeof (r1)); r1.event = event; r1.tstamp = *tstamp; r1.val = resolution;
PATCH 132/305 powerpc: Fix definition of SIAR and SDAR registers
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Huth <[email protected]>
commit d23fac2b27d94aeb7b65536a50d32bfdc21fe01e upstream.
The SIAR and SDAR registers are available twice, one time as SPRs 780 / 781 (unprivileged, but read-only), and one time as the SPRs 796 / 797 (privileged, but read and write). The Linux kernel code currently uses the unprivileged SPRs - while this is OK for reading, writing to that register of course does not work.
Since the KVM code tries to write to this register, too (see the mtspr in book3s_hv_rmhandlers.S), the contents of this register sometimes get lost for the guests, e.g. during migration of a VM.
To fix this issue, simply switch to the privileged SPR numbers instead.
--- arch/powerpc/include/asm/reg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/reg.h +2 -2
@@ -740,13 +740,13 @@#define SPRN_PMC6 792#define SPRN_PMC7 793#define SPRN_PMC8 794 -#define SPRN_SIAR 780 -#define SPRN_SDAR 781#define SPRN_SIER 784#define SIER_SIPR 0x2000000/* Sampled MSR_PR */ #define SIER_SIHV 0x1000000/* Sampled MSR_HV */ #define SIER_SIAR_VALID 0x0400000/* SIAR contents valid */ #define SIER_SDAR_VALID 0x0200000/* SDAR contents valid */ +#define SPRN_SIAR 796 +#define SPRN_SDAR 797#define SPRN_TACR 888#define SPRN_TCSCR 889#define SPRN_CSIGR 890
PATCH 108/305 Input: uinput - handle compat ioctl for UI_SET_PHYS
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ricky Liang <[email protected]>
commit affa80bd97f7ca282d1faa91667b3ee9e4c590e6 upstream.
When running a 32-bit userspace on a 64-bit kernel, the UI_SET_PHYS ioctl needs to be treated with special care, as it has the pointer size encoded in the command.
--- drivers/input/misc/uinput.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/input/misc/uinput.c +6 -0
@@ -886,9 +886,15 @@ static long uinput_ioctl(struct file *fi }#ifdef CONFIG_COMPAT + +#define UI_SET_PHYS_COMPAT _IOW(UINPUT_IOCTL_BASE, 108, compat_uptr_t) +static long uinput_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { +if (cmd ==UI_SET_PHYS_COMPAT ) + cmd =UI_SET_PHYS ; +return uinput_ioctl_handler (file, cmd, arg,compat_ptr (arg)); }#endif
PATCH 282/305 KVM: PPC: Book3S HV: Pull out TM state save/restore into separate procedures
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Mackerras <[email protected]>
commit f024ee098476a3e620232e4a78cfac505f121245 upstream.
This moves the transactional memory state save and restore sequences out of the guest entry/exit paths into separate procedures. This is so that these sequences can be used in going into and out of nap in a subsequent patch.
The only code changes here are (a) saving and restore LR on the stack, since these new procedures get called with a bl instruction,
(b) explicitly saving r1 into the PACA instead of assuming that HSTATE_HOST_R1(r13) is already set, and (c) removing an unnecessary and redundant setting of MSR[TM] that should have been removed by commit 9d4d0bdd9e0a ("KVM: PPC: Book3S HV: Add transactional memory support", 2013-09-24) but wasn't.
--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 449 +++++++++++++++++--------------- 1 file changed, 237 insertions(+), 212 deletions(-)
arch/powerpc/kvm/book3s_hv_rmhandlers.S +237 -212
@@ -628,112 +628,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) #ifdef CONFIG_PPC_TRANSACTIONAL_MEM BEGIN_FTR_SECTION - b skip_tm -END_FTR_SECTION_IFCLR(CPU_FTR_TM) - - /* Turn on TM/FP/VSX/VMX so we can restore them. */ - mfmsr r5 - li r6, MSR_TM >> 32 - sldi r6, r6, 32 - or r5, r5, r6 - ori r5, r5, MSR_FP - oris r5, r5, (MSR_VEC | MSR_VSX)@h - mtmsrd r5 - - /* - * The user may change these outside of a transaction, so they must - * always be context switched. - */ - ld r5, VCPU_TFHAR(r4) - ld r6, VCPU_TFIAR(r4) - ld r7, VCPU_TEXASR(r4) - mtspr SPRN_TFHAR, r5 - mtspr SPRN_TFIAR, r6 - mtspr SPRN_TEXASR, r7 - - ld r5, VCPU_MSR(r4) - rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 - beq skip_tm /* TM not active in guest */ - - /* Make sure the failure summary is set, otherwise we'll program check - * when we trechkpt. It's possible that this might have been not set - * on a kvmppc_set_one_reg() call but we shouldn't let this crash the - * host. - */ - oris r7, r7, (TEXASR_FS)@h - mtspr SPRN_TEXASR, r7 - - /* - * We need to load up the checkpointed state for the guest. - * We need to do this early as it will blow away any GPRs, VSRs and - * some SPRs. - */ - - mr r31, r4 - addi r3, r31, VCPU_FPRS_TM - bl .load_fp_state - addi r3, r31, VCPU_VRS_TM - bl .load_vr_state - mr r4, r31 - lwz r7, VCPU_VRSAVE_TM(r4) - mtspr SPRN_VRSAVE, r7 - - ld r5, VCPU_LR_TM(r4) - lwz r6, VCPU_CR_TM(r4) - ld r7, VCPU_CTR_TM(r4) - ld r8, VCPU_AMR_TM(r4) - ld r9, VCPU_TAR_TM(r4) - mtlr r5 - mtcr r6 - mtctr r7 - mtspr SPRN_AMR, r8 - mtspr SPRN_TAR, r9 - - /* - * Load up PPR and DSCR values but don't put them in the actual SPRs - * till the last moment to avoid running with userspace PPR and DSCR for - * too long. - */ - ld r29, VCPU_DSCR_TM(r4) - ld r30, VCPU_PPR_TM(r4) - - std r2, PACATMSCRATCH(r13) /* Save TOC */ - - /* Clear the MSR RI since r1, r13 are all going to be foobar. */ - li r5, 0 - mtmsrd r5, 1 - - /* Load GPRs r0-r28 */ - reg = 0 - .rept 29 - ld reg, VCPU_GPRS_TM(reg)(r31) - reg = reg + 1 - .endr - - mtspr SPRN_DSCR, r29 - mtspr SPRN_PPR, r30 - - /* Load final GPRs */ - ld 29, VCPU_GPRS_TM(29)(r31) - ld 30, VCPU_GPRS_TM(30)(r31) - ld 31, VCPU_GPRS_TM(31)(r31) - - /* TM checkpointed state is now setup. All GPRs are now volatile. */ - TRECHKPT - - /* Now let's get back the state we need. */ - HMT_MEDIUM - GET_PACA(r13) - ld r29, HSTATE_DSCR(r13) - mtspr SPRN_DSCR, r29 - ld r4, HSTATE_KVM_VCPU(r13) - ld r1, HSTATE_HOST_R1(r13) - ld r2, PACATMSCRATCH(r13) - - /* Set the MSR RI since we have our registers back. */ - li r5, MSR_RI - mtmsrd r5, 1 -skip_tm: + bl kvmppc_restore_tm +END_FTR_SECTION_IFSET(CPU_FTR_TM) #endif /* Load guest PMU registers */
@@ -824,12 +720,6 @@ BEGIN_FTR_SECTION /* Skip next section on POWER7 or PPC970 */ b 8f END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) - /* Turn on TM so we can access TFHAR/TFIAR/TEXASR */ - mfmsr r8 - li r0, 1 - rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG - mtmsrd r8 - /* Load up POWER8-specific registers */ ld r5, VCPU_IAMR(r4) lwz r6, VCPU_PSPB(r4)
@@ -1350,106 +1240,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) #ifdef CONFIG_PPC_TRANSACTIONAL_MEM BEGIN_FTR_SECTION - b 2f -END_FTR_SECTION_IFCLR(CPU_FTR_TM) - /* Turn on TM. */ - mfmsr r8 - li r0, 1 - rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG - mtmsrd r8 - - ld r5, VCPU_MSR(r9) - rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 - beq 1f /* TM not active in guest. */ - - li r3, TM_CAUSE_KVM_RESCHED - - /* Clear the MSR RI since r1, r13 are all going to be foobar. */ - li r5, 0 - mtmsrd r5, 1 - - /* All GPRs are volatile at this point. */ - TRECLAIM(R3) - - /* Temporarily store r13 and r9 so we have some regs to play with */ - SET_SCRATCH0(r13) - GET_PACA(r13) - std r9, PACATMSCRATCH(r13) - ld r9, HSTATE_KVM_VCPU(r13) - - /* Get a few more GPRs free. */ - std r29, VCPU_GPRS_TM(29)(r9) - std r30, VCPU_GPRS_TM(30)(r9) - std r31, VCPU_GPRS_TM(31)(r9) - - /* Save away PPR and DSCR soon so don't run with user values. */ - mfspr r31, SPRN_PPR - HMT_MEDIUM - mfspr r30, SPRN_DSCR - ld r29, HSTATE_DSCR(r13) - mtspr SPRN_DSCR, r29 - - /* Save all but r9, r13 & r29-r31 */ - reg = 0 - .rept 29 - .if (reg != 9) && (reg != 13) - std reg, VCPU_GPRS_TM(reg)(r9) - .endif - reg = reg + 1 - .endr - /* ... now save r13 */ - GET_SCRATCH0(r4) - std r4, VCPU_GPRS_TM(13)(r9) - /* ... and save r9 */ - ld r4, PACATMSCRATCH(r13) - std r4, VCPU_GPRS_TM(9)(r9) - - /* Reload stack pointer and TOC. */ - ld r1, HSTATE_HOST_R1(r13) - ld r2, PACATOC(r13) - - /* Set MSR RI now we have r1 and r13 back. */ - li r5, MSR_RI - mtmsrd r5, 1 - - /* Save away checkpinted SPRs. */ - std r31, VCPU_PPR_TM(r9) - std r30, VCPU_DSCR_TM(r9) - mflr r5 - mfcr r6 - mfctr r7 - mfspr r8, SPRN_AMR - mfspr r10, SPRN_TAR - std r5, VCPU_LR_TM(r9) - stw r6, VCPU_CR_TM(r9) - std r7, VCPU_CTR_TM(r9) - std r8, VCPU_AMR_TM(r9) - std r10, VCPU_TAR_TM(r9) - - /* Restore r12 as trap number. */ - lwz r12, VCPU_TRAP(r9) - - /* Save FP/VSX. */ - addi r3, r9, VCPU_FPRS_TM - bl .store_fp_state - addi r3, r9, VCPU_VRS_TM - bl .store_vr_state - mfspr r6, SPRN_VRSAVE - stw r6, VCPU_VRSAVE_TM(r9) -1: - /* - * We need to save these SPRs after the treclaim so that the software - * error code is recorded correctly in the TEXASR. Also the user may - * change these outside of a transaction, so they must always be - * context switched. - */ - mfspr r5, SPRN_TFHAR - mfspr r6, SPRN_TFIAR - mfspr r7, SPRN_TEXASR - std r5, VCPU_TFHAR(r9) - std r6, VCPU_TFIAR(r9) - std r7, VCPU_TEXASR(r9) -2: + bl kvmppc_save_tm +END_FTR_SECTION_IFSET(CPU_FTR_TM) #endif /* Increment yield count if they have a VPA */
@@ -2471,6 +2263,239 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) mr r4,r31 blr +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +/* + * Save transactional state and TM-related registers. + * Called with r9 pointing to the vcpu struct. + * This can modify all checkpointed registers, but + * restores r1, r2 and r9 (vcpu pointer) before exit. + */ +kvmppc_save_tm: + mflr r0 + std r0, PPC_LR_STKOFF(r1) + + /* Turn on TM. */ + mfmsr r8 + li r0, 1 + rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG + mtmsrd r8 + + ld r5, VCPU_MSR(r9) + rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 + beq 1f /* TM not active in guest. */ + + std r1, HSTATE_HOST_R1(r13) + li r3, TM_CAUSE_KVM_RESCHED + + /* Clear the MSR RI since r1, r13 are all going to be foobar. */ + li r5, 0 + mtmsrd r5, 1 + + /* All GPRs are volatile at this point. */ + TRECLAIM(R3) + + /* Temporarily store r13 and r9 so we have some regs to play with */ + SET_SCRATCH0(r13) + GET_PACA(r13) + std r9, PACATMSCRATCH(r13) + ld r9, HSTATE_KVM_VCPU(r13) + + /* Get a few more GPRs free. */ + std r29, VCPU_GPRS_TM(29)(r9) + std r30, VCPU_GPRS_TM(30)(r9) + std r31, VCPU_GPRS_TM(31)(r9) + + /* Save away PPR and DSCR soon so don't run with user values. */ + mfspr r31, SPRN_PPR + HMT_MEDIUM + mfspr r30, SPRN_DSCR + ld r29, HSTATE_DSCR(r13) + mtspr SPRN_DSCR, r29 + + /* Save all but r9, r13 & r29-r31 */ + reg = 0 + .rept 29 + .if (reg != 9) && (reg != 13) + std reg, VCPU_GPRS_TM(reg)(r9) + .endif + reg = reg + 1 + .endr + /* ... now save r13 */ + GET_SCRATCH0(r4) + std r4, VCPU_GPRS_TM(13)(r9) + /* ... and save r9 */ + ld r4, PACATMSCRATCH(r13) + std r4, VCPU_GPRS_TM(9)(r9) + + /* Reload stack pointer and TOC. */ + ld r1, HSTATE_HOST_R1(r13) + ld r2, PACATOC(r13) + + /* Set MSR RI now we have r1 and r13 back. */ + li r5, MSR_RI + mtmsrd r5, 1 + + /* Save away checkpinted SPRs. */ + std r31, VCPU_PPR_TM(r9) + std r30, VCPU_DSCR_TM(r9) + mflr r5 + mfcr r6 + mfctr r7 + mfspr r8, SPRN_AMR + mfspr r10, SPRN_TAR + std r5, VCPU_LR_TM(r9) + stw r6, VCPU_CR_TM(r9) + std r7, VCPU_CTR_TM(r9) + std r8, VCPU_AMR_TM(r9) + std r10, VCPU_TAR_TM(r9) + + /* Restore r12 as trap number. */ + lwz r12, VCPU_TRAP(r9) + + /* Save FP/VSX. */ + addi r3, r9, VCPU_FPRS_TM + bl .store_fp_state + addi r3, r9, VCPU_VRS_TM + bl .store_vr_state + mfspr r6, SPRN_VRSAVE + stw r6, VCPU_VRSAVE_TM(r9) +1: + /* + * We need to save these SPRs after the treclaim so that the software + * error code is recorded correctly in the TEXASR. Also the user may + * change these outside of a transaction, so they must always be + * context switched. + */ + mfspr r5, SPRN_TFHAR + mfspr r6, SPRN_TFIAR + mfspr r7, SPRN_TEXASR + std r5, VCPU_TFHAR(r9) + std r6, VCPU_TFIAR(r9) + std r7, VCPU_TEXASR(r9) + + ld r0, PPC_LR_STKOFF(r1) + mtlr r0 + blr + +/* + * Restore transactional state and TM-related registers. + * Called with r4 pointing to the vcpu struct. + * This potentially modifies all checkpointed registers. + * It restores r1, r2, r4 from the PACA. + */ +kvmppc_restore_tm: + mflr r0 + std r0, PPC_LR_STKOFF(r1) + + /* Turn on TM/FP/VSX/VMX so we can restore them. */ + mfmsr r5 + li r6, MSR_TM >> 32 + sldi r6, r6, 32 + or r5, r5, r6 + ori r5, r5, MSR_FP + oris r5, r5, (MSR_VEC | MSR_VSX)@h + mtmsrd r5 + + /* + * The user may change these outside of a transaction, so they must + * always be context switched. + */ + ld r5, VCPU_TFHAR(r4) + ld r6, VCPU_TFIAR(r4) + ld r7, VCPU_TEXASR(r4) + mtspr SPRN_TFHAR, r5 + mtspr SPRN_TFIAR, r6 + mtspr SPRN_TEXASR, r7 + + ld r5, VCPU_MSR(r4) + rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 + beqlr /* TM not active in guest */ + std r1, HSTATE_HOST_R1(r13) + + /* Make sure the failure summary is set, otherwise we'll program check + * when we trechkpt. It's possible that this might have been not set + * on a kvmppc_set_one_reg() call but we shouldn't let this crash the + * host. + */ + oris r7, r7, (TEXASR_FS)@h + mtspr SPRN_TEXASR, r7 + + /* + * We need to load up the checkpointed state for the guest. + * We need to do this early as it will blow away any GPRs, VSRs and + * some SPRs. + */ + + mr r31, r4 + addi r3, r31, VCPU_FPRS_TM + bl .load_fp_state + addi r3, r31, VCPU_VRS_TM + bl .load_vr_state + mr r4, r31 + lwz r7, VCPU_VRSAVE_TM(r4) + mtspr SPRN_VRSAVE, r7 + + ld r5, VCPU_LR_TM(r4) + lwz r6, VCPU_CR_TM(r4) + ld r7, VCPU_CTR_TM(r4) + ld r8, VCPU_AMR_TM(r4) + ld r9, VCPU_TAR_TM(r4) + mtlr r5 + mtcr r6 + mtctr r7 + mtspr SPRN_AMR, r8 + mtspr SPRN_TAR, r9 + + /* + * Load up PPR and DSCR values but don't put them in the actual SPRs + * till the last moment to avoid running with userspace PPR and DSCR for + * too long. + */ + ld r29, VCPU_DSCR_TM(r4) + ld r30, VCPU_PPR_TM(r4) + + std r2, PACATMSCRATCH(r13) /* Save TOC */ + + /* Clear the MSR RI since r1, r13 are all going to be foobar. */ + li r5, 0 + mtmsrd r5, 1 + + /* Load GPRs r0-r28 */ + reg = 0 + .rept 29 + ld reg, VCPU_GPRS_TM(reg)(r31) + reg = reg + 1 + .endr + + mtspr SPRN_DSCR, r29 + mtspr SPRN_PPR, r30 + + /* Load final GPRs */ + ld 29, VCPU_GPRS_TM(29)(r31) + ld 30, VCPU_GPRS_TM(30)(r31) + ld 31, VCPU_GPRS_TM(31)(r31) + + /* TM checkpointed state is now setup. All GPRs are now volatile. */ + TRECHKPT + + /* Now let's get back the state we need. */ + HMT_MEDIUM + GET_PACA(r13) + ld r29, HSTATE_DSCR(r13) + mtspr SPRN_DSCR, r29 + ld r4, HSTATE_KVM_VCPU(r13) + ld r1, HSTATE_HOST_R1(r13) + ld r2, PACATMSCRATCH(r13) + + /* Set the MSR RI since we have our registers back. */ + li r5, MSR_RI + mtmsrd r5, 1 + + ld r0, PPC_LR_STKOFF(r1) + mtlr r0 + blr +#endif + /* * We come here if we get any exception or interrupt while we are * executing host real mode code while in guest MMU context.
PATCH 232/305 iio:ad7266: Fix broken regulator error handling
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 6b7f4e25f3309f106a5c7ff42c8231494cf285d3 upstream.
All regulator_get() variants return either a pointer to a regulator or an ERR_PTR() so testing for NULL makes no sense and may lead to bugs if we use NULL as a valid regulator. Fix this by using IS_ERR() as expected.
--- drivers/iio/adc/ad7266.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7266.c +1 -1
@@ -397,7 +397,7 @@ static int ad7266_probe(struct spi_devic st =iio_priv (indio_dev); st->reg =devm_regulator_get (&spi->dev,"vref" ); -if (!IS_ERR_OR_NULL (st->reg)) { +if (!IS_ERR (st->reg)) { ret =regulator_enable (st->reg);if (ret)return ret;
PATCH 101/305 batman-adv: Fix integer overflow in batadv_iv_ogm_calc_tq
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit d285f52cc0f23564fd61976d43fd5b991b4828f6 upstream.
The undefined behavior sanatizer detected an signed integer overflow in a setup with near perfect link quality
UBSAN: Undefined behaviour in net/batman-adv/bat_iv_ogm.c:1246:25
signed integer overflow:
8713350 * 255 cannot be represented in type 'int'The problems happens because the calculation of mixed unsigned and signed integers resulted in an integer multiplication.
batadv_ogm_packet::tq (u8 255)
* tq_own (u8 255)
* tq_asym_penalty (int 134; max 255)
* tq_iface_penalty (int 255; max 255)
The tq_iface_penalty, tq_asym_penalty and inv_asym_penalty can just be changed to unsigned int because they are not expected to become negative.
--- net/batman-adv/bat_iv_ogm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/batman-adv/bat_iv_ogm.c +3 -2
@@ -1134,9 +1134,10 @@ static int batadv_iv_ogm_calc_tq(structuint8_t total_count;uint8_t orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; -int tq_asym_penalty, inv_asym_penalty, if_num, ret =0 ; +int if_num, ret =0 ; +unsigned int tq_asym_penalty, inv_asym_penalty;unsigned int combined_tq; -int tq_iface_penalty; +unsigned int tq_iface_penalty;/* find corresponding one hop neighbor */ rcu_read_lock ();
PATCH 280/305 tipc: fix an infoleak in tipc_nl_compat_link_dump
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kangjie Lu <[email protected]>
commit 5d2be1422e02ccd697ccfcd45c85b4a26e6178e2 upstream.
link_info.str is a char array of size 60. Memory after the NULL byte is not initialized. Sending the whole object out can cause a leak.
[carnil: Backported to 3.16 (same as bwh did for 3.2): the unpadded strcpy() is in tipc_node_get_links() and no nlattr is involved, so use strncpy()]
---
net/tipc/node.c +2 -1
@@ -417,7 +417,8 @@ struct sk_buff *tipc_node_get_links(conscontinue ; link_info.dest =htonl (n_ptr->addr); link_info.up =htonl (tipc_link_is_up (n_ptr->links[i])); -strcpy (link_info.str, n_ptr->links[i]->name); +strncpy (link_info.str, n_ptr->links[i]->name, +sizeof (link_info.str));tipc_cfg_append_tlv (buf,TIPC_TLV_LINK_INFO , &link_info,sizeof (link_info)); }
PATCH 300/305 netfilter: ip6_tables: simplify translate_compat_table args
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 329a0807124f12fe1c8032f95d8a8eb47047fb0e upstream.
---
net/ipv6/netfilter/ip6_tables.c +25 -36
@@ -1457,7 +1457,6 @@ compat_copy_entry_to_user(struct ip6t_enstatic int compat_find_calc_match (struct xt_entry_match *m, -const char *name,const struct ip6t_ip6 *ipv6,unsigned int hookmask,int *size)
@@ -1495,8 +1494,7 @@ check_compat_entry_size_and_hooks(structconst unsigned char *base, const unsigned char *limit, const unsigned int *hook_entries, - const unsigned int *underflows, - const char *name) + const unsigned int *underflows) { struct xt_entry_match *ematch;struct xt_entry_target *t;
@@ -1532,8 +1530,8 @@ check_compat_entry_size_and_hooks(struct entry_offset = (void *)e - (void *)base; j =0 ; xt_ematch_foreach(ematch, e) { - ret =compat_find_calc_match (ematch, name, - &e->ipv6, e->comefrom, &off); + ret =compat_find_calc_match (ematch, &e->ipv6, e->comefrom, + &off);if (ret !=0 ) goto release_matches; ++j;
@@ -1582,7 +1580,7 @@ release_matches:static int compat_copy_entry_from_user (struct compat_ip6t_entry *e,void **dstptr, -unsigned int *size,const char *name, +unsigned int *size,struct xt_table_info *newinfo,unsigned char *base) {struct xt_entry_target *t;
@@ -1656,14 +1654,9 @@ static int compat_check_entry(struct ip6static int translate_compat_table (struct net *net, -const char *name, -unsigned int valid_hooks,struct xt_table_info **pinfo,void **pentry0, -unsigned int total_size, -unsigned int number, -unsigned int *hook_entries, -unsigned int *underflows) +const struct compat_ip6t_replace *compatr) {unsigned int i, j;struct xt_table_info *newinfo, *info;
@@ -1675,8 +1668,8 @@ translate_compat_table(struct net *net, info = *pinfo; entry0 = *pentry0; - size = total_size; - info->number = number; + size = compatr->size; + info->number = compatr->num_entries;/* Init all hooks to impossible value. */ for (i =0 ; i <NF_INET_NUMHOOKS ; i++) {
@@ -1687,40 +1680,39 @@ translate_compat_table(struct net *net,duprintf ("translate_compat_table: size %u\n" , info->size); j =0 ;xt_compat_lock (AF_INET6 ); -xt_compat_init_offsets (AF_INET6 , number); +xt_compat_init_offsets (AF_INET6 , compatr->num_entries);/* Walk through entries, checking offsets. */ - xt_entry_foreach(iter0, entry0, total_size) { + xt_entry_foreach(iter0, entry0, compatr->size) { ret =check_compat_entry_size_and_hooks (iter0, info, &size, entry0, - entry0 + total_size, - hook_entries, - underflows, - name); + entry0 + compatr->size, + compatr->hook_entry, + compatr->underflow);if (ret !=0 ) goto out_unlock; ++j; } ret = -EINVAL ; -if (j != number) { +if (j != compatr->num_entries) {duprintf ("translate_compat_table: %u not %u entries\n" , - j, number); + j, compatr->num_entries); goto out_unlock; }/* Check hooks all assigned */ for (i =0 ; i <NF_INET_NUMHOOKS ; i++) {/* Only hooks which are valid */ -if (!(valid_hooks & (1 << i))) +if (!(compatr->valid_hooks & (1 << i)))continue ;if (info->hook_entry[i] ==0xFFFFFFFF ) {duprintf ("Invalid hook entry %u %u\n" , - i, hook_entries[i]); + i, info->hook_entry[i]); goto out_unlock; }if (info->underflow[i] ==0xFFFFFFFF ) {duprintf ("Invalid underflow %u %u\n" , - i, underflows[i]); + i, info->underflow[i]); goto out_unlock; } }
@@ -1730,17 +1722,17 @@ translate_compat_table(struct net *net,if (!newinfo) goto out_unlock; - newinfo->number = number; + newinfo->number = compatr->num_entries;for (i =0 ; i <NF_INET_NUMHOOKS ; i++) { newinfo->hook_entry[i] = info->hook_entry[i]; newinfo->underflow[i] = info->underflow[i]; } entry1 = newinfo->entries[raw_smp_processor_id ()]; pos = entry1; - size = total_size; - xt_entry_foreach(iter0, entry0, total_size) { + size = compatr->size; + xt_entry_foreach(iter0, entry0, compatr->size) { ret =compat_copy_entry_from_user (iter0, &pos, &size, - name, newinfo, entry1); + newinfo, entry1);if (ret !=0 )break ; }
@@ -1750,12 +1742,12 @@ translate_compat_table(struct net *net, goto free_newinfo; ret = -ELOOP ; -if (!mark_source_chains (newinfo, valid_hooks, entry1)) +if (!mark_source_chains (newinfo, compatr->valid_hooks, entry1)) goto free_newinfo; i =0 ; xt_entry_foreach(iter1, entry1, newinfo->size) { - ret =compat_check_entry (iter1, net, name); + ret =compat_check_entry (iter1, net, compatr->name);if (ret !=0 )break ; ++i;
@@ -1800,7 +1792,7 @@ translate_compat_table(struct net *net, free_newinfo:xt_free_table_info (newinfo); out: - xt_entry_foreach(iter0, entry0, total_size) { + xt_entry_foreach(iter0, entry0, compatr->size) {if (j-- ==0 )break ;compat_release_entry (iter0);
@@ -1843,10 +1835,7 @@ compat_do_replace(struct net *net, void goto free_newinfo; } - ret =translate_compat_table (net, tmp.name, tmp.valid_hooks, - &newinfo, &loc_cpu_entry, tmp.size, - tmp.num_entries, tmp.hook_entry, - tmp.underflow); + ret =translate_compat_table (net, &newinfo, &loc_cpu_entry, &tmp);if (ret !=0 ) goto free_newinfo;
PATCH 203/305 can: at91_can: RX queue could get stuck at high bus load
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wolfgang Grandegger <[email protected]>
commit 43200a4480cbbe660309621817f54cbb93907108 upstream.
At high bus load it could happen that "at91_poll()" enters with all RX message boxes filled up. If then at the end the "quota" is exceeded as well, "rx_next" will not be reset to the first RX mailbox and hence the interrupts remain disabled.
--- drivers/net/can/at91_can.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/can/at91_can.c +3 -2
@@ -734,9 +734,10 @@ static int at91_poll_rx(struct net_devic/* upper group completed, look again in lower */ if (priv->rx_next >get_mb_rx_low_last (priv) && - quota >0 && mb >get_mb_rx_last (priv)) { + mb >get_mb_rx_last (priv)) { priv->rx_next =get_mb_rx_first (priv); - goto again; +if (quota >0 ) + goto again; }return received;
PATCH 82/305 i40e: fix an uninitialized variable bug
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 1c306f7f62a38ee5f05f0ee994dfe82d654cf47c upstream.
We removed this initialization but it is required. Let's put it back.
--- drivers/net/ethernet/intel/i40e/i40e_hmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_hmc.c +1 -1
@@ -49,7 +49,7 @@ i40e_status i40e_add_sd_table_entry(strustruct i40e_hmc_sd_entry *sd_entry;bool dma_mem_alloc_done = false;struct i40e_dma_mem mem; -i40e_status ret_code; +i40e_status ret_code =I40E_SUCCESS ;u64 alloc_len;if (NULL == hmc_info->sd_table.sd_entry) {
PATCH 22/305 powerpc/book3s64: Fix branching to OOL handlers in relocatable kernel
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hari Bathini <[email protected]>
commit 8ed8ab40047a570fdd8043a40c104a57248dd3fd upstream.
Some of the interrupt vectors on 64-bit POWER server processors are only 32 bytes long (8 instructions), which is not enough for the full first-level interrupt handler. For these we need to branch to an out-of-line (OOL) handler. But when we are running a relocatable kernel, interrupt vectors till __end_interrupts marker are copied down to real address 0x100. So, branching to labels (ie. OOL handlers) outside this section must be handled differently (see LOAD_HANDLER()), considering relocatable kernel, which would need at least 4 instructions.
However, branching from interrupt vector means that we corrupt the CFAR (come-from address register) on POWER7 and later processors as mentioned in commit 1707dd16. So, EXCEPTION_PROLOG_0 (6 instructions) that contains the part up to the point where the CFAR is saved in the PACA should be part of the short interrupt vectors before we branch out to OOL handlers.
But as mentioned already, there are interrupt vectors on 64-bit POWER server processors that are only 32 bytes long (like vectors 0x4f00, 0x4f20, etc.), which cannot accomodate the above two cases at the same time owing to space constraint. Currently, in these interrupt vectors, we simply branch out to OOL handlers, without using LOAD_HANDLER(), which leaves us vulnerable when running a relocatable kernel (eg. kdump case). While this has been the case for sometime now and kdump is used widely, we were fortunate not to see any problems so far, for three reasons:
1. In almost all cases, production kernel (relocatable) is used for kdump as well, which would mean that crashed kernel's OOL handler would be at the same place where we end up branching to, from short interrupt vector of kdump kernel.
2. Also, OOL handler was unlikely the reason for crash in almost all the kdump scenarios, which meant we had a sane OOL handler from crashed kernel that we branched to.
3. On most 64-bit POWER server processors, page size is large enough that marking interrupt vector code as executable (see commit 429d2e83) leads to marking OOL handler code from crashed kernel, that sits right below interrupt vector code from kdump kernel, as executable as well.
Let us fix this by moving the __end_interrupts marker down past OOL handlers to make sure that we also copy OOL handlers to real address 0x100 when running a relocatable kernel.
This fix has been tested successfully in kdump scenario, on an LPAR with 4K page size by using different default/production kernel and kdump kernel.
Also tested by manually corrupting the OOL handlers in the first kernel and then kdump'ing, and then causing the OOL handlers to fire - mpe.
--- arch/powerpc/kernel/exceptions-64s.S | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
arch/powerpc/kernel/exceptions-64s.S +11 -5
@@ -965,11 +965,6 @@ hv_facility_unavailable_relon_trampoline #endif STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist) - /* Other future vectors */ - .align 7 - .globl __end_interrupts -__end_interrupts: - .align 7 system_call_entry_direct: #if defined(CONFIG_RELOCATABLE)
@@ -1323,6 +1318,17 @@ __end_handlers: STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable) STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable) + /* + * The __end_interrupts marker must be past the out-of-line (OOL) + * handlers, so that they are copied to real address 0x100 when running + * a relocatable kernel. This ensures they can be reached from the short + * trampoline handlers (like 0x4f00, 0x4f20, etc.) which branch + * directly, without using LOAD_HANDLER(). + */ + .align 7 + .globl __end_interrupts +__end_interrupts: + #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) /* * Data area reserved for FWNMI option.
PATCH 268/305 xenbus: don't BUG() on user mode induced condition
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
commit 0beef634b86a1350c31da5fcc2992f0d7c8a622b upstream.
Inability to locate a user mode specified transaction ID should not lead to a kernel crash. For other than XS_TRANSACTION_START also don't issue anything to xenbus if the specified ID doesn't match that of any active transaction.
--- drivers/xen/xenbus/xenbus_dev_frontend.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/xen/xenbus/xenbus_dev_frontend.c +8 -6
@@ -316,11 +316,18 @@ static int xenbus_write_transaction(unsi rc = -ENOMEM ; goto out; } + }else { +list_for_each_entry (trans, &u->transactions, list) +if (trans->handle.id == u->u.msg.tx_id) +break ; +if (&trans->list == &u->transactions) +return -ESRCH ; } reply =xenbus_dev_request_and_reply (&u->u.msg);if (IS_ERR (reply)) { -kfree (trans); +if (msg_type ==XS_TRANSACTION_START ) +kfree (trans); rc =PTR_ERR (reply); goto out; }
@@ -330,12 +337,7 @@ static int xenbus_write_transaction(unsilist_add (&trans->list, &u->transactions); }else if (msg_type ==XS_TRANSACTION_END ) { -list_for_each_entry (trans, &u->transactions, list) -if (trans->handle.id == u->u.msg.tx_id) -break ; -BUG_ON (&trans->list == &u->transactions);list_del (&trans->list); -kfree (trans); }
PATCH 4/305 serial: doc: Un-document non-existing uart_write_console()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit 834392a7d92677ff2bdc1c709b1171ee585b55c9 upstream.
uart_write_console() never existed, not even when the "new uart_write_console function" was documented.
--- Documentation/serial/driver | 5 ----- 1 file changed, 5 deletions(-)
Documentation/serial/driver +0 -5
@@ -28,11 +28,6 @@ The serial core provides a few helper fu the correct port structure (via uart_get_console) and decoding command line arguments (uart_parse_options). -There is also a helper function (uart_write_console) which performs a -character by character write, translating newlines to CRLF sequences. -Driver writers are recommended to use this function rather than implementing -their own version. - Locking -------
PATCH 242/305 s390: fix test_fp_ctl inline assembly contraints
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Martin Schwidefsky <[email protected]>
commit bcf4dd5f9ee096bd1510f838dd4750c35df4e38b upstream.
The test_fp_ctl function is used to test if a given value is a valid floating-point control. The inline assembly in test_fp_ctl uses an incorrect constraint for the 'orig_fpc' variable. If the compiler chooses the same register for 'fpc' and 'orig_fpc' the test_fp_ctl() function always returns true. This allows user space to trigger kernel oopses with invalid floating-point control values on the signal stack.
This problem has been introduced with git commit 4725c86055f5bbdcdf "s390: fix save and restore of the floating-point-control register"
--- arch/s390/include/asm/switch_to.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/include/asm/switch_to.h +1 -1
@@ -28,7 +28,7 @@ static inline int test_fp_ctl(u32 fpc)" la %0,0\n" "1:\n" EX_TABLE (0b ,1b ) - : "=d" (rc), "=d" (orig_fpc) + : "=d" (rc), "=&d" (orig_fpc) : "d" (fpc), "0" (-EINVAL)); return rc; }
PATCH 49/305 arm64: Ensure pmd_present() returns false after pmd_mknotpresent()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit 5bb1cc0ff9a6b68871970737e6c4c16919928d8b upstream.
Currently, pmd_present() only checks for a non-zero value, returning true even after pmd_mknotpresent() (which only clears the type bits). This patch converts pmd_present() to using pte_present(), similar to the other pmd_*() checks. As a side effect, it will return true for PROT_NONE mappings, though they are not yet used by the kernel with transparent huge pages.
For consistency, also change pmd_mknotpresent() to only clear the PMD_SECT_VALID bit, even though the PMD_TABLE_BIT is already 0 for block mappings (no functional change). The unused PMD_SECT_PROT_NONE definition is removed as transparent huge pages use the pte page prot values.
--- arch/arm64/include/asm/pgtable-hwdef.h | 1 - arch/arm64/include/asm/pgtable.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
arch/arm64/include/asm/pgtable-hwdef.h +0 -1
@@ -45,7 +45,6 @@* Section */ #define PMD_SECT_VALID (_AT(pmdval_t, 1) << 0) -#define PMD_SECT_PROT_NONE (_AT(pmdval_t, 1) << 58)#define PMD_SECT_USER (_AT(pmdval_t, 1) << 6)/* AP[1] */ #define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)/* AP[2] */ #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
arch/arm64/include/asm/pgtable.h +2 -2
@@ -250,6 +250,7 @@ static inline pmd_t pte_pmd(pte_t pte)#define pmd_trans_splitting (pmd) pte_special(pmd_pte(pmd))#endif +#define pmd_present (pmd) pte_present(pmd_pte(pmd))#define pmd_young (pmd) pte_young(pmd_pte(pmd))#define pmd_wrprotect (pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd)))#define pmd_mksplitting (pmd) pte_pmd(pte_mkspecial(pmd_pte(pmd)))
@@ -257,7 +258,7 @@ static inline pmd_t pte_pmd(pte_t pte)#define pmd_mkwrite (pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd)))#define pmd_mkdirty (pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))#define pmd_mkyoung (pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd))) -#define pmd_mknotpresent (pmd) (__pmd(pmd_val(pmd) & ~PMD_TYPE_MASK)) +#define pmd_mknotpresent (pmd) (__pmd(pmd_val(pmd) & ~PMD_SECT_VALID))#define __HAVE_ARCH_PMD_WRITE#define pmd_write (pmd) pte_write(pmd_pte(pmd))
@@ -294,7 +295,6 @@ extern pgprot_t phys_mem_access_prot(str unsigned long size, pgprot_t vma_prot);#define pmd_none (pmd) (!pmd_val(pmd)) -#define pmd_present (pmd) (pmd_val(pmd))#define pmd_bad (pmd) (!(pmd_val(pmd) & 2))
PATCH 166/305 iio:st_pressure: fix sampling gains (bring inline with ABI)
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gregor Boirie <[email protected]>
commit d43a41152f8e9e4c0d19850884d1fada076dee10 upstream.
Temperature channels report scaled samples in Celsius although expected as milli degree Celsius in Documentation/ABI/testing/sysfs-bus-iio. Gains are not implemented at all for LPS001WP pressure and temperature channels.
This patch ensures that proper offsets and scales are exposed to userpace for both pressure and temperature channels.
Also fix a NULL pointer exception when userspace reads content of sysfs scale attribute when gains are not defined.
[bwh: Backported to 3.16:
- Adjust context
- In st_press_read_raw() use pdata instead of press_data]
--- drivers/iio/pressure/st_pressure_core.c | 80 ++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 30 deletions(-)
drivers/iio/pressure/st_pressure_core.c +50 -30
@@ -28,15 +28,21 @@#include <linux/iio/common/st_sensors.h> #include "st_pressure.h" +#define MCELSIUS_PER_CELSIUS 1000 + +/* Default pressure sensitivity */ #define ST_PRESS_LSB_PER_MBAR 4096UL#define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \ ST_PRESS_LSB_PER_MBAR) + +/* Default temperature sensitivity */ #define ST_PRESS_LSB_PER_CELSIUS 480UL -#define ST_PRESS_CELSIUS_NANO_SCALE (1000000000UL / \ - ST_PRESS_LSB_PER_CELSIUS) +#define ST_PRESS_MILLI_CELSIUS_OFFSET 42500UL +#define ST_PRESS_NUMBER_DATA_CHANNELS 1/* FULLSCALE */ +#define ST_PRESS_FS_AVL_1100MB 1100#define ST_PRESS_FS_AVL_1260MB 1260#define ST_PRESS_1_OUT_XL_ADDR 0x28
@@ -54,18 +60,20 @@#define ST_PRESS_LPS331AP_PW_MASK 0x80#define ST_PRESS_LPS331AP_FS_ADDR 0x23#define ST_PRESS_LPS331AP_FS_MASK 0x30 -#define ST_PRESS_LPS331AP_FS_AVL_1260_VAL 0x00 -#define ST_PRESS_LPS331AP_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE -#define ST_PRESS_LPS331AP_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE#define ST_PRESS_LPS331AP_BDU_ADDR 0x20#define ST_PRESS_LPS331AP_BDU_MASK 0x04#define ST_PRESS_LPS331AP_DRDY_IRQ_ADDR 0x22#define ST_PRESS_LPS331AP_DRDY_IRQ_INT1_MASK 0x04#define ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK 0x20#define ST_PRESS_LPS331AP_MULTIREAD_BIT true -#define ST_PRESS_LPS331AP_TEMP_OFFSET 42500/* CUSTOM VALUES FOR LPS001WP SENSOR */ + +/* LPS001WP pressure resolution */ +#define ST_PRESS_LPS001WP_LSB_PER_MBAR 16UL +/* LPS001WP temperature resolution */ +#define ST_PRESS_LPS001WP_LSB_PER_CELSIUS 64UL +#define ST_PRESS_LPS001WP_WAI_EXP 0xba#define ST_PRESS_LPS001WP_ODR_ADDR 0x20#define ST_PRESS_LPS001WP_ODR_MASK 0x30
@@ -74,6 +82,8 @@#define ST_PRESS_LPS001WP_ODR_AVL_13HZ_VAL 0x03#define ST_PRESS_LPS001WP_PW_ADDR 0x20#define ST_PRESS_LPS001WP_PW_MASK 0x40 +#define ST_PRESS_LPS001WP_FS_AVL_PRESS_GAIN \ + (100000000UL / ST_PRESS_LPS001WP_LSB_PER_MBAR)#define ST_PRESS_LPS001WP_BDU_ADDR 0x20#define ST_PRESS_LPS001WP_BDU_MASK 0x04#define ST_PRESS_LPS001WP_MULTIREAD_BIT true
@@ -90,18 +100,12 @@#define ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL 0x04#define ST_PRESS_LPS25H_PW_ADDR 0x20#define ST_PRESS_LPS25H_PW_MASK 0x80 -#define ST_PRESS_LPS25H_FS_ADDR 0x00 -#define ST_PRESS_LPS25H_FS_MASK 0x00 -#define ST_PRESS_LPS25H_FS_AVL_1260_VAL 0x00 -#define ST_PRESS_LPS25H_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE -#define ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE#define ST_PRESS_LPS25H_BDU_ADDR 0x20#define ST_PRESS_LPS25H_BDU_MASK 0x04#define ST_PRESS_LPS25H_DRDY_IRQ_ADDR 0x23#define ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK 0x01#define ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK 0x10#define ST_PRESS_LPS25H_MULTIREAD_BIT true -#define ST_PRESS_LPS25H_TEMP_OFFSET 42500#define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28#define ST_TEMP_LPS25H_OUT_L_ADDR 0x2b
@@ -153,7 +157,9 @@ static const struct iio_chan_spec st_pre .storagebits = 16, .endianness = IIO_LE, }, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), .modified = 0, }, {
@@ -169,7 +175,7 @@ static const struct iio_chan_spec st_pre }, .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) | - BIT(IIO_CHAN_INFO_OFFSET), + BIT(IIO_CHAN_INFO_SCALE), .modified =0 , },IIO_CHAN_SOFT_TIMESTAMP (1 )
@@ -203,11 +209,14 @@ static const struct st_sensors st_press_ .addr = ST_PRESS_LPS331AP_FS_ADDR, .mask = ST_PRESS_LPS331AP_FS_MASK, .fs_avl = { +/* +* Pressure and temperature sensitivity values +* as defined in table 3 of LPS331AP datasheet. + */ [0] = { .num = ST_PRESS_FS_AVL_1260MB, - .value = ST_PRESS_LPS331AP_FS_AVL_1260_VAL, - .gain = ST_PRESS_LPS331AP_FS_AVL_1260_GAIN, - .gain2 = ST_PRESS_LPS331AP_FS_AVL_TEMP_GAIN, + .gain = ST_PRESS_KPASCAL_NANO_SCALE, + .gain2 = ST_PRESS_LSB_PER_CELSIUS, }, }, },
@@ -246,7 +255,17 @@ static const struct st_sensors st_press_ .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, }, .fs = { - .addr = 0, + .fs_avl = { +/* +* Pressure and temperature resolution values +* as defined in table 3 of LPS001WP datasheet. + */ + [0] = { + .num = ST_PRESS_FS_AVL_1100MB, + .gain = ST_PRESS_LPS001WP_FS_AVL_PRESS_GAIN, + .gain2 = ST_PRESS_LPS001WP_LSB_PER_CELSIUS, + }, + }, }, .bdu = { .addr = ST_PRESS_LPS001WP_BDU_ADDR,
@@ -282,14 +301,15 @@ static const struct st_sensors st_press_ .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, }, .fs = { - .addr = ST_PRESS_LPS25H_FS_ADDR, - .mask = ST_PRESS_LPS25H_FS_MASK, .fs_avl = { +/* +* Pressure and temperature sensitivity values +* as defined in table 3 of LPS25H datasheet. + */ [0] = { .num = ST_PRESS_FS_AVL_1260MB, - .value = ST_PRESS_LPS25H_FS_AVL_1260_VAL, - .gain = ST_PRESS_LPS25H_FS_AVL_1260_GAIN, - .gain2 = ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN, + .gain = ST_PRESS_KPASCAL_NANO_SCALE, + .gain2 = ST_PRESS_LSB_PER_CELSIUS, }, }, },
@@ -322,26 +342,26 @@ static int st_press_read_raw(struct iio_return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE : - *val =0 ; -switch (ch->type) {case IIO_PRESSURE : + *val =0 ; *val2 = pdata->current_fullscale->gain; -break ; +return IIO_VAL_INT_PLUS_NANO ;case IIO_TEMP : + *val =MCELSIUS_PER_CELSIUS ; *val2 = pdata->current_fullscale->gain2; -break ; +return IIO_VAL_FRACTIONAL ;default : err = -EINVAL ; goto read_error; } -return IIO_VAL_INT_PLUS_NANO ;case IIO_CHAN_INFO_OFFSET :switch (ch->type) {case IIO_TEMP : - *val =425 ; - *val2 =10 ; + *val =ST_PRESS_MILLI_CELSIUS_OFFSET * + pdata->current_fullscale->gain2; + *val2 =MCELSIUS_PER_CELSIUS ;break ;default : err = -EINVAL ;
PATCH 170/305 usb: gadget: avoid exposing kernel stack
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Heinrich Schuchardt <[email protected]>
commit ffeee83aa0461992e8a99a59db2df31933e60362 upstream.
Function in_rq_cur copies random bytes from the stack. Zero the memory instead.
--- drivers/usb/gadget/f_uac2.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/f_uac2.c +1 -0
@@ -1153,6 +1153,7 @@ in_rq_cur(struct usb_function *fn, constif (control_selector ==UAC2_CS_CONTROL_SAM_FREQ ) {struct cntrl_cur_lay3 c; +memset (&c,0 ,sizeof (struct cntrl_cur_lay3 ));if (entity_id ==USB_IN_CLK_ID ) c.dCUR = p_srate;
PATCH 155/305 cpufreq: intel_pstate: Fix ->set_policy() interface for no_turbo
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit 983e600e88835f0321d1a0ea06f52d48b7b5a544 upstream.
When turbo is disabled, the ->set_policy() interface is broken.
For example, when turbo is disabled and cpuinfo.max = 2900000 (full max turbo frequency), setting the limits results in frequency less than the requested one:
Set 1000000 KHz results in 0700000 KHz
Set 1500000 KHz results in 1100000 KHz
Set 2000000 KHz results in 1500000 KHz
This is because the limits->max_perf fraction is calculated using the max turbo frequency as the reference, but when the max P-State is capped in intel_pstate_get_min_max(), the reference is not the max turbo P-State. This results in reducing max P-State.
One option is to always use max turbo as reference for calculating limits. But this will not be correct. By definition the intel_pstate sysfs limits, shows percentage of available performance. So when BIOS has disabled turbo, the available performance is max non turbo. So the max_perf_pct should still show 100%.
[bwh: Backported to 3.16:
- limits is a perf_limits structure, not a pointer to it
- Adjust context]
--- drivers/cpufreq/intel_pstate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpufreq/intel_pstate.c +5 -2
@@ -877,8 +877,11 @@ static int intel_pstate_cpu_init(struct/* cpuinfo and default policy values */ policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; - policy->cpuinfo.max_freq = - cpu->pstate.turbo_pstate * cpu->pstate.scaling; +update_turbo_state (); + policy->cpuinfo.max_freq = limits.turbo_disabled ? + cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; + policy->cpuinfo.max_freq *= cpu->pstate.scaling; + policy->cpuinfo.transition_latency =CPUFREQ_ETERNAL ;cpumask_set_cpu (policy->cpu, policy->cpus);
PATCH 209/305 mm: Export migrate_page_move_mapping and migrate_page_copy
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 1118dce773d84f39ebd51a9fe7261f9169cb056e upstream.
Export these symbols such that UBIFS can implement ->migratepage.
--- mm/migrate.c | 2 ++ 1 file changed, 2 insertions(+)
mm/migrate.c +2 -0
@@ -443,6 +443,7 @@ int migrate_page_move_mapping(struct addreturn MIGRATEPAGE_SUCCESS ; } +EXPORT_SYMBOL (migrate_page_move_mapping);/* * The expected number of remaining references is the same as that
@@ -591,6 +592,7 @@ void migrate_page_copy(struct page *newpif (PageWriteback (newpage))end_page_writeback (newpage); } +EXPORT_SYMBOL (migrate_page_copy);/************************************************************ * Migration functions
PATCH 240/305 ARC: unwind: ensure that .debug_frame is generated (vs. .eh_frame)
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit f52e126cc7476196f44f3c313b7d9f0699a881fc upstream.
With recent binutils update to support dwarf CFI pseudo-ops in gas, we now get .eh_frame vs. .debug_frame. Although the call frame info is exactly the same in both, the CIE differs, which the current kernel unwinder can't cope with.
This broke both the kernel unwinder as well as loadable modules (latter because of a new unhandled relo R_ARC_32_PCREL from .rela.eh_frame in the module loader)
The ideal solution would be to switch unwinder to .eh_frame. For now however we can make do by just ensureing .debug_frame is generated by removing -fasynchronous-unwind-tables
.eh_frame generated with -gdwarf-2 -fasynchronous-unwind-tables
.debug_frame generated with -gdwarf-2
Fixes STAR 9001058196
--- arch/arc/Makefile | 2 -- 1 file changed, 2 deletions(-)
arch/arc/Makefile +0 -2
@@ -35,8 +35,6 @@ cflags-$(atleast_gcc44) += -fsection-a cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape cflags-$(CONFIG_ARC_HAS_RTSC) += -mrtsc -cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables - # By default gcc 4.8 generates dwarf4 which kernel unwinder can't grok ifeq ($(atleast_gcc48),y) cflags-$(CONFIG_ARC_DW2_UNWIND) += -gdwarf-2
PATCH 188/305 kernel/sysrq, watchdog, sched/core: Reset watchdog on all CPUs while processing sysrq-w
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ryabinin <[email protected]>
commit 57675cb976eff977aefb428e68e4e0236d48a9ff upstream.
Lengthy output of sysrq-w may take a lot of time on slow serial console.
Currently we reset NMI-watchdog on the current CPU to avoid spurious lockup messages. Sometimes this doesn't work since softlockup watchdog might trigger on another CPU which is waiting for an IPI to proceed. We reset softlockup watchdogs on all CPUs, but we do this only after listing all tasks, and this may be too late on a busy system.
So, reset watchdogs CPUs earlier, in for_each_process_thread() loop.
--- kernel/sched/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/sched/core.c +4 -2
@@ -4548,14 +4548,16 @@ void show_state_filter(unsigned long sta/* * reset the NMI-timeout, listing all files on a slow * console might take a lot of time: +* Also, reset softlockup watchdogs on all CPUs, because +* another CPU might be blocked waiting for us to process +* an IPI. */ touch_nmi_watchdog (); +touch_all_softlockup_watchdogs ();if (!state_filter || (p->state & state_filter))sched_show_task (p); }while_each_thread (g, p); -touch_all_softlockup_watchdogs (); -#ifdef CONFIG_SCHED_DEBUG sysrq_sched_debug_show ();#endif
PATCH 69/305 powerpc/mm/hash64: Factor out hash preload psize check
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit 8bbc9b7b001eaab8abf7e9e24edf1bb285c8d825 upstream.
Currently we have a check in hash_preload() against the psize, which is only included when CONFIG_PPC_MM_SLICES is enabled. We want to expand this check in a subsequent patch, so factor it out to allow that. As a bonus it removes the #ifdef in the C code.
Unfortunately we can't put this in the existing CONFIG_PPC_MM_SLICES block because it would require a forward declaration.
--- arch/powerpc/mm/hash_utils_64.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
arch/powerpc/mm/hash_utils_64.c +17 -4
@@ -1196,6 +1196,22 @@ bail: }EXPORT_SYMBOL_GPL (hash_page); +#ifdef CONFIG_PPC_MM_SLICES +static bool should_hash_preload (struct mm_struct *mm,unsigned long ea) +{ +/* We only prefault standard pages for now */ +if (unlikely (get_slice_psize (mm, ea) != mm->context.user_psize)) +return false; + +return true; +} +#else +static bool should_hash_preload (struct mm_struct *mm,unsigned long ea) +{ +return true; +} +#endif +void hash_preload (struct mm_struct *mm,unsigned long ea,unsigned long access,unsigned long trap) {
@@ -1208,11 +1224,8 @@ void hash_preload(struct mm_struct *mm,BUG_ON (REGION_ID (ea) !=USER_REGION_ID ); -#ifdef CONFIG_PPC_MM_SLICES -/* We only prefault standard pages for now */ -if (unlikely (get_slice_psize (mm, ea) != mm->context.user_psize)) +if (!should_hash_preload (mm, ea))return ; -#endif DBG_LOW ("hash_preload(mm=%p, mm->pgdir=%p, ea=%016lx, access=%lx," " trap=%lx\n" , mm, mm->pgd, ea, access, trap);
PATCH 131/305 powerpc/pseries/eeh: Handle RTAS delay requests in configure_bridge
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Russell Currey <[email protected]>
commit 871e178e0f2c4fa788f694721a10b4758d494ce1 upstream.
In the "ibm,configure-pe" and "ibm,configure-bridge" RTAS calls, the spec states that values of 9900-9905 can be returned, indicating that software should delay for 10^x (where x is the last digit, i.e. 990x) milliseconds and attempt the call again. Currently, the kernel doesn't know about this, and respecting it fixes some PCI failures when the hypervisor is busy.
The delay is capped at 0.2 seconds.
--- arch/powerpc/platforms/pseries/eeh_pseries.c | 51 ++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 15 deletions(-)
arch/powerpc/platforms/pseries/eeh_pseries.c +36 -15
@@ -655,29 +655,50 @@ static int pseries_eeh_configure_bridge( {int config_addr;int ret; +/* Waiting 0.2s maximum before skipping configuration */ +int max_wait =200 ;/* Figure out the PE address */ config_addr = pe->config_addr;if (pe->addr) config_addr = pe->addr; -/* Use new configure-pe function, if supported */ -if (ibm_configure_pe !=RTAS_UNKNOWN_SERVICE ) { - ret =rtas_call (ibm_configure_pe,3 ,1 ,NULL , - config_addr,BUID_HI (pe->phb->buid), -BUID_LO (pe->phb->buid)); - }else if (ibm_configure_bridge !=RTAS_UNKNOWN_SERVICE ) { - ret =rtas_call (ibm_configure_bridge,3 ,1 ,NULL , - config_addr,BUID_HI (pe->phb->buid), -BUID_LO (pe->phb->buid)); - }else { -return -EFAULT ; - } +while (max_wait >0 ) { +/* Use new configure-pe function, if supported */ +if (ibm_configure_pe !=RTAS_UNKNOWN_SERVICE ) { + ret =rtas_call (ibm_configure_pe,3 ,1 ,NULL , + config_addr,BUID_HI (pe->phb->buid), +BUID_LO (pe->phb->buid)); + }else if (ibm_configure_bridge !=RTAS_UNKNOWN_SERVICE ) { + ret =rtas_call (ibm_configure_bridge,3 ,1 ,NULL , + config_addr,BUID_HI (pe->phb->buid), +BUID_LO (pe->phb->buid)); + }else { +return -EFAULT ; + } + +if (!ret) +return ret; + +/* +* If RTAS returns a delay value that's above 100ms, cut it +* down to 100ms in case firmware made a mistake. For more +* on how these delay values work see rtas_busy_delay_time +*/ +if (ret >RTAS_EXTENDED_DELAY_MIN +2 && + ret <=RTAS_EXTENDED_DELAY_MAX ) + ret =RTAS_EXTENDED_DELAY_MIN +2 ; -if (ret) -pr_warning ("%s: Unable to configure bridge PHB#%d-PE#%x (%d)\n" , - __func__, pe->phb->global_number, pe->addr, ret); + max_wait -=rtas_busy_delay_time (ret); + +if (max_wait <0 ) +break ; + +rtas_busy_delay (ret); + } +pr_warn ("%s: Unable to configure bridge PHB#%d-PE#%x (%d)\n" , + __func__, pe->phb->global_number, pe->addr, ret);return ret; }
PATCH 298/305 netfilter: arp_tables: simplify translate_compat_table args
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 8dddd32756f6fe8e4e82a63361119b7e2384e02f upstream.
--- net/ipv4/netfilter/arp_tables.c | 82 ++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 46 deletions(-)
net/ipv4/netfilter/arp_tables.c +36 -46
@@ -1205,6 +1205,18 @@ static int do_add_counters(struct net *n }#ifdef CONFIG_COMPAT +struct compat_arpt_replace { +char name[XT_TABLE_MAXNAMELEN ]; +u32 valid_hooks; +u32 num_entries; +u32 size; +u32 hook_entry[NF_ARP_NUMHOOKS ]; +u32 underflow[NF_ARP_NUMHOOKS ]; +u32 num_counters; +compat_uptr_t counters; +struct compat_arpt_entry entries[0 ]; +}; +static inline void compat_release_entry (struct compat_arpt_entry *e) {struct xt_entry_target *t;
@@ -1220,8 +1232,7 @@ check_compat_entry_size_and_hooks(structconst unsigned char *base, const unsigned char *limit, const unsigned int *hook_entries, - const unsigned int *underflows, - const char *name) + const unsigned int *underflows) { struct xt_entry_target *t;struct xt_target *target;
@@ -1292,7 +1303,7 @@ out:static int compat_copy_entry_from_user (struct compat_arpt_entry *e,void **dstptr, -unsigned int *size,const char *name, +unsigned int *size,struct xt_table_info *newinfo,unsigned char *base) {struct xt_entry_target *t;
@@ -1325,14 +1336,9 @@ compat_copy_entry_from_user(struct compareturn ret; } -static int translate_compat_table (const char *name, -unsigned int valid_hooks, -struct xt_table_info **pinfo, +static int translate_compat_table (struct xt_table_info **pinfo,void **pentry0, -unsigned int total_size, -unsigned int number, -unsigned int *hook_entries, -unsigned int *underflows) +const struct compat_arpt_replace *compatr) {unsigned int i, j;struct xt_table_info *newinfo, *info;
@@ -1344,8 +1350,8 @@ static int translate_compat_table(const info = *pinfo; entry0 = *pentry0; - size = total_size; - info->number = number; + size = compatr->size; + info->number = compatr->num_entries;/* Init all hooks to impossible value. */ for (i =0 ; i <NF_ARP_NUMHOOKS ; i++) {
@@ -1356,40 +1362,39 @@ static int translate_compat_table(constduprintf ("translate_compat_table: size %u\n" , info->size); j =0 ;xt_compat_lock (NFPROTO_ARP ); -xt_compat_init_offsets (NFPROTO_ARP , number); +xt_compat_init_offsets (NFPROTO_ARP , compatr->num_entries);/* Walk through entries, checking offsets. */ - xt_entry_foreach(iter0, entry0, total_size) { + xt_entry_foreach(iter0, entry0, compatr->size) { ret =check_compat_entry_size_and_hooks (iter0, info, &size, entry0, - entry0 + total_size, - hook_entries, - underflows, - name); + entry0 + compatr->size, + compatr->hook_entry, + compatr->underflow);if (ret !=0 ) goto out_unlock; ++j; } ret = -EINVAL ; -if (j != number) { +if (j != compatr->num_entries) {duprintf ("translate_compat_table: %u not %u entries\n" , - j, number); + j, compatr->num_entries); goto out_unlock; }/* Check hooks all assigned */ for (i =0 ; i <NF_ARP_NUMHOOKS ; i++) {/* Only hooks which are valid */ -if (!(valid_hooks & (1 << i))) +if (!(compatr->valid_hooks & (1 << i)))continue ;if (info->hook_entry[i] ==0xFFFFFFFF ) {duprintf ("Invalid hook entry %u %u\n" , - i, hook_entries[i]); + i, info->hook_entry[i]); goto out_unlock; }if (info->underflow[i] ==0xFFFFFFFF ) {duprintf ("Invalid underflow %u %u\n" , - i, underflows[i]); + i, info->underflow[i]); goto out_unlock; } }
@@ -1399,17 +1404,17 @@ static int translate_compat_table(constif (!newinfo) goto out_unlock; - newinfo->number = number; + newinfo->number = compatr->num_entries;for (i =0 ; i <NF_ARP_NUMHOOKS ; i++) { newinfo->hook_entry[i] = info->hook_entry[i]; newinfo->underflow[i] = info->underflow[i]; } entry1 = newinfo->entries[raw_smp_processor_id ()]; pos = entry1; - size = total_size; - xt_entry_foreach(iter0, entry0, total_size) { + size = compatr->size; + xt_entry_foreach(iter0, entry0, compatr->size) { ret =compat_copy_entry_from_user (iter0, &pos, &size, - name, newinfo, entry1); + newinfo, entry1);if (ret !=0 )break ; }
@@ -1419,12 +1424,12 @@ static int translate_compat_table(const goto free_newinfo; ret = -ELOOP ; -if (!mark_source_chains (newinfo, valid_hooks, entry1)) +if (!mark_source_chains (newinfo, compatr->valid_hooks, entry1)) goto free_newinfo; i =0 ; xt_entry_foreach(iter1, entry1, newinfo->size) { - ret =check_target (iter1, name); + ret =check_target (iter1, compatr->name);if (ret !=0 )break ; ++i;
@@ -1469,7 +1474,7 @@ static int translate_compat_table(const free_newinfo:xt_free_table_info (newinfo); out: - xt_entry_foreach(iter0, entry0, total_size) { + xt_entry_foreach(iter0, entry0, compatr->size) {if (j-- ==0 )break ;compat_release_entry (iter0);
@@ -1481,18 +1486,6 @@ out_unlock: goto out; } -struct compat_arpt_replace { -char name[XT_TABLE_MAXNAMELEN ]; -u32 valid_hooks; -u32 num_entries; -u32 size; -u32 hook_entry[NF_ARP_NUMHOOKS ]; -u32 underflow[NF_ARP_NUMHOOKS ]; -u32 num_counters; -compat_uptr_t counters; -struct compat_arpt_entry entries[0 ]; -}; -static int compat_do_replace (struct net *net,void __user *user,unsigned int len) {
@@ -1523,10 +1516,7 @@ static int compat_do_replace(struct net goto free_newinfo; } - ret =translate_compat_table (tmp.name, tmp.valid_hooks, - &newinfo, &loc_cpu_entry, tmp.size, - tmp.num_entries, tmp.hook_entry, - tmp.underflow); + ret =translate_compat_table (&newinfo, &loc_cpu_entry, &tmp);if (ret !=0 ) goto free_newinfo;
PATCH 85/305 net/mlx4_core: Fix access to uninitialized index
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tariq Toukan <[email protected]>
commit 2bb07e155bb3e0c722c806723f737cf8020961ef upstream.
Prevent using uninitialized or negative index when handling steering entries.
--- drivers/net/ethernet/mellanox/mlx4/mcg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx4/mcg.c +2 -2
@@ -953,7 +953,7 @@ int mlx4_qp_attach_common(struct mlx4_destruct mlx4_cmd_mailbox *mailbox;struct mlx4_mgm *mgm;u32 members_count; -int index, prev; +int index =-1 , prev;int link =0 ;int i;int err;
@@ -1032,7 +1032,7 @@ int mlx4_qp_attach_common(struct mlx4_de goto out; out: -if (prot ==MLX4_PROT_ETH ) { +if (prot ==MLX4_PROT_ETH && index !=-1 ) {/* manage the steering entry for promisc mode */ if (new_entry)new_steering_entry (dev, port, steer, index, qp->qpn);
PATCH 60/305 USB: serial: quatech2: fix use-after-free in probe error path
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 028c49f5e02a257c94129cd815f7c8485f51d4ef upstream.
The interface read URB is submitted in attach, but was only unlinked by the driver at disconnect.
In case of a late probe error (e.g. due to failed minor allocation), disconnect is never called and we would end up with active URBs for an unbound interface. This in turn could lead to deallocated memory being dereferenced in the completion callback.
--- drivers/usb/serial/quatech2.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/quatech2.c +1 -0
@@ -141,6 +141,7 @@ static void qt2_release(struct usb_seria serial_priv =usb_get_serial_data (serial); +usb_kill_urb (serial_priv->read_urb);usb_free_urb (serial_priv->read_urb);kfree (serial_priv->read_buffer);kfree (serial_priv);
PATCH 186/305 spi: sunxi: fix transfer timeout
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michal Suchanek <[email protected]>
commit 719bd6542044efd9b338a53dba1bef45f40ca169 upstream.
The trasfer timeout is fixed at 1000 ms. Reading a 4Mbyte flash over 1MHz SPI bus takes way longer than that. Calculate the timeout from the actual time the transfer is supposed to take and multiply by 2 for good measure.
--- drivers/spi/spi-sun4i.c | 10 +++++++++- drivers/spi/spi-sun6i.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/spi/spi-sun4i.c +9 -1
@@ -170,6 +170,7 @@ static int sun4i_spi_transfer_one(struct {struct sun4i_spi *sspi =spi_master_get_devdata (master);unsigned int mclk_rate, div, timeout; +unsigned int start, end, tx_time;unsigned int tx_len =0 ;int ret =0 ;u32 reg;
@@ -286,9 +287,16 @@ static int sun4i_spi_transfer_one(struct reg =sun4i_spi_read (sspi,SUN4I_CTL_REG );sun4i_spi_write (sspi,SUN4I_CTL_REG , reg |SUN4I_CTL_XCH ); + tx_time =max (tfr->len *8 *2 / (tfr->speed_hz /1000 ),100U ); + start = jiffies; timeout =wait_for_completion_timeout (&sspi->done, -msecs_to_jiffies (1000 )); +msecs_to_jiffies (tx_time)); + end = jiffies;if (!timeout) { +dev_warn (&master->dev, +"%s: timeout transferring %u bytes@%iHz for %i(%i)ms" , +dev_name (&spi->dev), tfr->len, tfr->speed_hz, +jiffies_to_msecs (end - start), tx_time); ret = -ETIMEDOUT ; goto out; }
drivers/spi/spi-sun6i.c +9 -1
@@ -160,6 +160,7 @@ static int sun6i_spi_transfer_one(struct {struct sun6i_spi *sspi =spi_master_get_devdata (master);unsigned int mclk_rate, div, timeout; +unsigned int start, end, tx_time;unsigned int tx_len =0 ;int ret =0 ;u32 reg;
@@ -269,9 +270,16 @@ static int sun6i_spi_transfer_one(struct reg =sun6i_spi_read (sspi,SUN6I_TFR_CTL_REG );sun6i_spi_write (sspi,SUN6I_TFR_CTL_REG , reg |SUN6I_TFR_CTL_XCH ); + tx_time =max (tfr->len *8 *2 / (tfr->speed_hz /1000 ),100U ); + start = jiffies; timeout =wait_for_completion_timeout (&sspi->done, -msecs_to_jiffies (1000 )); +msecs_to_jiffies (tx_time)); + end = jiffies;if (!timeout) { +dev_warn (&master->dev, +"%s: timeout transferring %u bytes@%iHz for %i(%i)ms" , +dev_name (&spi->dev), tfr->len, tfr->speed_hz, +jiffies_to_msecs (end - start), tx_time); ret = -ETIMEDOUT ; goto out; }
PATCH 296/305 netfilter: x_tables: validate all offsets and sizes in a rule
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 13631bfc604161a9d69cd68991dff8603edd66f9 upstream.
Validate that all matches (if any) add up to the beginning of the target and that each match covers at least the base structure size.
The compat path should be able to safely re-use the function as the structures only differ in alignment; added a BUILD_BUG_ON just in case we have an arch that adds padding as well.
--- net/netfilter/x_tables.c | 81 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 5 deletions(-)
net/netfilter/x_tables.c +76 -5
@@ -435,6 +435,47 @@ int xt_check_match(struct xt_mtchk_param }EXPORT_SYMBOL_GPL (xt_check_match); +/** xt_check_entry_match - check that matches end before start of target +* +* @match: beginning of xt_entry_match +* @target: beginning of this rules target (alleged end of matches) +* @alignment: alignment requirement of match structures +* +* Validates that all matches add up to the beginning of the target, +* and that each match covers at least the base structure size. +* +* Return: 0 on success, negative errno on failure. +*/ +static int xt_check_entry_match (const char *match,const char *target, +const size_t alignment) +{ +const struct xt_entry_match *pos; +int length = target - match; + +if (length ==0 )/* no matches */ +return 0 ; + + pos = (struct xt_entry_match *)match; +do { +if ((unsigned long )pos % alignment) +return -EINVAL ; + +if (length < (int )sizeof (struct xt_entry_match )) +return -EINVAL ; + +if (pos->u.match_size <sizeof (struct xt_entry_match )) +return -EINVAL ; + +if (pos->u.match_size > length) +return -EINVAL ; + + length -= pos->u.match_size; + pos = ((void *)((char *)(pos) + (pos)->u.match_size)); + }while (length >0 ); + +return 0 ; +} +#ifdef CONFIG_COMPAT int xt_compat_add_offset (u_int8_t af,unsigned int offset,int delta) {
@@ -590,7 +631,14 @@ int xt_compat_check_entry_offsets(const target_offset + sizeof(struct compat_xt_standard_target) != next_offset) return -EINVAL; - return 0; +/* compat_xt_entry match has less strict aligment requirements, +* otherwise they are identical. In case of padding differences +* we need to add compat version of xt_check_entry_match. +*/ +BUILD_BUG_ON (sizeof (struct compat_xt_entry_match ) !=sizeof (struct xt_entry_match )); + +return xt_check_entry_match (elems, base + target_offset, + __alignof__(struct compat_xt_entry_match)); }EXPORT_SYMBOL (xt_compat_check_entry_offsets);#endif /* CONFIG_COMPAT */
@@ -603,17 +651,39 @@ EXPORT_SYMBOL(xt_compat_check_entry_offs* @target_offset: the arp/ip/ip6_t->target_offset * @next_offset: the arp/ip/ip6_t->next_offset * -* validates that target_offset and next_offset are sane. -* Also see xt_compat_check_entry_offsets for CONFIG_COMPAT version. +* validates that target_offset and next_offset are sane and that all +* match sizes (if any) align with the target offset. * * This function does not validate the targets or matches themselves, it -* only tests that all the offsets and sizes are correct. +* only tests that all the offsets and sizes are correct, that all +* match structures are aligned, and that the last structure ends where +* the target structure begins. +* +* Also see xt_compat_check_entry_offsets for CONFIG_COMPAT version. * * The arp/ip/ip6t_entry structure @base must have passed following tests: * - it must point to a valid memory location * - base to base + next_offset must be accessible, i.e. not exceed allocated * length. * +* A well-formed entry looks like this: +* +* ip(6)t_entry match [mtdata] match [mtdata] target [tgdata] ip(6)t_entry +* e->elems[]-----' | | +* matchsize | | +* matchsize | | +* | | +* target_offset---------------------------------' | +* next_offset---------------------------------------------------' +* +* elems[]: flexible array member at end of ip(6)/arpt_entry struct. +* This is where matches (if any) and the target reside. +* target_offset: beginning of target. +* next_offset: start of the next rule; also: size of this rule. +* Since targets have a minimum size, target_offset + minlen <= next_offset. +* +* Every match stores its size, sum of sizes must not exceed target_offset. +* * Return: 0 on success, negative errno on failure. */ int xt_check_entry_offsets(const void *base,
@@ -643,7 +713,8 @@ int xt_check_entry_offsets(const void *b target_offset + sizeof(struct xt_standard_target) != next_offset) return -EINVAL; -return 0 ; +return xt_check_entry_match (elems, base + target_offset, + __alignof__(struct xt_entry_match )); }EXPORT_SYMBOL (xt_check_entry_offsets);
PATCH 248/305 ipr: Clear interrupt on croc/crocodile when running with LSI
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Brian King <[email protected]>
commit 54e430bbd490e18ab116afa4cd90dcc45787b3df upstream.
If we fall back to using LSI on the Croc or Crocodile chip we need to clear the interrupt so we don't hang the system.
--- drivers/scsi/ipr.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ipr.c +1 -0
@@ -9753,6 +9753,7 @@ static int ipr_probe_ioa(struct pci_dev ioa_cfg->intr_flag =IPR_USE_MSI ; else { ioa_cfg->intr_flag =IPR_USE_LSI ; + ioa_cfg->clear_isr =1 ; ioa_cfg->nvectors =1 ;dev_info (&pdev->dev,"Cannot enable MSI.\n" ); }
PATCH 77/305 ring-buffer: Use long for nr_pages to avoid overflow failures
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (Red Hat)" <[email protected]>
commit 9b94a8fba501f38368aef6ac1b30e7335252a220 upstream.
The size variable to change the ring buffer in ftrace is a long. The nr_pages used to update the ring buffer based on the size is int. On 64 bit machines this can cause an overflow problem.
For example, the following will cause the ring buffer to crash:
# cd /sys/kernel/debug/tracing # echo 10 > buffer_size_kb # echo 8556384240 > buffer_size_kb
Then you get the warning of:
WARNING: CPU: 1 PID: 318 at kernel/trace/ring_buffer.c:1527 rb_update_pages+0x22f/0x260
Which is:
RB_WARN_ON(cpu_buffer, nr_removed);
Note each ring buffer page holds 4080 bytes.
This is because:
1) 10 causes the ring buffer to have 3 pages.
(10kb requires 3 * 4080 pages to hold)
2) (2^31 / 2^10 + 1) * 4080 = 8556384240
The value written into buffer_size_kb is shifted by 10 and then passed to ring_buffer_resize(). 8556384240 * 2^10 = 8761737461760
3) The size passed to ring_buffer_resize() is then divided by BUF_PAGE_SIZE
which is 4080. 8761737461760 / 4080 = 2147484672
4) nr_pages is subtracted from the current nr_pages (3) and we get:
2147484669. This value is saved in a signed integer nr_pages_to_update
5) 2147484669 is greater than 2^31 but smaller than 2^32, a signed int
turns into the value of -2147482627
6) As the value is a negative number, in update_pages_handler() it is negated and passed to rb_remove_pages() and 2147482627 pages will be removed, which is much larger than 3 and it causes the warning because not all the pages asked to be removed were removed.
--- kernel/trace/ring_buffer.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
kernel/trace/ring_buffer.c +14 -12
@@ -466,7 +466,7 @@ struct ring_buffer_per_cpu {raw_spinlock_t reader_lock;/* serialize readers */ arch_spinlock_t lock;struct lock_class_key lock_key; -unsigned int nr_pages; +unsigned long nr_pages;struct list_head *pages;struct buffer_page *head_page;/* read from head */ struct buffer_page *tail_page;/* write to tail */
@@ -486,7 +486,7 @@ struct ring_buffer_per_cpu {u64 write_stamp;u64 read_stamp;/* ring buffer pages to update, > 0 to add, < 0 to remove */ -int nr_pages_to_update; +long nr_pages_to_update;struct list_head new_pages;/* new pages to add */ struct work_struct update_pages_work;struct completion update_done;
@@ -1165,10 +1165,10 @@ static int rb_check_pages(struct ring_bureturn 0 ; } -static int __rb_allocate_pages (int nr_pages,struct list_head *pages,int cpu) +static int __rb_allocate_pages (long nr_pages,struct list_head *pages,int cpu) { -int i;struct buffer_page *bpage, *tmp; +long i;for (i =0 ; i < nr_pages; i++) {struct page *page;
@@ -1205,7 +1205,7 @@ free_pages: }static int rb_allocate_pages (struct ring_buffer_per_cpu *cpu_buffer, -unsigned nr_pages) +unsigned long nr_pages) {LIST_HEAD (pages);
@@ -1230,7 +1230,7 @@ static int rb_allocate_pages(struct ring }static struct ring_buffer_per_cpu * -rb_allocate_cpu_buffer (struct ring_buffer *buffer,int nr_pages,int cpu) +rb_allocate_cpu_buffer (struct ring_buffer *buffer,long nr_pages,int cpu) {struct ring_buffer_per_cpu *cpu_buffer;struct buffer_page *bpage;
@@ -1330,8 +1330,9 @@ struct ring_buffer *__ring_buffer_alloc( struct lock_class_key *key) {struct ring_buffer *buffer; +long nr_pages;int bsize; -int cpu, nr_pages; +int cpu;/* keep it in its own cache line */ buffer = kzalloc(ALIGN(sizeof(*buffer), cache_line_size()),
@@ -1457,12 +1458,12 @@ static inline unsigned long rb_page_writ }static int -rb_remove_pages (struct ring_buffer_per_cpu *cpu_buffer,unsigned int nr_pages) +rb_remove_pages (struct ring_buffer_per_cpu *cpu_buffer,unsigned long nr_pages) {struct list_head *tail_page, *to_remove, *next_page;struct buffer_page *to_remove_page, *tmp_iter_page;struct buffer_page *last_page, *first_page; -unsigned int nr_removed; +unsigned long nr_removed;unsigned long head_bit;int page_entries;
@@ -1679,7 +1680,7 @@ int ring_buffer_resize(struct ring_buffe int cpu_id) {struct ring_buffer_per_cpu *cpu_buffer; -unsigned nr_pages; +unsigned long nr_pages;int cpu, err =0 ;/*
@@ -4669,8 +4670,9 @@ static int rb_cpu_notify(struct notifierstruct ring_buffer *buffer = container_of(self, struct ring_buffer, cpu_notify);long cpu = (long )hcpu; -int cpu_i, nr_pages_same; -unsigned int nr_pages; +long nr_pages_same; +int cpu_i; +unsigned long nr_pages;switch (action) {case CPU_UP_PREPARE :
PATCH 210/305 UBIFS: Implement ->migratepage()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Kirill A. Shutemov" <[email protected]>
commit 4ac1c17b2044a1b4b2fbed74451947e905fc2992 upstream.
During page migrations UBIFS might get confused
and the following assert triggers:
[ 213.480000] UBIFS assert failed in ubifs_set_page_dirty at 1451 (pid 436) [ 213.490000] CPU: 0 PID: 436 Comm: drm-stress-test Not tainted 4.4.4-00176-geaa802524636-dirty #1008 [ 213.490000] Hardware name: Allwinner sun4i/sun5i Families [ 213.490000] [<c0015e70>] (unwind_backtrace) from [<c0012cdc>] (show_stack+0x10/0x14) [ 213.490000] [<c0012cdc>] (show_stack) from [<c02ad834>] (dump_stack+0x8c/0xa0) [ 213.490000] [<c02ad834>] (dump_stack) from [<c0236ee8>] (ubifs_set_page_dirty+0x44/0x50) [ 213.490000] [<c0236ee8>] (ubifs_set_page_dirty) from [<c00fa0bc>] (try_to_unmap_one+0x10c/0x3a8) [ 213.490000] [<c00fa0bc>] (try_to_unmap_one) from [<c00fadb4>] (rmap_walk+0xb4/0x290) [ 213.490000] [<c00fadb4>] (rmap_walk) from [<c00fb1bc>] (try_to_unmap+0x64/0x80) [ 213.490000] [<c00fb1bc>] (try_to_unmap) from [<c010dc28>] (migrate_pages+0x328/0x7a0) [ 213.490000] [<c010dc28>] (migrate_pages) from [<c00d0cb0>] (alloc_contig_range+0x168/0x2f4) [ 213.490000] [<c00d0cb0>] (alloc_contig_range) from [<c010ec00>] (cma_alloc+0x170/0x2c0) [ 213.490000] [<c010ec00>] (cma_alloc) from [<c001a958>] (__alloc_from_contiguous+0x38/0xd8) [ 213.490000] [<c001a958>] (__alloc_from_contiguous) from [<c001ad44>] (__dma_alloc+0x23c/0x274) [ 213.490000] [<c001ad44>] (__dma_alloc) from [<c001ae08>] (arm_dma_alloc+0x54/0x5c) [ 213.490000] [<c001ae08>] (arm_dma_alloc) from [<c035cecc>] (drm_gem_cma_create+0xb8/0xf0) [ 213.490000] [<c035cecc>] (drm_gem_cma_create) from [<c035cf20>] (drm_gem_cma_create_with_handle+0x1c/0xe8) [ 213.490000] [<c035cf20>] (drm_gem_cma_create_with_handle) from [<c035d088>] (drm_gem_cma_dumb_create+0x3c/0x48) [ 213.490000] [<c035d088>] (drm_gem_cma_dumb_create) from [<c0341ed8>] (drm_ioctl+0x12c/0x444) [ 213.490000] [<c0341ed8>] (drm_ioctl) from [<c0121adc>] (do_vfs_ioctl+0x3f4/0x614) [ 213.490000] [<c0121adc>] (do_vfs_ioctl) from [<c0121d30>] (SyS_ioctl+0x34/0x5c) [ 213.490000] [<c0121d30>] (SyS_ioctl) from [<c000f2c0>] (ret_fast_syscall+0x0/0x34)
UBIFS is using PagePrivate() which can have different meanings across filesystems. Therefore the generic page migration code cannot handle this case correctly.
We have to implement our own migration function which basically does a plain copy but also duplicates the page private flag.
UBIFS is not a block device filesystem and cannot use buffer_migrate_page().
--- fs/ubifs/file.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/ubifs/file.c +24 -0
@@ -54,6 +54,7 @@#include <linux/mount.h> #include <linux/namei.h> #include <linux/slab.h> +#include <linux/migrate.h> static int read_block (struct inode *inode,void *addr,unsigned int block,struct ubifs_data_node *dn)
@@ -1419,6 +1420,26 @@ static int ubifs_set_page_dirty(struct preturn ret; } +#ifdef CONFIG_MIGRATION +static int ubifs_migrate_page (struct address_space *mapping, +struct page *newpage,struct page *page,enum migrate_mode mode) +{ +int rc; + + rc =migrate_page_move_mapping (mapping, newpage, page,NULL , mode,0 ); +if (rc !=MIGRATEPAGE_SUCCESS ) +return rc; + +if (PagePrivate (page)) { +ClearPagePrivate (page); +SetPagePrivate (newpage); + } + +migrate_page_copy (newpage, page); +return MIGRATEPAGE_SUCCESS ; +} +#endif +static int ubifs_releasepage (struct page *page,gfp_t unused_gfp_flags) {/*
@@ -1556,6 +1577,9 @@ const struct address_space_operations ub .write_end = ubifs_write_end, .invalidatepage = ubifs_invalidatepage, .set_page_dirty = ubifs_set_page_dirty, +#ifdef CONFIG_MIGRATION + .migratepage = ubifs_migrate_page, +#endif .releasepage = ubifs_releasepage, };
PATCH 211/305 powerpc/bpf/jit: Disable classic BPF JIT on ppc64le
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Naveen N. Rao" <[email protected]>
commit 844e3be47693f92a108cb1fb3b0606bf25e9c7a6 upstream.
Classic BPF JIT was never ported completely to work on little endian powerpc. However, it can be enabled and will crash the system when used. As such, disable use of BPF JIT on ppc64le.
--- arch/powerpc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -1
@@ -124,7 +124,7 @@ config PPC select IRQ_FORCED_THREADING select HAVE_RCU_TABLE_FREE if SMP select HAVE_SYSCALL_TRACEPOINTS - select HAVE_BPF_JIT if PPC64 + select HAVE_BPF_JIT if PPC64 && CPU_BIG_ENDIAN select HAVE_ARCH_JUMP_LABEL select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD
PATCH 147/305 mnt: fs_fully_visible test the proper mount for MNT_LOCKED
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit d71ed6c930ac7d8f88f3cef6624a7e826392d61f upstream.
MNT_LOCKED implies on a child mount implies the child is locked to the parent. So while looping through the children the children should be tested (not their parent).
Typically an unshare of a mount namespace locks all mounts together making both the parent and the slave as locked but there are a few corner cases where other things work.
--- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/namespace.c +1 -1
@@ -3072,7 +3072,7 @@ static bool fs_fully_visible(struct filelist_for_each_entry (child, &mnt->mnt_mounts, mnt_child) {struct inode *inode = child->mnt_mountpoint->d_inode;/* Only worry about locked mounts */ -if (!(mnt->mnt.mnt_flags &MNT_LOCKED )) +if (!(child->mnt.mnt_flags &MNT_LOCKED ))continue ;/* Is the directory permanetly empty? */ if (!is_empty_dir_inode (inode))
PATCH 74/305 powerpc/iommu: Remove the dependency on EEH struct in DDW mechanism
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Guilherme G. Piccoli" <[email protected]>
commit 8445a87f7092bc8336ea1305be9306f26b846d93 upstream.
Commit 39baadbf36ce ("powerpc/eeh: Remove eeh information from pci_dn") changed the pci_dn struct by removing its EEH-related members. As part of this clean-up, DDW mechanism was modified to read the device configuration address from eeh_dev struct.
As a consequence, now if we disable EEH mechanism on kernel command-line for example, the DDW mechanism will fail, generating a kernel oops by dereferencing a NULL pointer (which turns to be the eeh_dev pointer).
This patch just changes the configuration address calculation on DDW functions to a manual calculation based on pci_dn members instead of using eeh_dev-based address.
No functional changes were made. This was tested on pSeries, both in PHyp and qemu guest.
--- arch/powerpc/platforms/pseries/iommu.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +12 -12
@@ -826,7 +826,8 @@ machine_arch_initcall(pseries, find_exisstatic int query_ddw (struct pci_dev *dev,const u32 *ddw_avail,struct ddw_query_response *query) { -struct eeh_dev *edev; +struct device_node *dn; +struct pci_dn *pdn;u32 cfg_addr;u64 buid;int ret;
@@ -837,11 +838,10 @@ static int query_ddw(struct pci_dev *dev* Retrieve them from the pci device, not the node with the * dma-window property */ - edev =pci_dev_to_eeh_dev (dev); - cfg_addr = edev->config_addr; -if (edev->pe_config_addr) - cfg_addr = edev->pe_config_addr; - buid = edev->phb->buid; + dn =pci_device_to_OF_node (dev); + pdn =PCI_DN (dn); + buid = pdn->phb->buid; + cfg_addr = (pdn->busno <<8 ) | pdn->devfn; ret =rtas_call (ddw_avail[0 ],3 ,5 , (u32 *)query, cfg_addr,BUID_HI (buid),BUID_LO (buid));
@@ -855,7 +855,8 @@ static int create_ddw(struct pci_dev *de struct ddw_create_response *create, int page_shift, int window_shift) { - struct eeh_dev *edev; + struct device_node *dn; +struct pci_dn *pdn;u32 cfg_addr;u64 buid;int ret;
@@ -866,11 +867,10 @@ static int create_ddw(struct pci_dev *de* Retrieve them from the pci device, not the node with the * dma-window property */ - edev =pci_dev_to_eeh_dev (dev); - cfg_addr = edev->config_addr; -if (edev->pe_config_addr) - cfg_addr = edev->pe_config_addr; - buid = edev->phb->buid; + dn =pci_device_to_OF_node (dev); + pdn =PCI_DN (dn); + buid = pdn->phb->buid; + cfg_addr = (pdn->busno <<8 ) | pdn->devfn; do { /* extra outputs are LIOBN and dma-addr (hi, lo) */
PATCH 275/305 proc: prevent stacking filesystems on top
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit e54ad7f1ee263ffa5a2de9c609d58dfa27b21cd9 upstream.
This prevents stacking filesystems (ecryptfs and overlayfs) from using procfs as lower filesystem. There is too much magic going on inside procfs, and there is no good reason to stack stuff on top of procfs.
(For example, procfs does access checks in VFS open handlers, and ecryptfs by design calls open handlers from a kernel thread that doesn't drop privileges or so.)
--- fs/proc/root.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/proc/root.c +7 -0
@@ -121,6 +121,13 @@ static struct dentry *proc_mount(structif (IS_ERR (sb))return ERR_CAST (sb); +/* +* procfs isn't actually a stacking filesystem; however, there is +* too much magic going on inside it to permit stacking things on +* top of it +*/ + sb->s_stack_depth =FILESYSTEM_MAX_STACK_DEPTH ; +if (!proc_parse_options (options, ns)) {deactivate_locked_super (sb);return ERR_PTR (-EINVAL );
PATCH 68/305 kbuild: move -Wunused-const-variable to W=1 warning level
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit c9c6837d39311b0cc14cdbe7c18e815ab44aefb1 upstream.
gcc-6 started warning by default about variables that are not used anywhere and that are marked 'const', generating many false positives in an allmodconfig build, e.g.:
arch/arm/mach-davinci/board-da830-evm.c:282:20: warning: 'da830_evm_emif25_pins' defined but not used [-Wunused-const-variable=] arch/arm/plat-omap/dmtimer.c:958:34: warning: 'omap_timer_match' defined but not used [-Wunused-const-variable=] drivers/bluetooth/hci_bcm.c:625:39: warning: 'acpi_bcm_default_gpios' defined but not used [-Wunused-const-variable=] drivers/char/hw_random/omap-rng.c:92:18: warning: 'reg_map_omap4' defined but not used [-Wunused-const-variable=] drivers/devfreq/exynos/exynos5_bus.c:381:32: warning: 'exynos5_busfreq_int_pm' defined but not used [-Wunused-const-variable=] drivers/dma/mv_xor.c:1139:34: warning: 'mv_xor_dt_ids' defined but not used [-Wunused-const-variable=]
This is similar to the existing -Wunused-but-set-variable warning that was added in an earlier release and that we disable by default now and only enable when W=1 is set, so it makes sense to do the same here. Once we have eliminated the majority of the warnings for both, we can put them back into the default list.
We probably want this in backport kernels as well, to allow building them with gcc-6 without introducing extra warnings.
--- Makefile | 5 +++-- scripts/Makefile.extrawarn | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
Makefile +3 -2
@@ -671,9 +671,10 @@ KBUILD_CFLAGS += $(call cc-disable-warni KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) else -# This warning generated too much noise in a regular build. -# Use make W=1 to enable this warning (see scripts/Makefile.build) +# These warnings generated too much noise in a regular build. +# Use make W=1 to enable them (see scripts/Makefile.build) KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) endif ifdef CONFIG_FRAME_POINTER
scripts/Makefile.extrawarn +1 -0
@@ -24,6 +24,7 @@ warning-1 += $(call cc-option, -Wmissing warning-1 += -Wold-style-definition warning-1 += $(call cc-option, -Wmissing-include-dirs) warning-1 += $(call cc-option, -Wunused-but-set-variable) +warning-1 += $(call cc-option, -Wunused-const-variable) warning-1 += $(call cc-disable-warning, missing-field-initializers) # Clang
PATCH 125/305 Input: xpad - prevent spurious input from wired Xbox 360 controllers
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Cameron Gutman <[email protected]>
commit 1ff5fa3c6732f08e01ae12f12286d4728c9e4d86 upstream.
After initially connecting a wired Xbox 360 controller or sending it a command to change LEDs, a status/response packet is interpreted as controller input. This causes the state of buttons represented in byte 2 of the controller data packet to be incorrect until the next valid input packet. Wireless Xbox 360 controllers are not affected.
Writing a new value to the LED device while holding the Start button and running jstest is sufficient to reproduce this bug. An event will come through with the Start button released.
Xboxdrv also won't attempt to read controller input from a packet where byte 0 is non-zero. It also checks that byte 1 is 0x14, but that value differs between wired and wireless controllers and this code is shared by both. I think just checking byte 0 is enough to eliminate unwanted packets.
The following are some examples of 3-byte status packets I saw:
01 03 02
02 03 00
03 03 03
08 03 00
--- drivers/input/joystick/xpad.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/joystick/xpad.c +4 -0
@@ -415,6 +415,10 @@ static void xpad360_process_packet(struc {struct input_dev *dev = xpad->dev; +/* valid pad data */ +if (data[0 ] !=0x00 ) +return ; +/* digital pad */ if (xpad->mapping &MAP_DPAD_TO_BUTTONS ) {/* dpad as buttons (left, right, up, down) */
PATCH 100/305 batman-adv: Fix unexpected free of bcast_own on add_if error
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit f7dcdf5fdbe8fec7670d8f65a5db595c98e0ecab upstream.
The function batadv_iv_ogm_orig_add_if allocates new buffers for bcast_own and bcast_own_sum. It is expected that these buffers are unchanged in case either bcast_own or bcast_own_sum couldn't be resized.
But the error handling of this function frees the already resized buffer for bcast_own when the allocation of the new bcast_own_sum buffer failed. This will lead to an invalid memory access when some code will try to access bcast_own.
Instead the resized new bcast_own buffer has to be kept. This will not lead to problems because the size of the buffer was only increased and therefore no user of the buffer will try to access bytes outside of the new buffer.
--- net/batman-adv/bat_iv_ogm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/batman-adv/bat_iv_ogm.c +1 -3
@@ -124,10 +124,8 @@ static int batadv_iv_ogm_orig_add_if(str orig_node->bat_iv.bcast_own = data_ptr; data_ptr =kmalloc (max_if_num *sizeof (uint8_t ),GFP_ATOMIC ); -if (!data_ptr) { -kfree (orig_node->bat_iv.bcast_own); +if (!data_ptr) goto unlock; - }memcpy (data_ptr, orig_node->bat_iv.bcast_own_sum, (max_if_num -1 ) *sizeof (uint8_t ));
PATCH 212/305 can: fix oops caused by wrong rtnl dellink usage
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
commit 25e1ed6e64f52a692ba3191c4fde650aab3ecc07 upstream.
For 'real' hardware CAN devices the netlink interface is used to set CAN specific communication parameters. Real CAN hardware can not be created nor removed with the ip tool ...
This patch adds a private dellink function for the CAN device driver interface that does just nothing.
It's a follow up to commit 993e6f2fd ("can: fix oops caused by wrong rtnl newlink usage") but for dellink.
--- drivers/net/can/dev.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/can/dev.c +6 -0
@@ -881,6 +881,11 @@ static int can_newlink(struct net *src_nreturn -EOPNOTSUPP ; } +static void can_dellink (struct net_device *dev,struct list_head *head) +{ +return ; +} +static struct rtnl_link_ops can_link_ops__read_mostly = { .kind ="can" , .maxtype =IFLA_CAN_MAX ,
@@ -888,6 +893,7 @@ static struct rtnl_link_ops can_link_ops .setup = can_setup, .newlink = can_newlink, .changelink = can_changelink, + .dellink = can_dellink, .get_size = can_get_size, .fill_info = can_fill_info, .get_xstats_size = can_get_xstats_size,
PATCH 73/305 sched/loadavg: Fix loadavg artifacts on fully idle and on fully loaded systems
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vik Heyndrickx <[email protected]>
commit 20878232c52329f92423d27a60e48b6a6389e0dd upstream.
Systems show a minimal load average of 0.00, 0.01, 0.05 even when they have no load at all.
Uptime and /proc/loadavg on all systems with kernels released during the last five years up until kernel version 4.6-rc5, show a 5- and 15-minute minimum loadavg of 0.01 and 0.05 respectively. This should be 0.00 on idle systems, but the way the kernel calculates this value prevents it from getting lower than the mentioned values.
Likewise but not as obviously noticeable, a fully loaded system with no processes waiting, shows a maximum 1/5/15 loadavg of 1.00, 0.99, 0.95 (multiplied by number of cores).
Once the (old) load becomes 93 or higher, it mathematically can never get lower than 93, even when the active (load) remains 0 forever. This results in the strange 0.00, 0.01, 0.05 uptime values on idle systems. Note: 93/2048 = 0.0454..., which rounds up to 0.05.
It is not correct to add a 0.5 rounding (=1024/2048) here, since the result from this function is fed back into the next iteration again, so the result of that +0.5 rounding value then gets multiplied by (2048-2037), and then rounded again, so there is a virtual "ghost" load created, next to the old and active load terms.
By changing the way the internally kept value is rounded, that internal value equivalent now can reach 0.00 on idle, and 1.00 on full load. Upon increasing load, the internally kept load value is rounded up, when the load is decreasing, the load value is rounded down.
The modified code was tested on nohz=off and nohz kernels. It was tested on vanilla kernel 4.6-rc5 and on centos 7.1 kernel 3.10.0-327. It was tested on single, dual, and octal cores system. It was tested on virtual hosts and bare hardware. No unwanted effects have been observed, and the problems that the patch intended to fix were indeed gone.
--- kernel/sched/proc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/sched/proc.c +7 -4
@@ -104,10 +104,13 @@ long calc_load_fold_active(struct rq *thstatic unsigned long calc_load (unsigned long load,unsigned long exp,unsigned long active) { - load *= exp; - load += active * (FIXED_1 - exp); - load +=1UL << (FSHIFT -1 ); -return load >>FSHIFT ; +unsigned long newload; + + newload = load * exp + active * (FIXED_1 - exp); +if (active >= load) + newload +=FIXED_1 -1 ; + +return newload /FIXED_1 ; }#ifdef CONFIG_NO_HZ_COMMON
PATCH 6/305 iommu/vt-d: Ratelimit fault handler
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
commit c43fce4eebae257ca413733690e2076757282093 upstream.
Fault rates can easily overwhelm the console and make the system unresponsive. Ratelimit to allow an opportunity for maintenance.
--- drivers/iommu/dmar.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
drivers/iommu/dmar.c +23 -12
@@ -1482,10 +1482,17 @@ irqreturn_t dmar_fault(int irq, void *deint reg, fault_index;u32 fault_status;unsigned long flag; +bool ratelimited; + static DEFINE_RATELIMIT_STATE(rs, + DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST); + +/* Disable printing, simply clear the fault when ratelimited */ + ratelimited = !__ratelimit (&rs);raw_spin_lock_irqsave (&iommu->register_lock, flag); fault_status =readl (iommu->reg +DMAR_FSTS_REG ); -if (fault_status) +if (fault_status && !ratelimited)pr_err ("DRHD: handling fault status reg %x\n" , fault_status);/* TBD: ignore advanced fault log currently */
@@ -1507,24 +1514,28 @@ irqreturn_t dmar_fault(int irq, void *deif (!(data &DMA_FRCD_F ))break ; - fault_reason =dma_frcd_fault_reason (data); - type =dma_frcd_type (data); - - data =readl (iommu->reg + reg + - fault_index *PRIMARY_FAULT_REG_LEN +8 ); - source_id =dma_frcd_source_id (data); +if (!ratelimited) { + fault_reason =dma_frcd_fault_reason (data); + type =dma_frcd_type (data); + + data =readl (iommu->reg + reg + + fault_index *PRIMARY_FAULT_REG_LEN +8 ); + source_id =dma_frcd_source_id (data); + + guest_addr =dmar_readq (iommu->reg + reg + + fault_index *PRIMARY_FAULT_REG_LEN ); + guest_addr =dma_frcd_page_addr (guest_addr); + } - guest_addr =dmar_readq (iommu->reg + reg + - fault_index *PRIMARY_FAULT_REG_LEN ); - guest_addr =dma_frcd_page_addr (guest_addr);/* clear the fault */ writel (DMA_FRCD_F , iommu->reg + reg + fault_index *PRIMARY_FAULT_REG_LEN +12 );raw_spin_unlock_irqrestore (&iommu->register_lock, flag); -dmar_fault_do_one (iommu, type, fault_reason, - source_id, guest_addr); +if (!ratelimited) +dmar_fault_do_one (iommu, type, fault_reason, + source_id, guest_addr); fault_index++;if (fault_index >=cap_num_fault_regs (iommu->cap))
PATCH 261/305 bonding: prevent out of bound accesses
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit f87fda00b6ed232a817c655b8d179b48bde8fdbe upstream.
ether_addr_equal_64bits() requires some care about its arguments, namely that 8 bytes might be read, even if last 2 byte values are not used.
KASan detected a violation with null_mac_addr and lacpdu_mcast_addr in bond_3ad.c
Same problem with mac_bcast[] and mac_v6_allmcast[] in bond_alb.c :
Although the 8-byte alignment was there, KASan would detect out of bound accesses.
[bwh: Backported to 3.16:
- Adjust filename
- Drop change to bond_params::ad_actor_system
- Fix one more copy of null_mac_addr to use eth_zero_addr()]
--- drivers/net/bonding/bond_3ad.c | 11 +++++++---- drivers/net/bonding/bond_alb.c | 7 ++----- drivers/net/bonding/bonding.h | 7 ++++++- 3 files changed, 15 insertions(+), 10 deletions(-)
drivers/net/bonding/bond_3ad.c +8 -5
@@ -95,11 +95,14 @@#define MAC_ADDRESS_EQUAL (A ,B ) \ ether_addr_equal_64bits((const u8 *)A, (const u8 *)B) -static struct mac_addr null_mac_addr = { {0 ,0 ,0 ,0 ,0 ,0 } }; +static const u8 null_mac_addr[ETH_ALEN + 2] __long_aligned = { +0 ,0 ,0 ,0 ,0 ,0 +};static u16 ad_ticks_per_sec;static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL *HZ ) /1000 ; -static const u8 lacpdu_mcast_addr[ETH_ALEN ] =MULTICAST_LACPDU_ADDR ; +static const u8 lacpdu_mcast_addr[ETH_ALEN + 2] __long_aligned = +MULTICAST_LACPDU_ADDR ;/* ================= main 802.3ad protocol functions ================== */ static int ad_lacpdu_send (struct port *port);
@@ -1614,7 +1617,7 @@ static void ad_clear_agg(struct aggregat aggregator->is_individual = false; aggregator->actor_admin_aggregator_key =0 ; aggregator->actor_oper_aggregator_key =0 ; - aggregator->partner_system = null_mac_addr; +eth_zero_addr (aggregator->partner_system.mac_addr_value); aggregator->partner_system_priority =0 ; aggregator->partner_oper_aggregator_key =0 ; aggregator->receive_state =0 ;
@@ -1636,7 +1639,7 @@ static void ad_initialize_agg(struct aggif (aggregator) {ad_clear_agg (aggregator); - aggregator->aggregator_mac_address = null_mac_addr; +eth_zero_addr (aggregator->aggregator_mac_address.mac_addr_value); aggregator->aggregator_identifier =0 ; aggregator->slave =NULL ; }
@@ -1671,7 +1674,7 @@ static void ad_initialize_port(struct poif (port) { port->actor_port_number =1 ; port->actor_port_priority =0xff ; - port->actor_system = null_mac_addr; +eth_zero_addr (port->actor_system.mac_addr_value); port->actor_system_priority =0xffff ; port->actor_port_aggregator_identifier =0 ; port->ntt = false;
drivers/net/bonding/bond_alb.c +2 -5
@@ -44,13 +44,10 @@ -#ifndef __long_aligned -#define __long_aligned __attribute__((aligned((sizeof(long))))) -#endif -static const u8 mac_bcast[ETH_ALEN] __long_aligned = { +static const u8 mac_bcast[ETH_ALEN + 2] __long_aligned = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; -static const u8 mac_v6_allmcast[ETH_ALEN] __long_aligned = { +static const u8 mac_v6_allmcast[ETH_ALEN + 2] __long_aligned = {0x33 ,0x33 ,0x00 ,0x00 ,0x00 ,0x01 };static const int alb_delta_in_ticks =HZ /ALB_TIMER_TICKS_PER_SEC ;
drivers/net/bonding/bonding.h +3 -0
@@ -41,6 +41,9 @@#define BOND_DEFAULT_MIIMON 100 +#ifndef __long_aligned +#define __long_aligned __attribute__((aligned((sizeof(long))))) +#endif /* * Less bad way to call ioctl from within the kernel; this needs to be * done some other way to get the call out of interrupt context.
PATCH 252/305 batman-adv: replace WARN with rate limited output on non-existing VLAN
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Simon Wunderlich <[email protected]>
commit 0b3dd7dfb81ad8af53791ea2bb64b83bac1b7d32 upstream.
If a VLAN tagged frame is received and the corresponding VLAN is not configured on the soft interface, it will splat a WARN on every packet received. This is a quite annoying behaviour for some scenarios, e.g. if bat0 is bridged with eth0, and there are arbitrary VLAN tagged frames from Ethernet coming in without having any VLAN configuration on bat0.
The code should probably create vlan objects on the fly and transparently transport these VLAN-tagged Ethernet frames, but until this is done, at least the WARN splat should be replaced by a rate limited output.
--- net/batman-adv/translation-table.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/batman-adv/translation-table.c +4 -2
@@ -576,8 +576,10 @@ bool batadv_tt_local_add(struct net_devi/* increase the refcounter of the related vlan */ vlan =batadv_softif_vlan_get (bat_priv, vid); -if (WARN (!vlan,"adding TT local entry %pM to non-existent VLAN %d" , - addr,BATADV_PRINT_VID (vid))) { +if (!vlan) { +net_ratelimited_function (batadv_info, soft_iface, +"adding TT local entry %pM to non-existent VLAN %d\n" , + addr,BATADV_PRINT_VID (vid));kfree (tt_local); tt_local =NULL ; goto out;
PATCH 65/305 s390/vmem: fix identity mapping
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit c34a69059d7876e0793eb410deedfb08ccb22b02 upstream.
The identity mapping is suboptimal for the last 2GB frame. The mapping will be established with a mix of 4KB and 1MB mappings instead of a single 2GB mapping.
This happens because of a off-by-one bug introduced with commit 50be63450728 ("s390/mm: Convert bootmem to memblock").
Currently the identity mapping looks like this:
0x0000000080000000-0x0000000180000000 4G PUD RW
0x0000000180000000-0x00000001fff00000 2047M PMD RW
0x00000001fff00000-0x0000000200000000 1M PTE RW
With the bug fixed it looks like this:
0x0000000080000000-0x0000000200000000 6G PUD RW
--- arch/s390/mm/vmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/mm/vmem.c +1 -1
@@ -380,7 +380,7 @@ void __init vmem_map_init(void) ro_end = (unsigned long )&_eshared &PAGE_MASK ;for_each_memblock (memory, reg) { start = reg->base; - end = reg->base + reg->size -1 ; + end = reg->base + reg->size;if (start >= ro_end || end <= ro_start)vmem_add_mem (start, end - start,0 );else if (start >= ro_start && end <= ro_end)
PATCH 221/305 cifs: use CIFS_MAX_DOMAINNAME_LEN when converting the domain name
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Marchand <[email protected]>
commit 202d772ba02b1deb8835a631cd8255943d1906a0 upstream.
Currently in build_ntlmssp_auth_blob(), when converting the domain name to UTF16, CIFS_MAX_USERNAME_LEN limit is used. It should be CIFS_MAX_DOMAINNAME_LEN. This patch fixes this.
--- fs/cifs/sess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/sess.c +1 -1
@@ -429,7 +429,7 @@ int build_ntlmssp_auth_blob(unsigned cha }else {int len; len =cifs_strtoUTF16 ((__le16 *)tmp, ses->domainName, -CIFS_MAX_USERNAME_LEN , nls_cp); +CIFS_MAX_DOMAINNAME_LEN , nls_cp); len *=2 ;/* unicode is 2 bytes each */ sec_blob->DomainName.BufferOffset =cpu_to_le32 (tmp - pbuffer); sec_blob->DomainName.Length =cpu_to_le16 (len);
PATCH 250/305 net: phy: Manage fixed PHY address space using IDA
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit 69fc58a57e56bf5e39b48809aefffdaa1b04c945 upstream.
If we have a system which uses fixed PHY devices and calls fixed_phy_register() then fixed_phy_unregister() we can exhaust the number of fixed PHYs available after a while, since we keep incrementing the variable phy_fixed_addr, but we never decrement it.
This patch fixes that by converting the fixed PHY allocation to using IDA, which takes care of the allocation/dealloaction of the PHY addresses for us.
[bwh: Backported to 3.16:
- Adjust filename, context
- fixed_phy_register() returns an integer, not a pointer/error]
--- drivers/net/phy/fixed.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/net/phy/fixed.c +11 -11
@@ -22,6 +22,7 @@#include <linux/err.h> #include <linux/slab.h> #include <linux/of.h> +#include <linux/idr.h> #define MII_REGS_NUM 29
@@ -204,6 +205,8 @@ err_regs: }EXPORT_SYMBOL_GPL (fixed_phy_add); +static DEFINE_IDA (phy_fixed_ida); +void fixed_phy_del (int phy_addr) {struct fixed_mdio_bus *fmb = &platform_fmb;
@@ -213,15 +216,13 @@ void fixed_phy_del(int phy_addr)if (fp->addr == phy_addr) {list_del (&fp->node);kfree (fp); +ida_simple_remove (&phy_fixed_ida, phy_addr);return ; } } }EXPORT_SYMBOL_GPL (fixed_phy_del); -static int phy_fixed_addr; -static DEFINE_SPINLOCK (phy_fixed_addr_lock); -int fixed_phy_register (unsigned int irq,struct fixed_phy_status *status,struct device_node *np)
@@ -232,17 +233,15 @@ int fixed_phy_register(unsigned int irq,int ret;/* Get the next available PHY address, up to PHY_MAX_ADDR */ -spin_lock (&phy_fixed_addr_lock); -if (phy_fixed_addr ==PHY_MAX_ADDR ) { -spin_unlock (&phy_fixed_addr_lock); -return -ENOSPC ; - } - phy_addr = phy_fixed_addr++; -spin_unlock (&phy_fixed_addr_lock); + phy_addr =ida_simple_get (&phy_fixed_ida,0 ,PHY_MAX_ADDR ,GFP_KERNEL ); +if (phy_addr <0 ) +return phy_addr; ret =fixed_phy_add (irq, phy_addr, status); -if (ret <0 ) +if (ret <0 ) { +ida_simple_remove (&phy_fixed_ida, phy_addr);return ret; + } phy =get_phy_device (fmb->mii_bus, phy_addr, false);if (!phy ||IS_ERR (phy)) {
@@ -317,6 +316,7 @@ static void __exit fixed_mdio_bus_exit(vlist_del (&fp->node);kfree (fp); } +ida_destroy (&phy_fixed_ida); }module_exit (fixed_mdio_bus_exit);
PATCH 59/305 USB: serial: mxuport: fix use-after-free in probe error path
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 9e45284984096314994777f27e1446dfbfd2f0d7 upstream.
The interface read and event URBs are submitted in attach, but were never explicitly unlinked by the driver. Instead the URBs would have been killed by usb-serial core on disconnect.
In case of a late probe error (e.g. due to failed minor allocation), disconnect is never called and we could end up with active URBs for an unbound interface. This in turn could lead to deallocated memory being dereferenced in the completion callbacks.
driver")
--- drivers/usb/serial/mxuport.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/usb/serial/mxuport.c +10 -0
@@ -1263,6 +1263,15 @@ static int mxuport_attach(struct usb_serreturn 0 ; } +static void mxuport_release (struct usb_serial *serial) +{ +struct usb_serial_port *port0 = serial->port[0 ]; +struct usb_serial_port *port1 = serial->port[1 ]; + +usb_serial_generic_close (port1); +usb_serial_generic_close (port0); +} +static int mxuport_open (struct tty_struct *tty,struct usb_serial_port *port) {struct mxuport_port *mxport =usb_get_serial_port_data (port);
@@ -1365,6 +1374,7 @@ static struct usb_serial_driver mxuport_ .probe = mxuport_probe, .port_probe = mxuport_port_probe, .attach = mxuport_attach, + .release = mxuport_release, .calc_num_ports = mxuport_calc_num_ports, .open = mxuport_open, .close = mxuport_close,
PATCH 215/305 IB/mlx4: Fix the SQ size of an RC QP
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
commit f2940e2c76bb554a7fbdd28ca5b90904117a9e96 upstream.
When calculating the required size of an RC QP send queue, leave enough space for masked atomic operations, which require more space than "regular" atomic operation.
--- drivers/infiniband/hw/mlx4/qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/qp.c +1 -1
@@ -361,7 +361,7 @@ static int send_wqe_overhead(enum mlx4_isizeof (struct mlx4_wqe_raddr_seg );case MLX4_IB_QPT_RC :return sizeof (struct mlx4_wqe_ctrl_seg ) + -sizeof (struct mlx4_wqe_atomic_seg ) + +sizeof (struct mlx4_wqe_masked_atomic_seg ) +sizeof (struct mlx4_wqe_raddr_seg );case MLX4_IB_QPT_SMI :case MLX4_IB_QPT_GSI :
PATCH 67/305 arm64: cpuinfo: Missing NULL terminator in compat_hwcap_str
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Julien Grall <[email protected]>
commit f228b494e56d949be8d8ea09d4f973d1979201bf upstream.
The loop that browses the array compat_hwcap_str will stop when a NULL is encountered, however NULL is missing at the end of array. This will lead to overrun until a NULL is found somewhere in the following memory. In reality, this works out because the compat_hwcap2_str array tends to follow immediately in memory, and that *is* terminated correctly. Furthermore, the unsigned int compat_elf_hwcap is checked before printing each capability, so we end up doing the right thing because the size of the two arrays is less than 32. Still, this is an obvious mistake and should be fixed.
Note for backporting: commit 12d11817eaafa414 ("arm64: Move /proc/cpuinfo handling code") moved this code in v4.4. Prior to that commit, the same change should be made in arch/arm64/kernel/setup.c.
--- arch/arm64/kernel/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/kernel/setup.c +2 -1
@@ -481,7 +481,8 @@ static const char *compat_hwcap_str[] ="idivt" ,"vfpd32" ,"lpae" , -"evtstrm" +"evtstrm" , +NULL };#endif /* CONFIG_COMPAT */
PATCH 257/305 qlcnic: use the correct ring in qlcnic_83xx_process_rcv_ring_diag()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 5b4d10f5e0369ed79434593b7cd8e85eebbe473f upstream.
There is a static checker warning here "warn: mask and shift to zero" and the code sets "ring" to zero every time. From looking at how QLCNIC_FETCH_RING_ID() is used in qlcnic_83xx_process_rcv_ring() the qlcnic_83xx_hndl() should be removed.
--- drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c +1 -1
@@ -2198,7 +2198,7 @@ void qlcnic_83xx_process_rcv_ring_diag(sif (!opcode)return ; - ring =QLCNIC_FETCH_RING_ID (qlcnic_83xx_hndl (sts_data[0 ])); + ring =QLCNIC_FETCH_RING_ID (sts_data[0 ]);qlcnic_83xx_process_rcv_diag (adapter, ring, sts_data); desc = &sds_ring->desc_head[consumer]; desc->status_desc_data[0 ] =cpu_to_le64 (STATUS_OWNER_PHANTOM );
PATCH 136/305 arm64: Provide "model name" in /proc/cpuinfo for PER_LINUX32 tasks
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit e47b020a323d1b2a7b1e9aac86e99eae19463630 upstream.
This patch brings the PER_LINUX32 /proc/cpuinfo format more in line with the 32-bit ARM one by providing an additional line:
model name : ARMv8 Processor rev X (v8l)
[bwh: Backported to 3.16:
- Adjust filename, context
- Open-code MIDR_REVISION()]
--- arch/arm64/include/asm/elf.h | 4 ++-- arch/arm64/kernel/setup.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-)
arch/arm64/include/asm/elf.h +2 -2
@@ -161,14 +161,14 @@ struct mm_struct;extern unsigned long arch_randomize_brk (struct mm_struct *mm);#define arch_randomize_brk arch_randomize_brk -#ifdef CONFIG_COMPAT -#ifdef __AARCH64EB__#define COMPAT_ELF_PLATFORM ("v8b")#else #define COMPAT_ELF_PLATFORM ("v8l")#endif +#ifdef CONFIG_COMPAT +#define COMPAT_ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_32 / 3))/* AArch32 registers. */
arch/arm64/kernel/setup.c +7 -1
@@ -44,6 +44,8 @@#include <linux/of_platform.h> #include <linux/efi.h> #include <linux/personality.h> +#include <linux/compat.h> +#include <linux/elf.h> #include <asm/fixmap.h> #include <asm/cputype.h>
@@ -489,6 +491,7 @@ static const char *compat_hwcap_str[] =static int c_show (struct seq_file *m,void *v) {int i, j; +bool compat =personality (current->personality) ==PER_LINUX32 ;for_each_online_cpu (i) {struct cpuinfo_arm64 *cpuinfo = &per_cpu (cpu_data, i);
@@ -500,6 +503,9 @@ static int c_show(struct seq_file *m, vo* "processor". Give glibc what it expects. */ #ifdef CONFIG_SMP +if (compat) +seq_printf (m,"model name\t: ARMv8 Processor rev %d (%s)\n" , + midr &0xf ,COMPAT_ELF_PLATFORM );seq_printf (m,"processor\t: %d\n" , i);#endif
@@ -514,7 +520,7 @@ static int c_show(struct seq_file *m, vo* software which does already (at least for 32-bit). */ seq_puts (m,"Features\t:" ); -if (personality (current->personality) ==PER_LINUX32 ) { +if (compat) {#ifdef CONFIG_COMPAT for (j =0 ; compat_hwcap_str[j]; j++)if (compat_elf_hwcap & (1 << j))
PATCH 143/305 ALSA: hda - Fix headset mic detection problem for Dell machine
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: AceLan Kao <[email protected]>
commit f90d83b301701026b2e4c437a3613f377f63290e upstream.
Add the pin configuration value of this machine into the pin_quirk table to make DELL1_MIC_NO_PRESENCE apply to this machine.
--- sound/pci/hda/patch_realtek.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/pci/hda/patch_realtek.c +4 -0
@@ -5182,6 +5182,10 @@ static const struct snd_hda_pin_quirk al {0x1d, 0x40700001}, {0x1e, 0x411111f0}, {0x21, 0x02211040}), + SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, + {0x12, 0x90a60180}, + {0x14, 0x90170120}, + {0x21, 0x02211030}), SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1, {0x12, 0x99a30130}, {0x14, 0x90170110},
PATCH 272/305 tmpfs: fix regression hang in fallocate undo
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hugh Dickins <[email protected]>
commit 7f556567036cb7f89aabe2f0954b08566b4efb53 upstream.
The well-spotted fallocate undo fix is good in most cases, but not when fallocate failed on the very first page. index 0 then passes lend -1 to shmem_undo_range(), and that has two bad effects: (a) that it will undo every fallocation throughout the file, unrestricted by the current range; but more importantly (b) it can cause the undo to hang, because lend -1 is treated as truncation, which makes it keep on retrying until every page has gone, but those already fully instantiated will never go away. Big thank you to xfstests generic/269 which demonstrates this.
--- mm/shmem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
mm/shmem.c +5 -3
@@ -1865,9 +1865,11 @@ static long shmem_fallocate(struct file NULL);if (error) {/* Remove the !PageUptodate pages we added */ -shmem_undo_range (inode, - (loff_t )start <<PAGE_CACHE_SHIFT , - ((loff_t )index <<PAGE_CACHE_SHIFT ) -1 , true); +if (index > start) { +shmem_undo_range (inode, + (loff_t )start <<PAGE_CACHE_SHIFT , + ((loff_t )index <<PAGE_CACHE_SHIFT ) -1 , true); + } goto undone; }
PATCH 39/305 char: Drop bogus dependency of DEVPORT on !M68K
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit 309124e2648d668a0c23539c5078815660a4a850 upstream.
According to full-history-linux commit d3794f4fa7c3edc3 ("[PATCH] M68k update (part 25)"), port operations are allowed on m68k if CONFIG_ISA is defined.
However, commit 153dcc54df826d2f ("[PATCH] mem driver: fix conditional on isa i/o support") accidentally changed an "||" into an "&&", disabling it completely on m68k. This logic was retained when introducing the DEVPORT symbol in commit 4f911d64e04a44c4 ("Make /dev/port conditional on config symbol").
Drop the bogus dependency on !M68K to fix this.
--- drivers/char/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/char/Kconfig +0 -1
@@ -575,7 +575,6 @@ config TELCLOCK config DEVPORT bool - depends on !M68K depends on ISA || PCI default y
PATCH 13/305 ARM: OMAP2+: hwmod: fix _idle() hwmod state sanity check sequence
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Suman Anna <[email protected]>
commit c20c8f750d9f8f8617f07ee2352d3ff560e66bc2 upstream.
The omap_hwmod _enable() function can return success without setting the hwmod state to _HWMOD_STATE_ENABLED for IPs with reset lines when all of the reset lines are asserted. The omap_hwmod _idle() function also performs a similar check, but after checking for the hwmod state first. This triggers the WARN when pm_runtime_get and pm_runtime_put are invoked on IPs with all reset lines asserted. Reverse the checks for hwmod state and reset lines status to fix this.
Issue found during a unbind operation on a device with reset lines still asserted, example backtrace below
------------[ cut here ]------------ WARNING: CPU: 1 PID: 879 at arch/arm/mach-omap2/omap_hwmod.c:2207 _idle+0x1e4/0x240() omap_hwmod: mmu_dsp: idle state can only be entered from enabled state Modules linked in: CPU: 1 PID: 879 Comm: sh Not tainted 4.4.0-00008-ga989d951331a #3 Hardware name: Generic OMAP5 (Flattened Device Tree) [<c0018e60>] (unwind_backtrace) from [<c0014dc4>] (show_stack+0x10/0x14) [<c0014dc4>] (show_stack) from [<c037ac28>] (dump_stack+0x90/0xc0) [<c037ac28>] (dump_stack) from [<c003f420>] (warn_slowpath_common+0x78/0xb4) [<c003f420>] (warn_slowpath_common) from [<c003f48c>] (warn_slowpath_fmt+0x30/0x40) [<c003f48c>] (warn_slowpath_fmt) from [<c0028c20>] (_idle+0x1e4/0x240) [<c0028c20>] (_idle) from [<c0029080>] (omap_hwmod_idle+0x28/0x48) [<c0029080>] (omap_hwmod_idle) from [<c002a5a4>] (omap_device_idle+0x3c/0x90) [<c002a5a4>] (omap_device_idle) from [<c0427a90>] (__rpm_callback+0x2c/0x60) [<c0427a90>] (__rpm_callback) from [<c0427ae4>] (rpm_callback+0x20/0x80) [<c0427ae4>] (rpm_callback) from [<c0427f84>] (rpm_suspend+0x138/0x74c) [<c0427f84>] (rpm_suspend) from [<c0428b78>] (__pm_runtime_idle+0x78/0xa8) [<c0428b78>] (__pm_runtime_idle) from [<c041f514>] (__device_release_driver+0x64/0x100) [<c041f514>] (__device_release_driver) from [<c041f5d0>] (device_release_driver+0x20/0x2c) [<c041f5d0>] (device_release_driver) from [<c041d85c>] (unbind_store+0x78/0xf8) [<c041d85c>] (unbind_store) from [<c0206df8>] (kernfs_fop_write+0xc0/0x1c4) [<c0206df8>] (kernfs_fop_write) from [<c018a120>] (__vfs_write+0x20/0xdc) [<c018a120>] (__vfs_write) from [<c018a9cc>] (vfs_write+0x90/0x164) [<c018a9cc>] (vfs_write) from [<c018b1f0>] (SyS_write+0x44/0x9c) [<c018b1f0>] (SyS_write) from [<c0010420>] (ret_fast_syscall+0x0/0x1c) ---[ end trace a4182013c75a9f50 ]---
While at this, fix the sequence in _shutdown() as well, though there is no easy reproducible scenario.
--- arch/arm/mach-omap2/omap_hwmod.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +6 -6
@@ -2263,15 +2263,15 @@ static int _idle(struct omap_hwmod *oh) {pr_debug ("omap_hwmod: %s: idling\n" , oh->name); +if (_are_all_hardreset_lines_asserted (oh)) +return 0 ; +if (oh->_state != _HWMOD_STATE_ENABLED) {WARN (1 ,"omap_hwmod: %s: idle state can only be entered from enabled state\n" , oh->name);return -EINVAL ; } -if (_are_all_hardreset_lines_asserted (oh)) -return 0 ; -if (oh->class->sysc)_idle_sysc (oh);_del_initiator_dep (oh, mpu_oh);
@@ -2318,6 +2318,9 @@ static int _shutdown(struct omap_hwmod *int ret, i;u8 prev_state; +if (_are_all_hardreset_lines_asserted (oh)) +return 0 ; +if (oh->_state != _HWMOD_STATE_IDLE && oh->_state != _HWMOD_STATE_ENABLED) { WARN(1, "omap_hwmod: %s: disabled state can only be entered from idle, or enabled state\n",
@@ -2325,9 +2328,6 @@ static int _shutdown(struct omap_hwmod *return -EINVAL ; } -if (_are_all_hardreset_lines_asserted (oh)) -return 0 ; -pr_debug ("omap_hwmod: %s: disabling\n" , oh->name);if (oh->class->pre_shutdown) {
PATCH 219/305 Input: wacom_w8001 - w8001_MAX_LENGTH should be 13
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ping Cheng <[email protected]>
commit 12afb34400eb2b301f06b2aa3535497d14faee59 upstream.
Somehow the patch that added two-finger touch support forgot to update W8001_MAX_LENGTH from 11 to 13.
--- drivers/input/touchscreen/wacom_w8001.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/wacom_w8001.c +1 -1
@@ -27,7 +27,7 @@ MODULE_AUTHOR("Jaya Kumar <jayakumar.lkmMODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" ); -#define W8001_MAX_LENGTH 11 +#define W8001_MAX_LENGTH 13#define W8001_LEAD_MASK 0x80#define W8001_LEAD_BYTE 0x80#define W8001_TAB_MASK 0x40
PATCH 251/305 batman-adv: Fix memory leak on tt add with invalid vlan
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit fd7dec25a18f495e50d2040398fd263836ff3b28 upstream.
The object tt_local is allocated with kmalloc and not initialized when the function batadv_tt_local_add checks for the vlan. But this function can only cleanup the object when the (not yet initialized) reference counter of the object is 1. This is unlikely and thus the object would leak when the vlan could not be found.
Instead the uninitialized object tt_local has to be freed manually and the pointer has to set to NULL to avoid calling the function which would try to decrement the reference counter of the not existing object.
CID: 1316518
--- net/batman-adv/translation-table.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/batman-adv/translation-table.c +4 -1
@@ -577,8 +577,11 @@ bool batadv_tt_local_add(struct net_devi/* increase the refcounter of the related vlan */ vlan =batadv_softif_vlan_get (bat_priv, vid);if (WARN (!vlan,"adding TT local entry %pM to non-existent VLAN %d" , - addr,BATADV_PRINT_VID (vid))) + addr,BATADV_PRINT_VID (vid))) { +kfree (tt_local); + tt_local =NULL ; goto out; + } batadv_dbg(BATADV_DBG_TT, bat_priv, "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n",
PATCH 45/305 USB: serial: option: add even more ZTE device ids
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lei Liu <[email protected]>
commit 74d2a91aec97ab832790c9398d320413ad185321 upstream.
Add even more ZTE device ids.
--- drivers/usb/serial/option.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
drivers/usb/serial/option.c +54 -0
@@ -1712,6 +1712,60 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff92, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff9f, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa0, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa1, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa2, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa3, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa4, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa5, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa6, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa7, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa8, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffa9, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffaa, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffab, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffac, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffae, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffaf, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb0, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb1, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb2, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb3, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb4, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb5, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb6, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb7, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb8, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffb9, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffba, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbb, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbc, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbd, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbe, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffbf, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc0, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc1, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc2, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc3, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc4, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc5, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc6, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc7, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc8, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffc9, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffca, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcb, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcc, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcd, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffce, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffcf, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd0, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd1, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd2, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd3, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd4, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffd5, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xffe9, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
PATCH 118/305 UBI: fix missing brace control flow
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Brian Norris <[email protected]>
commit b388e6a7a6ba988998ddd83919ae8d3debf1a13d upstream.
commit 0e707ae79ba3 ("UBI: do propagate positive error codes up") seems to have produced an unintended change in the control flow here.
Completely untested, but it looks obvious.
Caught by Coverity, which didn't like the indentation. CID 1271184.
--- drivers/mtd/ubi/eba.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/ubi/eba.c +2 -1
@@ -425,9 +425,10 @@ retry:ubi_warn ("corrupted VID header at PEB %d, LEB %d:%d" , pnum, vol_id, lnum); err = -EBADMSG ; - }else + }else { err = -EINVAL ;ubi_ro_mode (ubi); + } } goto out_free; }else if (err ==UBI_IO_BITFLIPS )
PATCH 264/305 block: fix use-after-free in sys_ioprio_get()
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Omar Sandoval <[email protected]>
commit 8ba8682107ee2ca3347354e018865d8e1967c5f4 upstream.
get_task_ioprio() accesses the task->io_context without holding the task lock and thus can race with exit_io_context(), leading to a use-after-free. The reproducer below hits this within a few seconds on my 4-core QEMU VM:
#define _GNU_SOURCE
#include <assert.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/wait.h>
int main(int argc, char **argv)
{
pid_t pid, child;
long nproc, i;
/* ioprio_set(IOPRIO_WHO_PROCESS, 0, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)); */
syscall(SYS_ioprio_set, 1, 0, 0x6000);
nproc = sysconf(_SC_NPROCESSORS_ONLN);
for (i = 0; i < nproc; i++) {
pid = fork();
assert(pid != -1);
if (pid == 0) {
for (;;) {
pid = fork();
assert(pid != -1);
if (pid == 0) {
_exit(0);
} else {
child = wait(NULL);
assert(child == pid);
}
}
}
pid = fork();
assert(pid != -1);
if (pid == 0) {
for (;;) {
/* ioprio_get(IOPRIO_WHO_PGRP, 0); */
syscall(SYS_ioprio_get, 2, 0);
}
}
}
for (;;) {
/* ioprio_get(IOPRIO_WHO_PGRP, 0); */
syscall(SYS_ioprio_get, 2, 0);
}
return 0;
}This gets us KASAN dumps like this:
[ 35.526914] ================================================================== [ 35.530009] BUG: KASAN: out-of-bounds in get_task_ioprio+0x7b/0x90 at addr ffff880066f34e6c [ 35.530009] Read of size 2 by task ioprio-gpf/363 [ 35.530009] ============================================================================= [ 35.530009] BUG blkdev_ioc (Not tainted): kasan: bad access detected [ 35.530009] -----------------------------------------------------------------------------
[ 35.530009] Disabling lock debugging due to kernel taint [ 35.530009] INFO: Allocated in create_task_io_context+0x2b/0x370 age=0 cpu=0 pid=360 [ 35.530009] ___slab_alloc+0x55d/0x5a0 [ 35.530009] __slab_alloc.isra.20+0x2b/0x40 [ 35.530009] kmem_cache_alloc_node+0x84/0x200 [ 35.530009] create_task_io_context+0x2b/0x370 [ 35.530009] get_task_io_context+0x92/0xb0 [ 35.530009] copy_process.part.8+0x5029/0x5660 [ 35.530009] _do_fork+0x155/0x7e0 [ 35.530009] SyS_clone+0x19/0x20 [ 35.530009] do_syscall_64+0x195/0x3a0 [ 35.530009] return_from_SYSCALL_64+0x0/0x6a [ 35.530009] INFO: Freed in put_io_context+0xe7/0x120 age=0 cpu=0 pid=1060 [ 35.530009] __slab_free+0x27b/0x3d0 [ 35.530009] kmem_cache_free+0x1fb/0x220 [ 35.530009] put_io_context+0xe7/0x120 [ 35.530009] put_io_context_active+0x238/0x380 [ 35.530009] exit_io_context+0x66/0x80 [ 35.530009] do_exit+0x158e/0x2b90 [ 35.530009] do_group_exit+0xe5/0x2b0 [ 35.530009] SyS_exit_group+0x1d/0x20 [ 35.530009] entry_SYSCALL_64_fastpath+0x1a/0xa4 [ 35.530009] INFO: Slab 0xffffea00019bcd00 objects=20 used=4 fp=0xffff880066f34ff0 flags=0x1fffe0000004080 [ 35.530009] INFO: Object 0xffff880066f34e58 @offset=3672 fp=0x0000000000000001 [ 35.530009] ==================================================================
Fix it by grabbing the task lock while we poke at the io_context.
--- block/ioprio.c | 2 ++ 1 file changed, 2 insertions(+)
block/ioprio.c +2 -0
@@ -149,8 +149,10 @@ static int get_task_ioprio(struct task_sif (ret) goto out; ret =IOPRIO_PRIO_VALUE (IOPRIO_CLASS_NONE ,IOPRIO_NORM ); +task_lock (p);if (p->io_context) ret = p->io_context->ioprio; +task_unlock (p); out:return ret; }
PATCH 291/305 netfilter: x_tables: kill check_entry helper
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit aa412ba225dd3bc36d404c28cdc3d674850d80d0 upstream.
Once we add more sanity testing to xt_check_entry_offsets it becomes relvant if we're expecting a 32bit 'config_compat' blob or a normal one.
Since we already have a lot of similar-named functions (check_entry, compat_check_entry, find_and_check_entry, etc.) and the current incarnation is short just fold its contents into the callers.
--- net/ipv4/netfilter/arp_tables.c | 19 ++++++++----------- net/ipv4/netfilter/ip_tables.c | 20 ++++++++------------ net/ipv6/netfilter/ip6_tables.c | 20 ++++++++------------ 3 files changed, 24 insertions(+), 35 deletions(-)
net/ipv4/netfilter/arp_tables.c +8 -11
@@ -491,14 +491,6 @@ static int mark_source_chains(const strureturn 1 ; } -static inline int check_entry (const struct arpt_entry *e) -{ -if (!arp_checkentry (&e->arp)) -return -EINVAL ; - -return xt_check_entry_offsets (e, e->target_offset, e->next_offset); -} -static inline int check_target (struct arpt_entry *e,const char *name) {struct xt_entry_target *t =arpt_get_target (e);
@@ -588,7 +580,10 @@ static inline int check_entry_size_and_hreturn -EINVAL ; } - err =check_entry (e); +if (!arp_checkentry (&e->arp)) +return -EINVAL ; + + err =xt_check_entry_offsets (e, e->target_offset, e->next_offset);if (err)return err;
@@ -1247,8 +1242,10 @@ check_compat_entry_size_and_hooks(structreturn -EINVAL ; } -/* For purposes of check_entry casting the compat entry is fine */ - ret =check_entry ((struct arpt_entry *)e); +if (!arp_checkentry (&e->arp)) +return -EINVAL ; + + ret =xt_check_entry_offsets (e, e->target_offset, e->next_offset);if (ret)return ret;
net/ipv4/netfilter/ip_tables.c +8 -12
@@ -585,15 +585,6 @@ static void cleanup_match(struct xt_entr }static int -check_entry (const struct ipt_entry *e) -{ -if (!ip_checkentry (&e->ip)) -return -EINVAL ; - -return xt_check_entry_offsets (e, e->target_offset, e->next_offset); -} - -static int check_match (struct xt_entry_match *m,struct xt_mtchk_param *par) {const struct ipt_ip *ip = par->entryinfo;
@@ -749,7 +740,10 @@ check_entry_size_and_hooks(struct ipt_enreturn -EINVAL ; } - err =check_entry (e); +if (!ip_checkentry (&e->ip)) +return -EINVAL ; + + err =xt_check_entry_offsets (e, e->target_offset, e->next_offset);if (err)return err;
@@ -1513,8 +1507,10 @@ check_compat_entry_size_and_hooks(structreturn -EINVAL ; } -/* For purposes of check_entry casting the compat entry is fine */ - ret =check_entry ((struct ipt_entry *)e); +if (!ip_checkentry (&e->ip)) +return -EINVAL ; + + ret =xt_check_entry_offsets (e, e->target_offset, e->next_offset);if (ret)return ret;
net/ipv6/netfilter/ip6_tables.c +8 -12
@@ -594,15 +594,6 @@ static void cleanup_match(struct xt_entrmodule_put (par.match->me); } -static int -check_entry (const struct ip6t_entry *e) -{ -if (!ip6_checkentry (&e->ipv6)) -return -EINVAL ; - -return xt_check_entry_offsets (e, e->target_offset, e->next_offset); -} -static int check_match (struct xt_entry_match *m,struct xt_mtchk_param *par) {const struct ip6t_ip6 *ipv6 = par->entryinfo;
@@ -760,7 +751,10 @@ check_entry_size_and_hooks(struct ip6t_ereturn -EINVAL ; } - err =check_entry (e); +if (!ip6_checkentry (&e->ipv6)) +return -EINVAL ; + + err =xt_check_entry_offsets (e, e->target_offset, e->next_offset);if (err)return err;
@@ -1525,8 +1519,10 @@ check_compat_entry_size_and_hooks(structreturn -EINVAL ; } -/* For purposes of check_entry casting the compat entry is fine */ - ret =check_entry ((struct ip6t_entry *)e); +if (!ip6_checkentry (&e->ipv6)) +return -EINVAL ; + + ret =xt_check_entry_offsets (e, e->target_offset, e->next_offset);if (ret)return ret;
PATCH 115/305 wait/ptrace: assume __WALL if the child is traced
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
commit bf959931ddb88c4e4366e96dd22e68fa0db9527c upstream.
The following program (simplified version of generated by syzkaller)
#include <pthread.h>
#include <unistd.h>
#include <sys/ptrace.h>
#include <stdio.h>
#include <signal.h>
void *thread_func(void *arg)
{
ptrace(PTRACE_TRACEME, 0,0,0);
return 0;
}
int main(void)
{
pthread_t thread;
if (fork())
return 0;
while (getppid() != 1)
;
pthread_create(&thread, NULL, thread_func, NULL);
pthread_join(thread, NULL);
return 0;
}creates an unreapable zombie if /sbin/init doesn't use __WALL.
This is not a kernel bug, at least in a sense that everything works as
expected: debugger should reap a traced sub-thread before it can reap the leader, but without __WALL/__WCLONE do_wait() ignores sub-threads.
Unfortunately, it seems that /sbin/init in most (all?) distributions doesn't use it and we have to change the kernel to avoid the problem. Note also that most init's use sys_waitid() which doesn't allow __WALL, so the necessary user-space fix is not that trivial.
This patch just adds the "ptrace" check into eligible_child(). To some degree this matches the "tsk->ptrace" in exit_notify(), ->exit_signal is mostly ignored when the tracee reports to debugger. Or WSTOPPED, the tracer doesn't need to set this flag to wait for the stopped tracee.
This obviously means the user-visible change: __WCLONE and __WALL no longer have any meaning for debugger. And I can only hope that this won't break something, but at least strace/gdb won't suffer.
We could make a more conservative change. Say, we can take __WCLONE into account, or !thread_group_leader(). But it would be nice to not complicate these historical/confusing checks.
--- kernel/exit.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
kernel/exit.c +20 -9
@@ -924,17 +924,28 @@ static int eligible_pid(struct wait_optstask_pid_type (p, wo->wo_type) == wo->wo_pid; } -static int eligible_child (struct wait_opts *wo,struct task_struct *p) +static int +eligible_child (struct wait_opts *wo,bool ptrace,struct task_struct *p) {if (!eligible_pid (wo, p))return 0 ; -/* Wait for all children (clone and not) if __WALL is set; -* otherwise, wait for clone children *only* if __WCLONE is -* set; otherwise, wait for non-clone children *only*. (Note: -* A "clone" child here is one that reports to its parent -* using a signal other than SIGCHLD.) */ -if (((p->exit_signal !=SIGCHLD ) ^ !!(wo->wo_flags & __WCLONE)) - && !(wo->wo_flags & __WALL)) + +/* +* Wait for all children (clone and not) if __WALL is set or +* if it is traced by us. +*/ +if (ptrace || (wo->wo_flags & __WALL)) +return 1 ; + +/* +* Otherwise, wait for clone children *only* if __WCLONE is set; +* otherwise, wait for non-clone children *only*. +* +* Note: a "clone" child here is one that reports to its parent +* using a signal other than SIGCHLD, or a non-leader thread which +* we can only see if it is traced by us. +*/ +if ((p->exit_signal !=SIGCHLD ) ^ !!(wo->wo_flags & __WCLONE))return 0 ;return 1 ;
@@ -1305,7 +1316,7 @@ static int wait_consider_task(struct waiif (unlikely (exit_state ==EXIT_DEAD ))return 0 ; - ret =eligible_child (wo, p); + ret =eligible_child (wo, ptrace, p);if (!ret)return ret;
PATCH 135/305 mac80211: mesh: flush mesh paths unconditionally
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Bob Copeland <[email protected]>
commit fe7a7c57629e8dcbc0e297363a9b2366d67a6dc5 upstream.
Currently, the mesh paths associated with a nexthop station are cleaned up in the following code path:
__sta_info_destroy_part1
synchronize_net()
__sta_info_destroy_part2
-> cleanup_single_sta
-> mesh_sta_cleanup
-> mesh_plink_deactivate
-> mesh_path_flush_by_nexthopHowever, there are a couple of problems here:
1) the paths aren't flushed at all if the MPM is running in userspace (e.g. when using wpa_supplicant or authsae)
2) there is no synchronize_rcu between removing the path and readers accessing the nexthop, which means the following race is possible:
CPU0 CPU1
~~~~ ~~~~
sta_info_destroy_part1() synchronize_net()rcu_read_lock()mesh_nexthop_resolve()
mpath = mesh_path_lookup()
[...] -> mesh_path_flush_by_nexthop()
sta = rcu_dereference(
mpath->next_hop)
kfree(sta)access sta <-- CRASH
Fix both of these by unconditionally flushing paths before destroying the sta, and by adding a synchronize_net() after path flush to ensure no active readers can still dereference the sta.
Fixes this crash:
[ 348.529295] BUG: unable to handle kernel paging request at 00020040 [ 348.530014] IP: [<f929245d>] ieee80211_mps_set_frame_flags+0x40/0xaa [mac80211] [ 348.530014] *pde = 00000000 [ 348.530014] Oops: 0000 [#1] PREEMPT [ 348.530014] Modules linked in: drbg ansi_cprng ctr ccm ppp_generic slhc ipt_MASQUERADE nf_nat_masquerade_ipv4 8021q ] [ 348.530014] CPU: 0 PID: 20597 Comm: wget Tainted: G O 4.6.0-rc5-wt=V1 #1 [ 348.530014] Hardware name: To Be Filled By O.E.M./To be filled by O.E.M., BIOS 080016 11/07/2014 [ 348.530014] task: f64fa280 ti: f4f9c000 task.ti: f4f9c000 [ 348.530014] EIP: 0060:[<f929245d>] EFLAGS: 00010246 CPU: 0 [ 348.530014] EIP is at ieee80211_mps_set_frame_flags+0x40/0xaa [mac80211] [ 348.530014] EAX: f4ce63e0 EBX: 00000088 ECX: f3788416 EDX: 00020008 [ 348.530014] ESI: 00000000 EDI: 00000088 EBP: f6409a4c ESP: f6409a40 [ 348.530014] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 0068 [ 348.530014] CR0: 80050033 CR2: 00020040 CR3: 33190000 CR4: 00000690 [ 348.530014] Stack: [ 348.530014] 00000000 f4ce63e0 f5f9bd80 f6409a64 f9291d80 0000ce67 f5d51e00 f4ce63e0 [ 348.530014] f3788416 f6409a80 f9291dc1 f4ce8320 f4ce63e0 f5d51e00 f4ce63e0 f4ce8320 [ 348.530014] f6409a98 f9277f6f 00000000 00000000 0000007c 00000000 f6409b2c f9278dd1 [ 348.530014] Call Trace: [ 348.530014] [<f9291d80>] mesh_nexthop_lookup+0xbb/0xc8 [mac80211] [ 348.530014] [<f9291dc1>] mesh_nexthop_resolve+0x34/0xd8 [mac80211] [ 348.530014] [<f9277f6f>] ieee80211_xmit+0x92/0xc1 [mac80211] [ 348.530014] [<f9278dd1>] __ieee80211_subif_start_xmit+0x807/0x83c [mac80211] [ 348.530014] [<c04df012>] ? sch_direct_xmit+0xd7/0x1b3 [ 348.530014] [<c022a8c6>] ? __local_bh_enable_ip+0x5d/0x7b [ 348.530014] [<f956870c>] ? nf_nat_ipv4_out+0x4c/0xd0 [nf_nat_ipv4] [ 348.530014] [<f957e036>] ? iptable_nat_ipv4_fn+0xf/0xf [iptable_nat] [ 348.530014] [<c04c6f45>] ? netif_skb_features+0x14d/0x30a [ 348.530014] [<f9278e10>] ieee80211_subif_start_xmit+0xa/0xe [mac80211] [ 348.530014] [<c04c769c>] dev_hard_start_xmit+0x1f8/0x267 [ 348.530014] [<c04c7261>] ? validate_xmit_skb.isra.120.part.121+0x10/0x253 [ 348.530014] [<c04defc6>] sch_direct_xmit+0x8b/0x1b3 [ 348.530014] [<c04c7a9c>] __dev_queue_xmit+0x2c8/0x513 [ 348.530014] [<c04c7cfb>] dev_queue_xmit+0xa/0xc [ 348.530014] [<f91bfc7a>] batadv_send_skb_packet+0xd6/0xec [batman_adv] [ 348.530014] [<f91bfdc4>] batadv_send_unicast_skb+0x15/0x4a [batman_adv] [ 348.530014] [<f91b5938>] batadv_dat_send_data+0x27e/0x310 [batman_adv] [ 348.530014] [<f91c30b5>] ? batadv_tt_global_hash_find.isra.11+0x8/0xa [batman_adv] [ 348.530014] [<f91b63f3>] batadv_dat_snoop_outgoing_arp_request+0x208/0x23d [batman_adv] [ 348.530014] [<f91c0cd9>] batadv_interface_tx+0x206/0x385 [batman_adv] [ 348.530014] [<c04c769c>] dev_hard_start_xmit+0x1f8/0x267 [ 348.530014] [<c04c7261>] ? validate_xmit_skb.isra.120.part.121+0x10/0x253 [ 348.530014] [<c04defc6>] sch_direct_xmit+0x8b/0x1b3 [ 348.530014] [<c04c7a9c>] __dev_queue_xmit+0x2c8/0x513 [ 348.530014] [<f80cbd2a>] ? igb_xmit_frame+0x57/0x72 [igb] [ 348.530014] [<c04c7cfb>] dev_queue_xmit+0xa/0xc [ 348.530014] [<f843a326>] br_dev_queue_push_xmit+0xeb/0xfb [bridge] [ 348.530014] [<f843a35f>] br_forward_finish+0x29/0x74 [bridge] [ 348.530014] [<f843a23b>] ? deliver_clone+0x3b/0x3b [bridge] [ 348.530014] [<f843a714>] __br_forward+0x89/0xe7 [bridge] [ 348.530014] [<f843a336>] ? br_dev_queue_push_xmit+0xfb/0xfb [bridge] [ 348.530014] [<f843a234>] deliver_clone+0x34/0x3b [bridge] [ 348.530014] [<f843a68b>] ? br_flood+0x95/0x95 [bridge] [ 348.530014] [<f843a66d>] br_flood+0x77/0x95 [bridge] [ 348.530014] [<f843a809>] br_flood_forward+0x13/0x1a [bridge] [ 348.530014] [<f843a68b>] ? br_flood+0x95/0x95 [bridge] [ 348.530014] [<f843b877>] br_handle_frame_finish+0x392/0x3db [bridge] [ 348.530014] [<c04e9b2b>] ? nf_iterate+0x2b/0x6b [ 348.530014] [<f843baa6>] br_handle_frame+0x1e6/0x240 [bridge] [ 348.530014] [<f843b4e5>] ? br_handle_local_finish+0x6a/0x6a [bridge] [ 348.530014] [<c04c4ba0>] __netif_receive_skb_core+0x43a/0x66b [ 348.530014] [<f843b8c0>] ? br_handle_frame_finish+0x3db/0x3db [bridge] [ 348.530014] [<c023cea4>] ? resched_curr+0x19/0x37 [ 348.530014] [<c0240707>] ? check_preempt_wakeup+0xbf/0xfe [ 348.530014] [<c0255dec>] ? ktime_get_with_offset+0x5c/0xfc [ 348.530014] [<c04c4fc1>] __netif_receive_skb+0x47/0x55 [ 348.530014] [<c04c57ba>] netif_receive_skb_internal+0x40/0x5a [ 348.530014] [<c04c61ef>] napi_gro_receive+0x3a/0x94 [ 348.530014] [<f80ce8d5>] igb_poll+0x6fd/0x9ad [igb] [ 348.530014] [<c0242bd8>] ? swake_up_locked+0x14/0x26 [ 348.530014] [<c04c5d29>] net_rx_action+0xde/0x250 [ 348.530014] [<c022a743>] __do_softirq+0x8a/0x163 [ 348.530014] [<c022a6b9>] ? __hrtimer_tasklet_trampoline+0x19/0x19 [ 348.530014] [<c021100f>] do_softirq_own_stack+0x26/0x2c [ 348.530014] <IRQ> [ 348.530014] [<c022a957>] irq_exit+0x31/0x6f [ 348.530014] [<c0210eb2>] do_IRQ+0x8d/0xa0 [ 348.530014] [<c058152c>] common_interrupt+0x2c/0x40 [ 348.530014] Code: e7 8c 00 66 81 ff 88 00 75 12 85 d2 75 0e b2 c3 b8 83 e9 29 f9 e8 a7 5f f9 c6 eb 74 66 81 e3 8c 005 [ 348.530014] EIP: [<f929245d>] ieee80211_mps_set_frame_flags+0x40/0xaa [mac80211] SS:ESP 0068:f6409a40 [ 348.530014] CR2: 0000000000020040 [ 348.530014] ---[ end trace 48556ac26779732e ]--- [ 348.530014] Kernel panic - not syncing: Fatal exception in interrupt [ 348.530014] Kernel Offset: disabled
--- net/mac80211/mesh.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mac80211/mesh.c +4 -0
@@ -161,6 +161,10 @@ void mesh_sta_cleanup(struct sta_info *sdel_timer_sync (&sta->plink_timer); } +/* make sure no readers can access nexthop sta from here on */ +mesh_path_flush_by_nexthop (sta); +synchronize_net (); +if (changed)ieee80211_mbss_info_change_notify (sdata, changed); }
PATCH 26/305 crypto: s5p-sss - Fix missed interrupts when working with 8 kB blocks
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 79152e8d085fd64484afd473ef6830b45518acba upstream.
The tcrypt testing module on Exynos5422-based Odroid XU3/4 board failed on testing 8 kB size blocks:
$ sudo modprobe tcrypt sec=1 mode=500 testing speed of async ecb(aes) (ecb-aes-s5p) encryption test 0 (128 bit key, 16 byte blocks): 21971 operations in 1 seconds (351536 bytes) test 1 (128 bit key, 64 byte blocks): 21731 operations in 1 seconds (1390784 bytes) test 2 (128 bit key, 256 byte blocks): 21932 operations in 1 seconds (5614592 bytes) test 3 (128 bit key, 1024 byte blocks): 21685 operations in 1 seconds (22205440 bytes) test 4 (128 bit key, 8192 byte blocks):
This was caused by a race issue of missed BRDMA_DONE ("Block cipher Receiving DMA") interrupt. Device starts processing the data in DMA mode immediately after setting length of DMA block: receiving (FCBRDMAL) or transmitting (FCBTDMAL). The driver sets these lengths from interrupt handler through s5p_set_dma_indata() function (or xxx_setdata()).
However the interrupt handler was first dealing with receive buffer (dma-unmap old, dma-map new, set receive block length which starts the operation), then with transmit buffer and finally was clearing pending interrupts (FCINTPEND). Because of the time window between setting receive buffer length and clearing pending interrupts, the operation on receive buffer could end already and driver would miss new interrupt.
User manual for Exynos5422 confirms in example code that setting DMA block lengths should be the last operation.
The tcrypt hang could be also observed in following blocked-task dmesg:
INFO: task modprobe:258 blocked for more than 120 seconds.
Not tainted 4.6.0-rc4-next-20160419-00005-g9eac8b7b7753-dirty #42"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
modprobe D c06b09d8 0 258 256 0x00000000
[<c06b09d8>] (__schedule) from [<c06b0f24>] (schedule+0x40/0xac)
[<c06b0f24>] (schedule) from [<c06b49f8>] (schedule_timeout+0x124/0x178) [<c06b49f8>] (schedule_timeout) from [<c06b17fc>] (wait_for_common+0xb8/0x144) [<c06b17fc>] (wait_for_common) from [<bf0013b8>] (test_acipher_speed+0x49c/0x740 [tcrypt]) [<bf0013b8>] (test_acipher_speed [tcrypt]) from [<bf003e8c>] (do_test+0x2240/0x30ec [tcrypt]) [<bf003e8c>] (do_test [tcrypt]) from [<bf008048>] (tcrypt_mod_init+0x48/0xa4 [tcrypt]) [<bf008048>] (tcrypt_mod_init [tcrypt]) from [<c010177c>] (do_one_initcall+0x3c/0x16c) [<c010177c>] (do_one_initcall) from [<c0191ff0>] (do_init_module+0x5c/0x1ac) [<c0191ff0>] (do_init_module) from [<c0185610>] (load_module+0x1a30/0x1d08) [<c0185610>] (load_module) from [<c0185ab0>] (SyS_finit_module+0x8c/0x98) [<c0185ab0>] (SyS_finit_module) from [<c01078c0>] (ret_fast_syscall+0x0/0x3c)
--- drivers/crypto/s5p-sss.c | 53 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 14 deletions(-)
drivers/crypto/s5p-sss.c +39 -14
@@ -313,43 +313,55 @@ static int s5p_set_indata(struct s5p_aesreturn err; } -static void s5p_aes_tx (struct s5p_aes_dev *dev) +/* +* Returns true if new transmitting (output) data is ready and its +* address+length have to be written to device (by calling +* s5p_set_dma_outdata()). False otherwise. +*/ +static bool s5p_aes_tx (struct s5p_aes_dev *dev) {int err =0 ; +bool ret = false;s5p_unset_outdata (dev);if (!sg_is_last (dev->sg_dst)) { err =s5p_set_outdata (dev,sg_next (dev->sg_dst)); -if (err) { +if (err)s5p_aes_complete (dev, err); -return ; - } - -s5p_set_dma_outdata (dev, dev->sg_dst); +else + ret = true; }else {s5p_aes_complete (dev, err); dev->busy = true;tasklet_schedule (&dev->tasklet); } + +return ret; } -static void s5p_aes_rx (struct s5p_aes_dev *dev) +/* +* Returns true if new receiving (input) data is ready and its +* address+length have to be written to device (by calling +* s5p_set_dma_indata()). False otherwise. +*/ +static bool s5p_aes_rx (struct s5p_aes_dev *dev) {int err; +bool ret = false;s5p_unset_indata (dev);if (!sg_is_last (dev->sg_src)) { err =s5p_set_indata (dev,sg_next (dev->sg_src)); -if (err) { +if (err)s5p_aes_complete (dev, err); -return ; - } - -s5p_set_dma_indata (dev, dev->sg_src); +else + ret = true; } + +return ret; }static irqreturn_t s5p_aes_interrupt (int irq,void *dev_id)
@@ -358,19 +370,32 @@ static irqreturn_t s5p_aes_interrupt(intstruct s5p_aes_dev *dev =platform_get_drvdata (pdev);uint32_t status;unsigned long flags; +bool set_dma_tx = false; +bool set_dma_rx = false;spin_lock_irqsave (&dev->lock, flags);if (irq == dev->irq_fc) { status =SSS_READ (dev,FCINTSTAT );if (status &SSS_FCINTSTAT_BRDMAINT ) -s5p_aes_rx (dev); + set_dma_rx =s5p_aes_rx (dev);if (status &SSS_FCINTSTAT_BTDMAINT ) -s5p_aes_tx (dev); + set_dma_tx =s5p_aes_tx (dev);SSS_WRITE (dev,FCINTPEND , status); } +/* +* Writing length of DMA block (either receiving or transmitting) +* will start the operation immediately, so this should be done +* at the end (even after clearing pending interrupts to not miss the +* interrupt). +*/ +if (set_dma_tx) +s5p_set_dma_outdata (dev, dev->sg_dst); +if (set_dma_rx) +s5p_set_dma_indata (dev, dev->sg_src); +spin_unlock_irqrestore (&dev->lock, flags);return IRQ_HANDLED ;
PATCH 43/305 tty: vt, return error when con_startup fails
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby <[email protected]>
commit 6798df4c5fe0a7e6d2065cf79649a794e5ba7114 upstream.
When csw->con_startup() fails in do_register_con_driver, we return no error (i.e. 0). This was changed back in 2006 by commit 3e795de763. Before that we used to return -ENODEV.
So fix the return value to be -ENODEV in that case again.
--- drivers/tty/vt/vt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/vt/vt.c +3 -2
@@ -3591,9 +3591,10 @@ static int do_register_con_driver(const goto err; desc = csw->con_startup (); - -if (!desc) +if (!desc) { + retval = -ENODEV ; goto err; + } retval = -EINVAL ;
PATCH 287/305 misc: mic: Fix for double fetch security bug in VOP driver
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ashutosh Dixit <[email protected]>
commit 9bf292bfca94694a721449e3fd752493856710f6 upstream.
The MIC VOP driver does two successive reads from user space to read a variable length data structure. Kernel memory corruption can result if the data structure changes between the two reads. This patch disallows the chance of this happening.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116651
Reported by: Pengfei Wang <[email protected]>
[bwh: Backported to 3.16:
- Adjust filename, context
- goto exit on failure]
--- drivers/misc/mic/host/mic_virtio.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/misc/mic/host/mic_virtio.c +5 -0
@@ -456,6 +456,11 @@ static int mic_copy_dp_entry(struct mic_ __func__, __LINE__, ret); goto exit; } +/* Ensure desc has not changed between the two reads */ +if (memcmp (&dd, dd_config,sizeof (dd))) { + ret = -EINVAL ; + goto exit; + } vqconfig =mic_vq_config (dd_config);for (i =0 ; i < dd.num_vq; i++) {
PATCH 302/305 netfilter: x_tables: do compat validation via translate_table
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 09d9686047dbbe1cf4faa558d3ecc4aae2046054 upstream.
This looks like refactoring, but its also a bug fix.
Problem is that the compat path (32bit iptables, 64bit kernel) lacks a few sanity tests that are done in the normal path.
For example, we do not check for underflows and the base chain policies.
While its possible to also add such checks to the compat path, its more copy&pastry, for instance we cannot reuse check_underflow() helper as e->target_offset differs in the compat case.
Other problem is that it makes auditing for validation errors harder; two places need to be checked and kept in sync.
At a high level 32 bit compat works like this:
1- initial pass over blob:
validate match/entry offsets, bounds checking lookup all matches and targets
do bookkeeping wrt. size delta of 32/64bit structures assign match/target.u.kernel pointer (points at kernel implementation, needed to access ->compatsize etc.)
2- allocate memory according to the total bookkeeping size to
contain the translated ruleset
3- second pass over original blob:
for each entry, copy the 32bit representation to the newly allocated memory. This also does any special match translations (e.g. adjust 32bit to 64bit longs, etc).
4- check if ruleset is free of loops (chase all jumps)
5-first pass over translated blob:
call the checkentry function of all matches and targets.
The alternative implemented by this patch is to drop steps 3&4 from the compat process, the translation is changed into an intermediate step rather than a full 1:1 translate_table replacement.
In the 2nd pass (step #3), change the 64bit ruleset back to a kernel representation, i.e. put() the kernel pointer and restore ->u.user.name .
This gets us a 64bit ruleset that is in the format generated by a 64bit iptables userspace -- we can then use translate_table() to get the 'native' sanity checks.
This has two drawbacks:
1. we re-validate all the match and target entry structure sizes even though compat translation is supposed to never generate bogus offsets.
2. we put and then re-lookup each match and target.
THe upside is that we get all sanity tests and ruleset validations provided by the normal path and can remove some duplicated compat code.
iptables-restore time of autogenerated ruleset with 300k chains of form -A CHAIN0001 -m limit --limit 1/s -j CHAIN0002
-A CHAIN0002 -m limit --limit 1/s -j CHAIN0003
shows no noticeable differences in restore times:
old: 0m30.796s new: 0m31.521s
64bit: 0m25.674s
---
net/ipv4/netfilter/arp_tables.c +22 -88
@@ -1225,19 +1225,17 @@ static inline void compat_release_entry(module_put (t->u.kernel.target->me); } -static inline int +static int check_compat_entry_size_and_hooks (struct compat_arpt_entry *e,struct xt_table_info *newinfo,unsigned int *size,const unsigned char *base, -const unsigned char *limit, -const unsigned int *hook_entries, -const unsigned int *underflows) +const unsigned char *limit) {struct xt_entry_target *t;struct xt_target *target;unsigned int entry_offset; -int ret, off, h; +int ret, off;duprintf ("check_compat_entry_size_and_hooks %p\n" , e); if ((unsigned long)e % __alignof__(struct compat_arpt_entry) != 0 ||
@@ -1282,17 +1280,6 @@ check_compat_entry_size_and_hooks(structif (ret) goto release_target; -/* Check hooks & underflows */ -for (h =0 ; h <NF_ARP_NUMHOOKS ; h++) { -if ((unsigned char *)e - base == hook_entries[h]) - newinfo->hook_entry[h] = hook_entries[h]; -if ((unsigned char *)e - base == underflows[h]) - newinfo->underflow[h] = underflows[h]; - } - -/* Clear counters and comefrom */ -memset (&e->counters,0 ,sizeof (e->counters)); - e->comefrom =0 ;return 0 ; release_target:
@@ -1342,7 +1329,7 @@ static int translate_compat_table(structstruct xt_table_info *newinfo, *info;void *pos, *entry0, *entry1;struct compat_arpt_entry *iter0; -struct arpt_entry *iter1; +struct arpt_replace repl;unsigned int size;int ret =0 ;
@@ -1351,12 +1338,6 @@ static int translate_compat_table(struct size = compatr->size; info->number = compatr->num_entries; -/* Init all hooks to impossible value. */ -for (i =0 ; i <NF_ARP_NUMHOOKS ; i++) { - info->hook_entry[i] =0xFFFFFFFF ; - info->underflow[i] =0xFFFFFFFF ; - } -duprintf ("translate_compat_table: size %u\n" , info->size); j =0 ;xt_compat_lock (NFPROTO_ARP );
@@ -1365,9 +1346,7 @@ static int translate_compat_table(struct xt_entry_foreach(iter0, entry0, compatr->size) { ret =check_compat_entry_size_and_hooks (iter0, info, &size, entry0, - entry0 + compatr->size, - compatr->hook_entry, - compatr->underflow); + entry0 + compatr->size);if (ret !=0 ) goto out_unlock; ++j;
@@ -1380,23 +1359,6 @@ static int translate_compat_table(struct goto out_unlock; } -/* Check hooks all assigned */ -for (i =0 ; i <NF_ARP_NUMHOOKS ; i++) { -/* Only hooks which are valid */ -if (!(compatr->valid_hooks & (1 << i))) -continue ; -if (info->hook_entry[i] ==0xFFFFFFFF ) { -duprintf ("Invalid hook entry %u %u\n" , - i, info->hook_entry[i]); - goto out_unlock; - } -if (info->underflow[i] ==0xFFFFFFFF ) { -duprintf ("Invalid underflow %u %u\n" , - i, info->underflow[i]); - goto out_unlock; - } - } - ret = -ENOMEM ; newinfo =xt_alloc_table_info (size);if (!newinfo)
@@ -1413,51 +1375,24 @@ static int translate_compat_table(struct xt_entry_foreach(iter0, entry0, compatr->size)compat_copy_entry_from_user (iter0, &pos, &size, newinfo, entry1); + +/* all module references in entry0 are now gone */ +xt_compat_flush_offsets (NFPROTO_ARP );xt_compat_unlock (NFPROTO_ARP ); - ret = -ELOOP ; -if (!mark_source_chains (newinfo, compatr->valid_hooks, entry1)) - goto free_newinfo; - - i =0 ; - xt_entry_foreach(iter1, entry1, newinfo->size) { - ret =check_target (iter1, compatr->name); -if (ret !=0 ) -break ; - ++i; -if (strcmp (arpt_get_target (iter1)->u.user.name, -XT_ERROR_TARGET ) ==0 ) - ++newinfo->stacksize; - } -if (ret) { -/* -* The first i matches need cleanup_entry (calls ->destroy) -* because they had called ->check already. The other j-i -* entries need only release. -*/ -int skip = i; - j -= i; - xt_entry_foreach(iter0, entry0, newinfo->size) { -if (skip-- >0 ) -continue ; -if (j-- ==0 ) -break ; -compat_release_entry (iter0); - } - xt_entry_foreach(iter1, entry1, newinfo->size) { -if (i-- ==0 ) -break ; -cleanup_entry (iter1); - } -xt_free_table_info (newinfo); -return ret; +memcpy (&repl, compatr,sizeof (*compatr)); +for (i =0 ; i <NF_ARP_NUMHOOKS ; i++) { + repl.hook_entry[i] = newinfo->hook_entry[i]; + repl.underflow[i] = newinfo->underflow[i]; } -/* And one copy for every other CPU */ -for_each_possible_cpu (i) -if (newinfo->entries[i] && newinfo->entries[i] != entry1) -memcpy (newinfo->entries[i], entry1, newinfo->size); + repl.num_counters =0 ; + repl.counters =NULL ; + repl.size = newinfo->size; + ret =translate_table (newinfo, entry1, &repl); +if (ret) + goto free_newinfo; *pinfo = newinfo; *pentry0 = entry1;
@@ -1466,17 +1401,16 @@ static int translate_compat_table(struct free_newinfo:xt_free_table_info (newinfo); -out: +return ret; +out_unlock: +xt_compat_flush_offsets (NFPROTO_ARP ); +xt_compat_unlock (NFPROTO_ARP ); xt_entry_foreach(iter0, entry0, compatr->size) {if (j-- ==0 )break ;compat_release_entry (iter0); }return ret; -out_unlock: -xt_compat_flush_offsets (NFPROTO_ARP ); -xt_compat_unlock (NFPROTO_ARP ); - goto out; } static int compat_do_replace(struct net *net, void __user *user,
net/ipv4/netfilter/ip_tables.c +28 -123
235 lines not on this page · raw message
net/ipv6/netfilter/ip6_tables.c +22 -123
224 lines not on this page · raw message
net/netfilter/x_tables.c +8 -0
@@ -552,6 +552,7 @@ void xt_compat_match_from_user(struct xtstruct compat_xt_entry_match *cm = (struct compat_xt_entry_match *)m;int pad, off =xt_compat_match_offset (match);u_int16_t msize = cm->u.user.match_size; +char name[sizeof (m->u.user.name)]; m = *dstptr;memcpy (m, cm,sizeof (*cm));
@@ -565,6 +566,9 @@ void xt_compat_match_from_user(struct xt msize += off; m->u.user.match_size = msize; +strlcpy (name, match->name,sizeof (name)); +module_put (match->me); +strncpy (m->u.user.name, name,sizeof (m->u.user.name)); *size += off; *dstptr += msize;
@@ -782,6 +786,7 @@ void xt_compat_target_from_user(struct xstruct compat_xt_entry_target *ct = (struct compat_xt_entry_target *)t;int pad, off =xt_compat_target_offset (target);u_int16_t tsize = ct->u.user.target_size; +char name[sizeof (t->u.user.name)]; t = *dstptr;memcpy (t, ct,sizeof (*ct));
@@ -795,6 +800,9 @@ void xt_compat_target_from_user(struct x tsize += off; t->u.user.target_size = tsize; +strlcpy (name, target->name,sizeof (name)); +module_put (target->me); +strncpy (t->u.user.name, name,sizeof (t->u.user.name)); *size += off; *dstptr += tsize;
PATCH 106/305 net: ehea: avoid null pointer dereference
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "[email protected]" <[email protected]>
commit 1740c29a46b30a2f157afc473156f157e599d4c2 upstream.
ehea_get_port may return NULL. Do not dereference NULL value.
--- drivers/net/ethernet/ibm/ehea/ehea_main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/ibm/ehea/ehea_main.c +4 -5
@@ -1169,16 +1169,15 @@ static void ehea_parse_eqe(struct ehea_a ec =EHEA_BMASK_GET (NEQE_EVENT_CODE , eqe); portnum =EHEA_BMASK_GET (NEQE_PORTNUM , eqe); port =ehea_get_port (adapter, portnum); +if (!port) { +netdev_err (NULL ,"unknown portnum %x\n" , portnum); +return ; + } dev = port->netdev;switch (ec) {case EHEA_EC_PORTSTATE_CHG :/* port state change */ -if (!port) { -netdev_err (dev,"unknown portnum %x\n" , portnum); -break ; - } -if (EHEA_BMASK_GET (NEQE_PORT_UP , eqe)) {if (!netif_carrier_ok (dev)) { ret =ehea_sense_port_attr (port);
PATCH 226/305 nfsd: check permissions when setting ACLs
In reply to Ben Hutchings3.16.37-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
commit 999653786df6954a31044528ac3f7a5dadca08f4 upstream.
Use set_posix_acl, which includes proper permission checks, instead of calling ->set_acl directly. Without this anyone may be able to grant themselves permissions to a file by setting the ACL.
Lock the inode to make the new checks atomic with respect to set_acl. (Also, nfsd was the only caller of set_acl not locking the inode, so I suspect this may fix other races.)
This also simplifies the code, and ensures our ACLs are checked by posix_acl_valid.
The permission checks and the inode locking were lost with commit 4ac7249e, which changed nfsd to use the set_acl inode operation directly instead of going through xattr handlers.
--- fs/nfsd/nfs2acl.c | 20 ++++++++++---------- fs/nfsd/nfs3acl.c | 16 +++++++--------- fs/nfsd/nfs4acl.c | 16 ++++++++-------- 3 files changed, 25 insertions(+), 27 deletions(-)
fs/nfsd/nfs2acl.c +10 -10
@@ -104,22 +104,21 @@ static __be32 nfsacld_proc_setacl(struct goto out; inode = fh->fh_dentry->d_inode; -if (!IS_POSIXACL (inode) || !inode->i_op->set_acl) { - error = -EOPNOTSUPP ; - goto out_errno; - } error =fh_want_write (fh);if (error) goto out_errno; - error = inode->i_op->set_acl (inode, argp->acl_access,ACL_TYPE_ACCESS ); +fh_lock (fh); + + error =set_posix_acl (inode,ACL_TYPE_ACCESS , argp->acl_access);if (error) - goto out_drop_write; - error = inode->i_op->set_acl (inode, argp->acl_default, -ACL_TYPE_DEFAULT ); + goto out_drop_lock; + error =set_posix_acl (inode,ACL_TYPE_DEFAULT , argp->acl_default);if (error) - goto out_drop_write; + goto out_drop_lock; + +fh_unlock (fh);fh_drop_write (fh);
@@ -131,7 +130,8 @@ out:posix_acl_release (argp->acl_access);posix_acl_release (argp->acl_default);return nfserr; -out_drop_write: +out_drop_lock: +fh_unlock (fh);fh_drop_write (fh); out_errno: nfserr =nfserrno (error);
fs/nfsd/nfs3acl.c +7 -9
@@ -95,22 +95,20 @@ static __be32 nfsd3_proc_setacl(struct s goto out; inode = fh->fh_dentry->d_inode; -if (!IS_POSIXACL (inode) || !inode->i_op->set_acl) { - error = -EOPNOTSUPP ; - goto out_errno; - } error =fh_want_write (fh);if (error) goto out_errno; - error = inode->i_op->set_acl (inode, argp->acl_access,ACL_TYPE_ACCESS ); +fh_lock (fh); + + error =set_posix_acl (inode,ACL_TYPE_ACCESS , argp->acl_access);if (error) - goto out_drop_write; - error = inode->i_op->set_acl (inode, argp->acl_default, -ACL_TYPE_DEFAULT ); + goto out_drop_lock; + error =set_posix_acl (inode,ACL_TYPE_DEFAULT , argp->acl_default); -out_drop_write: +out_drop_lock: +fh_unlock (fh);fh_drop_write (fh); out_errno: nfserr =nfserrno (error);
fs/nfsd/nfs4acl.c +8 -8
@@ -822,9 +822,6 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqst dentry = fhp->fh_dentry; inode = dentry->d_inode; -if (!inode->i_op->set_acl || !IS_POSIXACL (inode)) -return nfserr_attrnotsupp; -if (S_ISDIR (inode->i_mode)) flags =NFS4_ACL_DIR ;
@@ -834,16 +831,19 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstif (host_error <0 ) goto out_nfserr; - host_error = inode->i_op->set_acl (inode, pacl,ACL_TYPE_ACCESS ); +fh_lock (fhp); + + host_error =set_posix_acl (inode,ACL_TYPE_ACCESS , pacl);if (host_error <0 ) - goto out_release; + goto out_drop_lock;if (S_ISDIR (inode->i_mode)) { - host_error = inode->i_op->set_acl (inode, dpacl, -ACL_TYPE_DEFAULT ); + host_error =set_posix_acl (inode,ACL_TYPE_DEFAULT , dpacl); } -out_release: +out_drop_lock: +fh_unlock (fhp); +posix_acl_release (pacl);posix_acl_release (dpacl); out_nfserr: