Bluetooth: btusb: fix QCA Rome suspend/resume
Subsystems (215)
[added to the 4.1 stable tree] iscsi-target: Make TASK_REASSIGN use proper se_cmd->cmd_kref
In reply to Sasha LevinFrom: Nicholas Bellinger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ae072726f6109bb1c94841d6fb3a82dde298ea85 ]
Since commit 59b6986dbf fixed a potential NULL pointer dereference by allocating a se_tmr_req for ISCSI_TM_FUNC_TASK_REASSIGN, the se_tmr_req is currently leaked by iscsit_free_cmd() because no iscsi_cmd->se_cmd.se_tfo was associated.
To address this, treat ISCSI_TM_FUNC_TASK_REASSIGN like any other TMR and call transport_init_se_cmd() + target_get_sess_cmd() to setup iscsi_cmd->se_cmd.se_tfo with se_cmd->cmd_kref of 2.
This will ensure normal release operation once se_cmd->cmd_kref reaches zero and target_release_cmd_kref() is invoked, se_tmr_req will be released via existing target_free_cmd_mem() and core_tmr_release_req() code.
--- drivers/target/iscsi/iscsi_target.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/target/iscsi/iscsi_target.c +7 -13
@@ -1755,7 +1755,6 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,struct iscsi_tmr_req *tmr_req;struct iscsi_tm *hdr;int out_of_order_cmdsn =0 , ret; -bool sess_ref = false;u8 function, tcm_function =TMR_UNKNOWN ; hdr = (struct iscsi_tm *) buf;
@@ -1797,18 +1796,17 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, buf); } +transport_init_se_cmd (&cmd->se_cmd, &iscsi_ops, + conn->sess->se_sess,0 ,DMA_NONE , +TCM_SIMPLE_TAG , cmd->sense_buffer +2 ); + +target_get_sess_cmd (&cmd->se_cmd, true); +/* * TASK_REASSIGN for ERL=2 / connection stays inside of * LIO-Target $FABRIC_MOD */ if (function !=ISCSI_TM_FUNC_TASK_REASSIGN ) { -transport_init_se_cmd (&cmd->se_cmd, &iscsi_ops, - conn->sess->se_sess,0 ,DMA_NONE , -TCM_SIMPLE_TAG , cmd->sense_buffer +2 ); - -target_get_sess_cmd (&cmd->se_cmd, true); - sess_ref = true; -switch (function) {case ISCSI_TM_FUNC_ABORT_TASK : tcm_function =TMR_ABORT_TASK ;
@@ -1947,12 +1945,8 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,* For connection recovery, this is also the default action for * TMR TASK_REASSIGN. */ -if (sess_ref) { -pr_debug ("Handle TMR, using sess_ref=true check\n" ); -target_put_sess_cmd (&cmd->se_cmd); - } -iscsit_add_cmd_to_response_queue (cmd, conn, cmd->i_state); +target_put_sess_cmd (&cmd->se_cmd);return 0 ; }EXPORT_SYMBOL (iscsit_handle_task_mgt_cmd);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] USB: serial: cp210x: add IDs for LifeScan OneTouch Verio IQ
In reply to Sasha LevinFrom: Diego Elio Pettenò <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4307413256ac1e09b8f53e8715af3df9e49beec3 ]
Add IDs for the OneTouch Verio IQ that comes with an embedded USB-to-serial converter.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -119,6 +119,7 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */ { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */ + { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */ { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] USB: serial: cp210x: add new device ID ELV ALC 8xxx
In reply to Sasha LevinFrom: Christian Holl <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d14ac576d10f865970bb1324d337e5e24d79aaf4 ]
This adds the ELV ALC 8xxx Battery Charging device to the list of USB IDs of drivers/usb/serial/cp210x.c
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -169,6 +169,7 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ { USB_DEVICE(0x18EF, 0xE025) }, /* ELV Marble Sound Board 1 */ + { USB_DEVICE(0x18EF, 0xE030) }, /* ELV ALC 8xxx Battery Charger */ { USB_DEVICE(0x18EF, 0xE032) }, /* ELV TFD500 Data Logger */ { USB_DEVICE(0x1901, 0x0190) }, /* GE B850 CP2105 Recorder interface */ { USB_DEVICE(0x1901, 0x0193) }, /* GE B650 CP2104 PMC interface */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] e1000e: Fix e1000_check_for_copper_link_ich8lan return value.
In reply to Sasha LevinFrom: Benjamin Poirier <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4110e02eb45ea447ec6f5459c9934de0a273fb91 ]
e1000e_check_for_copper_link() and e1000_check_for_copper_link_ich8lan() are the two functions that may be assigned to mac.ops.check_for_link when phy.media_type == e1000_media_type_copper. Commit 19110cfbb34d ("e1000e:
Separate signaling for link check/link up") changed the meaning of the return value of check_for_link for copper media but only adjusted the first function. This patch adjusts the second function likewise.
--- drivers/net/ethernet/intel/e1000e/ich8lan.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +8 -3
@@ -1345,6 +1345,9 @@ static s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)* Checks to see of the link status of the hardware has changed. If a * change in link status has been detected, then we read the PHY registers * to get the current speed/duplex if link exists. +* +* Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link +* up). **/ static s32 e1000_check_for_copper_link_ich8lan (struct e1000_hw *hw) {
@@ -1360,7 +1363,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)* Change or Rx Sequence Error interrupt. */ if (!mac->get_link_status) -return 0 ; +return 1 ;/* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex
@@ -1519,10 +1522,12 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)* different link partner. */ ret_val =e1000e_config_fc_after_link_up (hw); -if (ret_val) +if (ret_val) {e_dbg ("Error configuring flow control\n" ); +return ret_val; + } -return ret_val; +return 1 ; }static s32 e1000_get_variants_ich8lan (struct e1000_adapter *adapter)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: misc: usb3503: make sure reset is low for at least 100us
In reply to Sasha LevinFrom: Stefan Agner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b8626f1dc29d3eee444bfaa92146ec7b291ef41c ]
When using a GPIO which is high by default, and initialize the driver in USB Hub mode, initialization fails with:
[ 111.757794] usb3503 0-0008: SP_ILOCK failed (-5)
The reason seems to be that the chip is not properly reset. Probe does initialize reset low, however some lines later the code already set it back high, which is not long enouth.
Make sure reset is asserted for at least 100us by inserting a delay after initializing the reset pin during probe.
--- drivers/usb/misc/usb3503.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/misc/usb3503.c +2 -0
@@ -292,6 +292,8 @@ static int usb3503_probe(struct usb3503 *hub)if (gpio_is_valid (hub->gpio_reset)) { err =devm_gpio_request_one (dev, hub->gpio_reset,GPIOF_OUT_INIT_LOW ,"usb3503 reset" ); +/* Datasheet defines a hardware reset to be at least 100us */ +usleep_range (100 ,10000 );if (err) { dev_err(dev, "unable to request GPIO %d as reset pin (%d)\n",
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] USB: fix usbmon BUG trigger
In reply to Sasha LevinFrom: Pete Zaitcev <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 46eb14a6e1585d99c1b9f58d0e7389082a5f466b ]
Automated tests triggered this by opening usbmon and accessing the mmap while simultaneously resizing the buffers. This bug was with us since 2006, because typically applications only size the buffers once and thus avoid racing. Reported by Kirill A. Shutemov.
--- drivers/usb/mon/mon_bin.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/mon/mon_bin.c +7 -1
@@ -1000,7 +1000,9 @@ static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long argbreak ;case MON_IOCQ_RING_SIZE : +mutex_lock (&rp->fetch_lock); ret = rp->b_size; +mutex_unlock (&rp->fetch_lock);break ;case MON_IOCT_RING_SIZE :
@@ -1227,12 +1229,16 @@ static int mon_bin_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)unsigned long offset, chunk_idx;struct page *pageptr; +mutex_lock (&rp->fetch_lock); offset = vmf->pgoff <<PAGE_SHIFT ; -if (offset >= rp->b_size) +if (offset >= rp->b_size) { +mutex_unlock (&rp->fetch_lock);return VM_FAULT_SIGBUS ; + } chunk_idx = offset /CHUNK_SIZE ; pageptr = rp->b_vec[chunk_idx].pg;get_page (pageptr); +mutex_unlock (&rp->fetch_lock); vmf->page = pageptr;return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Bluetooth: Prevent stack info leak from the EFS element.
In reply to Sasha LevinFrom: Ben Seri <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 06e7e776ca4d36547e503279aeff996cbb292c16 ]
In the function l2cap_parse_conf_rsp and in the function l2cap_parse_conf_req the following variable is declared without initialization:
struct l2cap_conf_efs efs;
In addition, when parsing input configuration parameters in both of these functions, the switch case for handling EFS elements may skip the memcpy call that will write to the efs variable:
...
case L2CAP_CONF_EFS:
if (olen == sizeof(efs))memcpy(&efs, (void *)val, olen);
...
The olen in the above if is attacker controlled, and regardless of that if, in both of these functions the efs variable would eventually be added to the outgoing configuration request that is being built:
l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs), (unsigned long) &efs);
So by sending a configuration request, or response, that contains an L2CAP_CONF_EFS element, but with an element length that is not sizeof(efs) - the memcpy to the uninitialized efs variable can be avoided, and the uninitialized variable would be returned to the attacker (16 bytes).
This issue has been assigned CVE-2017-1000410
--- net/bluetooth/l2cap_core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
net/bluetooth/l2cap_core.c +11 -9
@@ -3346,9 +3346,10 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t databreak ;case L2CAP_CONF_EFS : - remote_efs =1 ; -if (olen ==sizeof (efs)) +if (olen ==sizeof (efs)) { + remote_efs =1 ;memcpy (&efs, (void *) val, olen); + }break ;case L2CAP_CONF_EWS :
@@ -3567,16 +3568,17 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,break ;case L2CAP_CONF_EFS : -if (olen ==sizeof (efs)) +if (olen ==sizeof (efs)) {memcpy (&efs, (void *)val, olen); -if (chan->local_stype !=L2CAP_SERV_NOTRAFIC && - efs.stype !=L2CAP_SERV_NOTRAFIC && - efs.stype != chan->local_stype) -return -ECONNREFUSED ; +if (chan->local_stype !=L2CAP_SERV_NOTRAFIC && + efs.stype !=L2CAP_SERV_NOTRAFIC && + efs.stype != chan->local_stype) +return -ECONNREFUSED ; -l2cap_add_conf_opt (&ptr,L2CAP_CONF_EFS ,sizeof (efs), - (unsigned long ) &efs, endptr - ptr); +l2cap_add_conf_opt (&ptr,L2CAP_CONF_EFS ,sizeof (efs), + (unsigned long ) &efs, endptr - ptr); + }break ;case L2CAP_CONF_FCS :
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: remove kernel addresses from usb device and urb debug msgs
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e1346fd87c71a1f61de1fe476ec8df1425ac931c ]
usbip_dump_usb_device() and usbip_dump_urb() print kernel addresses. Remove kernel addresses from usb device and urb debug msgs and improve the message content.
Instead of printing parent device and bus addresses, print parent device and bus names.
--- drivers/usb/usbip/usbip_common.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/usb/usbip/usbip_common.c +3 -14
@@ -103,7 +103,7 @@ static void usbip_dump_usb_device(struct usb_device *udev)dev_dbg (dev," devnum(%d) devpath(%s) usb speed(%s)" , udev->devnum, udev->devpath,usb_speed_string (udev->speed)); -pr_debug ("tt %p, ttport %d\n" , udev->tt, udev->ttport); +pr_debug ("tt hub ttport %d\n" , udev->ttport);dev_dbg (dev," " );for (i =0 ; i <16 ; i++)
@@ -136,12 +136,8 @@ static void usbip_dump_usb_device(struct usb_device *udev) }pr_debug ("\n" ); -dev_dbg (dev,"parent %p, bus %p\n" , udev->parent, udev->bus); - -dev_dbg (dev, -"descriptor %p, config %p, actconfig %p, rawdescriptors %p\n" , - &udev->descriptor, udev->config, - udev->actconfig, udev->rawdescriptors); +dev_dbg (dev,"parent %s, bus %s\n" ,dev_name (&udev->parent->dev), + udev->bus->bus_name);dev_dbg (dev,"have_langid %d, string_langid %d\n" , udev->have_langid, udev->string_langid);
@@ -249,9 +245,6 @@ void usbip_dump_urb(struct urb *urb) dev = &urb->dev->dev; -dev_dbg (dev," urb :%p\n" , urb); -dev_dbg (dev," dev :%p\n" , urb->dev); -usbip_dump_usb_device (urb->dev);dev_dbg (dev," pipe :%08x " , urb->pipe);
@@ -260,11 +253,9 @@ void usbip_dump_urb(struct urb *urb)dev_dbg (dev," status :%d\n" , urb->status);dev_dbg (dev," transfer_flags :%08X\n" , urb->transfer_flags); -dev_dbg (dev," transfer_buffer :%p\n" , urb->transfer_buffer);dev_dbg (dev," transfer_buffer_length:%d\n" , urb->transfer_buffer_length);dev_dbg (dev," actual_length :%d\n" , urb->actual_length); -dev_dbg (dev," setup_packet :%p\n" , urb->setup_packet);if (urb->setup_packet &&usb_pipetype (urb->pipe) ==PIPE_CONTROL ) usbip_dump_usb_ctrlrequest(
@@ -274,8 +265,6 @@ void usbip_dump_urb(struct urb *urb)dev_dbg (dev," number_of_packets :%d\n" , urb->number_of_packets);dev_dbg (dev," interval :%d\n" , urb->interval);dev_dbg (dev," error_count :%d\n" , urb->error_count); -dev_dbg (dev," context :%p\n" , urb->context); -dev_dbg (dev," complete :%p\n" , urb->complete); }EXPORT_SYMBOL_GPL (usbip_dump_urb);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/cpu: Factor out application of forced CPU caps
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8bf1ebca215c262e48c15a4a15f175991776f57f ]
There are multiple call sites that apply forced CPU caps. Factor them into a helper.
--- arch/x86/kernel/cpu/common.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/common.c +13 -9
@@ -666,6 +666,16 @@ void cpu_detect(struct cpuinfo_x86 *c) } } +static void apply_forced_caps (struct cpuinfo_x86 *c) +{ +int i; + +for (i =0 ; i <NCAPINTS ; i++) { + c->x86_capability[i] &= ~cpu_caps_cleared[i]; + c->x86_capability[i] |= cpu_caps_set[i]; + } +} +void get_cpu_cap (struct cpuinfo_x86 *c) {u32 tfms, xlvl;
@@ -957,11 +967,8 @@ static void identify_cpu(struct cpuinfo_x86 *c)if (this_cpu->c_identify) this_cpu->c_identify (c); -/* Clear/Set all flags overriden by options, after probe */ -for (i =0 ; i <NCAPINTS ; i++) { - c->x86_capability[i] &= ~cpu_caps_cleared[i]; - c->x86_capability[i] |= cpu_caps_set[i]; - } +/* Clear/Set all flags overridden by options, after probe */ +apply_forced_caps (c);#ifdef CONFIG_X86_64 c->apicid = apic->phys_pkg_id (c->initial_apicid,0 );
@@ -1022,10 +1029,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)* Clear/Set all flags overriden by options, need do it * before following smp all cpus cap AND. */ -for (i =0 ; i <NCAPINTS ; i++) { - c->x86_capability[i] &= ~cpu_caps_cleared[i]; - c->x86_capability[i] |= cpu_caps_set[i]; - } +apply_forced_caps (c);/* * On SMP, boot_cpu_data holds the common feature set between
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] staging: android: ashmem: fix a race condition in ASHMEM_SET_SIZE ioctl
In reply to Sasha LevinFrom: Viktor Slavkovic <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 443064cb0b1fb4569fe0a71209da7625129fb760 ]
A lock-unlock is missing in ASHMEM_SET_SIZE ioctl which can result in a race condition when mmap is called. After the !asma->file check, before setting asma->size, asma->file can be set in mmap. That would result in having different asma->size than the mapped memory size. Combined with ASHMEM_UNPIN ioctl and shrinker invocation, this can result in memory corruption.
--- drivers/staging/android/ashmem.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/android/ashmem.c +2 -0
@@ -758,10 +758,12 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)break ;case ASHMEM_SET_SIZE : ret = -EINVAL ; +mutex_lock (&ashmem_mutex);if (!asma->file) { ret =0 ; asma->size = (size_t ) arg; } +mutex_unlock (&ashmem_mutex);break ;case ASHMEM_GET_SIZE : ret = asma->size;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] uas: ignore UAS for Norelsys NS1068(X) chips
In reply to Sasha LevinFrom: Icenowy Zheng <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 928afc85270753657b5543e052cc270c279a3fe9 ]
The UAS mode of Norelsys NS1068(X) is reported to fail to work on several platforms with the following error message:
xhci-hcd xhci-hcd.0.auto: ERROR Transfer event for unknown stream ring slot 1 ep 8 xhci-hcd xhci-hcd.0.auto: @00000000bf04a400 00000000 00000000 1b000000 01098001
And when trying to mount a partition on the disk the disk will disconnect from the USB controller, then after re-connecting the device will be offlined and not working at all.
Falling back to USB mass storage can solve this problem, so ignore UAS function of this chip.
--- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_uas.h +7 -0
@@ -155,6 +155,13 @@ UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999, USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_ATA_1X), +/* Reported-by: Icenowy Zheng <[email protected]> */ +UNUSUAL_DEV (0x2537 ,0x1068 ,0x0000 ,0x9999 , +"Norelsys" , +"NS1068X" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_IGNORE_UAS ), +/* Reported-by: Takeo Nakayama <[email protected]> */ UNUSUAL_DEV(0x357d, 0x7788, 0x0000, 0x9999, "JMicron",
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/cpufeatures: Make CPU bugs sticky
In reply to Sasha LevinFrom: Thomas Gleixner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6cbd2171e89b13377261d15e64384df60ecb530e ]
There is currently no way to force CPU bug bits like CPU feature bits. That makes it impossible to set a bug bit once at boot and have it stick for all upcoming CPUs.
Extend the force set/clear arrays to handle bug bits as well.
--- arch/x86/include/asm/cpufeature.h | 2 ++ arch/x86/include/asm/processor.h | 4 ++-- arch/x86/kernel/cpu/common.c | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/include/asm/cpufeature.h +2 -0
@@ -348,6 +348,8 @@ extern const char * const x86_bug_flags[NBUGINTS*32];set_bit (bit, (unsigned long *)cpu_caps_set); \ } while (0) +#define setup_force_cpu_bug (bit) setup_force_cpu_cap(bit) +#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
arch/x86/include/asm/processor.h +2 -2
@@ -150,8 +150,8 @@ extern struct cpuinfo_x86 boot_cpu_data;extern struct cpuinfo_x86 new_cpu_data;extern struct tss_struct doublefault_tss; -extern __u32 cpu_caps_cleared[NCAPINTS ]; -extern __u32 cpu_caps_set[NCAPINTS ]; +extern __u32 cpu_caps_cleared[NCAPINTS +NBUGINTS ]; +extern __u32 cpu_caps_set[NCAPINTS +NBUGINTS ];#ifdef CONFIG_SMP DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
arch/x86/kernel/cpu/common.c +3 -3
@@ -436,8 +436,8 @@ static const char *table_lookup_model(struct cpuinfo_x86 *c)return NULL ;/* Not found */ } -__u32 cpu_caps_cleared[NCAPINTS ]; -__u32 cpu_caps_set[NCAPINTS ]; +__u32 cpu_caps_cleared[NCAPINTS +NBUGINTS ]; +__u32 cpu_caps_set[NCAPINTS +NBUGINTS ];void load_percpu_segment (int cpu) {
@@ -670,7 +670,7 @@ static void apply_forced_caps(struct cpuinfo_x86 *c) {int i; -for (i =0 ; i <NCAPINTS ; i++) { +for (i =0 ; i <NCAPINTS +NBUGINTS ; i++) { c->x86_capability[i] &= ~cpu_caps_cleared[i]; c->x86_capability[i] |= cpu_caps_set[i]; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/alternatives: Fix optimize_nops() checking
In reply to Sasha LevinFrom: Borislav Petkov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 612e8e9350fd19cae6900cf36ea0c6892d1a0dca ]
The alternatives code checks only the first byte whether it is a NOP, but with NOPs in front of the payload and having actual instructions after it breaks the "optimized' test.
Make sure to scan all bytes before deciding to optimize the NOPs in there.
--- arch/x86/kernel/alternative.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/alternative.c +5 -2
@@ -326,9 +326,12 @@ recompute_jump(struct alt_instr *a, u8 *orig_insn, u8 *repl_insn, u8 *insnbuf) static void __init_or_module optimize_nops(struct alt_instr *a, u8 *instr) {unsigned long flags; +int i; -if (instr[0 ] !=0x90 ) -return ; +for (i =0 ; i < a->padlen; i++) { +if (instr[i] !=0x90 ) +return ; + }local_irq_save (flags);add_nops (instr + (a->instrlen - a->padlen), a->padlen);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/alternatives: Add missing '\n' at end of ALTERNATIVE inline asm
In reply to Sasha LevinFrom: David Woodhouse <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b9e705ef7cfaf22db0daab91ad3cd33b0fa32eb9 ]
Where an ALTERNATIVE is used in the middle of an inline asm block, this would otherwise lead to the following instruction being appended directly to the trailing ".popsection", and a failed compile.
--- arch/x86/include/asm/alternative.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/alternative.h +2 -2
@@ -132,7 +132,7 @@ static inline int alternatives_text_reserved(void *start, void *end)".popsection\n" \".pushsection .altinstr_replacement, \"ax\"\n" \ ALTINSTR_REPLACEMENT(newinstr, feature, 1) \ - ".popsection" + ".popsection\n"#define ALTERNATIVE_2 (oldinstr, newinstr1, feature1, newinstr2, feature2)\ OLDINSTR_2(oldinstr, 1, 2) \
@@ -143,7 +143,7 @@ static inline int alternatives_text_reserved(void *start, void *end)".pushsection .altinstr_replacement, \"ax\"\n" \ ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \ ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \ -".popsection" +".popsection\n" /* * This must be included *after* the definition of ALTERNATIVE due to
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] gcov: disable for COMPILE_TEST
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cc622420798c4bcf093785d872525087a7798db9 ]
Enabling gcov is counterproductive to compile testing: it significantly increases the kernel image size, compile time, and it produces lots of false positive "may be used uninitialized" warnings as the result of missed optimizations.
This is in line with how UBSAN_SANITIZE_ALL and PROFILE_ALL_BRANCHES work, both of which have similar problems.
With an ARM allmodconfig kernel, I see the build time drop from 283 minutes CPU time to 225 minutes, and the vmlinux size drops from 43MB to 26MB.
--- kernel/gcov/Kconfig | 1 + 1 file changed, 1 insertion(+)
kernel/gcov/Kconfig +1 -0
@@ -37,6 +37,7 @@ config ARCH_HAS_GCOV_PROFILE_ALL config GCOV_PROFILE_ALL bool "Profile entire Kernel" + depends on !COMPILE_TEST depends on GCOV_KERNEL depends on ARCH_HAS_GCOV_PROFILE_ALL default n
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/asm: Use register variable to get stack pointer value
In reply to Sasha LevinFrom: Andrey Ryabinin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 196bd485ee4f03ce4c690bfcf38138abfcd0a4bc ]
Currently we use current_stack_pointer() function to get the value of the stack pointer register. Since commit:
f5caf621ee35 ("x86/asm: Fix inline asm call constraints for Clang")
... we have a stack register variable declared. It can be used instead of current_stack_pointer() function which allows to optimize away some excessive "mov %rsp, %<dst>" instructions:
-mov %rsp,%rdx -sub %rdx,%rax -cmp $0x3fff,%rax -ja ffffffff810722fd <ist_begin_non_atomic+0x2d>
+sub %rsp,%rax +cmp $0x3fff,%rax +ja ffffffff810722fa <ist_begin_non_atomic+0x2a>
Remove current_stack_pointer(), rename __asm_call_sp to current_stack_pointer and use it instead of the removed function.
--- arch/x86/include/asm/asm.h | 11 +++++++++++ arch/x86/include/asm/thread_info.h | 11 ----------- arch/x86/kernel/irq_32.c | 6 +++--- arch/x86/kernel/traps.c | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-)
arch/x86/include/asm/asm.h +11 -0
@@ -88,4 +88,15 @@/* For C file, we already have NOKPROBE_SYMBOL macro */ #endif +#ifndef __ASSEMBLY__ +/* +* This output constraint should be used for any inline asm which has a "call" +* instruction. Otherwise the asm may be inserted before the frame pointer +* gets set up by the containing function. If you forget to do this, objtool +* may print a "call without frame pointer save/setup" warning. +*/ +registerunsigned long current_stack_pointer asm (_ASM_SP ); +#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer) +#endif +#endif /* _ASM_X86_ASM_H */
arch/x86/include/asm/thread_info.h +0 -11
@@ -184,17 +184,6 @@ static inline struct thread_info *current_thread_info(void) return (struct thread_info *)(current_top_of_stack() - THREAD_SIZE); } -static inline unsigned long current_stack_pointer (void ) -{ -unsigned long sp; -#ifdef CONFIG_X86_64 - asm("mov %%rsp,%0" :"=g" (sp)); -#else - asm("mov %%esp,%0" :"=g" (sp)); -#endif -return sp; -} -#else /* !__ASSEMBLY__ */ /* Load thread_info address into "reg" */
arch/x86/kernel/irq_32.c +3 -3
@@ -71,7 +71,7 @@ static void call_on_stack(void *func, void *stack)static inline void *current_stack (void ) { -return (void *)(current_stack_pointer () & ~(THREAD_SIZE -1 )); +return (void *)(current_stack_pointer & ~(THREAD_SIZE -1 )); } static inline int
@@ -96,7 +96,7 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)/* Save the next esp at the bottom of the stack */ prev_esp = (u32 *)irqstk; - *prev_esp =current_stack_pointer (); + *prev_esp = current_stack_pointer;if (unlikely (overflow))call_on_stack (print_stack_overflow, isp);
@@ -149,7 +149,7 @@ void do_softirq_own_stack(void)/* Push the previous esp onto the stack */ prev_esp = (u32 *)irqstk; - *prev_esp =current_stack_pointer (); + *prev_esp = current_stack_pointer;call_on_stack (__do_softirq, isp); }
arch/x86/kernel/traps.c +1 -1
@@ -175,7 +175,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)* from double_fault. */ BUG_ON ((unsigned long )(current_top_of_stack () - -current_stack_pointer ()) >=THREAD_SIZE ); + current_stack_pointer) >=THREAD_SIZE );preempt_count_sub (HARDIRQ_OFFSET ); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/kbuild: enable modversions for symbols exported from asm
In reply to Sasha LevinFrom: Adam Borowski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 334bb773876403eae3457d81be0b8ea70f8e4ccc ]
Commit 4efca4ed ("kbuild: modversions for EXPORT_SYMBOL() for asm") adds modversion support for symbols exported from asm files. Architectures must include C-style declarations for those symbols in asm/asm-prototypes.h in order for them to be versioned.
Add these declarations for x86, and an architecture-independent file that can be used for common symbols.
With f27c2f6 reverting 8ab2ae6 ("default exported asm symbols to zero") we produce a scary warning on x86, this commit fixes that.
--- arch/x86/include/asm/asm-prototypes.h | 16 ++++++++++++++++ include/asm-generic/asm-prototypes.h | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 arch/x86/include/asm/asm-prototypes.h create mode 100644 include/asm-generic/asm-prototypes.h
arch/x86/include/asm/asm-prototypes.h new file +16 -0
@@ -0,0 +1,16 @@ +#include <asm/ftrace.h> +#include <asm/uaccess.h> +#include <asm/string.h> +#include <asm/page.h> +#include <asm/checksum.h> + +#include <asm-generic/asm-prototypes.h> + +#include <asm/page.h> +#include <asm/pgtable.h> +#include <asm/special_insns.h> +#include <asm/preempt.h> + +#ifndef CONFIG_X86_CMPXCHG64 +extern void cmpxchg8b_emu (void ); +#endif
include/asm-generic/asm-prototypes.h new file +7 -0
@@ -0,0 +1,7 @@ +#include <linux/bitops.h> +extern void *__memset (void *,int ,__kernel_size_t ); +extern void *__memcpy (void *,const void *,__kernel_size_t ); +extern void *__memmove (void *,const void *,__kernel_size_t ); +extern void *memset (void *,int ,__kernel_size_t ); +extern void *memcpy (void *,const void *,__kernel_size_t ); +extern void *memmove (void *,const void *,__kernel_size_t );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/asm: Make asm/alternative.h safe from assembly
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f005f5d860e0231fe212cfda8c1a3148b99609f4 ]
asm/alternative.h isn't directly useful from assembly, but it shouldn't break the build.
--- arch/x86/include/asm/alternative.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/include/asm/alternative.h +4 -0
@@ -1,6 +1,8 @@#ifndef _ASM_X86_ALTERNATIVE_H#define _ASM_X86_ALTERNATIVE_H +#ifndef __ASSEMBLY__ +#include <linux/types.h> #include <linux/stddef.h> #include <linux/stringify.h>
@@ -265,4 +267,6 @@ extern void *text_poke(void *addr, const void *opcode, size_t len);extern int poke_int3_handler (struct pt_regs *regs);extern void *text_poke_bp (void *addr,const void *opcode,size_t len,void *handler); +#endif /* __ASSEMBLY__ */ +#endif /* _ASM_X86_ALTERNATIVE_H */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] EXPORT_SYMBOL() for asm
In reply to Sasha LevinFrom: Al Viro <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 22823ab419d8ed884195cfa75483fd3a99bb1462 ]
Add asm-usable variants of EXPORT_SYMBOL/EXPORT_SYMBOL_GPL. This commit just adds the default implementation; most of the architectures can simply add export.h to asm/Kbuild and start using <asm/export.h> from assembler. The rest needs to have their <asm/export.h> define everal macros and then explicitly include <asm-generic/export.h>
One area where the things might diverge from default is the alignment; normally it's 8 bytes on 64bit targets and 4 on 32bit ones, both for unsigned long and for struct kernel_symbol. Unfortunately, amd64 and m68k are unusual - m68k aligns to 2 bytes (for both) and amd64 aligns struct kernel_symbol to 16 bytes. For those we'll need asm/export.h to override the constants used by generic version - KSYM_ALIGN and KCRC_ALIGN for kernel_symbol and unsigned long resp. And no, __alignof__ would not do the trick - on amd64 __alignof__ of struct kernel_symbol is 8, not 16.
More serious source of unpleasantness is treatment of function descriptors on architectures that have those. Things like ppc64, parisc, ia64, etc. need more than the address of the first insn to call an arbitrary function. As the result, their representation of pointers to functions is not the typical "address of the entry point" - it's an address of a small static structure containing all the required information (including the entry point, of course). Sadly, the asm-side conventions differ in what the function name refers to - entry point or the function descriptor. On ppc64 we do the latter;
bar: .quad foo
is what void (*bar)(void) = foo; turns into and the rare places where we need to explicitly work with the label of entry point are dealt with as DOTSYM(foo). For our purposes it's ideal - generic macros are usable. However, parisc would have foo and P%foo used for label of entry point and address of the function descriptor and
bar: .long P%foo
woudl be used instead. ia64 goes similar to parisc in that respect,
except that there it's @fptr(foo) rather than P%foo. Such architectures need to define KSYM_FUNC that would turn a function name into whatever is needed to refer to function descriptor.
What's more, on such architectures we need to know whether we are exporting a function or an object - in assembler we have to tell that explicitly, to decide whether we want EXPORT_SYMBOL(foo) produce e.g.
__ksymtab_foo: .quad foo
or
__ksymtab_foo: .quad @fptr(foo)
For that reason we introduce EXPORT_DATA_SYMBOL{,_GPL}(), to be used for exports of data objects. On normal architectures it's the same thing as EXPORT_SYMBOL{,_GPL}(), but on parisc-like ones they differ and the right one needs to be used. Most of the exports are functions, so we keep EXPORT_SYMBOL for those...
--- include/asm-generic/export.h | 94 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 include/asm-generic/export.h
include/asm-generic/export.h new file +94 -0
@@ -0,0 +1,94 @@ +#ifndef __ASM_GENERIC_EXPORT_H +#define __ASM_GENERIC_EXPORT_H + +#ifndef KSYM_FUNC +#define KSYM_FUNC(x) x +#endif +#ifdef CONFIG_64BIT +#define __put .quad +#ifndef KSYM_ALIGN +#define KSYM_ALIGN 8 +#endif +#ifndef KCRC_ALIGN +#define KCRC_ALIGN 8 +#endif +#else +#define __put .long +#ifndef KSYM_ALIGN +#define KSYM_ALIGN 4 +#endif +#ifndef KCRC_ALIGN +#define KCRC_ALIGN 4 +#endif +#endif + +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define KSYM(name) _##name +#else +#define KSYM(name) name +#endif + +/* + * note on .section use: @progbits vs %progbits nastiness doesn't matter, + * since we immediately emit into those sections anyway. + */ +.macro ___EXPORT_SYMBOL name,val,sec +#ifdef CONFIG_MODULES + .globl KSYM(__ksymtab_\name) + .section ___ksymtab\sec+\name,"a" + .balign KSYM_ALIGN +KSYM(__ksymtab_\name): + __put \val, KSYM(__kstrtab_\name) + .previous + .section __ksymtab_strings,"a" +KSYM(__kstrtab_\name): +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX + .asciz "_\name" +#else + .asciz "\name" +#endif + .previous +#ifdef CONFIG_MODVERSIONS + .section ___kcrctab\sec+\name,"a" + .balign KCRC_ALIGN +KSYM(__kcrctab_\name): + __put KSYM(__crc_\name) + .weak KSYM(__crc_\name) + .previous +#endif +#endif +.endm +#undef __put + +#if defined(__KSYM_DEPS__) + +#define __EXPORT_SYMBOL(sym, val, sec) === __KSYM_##sym === + +#elif defined(CONFIG_TRIM_UNUSED_KSYMS) + +#include <linux/kconfig.h> +#include <generated/autoksyms.h> + +#define __EXPORT_SYMBOL(sym, val, sec) \ + __cond_export_sym(sym, val, sec, config_enabled(__KSYM_##sym)) +#define __cond_export_sym(sym, val, sec, conf) \ + ___cond_export_sym(sym, val, sec, conf) +#define ___cond_export_sym(sym, val, sec, enabled) \ + __cond_export_sym_##enabled(sym, val, sec) +#define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec +#define __cond_export_sym_0(sym, val, sec) /* nothing */ + +#else +#define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec +#endif + +#define EXPORT_SYMBOL(name) \ + __EXPORT_SYMBOL(name, KSYM_FUNC(KSYM(name)),) +#define EXPORT_SYMBOL_GPL(name) \ + __EXPORT_SYMBOL(name, KSYM_FUNC(KSYM(name)), _gpl) +#define EXPORT_DATA_SYMBOL(name) \ + __EXPORT_SYMBOL(name, KSYM(name),) +#define EXPORT_DATA_SYMBOL_GPL(name) \ + __EXPORT_SYMBOL(name, KSYM(name),_gpl) + +#endif
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kconfig.h: use __is_defined() to check if MODULE is defined
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4f920843d248946545415c1bf6120942048708ed ]
The macro MODULE is not a config option, it is a per-file build option. So, config_enabled(MODULE) is not sensible. (There is another case in include/linux/export.h, where config_enabled() is used against a non-config option.)
This commit renames some macros in include/linux/kconfig.h for the use for non-config macros and replaces config_enabled(MODULE) with __is_defined(MODULE).
I am keeping config_enabled() because it is still referenced from some places, but I expect it would be deprecated in the future.
--- include/linux/kconfig.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
include/linux/kconfig.h +6 -5
@@ -17,10 +17,11 @@* the last step cherry picks the 2nd arg, we get a zero. */ #define __ARG_PLACEHOLDER_1 0, -#define config_enabled (cfg) _config_enabled(cfg) -#define _config_enabled (value) __config_enabled(__ARG_PLACEHOLDER_##value) -#define __config_enabled (arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0) -#define ___config_enabled (__ignored, val, ...) val +#define config_enabled (cfg) ___is_defined(cfg) +#define __is_defined (x) ___is_defined(x) +#define ___is_defined (val) ____is_defined(__ARG_PLACEHOLDER_##val) +#define ____is_defined (arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0) +#define __take_second_arg (__ignored, val, ...) val/* * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
@@ -42,7 +43,7 @@* built-in code when CONFIG_FOO is set to 'm'. */ #define IS_REACHABLE (option) (config_enabled(option) || \ - (config_enabled(option##_MODULE) && config_enabled(MODULE))) + (config_enabled(option##_MODULE) && __is_defined(MODULE)))/* * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/retpoline/checksum32: Convert assembler indirect jumps
In reply to Sasha LevinFrom: David Woodhouse <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5096732f6f695001fa2d6f1335a2680b37912c69 ]
Convert all indirect jumps in 32bit checksum assembler code to use non-speculative sequences when CONFIG_RETPOLINE is enabled.
--- arch/x86/lib/checksum_32.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/lib/checksum_32.S +4 -3
@@ -29,7 +29,8 @@ #include <asm/dwarf2.h> #include <asm/errno.h> #include <asm/asm.h> - +#include <asm/nospec-branch.h> + /* * computes a partial checksum, e.g. for TCP/UDP fragments */
@@ -159,7 +160,7 @@ ENTRY(csum_partial) negl %ebx lea 45f(%ebx,%ebx,2), %ebx testl %esi, %esi - jmp *%ebx + JMP_NOSPEC %ebx # Handle 2-byte-aligned regions 20: addw (%esi), %ax
@@ -446,7 +447,7 @@ ENTRY(csum_partial_copy_generic) andl $-32,%edx lea 3f(%ebx,%ebx), %ebx testl %esi, %esi - jmp *%ebx + JMP_NOSPEC %ebx 1: addl $64,%esi addl $64,%edi SRC(movb -32(%edx),%bl) ; SRC(movb (%edx),%bl)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] scsi: sg: disable SET_FORCE_LOW_DMA
In reply to Sasha LevinFrom: Hannes Reinecke <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 745dfa0d8ec26b24f3304459ff6e9eacc5c8351b ]
The ioctl SET_FORCE_LOW_DMA has never worked since the initial git check-in, and the respective setting is nowadays handled correctly. So disable it entirely.
--- drivers/scsi/sg.c | 30 +++++++++--------------------- include/scsi/sg.h | 1 - 2 files changed, 9 insertions(+), 22 deletions(-)
drivers/scsi/sg.c +9 -21
@@ -160,7 +160,6 @@ typedef struct sg_fd { /* holds the state of a file descriptor */struct list_head rq_list;/* head of request list */ struct fasync_struct *async_qp;/* used by asynchronous notification */ Sg_request req_arr[SG_MAX_QUEUE ];/* used as singly-linked list */ -char low_dma;/* as in parent but possibly overridden to 1 */ char force_packid;/* 1 -> pack_id input to read(), 0 -> ignored */ char cmd_q;/* 1 -> allow command queuing, 0 -> don't */ unsigned char next_cmd_len;/* 0: automatic, >0: use on next write() */
@@ -926,24 +925,14 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)/* strange ..., for backward compatibility */ return sfp->timeout_user;case SG_SET_FORCE_LOW_DMA : - result =get_user (val, ip); -if (result) -return result; -if (val) { - sfp->low_dma =1 ; -if ((0 == sfp->low_dma) && !sfp->res_in_use) { - val = (int ) sfp->reserve.bufflen; -sg_remove_scat (sfp, &sfp->reserve); -sg_build_reserve (sfp, val); - } - }else { -if (atomic_read (&sdp->detaching)) -return -ENODEV ; - sfp->low_dma = sdp->device->host->unchecked_isa_dma; - } +/* +* N.B. This ioctl never worked properly, but failed to +* return an error value. So returning '0' to keep compability +* with legacy applications. +*/ return 0 ;case SG_GET_LOW_DMA : -return put_user ((int ) sfp->low_dma, ip); +return put_user ((int ) sdp->device->host->unchecked_isa_dma, ip);case SG_GET_SCSI_ID :if (!access_ok (VERIFY_WRITE , p,sizeof (sg_scsi_id_t)))return -EFAULT ;
@@ -1864,6 +1853,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)int sg_tablesize = sfp->parentdp->sg_tablesize;int blk_size = buff_size, order;gfp_t gfp_mask =GFP_ATOMIC | __GFP_COMP | __GFP_NOWARN; +struct sg_device *sdp = sfp->parentdp;if (blk_size <0 )return -EFAULT ;
@@ -1889,7 +1879,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) scatter_elem_sz_prev = num; } -if (sfp->low_dma) +if (sdp->device->host->unchecked_isa_dma) gfp_mask |=GFP_DMA ;if (!capable (CAP_SYS_ADMIN ) || !capable (CAP_SYS_RAWIO ))
@@ -2152,8 +2142,6 @@ sg_add_sfp(Sg_device * sdp) sfp->timeout =SG_DEFAULT_TIMEOUT ; sfp->timeout_user =SG_DEFAULT_TIMEOUT_USER ; sfp->force_packid =SG_DEF_FORCE_PACK_ID ; - sfp->low_dma = (SG_DEF_FORCE_LOW_DMA ==0 ) ? - sdp->device->host->unchecked_isa_dma :1 ; sfp->cmd_q =SG_DEF_COMMAND_Q ; sfp->keep_orphan =SG_DEF_KEEP_ORPHAN ; sfp->parentdp = sdp;
@@ -2612,7 +2600,7 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)jiffies_to_msecs (fp->timeout), fp->reserve.bufflen, (int ) fp->reserve.k_use_sg, - (int) fp->low_dma); + (int) sdp->device->host->unchecked_isa_dma);seq_printf (s," cmd_q=%d f_packid=%d k_orphan=%d closed=0\n" , (int ) fp->cmd_q, (int ) fp->force_packid, (int ) fp->keep_orphan);
include/scsi/sg.h +0 -1
@@ -197,7 +197,6 @@ typedef struct sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */#define SG_DEFAULT_RETRIES 0/* Defaults, commented if they differ from original sg driver */ -#define SG_DEF_FORCE_LOW_DMA 0/* was 1 -> memory below 16MB on i386 */ #define SG_DEF_FORCE_PACK_ID 0#define SG_DEF_KEEP_ORPHAN 0#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ/* load time option */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] futex: Prevent overflow by strengthen input validation
In reply to Sasha LevinFrom: Li Jinyue <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fbe0e839d1e22d88810f3ee3e2f1479be4c0aa4a ]
UBSAN reports signed integer overflow in kernel/futex.c:
UBSAN: Undefined behaviour in kernel/futex.c:2041:18 signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'
Add a sanity check to catch negative values of nr_wake and nr_requeue.
--- kernel/futex.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/futex.c +3 -0
@@ -1514,6 +1514,9 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags,struct futex_hash_bucket *hb1, *hb2;struct futex_q *this, *next; +if (nr_wake <0 || nr_requeue <0 ) +return -EINVAL ; +if (requeue_pi) {/* * Requeue PI only works on two distinct uaddrs. This
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: pcm: Remove yet superfluous WARN_ON()
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 23b19b7b50fe1867da8d431eea9cd3e4b6328c2c ]
muldiv32() contains a snd_BUG_ON() (which is morphed as WARN_ON() with debug option) for checking the case of 0 / 0. This would be helpful if this happens only as a logical error; however, since the hw refine is performed with any data set provided by user, the inconsistent values that can trigger such a condition might be passed easily. Actually, syzbot caught this by passing some zero'ed old hw_params ioctl.
So, having snd_BUG_ON() there is simply superfluous and rather harmful to give unnecessary confusions. Let's get rid of it.
--- sound/core/pcm_lib.c | 1 - 1 file changed, 1 deletion(-)
sound/core/pcm_lib.c +0 -1
@@ -578,7 +578,6 @@ static inline unsigned int muldiv32(unsigned int a, unsigned int b, {u_int64_t n = (u_int64_t ) a * b;if (c ==0 ) { -snd_BUG_ON (!n); *r =0 ;return UINT_MAX ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: hda - Apply headphone noise quirk for another Dell XPS 13 variant
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e4c9fd10eb21376f44723c40ad12395089251c28 ]
There is another Dell XPS 13 variant (SSID 1028:082a) that requires the existing fixup for reducing the headphone noise. This patch adds the quirk entry for that.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -5493,6 +5493,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1028 ,0x075b ,"Dell XPS 13 9360" ,ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE ),SND_PCI_QUIRK (0x1028 ,0x075d ,"Dell AIO" ,ALC298_FIXUP_SPK_VOLUME ),SND_PCI_QUIRK (0x1028 ,0x0798 ,"Dell Inspiron 17 7000 Gaming" ,ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER ), +SND_PCI_QUIRK (0x1028 ,0x082a ,"Dell XPS 13 9360" ,ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE ),SND_PCI_QUIRK (0x1028 ,0x164a ,"Dell" ,ALC293_FIXUP_DELL1_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x164b ,"Dell" ,ALC293_FIXUP_DELL1_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: hda - Apply the existing quirk to iMac 14,1
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 031f335cda879450095873003abb03ae8ed3b74a ]
iMac 14,1 requires the same quirk as iMac 12,2, using GPIO 2 and 3 for headphone and speaker output amps. Add the codec SSID quirk entry (106b:0600) accordingly.
--- sound/pci/hda/patch_cirrus.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_cirrus.c +1 -0
@@ -394,6 +394,7 @@ static const struct snd_pci_quirk cs420x_fixup_tbl[] = {/*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/ /* codec SSID */ +SND_PCI_QUIRK (0x106b ,0x0600 ,"iMac 14,1" ,CS420X_IMAC27_122 ),SND_PCI_QUIRK (0x106b ,0x1c00 ,"MacBookPro 8,1" ,CS420X_MBP81 ),SND_PCI_QUIRK (0x106b ,0x2000 ,"iMac 12,2" ,CS420X_IMAC27_122 ), SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] af_key: fix buffer overread in verify_address_len()
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 06b335cb51af018d5feeff5dd4fd53847ddb675a ]
If a message sent to a PF_KEY socket ended with one of the extensions that takes a 'struct sadb_address' but there were not enough bytes remaining in the message for the ->sa_family member of the 'struct sockaddr' which is supposed to follow, then verify_address_len() read past the end of the message, into uninitialized memory. Fix it by returning -EINVAL in this case.
This bug was found using syzkaller with KMSAN.
Reproducer:
#include <linux/pfkeyv2.h>
#include <sys/socket.h>
#include <unistd.h>
int main()
{
int sock = socket(PF_KEY, SOCK_RAW, PF_KEY_V2);
char buf[24] = { 0 };
struct sadb_msg *msg = (void *)buf;
struct sadb_address *addr = (void *)(msg + 1);
msg->sadb_msg_version = PF_KEY_V2;
msg->sadb_msg_type = SADB_DELETE;
msg->sadb_msg_len = 3;
addr->sadb_address_len = 1;
addr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
write(sock, buf, 24);
}--- net/key/af_key.c | 5 +++++ 1 file changed, 5 insertions(+)
net/key/af_key.c +5 -0
@@ -401,6 +401,11 @@ static int verify_address_len(const void *p)#endif int len; +if (sp->sadb_address_len < +DIV_ROUND_UP (sizeof (*sp) +offsetofend (typeof (*addr), sa_family), +sizeof (uint64_t ))) +return -EINVAL ; +switch (addr->sa_family) {case AF_INET : len =DIV_ROUND_UP (sizeof (*sp) +sizeof (*sin),sizeof (uint64_t ));
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] af_key: fix buffer overread in parse_exthdrs()
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4e765b4972af7b07adcb1feb16e7a525ce1f6b28 ]
If a message sent to a PF_KEY socket ended with an incomplete extension header (fewer than 4 bytes remaining), then parse_exthdrs() read past the end of the message, into uninitialized memory. Fix it by returning -EINVAL in this case.
Reproducer:
#include <linux/pfkeyv2.h>
#include <sys/socket.h>
#include <unistd.h>
int main()
{
int sock = socket(PF_KEY, SOCK_RAW, PF_KEY_V2);
char buf[17] = { 0 };
struct sadb_msg *msg = (void *)buf;
msg->sadb_msg_version = PF_KEY_V2;
msg->sadb_msg_type = SADB_DELETE;
msg->sadb_msg_len = 2;
write(sock, buf, 17);
}--- net/key/af_key.c | 3 +++ 1 file changed, 3 insertions(+)
net/key/af_key.c +3 -0
@@ -516,6 +516,9 @@ static int parse_exthdrs(struct sk_buff *skb, const struct sadb_msg *hdr, void *uint16_t ext_type;int ext_len; +if (len <sizeof (*ehdr)) +return -EINVAL ; + ext_len = ehdr->sadb_ext_len; ext_len *=sizeof (uint64_t ); ext_type = ehdr->sadb_ext_type;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] module: Add retpoline tag to VERMAGIC
In reply to Sasha LevinFrom: Andi Kleen <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6cfb521ac0d5b97470883ff9b7facae264b7ab12 ]
Add a marker for retpoline to the module VERMAGIC. This catches the case when a non RETPOLINE compiled module gets loaded into a retpoline kernel, making it insecure.
It doesn't handle the case when retpoline has been runtime disabled. Even in this case the match of the retcompile status will be enforced. This implies that even with retpoline run time disabled all modules loaded need to be recompiled.
--- include/linux/vermagic.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/vermagic.h +7 -1
@@ -24,10 +24,16 @@#ifndef MODULE_ARCH_VERMAGIC #define MODULE_ARCH_VERMAGIC ""#endif +#ifdef RETPOLINE +#define MODULE_VERMAGIC_RETPOLINE "retpoline " +#else +#define MODULE_VERMAGIC_RETPOLINE "" +#endif #define VERMAGIC_STRING \ UTS_RELEASE " " \ MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \ MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \ - MODULE_ARCH_VERMAGIC + MODULE_ARCH_VERMAGIC \ + MODULE_VERMAGIC_RETPOLINE
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] pipe: avoid round_pipe_size() nr_pages overflow on 32-bit
In reply to Sasha LevinFrom: Joe Lawrence <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d3f14c485867cfb2e0c48aa88c41d0ef4bf5209c ]
round_pipe_size() contains a right-bit-shift expression which may overflow, which would cause undefined results in a subsequent roundup_pow_of_two() call.
static inline unsigned int round_pipe_size(unsigned int size)
{
unsigned long nr_pages;
nr_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
return roundup_pow_of_two(nr_pages) << PAGE_SHIFT;}
PAGE_SIZE is defined as (1UL << PAGE_SHIFT), so:
- 4 bytes wide on 32-bit (0 to 0xffffffff)
- 8 bytes wide on 64-bit (0 to 0xffffffffffffffff)
That means that 32-bit round_pipe_size(), nr_pages may overflow to 0:
size=0x00000000 nr_pages=0x0 size=0x00000001 nr_pages=0x1 size=0xfffff000 nr_pages=0xfffff size=0xfffff001 nr_pages=0x0 << ! size=0xffffffff nr_pages=0x0 << !
This is bad because roundup_pow_of_two(n) is undefined when n == 0!
64-bit is not a problem as the unsigned int size is 4 bytes wide (similar to 32-bit) and the larger, 8 byte wide unsigned long, is sufficient to handle the largest value of the bit shift expression:
size=0xffffffff nr_pages=100000
Modify round_pipe_size() to return 0 if n == 0 and updates its callers to handle accordingly.
--- fs/pipe.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
fs/pipe.c +16 -2
@@ -999,6 +999,9 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages) {struct pipe_buffer *bufs; +if (!nr_pages) +return -EINVAL ; +/* * We can shrink the pipe, if arg >= pipe->nrbufs. Since we don't * expect a lot of shrink+grow operations, just free and allocate
@@ -1043,13 +1046,19 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)/* * Currently we rely on the pipe array holding a power-of-2 number -* of pages. +* of pages. Returns 0 on error. */ static inline unsigned int round_pipe_size (unsigned int size) {unsigned long nr_pages; +if (size < pipe_min_size) + size = pipe_min_size; + nr_pages = (size +PAGE_SIZE -1 ) >>PAGE_SHIFT ; +if (nr_pages ==0 ) +return 0 ; +return roundup_pow_of_two (nr_pages) <<PAGE_SHIFT ; }
@@ -1060,13 +1069,18 @@ static inline unsigned int round_pipe_size(unsigned int size)int pipe_proc_fn (struct ctl_table *table,int write,void __user *buf,size_t *lenp,loff_t *ppos) { +unsigned int rounded_pipe_max_size;int ret; ret =proc_dointvec_minmax (table, write, buf, lenp, ppos);if (ret <0 || !write)return ret; - pipe_max_size =round_pipe_size (pipe_max_size); + rounded_pipe_max_size =round_pipe_size (pipe_max_size); +if (rounded_pipe_max_size ==0 ) +return -EINVAL ; + + pipe_max_size = rounded_pipe_max_size;return ret; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit acfb3b883f6d6a4b5d27ad7fdded11f6a09ae6dd ]
KVM doesn't follow the SMCCC when it comes to unimplemented calls, and inject an UNDEF instead of returning an error. Since firmware calls are now used for security mitigation, they are becoming more common, and the undef is counter productive.
Instead, let's follow the SMCCC which states that -1 must be returned to the caller when getting an unknown function number.
--- arch/arm64/kvm/handle_exit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/handle_exit.c +2 -2
@@ -42,7 +42,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) ret =kvm_psci_call (vcpu);if (ret <0 ) { -kvm_inject_undefined (vcpu); +vcpu_set_reg (vcpu,0 , ~0UL );return 1 ; }
@@ -51,7 +51,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)static int handle_smc (struct kvm_vcpu *vcpu,struct kvm_run *run) { -kvm_inject_undefined (vcpu); +vcpu_set_reg (vcpu,0 , ~0UL );return 1 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Input: twl6040-vibra - fix DT node memory management
In reply to Sasha LevinFrom: "H. Nikolaus Schaller" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c52c545ead97fcc2f4f8ea38f1ae3c23211e09a8 ]
commit e7ec014a47e4 ("Input: twl6040-vibra - update for device tree support")
made the separate vibra DT node to a subnode of the twl6040.
It now calls of_find_node_by_name() to locate the "vibra" subnode. This function has a side effect to call of_node_put on() for the twl6040 parent node passed in as a parameter. This causes trouble later on.
Solution: we must call of_node_get() before of_find_node_by_name()
--- drivers/input/misc/twl6040-vibra.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/misc/twl6040-vibra.c +1 -0
@@ -262,6 +262,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)int vddvibr_uV =0 ;int error; +of_node_get (twl6040_core_dev->of_node); twl6040_core_node =of_find_node_by_name (twl6040_core_dev->of_node,"vibra" );if (!twl6040_core_node) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Input: 88pm860x-ts - fix child-node lookup
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 906bf7daa0618d0ef39f4872ca42218c29a3631f ]
Fix child node-lookup during probe, which ended up searching the whole device tree depth-first starting at parent rather than just matching on its children.
To make things worse, the parent node was prematurely freed, while the child node was leaked.
--- drivers/input/touchscreen/88pm860x-ts.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/input/touchscreen/88pm860x-ts.c +12 -4
@@ -126,7 +126,7 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,int data, n, ret;if (!np)return -ENODEV ; - np =of_find_node_by_name (np,"touch" ); + np =of_get_child_by_name (np,"touch" );if (!np) {dev_err (&pdev->dev,"Can't find touch node\n" );return -EINVAL ;
@@ -144,13 +144,13 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,if (data) { ret =pm860x_reg_write (i2c,PM8607_GPADC_MISC1 , data);if (ret <0 ) -return -EINVAL ; + goto err_put_node; }/* set tsi prebias time */ if (!of_property_read_u32 (np,"marvell,88pm860x-tsi-prebias" , &data)) { ret =pm860x_reg_write (i2c,PM8607_TSI_PREBIAS , data);if (ret <0 ) -return -EINVAL ; + goto err_put_node; }/* set prebias & prechg time of pen detect */ data =0 ;
@@ -161,10 +161,18 @@ static int pm860x_touch_dt_init(struct platform_device *pdev,if (data) { ret =pm860x_reg_write (i2c,PM8607_PD_PREBIAS , data);if (ret <0 ) -return -EINVAL ; + goto err_put_node; }of_property_read_u32 (np,"marvell,88pm860x-resistor-X" , res_x); + +of_node_put (np); +return 0 ; + +err_put_node: +of_node_put (np); + + return -EINVAL; }#else #define pm860x_touch_dt_init (x, y, z) (-1)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] MIPS: AR7: ensure the port type's FCR value is used
In reply to Sasha LevinFrom: Jonas Gorski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0a5191efe06b5103909206e4fbcff81d30283f8e ]
Since commit aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers"), the port's default FCR value isn't used in serial8250_do_set_termios anymore, but copied over once in serial8250_config_port and then modified as needed.
Unfortunately, serial8250_config_port will never be called if the port is shared between kernel and userspace, and the port's flag doesn't have UPF_BOOT_AUTOCONF, which would trigger a serial8250_config_port as well.
This causes garbled output from userspace:
[ 5.220000] random: procd urandom read with 49 bits of entropy available
ers
[kee
Fix this by forcing it to be configured on boot, resulting in the expected output:
[ 5.250000] random: procd urandom read with 50 bits of entropy available
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
Patchwork: https://patchwork.linux-mips.org/patch/17544/
--- arch/mips/ar7/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/ar7/platform.c +1 -1
@@ -577,7 +577,7 @@ static int __init ar7_register_uarts(void) uart_port.type =PORT_AR7 ; uart_port.uartclk =clk_get_rate (bus_clk) /2 ; uart_port.iotype =UPIO_MEM32 ; - uart_port.flags =UPF_FIXED_TYPE ; + uart_port.flags =UPF_FIXED_TYPE |UPF_BOOT_AUTOCONF ; uart_port.regshift =2 ; uart_port.line =0 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Input: twl6040-vibra - fix child-node lookup
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dcaf12a8b0bbdbfcfa2be8dff2c4948d9844b4ad ]
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at parent rather than just matching on its children.
Later sanity checks on node properties (which would likely be missing) should prevent this from causing much trouble however, especially as the original premature free of the parent node has already been fixed separately (but that "fix" was apparently never backported to stable).
--- drivers/input/misc/twl6040-vibra.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/misc/twl6040-vibra.c +1 -2
@@ -262,8 +262,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)int vddvibr_uV =0 ;int error; -of_node_get (twl6040_core_dev->of_node); - twl6040_core_node =of_find_node_by_name (twl6040_core_dev->of_node, + twl6040_core_node =of_get_child_by_name (twl6040_core_dev->of_node,"vibra" );if (!twl6040_core_node) {dev_err (&pdev->dev,"parent of node is missing?\n" );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tracing: Fix converting enum's from the map in trace_event_eval_update()
In reply to Sasha LevinFrom: "Steven Rostedt (VMware)" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1ebe1eaf2f02784921759992ae1fde1a9bec8fd0 ]
Since enums do not get converted by the TRACE_EVENT macro into their values, the event format displaces the enum name and not the value. This breaks tools like perf and trace-cmd that need to interpret the raw binary data. To solve this, an enum map was created to convert these enums into their actual numbers on boot up. This is done by TRACE_EVENTS() adding a TRACE_DEFINE_ENUM() macro.
Some enums were not being converted. This was caused by an optization that had a bug in it.
All calls get checked against this enum map to see if it should be converted or not, and it compares the call's system to the system that the enum map was created under. If they match, then they call is processed.
To cut down on the number of iterations needed to find the maps with a matching system, since calls and maps are grouped by system, when a match is made, the index into the map array is saved, so that the next call, if it belongs to the same system as the previous call, could start right at that array index and not have to scan all the previous arrays.
The problem was, the saved index was used as the variable to know if this is a call in a new system or not. If the index was zero, it was assumed that the call is in a new system and would keep incrementing the saved index until it found a matching system. The issue arises when the first matching system was at index zero. The next map, if it belonged to the same system, would then think it was the first match and increment the index to one. If the next call belong to the same system, it would begin its search of the maps off by one, and miss the first enum that should be converted. This left a single enum not converted properly.
Also add a comment to describe exactly what that index was for. It took me a bit too long to figure out what I was thinking when debugging this issue.
--- kernel/trace/trace_events.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
kernel/trace/trace_events.c +15 -1
@@ -1819,6 +1819,7 @@ void trace_event_enum_update(struct trace_enum_map **map, int len) {struct ftrace_event_call *call, *p;const char *last_system =NULL ; +bool first = false;int last_i;int i;
@@ -1826,15 +1827,28 @@ void trace_event_enum_update(struct trace_enum_map **map, int len)list_for_each_entry_safe (call, p, &ftrace_events, list) {/* events are usually grouped together with systems */ if (!last_system || call->class->system != last_system) { + first = true; last_i =0 ; last_system = call->class->system; } +/* +* Since calls are grouped by systems, the likelyhood that the +* next call in the iteration belongs to the same system as the +* previous call is high. As an optimization, we skip seaching +* for a map[] that matches the call's system if the last call +* was from the same system. That's what last_i is for. If the +* call has the same system as the previous call, then last_i +* will be the index of the first map[] that has a matching +* system. +*/ for (i = last_i; i < len; i++) {if (call->class->system == map[i]->system) {/* Save the first system if need be */ -if (!last_i) +if (first) { last_i = i; + first = false; + }update_event_printk (call, map[i]); } }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/asm/32: Make sync_core() handle missing CPUID on all 32-bit kernels
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1c52d859cb2d417e7216d3e56bb7fea88444cec9 ]
We support various non-Intel CPUs that don't have the CPUID instruction, so the M486 test was wrong. For now, fix it with a big
hammer: handle missing CPUID on all 32-bit CPUs.
--- arch/x86/include/asm/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/processor.h +1 -1
@@ -701,7 +701,7 @@ static inline void sync_core(void) {int tmp; -#ifdef CONFIG_M486 +#ifdef CONFIG_X86_32 /* * Do a CPUID if available, otherwise do a jump. The jump * can conveniently enough be the jump around CPUID.
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ARM: dts: kirkwood: fix pin-muxing of MPP7 on OpenBlocks A7
In reply to Sasha LevinFrom: Thomas Petazzoni <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 56aeb07c914a616ab84357d34f8414a69b140cdf ]
MPP7 is currently muxed as "gpio", but this function doesn't exist for MPP7, only "gpo" is available. This causes the following error:
kirkwood-pinctrl f1010000.pin-controller: unsupported function gpio on pin mpp7 pinctrl core: failed to register map default (6): invalid type given kirkwood-pinctrl f1010000.pin-controller: error claiming hogs: -22 kirkwood-pinctrl f1010000.pin-controller: could not claim hogs: -22 kirkwood-pinctrl f1010000.pin-controller: unable to register pinctrl driver
kirkwood-pinctrl: probe of f1010000.pin-controller failed with error -22
So the pinctrl driver is not probed, all device drivers (including the UART driver) do a -EPROBE_DEFER, and therefore the system doesn't really boot (well, it boots, but with no UART, and no devices that require pin-muxing).
Back when the Device Tree file for this board was introduced, the definition was already wrong. The pinctrl driver also always described as "gpo" this function for MPP7. However, between Linux 4.10 and 4.11, a hog pin failing to be muxed was turned from a simple warning to a hard error that caused the entire pinctrl driver probe to bail out. This is probably the result of commit 6118714275f0a ("pinctrl:
core: Fix pinctrl_register_and_init() with pinctrl_enable()").
This commit fixes the Device Tree to use the proper "gpo" function for MPP7, which fixes the boot of OpenBlocks A7, which was broken since Linux 4.11.
--- arch/arm/boot/dts/kirkwood-openblocks_a7.dts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm/boot/dts/kirkwood-openblocks_a7.dts +8 -2
@@ -53,7 +53,8 @@ }; pinctrl: pin-controller@10000 { - pinctrl-0 = <&pmx_dip_switches &pmx_gpio_header>; + pinctrl-0 = <&pmx_dip_switches &pmx_gpio_header + &pmx_gpio_header_gpo>; pinctrl-names = "default"; pmx_uart0: pmx-uart0 {
@@ -85,11 +86,16 @@ * ground. */ pmx_gpio_header: pmx-gpio-header { - marvell,pins = "mpp17", "mpp7", "mpp29", "mpp28", + marvell,pins = "mpp17", "mpp29", "mpp28", "mpp35", "mpp34", "mpp40"; marvell,function = "gpio"; }; + pmx_gpio_header_gpo: pxm-gpio-header-gpo { + marvell,pins = "mpp7"; + marvell,function = "gpo"; + }; + pmx_gpio_init: pmx-init { marvell,pins = "mpp38"; marvell,function = "gpio";
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] can: peak: fix potential bug in packet fragmentation
In reply to Sasha LevinFrom: Stephane Grosjean <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d8a243af1a68395e07ac85384a2740d4134c67f4 ]
In some rare conditions when running one PEAK USB-FD interface over a non high-speed USB controller, one useless USB fragment might be sent. This patch fixes the way a USB command is fragmented when its length is greater than 64 bytes and when the underlying USB controller is not a high-speed one.
--- drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb_fd.c +11 -10
@@ -184,7 +184,7 @@ static int pcan_usb_fd_send_cmd(struct peak_usb_device *dev, void *cmd_tail)void *cmd_head =pcan_usb_fd_cmd_buffer (dev);int err =0 ;u8 *packet_ptr; -int i, n =1 , packet_len; +int packet_len;ptrdiff_t cmd_len;/* usb device unregistered? */
@@ -201,17 +201,13 @@ static int pcan_usb_fd_send_cmd(struct peak_usb_device *dev, void *cmd_tail) } packet_ptr = cmd_head; + packet_len = cmd_len;/* firmware is not able to re-assemble 512 bytes buffer in full-speed */ -if ((dev->udev->speed !=USB_SPEED_HIGH ) && - (cmd_len >PCAN_UFD_LOSPD_PKT_SIZE )) { - packet_len =PCAN_UFD_LOSPD_PKT_SIZE ; - n += cmd_len / packet_len; - }else { - packet_len = cmd_len; - } +if (unlikely (dev->udev->speed !=USB_SPEED_HIGH )) + packet_len =min (packet_len,PCAN_UFD_LOSPD_PKT_SIZE ); -for (i =0 ; i < n; i++) { + do { err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, PCAN_USBPRO_EP_CMDOUT),
@@ -224,7 +220,12 @@ static int pcan_usb_fd_send_cmd(struct peak_usb_device *dev, void *cmd_tail) } packet_ptr += packet_len; - } + cmd_len -= packet_len; + +if (cmd_len <PCAN_UFD_LOSPD_PKT_SIZE ) + packet_len = cmd_len; + + }while (packet_len >0 );return err; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] time: Avoid undefined behaviour in ktime_add_safe()
In reply to Sasha LevinFrom: Vegard Nossum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 979515c5645830465739254abc1b1648ada41518 ]
I ran into this:
================================================================================
UBSAN: Undefined behaviour in kernel/time/hrtimer.c:310:16
signed integer overflow:
9223372036854775807 + 50000 cannot be represented in type 'long long int'
CPU: 2 PID: 4798 Comm: trinity-c2 Not tainted 4.8.0-rc1+ #91
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
0000000000000000 ffff88010ce6fb88 ffffffff82344740 0000000041b58ab3
ffffffff84f97a20 ffffffff82344694 ffff88010ce6fbb0 ffff88010ce6fb60
000000000000c350 ffff88010ce6f968 dffffc0000000000 ffffffff857bc320
Call Trace:
[<ffffffff82344740>] dump_stack+0xac/0xfc
[<ffffffff82344694>] ? _atomic_dec_and_lock+0xc4/0xc4
[<ffffffff8242df78>] ubsan_epilogue+0xd/0x8a
[<ffffffff8242e6b4>] handle_overflow+0x202/0x23d
[<ffffffff8242e4b2>] ? val_to_string.constprop.6+0x11e/0x11e
[<ffffffff8236df71>] ? timerqueue_add+0x151/0x410
[<ffffffff81485c48>] ? hrtimer_start_range_ns+0x3b8/0x1380
[<ffffffff81795631>] ? memset+0x31/0x40
[<ffffffff8242e6fd>] __ubsan_handle_add_overflow+0xe/0x10
[<ffffffff81488ac9>] hrtimer_nanosleep+0x5d9/0x790
[<ffffffff814884f0>] ? hrtimer_init_sleeper+0x80/0x80
[<ffffffff813a9ffb>] ? __might_sleep+0x5b/0x260
[<ffffffff8148be10>] common_nsleep+0x20/0x30
[<ffffffff814906c7>] SyS_clock_nanosleep+0x197/0x210
[<ffffffff81490530>] ? SyS_clock_getres+0x150/0x150
[<ffffffff823c7113>] ? __this_cpu_preempt_check+0x13/0x20
[<ffffffff8162ef60>] ? __context_tracking_exit.part.3+0x30/0x1b0
[<ffffffff81490530>] ? SyS_clock_getres+0x150/0x150
[<ffffffff81007bd3>] do_syscall_64+0x1b3/0x4b0
[<ffffffff845f85aa>] entry_SYSCALL64_slow_path+0x25/0x25
================================================================================Add a new ktime_add_unsafe() helper which doesn't check for overflow, but doesn't throw a UBSAN warning when it does overflow either.
--- include/linux/ktime.h | 7 +++++++ kernel/time/hrtimer.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
include/linux/ktime.h +7 -0
@@ -63,6 +63,13 @@ static inline ktime_t ktime_set(const s64 secs, const unsigned long nsecs)#define ktime_add (lhs, rhs) \ ({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; }) +/* +* Same as ktime_add(), but avoids undefined behaviour on overflow; however, +* this means that you must check the result for overflow yourself. +*/ +#define ktime_add_unsafe (lhs, rhs) \ + ({ (ktime_t){ .tv64 = (u64) (lhs).tv64 + (rhs).tv64 }; }) +/* * Add a ktime_t variable and a scalar nanosecond value. * res = kt + nsval:
kernel/time/hrtimer.c +1 -1
@@ -292,7 +292,7 @@ EXPORT_SYMBOL_GPL(__ktime_divns);*/ ktime_t ktime_add_safe (const ktime_t lhs,const ktime_t rhs) { -ktime_t res =ktime_add (lhs, rhs); +ktime_t res =ktime_add_unsafe (lhs, rhs);/* * We use KTIME_SEC_MAX here, the maximum timeout which we can
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] libata: apply MAX_SEC_1024 to all LITEON EP1 series devices
In reply to Sasha LevinFrom: Xinyu Lin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit db5ff909798ef0099004ad50a0ff5fde92426fd1 ]
LITEON EP1 has the same timeout issues as CX1 series devices.
Revert max_sectors to the value of 1024.
'e0edc8c54646 ("libata: apply MAX_SEC_1024 to all CX1-JB*-HP devices")'
--- drivers/ata/libata-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/libata-core.c +1 -0
@@ -4145,6 +4145,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {* https://bugzilla.kernel.org/show_bug.cgi?id=121671 */ { "LITEON CX1-JB*-HP", NULL, ATA_HORKAGE_MAX_SEC_1024 }, + { "LITEON EP1-*", NULL, ATA_HORKAGE_MAX_SEC_1024 },/* Devices we expect to fail diagnostics */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: Fix implicit fallthrough warning
In reply to Sasha LevinFrom: Jonathan Dieter <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cfd6ed4537a9e938fa76facecd4b9cd65b6d1563 ]
GCC 7 now warns when switch statements fall through implicitly, and with -Werror enabled in configure.ac, that makes these tools unbuildable.
We fix this by notifying the compiler that this particular case statement is meant to fall through.
--- tools/usb/usbip/src/usbip.c | 2 ++ 1 file changed, 2 insertions(+)
tools/usb/usbip/src/usbip.c +2 -0
@@ -176,6 +176,8 @@ int main(int argc, char *argv[])break ;case '?' :printf ("usbip: invalid option\n" ); +/* Terminate after printing error */ +/* FALLTHRU */ default :usbip_usage (); goto out;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] dm btree: fix serious bug in btree_split_beneath()
In reply to Sasha LevinFrom: Joe Thornber <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bc68d0a43560e950850fc69b58f0f8254b28f6d6 ]
When inserting a new key/value pair into a btree we walk down the spine of btree nodes performing the following 2 operations:
i) space for a new entry
ii) adjusting the first key entry if the new key is lower than any in the node.
If the _root_ node is full, the function btree_split_beneath() allocates 2 new nodes, and redistibutes the root nodes entries between them. The root node is left with 2 entries corresponding to the 2 new nodes.
btree_split_beneath() then adjusts the spine to point to one of the two new children. This means the first key is never adjusted if the new key was lower, ie. operation (ii) gets missed out. This can result in the new key being 'lost' for a period; until another low valued key is inserted that will uncover it.
This is a serious bug, and quite hard to make trigger in normal use. A reproducing test case ("thin create devices-in-reverse-order") is available as part of the thin-provision-tools project:
https://github.com/jthornber/thin-provisioning-tools/blob/master/functional-tests/device-mapper/dm-tests.scm#L593
Fix the issue by changing btree_split_beneath() so it no longer adjusts the spine. Instead it unlocks both the new nodes, and lets the main loop in btree_insert_raw() relock the appropriate one and make any neccessary adjustments.
--- drivers/md/persistent-data/dm-btree.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/md/persistent-data/dm-btree.c +2 -17
@@ -572,23 +572,8 @@ static int btree_split_beneath(struct shadow_spine *s, uint64_t key) pn->keys[1 ] = rn->keys[0 ];memcpy_disk (value_ptr (pn,1 ), &val,sizeof (__le64)); -/* -* rejig the spine. This is ugly, since it knows too -* much about the spine -*/ -if (s->nodes[0 ] != new_parent) { -unlock_block (s->info, s->nodes[0 ]); - s->nodes[0 ] = new_parent; - } -if (key <le64_to_cpu (rn->keys[0 ])) { -unlock_block (s->info, right); - s->nodes[1 ] = left; - }else { -unlock_block (s->info, left); - s->nodes[1 ] = right; - } - s->count =2 ; - +unlock_block (s->info, left); +unlock_block (s->info, right);return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: prevent vhci_hcd driver from leaking a socket pointer address
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2f2d0088eb93db5c649d2a5e34a3800a8a935fc5 ]
When a client has a USB device attached over IP, the vhci_hcd driver is locally leaking a socket pointer address via the
/sys/devices/platform/vhci_hcd/status file (world-readable) and in debug output when "usbip --debug port" is run.
Fix it to not leak. The socket pointer address is not used at the moment and it was made visible as a convenient way to find IP address from socket pointer address by looking up /proc/net/{tcp,tcp6}.
As this opens a security hole, the fix replaces socket pointer address with sockfd.
--- drivers/usb/usbip/usbip_common.h | 1 + drivers/usb/usbip/vhci_sysfs.c | 25 +++++++++++++++---------- tools/usb/usbip/libsrc/vhci_driver.c | 8 ++++---- 3 files changed, 20 insertions(+), 14 deletions(-)
drivers/usb/usbip/usbip_common.h +1 -0
@@ -261,6 +261,7 @@ struct usbip_device {/* lock for status */ spinlock_t lock; +int sockfd;struct socket *tcp_socket;struct task_struct *tcp_rx;
drivers/usb/usbip/vhci_sysfs.c +15 -10
@@ -39,16 +39,20 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr,/* * output example: -* prt sta spd dev socket local_busid -* 000 004 000 000 c5a7bb80 1-2.3 -* 001 004 000 000 d8cee980 2-3.4 +* port sta spd dev sockfd local_busid +* 0000 004 000 00000000 000003 1-2.3 +* 0001 004 000 00000000 000004 2-3.4 * -* IP address can be retrieved from a socket pointer address by looking -* up /proc/net/{tcp,tcp6}. Also, a userland program may remember a -* port number and its peer IP address. +* Output includes socket fd instead of socket pointer address to +* avoid leaking kernel memory address in: +* /sys/devices/platform/vhci_hcd.0/status and in debug output. +* The socket pointer address is not used at the moment and it was +* made visible as a convenient way to find IP address from socket +* pointer address by looking up /proc/net/{tcp,tcp6}. As this opens +* a security hole, the change is made to use sockfd instead. */ out +=sprintf (out, -"prt sta spd bus dev socket local_busid\n" ); +"prt sta spd bus dev sockfd local_busid\n" );for (i =0 ; i <VHCI_NPORTS ; i++) {struct vhci_device *vdev =port_to_vdev (i);
@@ -60,11 +64,11 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr, out +=sprintf (out,"%03u %08x " , vdev->speed, vdev->devid); out +=sprintf (out,"%16p " , vdev->ud.tcp_socket); + out +=sprintf (out,"%06u" , vdev->ud.sockfd); out +=sprintf (out,"%s" ,dev_name (&vdev->udev->dev)); - }else { - out +=sprintf (out,"000 000 000 0000000000000000 0-0" ); - } + }else + out +=sprintf (out,"000 000 000 000000 0-0" ); out +=sprintf (out,"\n" );spin_unlock (&vdev->ud.lock);
@@ -223,6 +227,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, vdev->devid = devid; vdev->speed = speed; + vdev->ud.sockfd = sockfd; vdev->ud.tcp_socket = socket; vdev->ud.status =VDEV_ST_NOTASSIGNED ;
tools/usb/usbip/libsrc/vhci_driver.c +4 -4
@@ -55,12 +55,12 @@ static int parse_status(const char *value)while (*c !='\0' ) {int port, status, speed, devid; -unsigned long socket; +int sockfd;char lbusid[SYSFS_BUS_ID_SIZE ]; - ret =sscanf (c,"%d %d %d %x %lx %31s\n" , + ret =sscanf (c,"%d %d %d %x %u %31s\n" , &port, &status, &speed, - &devid, &socket, lbusid); + &devid, &sockfd, lbusid);if (ret <5 ) {dbg ("sscanf failed: %d" , ret);
@@ -69,7 +69,7 @@ static int parse_status(const char *value)dbg ("port %d status %d speed %d devid %x" , port, status, speed, devid); -dbg ("socket %lx lbusid %s" , socket, lbusid); +dbg ("sockfd %u lbusid %s" , sockfd, lbusid);/* if a device is connected, look at it */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] drivers: base: cacheinfo: fix x86 with CONFIG_OF enabled
In reply to Sasha LevinFrom: Sudeep Holla <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fac51482577d5e05bbb0efa8d602a3c2111098bf ]
With CONFIG_OF enabled on x86, we get the following error on boot:
"
Failed to find cpu0 device node
Unable to detect cache hierarchy from DT for CPU 0
"
and the cacheinfo fails to get populated in the corresponding sysfs entries. This is because cache_setup_of_node looks for of_node for setting up the shared cpu_map without checking that it's already populated in the architecture specific callback.
In order to indicate that the shared cpu_map is already populated, this patch introduces a boolean cpu_map_populated in struct cpu_cacheinfo that can be used by the generic code to skip cache_shared_cpu_map_setup.
This patch also sets that boolean for x86.
--- arch/x86/kernel/cpu/intel_cacheinfo.c | 2 ++ drivers/base/cacheinfo.c | 3 +++ include/linux/cacheinfo.h | 1 + 3 files changed, 6 insertions(+)
arch/x86/kernel/cpu/intel_cacheinfo.c +2 -0
@@ -934,6 +934,8 @@ static int __populate_cache_leaves(unsigned int cpu)ci_leaf_init (this_leaf++, &id4_regs);__cache_cpumap_setup (cpu, idx, &id4_regs); } + this_cpu_ci->cpu_map_populated = true; +return 0 ; }
drivers/base/cacheinfo.c +3 -0
@@ -106,6 +106,9 @@ static int cache_shared_cpu_map_setup(unsigned int cpu)unsigned int index;int ret; +if (this_cpu_ci->cpu_map_populated) +return 0 ; + ret =cache_setup_of_node (cpu);if (ret)return ret;
include/linux/cacheinfo.h +1 -0
@@ -71,6 +71,7 @@ struct cpu_cacheinfo {struct cacheinfo *info_list;unsigned int num_levels;unsigned int num_leaves; +bool cpu_map_populated; };/*
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: Fix potential format overflow in userspace tools
In reply to Sasha LevinFrom: Jonathan Dieter <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e5dfa3f902b9a642ae8c6997d57d7c41e384a90b ]
The usbip userspace tools call sprintf()/snprintf() and don't check for the return value which can lead the paths to overflow, truncating the final file in the path.
More urgently, GCC 7 now warns that these aren't checked with -Wformat-overflow, and with -Werror enabled in configure.ac, that makes these tools unbuildable.
This patch fixes these problems by replacing sprintf() with snprintf() in one place and adding checks for the return value of snprintf().
--- tools/usb/usbip/libsrc/usbip_common.c | 9 ++++++++- tools/usb/usbip/libsrc/usbip_host_driver.c | 27 ++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-)
tools/usb/usbip/libsrc/usbip_common.c +8 -1
@@ -215,9 +215,16 @@ int read_usb_interface(struct usbip_usb_device *udev, int i, struct usbip_usb_interface *uinf) {char busid[SYSFS_BUS_ID_SIZE ]; +int size;struct udev_device *sif; -sprintf (busid,"%s:%d.%d" , udev->busid, udev->bConfigurationValue, i); + size =snprintf (busid,sizeof (busid),"%s:%d.%d" , + udev->busid, udev->bConfigurationValue, i); +if (size <0 || (unsigned int )size >=sizeof (busid)) { +err ("busid length %i >= %lu or < 0" , size, + (unsigned long )sizeof (busid)); +return -1 ; + } sif =udev_device_new_from_subsystem_sysname (udev_context,"usb" , busid);if (!sif) {
tools/usb/usbip/libsrc/usbip_host_driver.c +22 -5
@@ -39,13 +39,19 @@ struct udev *udev_context;static int32_t read_attr_usbip_status (struct usbip_usb_device *udev) {char status_attr_path[SYSFS_PATH_MAX ]; +int size;int fd;int length;char status;int value =0 ; -snprintf (status_attr_path,SYSFS_PATH_MAX ,"%s/usbip_status" , - udev->path); + size =snprintf (status_attr_path,SYSFS_PATH_MAX ,"%s/usbip_status" , + udev->path); +if (size <0 || (unsigned int )size >=sizeof (status_attr_path)) { +err ("usbip_status path length %i >= %lu or < 0" , size, + (unsigned long )sizeof (status_attr_path)); +return -1 ; + } fd =open (status_attr_path,O_RDONLY );if (fd <0 ) {
@@ -225,6 +231,7 @@ int usbip_host_export_device(struct usbip_exported_device *edev, int sockfd) {char attr_name[] ="usbip_sockfd" ;char sockfd_attr_path[SYSFS_PATH_MAX ]; +int size;char sockfd_buff[30 ];int ret;
@@ -244,10 +251,20 @@ int usbip_host_export_device(struct usbip_exported_device *edev, int sockfd) }/* only the first interface is true */ -snprintf (sockfd_attr_path,sizeof (sockfd_attr_path),"%s/%s" , - edev->udev.path, attr_name); + size =snprintf (sockfd_attr_path,sizeof (sockfd_attr_path),"%s/%s" , + edev->udev.path, attr_name); +if (size <0 || (unsigned int )size >=sizeof (sockfd_attr_path)) { +err ("exported device path length %i >= %lu or < 0" , size, + (unsigned long )sizeof (sockfd_attr_path)); +return -1 ; + } -snprintf (sockfd_buff,sizeof (sockfd_buff),"%d\n" , sockfd); + size =snprintf (sockfd_buff,sizeof (sockfd_buff),"%d\n" , sockfd); +if (size <0 || (unsigned int )size >=sizeof (sockfd_buff)) { +err ("socket length %i >= %lu or < 0" , size, + (unsigned long )sizeof (sockfd_buff)); +return -1 ; + } ret =write_sysfs_attribute (sockfd_attr_path, sockfd_buff,strlen (sockfd_buff));
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6
In reply to Sasha LevinFrom: Dennis Yang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 490ae017f54e55bde382d45ea24bddfb6d1a0aaf ]
For btree removal, there is a corner case that a single thread could takes 6 locks which is more than THIN_MAX_CONCURRENT_LOCKS(5) and leads to deadlock.
A btree removal might eventually call rebalance_children()->rebalance3() to rebalance entries of three neighbor child nodes when shadow_spine has already acquired two write locks. In rebalance3(), it tries to shadow and acquire the write locks of all three child nodes. However, shadowing a child node requires acquiring a read lock of the original child node and a write lock of the new block. Although the read lock will be released after block shadowing, shadowing the third child node in rebalance3() could still take the sixth lock.
(2 write locks for shadow_spine +
2 write locks for the first two child nodes's shadow + 1 write lock for the last child node's shadow +
1 read lock for the last child node)
--- drivers/md/dm-thin-metadata.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/md/dm-thin-metadata.c +5 -1
@@ -81,10 +81,14 @@#define SECTOR_TO_BLOCK_SHIFT 3/* +* For btree insert: * 3 for btree insert + * 2 for btree lookup used within space map +* For btree remove: +* 2 for shadow spine + +* 4 for rebalance 3 child node */ -#define THIN_MAX_CONCURRENT_LOCKS 5 +#define THIN_MAX_CONCURRENT_LOCKS 6/* This should be plenty */ #define SPACE_MAP_ROOT_SIZE 128
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/cpu/intel: Introduce macros for Intel family numbers
In reply to Sasha LevinFrom: Dave Hansen <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 970442c599b22ccd644ebfe94d1d303bf6f87c05 ]
Problem:
We have a boatload of open-coded family-6 model numbers. Half of them have these model numbers in hex and the other half in decimal. This makes grepping for them tons of fun, if you were to try.
Solution:
Consolidate all the magic numbers. Put all the definitions in one header.
The names here are closely derived from the comments describing the models from arch/x86/events/intel/core.c. We could easily make them shorter by doing things like s/SANDYBRIDGE/SNB/, but they seemed fine even with the longer versions to me.
Do not take any of these names too literally, like "DESKTOP" or "MOBILE". These are all colloquial names and not precise descriptions of everywhere a given model will show up.
--- arch/x86/include/asm/intel-family.h | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 arch/x86/include/asm/intel-family.h
arch/x86/include/asm/intel-family.h new file +68 -0
@@ -0,0 +1,68 @@ +#ifndef _ASM_X86_INTEL_FAMILY_H +#define _ASM_X86_INTEL_FAMILY_H + +/* +* "Big Core" Processors (Branded as Core, Xeon, etc...) +* +* The "_X" parts are generally the EP and EX Xeons, or the +* "Extreme" ones, like Broadwell-E. +* +* Things ending in "2" are usually because we have no better +* name for them. There's no processor called "WESTMERE2". +*/ + +#define INTEL_FAM6_CORE_YONAH 0x0E +#define INTEL_FAM6_CORE2_MEROM 0x0F +#define INTEL_FAM6_CORE2_MEROM_L 0x16 +#define INTEL_FAM6_CORE2_PENRYN 0x17 +#define INTEL_FAM6_CORE2_DUNNINGTON 0x1D + +#define INTEL_FAM6_NEHALEM 0x1E +#define INTEL_FAM6_NEHALEM_EP 0x1A +#define INTEL_FAM6_NEHALEM_EX 0x2E +#define INTEL_FAM6_WESTMERE 0x25 +#define INTEL_FAM6_WESTMERE2 0x1F +#define INTEL_FAM6_WESTMERE_EP 0x2C +#define INTEL_FAM6_WESTMERE_EX 0x2F + +#define INTEL_FAM6_SANDYBRIDGE 0x2A +#define INTEL_FAM6_SANDYBRIDGE_X 0x2D +#define INTEL_FAM6_IVYBRIDGE 0x3A +#define INTEL_FAM6_IVYBRIDGE_X 0x3E + +#define INTEL_FAM6_HASWELL_CORE 0x3C +#define INTEL_FAM6_HASWELL_X 0x3F +#define INTEL_FAM6_HASWELL_ULT 0x45 +#define INTEL_FAM6_HASWELL_GT3E 0x46 + +#define INTEL_FAM6_BROADWELL_CORE 0x3D +#define INTEL_FAM6_BROADWELL_XEON_D 0x56 +#define INTEL_FAM6_BROADWELL_GT3E 0x47 +#define INTEL_FAM6_BROADWELL_X 0x4F + +#define INTEL_FAM6_SKYLAKE_MOBILE 0x4E +#define INTEL_FAM6_SKYLAKE_DESKTOP 0x5E +#define INTEL_FAM6_SKYLAKE_X 0x55 +#define INTEL_FAM6_KABYLAKE_MOBILE 0x8E +#define INTEL_FAM6_KABYLAKE_DESKTOP 0x9E + +/* "Small Core" Processors (Atom) */ + +#define INTEL_FAM6_ATOM_PINEVIEW 0x1C +#define INTEL_FAM6_ATOM_LINCROFT 0x26 +#define INTEL_FAM6_ATOM_PENWELL 0x27 +#define INTEL_FAM6_ATOM_CLOVERVIEW 0x35 +#define INTEL_FAM6_ATOM_CEDARVIEW 0x36 +#define INTEL_FAM6_ATOM_SILVERMONT1 0x37/* BayTrail/BYT / Valleyview */ +#define INTEL_FAM6_ATOM_SILVERMONT2 0x4D/* Avaton/Rangely */ +#define INTEL_FAM6_ATOM_AIRMONT 0x4C/* CherryTrail / Braswell */ +#define INTEL_FAM6_ATOM_MERRIFIELD1 0x4A/* Tangier */ +#define INTEL_FAM6_ATOM_MERRIFIELD2 0x5A/* Annidale */ +#define INTEL_FAM6_ATOM_GOLDMONT 0x5C +#define INTEL_FAM6_ATOM_DENVERTON 0x5F/* Goldmont Microserver */ + +/* Xeon Phi */ + +#define INTEL_FAM6_XEON_PHI_KNL 0x57/* Knights Landing */ + +#endif /* _ASM_X86_INTEL_FAMILY_H */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kbuild: modversions for EXPORT_SYMBOL() for asm
In reply to Sasha LevinFrom: Nicholas Piggin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4efca4ed05cbdfd13ec3e8cb623fb77d6e4ab187 ]
Allow architectures to create asm/asm-prototypes.h file that provides C prototypes for exported asm functions, which enables proper CRC versions to be generated for them.
--- scripts/Makefile.build | 87 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 7 deletions(-)
scripts/Makefile.build +80 -7
@@ -158,7 +158,8 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< $(obj)/%.i: $(src)/%.c FORCE $(call if_changed_dep,cc_i_c) -cmd_gensymtypes = \ +# These mirror gensymtypes_S and co below, keep them in synch. +cmd_gensymtypes_c = \ $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ $(GENKSYMS) $(if $(1), -T $(2)) \ $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \
@@ -168,7 +169,7 @@ cmd_gensymtypes = \ quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ cmd_cc_symtypes_c = \ set -e; \ - $(call cmd_gensymtypes,true,$@) >/dev/null; \ + $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ test -s $@ || rm -f $@ $(obj)/%.symtypes : $(src)/%.c FORCE
@@ -197,9 +198,10 @@ else # the actual value of the checksum generated by genksyms cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< -cmd_modversions = \ + +cmd_modversions_c = \ if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ - $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ + $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ > $(@D)/.tmp_$(@F:.o=.ver); \ \ $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
@@ -244,7 +246,7 @@ endif define rule_cc_o_c $(call echo-cmd,checksrc) $(cmd_checksrc) \ $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ - $(cmd_modversions) \ + $(cmd_modversions_c) \ $(call echo-cmd,record_mcount) \ $(cmd_record_mcount) \ scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
@@ -253,6 +255,15 @@ define rule_cc_o_c mv -f $(dot-target).tmp $(dot-target).cmd endef +define rule_as_o_S + $(call echo-cmd,as_o_S) $(cmd_as_o_S); \ + scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,as_o_S)' > \ + $(dot-target).tmp; \ + $(cmd_modversions_S) \ + rm -f $(depfile); \ + mv -f $(dot-target).tmp $(dot-target).cmd +endef + # Built-in and composite module parts $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE $(call cmd,force_checksrc)
@@ -281,6 +292,38 @@ modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) +# .S file exports must have their C prototypes defined in asm/asm-prototypes.h +# or a file that it includes, in order to get versioned symbols. We build a +# dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from +# the .S file (with trailing ';'), and run genksyms on that, to extract vers. +# +# This is convoluted. The .S file must first be preprocessed to run guards and +# expand names, then the resulting exports must be constructed into plain +# EXPORT_SYMBOL(symbol); to build our dummy C file, and that gets preprocessed +# to make the genksyms input. +# +# These mirror gensymtypes_c and co above, keep them in synch. +cmd_gensymtypes_S = \ + (echo "\#include <linux/kernel.h>" ; \ + echo "\#include <asm/asm-prototypes.h>" ; \ + $(CPP) $(a_flags) $< | \ + grep "\<___EXPORT_SYMBOL\>" | \ + sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \ + $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ + $(GENKSYMS) $(if $(1), -T $(2)) \ + $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ + $(if $(KBUILD_PRESERVE),-p) \ + -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) + +quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ +cmd_cc_symtypes_S = \ + set -e; \ + $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ + test -s $@ || rm -f $@ + +$(obj)/%.symtypes : $(src)/%.S FORCE + $(call cmd,cc_symtypes_S) + quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
@@ -288,10 +331,40 @@ $(obj)/%.s: $(src)/%.S FORCE $(call if_changed_dep,as_s_S) quiet_cmd_as_o_S = AS $(quiet_modtag) $@ -cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +ifndef CONFIG_MODVERSIONS +cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +else + +ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h) + +ifeq ($(ASM_PROTOTYPES),) +cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +else + +# versioning matches the C process described above, with difference that +# we parse asm-prototypes.h C header to get function definitions. + +cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $< + +cmd_modversions_S = \ + if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + $(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ + > $(@D)/.tmp_$(@F:.o=.ver); \ + \ + $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ + -T $(@D)/.tmp_$(@F:.o=.ver); \ + rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ + else \ + mv -f $(@D)/.tmp_$(@F) $@; \ + fi; +endif +endif $(obj)/%.o: $(src)/%.S FORCE - $(call if_changed_dep,as_o_S) + $(call if_changed_rule,as_o_S) targets += $(real-objs-y) $(real-objs-m) $(lib-y) targets += $(extra-y) $(MAKECMDGOALS) $(always)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once
In reply to Sasha LevinFrom: Marc Kleine-Budde <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8cb68751c115d176ec851ca56ecfbb411568c9e8 ]
If an invalid CAN frame is received, from a driver or from a tun interface, a Kernel warning is generated.
This patch replaces the WARN_ONCE by a simple pr_warn_once, so that a kernel, bootet with panic_on_warn, does not panic. A printk seems to be more appropriate here.
--- net/can/af_can.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/can/af_can.c +5 -6
@@ -714,13 +714,12 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev,if (unlikely (!net_eq (dev_net (dev), &init_net))) goto drop; -if (WARN_ONCE (dev->type !=ARPHRD_CAN || - skb->len !=CAN_MTU || - cfd->len >CAN_MAX_DLEN , -"PF_CAN: dropped non conform CAN skbuf: " -"dev type %d, len %d, datalen %d\n" , - dev->type, skb->len, cfd->len)) +if (unlikely (dev->type !=ARPHRD_CAN || skb->len !=CAN_MTU || + cfd->len >CAN_MAX_DLEN )) { +pr_warn_once ("PF_CAN: dropped non conform CAN skbuf: dev type %d, len %d, datalen %d\n" , + dev->type, skb->len, cfd->len); goto drop; + }can_receive (skb, dev);return NET_RX_SUCCESS ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] can: af_can: canfd_rcv(): replace WARN_ONCE by pr_warn_once
In reply to Sasha LevinFrom: Marc Kleine-Budde <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d4689846881d160a4d12a514e991a740bcb5d65a ]
If an invalid CANFD frame is received, from a driver or from a tun interface, a Kernel warning is generated.
This patch replaces the WARN_ONCE by a simple pr_warn_once, so that a kernel, bootet with panic_on_warn, does not panic. A printk seems to be more appropriate here.
--- net/can/af_can.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/can/af_can.c +5 -6
@@ -737,13 +737,12 @@ static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,if (unlikely (!net_eq (dev_net (dev), &init_net))) goto drop; -if (WARN_ONCE (dev->type !=ARPHRD_CAN || - skb->len !=CANFD_MTU || - cfd->len >CANFD_MAX_DLEN , -"PF_CAN: dropped non conform CAN FD skbuf: " -"dev type %d, len %d, datalen %d\n" , - dev->type, skb->len, cfd->len)) +if (unlikely (dev->type !=ARPHRD_CAN || skb->len !=CANFD_MTU || + cfd->len >CANFD_MAX_DLEN )) { +pr_warn_once ("PF_CAN: dropped non conform CAN FD skbuf: dev type %d, len %d, datalen %d\n" , + dev->type, skb->len, cfd->len); goto drop; + }can_receive (skb, dev);return NET_RX_SUCCESS ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] PM / sleep: declare __tracedata symbols as char[] rather than char
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f97238373b8662a6d580e204df2e7bcbfa43e27a ]
Accessing more than one byte from a symbol declared simply 'char' is undefined behavior, as reported by UBSAN:
UBSAN: Undefined behaviour in drivers/base/power/trace.c:178:18 load of address ffffffff8203fc78 with insufficient space for an object of type 'char'
Avoid this by declaring the symbols as arrays.
--- drivers/base/power/trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/power/trace.c +2 -2
@@ -166,14 +166,14 @@ void generate_pm_trace(const void *tracedata, unsigned int user) }EXPORT_SYMBOL (generate_pm_trace); -extern char __tracedata_start, __tracedata_end; +extern char __tracedata_start[], __tracedata_end[];static int show_file_hash (unsigned int value) {int match;char *tracedata; match =0 ; -for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; +for (tracedata = __tracedata_start ; tracedata < __tracedata_end ; tracedata +=2 +sizeof (unsigned long )) {unsigned short lineno = *(unsigned short *)tracedata;const char *file = *(const char **)(tracedata +2 );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] fs/select: add vmalloc fallback for select(2)
In reply to Sasha LevinFrom: Vlastimil Babka <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2d19309cf86883f634a4f8ec55a54bda87db19bf ]
The select(2) syscall performs a kmalloc(size, GFP_KERNEL) where size grows with the number of fds passed. We had a customer report page allocation failures of order-4 for this allocation. This is a costly order, so it might easily fail, as the VM expects such allocation to have a lower-order fallback.
Such trivial fallback is vmalloc(), as the memory doesn't have to be physically contiguous and the allocation is temporary for the duration of the syscall only. There were some concerns, whether this would have negative impact on the system by exposing vmalloc() to userspace. Although an excessive use of vmalloc can cause some system wide performance issues - TLB flushes etc. - a large order allocation is not for free either and an excessive reclaim/compaction can have a similar effect. Also note that the size is effectively limited by RLIMIT_NOFILE which defaults to 1024 on the systems I checked. That means the bitmaps will fit well within single page and thus the vmalloc() fallback could be only excercised for processes where root allows a higher limit.
Note that the poll(2) syscall seems to use a linked list of order-0 pages, so it doesn't need this kind of fallback.
--- fs/select.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/select.c +11 -3
@@ -29,6 +29,7 @@#include <linux/sched/rt.h> #include <linux/freezer.h> #include <net/busy_poll.h> +#include <linux/vmalloc.h> #include <asm/uaccess.h>
@@ -550,7 +551,7 @@ int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,fd_set_bits fds;void *bits;int ret, max_fds; -unsigned int size; +size_t size, alloc_size;struct fdtable *fdt;/* Allocate small arguments on the stack to save memory and be faster */ long stack_fds[SELECT_STACK_ALLOC /sizeof (long )];
@@ -577,7 +578,14 @@ int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,if (size >sizeof (stack_fds) /6 ) {/* Not enough space in on-stack array; must use kmalloc */ ret = -ENOMEM ; - bits =kmalloc (6 * size,GFP_KERNEL ); +if (size > (SIZE_MAX /6 )) + goto out_nofds; + + alloc_size =6 * size; + bits =kmalloc (alloc_size,GFP_KERNEL |__GFP_NOWARN); +if (!bits && alloc_size >PAGE_SIZE ) + bits =vmalloc (alloc_size); +if (!bits) goto out_nofds; }
@@ -614,7 +622,7 @@ int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, out:if (bits != stack_fds) -kfree (bits); +kvfree (bits); out_nofds:return ret; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] mm/mmap.c: do not blow on PROT_NONE MAP_FIXED holes in the stack
In reply to Sasha LevinFrom: Michal Hocko <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 561b5e0709e4a248c67d024d4d94b6e31e3edf2f ]
Commit 1be7107fbe18 ("mm: larger stack guard gap, between vmas") has introduced a regression in some rust and Java environments which are trying to implement their own stack guard page. They are punching a new MAP_FIXED mapping inside the existing stack Vma.
This will confuse expand_{downwards,upwards} into thinking that the stack expansion would in fact get us too close to an existing non-stack vma which is a correct behavior wrt safety. It is a real regression on the other hand.
Let's work around the problem by considering PROT_NONE mapping as a part of the stack. This is a gros hack but overflowing to such a mapping would trap anyway an we only can hope that usespace knows what it is doing and handle it propely.
--- mm/mmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/mmap.c +4 -2
@@ -2179,7 +2179,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)if (gap_addr < address)return -ENOMEM ; next = vma->vm_next; -if (next && next->vm_start < gap_addr) { +if (next && next->vm_start < gap_addr && + (next->vm_flags & (VM_WRITE |VM_READ |VM_EXEC ))) {if (!(next->vm_flags &VM_GROWSUP ))return -ENOMEM ;/* Check that both stack segments have the same anon_vma? */
@@ -2260,7 +2261,8 @@ int expand_downwards(struct vm_area_struct *vma,if (gap_addr > address)return -ENOMEM ; prev = vma->vm_prev; -if (prev && prev->vm_end > gap_addr) { +if (prev && prev->vm_end > gap_addr && + (prev->vm_flags & (VM_WRITE |VM_READ |VM_EXEC ))) {if (!(prev->vm_flags &VM_GROWSDOWN ))return -ENOMEM ;/* Check that both stack segments have the same anon_vma? */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] hwpoison, memcg: forcibly uncharge LRU pages
In reply to Sasha LevinFrom: Michal Hocko <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 18365225f0440d09708ad9daade2ec11275c3df9 ]
Laurent Dufour has noticed that hwpoinsoned pages are kept charged. In his particular case he has hit a bad_page("page still charged to cgroup") when onlining a hwpoison page. While this looks like something that shouldn't happen in the first place because onlining hwpages and returning them to the page allocator makes only little sense it shows a real problem.
hwpoison pages do not get freed usually so we do not uncharge them (at least not since commit 0a31bc97c80c ("mm: memcontrol: rewrite uncharge API")). Each charge pins memcg (since e8ea14cc6ead ("mm: memcontrol:
take a css reference for each charged page")) as well and so the mem_cgroup and the associated state will never go away. Fix this leak by forcibly uncharging a LRU hwpoisoned page in delete_from_lru_cache(). We also have to tweak uncharge_list because it cannot rely on zero ref count for these pages.
--- mm/memcontrol.c | 2 +- mm/memory-failure.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
mm/memcontrol.c +1 -1
@@ -5641,7 +5641,7 @@ static void uncharge_list(struct list_head *page_list) next = page->lru.next;VM_BUG_ON_PAGE (PageLRU (page), page); -VM_BUG_ON_PAGE (page_count (page), page); +VM_BUG_ON_PAGE (!PageHWPoison (page) &&page_count (page), page);if (!page->mem_cgroup)continue ;
mm/memory-failure.c +7 -0
@@ -582,6 +582,13 @@ static int delete_from_lru_cache(struct page *p)*/ ClearPageActive (p);ClearPageUnevictable (p); + +/* +* Poisoned page might never drop its ref count to 0 so we have +* to uncharge it manually from its memcg. +*/ +mem_cgroup_uncharge (p); +/* * drop the page count elevated by isolate_lru_page() */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] cma: fix calculation of aligned offset
In reply to Sasha LevinFrom: Doug Berger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e048cb32f69038aa1c8f11e5c1b331be4181659d ]
The align_offset parameter is used by bitmap_find_next_zero_area_off() to represent the offset of map's base from the previous alignment boundary; the function ensures that the returned index, plus the align_offset, honors the specified align_mask.
The logic introduced by commit b5be83e308f7 ("mm: cma: align to physical address, not CMA region position") has the cma driver calculate the offset to the *next* alignment boundary. In most cases, the base alignment is greater than that specified when making allocations, resulting in a zero offset whether we align up or down. In the example given with the commit, the base alignment (8MB) was half the requested alignment (16MB) so the math also happened to work since the offset is 8MB in both directions. However, when requesting allocations with an alignment greater than twice that of the base, the returned index would not be correctly aligned.
Also, the align_order arguments of cma_bitmap_aligned_mask() and cma_bitmap_aligned_offset() should not be negative so the argument type was made unsigned.
--- mm/cma.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
mm/cma.c +6 -9
@@ -54,7 +54,7 @@ unsigned long cma_get_size(const struct cma *cma) }static unsigned long cma_bitmap_aligned_mask (const struct cma *cma, -int align_order) +unsigned int align_order) {if (align_order <= cma->order_per_bit)return 0 ;
@@ -62,17 +62,14 @@ static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, }/* -* Find a PFN aligned to the specified order and return an offset represented in -* order_per_bits. +* Find the offset of the base PFN from the specified align_order. +* The value returned is represented in order_per_bits. */ static unsigned long cma_bitmap_aligned_offset (const struct cma *cma, -int align_order) +unsigned int align_order) { -if (align_order <= cma->order_per_bit) -return 0 ; - -return (ALIGN (cma->base_pfn, (1UL << align_order)) - - cma->base_pfn) >> cma->order_per_bit; +return (cma->base_pfn & ((1UL << align_order) -1 )) + >> cma->order_per_bit; } static unsigned long cma_bitmap_pages_to_bits(const struct cma *cma,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ipc: msg, make msgrcv work with LONG_MIN
In reply to Sasha LevinFrom: Jiri Slaby <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 999898355e08ae3b92dfd0a08db706e0c6703d30 ]
When LONG_MIN is passed to msgrcv, one would expect to recieve any message. But convert_mode does *msgtyp = -*msgtyp and -LONG_MIN is undefined. In particular, with my gcc -LONG_MIN produces -LONG_MIN again.
So handle this case properly by assigning LONG_MAX to *msgtyp if LONG_MIN was specified as msgtyp to msgrcv.
This code:
long msg[] = { 100, 200 };
int m = msgget(IPC_PRIVATE, IPC_CREAT | 0644);
msgsnd(m, &msg, sizeof(msg), 0);
msgrcv(m, &msg, sizeof(msg), LONG_MIN, 0);
produces currently nothing:
msgget(IPC_PRIVATE, IPC_CREAT|0644) = 65538
msgsnd(65538, {100, "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16, 0) = 0 msgrcv(65538, ...
Except a UBSAN warning:
UBSAN: Undefined behaviour in ipc/msg.c:745:13 negation of -9223372036854775808 cannot be represented in type 'long int':
With the patch, I see what I expect:
msgget(IPC_PRIVATE, IPC_CREAT|0644) = 0
msgsnd(0, {100, "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16, 0) = 0 msgrcv(0, {100, "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16, -9223372036854775808, 0) = 16
--- ipc/msg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
ipc/msg.c +4 -1
@@ -740,7 +740,10 @@ static inline int convert_mode(long *msgtyp, int msgflg)if (*msgtyp ==0 )return SEARCH_ANY ;if (*msgtyp <0 ) { - *msgtyp = -*msgtyp; +if (*msgtyp ==LONG_MIN )/* -LONG_MIN is undefined */ + *msgtyp =LONG_MAX ; +else + *msgtyp = -*msgtyp;return SEARCH_LESSEQUAL ; }if (msgflg &MSG_EXCEPT )
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/ioapic: Fix incorrect pointers in ioapic_setup_resources()
In reply to Sasha LevinFrom: Rui Wang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9d98bcec731756b8688b59ec998707924d716d7b ]
On a 4-socket Brickland system, hot-removing one ioapic is fine. Hot-removing the 2nd one causes panic in mp_unregister_ioapic() while calling release_resource().
It is because the iomem_res pointer has already been released when removing the first ioapic.
To explain the use of &res[num] here: res is assigned to ioapic_resources, and later in ioapic_insert_resources() we do:
struct resource *r = ioapic_resources;
for_each_ioapic(i) {
insert_resource(&iomem_resource, r);
r++;
}Here 'r' is treated as an arry of 'struct resource', and the r++ ensures that each element of the array is inserted separately. Thus we should call release_resouce() on each element at &res[num].
Fix it by assigning the correct pointers to ioapics[i].iomem_res in ioapic_setup_resources().
--- arch/x86/kernel/apic/io_apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/apic/io_apic.c +1 -1
@@ -2728,8 +2728,8 @@ static struct resource * __init ioapic_setup_resources(void) res[num].flags =IORESOURCE_MEM |IORESOURCE_BUSY ;snprintf (mem,IOAPIC_RESOURCE_NAME_SIZE ,"IOAPIC %u" , i); mem +=IOAPIC_RESOURCE_NAME_SIZE ; + ioapics[i].iomem_res = &res[num]; num++; - ioapics[i].iomem_res = res; } ioapic_resources = res;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ACPI / processor: Avoid reserving IO regions too early
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 86314751c7945fa0c67f459beeda2e7c610ca429 ]
Roland Dreier reports that one of his systems cannot boot because of the changes made by commit ac212b6980d8 (ACPI / processor: Use common hotplug infrastructure).
The problematic part of it is the request_region() call in acpi_processor_get_info() that used to run at module init time before the above commit and now it runs much earlier. Unfortunately, the region(s) reserved by it fall into a range the PCI subsystem attempts to reserve for AHCI IO BARs. As a result, the PCI reservation fails and AHCI doesn't work, while previously the PCI reservation would be made before acpi_processor_get_info() and it would succeed.
That request_region() call, however, was overlooked by commit ac212b6980d8, as it is not necessary for the enumeration of the processors. It only is needed when the ACPI processor driver actually attempts to handle them which doesn't happen before loading the ACPI processor driver module. Therefore that call should have been moved from acpi_processor_get_info() into that module.
Address the problem by moving the request_region() call in question out of acpi_processor_get_info() and use the observation that the region reserved by it is only needed if the FADT-based CPU throttling method is going to be used, which means that it should be sufficient to invoke it from acpi_processor_get_throttling_fadt().
--- drivers/acpi/acpi_processor.c | 9 --------- drivers/acpi/processor_throttling.c | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/acpi/acpi_processor.c +0 -9
@@ -315,15 +315,6 @@ static int acpi_processor_get_info(struct acpi_device *device) pr->throttling.duty_width = acpi_gbl_FADT.duty_width; pr->pblk = object.processor.pblk_address; - -/* -* We don't care about error returns - we just try to mark -* these reserved so that nobody else is confused into thinking -* that this region might be unused.. -* -* (In particular, allocating the IO range for Cardbus) -*/ -request_region (pr->throttling.address,6 ,"ACPI CPU throttle" ); }/*
drivers/acpi/processor_throttling.c +9 -0
@@ -680,6 +680,15 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)if (!pr->flags.throttling)return -ENODEV ; +/* +* We don't care about error returns - we just try to mark +* these reserved so that nobody else is confused into thinking +* that this region might be unused.. +* +* (In particular, allocating the IO range for Cardbus) +*/ +request_region (pr->throttling.address,6 ,"ACPI CPU throttle" ); + pr->throttling.state =0 ; duty_mask = pr->throttling.state_count -1 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: arp_tables: fix invoking 32bit "iptable -P INPUT ACCEPT" failed in 64bit kernel
In reply to Sasha LevinFrom: Hongxu Jia <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 17a49cd549d9dc8707dc9262210166455c612dde ]
Since 09d9686047db ("netfilter: x_tables: do compat validation via translate_table"), it used compatr structure to assign newinfo structure. In translate_compat_table of ip_tables.c and ip6_tables.c, it used compatr->hook_entry to replace info->hook_entry and compatr->underflow to replace info->underflow, but not do the same replacement in arp_tables.c.
It caused invoking 32-bit "arptbale -P INPUT ACCEPT" failed in 64bit kernel.
--------------------------------------
root@qemux86-64:~# arptables -P INPUT ACCEPT root@qemux86-64:~# arptables -P INPUT ACCEPT ERROR: Policy for `INPUT' offset 448 != underflow 0 arptables: Incompatible with this kernel --------------------------------------
--- net/ipv4/netfilter/arp_tables.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/netfilter/arp_tables.c +2 -2
@@ -1330,8 +1330,8 @@ static int translate_compat_table(struct xt_table_info **pinfo, 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]; + newinfo->hook_entry[i] = compatr->hook_entry[i]; + newinfo->underflow[i] = compatr->underflow[i]; } entry1 = newinfo->entries[raw_smp_processor_id ()]; pos = entry1;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: nf_ct_expect: remove the redundant slash when policy name is empty
In reply to Sasha LevinFrom: Liping Zhang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b173a28f62cf929324a8a6adcc45adadce311d16 ]
The 'name' filed in struct nf_conntrack_expect_policy{} is not a pointer, so check it is NULL or not will always return true. Even if the name is empty, slash will always be displayed like follows:
# cat /proc/net/nf_conntrack_expect
297 l3proto = 2 proto=6 src=1.1.1.1 dst=2.2.2.2 sport=1 dport=1025 ftp/
^--- net/netfilter/nf_conntrack_expect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_expect.c +1 -1
@@ -557,7 +557,7 @@ static int exp_seq_show(struct seq_file *s, void *v) helper =rcu_dereference (nfct_help (expect->master)->helper);if (helper) {seq_printf (s,"%s%s" , expect->flags ?" " :"" , helper->name); -if (helper->expect_policy[expect->class].name) +if (helper->expect_policy[expect->class].name[0 ])seq_printf (s,"/%s" , helper->expect_policy[expect->class].name); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: restart search if moved to other chain
In reply to Sasha LevinFrom: Florian Westphal <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 95a8d19f28e6b29377a880c6264391a62e07fccc ]
In case nf_conntrack_tuple_taken did not find a conflicting entry check that all entries in this hash slot were tested and restart in case an entry was moved to another chain.
--- net/netfilter/nf_conntrack_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/netfilter/nf_conntrack_core.c +7 -0
@@ -695,6 +695,7 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,* least once for the stats anyway. */ rcu_read_lock_bh (); + begin:hlist_nulls_for_each_entry_rcu (h, n, &net->ct.hash[hash], hnnode) { ct =nf_ct_tuplehash_to_ctrack (h); if (ct != ignored_conntrack &&
@@ -706,6 +707,12 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple, }NF_CT_STAT_INC (net, searched); } + +if (get_nulls_value (n) != hash) { +NF_CT_STAT_INC (net, search_restart); + goto begin; + } +rcu_read_unlock_bh ();return 0 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: nf_conntrack_sip: extend request line validation
In reply to Sasha LevinFrom: Ulrich Weber <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 444f901742d054a4cd5ff045871eac5131646cfb ]
on SIP requests, so a fragmented TCP SIP packet from an allow header starting with
INVITE,NOTIFY,OPTIONS,REFER,REGISTER,UPDATE,SUBSCRIBE
Content-Length: 0
will not bet interpreted as an INVITE request. Also Request-URI must start with an alphabetic character.
Confirm with RFC 3261
Request-Line = Method SP Request-URI SP SIP-Version CRLF
--- net/netfilter/nf_conntrack_sip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_sip.c +4 -1
@@ -1434,9 +1434,12 @@ static int process_sip_request(struct sk_buff *skb, unsigned int protoff, handler = &sip_handlers[i];if (handler->request ==NULL )continue ; -if (*datalen < handler->len || +if (*datalen < handler->len +2 ||strncasecmp (*dptr, handler->method, handler->len))continue ; +if ((*dptr)[handler->len] !=' ' || + !isalpha ((*dptr)[handler->len+1 ])) +continue ;if (ct_sip_get_header (ct, *dptr,0 , *datalen,SIP_HDR_CSEQ , &matchoff, &matchlen) <=0 ) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: nfnetlink_cthelper: Add missing permission checks
In reply to Sasha LevinFrom: Kevin Cernekee <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4b380c42f7d00a395feede754f0bc2292eebe6e5 ]
The capability check in nfnetlink_rcv() verifies that the caller has CAP_NET_ADMIN in the namespace that "owns" the netlink socket. However, nfnl_cthelper_list is shared by all net namespaces on the system. An unprivileged user can create user and net namespaces in which he holds CAP_NET_ADMIN to bypass the netlink_net_capable() check:
$ nfct helper list
nfct v1.4.4: netlink error: Operation not permitted
$ vpnns -- nfct helper list
{
.name = ftp,
.queuenum = 0,
.l3protonum = 2,
.l4protonum = 6,
.priv_data_len = 24,
.status = enabled,
};Add capable() checks in nfnetlink_cthelper, as this is cleaner than trying to generalize the solution.
--- net/netfilter/nfnetlink_cthelper.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/netfilter/nfnetlink_cthelper.c +10 -0
@@ -17,6 +17,7 @@#include <linux/types.h> #include <linux/list.h> #include <linux/errno.h> +#include <linux/capability.h> #include <net/netlink.h> #include <net/sock.h>
@@ -392,6 +393,9 @@ nfnl_cthelper_new(struct sock *nfnl, struct sk_buff *skb,struct nfnl_cthelper *nlcth;int ret =0 ; +if (!capable (CAP_NET_ADMIN )) +return -EPERM ; +if (!tb[NFCTH_NAME ] || !tb[NFCTH_TUPLE ])return -EINVAL ;
@@ -595,6 +599,9 @@ nfnl_cthelper_get(struct sock *nfnl, struct sk_buff *skb,struct nfnl_cthelper *nlcth;bool tuple_set = false; +if (!capable (CAP_NET_ADMIN )) +return -EPERM ; +if (nlh->nlmsg_flags &NLM_F_DUMP ) {struct netlink_dump_control c = { .dump = nfnl_cthelper_dump_table,
@@ -661,6 +668,9 @@ nfnl_cthelper_del(struct sock *nfnl, struct sk_buff *skb,struct nfnl_cthelper *nlcth, *n;int j =0 , ret; +if (!capable (CAP_NET_ADMIN )) +return -EPERM ; +if (tb[NFCTH_NAME ]) helper_name =nla_data (tb[NFCTH_NAME ]);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: xt_osf: Add missing permission checks
In reply to Sasha LevinFrom: Kevin Cernekee <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 916a27901de01446bcf57ecca4783f6cff493309 ]
The capability check in nfnetlink_rcv() verifies that the caller has CAP_NET_ADMIN in the namespace that "owns" the netlink socket. However, xt_osf_fingers is shared by all net namespaces on the system. An unprivileged user can create user and net namespaces in which he holds CAP_NET_ADMIN to bypass the netlink_net_capable() check:
vpnns -- nfnl_osf -f /tmp/pf.os
vpnns -- nfnl_osf -f /tmp/pf.os -d
These non-root operations successfully modify the systemwide OS fingerprint list. Add new capable() checks so that they can't.
--- net/netfilter/xt_osf.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/netfilter/xt_osf.c +7 -0
@@ -19,6 +19,7 @@#include <linux/module.h> #include <linux/kernel.h> +#include <linux/capability.h> #include <linux/if.h> #include <linux/inetdevice.h> #include <linux/ip.h>
@@ -69,6 +70,9 @@ static int xt_osf_add_callback(struct sock *ctnl, struct sk_buff *skb,struct xt_osf_finger *kf =NULL , *sf;int err =0 ; +if (!capable (CAP_NET_ADMIN )) +return -EPERM ; +if (!osf_attrs[OSF_ATTR_FINGER ])return -EINVAL ;
@@ -112,6 +116,9 @@ static int xt_osf_remove_callback(struct sock *ctnl, struct sk_buff *skb,struct xt_osf_finger *sf;int err = -ENOENT ; +if (!capable (CAP_NET_ADMIN )) +return -EPERM ; +if (!osf_attrs[OSF_ATTR_FINGER ])return -EINVAL ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ext2: Don't clear SGID when inheriting ACLs
In reply to Sasha LevinFrom: Jan Kara <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a992f2d38e4ce17b8c7d1f7f67b2de0eebdea069 ]
When new directory 'DIR1' is created in a directory 'DIR0' with SGID bit set, DIR1 is expected to have SGID bit set (and owning group equal to the owning group of 'DIR0'). However when 'DIR0' also has some default ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on 'DIR1' to get cleared if user is not member of the owning group.
Fix the problem by creating __ext2_set_acl() function that does not call posix_acl_update_mode() and use it when inheriting ACLs. That prevents SGID bit clearing and the mode has been properly set by posix_acl_create() anyway.
--- fs/ext2/acl.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
fs/ext2/acl.c +22 -14
@@ -178,11 +178,8 @@ ext2_get_acl(struct inode *inode, int type)return acl; } -/* -* inode->i_mutex: down -*/ -int -ext2_set_acl (struct inode *inode,struct posix_acl *acl,int type) +static int +__ext2_set_acl (struct inode *inode,struct posix_acl *acl,int type) {int name_index;void *value =NULL ;
@@ -192,13 +189,6 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)switch (type) {case ACL_TYPE_ACCESS : name_index =EXT2_XATTR_INDEX_POSIX_ACL_ACCESS ; -if (acl) { - error =posix_acl_update_mode (inode, &inode->i_mode, &acl); -if (error) -return error; - inode->i_ctime =CURRENT_TIME_SEC ; -mark_inode_dirty (inode); - }break ;case ACL_TYPE_DEFAULT :
@@ -224,6 +214,24 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)return error; } +/* +* inode->i_mutex: down +*/ +int +ext2_set_acl (struct inode *inode,struct posix_acl *acl,int type) +{ +int error; + +if (type ==ACL_TYPE_ACCESS && acl) { + error =posix_acl_update_mode (inode, &inode->i_mode, &acl); +if (error) +return error; + inode->i_ctime =CURRENT_TIME_SEC ; +mark_inode_dirty (inode); + } +return __ext2_set_acl (inode, acl, type); +} +/* * Initialize the ACLs of a new inode. Called from ext2_new_inode. *
@@ -241,12 +249,12 @@ ext2_init_acl(struct inode *inode, struct inode *dir)return error;if (default_acl) { - error =ext2_set_acl (inode, default_acl,ACL_TYPE_DEFAULT ); + error =__ext2_set_acl (inode, default_acl,ACL_TYPE_DEFAULT );posix_acl_release (default_acl); }if (acl) {if (!error) - error =ext2_set_acl (inode, acl,ACL_TYPE_ACCESS ); + error =__ext2_set_acl (inode, acl,ACL_TYPE_ACCESS );posix_acl_release (acl); }return error;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] reiserfs: fix race in prealloc discard
In reply to Sasha LevinFrom: Jeff Mahoney <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 08db141b5313ac2f64b844fb5725b8d81744b417 ]
The main loop in __discard_prealloc is protected by the reiserfs write lock which is dropped across schedules like the BKL it replaced. The problem is that it checks the value, calls a routine that schedules, and then adjusts the state. As a result, two threads that are calling reiserfs_prealloc_discard at the same time can race when one calls reiserfs_free_prealloc_block, the lock is dropped, and the other calls reiserfs_free_prealloc_block with the same block number. In the right circumstances, it can cause the prealloc count to go negative.
--- fs/reiserfs/bitmap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
fs/reiserfs/bitmap.c +10 -2
@@ -513,9 +513,17 @@ static void __discard_prealloc(struct reiserfs_transaction_handle *th, "inode has negative prealloc blocks count.");#endif while (ei->i_prealloc_count >0 ) { -reiserfs_free_prealloc_block (th, inode, ei->i_prealloc_block); - ei->i_prealloc_block++; +b_blocknr_t block_to_free; + +/* +* reiserfs_free_prealloc_block can drop the write lock, +* which could allow another caller to free the same block. +* We can protect against it by modifying the prealloc +* state before calling it. +*/ + block_to_free = ei->i_prealloc_block++; ei->i_prealloc_count--; +reiserfs_free_prealloc_block (th, inode, block_to_free); dirty =1 ; }if (dirty)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] reiserfs: don't preallocate blocks for extended attributes
In reply to Sasha LevinFrom: Jeff Mahoney <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 54930dfeb46e978b447af0fb8ab4e181c1bf9d7a ]
Most extended attributes will fit in a single block. More importantly, we drop the reference to the inode while holding the transaction open so the preallocated blocks aren't released. As a result, the inode may be evicted before it's removed from the transaction's prealloc list which can cause memory corruption.
--- fs/reiserfs/bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/reiserfs/bitmap.c +1 -1
@@ -1136,7 +1136,7 @@ static int determine_prealloc_size(reiserfs_blocknr_hint_t * hint) hint->prealloc_size =0 ;if (!hint->formatted_node && hint->preallocate) { -if (S_ISREG (hint->inode->i_mode) +if (S_ISREG (hint->inode->i_mode) && !IS_PRIVATE (hint->inode) && hint->inode->i_size >=REISERFS_SB (hint->th->t_super)->s_alloc_options. preallocmin * hint->inode->i_sb->s_blocksize)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] fs/fcntl: f_setown, avoid undefined behaviour
In reply to Sasha LevinFrom: Jiri Slaby <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fc3dc67471461c0efcb1ed22fb7595121d65fad9 ]
fcntl(0, F_SETOWN, 0x80000000) triggers:
UBSAN: Undefined behaviour in fs/fcntl.c:118:7 negation of -2147483648 cannot be represented in type 'int': CPU: 1 PID: 18261 Comm: syz-executor Not tainted 4.8.1-0-syzkaller #1 ... Call Trace:
...
[<ffffffffad8f0868>] ? f_setown+0x1d8/0x200 [<ffffffffad8f19a9>] ? SyS_fcntl+0x999/0xf30 [<ffffffffaed1fb00>] ? entry_SYSCALL_64_fastpath+0x23/0xc1
Fix that by checking the arg parameter properly (against INT_MAX) before "who = -who". And return immediatelly with -EINVAL in case it is wrong. Note that according to POSIX we can return EINVAL:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
[EINVAL]
The cmd argument is F_SETOWN and the value of the argument is not valid as a process or process group identifier.
[v2] returns an error, v1 used to fail silently [v3] implement proper check for the bad value INT_MIN
--- fs/fcntl.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/fcntl.c +4 -0
@@ -113,6 +113,10 @@ void f_setown(struct file *filp, unsigned long arg, int force)int who = arg; type =PIDTYPE_PID ;if (who <0 ) { +/* avoid overflow below */ +if (who ==INT_MIN ) +return ; + type =PIDTYPE_PGID ; who = -who; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] reiserfs: Don't clear SGID when inheriting ACLs
In reply to Sasha LevinFrom: Jan Kara <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6883cd7f68245e43e91e5ee583b7550abf14523f ]
When new directory 'DIR1' is created in a directory 'DIR0' with SGID bit set, DIR1 is expected to have SGID bit set (and owning group equal to the owning group of 'DIR0'). However when 'DIR0' also has some default ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on 'DIR1' to get cleared if user is not member of the owning group.
Fix the problem by moving posix_acl_update_mode() out of __reiserfs_set_acl() into reiserfs_set_acl(). That way the function will not be called when inheriting ACLs which is what we want as it prevents SGID bit clearing and the mode has been properly set by posix_acl_create() anyway.
--- fs/reiserfs/xattr_acl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/reiserfs/xattr_acl.c +7 -5
@@ -37,7 +37,14 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) error =journal_begin (&th, inode->i_sb, jcreate_blocks);reiserfs_write_unlock (inode->i_sb);if (error ==0 ) { +if (type ==ACL_TYPE_ACCESS && acl) { + error =posix_acl_update_mode (inode, &inode->i_mode, + &acl); +if (error) + goto unlock; + } error =__reiserfs_set_acl (&th, inode, type, acl); +unlock:reiserfs_write_lock (inode->i_sb); error2 =journal_end (&th);reiserfs_write_unlock (inode->i_sb);
@@ -245,11 +252,6 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,switch (type) {case ACL_TYPE_ACCESS : name =POSIX_ACL_XATTR_ACCESS ; -if (acl) { - error =posix_acl_update_mode (inode, &inode->i_mode, &acl); -if (error) -return error; - }break ;case ACL_TYPE_DEFAULT : name =POSIX_ACL_XATTR_DEFAULT ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] scsi: libiscsi: fix shifting of DID_REQUEUE host byte
In reply to Sasha LevinFrom: Johannes Thumshirn <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit eef9ffdf9cd39b2986367bc8395e2772bc1284ba ]
The SCSI host byte should be shifted left by 16 in order to have scsi_decide_disposition() do the right thing (.i.e. requeue the command).
--- drivers/scsi/libiscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libiscsi.c +1 -1
@@ -1727,7 +1727,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)if (test_bit (ISCSI_SUSPEND_BIT , &conn->suspend_tx)) { reason =FAILURE_SESSION_IN_RECOVERY ; - sc->result =DID_REQUEUE ; + sc->result =DID_REQUEUE <<16 ; goto fault; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Revert "module: Add retpoline tag to VERMAGIC"
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5132ede0fe8092b043dae09a7cc32b8ae7272baa ]
This reverts commit 6cfb521ac0d5b97470883ff9b7facae264b7ab12.
Turns out distros do not want to make retpoline as part of their "ABI", so this patch should not have been merged. Sorry Andi, this was my fault, I suggested it when your original patch was the "correct" way of doing this instead.
--- include/linux/vermagic.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
include/linux/vermagic.h +1 -7
@@ -24,16 +24,10 @@#ifndef MODULE_ARCH_VERMAGIC #define MODULE_ARCH_VERMAGIC ""#endif -#ifdef RETPOLINE -#define MODULE_VERMAGIC_RETPOLINE "retpoline " -#else -#define MODULE_VERMAGIC_RETPOLINE "" -#endif #define VERMAGIC_STRING \ UTS_RELEASE " " \ MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \ MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \ - MODULE_ARCH_VERMAGIC \ - MODULE_VERMAGIC_RETPOLINE + MODULE_ARCH_VERMAGIC
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Input: trackpoint - force 3 buttons if 0 button is reported
In reply to Sasha LevinFrom: Aaron Ma <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f5d07b9e98022d50720e38aa936fc11c67868ece ]
Lenovo introduced trackpoint compatible sticks with minimum PS/2 commands. They supposed to reply with 0x02, 0x03, or 0x04 in response to the "Read Extended ID" command, so we would know not to try certain extended commands. Unfortunately even some trackpoints reporting the original IBM version (0x01 firmware 0x0e) now respond with incorrect data to the "Get Extended Buttons" command:
thinkpad_acpi: ThinkPad BIOS R0DET87W (1.87 ), EC unknown
thinkpad_acpi: Lenovo ThinkPad E470, model 20H1004SGE
psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 0/0
Since there are no trackpoints without buttons, let's assume the trackpoint has 3 buttons when we get 0 response to the extended buttons query.
--- drivers/input/mouse/trackpoint.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/mouse/trackpoint.c +3 -0
@@ -383,6 +383,9 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)if (trackpoint_read (&psmouse->ps2dev,TP_EXT_BTN , &button_info)) {psmouse_warn (psmouse,"failed to get extended button data, assuming 3 buttons\n" ); button_info =0x33 ; + }else if (!button_info) { +psmouse_warn (psmouse,"got 0 in extended button data, assuming 3 buttons\n" ); + button_info =0x33 ; } psmouse->private =kzalloc (sizeof (struct trackpoint_data ),GFP_KERNEL );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: fix stub_rx: get_pipe() to validate endpoint number
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 635f545a7e8be7596b9b2b6a43cab6bbd5a88e43 ]
get_pipe() routine doesn't validate the input endpoint number and uses to reference ep_in and ep_out arrays. Invalid endpoint number can trigger BUG(). Range check the epnum and returning error instead of calling BUG().
Change caller stub_recv_cmd_submit() to handle the get_pipe() error return.
--- drivers/usb/usbip/stub_rx.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/usb/usbip/stub_rx.c +11 -7
@@ -344,15 +344,15 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir)struct usb_host_endpoint *ep;struct usb_endpoint_descriptor *epd =NULL ; +if (epnum <0 || epnum >15 ) + goto err_ret; +if (dir ==USBIP_DIR_IN ) ep = udev->ep_in[epnum &0x7f ];else ep = udev->ep_out[epnum &0x7f ]; -if (!ep) { -dev_err (&sdev->interface->dev,"no such endpoint?, %d\n" , - epnum); -BUG (); - } +if (!ep) + goto err_ret; epd = &ep->desc;if (usb_endpoint_xfer_control (epd)) {
@@ -383,9 +383,10 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir)return usb_rcvisocpipe (udev, epnum); } +err_ret:/* NOT REACHED */ -dev_err (&sdev->interface->dev,"get pipe, epnum %d\n" , epnum); -return 0 ; +dev_err (&sdev->udev->dev,"get pipe() invalid epnum %d\n" , epnum); +return -1 ; }static void masking_bogus_flags (struct urb *urb)
@@ -451,6 +452,9 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,struct usb_device *udev = sdev->udev;int pipe =get_pipe (sdev, pdu->base.ep, pdu->base.direction); +if (pipe ==-1 ) +return ; + priv =stub_priv_alloc (sdev, pdu);if (!priv)return ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] dccp: don't restart ccid2_hc_tx_rto_expire() if sk in closed state
In reply to Sasha LevinFrom: Alexey Kodanev <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dd5684ecae3bd8e44b644f50e2c12c7e57fdfef5 ]
ccid2_hc_tx_rto_expire() timer callback always restarts the timer again and can run indefinitely (unless it is stopped outside), and after commit 120e9dabaf55 ("dccp: defer ccid_hc_tx_delete() at dismantle time"), which moved ccid_hc_tx_delete() (also includes sk_stop_timer()) from dccp_destroy_sock() to sk_destruct(), this started to happen quite often. The timer prevents releasing the socket, as a result, sk_destruct() won't be called.
Found with LTP/dccp_ipsec tests running on the bonding device, which later couldn't be unloaded after the tests were completed:
unregister_netdevice: waiting for bond0 to become free. Usage count = 148
--- net/dccp/ccids/ccid2.c | 3 +++ 1 file changed, 3 insertions(+)
net/dccp/ccids/ccid2.c +3 -0
@@ -140,6 +140,9 @@ static void ccid2_hc_tx_rto_expire(unsigned long data)ccid2_pr_debug ("RTO_EXPIRE\n" ); +if (sk->sk_state ==DCCP_CLOSED ) + goto out; +/* back-off timer */ hc->tx_rto <<=1 ;if (hc->tx_rto >DCCP_RTO_MAX )
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: fix stub_rx: harden CMD_SUBMIT path to handle malicious input
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c6688ef9f29762e65bce325ef4acd6c675806366 ]
Harden CMD_SUBMIT path to handle malicious input that could trigger large memory allocations. Add checks to validate transfer_buffer_length and number_of_packets to protect against bad input requesting for unbounded memory allocations. Validate early in get_pipe() and return failure.
--- drivers/usb/usbip/stub_rx.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/usb/usbip/stub_rx.c +27 -3
@@ -338,11 +338,13 @@ static struct stub_priv *stub_priv_alloc(struct stub_device *sdev,return priv; } -static int get_pipe (struct stub_device *sdev,int epnum,int dir) +static int get_pipe (struct stub_device *sdev,struct usbip_header *pdu) {struct usb_device *udev = sdev->udev;struct usb_host_endpoint *ep;struct usb_endpoint_descriptor *epd =NULL ; +int epnum = pdu->base.ep; +int dir = pdu->base.direction;if (epnum <0 || epnum >15 ) goto err_ret;
@@ -355,6 +357,7 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir) goto err_ret; epd = &ep->desc; +if (usb_endpoint_xfer_control (epd)) {if (dir ==USBIP_DIR_OUT )return usb_sndctrlpipe (udev, epnum);
@@ -377,6 +380,27 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir) }if (usb_endpoint_xfer_isoc (epd)) { +/* validate packet size and number of packets */ +unsigned int maxp, packets, bytes; + +#define USB_EP_MAXP_MULT_SHIFT 11 +#define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT) +#define USB_EP_MAXP_MULT (m) \ + (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT) + + maxp =usb_endpoint_maxp (epd); + maxp *= (USB_EP_MAXP_MULT ( +__le16_to_cpu (epd->wMaxPacketSize)) +1 ); + bytes = pdu->u.cmd_submit.transfer_buffer_length; + packets =DIV_ROUND_UP (bytes, maxp); + +if (pdu->u.cmd_submit.number_of_packets <0 || + pdu->u.cmd_submit.number_of_packets > packets) { +dev_err (&sdev->udev->dev, +"CMD_SUBMIT: isoc invalid num packets %d\n" , + pdu->u.cmd_submit.number_of_packets); +return -1 ; + }if (dir ==USBIP_DIR_OUT )return usb_sndisocpipe (udev, epnum);else
@@ -385,7 +409,7 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir) err_ret:/* NOT REACHED */ -dev_err (&sdev->udev->dev,"get pipe() invalid epnum %d\n" , epnum); +dev_err (&sdev->udev->dev,"CMD_SUBMIT: invalid epnum %d\n" , epnum);return -1 ; }
@@ -450,7 +474,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,struct stub_priv *priv;struct usbip_device *ud = &sdev->ud;struct usb_device *udev = sdev->udev; -int pipe =get_pipe (sdev, pdu->base.ep, pdu->base.direction); +int pipe =get_pipe (sdev, pdu);if (pipe ==-1 )return ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ipv6: fix udpv6 sendmsg crash caused by too small MTU
In reply to Sasha LevinFrom: Mike Maloney <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 749439bfac6e1a2932c582e2699f91d329658196 ]
The logic in __ip6_append_data() assumes that the MTU is at least large enough for the headers. A device's MTU may be adjusted after being added while sendmsg() is processing data, resulting in __ip6_append_data() seeing any MTU. For an mtu smaller than the size of the fragmentation header, the math results in a negative 'maxfraglen', which causes problems when refragmenting any previous skb in the skb_write_queue, leaving it possibly malformed.
Instead sendmsg returns EINVAL when the mtu is calculated to be less than IPV6_MIN_MTU.
Found by syzkaller:
kernel BUG at ./include/linux/skbuff.h:2064!
invalid opcode: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in: CPU: 1 PID: 14216 Comm: syz-executor5 Not tainted 4.13.0-rc4+ #2 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 task: ffff8801d0b68580 task.stack: ffff8801ac6b8000 RIP: 0010:__skb_pull include/linux/skbuff.h:2064 [inline] RIP: 0010:__ip6_make_skb+0x18cf/0x1f70 net/ipv6/ip6_output.c:1617 RSP: 0018:ffff8801ac6bf570 EFLAGS: 00010216 RAX: 0000000000010000 RBX: 0000000000000028 RCX: ffffc90003cce000 RDX: 00000000000001b8 RSI: ffffffff839df06f RDI: ffff8801d9478ca0 RBP: ffff8801ac6bf780 R08: ffff8801cc3f1dbc R09: 0000000000000000 R10: ffff8801ac6bf7a0 R11: 43cb4b7b1948a9e7 R12: ffff8801cc3f1dc8 R13: ffff8801cc3f1d40 R14: 0000000000001036 R15: dffffc0000000000 FS: 00007f43d740c700(0000) GS:ffff8801dc100000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f7834984000 CR3: 00000001d79b9000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ip6_finish_skb include/net/ipv6.h:911 [inline] udp_v6_push_pending_frames+0x255/0x390 net/ipv6/udp.c:1093 udpv6_sendmsg+0x280d/0x31a0 net/ipv6/udp.c:1363 inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:762 sock_sendmsg_nosec net/socket.c:633 [inline] sock_sendmsg+0xca/0x110 net/socket.c:643 SYSC_sendto+0x352/0x5a0 net/socket.c:1750 SyS_sendto+0x40/0x50 net/socket.c:1718 entry_SYSCALL_64_fastpath+0x1f/0xbe RIP: 0033:0x4512e9 RSP: 002b:00007f43d740bc08 EFLAGS: 00000216 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00000000007180a8 RCX: 00000000004512e9 RDX: 000000000000002e RSI: 0000000020d08000 RDI: 0000000000000005 RBP: 0000000000000086 R08: 00000000209c1000 R09: 000000000000001c R10: 0000000000040800 R11: 0000000000000216 R12: 00000000004b9c69 R13: 00000000ffffffff R14: 0000000000000005 R15: 00000000202c2000 Code: 9e 01 fe e9 c5 e8 ff ff e8 7f 9e 01 fe e9 4a ea ff ff 48 89 f7 e8 52 9e 01 fe e9 aa eb ff ff e8 a8 b6 cf fd 0f 0b e8 a1 b6 cf fd <0f> 0b 49 8d 45 78 4d 8d 45 7c 48 89 85 78 fe ff ff 49 8d 85 ba RIP: __skb_pull include/linux/skbuff.h:2064 [inline] RSP: ffff8801ac6bf570 RIP: __ip6_make_skb+0x18cf/0x1f70 net/ipv6/ip6_output.c:1617 RSP: ffff8801ac6bf570
--- net/ipv6/ip6_output.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv6/ip6_output.c +4 -2
@@ -1217,14 +1217,16 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork, v6_cork->tclass = tclass;if (rt->dst.flags &DST_XFRM_TUNNEL ) mtu = np->pmtudisc >=IPV6_PMTUDISC_PROBE ? - rt->dst.dev->mtu :dst_mtu (&rt->dst); +READ_ONCE (rt->dst.dev->mtu) :dst_mtu (&rt->dst);else mtu = np->pmtudisc >=IPV6_PMTUDISC_PROBE ? - rt->dst.dev->mtu :dst_mtu (rt->dst.path); +READ_ONCE (rt->dst.dev->mtu) :dst_mtu (rt->dst.path);if (np->frag_size < mtu) {if (np->frag_size) mtu = np->frag_size; } +if (mtu <IPV6_MIN_MTU ) +return -EINVAL ; cork->base.fragsize = mtu;if (dst_allfrag (rt->dst.path)) cork->base.flags |=IPCORK_ALLFRAG ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ipv6: ip6_make_skb() needs to clear cork.base.dst
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 95ef498d977bf44ac094778fd448b98af158a3e6 ]
In my last patch, I missed fact that cork.base.dst was not initialized in ip6_make_skb() :
If ip6_setup_cork() returns an error, we might attempt a dst_release() on some random pointer.
--- net/ipv6/ip6_output.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/ip6_output.c +1 -0
@@ -1759,6 +1759,7 @@ struct sk_buff *ip6_make_skb(struct sock *sk, cork.base.flags =0 ; cork.base.addr =0 ; cork.base.opt =NULL ; + cork.base.dst =NULL ; v6_cork.opt =NULL ; err =ip6_setup_cork (sk, &cork, &v6_cork, hlimit, tclass, opt, rt, fl6);if (err) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: prevent leaking socket pointer address in messages
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 90120d15f4c397272aaf41077960a157fc4212bf ]
usbip driver is leaking socket pointer address in messages. Remove the messages that aren't useful and print sockfd in the ones that are useful for debugging.
--- drivers/usb/usbip/stub_dev.c | 3 +-- drivers/usb/usbip/usbip_common.c | 15 ++++----------- drivers/usb/usbip/vhci_hcd.c | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-)
drivers/usb/usbip/stub_dev.c +1 -2
@@ -163,8 +163,7 @@ static void stub_shutdown_connection(struct usbip_device *ud)* step 1? */ if (ud->tcp_socket) { -dev_dbg (&sdev->udev->dev,"shutdown tcp_socket %p\n" , - ud->tcp_socket); +dev_dbg (&sdev->udev->dev,"shutdown sockfd %d\n" , ud->sockfd);kernel_sock_shutdown (ud->tcp_socket,SHUT_RDWR ); }
drivers/usb/usbip/usbip_common.c +4 -11
@@ -317,18 +317,14 @@ int usbip_recv(struct socket *sock, void *buf, int size)struct msghdr msg;struct kvec iov;int total =0 ; -/* for blocks of if (usbip_dbg_flag_xmit) */ char *bp = buf;int osize = size; -usbip_dbg_xmit ("enter\n" ); - -if (!sock || !buf || !size) { -pr_err ("invalid arg, sock %p buff %p size %d\n" , sock, buf, - size); +if (!sock || !buf || !size)return -EINVAL ; - } + +usbip_dbg_xmit ("enter\n" ); do { sock->sk->sk_allocation = GFP_NOIO;
@@ -341,11 +337,8 @@ int usbip_recv(struct socket *sock, void *buf, int size) msg.msg_flags =MSG_NOSIGNAL ; result =kernel_recvmsg (sock, &msg, &iov,1 , size,MSG_WAITALL ); -if (result <=0 ) { -pr_debug ("receive sock %p buf %p size %u ret %d total %d\n" , - sock, buf, size, result, total); +if (result <=0 ) goto err; - } size -= result; buf += result;
drivers/usb/usbip/vhci_hcd.c +1 -1
@@ -761,7 +761,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)/* need this? see stub_dev.c */ if (ud->tcp_socket) { -pr_debug ("shutdown tcp_socket %p\n" , ud->tcp_socket); +pr_debug ("shutdown sockfd %d\n" , ud->sockfd);kernel_sock_shutdown (ud->tcp_socket,SHUT_RDWR ); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: igmp: fix source address check for IGMPv3 reports
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ad23b750933ea7bf962678972a286c78a8fa36aa ]
Commit "net: igmp: Use correct source address on IGMPv3 reports" introduced a check to validate the source address of locally generated IGMPv3 packets.
Instead of checking the local interface address directly, it uses inet_ifa_match(fl4->saddr, ifa), which checks if the address is on the local subnet (or equal to the point-to-point address if used).
This breaks for point-to-point interfaces, so check against ifa->ifa_local directly.
--- net/ipv4/igmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/igmp.c +1 -1
@@ -330,7 +330,7 @@ static __be32 igmpv3_get_srcaddr(struct net_device *dev,return htonl (INADDR_ANY );for_ifa (in_dev) { -if (inet_ifa_match (fl4->saddr, ifa)) +if (fl4->saddr == ifa->ifa_local)return fl4->saddr; }endfor_ifa (in_dev);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] um: link vmlinux with -no-pie
In reply to Sasha LevinFrom: Thomas Meyer <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 883354afbc109c57f925ccc19840055193da0cc0 ]
Debian's gcc defaults to pie. The global Makefile already defines the -fno-pie option. Link UML dynamic kernel image also with -no-pie to fix the build.
--- arch/um/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/Makefile +1 -1
@@ -116,7 +116,7 @@ archheaders: archprepare: include/generated/user_constants.h LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static -LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib +LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie) CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ $(call cc-option, -fno-stack-protector,) \
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] eventpoll.h: add missing epoll event masks
In reply to Sasha LevinFrom: Greg KH <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7e040726850a106587485c21bdacc0bfc8a0cbed ]
[resend due to me forgetting to cc: linux-api the first time around I posted these back on Feb 23]
From: Greg Kroah-Hartman <[email protected]>
For some reason these values are not in the uapi header file, so any libc has to define it themselves. To prevent them from needing to do this, just have the kernel provide the correct values.
--- include/uapi/linux/eventpoll.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/uapi/linux/eventpoll.h +13 -0
@@ -26,6 +26,19 @@#define EPOLL_CTL_DEL 2#define EPOLL_CTL_MOD 3 +/* Epoll event masks */ +#define EPOLLIN 0x00000001 +#define EPOLLPRI 0x00000002 +#define EPOLLOUT 0x00000004 +#define EPOLLERR 0x00000008 +#define EPOLLHUP 0x00000010 +#define EPOLLRDNORM 0x00000040 +#define EPOLLRDBAND 0x00000080 +#define EPOLLWRNORM 0x00000100 +#define EPOLLWRBAND 0x00000200 +#define EPOLLMSG 0x00000400 +#define EPOLLRDHUP 0x00002000 +/* * Request the handling of system wakeup events so as to prevent system suspends * from happening while those events are being processed.
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tcp: __tcp_hdrlen() helper
In reply to Sasha LevinFrom: Craig Gallek <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d9b3fca27385eafe61c3ca6feab6cb1e7dc77482 ]
tcp_hdrlen is wasteful if you already have a pointer to struct tcphdr. This splits the size calculation into a helper function that can be used if a struct tcphdr is already available.
--- include/linux/tcp.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/linux/tcp.h +6 -1
@@ -29,9 +29,14 @@ static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)return (struct tcphdr *)skb_transport_header (skb); } +static inline unsigned int __tcp_hdrlen (const struct tcphdr *th) +{ +return th->doff *4 ; +} +static inline unsigned int tcp_hdrlen (const struct sk_buff *skb) { -return tcp_hdr (skb)->doff *4 ; +return __tcp_hdrlen (tcp_hdr (skb)); }static inline struct tcphdr *inner_tcp_hdr (const struct sk_buff *skb)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: qdisc_pkt_len_init() should be more robust
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7c68d1a6b4db9012790af7ac0f0fdc0d2083422a ]
Without proper validation of DODGY packets, we might very well feed qdisc_pkt_len_init() with invalid GSO packets.
tcp_hdrlen() might access out-of-bound data, so let's use skb_header_pointer() and proper checks.
Whole story is described in commit d0c081b49137 ("flow_dissector:
properly cap thoff field")
We have the goal of validating DODGY packets earlier in the stack, so we might very well revert this fix in the future.
--- net/core/dev.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
net/core/dev.c +15 -4
@@ -2803,10 +2803,21 @@ static void qdisc_pkt_len_init(struct sk_buff *skb) hdr_len =skb_transport_header (skb) -skb_mac_header (skb);/* + transport layer */ -if (likely (shinfo->gso_type & (SKB_GSO_TCPV4 |SKB_GSO_TCPV6 ))) - hdr_len +=tcp_hdrlen (skb); -else - hdr_len +=sizeof (struct udphdr ); +if (likely (shinfo->gso_type & (SKB_GSO_TCPV4 |SKB_GSO_TCPV6 ))) { +const struct tcphdr *th; +struct tcphdr _tcphdr; + + th =skb_header_pointer (skb,skb_transport_offset (skb), +sizeof (_tcphdr), &_tcphdr); +if (likely (th)) + hdr_len +=__tcp_hdrlen (th); + }else { +struct udphdr _udphdr; + +if (skb_header_pointer (skb,skb_transport_offset (skb), +sizeof (_udphdr), &_udphdr)) + hdr_len +=sizeof (struct udphdr ); + }if (shinfo->gso_type &SKB_GSO_DODGY ) gso_segs = DIV_ROUND_UP(skb->len - hdr_len,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sctp: do not allow the v4 socket to bind a v4mapped v6 address
In reply to Sasha LevinFrom: Xin Long <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c5006b8aa74599ce19104b31d322d2ea9ff887cc ]
The check in sctp_sockaddr_af is not robust enough to forbid binding a v4mapped v6 addr on a v4 socket.
The worse thing is that v4 socket's bind_verify would not convert this v4mapped v6 addr to a v4 addr. syzbot even reported a crash as the v4 socket bound a v6 addr.
This patch is to fix it by doing the common sa.sa_family check first, then AF_INET check for v4mapped v6 addrs.
--- net/sctp/socket.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/sctp/socket.c +6 -8
@@ -332,16 +332,14 @@ static struct sctp_af *sctp_sockaddr_af(struct sctp_sock *opt,if (len <sizeof (struct sockaddr ))return NULL ; +if (!opt->pf->af_supported (addr->sa.sa_family, opt)) +return NULL ; +/* V4 mapped address are really of AF_INET family */ if (addr->sa.sa_family ==AF_INET6 && -ipv6_addr_v4mapped (&addr->v6.sin6_addr)) { -if (!opt->pf->af_supported (AF_INET , opt)) -return NULL ; - }else { -/* Does this PF support this AF? */ -if (!opt->pf->af_supported (addr->sa.sa_family, opt)) -return NULL ; - } +ipv6_addr_v4mapped (&addr->v6.sin6_addr) && + !opt->pf->af_supported (AF_INET , opt)) +return NULL ;/* If we get this far, af is valid. */ af =sctp_get_af_specific (addr->sa.sa_family);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] pppoe: take ->needed_headroom of lower device into account on xmit
In reply to Sasha LevinFrom: Guillaume Nault <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 02612bb05e51df8489db5e94d0cf8d1c81f87b0c ]
In pppoe_sendmsg(), reserving dev->hard_header_len bytes of headroom was probably fine before the introduction of ->needed_headroom in commit f5184d267c1a ("net: Allow netdevices to specify needed head/tailroom").
But now, virtual devices typically advertise the size of their overhead in dev->needed_headroom, so we must also take it into account in skb_reserve().
Allocation size of skb is also updated to take dev->needed_tailroom into account and replace the arbitrary 32 bytes with the real size of a PPPoE header.
This issue was discovered by syzbot, who connected a pppoe socket to a gre device which had dev->header_ops->create == ipgre_header and dev->hard_header_len == 0. Therefore, PPPoE didn't reserve any headroom, and dev_hard_header() crashed when ipgre_header() tried to prepend its header to skb->data.
skbuff: skb_under_panic: text:000000001d390b3a len:31 put:24 head:00000000d8ed776f data:000000008150e823 tail:0x7 end:0xc0 dev:gre0
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:104!
invalid opcode: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 3670 Comm: syzkaller801466 Not tainted
4.15.0-rc7-next-20180115+ #97
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
RIP: 0010:skb_panic+0x162/0x1f0 net/core/skbuff.c:100
RSP: 0018:ffff8801d9bd7840 EFLAGS: 00010282
RAX: 0000000000000083 RBX: ffff8801d4f083c0 RCX: 0000000000000000
RDX: 0000000000000083 RSI: 1ffff1003b37ae92 RDI: ffffed003b37aefc
RBP: ffff8801d9bd78a8 R08: 1ffff1003b37ae8a R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffffffff86200de0
R13: ffffffff84a981ad R14: 0000000000000018 R15: ffff8801d2d34180
FS: 00000000019c4880(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000208bc000 CR3: 00000001d9111001 CR4: 00000000001606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
skb_under_panic net/core/skbuff.c:114 [inline]
skb_push+0xce/0xf0 net/core/skbuff.c:1714
ipgre_header+0x6d/0x4e0 net/ipv4/ip_gre.c:879
dev_hard_header include/linux/netdevice.h:2723 [inline]
pppoe_sendmsg+0x58e/0x8b0 drivers/net/ppp/pppoe.c:890
sock_sendmsg_nosec net/socket.c:630 [inline]
sock_sendmsg+0xca/0x110 net/socket.c:640
sock_write_iter+0x31a/0x5d0 net/socket.c:909
call_write_iter include/linux/fs.h:1775 [inline]
do_iter_readv_writev+0x525/0x7f0 fs/read_write.c:653
do_iter_write+0x154/0x540 fs/read_write.c:932
vfs_writev+0x18a/0x340 fs/read_write.c:977
do_writev+0xfc/0x2a0 fs/read_write.c:1012
SYSC_writev fs/read_write.c:1085 [inline]
SyS_writev+0x27/0x30 fs/read_write.c:1082
entry_SYSCALL_64_fastpath+0x29/0xa0Admittedly PPPoE shouldn't be allowed to run on non Ethernet-like interfaces, but reserving space for ->needed_headroom is a more fundamental issue that needs to be addressed first.
Same problem exists for __pppoe_xmit(), which also needs to take dev->needed_headroom into account in skb_cow_head().
--- drivers/net/ppp/pppoe.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ppp/pppoe.c +6 -5
@@ -860,6 +860,7 @@ static int pppoe_sendmsg(struct socket *sock, struct msghdr *m,struct pppoe_hdr *ph;struct net_device *dev;char *start; +int hlen;lock_sock (sk);if (sock_flag (sk,SOCK_DEAD ) || !(sk->sk_state &PPPOX_CONNECTED )) {
@@ -878,16 +879,16 @@ static int pppoe_sendmsg(struct socket *sock, struct msghdr *m,if (total_len > (dev->mtu + dev->hard_header_len)) goto end; - - skb =sock_wmalloc (sk, total_len + dev->hard_header_len +32 , -0 ,GFP_KERNEL ); + hlen =LL_RESERVED_SPACE (dev); + skb =sock_wmalloc (sk, hlen +sizeof (*ph) + total_len + + dev->needed_tailroom,0 ,GFP_KERNEL );if (!skb) { error = -ENOMEM ; goto end; }/* Reserve space for headers. */ -skb_reserve (skb, dev->hard_header_len); +skb_reserve (skb, hlen);skb_reset_network_header (skb); skb->dev = dev;
@@ -948,7 +949,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)/* Copy the data if there is no space for the header or if it's * read-only. */ -if (skb_cow_head (skb,sizeof (*ph) + dev->hard_header_len)) +if (skb_cow_head (skb,LL_RESERVED_SPACE (dev) +sizeof (*ph))) goto abort;__skb_push (skb,sizeof (*ph));
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] vmxnet3: repair memory leak
In reply to Sasha LevinFrom: Neil Horman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 848b159835ddef99cc4193083f7e786c3992f580 ]
with the introduction of commit b0eb57cb97e7837ebb746404c2c58c6f536f23fa, it appears that rq->buf_info is improperly handled. While it is heap allocated when an rx queue is setup, and freed when torn down, an old line of code in vmxnet3_rq_destroy was not properly removed, leading to rq->buf_info[0] being set to NULL prior to its being freed, causing a memory leak, which eventually exhausts the system on repeated create/destroy operations (for example, when the mtu of a vmxnet3 interface is changed frequently.
Fix is pretty straight forward, just move the NULL set to after the free.
Tested by myself with successful results
Applies to net, and should likely be queued for stable, please
--- drivers/net/vmxnet3/vmxnet3_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vmxnet3/vmxnet3_drv.c +1 -1
@@ -1431,7 +1431,6 @@ static void vmxnet3_rq_destroy(struct vmxnet3_rx_queue *rq, rq->rx_ring[i].basePA); rq->rx_ring[i].base =NULL ; } - rq->buf_info[i] =NULL ; }if (rq->comp_ring.base) {
@@ -1446,6 +1445,7 @@ static void vmxnet3_rq_destroy(struct vmxnet3_rx_queue *rq, (rq->rx_ring[0 ].size + rq->rx_ring[1 ].size);dma_free_coherent (&adapter->pdev->dev, sz, rq->buf_info[0 ], rq->buf_info_pa); + rq->buf_info[0 ] = rq->buf_info[1 ] =NULL ; } }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sctp: return error if the asoc has been peeled off in sctp_wait_for_sndbuf
In reply to Sasha LevinFrom: Xin Long <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a0ff660058b88d12625a783ce9e5c1371c87951f ]
After commit cea0cc80a677 ("sctp: use the right sk after waking up from wait_buf sleep"), it may change to lock another sk if the asoc has been peeled off in sctp_wait_for_sndbuf.
However, the asoc's new sk could be already closed elsewhere, as it's in the sendmsg context of the old sk that can't avoid the new sk's closing. If the sk's last one refcnt is held by this asoc, later on after putting this asoc, the new sk will be freed, while under it's own lock.
This patch is to revert that commit, but fix the old issue by returning error under the old sk's lock.
--- net/sctp/socket.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
net/sctp/socket.c +6 -10
@@ -83,7 +83,7 @@static int sctp_writeable (struct sock *sk);static void sctp_wfree (struct sk_buff *skb);static int sctp_wait_for_sndbuf (struct sctp_association *asoc,long *timeo_p, -size_t msg_len,struct sock **orig_sk); +size_t msg_len);static int sctp_wait_for_packet (struct sock *sk,int *err,long *timeo_p);static int sctp_wait_for_connect (struct sctp_association *,long *timeo_p);static int sctp_wait_for_accept (struct sock *sk,long timeo);
@@ -1946,7 +1946,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) timeo =sock_sndtimeo (sk, msg->msg_flags &MSG_DONTWAIT );if (!sctp_wspace (asoc)) {/* sk can be changed by peel off when waiting for buf. */ - err =sctp_wait_for_sndbuf (asoc, &timeo, msg_len, &sk); + err =sctp_wait_for_sndbuf (asoc, &timeo, msg_len);if (err) {if (err == -ESRCH ) {/* asoc is already dead. */
@@ -6977,12 +6977,12 @@ void sctp_sock_rfree(struct sk_buff *skb)/* Helper function to wait for space in the sndbuf. */ static int sctp_wait_for_sndbuf (struct sctp_association *asoc,long *timeo_p, -size_t msg_len,struct sock **orig_sk) +size_t msg_len) {struct sock *sk = asoc->base.sk; -int err =0 ;long current_timeo = *timeo_p;DEFINE_WAIT (wait); +int err =0 ;pr_debug ("%s: asoc:%p, timeo:%ld, msg_len:%zu\n" , __func__, asoc, *timeo_p, msg_len);
@@ -7012,17 +7012,13 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p, current_timeo =schedule_timeout (current_timeo);BUG_ON (sk != asoc->base.sk);lock_sock (sk); -if (sk != asoc->base.sk) { -release_sock (sk); - sk = asoc->base.sk; -lock_sock (sk); - } +if (sk != asoc->base.sk) + goto do_error; *timeo_p = current_timeo; } out: - *orig_sk = sk;finish_wait (&asoc->wait, &wait);/* Release the association's refcnt. */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: Allow neigh contructor functions ability to modify the primary_key
In reply to Sasha LevinFrom: Jim Westfall <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 096b9854c04df86f03b38a97d40b6506e5730919 ]
Use n->primary_key instead of pkey to account for the possibility that a neigh constructor function may have modified the primary_key value.
--- net/core/neighbour.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/neighbour.c +2 -2
@@ -492,7 +492,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,if (atomic_read (&tbl->entries) > (1 << nht->hash_shift)) nht =neigh_hash_grow (tbl, nht->hash_shift +1 ); - hash_val = tbl->hash (pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); + hash_val = tbl->hash (n->primary_key, dev, nht->hash_rnd) >> (32 - nht->hash_shift);if (n->parms->dead) { rc =ERR_PTR (-EINVAL );
@@ -504,7 +504,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey, n1 !=NULL ; n1 = rcu_dereference_protected(n1->next, lockdep_is_held(&tbl->lock))) { -if (dev == n1->dev && !memcmp (n1->primary_key, pkey, key_len)) { +if (dev == n1->dev && !memcmp (n1->primary_key, n->primary_key, key_len)) {if (want_ref)neigh_hold (n1); rc = n1;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] bpf: arsh is not supported in 32 bit alu thus reject it
In reply to Sasha LevinFrom: Daniel Borkmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7891a87efc7116590eaba57acc3c422487802c6f ]
The following snippet was throwing an 'unknown opcode cc' warning in BPF interpreter:
0: (18) r0 = 0x0
2: (7b) *(u64 *)(r10 -16) = r0
3: (cc) (u32) r0 s>>= (u32) r0
4: (95) exit
Although a number of JITs do support BPF_ALU | BPF_ARSH | BPF_{K,X} generation, not all of them do and interpreter does neither. We can leave existing ones and implement it later in bpf-next for the remaining ones, but reject this properly in verifier for the time being.
--- kernel/bpf/verifier.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/bpf/verifier.c +5 -0
@@ -1020,6 +1020,11 @@ static int check_alu_op(struct reg_state *regs, struct bpf_insn *insn)return -EINVAL ; } +if (opcode ==BPF_ARSH &&BPF_CLASS (insn->code) !=BPF_ALU64 ) { +verbose ("BPF_ARSH not supported for 32 bit ALU\n" ); +return -EINVAL ; + } +if ((opcode ==BPF_LSH || opcode ==BPF_RSH || opcode ==BPF_ARSH ) &&BPF_SRC (insn->code) ==BPF_K ) {int size =BPF_CLASS (insn->code) ==BPF_ALU64 ?64 :32 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY
In reply to Sasha LevinFrom: Jim Westfall <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cd9ff4de0107c65d69d02253bb25d6db93c3dbc1 ]
Map all lookup neigh keys to INADDR_ANY for loopback/point-to-point devices to avoid making an entry for every remote ip the device needs to talk to.
This used the be the old behavior but became broken in a263b3093641f (ipv4: Make neigh lookups directly in output packet path) and later removed in 0bb4087cbec0 (ipv4: Fix neigh lookup keying over loopback/point-to-point devices) because it was broken.
--- include/net/arp.h | 3 +++ net/ipv4/arp.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
include/net/arp.h +3 -0
@@ -19,6 +19,9 @@ static inline u32 arp_hashfn(const void *pkey, const struct net_device *dev, u32static inline struct neighbour *__ipv4_neigh_lookup_noref (struct net_device *dev,u32 key) { +if (dev->flags & (IFF_LOOPBACK |IFF_POINTOPOINT )) + key =INADDR_ANY ; +return ___neigh_lookup_noref (&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev); }
net/ipv4/arp.c +6 -1
@@ -221,11 +221,16 @@ static bool arp_key_eq(const struct neighbour *neigh, const void *pkey)static int arp_constructor (struct neighbour *neigh) { -__be32 addr = *(__be32 *)neigh->primary_key; +__be32 addr;struct net_device *dev = neigh->dev;struct in_device *in_dev;struct neigh_parms *parms; +u32 inaddr_any =INADDR_ANY ; +if (dev->flags & (IFF_LOOPBACK |IFF_POINTOPOINT )) +memcpy (neigh->primary_key, &inaddr_any, arp_tbl.key_len); + + addr = *(__be32 *)neigh->primary_key;rcu_read_lock (); in_dev =__in_dev_get_rcu (dev);if (!in_dev) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: tcp: close sock if net namespace is exiting
In reply to Sasha LevinFrom: Dan Streetman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4ee806d51176ba7b8ff1efd81f271d7252e03a1d ]
When a tcp socket is closed, if it detects that its net namespace is exiting, close immediately and do not wait for FIN sequence.
For normal sockets, a reference is taken to their net namespace, so it will never exit while the socket is open. However, kernel sockets do not take a reference to their net namespace, so it may begin exiting while the kernel socket is still open. In this case if the kernel socket is a tcp socket, it will stay open trying to complete its close sequence. The sock's dst(s) hold a reference to their interface, which are all transferred to the namespace's loopback interface when the real interfaces are taken down. When the namespace tries to take down its loopback interface, it hangs waiting for all references to the loopback interface to release, which results in messages like:
unregister_netdevice: waiting for lo to become free. Usage count = 1
These messages continue until the socket finally times out and closes. Since the net namespace cleanup holds the net_mutex while calling its registered pernet callbacks, any new net namespace initialization is blocked until the current net namespace finishes exiting.
After this change, the tcp socket notices the exiting net namespace, and closes immediately, releasing its dst(s) and their reference to the loopback interface, which lets the net namespace continue exiting.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=97811
--- include/net/net_namespace.h | 10 ++++++++++ net/ipv4/tcp.c | 3 +++ net/ipv4/tcp_timer.c | 15 +++++++++++++++ 3 files changed, 28 insertions(+)
include/net/net_namespace.h +10 -0
@@ -203,6 +203,11 @@ int net_eq(const struct net *net1, const struct net *net2) return net1 == net2; } +static inline int check_net (const struct net *net) +{ +return atomic_read (&net->count) !=0 ; +} +void net_drop_ns (void *);#else
@@ -227,6 +232,11 @@ int net_eq(const struct net *net1, const struct net *net2) return 1; } +static inline int check_net (const struct net *net) +{ +return 1 ; +} +#define net_drop_ns NULL#endif
net/ipv4/tcp.c +3 -0
@@ -2137,6 +2137,9 @@ void tcp_close(struct sock *sk, long timeout)tcp_send_active_reset (sk,GFP_ATOMIC );NET_INC_STATS_BH (sock_net (sk),LINUX_MIB_TCPABORTONMEMORY ); + }else if (!check_net (sock_net (sk))) { +/* Not possible to send reset; just close */ +tcp_set_state (sk,TCP_CLOSE ); } }
net/ipv4/tcp_timer.c +15 -0
@@ -46,11 +46,19 @@ static void tcp_write_err(struct sock *sk)* to prevent DoS attacks. It is called when a retransmission timeout * or zero probe timeout occurs on orphaned socket. * +* Also close if our net namespace is exiting; in that case there is no +* hope of ever communicating again since all netns interfaces are already +* down (or about to be down), and we need to release our dst references, +* which have been moved to the netns loopback interface, so the namespace +* can finish exiting. This condition is only possible if we are a kernel +* socket, as those do not hold references to the namespace. +* * Criteria is still not confirmed experimentally and may change. * We kill the socket, if: * 1. If number of orphaned sockets exceeds an administratively configured * limit. * 2. If we have strong memory pressure. +* 3. If our net namespace is exiting. */ static int tcp_out_of_resources (struct sock *sk,bool do_reset) {
@@ -79,6 +87,13 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset)NET_INC_STATS_BH (sock_net (sk),LINUX_MIB_TCPABORTONMEMORY );return 1 ; } + +if (!check_net (sock_net (sk))) { +/* Not possible to send reset; just close */ +tcp_done (sk); +return 1 ; + } +return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] bpf: fix divides by zero
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c366287ebd698ef5e3de300d90cd62ee9ee7373e ]
Divides by zero are not nice, lets avoid them if possible.
Also do_div() seems not needed when dealing with 32bit operands, but this seems a minor detail.
--- kernel/bpf/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/core.c +2 -2
@@ -361,7 +361,7 @@ static unsigned int __bpf_prog_run(void *ctx, const struct bpf_insn *insn)DST = tmp;CONT ; ALU_MOD_X: -if (unlikely (SRC ==0 )) +if (unlikely ((u32 )SRC ==0 ))return 0 ; tmp = (u32 )DST ;DST =do_div (tmp, (u32 )SRC );
@@ -380,7 +380,7 @@ static unsigned int __bpf_prog_run(void *ctx, const struct bpf_insn *insn)DST =div64_u64 (DST ,SRC );CONT ; ALU_DIV_X: -if (unlikely (SRC ==0 )) +if (unlikely ((u32 )SRC ==0 ))return 0 ; tmp = (u32 )DST ;do_div (tmp, (u32 )SRC );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: seq: Make ioctls race-free
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b3defb791b26ea0683a93a4f49c77ec45ec96f10 ]
The ALSA sequencer ioctls have no protection against racy calls while the concurrent operations may lead to interfere with each other. As reported recently, for example, the concurrent calls of setting client pool with a combination of write calls may lead to either the unkillable dead-lock or UAF.
As a slightly big hammer solution, this patch introduces the mutex to make each ioctl exclusive. Although this may reduce performance via parallel ioctl calls, usually it's not demanded for sequencer usages, hence it should be negligible.
--- sound/core/seq/seq_clientmgr.c | 10 ++++++++-- sound/core/seq/seq_clientmgr.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-)
sound/core/seq/seq_clientmgr.c +8 -2
@@ -236,6 +236,7 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)rwlock_init (&client->ports_lock);mutex_init (&client->ports_mutex);INIT_LIST_HEAD (&client->ports_list_head); +mutex_init (&client->ioctl_mutex);/* find free slot in the client table */ spin_lock_irqsave (&clients_lock, flags);
@@ -2195,6 +2196,7 @@ static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd, void __user *arg) {struct seq_ioctl_table *p; +int ret;switch (cmd) {case SNDRV_SEQ_IOCTL_PVERSION :
@@ -2208,8 +2210,12 @@ static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd,if (! arg)return -EFAULT ;for (p = ioctl_tables; p->cmd; p++) { -if (p->cmd == cmd) -return p->func (client, arg); +if (p->cmd == cmd) { +mutex_lock (&client->ioctl_mutex); + ret = p->func (client, arg); +mutex_unlock (&client->ioctl_mutex); +return ret; + } }pr_debug ("ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n" , cmd,_IOC_TYPE (cmd),_IOC_NR (cmd));
sound/core/seq/seq_clientmgr.h +1 -0
@@ -59,6 +59,7 @@ struct snd_seq_client {struct list_head ports_list_head;rwlock_t ports_lock;struct mutex ports_mutex; +struct mutex ioctl_mutex;int convert32;/* convert 32->64bit */ /* output pool */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] nfsd: auth: Fix gid sorting when rootsquash enabled
In reply to Sasha LevinFrom: Ben Hutchings <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1995266727fa8143897e89b55f5d3c79aa828420 ]
Commit bdcf0a423ea1 ("kernel: make groups_sort calling a responsibility group_info allocators") appears to break nfsd rootsquash in a pretty major way.
It adds a call to groups_sort() inside the loop that copies/squashes gids, which means the valid gids are sorted along with the following garbage. The net result is that the highest numbered valid gids are replaced with any lower-valued garbage gids, possibly including 0.
We should sort only once, after filling in all the gids.
--- fs/nfsd/auth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/auth.c +3 -2
@@ -60,9 +60,10 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)else GROUP_AT (gi, i) =GROUP_AT (rqgi, i); -/* Each thread allocates its own gi, no race */ -groups_sort (gi); } + +/* Each thread allocates its own gi, no race */ +groups_sort (gi); }else { gi =get_group_info (rqgi); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] igb: Free IRQs when device is hotplugged
In reply to Sasha LevinFrom: Lyude Paul <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 888f22931478a05bc81ceb7295c626e1292bf0ed ]
Recently I got a Caldigit TS3 Thunderbolt 3 dock, and noticed that upon hotplugging my kernel would immediately crash due to igb:
[ 680.825801] kernel BUG at drivers/pci/msi.c:352! [ 680.828388] invalid opcode: 0000 [#1] SMP [ 680.829194] Modules linked in: igb(O) thunderbolt i2c_algo_bit joydev vfat fat btusb btrtl btbcm btintel bluetooth ecdh_generic hp_wmi sparse_keymap rfkill wmi_bmof iTCO_wdt intel_rapl x86_pkg_temp_thermal coretemp crc32_pclmul snd_pcm rtsx_pci_ms mei_me snd_timer memstick snd pcspkr mei soundcore i2c_i801 tpm_tis psmouse shpchp wmi tpm_tis_core tpm video hp_wireless acpi_pad rtsx_pci_sdmmc mmc_core crc32c_intel serio_raw rtsx_pci mfd_core xhci_pci xhci_hcd i2c_hid i2c_core [last unloaded: igb] [ 680.831085] CPU: 1 PID: 78 Comm: kworker/u16:1 Tainted: G O 4.15.0-rc3Lyude-Test+ #6 [ 680.831596] Hardware name: HP HP ZBook Studio G4/826B, BIOS P71 Ver. 01.03 06/09/2017 [ 680.832168] Workqueue: kacpi_hotplug acpi_hotplug_work_fn [ 680.832687] RIP: 0010:free_msi_irqs+0x180/0x1b0 [ 680.833271] RSP: 0018:ffffc9000030fbf0 EFLAGS: 00010286 [ 680.833761] RAX: ffff8803405f9c00 RBX: ffff88033e3d2e40 RCX: 000000000000002c [ 680.834278] RDX: 0000000000000000 RSI: 00000000000000ac RDI: ffff880340be2178 [ 680.834832] RBP: 0000000000000000 R08: ffff880340be1ff0 R09: ffff8803405f9c00 [ 680.835342] R10: 0000000000000000 R11: 0000000000000040 R12: ffff88033d63a298 [ 680.835822] R13: ffff88033d63a000 R14: 0000000000000060 R15: ffff880341959000 [ 680.836332] FS: 0000000000000000(0000) GS:ffff88034f440000(0000) knlGS:0000000000000000 [ 680.836817] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 680.837360] CR2: 000055e64044afdf CR3: 0000000001c09002 CR4: 00000000003606e0 [ 680.837954] Call Trace: [ 680.838853] pci_disable_msix+0xce/0xf0 [ 680.839616] igb_reset_interrupt_capability+0x5d/0x60 [igb] [ 680.840278] igb_remove+0x9d/0x110 [igb] [ 680.840764] pci_device_remove+0x36/0xb0 [ 680.841279] device_release_driver_internal+0x157/0x220 [ 680.841739] pci_stop_bus_device+0x7d/0xa0 [ 680.842255] pci_stop_bus_device+0x2b/0xa0 [ 680.842722] pci_stop_bus_device+0x3d/0xa0 [ 680.843189] pci_stop_and_remove_bus_device+0xe/0x20 [ 680.843627] trim_stale_devices+0xf3/0x140 [ 680.844086] trim_stale_devices+0x94/0x140 [ 680.844532] trim_stale_devices+0xa6/0x140 [ 680.845031] ? get_slot_status+0x90/0xc0 [ 680.845536] acpiphp_check_bridge.part.5+0xfe/0x140 [ 680.846021] acpiphp_hotplug_notify+0x175/0x200 [ 680.846581] ? free_bridge+0x100/0x100 [ 680.847113] acpi_device_hotplug+0x8a/0x490 [ 680.847535] acpi_hotplug_work_fn+0x1a/0x30 [ 680.848076] process_one_work+0x182/0x3a0 [ 680.848543] worker_thread+0x2e/0x380 [ 680.848963] ? process_one_work+0x3a0/0x3a0 [ 680.849373] kthread+0x111/0x130 [ 680.849776] ? kthread_create_worker_on_cpu+0x50/0x50 [ 680.850188] ret_from_fork+0x1f/0x30 [ 680.850601] Code: 43 14 85 c0 0f 84 d5 fe ff ff 31 ed eb 0f 83 c5 01 39 6b 14 0f 86 c5 fe ff ff 8b 7b 10 01 ef e8 b7 e4 d2 ff 48 83 78 70 00 74 e3 <0f> 0b 49 8d b5 a0 00 00 00 e8 62 6f d3 ff e9 c7 fe ff ff 48 8b [ 680.851497] RIP: free_msi_irqs+0x180/0x1b0 RSP: ffffc9000030fbf0
As it turns out, normally the freeing of IRQs that would fix this is called inside of the scope of __igb_close(). However, since the device is already gone by the point we try to unregister the netdevice from the driver due to a hotplug we end up seeing that the netif isn't present and thus, forget to free any of the device IRQs.
So: make sure that if we're in the process of dismantling the netdev, we always allow __igb_close() to be called so that IRQs may be freed normally. Additionally, only allow igb_close() to be called from __igb_close() if it hasn't already been called for the given adapter.
--- drivers/net/ethernet/intel/igb/igb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igb/igb_main.c +1 -1
@@ -3169,7 +3169,7 @@ static int __igb_close(struct net_device *netdev, bool suspending)static int igb_close (struct net_device *netdev) { -if (netif_device_present (netdev)) +if (netif_device_present (netdev) || netdev->dismantle)return __igb_close (netdev, false);return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] gpio: iop: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
In reply to Sasha LevinFrom: Jesse Chan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 97b03136e1b637d7a9d2274c099e44ecf23f1103 ]
This change resolves a new compile-time warning
when built as a loadable module:
WARNING: modpost: missing MODULE_LICENSE() in drivers/gpio/gpio-iop.o see include/linux/module.h for more information
This adds the license as "GPL", which matches the header of the file.
MODULE_DESCRIPTION and MODULE_AUTHOR are also added.
--- drivers/gpio/gpio-iop.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpio/gpio-iop.c +4 -0
@@ -129,3 +129,7 @@ static int __init iop3xx_gpio_init(void)return platform_driver_register (&iop3xx_gpio_driver); }arch_initcall (iop3xx_gpio_init); + +MODULE_DESCRIPTION ("GPIO handling for Intel IOP3xx processors" ); +MODULE_AUTHOR ("Lennert Buytenhek <[email protected]>" ); +MODULE_LICENSE ("GPL" );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] loop: fix concurrent lo_open/lo_release
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ae6650163c66a7eff1acd6eb8b0f752dcfa8eba5 ]
范龙飞 reports that KASAN can report a use-after-free in __lock_acquire. The reason is due to insufficient serialization in lo_release(), which will continue to use the loop device even after it has decremented the lo_refcnt to zero.
In the meantime, another process can come in, open the loop device again as it is being shut down. Confusion ensues.
--- drivers/block/loop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/block/loop.c +8 -2
@@ -1338,9 +1338,8 @@ static int lo_open(struct block_device *bdev, fmode_t mode)return err; } -static void lo_release (struct gendisk *disk,fmode_t mode) +static void __lo_release (struct loop_device *lo) { -struct loop_device *lo = disk->private_data;int err;mutex_lock (&lo->lo_ctl_mutex);
@@ -1368,6 +1367,13 @@ static void lo_release(struct gendisk *disk, fmode_t mode)mutex_unlock (&lo->lo_ctl_mutex); } +static void lo_release (struct gendisk *disk,fmode_t mode) +{ +mutex_lock (&loop_index_mutex); +__lo_release (disk->private_data); +mutex_unlock (&loop_index_mutex); +} +static const struct block_device_operations lo_fops = { .owner =THIS_MODULE , .open = lo_open,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] grace: replace BUG_ON by WARN_ONCE in exit_net hook
In reply to Sasha LevinFrom: Vasily Averin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b872285751c1af010e12d02bce7069e2061a58ca ]
--- fs/nfs_common/grace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfs_common/grace.c +3 -1
@@ -85,7 +85,9 @@ grace_exit_net(struct net *net) {struct list_head *grace_list =net_generic (net, grace_net_id); -BUG_ON (!list_empty (grace_list)); +WARN_ONCE (!list_empty (grace_list), +"net %x %s: grace_list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations grace_net_ops = {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: x86: emulator: Return to user-mode on L1 CPL=0 emulation failure
In reply to Sasha LevinFrom: Liran Alon <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1f4dcb3b213235e642088709a1c54964d23365e9 ]
On this case, handle_emulation_failure() fills kvm_run with internal-error information which it expects to be delivered to user-mode for further processing.
However, the code reports a wrong return-value which makes KVM to never return to user-mode on this scenario.
userspace")
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -5187,7 +5187,7 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu) vcpu->run->exit_reason =KVM_EXIT_INTERNAL_ERROR ; vcpu->run->internal.suberror =KVM_INTERNAL_ERROR_EMULATION ; vcpu->run->internal.ndata =0 ; - r =EMULATE_FAIL ; + r =EMULATE_USER_EXIT ; }kvm_queue_exception (vcpu,UD_VECTOR );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: x86: Don't re-execute instruction when not passing CR2 value
In reply to Sasha LevinFrom: Liran Alon <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9b8ae63798cb97e785a667ff27e43fa6220cb734 ]
In case of instruction-decode failure or emulation failure, x86_emulate_instruction() will call reexecute_instruction() which will attempt to use the cr2 value passed to x86_emulate_instruction(). However, when x86_emulate_instruction() is called from emulate_instruction(), cr2 is not passed (passed as 0) and therefore it doesn't make sense to execute reexecute_instruction() logic at all.
--- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/vmx.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +2 -1
@@ -933,7 +933,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2,static inline int emulate_instruction (struct kvm_vcpu *vcpu,int emulation_type) { -return x86_emulate_instruction (vcpu,0 , emulation_type,NULL ,0 ); +return x86_emulate_instruction (vcpu,0 , + emulation_type |EMULTYPE_NO_REEXECUTE ,NULL ,0 ); }void kvm_enable_efer_bits (u64 );
arch/x86/kvm/vmx.c +1 -1
@@ -5929,7 +5929,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)if (test_bit (KVM_REQ_EVENT , &vcpu->requests))return 1 ; - err =emulate_instruction (vcpu,EMULTYPE_NO_REEXECUTE ); + err =emulate_instruction (vcpu,0 );if (err ==EMULATE_USER_EXIT ) { ++vcpu->stat.mmio_exits;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] bcache: check return value of register_shrinker
In reply to Sasha LevinFrom: Michael Lyle <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6c4ca1e36cdc1a0a7a84797804b87920ccbebf51 ]
register_shrinker is now __must_check, so check it to kill a warning. Caller of bch_btree_cache_alloc in super.c appropriately checks return value so this is fully plumbed through.
This V2 fixes checkpatch warnings and improves the commit description, as I was too hasty getting the previous version out.
--- drivers/md/bcache/btree.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +4 -1
@@ -808,7 +808,10 @@ int bch_btree_cache_alloc(struct cache_set *c) c->shrink.scan_objects = bch_mca_scan; c->shrink.seeks =4 ; c->shrink.batch = c->btree_pages *2 ; -register_shrinker (&c->shrink); + +if (register_shrinker (&c->shrink)) +pr_warn ("bcache: %s: could not register shrinker" , + __func__);return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] drm/amdkfd: Fix SDMA oversubsription handling
In reply to Sasha LevinFrom: Felix Kuehling <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8c946b8988acec785bcf67088b6bd0747f36d2d3 ]
SDMA only supports a fixed number of queues. HWS cannot handle oversubscription.
--- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +18 -0
@@ -189,6 +189,24 @@ int pqm_create_queue(struct process_queue_manager *pqm,switch (type) {case KFD_QUEUE_TYPE_SDMA : +if (dev->dqm->queue_count >= +CIK_SDMA_QUEUES_PER_ENGINE *CIK_SDMA_ENGINE_NUM ) { +pr_err ("Over-subscription is not allowed for SDMA.\n" ); + retval = -EPERM ; + goto err_create_queue; + } + + retval =create_cp_queue (pqm, dev, &q, properties, f, *qid); +if (retval !=0 ) + goto err_create_queue; + pqn->q = q; + pqn->kq =NULL ; + retval = dev->dqm->ops.create_queue (dev->dqm, q, &pdd->qpd, + &q->properties.vmid); +pr_debug ("DQM returned %d for create_queue\n" , retval); +print_queue (q); +break ; +case KFD_QUEUE_TYPE_COMPUTE :/* check if there is over subscription */ if ((sched_policy == KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION) &&
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] nfsd: check for use of the closed special stateid
In reply to Sasha LevinFrom: Andrew Elble <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ae254dac721d44c0bfebe2795df87459e2e88219 ]
Prevent the use of the closed (invalid) special stateid by clients.
--- fs/nfsd/nfs4state.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/nfsd/nfs4state.c +5 -2
@@ -72,6 +72,7 @@ static u64 current_sessionid = 1;#define ZERO_STATEID (stateid) (!memcmp((stateid), &zero_stateid, sizeof(stateid_t)))#define ONE_STATEID (stateid) (!memcmp((stateid), &one_stateid, sizeof(stateid_t)))#define CURRENT_STATEID (stateid) (!memcmp((stateid), ¤tstateid, sizeof(stateid_t))) +#define CLOSE_STATEID (stateid) (!memcmp((stateid), &close_stateid, sizeof(stateid_t)))/* forward declarations */ static bool check_for_locks (struct nfs4_file *fp,struct nfs4_lockowner *lowner);
@@ -4618,7 +4619,8 @@ static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)struct nfs4_stid *s;__be32 status = nfserr_bad_stateid; -if (ZERO_STATEID (stateid) ||ONE_STATEID (stateid)) +if (ZERO_STATEID (stateid) ||ONE_STATEID (stateid) || +CLOSE_STATEID (stateid))return status;/* Client debugging aid. */ if (!same_clid (&stateid->si_opaque.so_clid, &cl->cl_clientid)) {
@@ -4676,7 +4678,8 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,else if (typemask &NFS4_DELEG_STID ) typemask |=NFS4_REVOKED_DELEG_STID ; -if (ZERO_STATEID (stateid) ||ONE_STATEID (stateid)) +if (ZERO_STATEID (stateid) ||ONE_STATEID (stateid) || +CLOSE_STATEID (stateid))return nfserr_bad_stateid; status =lookup_clientid (&stateid->si_opaque.so_clid, cstate, nn);if (status == nfserr_stale_clientid) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: X86: Fix operand/address-size during instruction decoding
In reply to Sasha LevinFrom: Wanpeng Li <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3853be2603191829b442b64dac6ae8ba0c027bf9 ]
Pedro reported:
During tests that we conducted on KVM, we noticed that executing a "PUSH %ES" instruction under KVM produces different results on both memory and the SP register depending on whether EPT support is enabled. With EPT the SP is reduced by 4 bytes (and the written value is 0-padded) but without EPT support it is only reduced by 2 bytes. The difference can be observed when the CS.DB field is 1 (32-bit) but not when it's 0 (16-bit).
The internal segment descriptor cache exist even in real/vm8096 mode. The CS.D also should be respected instead of just default operand/address-size/66H prefix/67H prefix during instruction decoding. This patch fixes it by also adjusting operand/address-size according to CS.D.
--- arch/x86/kvm/emulate.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kvm/emulate.c +7 -0
@@ -4480,6 +4480,8 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)bool op_prefix = false;bool has_seg_override = false;struct opcode opcode; +u16 dummy; +struct desc_struct desc; ctxt->memop.type =OP_NONE ; ctxt->memopp =NULL ;
@@ -4498,6 +4500,11 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)switch (mode) {case X86EMUL_MODE_REAL :case X86EMUL_MODE_VM86 : + def_op_bytes = def_ad_bytes =2 ; + ctxt->ops->get_segment (ctxt, &dummy, &desc,NULL ,VCPU_SREG_CS ); +if (desc.d) + def_op_bytes = def_ad_bytes =4 ; +break ;case X86EMUL_MODE_PROT16 : def_op_bytes = def_ad_bytes =2 ;break ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] cpufreq: Add Loongson machine dependencies
In reply to Sasha LevinFrom: James Hogan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0d307935fefa6389eb726c6362351c162c949101 ]
The MIPS loongson cpufreq drivers don't build unless configured for the correct machine type, due to dependency on machine specific architecture headers and symbols in machine specific platform code.
More specifically loongson1-cpufreq.c uses RST_CPU_EN and RST_CPU, neither of which is defined in asm/mach-loongson32/regs-clk.h unless CONFIG_LOONGSON1_LS1B=y, and loongson2_cpufreq.c references loongson2_clockmod_table[], which is only defined in arch/mips/loongson64/lemote-2f/clock.c, i.e. when CONFIG_LEMOTE_MACH2F=y.
Add these dependencies to Kconfig to avoid randconfig / allyesconfig build failures (e.g. when based on BMIPS which also has a cpufreq driver).
--- drivers/cpufreq/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
drivers/cpufreq/Kconfig +2 -0
@@ -236,6 +236,7 @@ endif if MIPS config LOONGSON2_CPUFREQ tristate "Loongson2 CPUFreq Driver" + depends on LEMOTE_MACH2F help This option adds a CPUFreq driver for loongson processors which support software configurable cpu frequency.
@@ -248,6 +249,7 @@ config LOONGSON2_CPUFREQ config LOONGSON1_CPUFREQ tristate "Loongson1 CPUFreq Driver" + depends on LOONGSON1_LS1B help This option adds a CPUFreq driver for loongson1 processors which support software configurable cpu frequency.
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] openvswitch: fix the incorrect flow action alloc size
In reply to Sasha LevinFrom: zhangliping <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 67c8d22a73128ff910e2287567132530abcf5b71 ]
If we want to add a datapath flow, which has more than 500 vxlan outputs' action, we will get the following error reports:
openvswitch: netlink: Flow action size 32832 bytes exceeds max
openvswitch: netlink: Flow action size 32832 bytes exceeds max
openvswitch: netlink: Actions may not be safe on all matching packets ... ...
It seems that we can simply enlarge the MAX_ACTIONS_BUFSIZE to fix it, but this is not the root cause. For example, for a vxlan output action, we need about 60 bytes for the nlattr, but after it is converted to the flow action, it only occupies 24 bytes. This means that we can still support more than 1000 vxlan output actions for a single datapath flow under the the current 32k max limitation.
So even if the nla_len(attr) is larger than MAX_ACTIONS_BUFSIZE, we shouldn't report EINVAL and keep it move on, as the judgement can be done by the reserve_sfa_size.
--- net/openvswitch/flow_netlink.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/openvswitch/flow_netlink.c +8 -8
@@ -1531,14 +1531,11 @@ int ovs_nla_put_mask(const struct sw_flow *flow, struct sk_buff *skb)#define MAX_ACTIONS_BUFSIZE (32 * 1024) -static struct sw_flow_actions *nla_alloc_flow_actions (int size,bool log) +static struct sw_flow_actions *nla_alloc_flow_actions (int size) {struct sw_flow_actions *sfa; -if (size >MAX_ACTIONS_BUFSIZE ) { -OVS_NLERR (log,"Flow action size %u bytes exceeds max" , size); -return ERR_PTR (-EINVAL ); - } +WARN_ON_ONCE (size >MAX_ACTIONS_BUFSIZE ); sfa =kmalloc (sizeof (*sfa) + size,GFP_KERNEL );if (!sfa)
@@ -1571,12 +1568,15 @@ static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa, new_acts_size =ksize (*sfa) *2 ;if (new_acts_size >MAX_ACTIONS_BUFSIZE ) { -if ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size) +if ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size) { +OVS_NLERR (log,"Flow action size exceeds max %u" , +MAX_ACTIONS_BUFSIZE );return ERR_PTR (-EMSGSIZE ); + } new_acts_size =MAX_ACTIONS_BUFSIZE ; } - acts =nla_alloc_flow_actions (new_acts_size, log); + acts =nla_alloc_flow_actions (new_acts_size);if (IS_ERR (acts))return (void *)acts;
@@ -2170,7 +2170,7 @@ int ovs_nla_copy_actions(const struct nlattr *attr, {int err; - *sfa =nla_alloc_flow_actions (nla_len (attr), log); + *sfa =nla_alloc_flow_actions (min (nla_len (attr),MAX_ACTIONS_BUFSIZE ));if (IS_ERR (*sfa))return PTR_ERR (*sfa);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] mac80211: fix the update of path metric for RANN frame
In reply to Sasha LevinFrom: Chun-Yeow Yeoh <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fbbdad5edf0bb59786a51b94a9d006bc8c2da9a2 ]
The previous path metric update from RANN frame has not considered the own link metric toward the transmitting mesh STA. Fix this.
--- net/mac80211/mesh_hwmp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
net/mac80211/mesh_hwmp.c +9 -6
@@ -763,7 +763,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,struct mesh_path *mpath;u8 ttl, flags, hopcount;const u8 *orig_addr; -u32 orig_sn, metric, metric_txsta, interval; +u32 orig_sn, new_metric, orig_metric, last_hop_metric, interval;bool root_is_gate; ttl = rann->rann_ttl;
@@ -774,7 +774,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, interval =le32_to_cpu (rann->rann_interval); hopcount = rann->rann_hopcount; hopcount++; - metric =le32_to_cpu (rann->rann_metric); + orig_metric =le32_to_cpu (rann->rann_metric);/* Ignore our own RANNs */ if (ether_addr_equal (orig_addr, sdata->vif.addr))
@@ -791,7 +791,10 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,return ; } - metric_txsta =airtime_link_metric_get (local, sta); + last_hop_metric =airtime_link_metric_get (local, sta); + new_metric = orig_metric + last_hop_metric; +if (new_metric < orig_metric) + new_metric =MAX_METRIC ; mpath =mesh_path_lookup (sdata, orig_addr);if (!mpath) {
@@ -804,7 +807,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, }if (!(SN_LT (mpath->sn, orig_sn)) && - !(mpath->sn == orig_sn && metric < mpath->rann_metric)) { + !(mpath->sn == orig_sn && new_metric < mpath->rann_metric)) {rcu_read_unlock ();return ; }
@@ -822,7 +825,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, } mpath->sn = orig_sn; - mpath->rann_metric = metric + metric_txsta; + mpath->rann_metric = new_metric; mpath->is_root = true;/* Recording RANNs sender address to send individually * addressed PREQs destined for root mesh STA */
@@ -842,7 +845,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,mesh_path_sel_frame_tx (MPATH_RANN , flags, orig_addr, orig_sn,0 ,NULL ,0 , broadcast_addr, hopcount, ttl, interval, - metric + metric_txsta,0 , sdata); + new_metric,0 , sdata); }rcu_read_unlock ();
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] btrfs: fix deadlock when writing out space cache
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b77000ed558daa3bef0899d29bf171b8c9b5e6a8 ]
If we fail to prepare our pages for whatever reason (out of memory in our case) we need to make sure to drop the block_group->data_rwsem, otherwise hilarity ensues.
--- fs/btrfs/free-space-cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/free-space-cache.c +2 -1
@@ -1260,7 +1260,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,/* Lock all pages first so we can lock the extent safely. */ ret =io_ctl_prepare_pages (io_ctl, inode,0 );if (ret) - goto out; + goto out_unlock;lock_extent_bits (&BTRFS_I (inode)->io_tree,0 ,i_size_read (inode) -1 ,0 , &cached_state);
@@ -1353,6 +1353,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, out_nospc:cleanup_write_cache_enospc (inode, io_ctl, &cached_state, &bitmap_list); +out_unlock:if (block_group && (block_group->flags &BTRFS_BLOCK_GROUP_DATA ))up_write (&block_group->data_rwsem);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: VMX: Fix rflags cache during vCPU reset
In reply to Sasha LevinFrom: Wanpeng Li <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c37c28730bb031cc8a44a130c2555c0f3efbe2d0 ]
Reported by syzkaller:
*** Guest State ***
CR0: actual=0x0000000080010031, shadow=0x0000000060000010, gh_mask=fffffffffffffff7
CR4: actual=0x0000000000002061, shadow=0x0000000000000000, gh_mask=ffffffffffffe8f1 CR3 = 0x000000002081e000
RSP = 0x000000000000fffa RIP = 0x0000000000000000
RFLAGS=0x00023000 DR7 = 0x00000000000000
^^^^^^^^^^
------------[ cut here ]------------
WARNING: CPU: 6 PID: 24431 at /home/kernel/linux/arch/x86/kvm//x86.c:7302 kvm_arch_vcpu_ioctl_run+0x651/0x2ea0 [kvm]
CPU: 6 PID: 24431 Comm: reprotest Tainted: G W OE 4.14.0+ #26
RIP: 0010:kvm_arch_vcpu_ioctl_run+0x651/0x2ea0 [kvm]
RSP: 0018:ffff880291d179e0 EFLAGS: 00010202
Call Trace:
kvm_vcpu_ioctl+0x479/0x880 [kvm]
do_vfs_ioctl+0x142/0x9a0
SyS_ioctl+0x74/0x80
entry_SYSCALL_64_fastpath+0x23/0x9aThe failed vmentry is triggered by the following beautified testcase:
#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[5];
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);
struct kvm_guest_debug debug = {
.control = 0xf0403,
.arch = {
.debugreg[6] = 0x2,
.debugreg[7] = 0x2
}
};
ioctl(r[4], KVM_SET_GUEST_DEBUG, &debug);
ioctl(r[4], KVM_RUN, 0);
}which testcase tries to setup the processor specific debug registers and configure vCPU for handling guest debug events through KVM_SET_GUEST_DEBUG. The KVM_SET_GUEST_DEBUG ioctl will get and set rflags in order to set TF bit if single step is needed. All regs' caches are reset to avail and GUEST_RFLAGS vmcs field is reset to 0x2 during vCPU reset. However, the cache of rflags is not reset during vCPU reset. The function vmx_get_rflags() returns an unreset rflags cache value since the cache is marked avail, it is 0 after boot. Vmentry fails if the rflags reserved bit 1 is 0.
This patch fixes it by resetting both the GUEST_RFLAGS vmcs field and its cache to 0x2 during vCPU reset.
--- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx.c +1 -1
@@ -4770,7 +4770,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu)vmcs_writel (GUEST_SYSENTER_ESP ,0 );vmcs_writel (GUEST_SYSENTER_EIP ,0 ); -vmcs_writel (GUEST_RFLAGS ,0x02 ); +kvm_set_rflags (vcpu,X86_EFLAGS_FIXED );kvm_rip_write (vcpu,0xfff0 );vmcs_writel (GUEST_GDTR_BASE ,0 );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] xen-netfront: remove warning when unloading module
In reply to Sasha LevinFrom: Eduardo Otubo <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5b5971df3bc2775107ddad164018a8a8db633b81 ]
v2:
* Replace busy wait with wait_event()/wake_up_all()
* Cannot garantee that at the time xennet_remove is called, the xen_netback state will not be XenbusStateClosed, so added a condition for that
* There's a small chance for the xen_netback state is XenbusStateUnknown by the time the xen_netfront switches to Closed, so added a condition for that.
When unloading module xen_netfront from guest, dmesg would output warning messages like below:
[ 105.236836] xen:grant_table: WARNING: g.e. 0x903 still in use! [ 105.236839] deferring g.e. 0x903 (pfn 0x35805)
This problem relies on netfront and netback being out of sync. By the time netfront revokes the g.e.'s netback didn't have enough time to free all of them, hence displaying the warnings on dmesg.
The trick here is to make netfront to wait until netback frees all the g.e.'s and only then continue to cleanup for the module removal, and this is done by manipulating both device states.
--- drivers/net/xen-netfront.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/xen-netfront.c +18 -0
@@ -87,6 +87,8 @@ struct netfront_cb {/* IRQ name is queue name with "-tx" or "-rx" appended */ #define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3) +static DECLARE_WAIT_QUEUE_HEAD (module_unload_q); +struct netfront_stats {u64 packets;u64 bytes;
@@ -1999,10 +2001,12 @@ static void netback_changed(struct xenbus_device *dev,break ;case XenbusStateClosed: +wake_up_all (&module_unload_q);if (dev->state == XenbusStateClosed)break ;/* Missed the backend's CLOSING state -- fallthrough */ case XenbusStateClosing: +wake_up_all (&module_unload_q);xenbus_frontend_closed (dev);break ; }
@@ -2108,6 +2112,20 @@ static int xennet_remove(struct xenbus_device *dev)dev_dbg (&dev->dev,"%s\n" , dev->nodename); +if (xenbus_read_driver_state (dev->otherend) != XenbusStateClosed) { +xenbus_switch_state (dev, XenbusStateClosing); +wait_event (module_unload_q, +xenbus_read_driver_state (dev->otherend) == + XenbusStateClosing); + +xenbus_switch_state (dev, XenbusStateClosed); +wait_event (module_unload_q, +xenbus_read_driver_state (dev->otherend) == + XenbusStateClosed || +xenbus_read_driver_state (dev->otherend) == + XenbusStateUnknown); + } +xennet_disconnect_backend (info);unregister_netdev (info->netdev);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] nfsd: CLOSE SHOULD return the invalid special stateid for NFSv4.x (x>0)
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fb500a7cfee7f2f447d2bbf30cb59629feab6ac1 ]
--- fs/nfsd/nfs4state.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/nfsd/nfs4state.c +8 -0
@@ -63,6 +63,9 @@ static const stateid_t zero_stateid = {static const stateid_t currentstateid = { .si_generation =1 , }; +static const stateid_t close_stateid = { + .si_generation =0xffffffffU , +};static u64 current_sessionid =1 ;
@@ -5107,6 +5110,11 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,nfsd4_close_open_stateid (stp); +/* See RFC5661 sectionm 18.2.4 */ +if (stp->st_stid.sc_client->cl_minorversion) +memcpy (&close->cl_stateid, &close_stateid, +sizeof (close->cl_stateid)); +/* put reference from nfs4_preprocess_seqid_op */ nfs4_put_stid (&stp->st_stid); out:
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] hwmon: (pmbus) Use 64bit math for DIRECT format values
In reply to Sasha LevinFrom: Robert Lippert <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bd467e4eababe4c04272c1e646f066db02734c79 ]
Power values in the 100s of watt range can easily blow past 32bit math limits when processing everything in microwatts.
Use 64bit math instead to avoid these issues on common 32bit ARM BMC platforms.
--- drivers/hwmon/pmbus/pmbus_core.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +12 -9
@@ -20,6 +20,7 @@*/ #include <linux/kernel.h> +#include <linux/math64.h> #include <linux/module.h> #include <linux/init.h> #include <linux/err.h>
@@ -476,8 +477,8 @@ static long pmbus_reg2data_linear(struct pmbus_data *data,static long pmbus_reg2data_direct (struct pmbus_data *data,struct pmbus_sensor *sensor) { -long val = (s16 ) sensor->data; -long m, b,R ; +s64 b, val = (s16 )sensor->data; +s32 m,R ; m = data->info->m[sensor->class]; b = data->info->b[sensor->class];
@@ -505,11 +506,12 @@ static long pmbus_reg2data_direct(struct pmbus_data *data,R --; }while (R <0 ) { - val =DIV_ROUND_CLOSEST (val,10 ); + val =div_s64 (val +5LL ,10L );/* round closest */ R ++; } -return (val - b) / m; + val =div_s64 (val - b, m); +return clamp_val (val,LONG_MIN ,LONG_MAX ); }/*
@@ -621,7 +623,8 @@ static u16 pmbus_data2reg_linear(struct pmbus_data *data,static u16 pmbus_data2reg_direct (struct pmbus_data *data,struct pmbus_sensor *sensor,long val) { -long m, b,R ; +s64 b, val64 = val; +s32 m,R ; m = data->info->m[sensor->class]; b = data->info->b[sensor->class];
@@ -638,18 +641,18 @@ static u16 pmbus_data2reg_direct(struct pmbus_data *data,R -=3 ;/* Adjust R and b for data in milli-units */ b *=1000 ; } - val = val * m + b; + val64 = val64 * m + b;while (R >0 ) { - val *=10 ; + val64 *=10 ;R --; }while (R <0 ) { - val =DIV_ROUND_CLOSEST (val,10 ); + val64 =div_s64 (val64 +5LL ,10L );/* round closest */ R ++; } -return val; +return (u16 )clamp_val (val64,S16_MIN ,S16_MAX ); } static u16 pmbus_data2reg_vid(struct pmbus_data *data,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: ethernet: xilinx: Mark XILINX_LL_TEMAC broken on 64-bit
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 15bfe05c8d6386f1a90e9340d15336e85e32aad6 ]
On 64-bit (e.g. powerpc64/allmodconfig):
drivers/net/ethernet/xilinx/ll_temac_main.c: In function 'temac_start_xmit_done':
drivers/net/ethernet/xilinx/ll_temac_main.c:633:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
dev_kfree_skb_irq((struct sk_buff *)cur_p->app4);
^
cdmac_bd.app4 is u32, so it is too small to hold a kernel pointer.
Note that several other fields in struct cdmac_bd are also too small to hold physical addresses on 64-bit platforms.
--- drivers/net/ethernet/xilinx/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/xilinx/Kconfig +1 -0
@@ -36,6 +36,7 @@ config XILINX_AXI_EMAC config XILINX_LL_TEMAC tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver" depends on (PPC || MICROBLAZE) + depends on !64BIT || BROKEN select PHYLIB ---help--- This driver supports the Xilinx 10/100/1000 LocalLink TEMAC
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] quota: Check for register_shrinker() failure.
In reply to Sasha LevinFrom: Tetsuo Handa <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 88bc0ede8d35edc969350852894dc864a2dc1859 ]
register_shrinker() might return -ENOMEM error since Linux 3.12. Call panic() as with other failure checks in this function if register_shrinker() failed.
--- fs/quota/dquot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/quota/dquot.c +2 -1
@@ -2881,7 +2881,8 @@ static int __init dquot_init(void)pr_info ("VFS: Dquot-cache hash table entries: %ld (order %ld," " %ld bytes)\n" , nr_hash, order, (PAGE_SIZE << order)); -register_shrinker (&dqcache_shrinker); +if (register_shrinker (&dqcache_shrinker)) +panic ("Cannot register dquot shrinker" );return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] SUNRPC: Allow connect to return EHOSTUNREACH
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4ba161a793d5f43757c35feff258d9f20a082940 ]
--- net/sunrpc/xprtsock.c | 1 + 1 file changed, 1 insertion(+)
net/sunrpc/xprtsock.c +1 -0
@@ -2189,6 +2189,7 @@ static void xs_tcp_setup_socket(struct work_struct *work)case -ECONNREFUSED :case -ECONNRESET :case -ENETUNREACH : +case -EHOSTUNREACH :case -EADDRINUSE :case -ENOBUFS :/* retry with existing socket, after a delay */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] drm/omap: Fix error handling path in 'omap_dmm_probe()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8677b1ac2db021ab30bb1fa34f1e56ebe0051ec3 ]
If we don't find a matching device node, we must free the memory allocated in 'omap_dmm' a few lines above.
--- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +2 -1
@@ -610,7 +610,8 @@ static int omap_dmm_probe(struct platform_device *dev) match =of_match_node (dmm_of_match, dev->dev.of_node);if (!match) {dev_err (&dev->dev,"failed to find matching device node\n" ); -return -ENODEV ; + ret = -ENODEV ; + goto fail; } omap_dmm->plat_data = match->data;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] xfs: ubsan fixes
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 22a6c83777ac7c17d6c63891beeeac24cf5da450 ]
Fix some complaints from the UBSAN about signed integer addition overflows.
--- fs/xfs/xfs_aops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/xfs/xfs_aops.c +3 -3
@@ -303,7 +303,7 @@ xfs_map_blocks( (ip->i_df.if_flags & XFS_IFEXTENTS));ASSERT (offset <= mp->m_super->s_maxbytes); -if (offset + count > mp->m_super->s_maxbytes) +if ((xfs_ufsize_t )offset + count > mp->m_super->s_maxbytes) count = mp->m_super->s_maxbytes - offset; end_fsb =XFS_B_TO_FSB (mp, (xfs_ufsize_t )offset + count); offset_fsb =XFS_B_TO_FSBT (mp, offset);
@@ -1332,7 +1332,7 @@ xfs_map_trim_size(if (mapping_size > size) mapping_size = size;if (offset <i_size_read (inode) && - offset + mapping_size >=i_size_read (inode)) { + (xfs_ufsize_t )offset + mapping_size >=i_size_read (inode)) {/* limit mapping to block that spans EOF */ mapping_size =roundup_64 (i_size_read (inode) - offset,1 << inode->i_blkbits);
@@ -1387,7 +1387,7 @@ __xfs_get_blocks( }ASSERT (offset <= mp->m_super->s_maxbytes); -if (offset + size > mp->m_super->s_maxbytes) +if ((xfs_ufsize_t )offset + size > mp->m_super->s_maxbytes) size = mp->m_super->s_maxbytes - offset; end_fsb =XFS_B_TO_FSB (mp, (xfs_ufsize_t )offset + size); offset_fsb =XFS_B_TO_FSBT (mp, offset);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 727535903bea924c4f73abb202c4b3e85fff0ca4 ]
_vreg_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference.
Fix this by moving the pointer dereference after _vreg_ has been null checked.
This issue was detected with the help of Coccinelle.
--- drivers/scsi/ufs/ufshcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +5 -2
@@ -4290,12 +4290,15 @@ static int ufshcd_config_vreg(struct device *dev, struct ufs_vreg *vreg, bool on) { int ret = 0; -struct regulator *reg = vreg->reg; -const char *name = vreg->name; +struct regulator *reg; +const char *name;int min_uV, uA_load;BUG_ON (!vreg); + reg = vreg->reg; + name = vreg->name; +if (regulator_count_voltages (reg) >0 ) { min_uV = on ? vreg->min_uV :0 ; ret =regulator_set_voltage (reg, min_uV, vreg->max_uV);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] media: usbtv: add a new usbid
In reply to Sasha LevinFrom: Icenowy Zheng <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 04226916d2360f56d57ad00bc48d2d1854d1e0b0 ]
A new usbid of UTV007 is found in a newly bought device.
The usbid is 1f71:3301.
The ID on the chip is:
UTV007
A89029.1
1520L18K1
Both video and audio is tested with the modified usbtv driver.
--- drivers/media/usb/usbtv/usbtv-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/usbtv/usbtv-core.c +1 -0
@@ -127,6 +127,7 @@ static void usbtv_disconnect(struct usb_interface *intf)static struct usb_device_id usbtv_id_table[] = { {USB_DEVICE (0x1b71 ,0x3002 ) }, + {USB_DEVICE (0x1f71 ,0x3301 ) }, {} };MODULE_DEVICE_TABLE (usb, usbtv_id_table);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: gadget: don't dereference g until after it has been null checked
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b2fc059fa549fe6881d4c1f8d698b0f50bcd16ec ]
Avoid dereferencing pointer g until after g has been sanity null checked; move the assignment of cdev much later when it is required into a more local scope.
Detected by CoverityScan, CID#1222135 ("Dereference before null check")
--- drivers/usb/gadget/composite.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/gadget/composite.c +5 -2
@@ -103,7 +103,6 @@ int config_ep_by_speed(struct usb_gadget *g,struct usb_function *f, struct usb_ep *_ep) { - struct usb_composite_dev *cdev = get_gadget_data(g); struct usb_endpoint_descriptor *chosen_desc = NULL;struct usb_descriptor_header **speed_desc =NULL ;
@@ -170,8 +169,12 @@ int config_ep_by_speed(struct usb_gadget *g, _ep->maxburst = comp_desc->bMaxBurst +1 ;break ;default : -if (comp_desc->bMaxBurst !=0 ) +if (comp_desc->bMaxBurst !=0 ) { +struct usb_composite_dev *cdev; + + cdev =get_gadget_data (g);ERROR (cdev,"ep0 bMaxBurst must be 0\n" ); + } _ep->maxburst =1 ;break ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] staging: rtl8188eu: Fix incorrect response to SIOCGIWESSID
In reply to Sasha LevinFrom: Larry Finger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b77992d2df9e47144354d1b25328b180afa33442 ]
When not associated with an AP, wifi device drivers should respond to the SIOCGIWESSID ioctl with a zero-length string for the SSID, which is the behavior expected by dhcpcd.
Currently, this driver returns an error code (-1) from the ioctl call, which causes dhcpcd to assume that the device is not a wireless interface and therefore it fails to work correctly with it thereafter.
This problem was reported and tested at
https://github.com/lwfinger/rtl8188eu/issues/234.
--- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +4 -10
@@ -1397,19 +1397,13 @@ static int rtw_wx_get_essid(struct net_device *dev,if ((check_fwstate (pmlmepriv, _FW_LINKED)) || (check_fwstate (pmlmepriv,WIFI_ADHOC_MASTER_STATE ))) { len = pcur_bss->Ssid.SsidLength; - - wrqu->essid.length = len; -memcpy (extra, pcur_bss->Ssid.Ssid, len); - - wrqu->essid.flags =1 ; }else { - ret =-1 ; - goto exit; + len =0 ; + *extra =0 ; } - -exit: - + wrqu->essid.length = len; + wrqu->essid.flags =1 ;return ret; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: option: Add support for FS040U modem
In reply to Sasha LevinFrom: OKAMOTO Yoshiaki <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 69341bd15018da0a662847e210f9b2380c71e623 ]
FS040U modem is manufactured by omega, and sold by Fujisoft. This patch adds ID of the modem to use option1 driver. Interface 3 is used as qmi_wwan, so the interface is ignored.
--- drivers/usb/serial/option.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/option.c +5 -0
@@ -375,6 +375,9 @@ static void option_instat_callback(struct urb *urb);#define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603#define FOUR_G_SYSTEMS_PRODUCT_W100 0x9b01 +/* Fujisoft products */ +#define FUJISOFT_PRODUCT_FS040U 0x9b02 +/* iBall 3.5G connect wireless modem */ #define IBALL_3_5G_CONNECT 0x9605
@@ -1882,6 +1885,8 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W100), .driver_info = (kernel_ulong_t)&four_g_w100_blacklist }, + {USB_DEVICE(LONGCHEER_VENDOR_ID, FUJISOFT_PRODUCT_FS040U), + .driver_info = (kernel_ulong_t)&net_intf3_blacklist}, { USB_DEVICE_INTERFACE_CLASS(LONGCHEER_VENDOR_ID, SPEEDUP_PRODUCT_SU9800, 0xff) }, { USB_DEVICE_INTERFACE_CLASS(LONGCHEER_VENDOR_ID, 0x9801, 0xff), .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] USB: serial: pl2303: new device id for Chilitag
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d08dd3f3dd2ae351b793fc5b76abdbf0fd317b12 ]
This adds a new device id for Chilitag devices to the pl2303 driver.
--- drivers/usb/serial/pl2303.c | 1 + drivers/usb/serial/pl2303.h | 1 + 2 files changed, 2 insertions(+)
drivers/usb/serial/pl2303.c +1 -0
@@ -39,6 +39,7 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) }, { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_CHILITAG) }, { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) },
drivers/usb/serial/pl2303.h +1 -0
@@ -17,6 +17,7 @@#define PL2303_PRODUCT_ID_DCU11 0x1234#define PL2303_PRODUCT_ID_PHAROS 0xaaa0#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 +#define PL2303_PRODUCT_ID_CHILITAG 0xaaa8#define PL2303_PRODUCT_ID_ALDIGA 0x0611#define PL2303_PRODUCT_ID_MMX 0x0612#define PL2303_PRODUCT_ID_GPRS 0x0609
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] USB: cdc-acm: Do not log urb submission errors on disconnect
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f0386c083c2ce85284dc0b419d7b89c8e567c09f ]
When disconnected sometimes the cdc-acm driver logs errors like these:
[20278.039417] cdc_acm 2-2:2.1: urb 9 failed submission with -19 [20278.042924] cdc_acm 2-2:2.1: urb 10 failed submission with -19 [20278.046449] cdc_acm 2-2:2.1: urb 11 failed submission with -19 [20278.049920] cdc_acm 2-2:2.1: urb 12 failed submission with -19 [20278.053442] cdc_acm 2-2:2.1: urb 13 failed submission with -19 [20278.056915] cdc_acm 2-2:2.1: urb 14 failed submission with -19 [20278.060418] cdc_acm 2-2:2.1: urb 15 failed submission with -19
Silence these by not logging errors when the result is -ENODEV.
--- drivers/usb/class/cdc-acm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/class/cdc-acm.c +1 -1
@@ -381,7 +381,7 @@ static int acm_submit_read_urb(struct acm *acm, int index, gfp_t mem_flags) res =usb_submit_urb (acm->read_urbs[index], mem_flags);if (res) { -if (res != -EPERM ) { +if (res != -EPERM && res != -ENODEV ) {dev_err (&acm->data->dev,"%s - usb_submit_urb failed: %d\n" , __func__, res);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] CDC-ACM: apply quirk for card reader
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit df1cc78a52491f71d8170d513d0f6f114faa1bda ]
This devices drops random bytes from messages if you talk to it too fast.
--- drivers/usb/class/cdc-acm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/class/cdc-acm.c +3 -0
@@ -1707,6 +1707,9 @@ static const struct usb_device_id acm_ids[] = { { USB_DEVICE(0x0ace, 0x1611), /* ZyDAS 56K USB MODEM - new version */ .driver_info =SINGLE_RX_URB ,/* firmware bug */ }, + { USB_DEVICE(0x11ca, 0x0201), /* VeriFone Mx870 Gadget Serial */ + .driver_info = SINGLE_RX_URB, + }, { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ },
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: list: don't list devices attached to vhci_hcd
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ef824501f50846589f02173d73ce3fe6021a9d2a ]
usbip host lists devices attached to vhci_hcd on the same server when user does attach over localhost or specifies the server as the remote.
usbip attach -r localhost -b busid
or
usbip attach -r servername (or server IP)
Fix it to check and not list devices that are attached to vhci_hcd.
--- tools/usb/usbip/src/usbip_list.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/usb/usbip/src/usbip_list.c +9 -0
@@ -180,6 +180,7 @@ static int list_devices(bool parsable)const char *busid;char product_name[128 ];int ret =-1 ; +const char *devpath;/* Create libudev context. */ udev =udev_new ();
@@ -202,6 +203,14 @@ static int list_devices(bool parsable) path =udev_list_entry_get_name (dev_list_entry); dev =udev_device_new_from_syspath (udev, path); +/* Ignore devices attached to vhci_hcd */ + devpath =udev_device_get_devpath (dev); +if (strstr (devpath,USBIP_VHCI_DRV_NAME )) { +dbg ("Skip the device %s already attached to %s\n" , + devpath,USBIP_VHCI_DRV_NAME ); +continue ; + } +/* Get device information. */ idVendor =udev_device_get_sysattr_value (dev,"idVendor" ); idProduct =udev_device_get_sysattr_value (dev,"idProduct" );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] USB: serial: io_edgeport: fix possible sleep-in-atomic
In reply to Sasha LevinFrom: Jia-Ju Bai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c7b8f77872c73f69a16528a9eb87afefcccdc18b ]
According to drivers/usb/serial/io_edgeport.c, the driver may sleep under a spinlock.
The function call path is:edge_bulk_in_callback (acquire the spinlock)
process_rcvd_data
process_rcvd_status
change_port_settings
send_iosp_ext_cmd
write_cmd_usb
usb_kill_urb --> may sleepTo fix it, the redundant usb_kill_urb() is removed from the error path after usb_submit_urb() fails.
This possible bug is found by my static analysis tool (DSAC) and checked by my code review.
--- drivers/usb/serial/io_edgeport.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/serial/io_edgeport.c +0 -1
@@ -2219,7 +2219,6 @@ static int write_cmd_usb(struct edgeport_port *edge_port,/* something went wrong */ dev_err (dev,"%s - usb_submit_urb(write command) failed, status = %d\n" , __func__, status); -usb_kill_urb (urb);usb_free_urb (urb);atomic_dec (&CmdUrbs);return status;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: prevent bind loops on devices attached to vhci_hcd
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ef54cf0c600fb8f5737fb001a9e357edda1a1de8 ]
usbip host binds to devices attached to vhci_hcd on the same server when user does attach over localhost or specifies the server as the remote.
usbip attach -r localhost -b busid
or
usbip attach -r servername (or server IP)
Unbind followed by bind works, however device is left in a bad state with accesses via the attached busid result in errors and system hangs during shutdown.
Fix it to check and bail out if the device is already attached to vhci_hcd.
--- tools/usb/usbip/src/usbip_bind.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/usb/usbip/src/usbip_bind.c +9 -0
@@ -144,6 +144,7 @@ static int bind_device(char *busid)int rc;struct udev *udev;struct udev_device *dev; +const char *devpath;/* Check whether the device with this bus ID exists. */ udev =udev_new ();
@@ -152,8 +153,16 @@ static int bind_device(char *busid)err ("device with the specified bus ID does not exist" );return -1 ; } + devpath =udev_device_get_devpath (dev);udev_unref (udev); +/* If the device is already attached to vhci_hcd - bail out */ +if (strstr (devpath,USBIP_VHCI_DRV_NAME )) { +err ("bind loop detected: device: %s is attached to %s\n" , + devpath,USBIP_VHCI_DRV_NAME ); +return -1 ; + } + rc =unbind_other (busid);if (rc ==UNBIND_ST_FAILED ) {err ("could not unbind driver from device on busid %s" , busid);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] USB: serial: simple: add Motorola Tetra driver
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 46fe895e22ab3845515ec06b01eaf1282b342e29 ]
Add new Motorola Tetra (simple) driver for Motorola Solutions TETRA PEI devices.
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=0cad ProdID=9011 Rev=24.16 S: Manufacturer=Motorola Solutions Inc. S: Product=Motorola Solutions TETRA PEI interface C: #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none) I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
Note that these devices do not support the CDC SET_CONTROL_LINE_STATE request (for any interface).
--- drivers/usb/serial/Kconfig | 1 + drivers/usb/serial/usb-serial-simple.c | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/usb/serial/Kconfig +1 -0
@@ -63,6 +63,7 @@ config USB_SERIAL_SIMPLE - Google USB serial devices - HP4x calculators - a number of Motorola phones + - Motorola Tetra devices - Novatel Wireless GPS receivers - Siemens USB/MPI adapter. - ViVOtech ViVOpay USB device.
drivers/usb/serial/usb-serial-simple.c +7 -0
@@ -80,6 +80,11 @@ DEVICE(vivopay, VIVOPAY_IDS); { USB_DEVICE(0x22b8, 0x2c64) } /* Motorola V950 phone */DEVICE (moto_modem,MOTO_IDS ); +/* Motorola Tetra driver */ +#define MOTOROLA_TETRA_IDS () \ + { USB_DEVICE(0x0cad, 0x9011) }/* Motorola Solutions TETRA PEI */ +DEVICE (motorola_tetra,MOTOROLA_TETRA_IDS ); +/* Novatel Wireless GPS driver */ #define NOVATEL_IDS () \ { USB_DEVICE(0x09d7, 0x0100) }/* NovAtel FlexPack GPS */
@@ -110,6 +115,7 @@ static struct usb_serial_driver * const serial_drivers[] = { &google_device, &vivopay_device, &moto_modem_device, + &motorola_tetra_device, &novatel_gps_device, &hp4x_device, &suunto_device,
@@ -125,6 +131,7 @@ static const struct usb_device_id id_table[] = {GOOGLE_IDS (),VIVOPAY_IDS (),MOTO_IDS (), +MOTOROLA_TETRA_IDS (),NOVATEL_IDS (),HP4X_IDS (), SUUNTO_IDS(),
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: f_fs: Prevent gadget unbind if it is already unbound
In reply to Sasha LevinFrom: Hemant Kumar <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ce5bf9a50daf2d9078b505aca1cea22e88ecb94a ]
Upon usb composition switch there is possibility of ep0 file release happening after gadget driver bind. In case of composition switch from adb to a non-adb composition gadget will never gets bound again resulting into failure of usb device enumeration. Fix this issue by checking FFS_FL_BOUND flag and avoid extra gadget driver unbind if it is already done as part of composition switch.
This fixes adb reconnection error reported on Android running v4.4 and above kernel versions. Verified on Hikey running vanilla v4.15-rc7 + few out of tree Mali patches.
Reviewed-at: https://android-review.googlesource.com/#/c/582632/
--- drivers/usb/gadget/function/f_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_fs.c +2 -1
@@ -3486,7 +3486,8 @@ static void ffs_closed(struct ffs_data *ffs) ci = opts->func_inst.group.cg_item.ci_parent->ci_parent;ffs_dev_unlock (); -unregister_gadget_item (ci); +if (test_bit (FFS_FL_BOUND , &ffs->flags)) +unregister_gadget_item (ci);return ; done:ffs_dev_unlock ();
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: uas: unconditionally bring back host after reset
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cbeef22fd611c4f47c494b821b2b105b8af970bb ]
Quoting Hans:
If we return 1 from our post_reset handler, then our disconnect handler will be called immediately afterwards. Since pre_reset blocks all scsi requests our disconnect handler will then hang in the scsi_remove_host call.
This is esp. bad because our disconnect handler hanging for ever also stops the USB subsys from enumerating any new USB devices, causes commands like lsusb to hang, etc.
In practice this happens when unplugging some uas devices because the hub code may see the device as needing a warm-reset and calls usb_reset_device before seeing the disconnect. In this case uas_configure_endpoints fails with -ENODEV. We do not want to print an error for this, so this commit also silences the shost_printk for -ENODEV.
ENDQUOTE
However, if we do that we better drop any unconditional execution and report to the SCSI subsystem that we have undergone a reset but we are not operational now.
--- drivers/usb/storage/uas.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/storage/uas.c +3 -4
@@ -1052,20 +1052,19 @@ static int uas_post_reset(struct usb_interface *intf)return 0 ; err =uas_configure_endpoints (devinfo); -if (err) { +if (err && err !=ENODEV )shost_printk (KERN_ERR , shost,"%s: alloc streams error %d after reset" , __func__, err); -return 1 ; - } +/* we must unblock the host in every case lest we deadlock */ spin_lock_irqsave (shost->host_lock, flags);scsi_report_bus_reset (shost,0 );spin_unlock_irqrestore (shost->host_lock, flags);scsi_unblock_requests (shost); -return 0 ; +return err ?1 :0 ; }static int uas_suspend (struct usb_interface *intf,pm_message_t message)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] spi: imx: do not access registers while clocks disabled
In reply to Sasha LevinFrom: Stefan Agner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d593574aff0ab846136190b1729c151c736727ec ]
Since clocks are disabled except during message transfer clocks are also disabled when spi_imx_remove gets called. Accessing registers leads to a freeeze at least on a i.MX 6ULL. Enable clocks before disabling accessing the MXC_CSPICTRL register.
--- drivers/spi/spi-imx.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/spi/spi-imx.c +13 -2
@@ -1221,12 +1221,23 @@ static int spi_imx_remove(struct platform_device *pdev) {struct spi_master *master =platform_get_drvdata (pdev);struct spi_imx_data *spi_imx =spi_master_get_devdata (master); +int ret;spi_bitbang_stop (&spi_imx->bitbang); + ret =clk_enable (spi_imx->clk_per); +if (ret) +return ret; + + ret =clk_enable (spi_imx->clk_ipg); +if (ret) { +clk_disable (spi_imx->clk_per); +return ret; + } +writel (0 , spi_imx->base +MXC_CSPICTRL ); -clk_unprepare (spi_imx->clk_ipg); -clk_unprepare (spi_imx->clk_per); +clk_disable_unprepare (spi_imx->clk_ipg); +clk_disable_unprepare (spi_imx->clk_per);spi_imx_sdma_exit (spi_imx);spi_master_put (master);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/bpf/jit: Disable classic BPF JIT on ppc64le
In reply to Sasha LevinFrom: "Naveen N. Rao" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 844e3be47693f92a108cb1fb3b0606bf25e9c7a6 ]
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
@@ -126,7 +126,7 @@ config PPC select IRQ_FORCED_THREADING select HAVE_RCU_TABLE_FREE if SMP select HAVE_SYSCALL_TRACEPOINTS - select HAVE_BPF_JIT + select HAVE_BPF_JIT if CPU_BIG_ENDIAN select HAVE_ARCH_JUMP_LABEL select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_HAS_GCOV_PROFILE_ALL
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64: Fix flush_(d|i)cache_range() called from modules
In reply to Sasha LevinFrom: Oliver O'Halloran <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8f5f525d5b83f7d76a6baf9c4e94d4bf312ea7f6 ]
When the kernel is compiled to use 64bit ABIv2 the _GLOBAL() macro does not include a global entry point. A function's global entry point is used when the function is called from a different TOC context and in the kernel this typically means a call from a module into the vmlinux (or vice-versa).
There are a few exported asm functions declared with _GLOBAL() and calling them from a module will likely crash the kernel since any TOC relative load will yield garbage.
flush_icache_range() and flush_dcache_range() are both exported to modules, and use the TOC, so must use _GLOBAL_TOC().
--- arch/powerpc/include/asm/ppc_asm.h | 12 ++++++++++++ arch/powerpc/kernel/misc_64.S | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/ppc_asm.h +12 -0
@@ -224,6 +224,16 @@ name: \ .globl name; \ name: +#define _KPROBE_TOC (name) \ + .section ".kprobes.text","a"; \ + .align 2 ; \ + .type name,@function; \ + .globl name; \ +name: \ +0: addis r2,r12,(.TOC.-0b)@ha; \ + addi r2,r2,(.TOC.-0b)@l; \ + .localentry name,.-name +#define DOTSYM (a) a#else
@@ -261,6 +271,8 @@ name: \ .type GLUE(.,name),@function; \ GLUE(.,name): +#define _KPROBE_TOC (n) _KPROBE(n) +#define DOTSYM (a) GLUE(.,a)#endif
arch/powerpc/kernel/misc_64.S +2 -2
@@ -65,7 +65,7 @@ PPC64_CACHES: * flush all bytes from start through stop-1 inclusive */ -_KPROBE(flush_icache_range) +_KPROBE_TOC(flush_icache_range) BEGIN_FTR_SECTION PURGE_PREFETCHED_INS blr
@@ -116,7 +116,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) * * flush all bytes from start to stop-1 inclusive */ -_GLOBAL(flush_dcache_range) +_GLOBAL_TOC(flush_dcache_range) /* * Flush the data cache to memory
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc: Fix VSX enabling/flushing to also test MSR_FP and MSR_VEC
In reply to Sasha LevinFrom: Benjamin Herrenschmidt <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5a69aec945d27e78abac9fd032533d3aaebf7c1e ]
VSX uses a combination of the old vector registers, the old FP registers and new "second halves" of the FP registers.
Thus when we need to see the VSX state in the thread struct (flush_vsx_to_thread()) or when we'll use the VSX in the kernel (enable_kernel_vsx()) we need to ensure they are all flushed into the thread struct if either of them is individually enabled.
Unfortunately we only tested if the whole VSX was enabled, not if they were individually enabled.
--- arch/powerpc/kernel/process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/kernel/process.c +3 -2
@@ -209,7 +209,8 @@ void enable_kernel_vsx(void)WARN_ON (preemptible ());#ifdef CONFIG_SMP -if (current->thread.regs && (current->thread.regs->msr &MSR_VSX )) +if (current->thread.regs && + (current->thread.regs->msr & (MSR_VSX |MSR_VEC |MSR_FP )))giveup_vsx (current);else giveup_vsx (NULL );/* just enable vsx for kernel - force */
@@ -231,7 +232,7 @@ void flush_vsx_to_thread(struct task_struct *tsk) {if (tsk->thread.regs) {preempt_disable (); -if (tsk->thread.regs->msr &MSR_VSX ) { +if (tsk->thread.regs->msr & (MSR_VSX |MSR_VEC |MSR_FP )) {#ifdef CONFIG_SMP BUG_ON (tsk != current);#endif
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/pseries: Add H_GET_CPU_CHARACTERISTICS flags & wrapper
In reply to Sasha LevinFrom: Michael Neuling <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 191eccb1580939fb0d47deb405b82a85b0379070 ]
A new hypervisor call has been defined to communicate various characteristics of the CPU to guests. Add definitions for the hcall number, flags and a wrapper function.
--- arch/powerpc/include/asm/hvcall.h | 17 +++++++++++++++++ arch/powerpc/include/asm/plpar_wrappers.h | 14 ++++++++++++++ 2 files changed, 31 insertions(+)
arch/powerpc/include/asm/hvcall.h +17 -0
@@ -239,6 +239,7 @@#define H_GET_HCA_INFO 0x1B8#define H_GET_PERF_COUNT 0x1BC#define H_MANAGE_TRACE 0x1C0 +#define H_GET_CPU_CHARACTERISTICS 0x1C8#define H_FREE_LOGICAL_LAN_BUFFER 0x1D4#define H_QUERY_INT_STATE 0x1E4#define H_POLL_PENDING 0x1D8
@@ -285,6 +286,17 @@#define H_SET_MODE_RESOURCE_ADDR_TRANS_MODE 3#define H_SET_MODE_RESOURCE_LE 4 +/* H_GET_CPU_CHARACTERISTICS return values */ +#define H_CPU_CHAR_SPEC_BAR_ORI31 (1ull << 63) // IBM bit 0 +#define H_CPU_CHAR_BCCTRL_SERIALISED (1ull << 62) // IBM bit 1 +#define H_CPU_CHAR_L1D_FLUSH_ORI30 (1ull << 61) // IBM bit 2 +#define H_CPU_CHAR_L1D_FLUSH_TRIG2 (1ull << 60) // IBM bit 3 +#define H_CPU_CHAR_L1D_THREAD_PRIV (1ull << 59) // IBM bit 4 + +#define H_CPU_BEHAV_FAVOUR_SECURITY (1ull << 63) // IBM bit 0 +#define H_CPU_BEHAV_L1D_FLUSH_PR (1ull << 62) // IBM bit 1 +#define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ull << 61) // IBM bit 2 +#ifndef __ASSEMBLY__/**
@@ -423,6 +435,11 @@ extern long pseries_big_endian_exceptions(void);#endif /* CONFIG_PPC_PSERIES */ +struct h_cpu_char_result { +u64 character; +u64 behaviour; +}; +#endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_HVCALL_H */
arch/powerpc/include/asm/plpar_wrappers.h +14 -0
@@ -323,4 +323,18 @@ static inline long plapr_set_watchpoint0(unsigned long dawr0, unsigned long dawr return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR, dawr0, dawrx0); } +static inline long plpar_get_cpu_characteristics (struct h_cpu_char_result *p) +{ +unsigned long retbuf[PLPAR_HCALL_BUFSIZE ]; +long rc; + + rc =plpar_hcall (H_GET_CPU_CHARACTERISTICS , retbuf); +if (rc ==H_SUCCESS ) { + p->character = retbuf[0 ]; + p->behaviour = retbuf[1 ]; + } + +return rc; +} +#endif /* _ASM_POWERPC_PLPAR_WRAPPERS_H */
Signature · 1 line
2.14.1
Michael Ellerman
reviewerRe: [added to the 4.1 stable tree] powerpc/pseries: Add H_GET_CPU_CHARACTERISTICS flags & wrapper
Quoted 4 lines · Sasha Levin
From: Michael Neuling <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
Hi Sasha,
I have done a back port of this series to 4.1, and there are a few differences between my version and yours.
Do you mind dropping these for now and I'll send you my version?
That would be this patch and up to and including:
powerpc/64s: Allow control of RFI flush via debugfs
cheers
Quoted 83 lines
===============
[ Upstream commit
191eccb1580939fb0d47deb405b82a85b0379070]A new hypervisor call has been defined to communicate various characteristics of the CPU to guests. Add definitions for the hcall number, flags and a wrapper function.
Signed-off-by Michael Neuling <[email protected]>Signed-off-by Michael Ellerman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- arch/powerpc/include/asm/hvcall.h | 17 +++++++++++++++++ arch/powerpc/include/asm/plpar_wrappers.h | 14 ++++++++++++++ 2 files changed, 31 insertions(+)arch/powerpc/include/asm/hvcall.h +17
-0@@ -239,6 +239,7 @@#define H_GET_HCA_INFO 0x1B8#define H_GET_PERF_COUNT 0x1BC#define H_MANAGE_TRACE 0x1C0 +#define H_GET_CPU_CHARACTERISTICS 0x1C8#define H_FREE_LOGICAL_LAN_BUFFER 0x1D4#define H_QUERY_INT_STATE 0x1E4#define H_POLL_PENDING 0x1D8@@ -285,6 +286,17 @@#define H_SET_MODE_RESOURCE_ADDR_TRANS_MODE 3#define H_SET_MODE_RESOURCE_LE 4 +/* H_GET_CPU_CHARACTERISTICS return values */ +#define H_CPU_CHAR_SPEC_BAR_ORI31 (1ull << 63) // IBM bit 0 +#define H_CPU_CHAR_BCCTRL_SERIALISED (1ull << 62) // IBM bit 1 +#define H_CPU_CHAR_L1D_FLUSH_ORI30 (1ull << 61) // IBM bit 2 +#define H_CPU_CHAR_L1D_FLUSH_TRIG2 (1ull << 60) // IBM bit 3 +#define H_CPU_CHAR_L1D_THREAD_PRIV (1ull << 59) // IBM bit 4 + +#define H_CPU_BEHAV_FAVOUR_SECURITY (1ull << 63) // IBM bit 0 +#define H_CPU_BEHAV_L1D_FLUSH_PR (1ull << 62) // IBM bit 1 +#define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ull << 61) // IBM bit 2 +#ifndef __ASSEMBLY__/** @@ -423,6 +435,11 @@ extern long pseries_big_endian_exceptions(void);#endif /* CONFIG_PPC_PSERIES */ +struct h_cpu_char_result { +u64 character; +u64 behaviour; +}; +#endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_HVCALL_H */ arch/powerpc/include/asm/plpar_wrappers.h +14
-0@@ -323,4 +323,18 @@ static inline long plapr_set_watchpoint0(unsigned long dawr0, unsigned long dawr return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR, dawr0, dawrx0); } +static inline long plpar_get_cpu_characteristics (struct h_cpu_char_result *p) +{ +unsigned long retbuf[PLPAR_HCALL_BUFSIZE ]; +long rc; + + rc =plpar_hcall (H_GET_CPU_CHARACTERISTICS , retbuf); +if (rc ==H_SUCCESS ) { + p->character = retbuf[0 ]; + p->behaviour = retbuf[1 ]; + } + +return rc; +} +#endif /* _ASM_POWERPC_PLPAR_WRAPPERS_H */ Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc: Simplify module TOC handling
In reply to Sasha LevinFrom: Alan Modra <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9 ]
PowerPC64 uses the symbol .TOC. much as other targets use _GLOBAL_OFFSET_TABLE_. It identifies the value of the GOT pointer (or in powerpc parlance, the TOC pointer). Global offset tables are generally local to an executable or shared library, or in the kernel, module. Thus it does not make sense for a module to resolve a relocation against .TOC. to the kernel's .TOC. value. A module has its own .TOC., and indeed the powerpc64 module relocation processing ignores the kernel value of .TOC. and instead calculates a module-local value.
This patch removes code involved in exporting the kernel .TOC., tweaks modpost to ignore an undefined .TOC., and the module loader to twiddle the section symbol so that .TOC. isn't seen as undefined.
Note that if the kernel was compiled with -msingle-pic-base then ELFv2 would not have function global entry code setting up r2. In that case the module call stubs would need to be modified to set up r2 using the kernel .TOC. value, requiring some of this code to be reinstated.
mpe: Furthermore a change in binutils master (not yet released) causes the current way we handle the TOC to no longer work when building with MODVERSIONS=y and RELOCATABLE=n. The symptom is that modules can not be loaded due to there being no version found for TOC.
--- arch/powerpc/kernel/misc_64.S | 28 ---------------------------- arch/powerpc/kernel/module_64.c | 12 +++++++++--- scripts/mod/modpost.c | 3 ++- 3 files changed, 11 insertions(+), 32 deletions(-)
arch/powerpc/kernel/misc_64.S +0 -28
@@ -634,31 +634,3 @@ _GLOBAL(kexec_sequence) li r5,0 blr /* image->start(physid, image->start, 0); */ #endif /* CONFIG_KEXEC */ - -#ifdef CONFIG_MODULES -#if defined(_CALL_ELF) && _CALL_ELF == 2 - -#ifdef CONFIG_MODVERSIONS -.weak __crc_TOC. -.section "___kcrctab+TOC.","a" -.globl __kcrctab_TOC. -__kcrctab_TOC.: - .llong __crc_TOC. -#endif - -/* - * Export a fake .TOC. since both modpost and depmod will complain otherwise. - * Both modpost and depmod strip the leading . so we do the same here. - */ -.section "__ksymtab_strings","a" -__kstrtab_TOC.: - .asciz "TOC." - -.section "___ksymtab+TOC.","a" -/* This symbol name is important: it's used by modpost to find exported syms */ -.globl __ksymtab_TOC. -__ksymtab_TOC.: - .llong 0 /* .value */ - .llong __kstrtab_TOC. -#endif /* ELFv2 */ -#endif /* MODULES */
arch/powerpc/kernel/module_64.c +9 -3
@@ -326,7 +326,10 @@ static void dedotify_versions(struct modversion_info *vers, } } -/* Undefined symbols which refer to .funcname, hack to funcname (or .TOC.) */ +/* +* Undefined symbols which refer to .funcname, hack to funcname. Make .TOC. +* seem to be defined (value set later). +*/ static void dedotify (Elf64_Sym *syms,unsigned int numsyms,char *strtab) {unsigned int i;
@@ -334,8 +337,11 @@ static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab)for (i =1 ; i < numsyms; i++) {if (syms[i].st_shndx ==SHN_UNDEF ) {char *name = strtab + syms[i].st_name; -if (name[0 ] =='.' ) +if (name[0 ] =='.' ) { +if (strcmp (name+1 ,"TOC." ) ==0 ) + syms[i].st_shndx =SHN_ABS ; syms[i].st_name++; + } } } }
@@ -351,7 +357,7 @@ static Elf64_Sym *find_dot_toc(Elf64_Shdr *sechdrs, numsyms = sechdrs[symindex].sh_size /sizeof (Elf64_Sym);for (i =1 ; i < numsyms; i++) { -if (syms[i].st_shndx ==SHN_UNDEF +if (syms[i].st_shndx ==SHN_ABS &&strcmp (strtab + syms[i].st_name,"TOC." ) ==0 )return &syms[i]; }
scripts/mod/modpost.c +2 -1
@@ -593,7 +593,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)if (strncmp (symname,"_restgpr0_" ,sizeof ("_restgpr0_" ) -1 ) ==0 ||strncmp (symname,"_savegpr0_" ,sizeof ("_savegpr0_" ) -1 ) ==0 ||strncmp (symname,"_restvr_" ,sizeof ("_restvr_" ) -1 ) ==0 || -strncmp (symname,"_savevr_" ,sizeof ("_savevr_" ) -1 ) ==0 ) +strncmp (symname,"_savevr_" ,sizeof ("_savevr_" ) -1 ) ==0 || +strcmp (symname,".TOC." ) ==0 )return 1 ;/* Do not ignore this symbol */ return 0 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64: Add macros for annotating the destination of rfid/hrfid
In reply to Sasha LevinFrom: Nicholas Piggin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 50e51c13b3822d14ff6df4279423e4b7b2269bc3 ]
The rfid/hrfid ((Hypervisor) Return From Interrupt) instruction is used for switching from the kernel to userspace, and from the hypervisor to the guest kernel. However it can and is also used for other transitions, eg. from real mode kernel code to virtual mode kernel code, and it's not always clear from the code what the destination context is.
To make it clearer when reading the code, add macros which encode the expected destination context.
--- arch/powerpc/include/asm/exception-64e.h | 6 ++++++ arch/powerpc/include/asm/exception-64s.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+)
arch/powerpc/include/asm/exception-64e.h +6 -0
@@ -208,5 +208,11 @@ exc_##label##_book3e: ori r3,r3,interrupt_base_book3e@l; \ mtspr SPRN_IVOR##vector_number,r3; +#define RFI_TO_KERNEL \ + rfi + +#define RFI_TO_USER \ + rfi +#endif /* _ASM_POWERPC_EXCEPTION_64E_H */
arch/powerpc/include/asm/exception-64s.h +29 -0
@@ -50,6 +50,35 @@#define EX_PPR 88/* SMT thread status register (priority) */ #define EX_CTR 96 +/* Macros for annotating the expected destination of (h)rfid */ + +#define RFI_TO_KERNEL \ + rfid + +#define RFI_TO_USER \ + rfid + +#define RFI_TO_USER_OR_KERNEL \ + rfid + +#define RFI_TO_GUEST \ + rfid + +#define HRFI_TO_KERNEL \ + hrfid + +#define HRFI_TO_USER \ + hrfid + +#define HRFI_TO_USER_OR_KERNEL \ + hrfid + +#define HRFI_TO_GUEST \ + hrfid + +#define HRFI_TO_UNKNOWN \ + hrfid +#ifdef CONFIG_RELOCATABLE #define __EXCEPTION_RELON_PROLOG_PSERIES_1 (label, h) \ ld r12,PACAKBASE(r13);/* get high part of &label */ \
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64: Convert fast_exception_return to use RFI_TO_USER/KERNEL
In reply to Sasha LevinFrom: Nicholas Piggin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a08f828cf47e6c605af21d2cdec68f84e799c318 ]
Similar to the syscall return path, in fast_exception_return we may be returning to user or kernel context. We already have a test for that, because we conditionally restore r13. So use that existing test and branch, and bifurcate the return based on that.
--- arch/powerpc/kernel/entry_64.S | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
arch/powerpc/kernel/entry_64.S +16 -2
@@ -840,7 +840,7 @@ BEGIN_FTR_SECTION END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) ACCOUNT_CPU_USER_EXIT(r2, r4) REST_GPR(13, r1) -1: + mtspr SPRN_SRR1,r3 ld r2,_CCR(r1)
@@ -853,8 +853,22 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) ld r3,GPR3(r1) ld r4,GPR4(r1) ld r1,GPR1(r1) + RFI_TO_USER + b . /* prevent speculative execution */ - rfid +1: mtspr SPRN_SRR1,r3 + + ld r2,_CCR(r1) + mtcrf 0xFF,r2 + ld r2,_NIP(r1) + mtspr SPRN_SRR0,r2 + + ld r0,GPR0(r1) + ld r2,GPR2(r1) + ld r3,GPR3(r1) + ld r4,GPR4(r1) + ld r1,GPR1(r1) + RFI_TO_KERNEL b . /* prevent speculative execution */ #endif /* CONFIG_PPC_BOOK3E */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64: Convert the syscall exit path to use RFI_TO_USER/KERNEL
In reply to Sasha LevinFrom: Nicholas Piggin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b8e90cb7bc04a509e821e82ab6ed7a8ef11ba333 ]
In the syscall exit path we may be returning to user or kernel context. We already have a test for that, because we conditionally restore r13. So use that existing test and branch, and bifurcate the return based on that.
--- arch/powerpc/kernel/entry_64.S | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/kernel/entry_64.S +11 -1
@@ -218,13 +218,23 @@ END_FTR_SECTION_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ACCOUNT_CPU_USER_EXIT(r11, r12) HMT_MEDIUM_LOW_HAS_PPR ld r13,GPR13(r1) /* only restore r13 if returning to usermode */ + ld r2,GPR2(r1) + ld r1,GPR1(r1) + mtlr r4 + mtcr r5 + mtspr SPRN_SRR0,r7 + mtspr SPRN_SRR1,r8 + RFI_TO_USER + b . /* prevent speculative execution */ + + /* exit to kernel */ 1: ld r2,GPR2(r1) ld r1,GPR1(r1) mtlr r4 mtcr r5 mtspr SPRN_SRR0,r7 mtspr SPRN_SRR1,r8 - RFI + RFI_TO_KERNEL b . /* prevent speculative execution */ syscall_error:
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64s: Convert slb_miss_common to use RFI_TO_USER/KERNEL
In reply to Sasha LevinFrom: Nicholas Piggin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c7305645eb0c1621351cfc104038831ae87c0053 ]
In the SLB miss handler we may be returning to user or kernel. We need to add a check early on and save the result in the cr4 register, and then we bifurcate the return path based on that.
--- arch/powerpc/kernel/exceptions-64s.S | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
arch/powerpc/kernel/exceptions-64s.S +20 -2
@@ -1511,6 +1511,8 @@ slb_miss_realmode: andi. r10,r12,MSR_RI /* check for unrecoverable exception */ beq- 2f + andi. r10,r12,MSR_PR /* check for user mode (PR != 0) */ + bne 1f .machine push .machine "power4"
@@ -1524,7 +1526,23 @@ slb_miss_realmode: ld r11,PACA_EXSLB+EX_R11(r13) ld r12,PACA_EXSLB+EX_R12(r13) ld r13,PACA_EXSLB+EX_R13(r13) - rfid + RFI_TO_KERNEL + b . /* prevent speculative execution */ + +1: +.machine push +.machine "power4" + mtcrf 0x80,r9 + mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */ +.machine pop + + RESTORE_PPR_PACA(PACA_EXSLB, r9) + ld r9,PACA_EXSLB+EX_R9(r13) + ld r10,PACA_EXSLB+EX_R10(r13) + ld r11,PACA_EXSLB+EX_R11(r13) + ld r12,PACA_EXSLB+EX_R12(r13) + ld r13,PACA_EXSLB+EX_R13(r13) + RFI_TO_USER b . /* prevent speculative execution */ 2: mfspr r11,SPRN_SRR0
@@ -1533,7 +1551,7 @@ slb_miss_realmode: mtspr SPRN_SRR0,r10 ld r10,PACAKMSR(r13) mtspr SPRN_SRR1,r10 - rfid + RFI_TO_KERNEL b . unrecov_slb:
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64s: Add support for RFI flush of L1-D cache
In reply to Sasha LevinFrom: Michael Ellerman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit aa8a5e0062ac940f7659394f4817c948dc8c0667 ]
On some CPUs we can prevent the Meltdown vulnerability by flushing the L1-D cache on exit from kernel to user mode, and from hypervisor to guest.
This is known to be the case on at least Power7, Power8 and Power9. At this time we do not know the status of the vulnerability on other CPUs such as the 970 (Apple G5), pasemi CPUs (AmigaOne X1000) or Freescale CPUs. As more information comes to light we can enable this, or other mechanisms on those CPUs.
The vulnerability occurs when the load of an architecturally inaccessible memory region (eg. userspace load of kernel memory) is speculatively executed to the point where its result can influence the address of a subsequent speculatively executed load.
In order for that to happen, the first load must hit in the L1, because before the load is sent to the L2 the permission check is performed. Therefore if no kernel addresses hit in the L1 the vulnerability can not occur. We can ensure that is the case by flushing the L1 whenever we return to userspace. Similarly for hypervisor vs guest.
In order to flush the L1-D cache on exit, we add a section of nops at each (h)rfi location that returns to a lower privileged context, and patch that with some sequence. Newer firmwares are able to advertise to us that there is a special nop instruction that flushes the L1-D. If we do not see that advertised, we fall back to doing a displacement flush in software.
For guest kernels we support migration between some CPU versions, and different CPUs may use different flush instructions. So that we are prepared to migrate to a machine with a different flush instruction activated, we may have to patch more than one flush instruction at boot if the hypervisor tells us to.
In the end this patch is mostly the work of Nicholas Piggin and Michael Ellerman. However a cast of thousands contributed to analysis of the issue, earlier versions of the patch, back ports testing etc. Many thanks to all of them.
--- arch/powerpc/include/asm/exception-64s.h | 40 +++++++++++--- arch/powerpc/include/asm/feature-fixups.h | 15 ++++++ arch/powerpc/include/asm/paca.h | 10 ++++ arch/powerpc/include/asm/setup.h | 13 +++++ arch/powerpc/kernel/asm-offsets.c | 4 ++ arch/powerpc/kernel/exceptions-64s.S | 86 +++++++++++++++++++++++++++++++ arch/powerpc/kernel/setup_64.c | 79 ++++++++++++++++++++++++++++ arch/powerpc/kernel/vmlinux.lds.S | 9 ++++ arch/powerpc/lib/feature-fixups.c | 42 +++++++++++++++ 9 files changed, 290 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/exception-64s.h +32 -8
@@ -50,34 +50,58 @@#define EX_PPR 88/* SMT thread status register (priority) */ #define EX_CTR 96 -/* Macros for annotating the expected destination of (h)rfid */ +/* +* Macros for annotating the expected destination of (h)rfid +* +* The nop instructions allow us to insert one or more instructions to flush the +* L1-D cache when returning to userspace or a guest. +*/ +#define RFI_FLUSH_SLOT \ + RFI_FLUSH_FIXUP_SECTION; \ + nop; \ + nop; \ + nop#define RFI_TO_KERNEL \ rfid#define RFI_TO_USER \ - rfid + RFI_FLUSH_SLOT; \ + rfid; \ + b rfi_flush_fallback#define RFI_TO_USER_OR_KERNEL \ - rfid + RFI_FLUSH_SLOT; \ + rfid; \ + b rfi_flush_fallback#define RFI_TO_GUEST \ - rfid + RFI_FLUSH_SLOT; \ + rfid; \ + b rfi_flush_fallback#define HRFI_TO_KERNEL \ hrfid#define HRFI_TO_USER \ - hrfid + RFI_FLUSH_SLOT; \ + hrfid; \ + b hrfi_flush_fallback#define HRFI_TO_USER_OR_KERNEL \ - hrfid + RFI_FLUSH_SLOT; \ + hrfid; \ + b hrfi_flush_fallback#define HRFI_TO_GUEST \ - hrfid + RFI_FLUSH_SLOT; \ + hrfid; \ + b hrfi_flush_fallback#define HRFI_TO_UNKNOWN \ - hrfid + RFI_FLUSH_SLOT; \ + hrfid; \ + b hrfi_flush_fallback#ifdef CONFIG_RELOCATABLE #define __EXCEPTION_RELON_PROLOG_PSERIES_1 (label, h) \
arch/powerpc/include/asm/feature-fixups.h +15 -0
@@ -184,4 +184,19 @@ label##3: \ FTR_ENTRY_OFFSET label##1b-label##3b; \ .popsection; +#define RFI_FLUSH_FIXUP_SECTION \ +951: \ + .pushsection __rfi_flush_fixup,"a"; \ + .align 2; \ +952: \ + FTR_ENTRY_OFFSET 951b-952b; \ + .popsection; + + +#ifndef __ASSEMBLY__ + +extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup; + +#endif +#endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */
arch/powerpc/include/asm/paca.h +10 -0
@@ -192,6 +192,16 @@ struct paca_struct {#endif struct kvmppc_host_state kvm_hstate;#endif +#ifdef CONFIG_PPC_BOOK3S_64 +/* +* rfi fallback flush must be in its own cacheline to prevent +* other paca data leaking into the L1d +*/ +u64 exrfi[13 ]__aligned(0x80) ; +void *rfi_flush_fallback_area; +u64 l1d_flush_congruence; +u64 l1d_flush_sets; +#endif };extern struct paca_struct *paca;
arch/powerpc/include/asm/setup.h +13 -0
@@ -26,6 +26,19 @@ void initmem_init(void);void setup_panic (void );#define ARCH_PANIC_TIMEOUT 180 +void rfi_flush_enable (bool enable); + +/* These are bit flags */ +enum l1d_flush_type { +L1D_FLUSH_NONE =0x1 , +L1D_FLUSH_FALLBACK =0x2 , +L1D_FLUSH_ORI =0x4 , +L1D_FLUSH_MTTRIG =0x8 , +}; + +void __init setup_rfi_flush (enum l1d_flush_type ,bool enable); +void do_rfi_flush_fixups (enum l1d_flush_type types); +#endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_SETUP_H */
arch/powerpc/kernel/asm-offsets.c +4 -0
@@ -244,6 +244,10 @@ int main(void)#ifdef CONFIG_PPC_BOOK3S_64 DEFINE (PACAMCEMERGSP , offsetof(struct paca_struct , mc_emergency_sp));DEFINE (PACA_IN_MCE , offsetof(struct paca_struct , in_mce)); +DEFINE (PACA_RFI_FLUSH_FALLBACK_AREA , offsetof(struct paca_struct , rfi_flush_fallback_area)); +DEFINE (PACA_EXRFI , offsetof(struct paca_struct , exrfi)); +DEFINE (PACA_L1D_FLUSH_CONGRUENCE , offsetof(struct paca_struct , l1d_flush_congruence)); +DEFINE (PACA_L1D_FLUSH_SETS , offsetof(struct paca_struct , l1d_flush_sets));#endif DEFINE (PACAHWCPUID , offsetof(struct paca_struct , hw_cpu_id));DEFINE (PACAKEXECSTATE , offsetof(struct paca_struct , kexec_state));
arch/powerpc/kernel/exceptions-64s.S +86 -0
92 lines not on this page · raw message
arch/powerpc/kernel/setup_64.c +79 -0
83 lines not on this page · raw message
arch/powerpc/kernel/vmlinux.lds.S +9 -0
@@ -72,6 +72,15 @@ SECTIONS /* Read-only data */ RODATA +#ifdef CONFIG_PPC64 + . = ALIGN(8); + __rfi_flush_fixup : AT(ADDR(__rfi_flush_fixup) - LOAD_OFFSET) { + __start___rfi_flush_fixup = .; + *(__rfi_flush_fixup) + __stop___rfi_flush_fixup = .; + } +#endif + EXCEPTION_TABLE(0) NOTES :kernel :notes
arch/powerpc/lib/feature-fixups.c +42 -0
54 lines not on this page · raw message
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64s: Support disabling RFI flush with no_rfi_flush and nopti
In reply to Sasha LevinFrom: Michael Ellerman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bc9c9304a45480797e13a8e1df96ffcf44fb62fe ]
Because there may be some performance overhead of the RFI flush, add kernel command line options to disable it.
We add a sensibly named 'no_rfi_flush' option, but we also hijack the x86 option 'nopti'. The RFI flush is not the same as KPTI, but if we see 'nopti' we can guess that the user is trying to avoid any overhead of Meltdown mitigations, and it means we don't have to educate every one about a different command line option.
--- arch/powerpc/kernel/setup_64.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
arch/powerpc/kernel/setup_64.c +23 -1
@@ -811,8 +811,29 @@ early_initcall(disable_hardlockup_detector);#ifdef CONFIG_PPC_BOOK3S_64 static enum l1d_flush_type enabled_flush_types;static void *l1d_flush_fallback_area; +static bool no_rfi_flush;bool rfi_flush; +static int __init handle_no_rfi_flush (char *p) +{ +pr_info ("rfi-flush: disabled on command line." ); + no_rfi_flush = true; +return 0 ; +} +early_param ("no_rfi_flush" , handle_no_rfi_flush); + +/* +* The RFI flush is not KPTI, but because users will see doco that says to use +* nopti we hijack that option here to also disable the RFI flush. +*/ +static int __init handle_no_pti (char *p) +{ +pr_info ("rfi-flush: disabling due to 'nopti' on command line.\n" ); +handle_no_rfi_flush (NULL ); +return 0 ; +} +early_param ("nopti" , handle_no_pti); +static void do_nothing (void *unused) {/*
@@ -883,7 +904,8 @@ void __init setup_rfi_flush(enum l1d_flush_type types, bool enable) enabled_flush_types = types; -rfi_flush_enable (enable); +if (!no_rfi_flush) +rfi_flush_enable (enable); }#endif /* CONFIG_PPC_BOOK3S_64 */ #endif
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/pseries: Query hypervisor for RFI flush settings
In reply to Sasha LevinFrom: Michael Neuling <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8989d56878a7735dfdb234707a2fee6faf631085 ]
A new hypervisor call is available which tells the guest settings related to the RFI flush. Use it to query the appropriate flush instruction(s), and whether the flush is required.
--- arch/powerpc/platforms/pseries/setup.c | 37 +++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/setup.c +36 -1
@@ -507,6 +507,39 @@ static void __init find_and_init_phbs(void) } } +static void pseries_setup_rfi_flush (void ) +{ +struct h_cpu_char_result result; +enum l1d_flush_type types; +bool enable; +long rc; + +/* Enable by default */ + enable = true; + + rc =plpar_get_cpu_characteristics (&result); +if (rc ==H_SUCCESS ) { + types =L1D_FLUSH_NONE ; + +if (result.character &H_CPU_CHAR_L1D_FLUSH_TRIG2 ) + types |=L1D_FLUSH_MTTRIG ; +if (result.character &H_CPU_CHAR_L1D_FLUSH_ORI30 ) + types |=L1D_FLUSH_ORI ; + +/* Use fallback if nothing set in hcall */ +if (types ==L1D_FLUSH_NONE ) + types =L1D_FLUSH_FALLBACK ; + +if (!(result.behaviour &H_CPU_BEHAV_L1D_FLUSH_PR )) + enable = false; + }else { +/* Default to fallback if case hcall is not available */ + types =L1D_FLUSH_FALLBACK ; + } + +setup_rfi_flush (types, enable); +} +static void __init pSeries_setup_arch (void ) {set_arch_panic_timeout (10 ,ARCH_PANIC_TIMEOUT );
@@ -523,7 +556,9 @@ static void __init pSeries_setup_arch(void)fwnmi_init (); -/* By default, only probe PCI (can be overriden by rtas_pci) */ +pseries_setup_rfi_flush (); + +/* By default, only probe PCI (can be overridden by rtas_pci) */ pci_add_flags (PCI_PROBE_ONLY );/* Find and initialize PCI host bridges */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64s: Wire up cpu_show_meltdown()
In reply to Sasha LevinFrom: Michael Ellerman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fd6e440f20b1a4304553775fc55938848ff617c9 ]
The recent commit 87590ce6e373 ("sysfs/cpu: Add vulnerability folder") added a generic folder and set of files for reporting information on CPU vulnerabilities. One of those was for meltdown:
/sys/devices/system/cpu/vulnerabilities/meltdown
This commit wires up that file for 64-bit Book3S powerpc.
For now we default to "Vulnerable" unless the RFI flush is enabled. That may not actually be true on all hardware, further patches will refine the reporting based on the CPU/platform etc. But for now we default to being pessimists.
--- arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/setup_64.c | 8 ++++++++ 2 files changed, 9 insertions(+)
arch/powerpc/Kconfig +1 -0
@@ -133,6 +133,7 @@ config PPC select GENERIC_SMP_IDLE_THREAD select GENERIC_CMOS_UPDATE select GENERIC_TIME_VSYSCALL_OLD + select GENERIC_CPU_VULNERABILITIES if PPC_BOOK3S_64 select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS_BROADCAST if SMP select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
arch/powerpc/kernel/setup_64.c +8 -0
@@ -907,5 +907,13 @@ void __init setup_rfi_flush(enum l1d_flush_type types, bool enable)if (!no_rfi_flush)rfi_flush_enable (enable); } + +ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) +{ +if (rfi_flush) +return sprintf (buf,"Mitigation: RFI Flush\n" ); + +return sprintf (buf,"Vulnerable\n" ); +}#endif /* CONFIG_PPC_BOOK3S_64 */ #endif
Signature · 1 line
2.14.1
Michael Ellerman
reviewerRe: [added to the 4.1 stable tree] powerpc/64s: Wire up cpu_show_meltdown()
Quoted 4 lines · Sasha Levin
From: Michael Ellerman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
This commit back ports cleanly to v4.1 but doesn't actually work because the generic support it depends on has not been back ported AFAICS.
We need at least this commit in v4.1:
87590ce6e373 ("sysfs/cpu: Add vulnerability folder")
cheers
Quoted 56 lines
===============
[ Upstream commit
fd6e440f20b1a4304553775fc55938848ff617c9]The recent commit
87590ce6e373("sysfs/cpu: Add vulnerability folder") added a generic folder and set of files for reporting information on CPU vulnerabilities. One of those was for meltdown:
/sys/devices/system/cpu/vulnerabilities/meltdownThis commit wires up that file for 64-bit Book3S powerpc.
For now we default to "Vulnerable" unless the RFI flush is enabled. That may not actually be true on all hardware, further patches will refine the reporting based on the CPU/platform etc. But for now we default to being pessimists.
Signed-off-by Michael Ellerman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/setup_64.c | 8 ++++++++ 2 files changed, 9 insertions(+)arch/powerpc/Kconfig +1
-0@@ -133,6 +133,7 @@ config PPC select GENERIC_SMP_IDLE_THREAD select GENERIC_CMOS_UPDATE select GENERIC_TIME_VSYSCALL_OLD + select GENERIC_CPU_VULNERABILITIES if PPC_BOOK3S_64 select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS_BROADCAST if SMP select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCASTarch/powerpc/kernel/setup_64.c +8
-0@@ -907,5 +907,13 @@ void __init setup_rfi_flush(enum l1d_flush_type types, bool enable)if (!no_rfi_flush)rfi_flush_enable (enable); } + +ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) +{ +if (rfi_flush) +return sprintf (buf,"Mitigation: RFI Flush\n" ); + +return sprintf (buf,"Vulnerable\n" ); +}#endif /* CONFIG_PPC_BOOK3S_64 */ #endif Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/64s: Allow control of RFI flush via debugfs
In reply to Sasha LevinFrom: Michael Ellerman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 236003e6b5443c45c18e613d2b0d776a9f87540e ]
Expose the state of the RFI flush (enabled/disabled) via debugfs, and allow it to be enabled/disabled at runtime.
eg: $ cat /sys/kernel/debug/powerpc/rfi_flush
1
$ echo 0 > /sys/kernel/debug/powerpc/rfi_flush $ cat /sys/kernel/debug/powerpc/rfi_flush 0
--- arch/powerpc/kernel/setup_64.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
arch/powerpc/kernel/setup_64.c +30 -0
@@ -38,6 +38,7 @@#include <linux/hugetlb.h> #include <linux/memory.h> #include <linux/nmi.h> +#include <linux/debugfs.h> #include <asm/io.h> #include <asm/kdump.h>
@@ -908,6 +909,35 @@ void __init setup_rfi_flush(enum l1d_flush_type types, bool enable)rfi_flush_enable (enable); } +#ifdef CONFIG_DEBUG_FS +static int rfi_flush_set (void *data,u64 val) +{ +if (val ==1 ) +rfi_flush_enable (true); +else if (val ==0 ) +rfi_flush_enable (false); +else +return -EINVAL ; + +return 0 ; +} + +static int rfi_flush_get (void *data,u64 *val) +{ + *val = rfi_flush ?1 :0 ; +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (fops_rfi_flush, rfi_flush_get, rfi_flush_set,"%llu\n" ); + +static __init int rfi_flush_debugfs_init (void ) +{ +debugfs_create_file ("rfi_flush" ,0600 , powerpc_debugfs_root,NULL , &fops_rfi_flush); +return 0 ; +} +device_initcall (rfi_flush_debugfs_init); +#endif +ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) {if (rfi_flush)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ASoC: pcm512x: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
In reply to Sasha LevinFrom: Jesse Chan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0cab20cec0b663b7be8e2be5998d5a4113647f86 ]
This change resolves a new compile-time warning
when built as a loadable module:
WARNING: modpost: missing MODULE_LICENSE() in sound/soc/codecs/snd-soc-pcm512x-spi.o see include/linux/module.h for more information
This adds the license as "GPL v2", which matches the header of the file.
MODULE_DESCRIPTION and MODULE_AUTHOR are also added.
--- sound/soc/codecs/pcm512x-spi.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/codecs/pcm512x-spi.c +4 -0
@@ -71,3 +71,7 @@ static struct spi_driver pcm512x_spi_driver = { };module_spi_driver (pcm512x_spi_driver); + +MODULE_DESCRIPTION ("ASoC PCM512x codec driver - SPI" ); +MODULE_AUTHOR ("Mark Brown <[email protected]>" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] drm: rcar-du: Use the VBK interrupt for vblank events
In reply to Sasha LevinFrom: Laurent Pinchart <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cbbb90b0c084d7dfb2ed8e3fecf8df200fbdd2a0 ]
When implementing support for interlaced modes, the driver switched from reporting vblank events on the vertical blanking (VBK) interrupt to the frame end interrupt (FRM). This incorrectly divided the reported refresh rate by two. Fix it by moving back to the VBK interrupt.
--- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/rcar-du/rcar_du_crtc.c +1 -1
@@ -511,7 +511,7 @@ static irqreturn_t rcar_du_crtc_irq(int irq, void *arg) status =rcar_du_crtc_read (rcrtc,DSSR );rcar_du_crtc_write (rcrtc,DSRCR , status &DSRCR_MASK ); -if (status &DSSR_FRM ) { +if (status &DSSR_VBK ) {drm_handle_vblank (rcrtc->crtc.dev, rcrtc->index);rcar_du_crtc_finish_page_flip (rcrtc); ret =IRQ_HANDLED ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ip6mr: fix stale iterator
In reply to Sasha LevinFrom: Nikolay Aleksandrov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4adfa79fc254efb7b0eb3cd58f62c2c3f805f1ba ]
When we dump the ip6mr mfc entries via proc, we initialize an iterator with the table to dump but we don't clear the cache pointer which might be initialized from a prior read on the same descriptor that ended. This can result in lock imbalance (an unnecessary unlock) leading to other crashes and hangs. Clear the cache pointer like ipmr does to fix the issue. Thanks for the reliable reproducer.
Here's syzbot's trace:
WARNING: bad unlock balance detected!
4.15.0-rc3+ #128 Not tainted
syzkaller971460/3195 is trying to release lock (mrt_lock) at:
[<000000006898068d>] ipmr_mfc_seq_stop+0xe1/0x130 net/ipv6/ip6mr.c:553 but there are no more locks to release!
other info that might help us debug this:
1 lock held by syzkaller971460/3195:
#0: (&p->lock){+.+.}, at: [<00000000744a6565>] seq_read+0xd5/0x13d0
fs/seq_file.c:165
stack backtrace: CPU: 1 PID: 3195 Comm: syzkaller971460 Not tainted 4.15.0-rc3+ #128 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x257 lib/dump_stack.c:53 print_unlock_imbalance_bug+0x12f/0x140 kernel/locking/lockdep.c:3561 __lock_release kernel/locking/lockdep.c:3775 [inline] lock_release+0x5f9/0xda0 kernel/locking/lockdep.c:4023 __raw_read_unlock include/linux/rwlock_api_smp.h:225 [inline] _raw_read_unlock+0x1a/0x30 kernel/locking/spinlock.c:255 ipmr_mfc_seq_stop+0xe1/0x130 net/ipv6/ip6mr.c:553 traverse+0x3bc/0xa00 fs/seq_file.c:135 seq_read+0x96a/0x13d0 fs/seq_file.c:189 proc_reg_read+0xef/0x170 fs/proc/inode.c:217 do_loop_readv_writev fs/read_write.c:673 [inline] do_iter_read+0x3db/0x5b0 fs/read_write.c:897 compat_readv+0x1bf/0x270 fs/read_write.c:1140 do_compat_preadv64+0xdc/0x100 fs/read_write.c:1189 C_SYSC_preadv fs/read_write.c:1209 [inline] compat_SyS_preadv+0x3b/0x50 fs/read_write.c:1203 do_syscall_32_irqs_on arch/x86/entry/common.c:327 [inline] do_fast_syscall_32+0x3ee/0xf9d arch/x86/entry/common.c:389 entry_SYSENTER_compat+0x51/0x60 arch/x86/entry/entry_64_compat.S:125 RIP: 0023:0xf7f73c79 RSP: 002b:00000000e574a15c EFLAGS: 00000292 ORIG_RAX: 000000000000014d RAX: ffffffffffffffda RBX: 000000000000000f RCX: 0000000020a3afb0 RDX: 0000000000000001 RSI: 0000000000000067 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 BUG: sleeping function called from invalid context at lib/usercopy.c:25 in_atomic(): 1, irqs_disabled(): 0, pid: 3195, name: syzkaller971460 INFO: lockdep is turned off. CPU: 1 PID: 3195 Comm: syzkaller971460 Not tainted 4.15.0-rc3+ #128 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x257 lib/dump_stack.c:53 ___might_sleep+0x2b2/0x470 kernel/sched/core.c:6060 __might_sleep+0x95/0x190 kernel/sched/core.c:6013 __might_fault+0xab/0x1d0 mm/memory.c:4525 _copy_to_user+0x2c/0xc0 lib/usercopy.c:25 copy_to_user include/linux/uaccess.h:155 [inline] seq_read+0xcb4/0x13d0 fs/seq_file.c:279 proc_reg_read+0xef/0x170 fs/proc/inode.c:217 do_loop_readv_writev fs/read_write.c:673 [inline] do_iter_read+0x3db/0x5b0 fs/read_write.c:897 compat_readv+0x1bf/0x270 fs/read_write.c:1140 do_compat_preadv64+0xdc/0x100 fs/read_write.c:1189 C_SYSC_preadv fs/read_write.c:1209 [inline] compat_SyS_preadv+0x3b/0x50 fs/read_write.c:1203 do_syscall_32_irqs_on arch/x86/entry/common.c:327 [inline] do_fast_syscall_32+0x3ee/0xf9d arch/x86/entry/common.c:389 entry_SYSENTER_compat+0x51/0x60 arch/x86/entry/entry_64_compat.S:125 RIP: 0023:0xf7f73c79 RSP: 002b:00000000e574a15c EFLAGS: 00000292 ORIG_RAX: 000000000000014d RAX: ffffffffffffffda RBX: 000000000000000f RCX: 0000000020a3afb0 RDX: 0000000000000001 RSI: 0000000000000067 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 WARNING: CPU: 1 PID: 3195 at lib/usercopy.c:26 _copy_to_user+0xb5/0xc0 lib/usercopy.c:26
--- net/ipv6/ip6mr.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/ip6mr.c +1 -0
@@ -496,6 +496,7 @@ static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos)return ERR_PTR (-ENOENT ); it->mrt = mrt; + it->cache =NULL ;return *pos ?ipmr_mfc_seq_idx (net, seq->private, *pos -1 ) :SEQ_START_TOKEN ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: igmp: add a missing rcu locking section
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e7aadb27a5415e8125834b84a74477bfbee4eff5 ]
Newly added igmpv3_get_srcaddr() needs to be called under rcu lock.
Timer callbacks do not ensure this locking.
=============================
WARNING: suspicious RCU usage
4.15.0+ #200 Not tainted
-----------------------------./include/linux/inetdevice.h:216 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
3 locks held by syzkaller616973/4074:
#0: (&mm->mmap_sem){++++}, at: [<00000000bfce669e>] __do_page_fault+0x32d/0xc90 arch/x86/mm/fault.c:1355
#1: ((&im->timer)){+.-.}, at: [<00000000619d2f71>] lockdep_copy_map include/linux/lockdep.h:178 [inline]
#1: ((&im->timer)){+.-.}, at: [<00000000619d2f71>] call_timer_fn+0x1c6/0x820 kernel/time/timer.c:1316
#2: (&(&im->lock)->rlock){+.-.}, at: [<000000005f833c5c>] spin_lock_bh include/linux/spinlock.h:315 [inline]
#2: (&(&im->lock)->rlock){+.-.}, at: [<000000005f833c5c>] igmpv3_send_report+0x98/0x5b0 net/ipv4/igmp.c:600stack backtrace: CPU: 0 PID: 4074 Comm: syzkaller616973 Not tainted 4.15.0+ #200 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x257 lib/dump_stack.c:53 lockdep_rcu_suspicious+0x123/0x170 kernel/locking/lockdep.c:4592 __in_dev_get_rcu include/linux/inetdevice.h:216 [inline] igmpv3_get_srcaddr net/ipv4/igmp.c:329 [inline] igmpv3_newpack+0xeef/0x12e0 net/ipv4/igmp.c:389 add_grhead.isra.27+0x235/0x300 net/ipv4/igmp.c:432 add_grec+0xbd3/0x1170 net/ipv4/igmp.c:565 igmpv3_send_report+0xd5/0x5b0 net/ipv4/igmp.c:605 igmp_send_report+0xc43/0x1050 net/ipv4/igmp.c:722 igmp_timer_expire+0x322/0x5c0 net/ipv4/igmp.c:831 call_timer_fn+0x228/0x820 kernel/time/timer.c:1326 expire_timers kernel/time/timer.c:1363 [inline] __run_timers+0x7ee/0xb70 kernel/time/timer.c:1666 run_timer_softirq+0x4c/0x70 kernel/time/timer.c:1692 __do_softirq+0x2d7/0xb85 kernel/softirq.c:285 invoke_softirq kernel/softirq.c:365 [inline] irq_exit+0x1cc/0x200 kernel/softirq.c:405 exiting_irq arch/x86/include/asm/apic.h:541 [inline] smp_apic_timer_interrupt+0x16b/0x700 arch/x86/kernel/apic/apic.c:1052 apic_timer_interrupt+0xa9/0xb0 arch/x86/entry/entry_64.S:938
--- net/ipv4/igmp.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv4/igmp.c +4 -0
@@ -384,7 +384,11 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu) pip->frag_off =htons (IP_DF ); pip->ttl =1 ; pip->daddr = fl4.daddr; + +rcu_read_lock (); pip->saddr =igmpv3_get_srcaddr (dev, &fl4); +rcu_read_unlock (); + pip->protocol =IPPROTO_IGMP ; pip->tot_len =0 ;/* filled in later */ ip_select_ident (net, skb,NULL );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] qlcnic: fix deadlock bug
In reply to Sasha LevinFrom: Junxiao Bi <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 233ac3891607f501f08879134d623b303838f478 ]
The following soft lockup was caught. This is a deadlock caused by recusive locking.
Process kworker/u40:1:28016 was holding spin lock "mbx->queue_lock" in qlcnic_83xx_mailbox_worker(), while a softirq came in and ask the same spin lock in qlcnic_83xx_enqueue_mbx_cmd(). This lock should be hold by disable bh..
[161846.962125] NMI watchdog: BUG: soft lockup - CPU#1 stuck for 22s! [kworker/u40:1:28016] [161846.962367] Modules linked in: tun ocfs2 xen_netback xen_blkback xen_gntalloc xen_gntdev xen_evtchn xenfs xen_privcmd autofs4 ocfs2_dlmfs ocfs2_stack_o2cb ocfs2_dlm ocfs2_nodemanager ocfs2_stackglue configfs bnx2fc fcoe libfcoe libfc sunrpc 8021q mrp garp bridge stp llc bonding dm_round_robin dm_multipath iTCO_wdt iTCO_vendor_support pcspkr sb_edac edac_core i2c_i801 shpchp lpc_ich mfd_core ioatdma ipmi_devintf ipmi_si ipmi_msghandler sg ext4 jbd2 mbcache2 sr_mod cdrom sd_mod igb i2c_algo_bit i2c_core ahci libahci megaraid_sas ixgbe dca ptp pps_core vxlan udp_tunnel ip6_udp_tunnel qla2xxx scsi_transport_fc qlcnic crc32c_intel be2iscsi bnx2i cnic uio cxgb4i cxgb4 cxgb3i libcxgbi ipv6 cxgb3 mdio libiscsi_tcp qla4xxx iscsi_boot_sysfs libiscsi scsi_transport_iscsi dm_mirror dm_region_hash dm_log dm_mod [161846.962454] [161846.962460] CPU: 1 PID: 28016 Comm: kworker/u40:1 Not tainted 4.1.12-94.5.9.el6uek.x86_64 #2 [161846.962463] Hardware name: Oracle Corporation SUN SERVER X4-2L /ASSY,MB,X4-2L , BIOS 26050100 09/19/2017 [161846.962489] Workqueue: qlcnic_mailbox qlcnic_83xx_mailbox_worker [qlcnic] [161846.962493] task: ffff8801f2e34600 ti: ffff88004ca5c000 task.ti: ffff88004ca5c000 [161846.962496] RIP: e030:[<ffffffff810013aa>] [<ffffffff810013aa>] xen_hypercall_sched_op+0xa/0x20 [161846.962506] RSP: e02b:ffff880202e43388 EFLAGS: 00000206 [161846.962509] RAX: 0000000000000000 RBX: ffff8801f6996b70 RCX: ffffffff810013aa [161846.962511] RDX: ffff880202e433cc RSI: ffff880202e433b0 RDI: 0000000000000003 [161846.962513] RBP: ffff880202e433d0 R08: 0000000000000000 R09: ffff8801fe893200 [161846.962516] R10: ffff8801fe400538 R11: 0000000000000206 R12: ffff880202e4b000 [161846.962518] R13: 0000000000000050 R14: 0000000000000001 R15: 000000000000020d [161846.962528] FS: 0000000000000000(0000) GS:ffff880202e40000(0000) knlGS:ffff880202e40000 [161846.962531] CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033 [161846.962533] CR2: 0000000002612640 CR3: 00000001bb796000 CR4: 0000000000042660 [161846.962536] Stack: [161846.962538] ffff880202e43608 0000000000000000 ffffffff813f0442 ffff880202e433b0 [161846.962543] 0000000000000000 ffff880202e433cc ffffffff00000001 0000000000000000 [161846.962547] 00000009813f03d6 ffff880202e433e0 ffffffff813f0460 ffff880202e43440 [161846.962552] Call Trace: [161846.962555] <IRQ> [161846.962565] [<ffffffff813f0442>] ? xen_poll_irq_timeout+0x42/0x50 [161846.962570] [<ffffffff813f0460>] xen_poll_irq+0x10/0x20 [161846.962578] [<ffffffff81014222>] xen_lock_spinning+0xe2/0x110 [161846.962583] [<ffffffff81013f01>] __raw_callee_save_xen_lock_spinning+0x11/0x20 [161846.962592] [<ffffffff816e5c57>] ? _raw_spin_lock+0x57/0x80 [161846.962609] [<ffffffffa028acfc>] qlcnic_83xx_enqueue_mbx_cmd+0x7c/0xe0 [qlcnic] [161846.962623] [<ffffffffa028e008>] qlcnic_83xx_issue_cmd+0x58/0x210 [qlcnic] [161846.962636] [<ffffffffa028caf2>] qlcnic_83xx_sre_macaddr_change+0x162/0x1d0 [qlcnic] [161846.962649] [<ffffffffa028cb8b>] qlcnic_83xx_change_l2_filter+0x2b/0x30 [qlcnic] [161846.962657] [<ffffffff8160248b>] ? __skb_flow_dissect+0x18b/0x650 [161846.962670] [<ffffffffa02856e5>] qlcnic_send_filter+0x205/0x250 [qlcnic] [161846.962682] [<ffffffffa0285c77>] qlcnic_xmit_frame+0x547/0x7b0 [qlcnic] [161846.962691] [<ffffffff8160ac22>] xmit_one+0x82/0x1a0 [161846.962696] [<ffffffff8160ad90>] dev_hard_start_xmit+0x50/0xa0 [161846.962701] [<ffffffff81630112>] sch_direct_xmit+0x112/0x220 [161846.962706] [<ffffffff8160b80f>] __dev_queue_xmit+0x1df/0x5e0 [161846.962710] [<ffffffff8160bc33>] dev_queue_xmit_sk+0x13/0x20 [161846.962721] [<ffffffffa0575bd5>] bond_dev_queue_xmit+0x35/0x80 [bonding] [161846.962729] [<ffffffffa05769fb>] __bond_start_xmit+0x1cb/0x210 [bonding] [161846.962736] [<ffffffffa0576a71>] bond_start_xmit+0x31/0x60 [bonding] [161846.962740] [<ffffffff8160ac22>] xmit_one+0x82/0x1a0 [161846.962745] [<ffffffff8160ad90>] dev_hard_start_xmit+0x50/0xa0 [161846.962749] [<ffffffff8160bb1e>] __dev_queue_xmit+0x4ee/0x5e0 [161846.962754] [<ffffffff8160bc33>] dev_queue_xmit_sk+0x13/0x20 [161846.962760] [<ffffffffa05cfa72>] vlan_dev_hard_start_xmit+0xb2/0x150 [8021q] [161846.962764] [<ffffffff8160ac22>] xmit_one+0x82/0x1a0 [161846.962769] [<ffffffff8160ad90>] dev_hard_start_xmit+0x50/0xa0 [161846.962773] [<ffffffff8160bb1e>] __dev_queue_xmit+0x4ee/0x5e0 [161846.962777] [<ffffffff8160bc33>] dev_queue_xmit_sk+0x13/0x20 [161846.962789] [<ffffffffa05adf74>] br_dev_queue_push_xmit+0x54/0xa0 [bridge] [161846.962797] [<ffffffffa05ae4ff>] br_forward_finish+0x2f/0x90 [bridge] [161846.962807] [<ffffffff810b0dad>] ? ttwu_do_wakeup+0x1d/0x100 [161846.962811] [<ffffffff815f929b>] ? __alloc_skb+0x8b/0x1f0 [161846.962818] [<ffffffffa05ae04d>] __br_forward+0x8d/0x120 [bridge] [161846.962822] [<ffffffff815f613b>] ? __kmalloc_reserve+0x3b/0xa0 [161846.962829] [<ffffffff810be55e>] ? update_rq_runnable_avg+0xee/0x230 [161846.962836] [<ffffffffa05ae176>] br_forward+0x96/0xb0 [bridge] [161846.962845] [<ffffffffa05af85e>] br_handle_frame_finish+0x1ae/0x420 [bridge] [161846.962853] [<ffffffffa05afc4f>] br_handle_frame+0x17f/0x260 [bridge] [161846.962862] [<ffffffffa05afad0>] ? br_handle_frame_finish+0x420/0x420 [bridge] [161846.962867] [<ffffffff8160d057>] __netif_receive_skb_core+0x1f7/0x870 [161846.962872] [<ffffffff8160d6f2>] __netif_receive_skb+0x22/0x70 [161846.962877] [<ffffffff8160d913>] netif_receive_skb_internal+0x23/0x90 [161846.962884] [<ffffffffa07512ea>] ? xenvif_idx_release+0xea/0x100 [xen_netback] [161846.962889] [<ffffffff816e5a10>] ? _raw_spin_unlock_irqrestore+0x20/0x50 [161846.962893] [<ffffffff8160e624>] netif_receive_skb_sk+0x24/0x90 [161846.962899] [<ffffffffa075269a>] xenvif_tx_submit+0x2ca/0x3f0 [xen_netback] [161846.962906] [<ffffffffa0753f0c>] xenvif_tx_action+0x9c/0xd0 [xen_netback] [161846.962915] [<ffffffffa07567f5>] xenvif_poll+0x35/0x70 [xen_netback] [161846.962920] [<ffffffff8160e01b>] napi_poll+0xcb/0x1e0 [161846.962925] [<ffffffff8160e1c0>] net_rx_action+0x90/0x1c0 [161846.962931] [<ffffffff8108aaba>] __do_softirq+0x10a/0x350 [161846.962938] [<ffffffff8108ae75>] irq_exit+0x125/0x130 [161846.962943] [<ffffffff813f03a9>] xen_evtchn_do_upcall+0x39/0x50 [161846.962950] [<ffffffff816e7ffe>] xen_do_hypervisor_callback+0x1e/0x40 [161846.962952] <EOI> [161846.962959] [<ffffffff816e5c4a>] ? _raw_spin_lock+0x4a/0x80 [161846.962964] [<ffffffff816e5b1e>] ? _raw_spin_lock_irqsave+0x1e/0xa0 [161846.962978] [<ffffffffa028e279>] ? qlcnic_83xx_mailbox_worker+0xb9/0x2a0 [qlcnic] [161846.962991] [<ffffffff810a14e1>] ? process_one_work+0x151/0x4b0 [161846.962995] [<ffffffff8100c3f2>] ? check_events+0x12/0x20 [161846.963001] [<ffffffff810a1960>] ? worker_thread+0x120/0x480 [161846.963005] [<ffffffff816e187b>] ? __schedule+0x30b/0x890 [161846.963010] [<ffffffff810a1840>] ? process_one_work+0x4b0/0x4b0 [161846.963015] [<ffffffff810a1840>] ? process_one_work+0x4b0/0x4b0 [161846.963021] [<ffffffff810a6b3e>] ? kthread+0xce/0xf0 [161846.963025] [<ffffffff810a6a70>] ? kthread_freezable_should_stop+0x70/0x70 [161846.963031] [<ffffffff816e6522>] ? ret_from_fork+0x42/0x70 [161846.963035] [<ffffffff810a6a70>] ? kthread_freezable_should_stop+0x70/0x70 [161846.963037] Code: cc 51 41 53 b8 1c 00 00 00 0f 05 41 5b 59 c3 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc 51 41 53 b8 1d 00 00 00 0f 05 <41> 5b 59 c3 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc
--- drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +9 -9
@@ -3825,7 +3825,7 @@ static void qlcnic_83xx_flush_mbx_queue(struct qlcnic_adapter *adapter)struct list_head *head = &mbx->cmd_q;struct qlcnic_cmd_args *cmd =NULL ; -spin_lock (&mbx->queue_lock); +spin_lock_bh (&mbx->queue_lock);while (!list_empty (head)) { cmd = list_entry(head->next, struct qlcnic_cmd_args, list);
@@ -3836,7 +3836,7 @@ static void qlcnic_83xx_flush_mbx_queue(struct qlcnic_adapter *adapter)qlcnic_83xx_notify_cmd_completion (adapter, cmd); } -spin_unlock (&mbx->queue_lock); +spin_unlock_bh (&mbx->queue_lock); }static int qlcnic_83xx_check_mbx_status (struct qlcnic_adapter *adapter)
@@ -3872,12 +3872,12 @@ static void qlcnic_83xx_dequeue_mbx_cmd(struct qlcnic_adapter *adapter, {struct qlcnic_mailbox *mbx = adapter->ahw->mailbox; -spin_lock (&mbx->queue_lock); +spin_lock_bh (&mbx->queue_lock);list_del (&cmd->list); mbx->num_cmds--; -spin_unlock (&mbx->queue_lock); +spin_unlock_bh (&mbx->queue_lock);qlcnic_83xx_notify_cmd_completion (adapter, cmd); }
@@ -3942,7 +3942,7 @@ static int qlcnic_83xx_enqueue_mbx_cmd(struct qlcnic_adapter *adapter,init_completion (&cmd->completion); cmd->rsp_opcode =QLC_83XX_MBX_RESPONSE_UNKNOWN ; -spin_lock (&mbx->queue_lock); +spin_lock_bh (&mbx->queue_lock);list_add_tail (&cmd->list, &mbx->cmd_q); mbx->num_cmds++;
@@ -3950,7 +3950,7 @@ static int qlcnic_83xx_enqueue_mbx_cmd(struct qlcnic_adapter *adapter, *timeout = cmd->total_cmds *QLC_83XX_MBX_TIMEOUT ;queue_work (mbx->work_q, &mbx->work); -spin_unlock (&mbx->queue_lock); +spin_unlock_bh (&mbx->queue_lock);return 0 ; }
@@ -4046,15 +4046,15 @@ static void qlcnic_83xx_mailbox_worker(struct work_struct *work) mbx->rsp_status =QLC_83XX_MBX_RESPONSE_WAIT ;spin_unlock_irqrestore (&mbx->aen_lock, flags); -spin_lock (&mbx->queue_lock); +spin_lock_bh (&mbx->queue_lock);if (list_empty (head)) { -spin_unlock (&mbx->queue_lock); +spin_unlock_bh (&mbx->queue_lock);return ; } cmd = list_entry(head->next, struct qlcnic_cmd_args, list); -spin_unlock (&mbx->queue_lock); +spin_unlock_bh (&mbx->queue_lock); mbx_ops->encode_cmd (adapter, cmd); mbx_ops->nofity_fw (adapter,QLC_83XX_MBX_REQUEST );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tcp: release sk_frag.page in tcp_disconnect
In reply to Sasha LevinFrom: Li RongQing <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9b42d55a66d388e4dd5550107df051a9637564fc ]
socket can be disconnected and gets transformed back to a listening socket, if sk_frag.page is not released, which will be cloned into a new socket by sk_clone_lock, but the reference count of this page is increased, lead to a use after free or double free issue
--- net/ipv4/tcp.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/tcp.c +6 -0
@@ -2235,6 +2235,12 @@ int tcp_disconnect(struct sock *sk, int flags)WARN_ON (inet->inet_num && !icsk->icsk_bind_hash); +if (sk->sk_frag.page) { +put_page (sk->sk_frag.page); + sk->sk_frag.page =NULL ; + sk->sk_frag.offset =0 ; + } + sk->sk_error_report (sk);return err; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] r8169: fix RTL8168EP take too long to complete driver initialization.
In reply to Sasha LevinFrom: Chunhao Lin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 086ca23d03c0d2f4088f472386778d293e15c5f6 ]
Driver check the wrong register bit in rtl_ocp_tx_cond() that keep driver waiting until timeout.
Fix this by waiting for the right register bit.
--- drivers/net/ethernet/realtek/r8169.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169.c +2 -2
@@ -1375,7 +1375,7 @@ DECLARE_RTL_COND(rtl_ocp_tx_cond) {void __iomem *ioaddr = tp->mmio_addr; -return RTL_R8 (IBISR0 ) &0x02 ; +return RTL_R8 (IBISR0 ) &0x20 ; }static void rtl8168ep_stop_cmac (struct rtl8169_private *tp)
@@ -1383,7 +1383,7 @@ static void rtl8168ep_stop_cmac(struct rtl8169_private *tp)void __iomem *ioaddr = tp->mmio_addr;RTL_W8 (IBCR2 ,RTL_R8 (IBCR2 ) & ~0x01 ); -rtl_msleep_loop_wait_low (tp, &rtl_ocp_tx_cond,50 ,2000 ); +rtl_msleep_loop_wait_high (tp, &rtl_ocp_tx_cond,50 ,2000 );RTL_W8 (IBISR0 ,RTL_R8 (IBISR0 ) |0x20 );RTL_W8 (IBCR0 ,RTL_R8 (IBCR0 ) & ~0x01 ); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] vhost_net: stop device during reset owner
In reply to Sasha LevinFrom: Jason Wang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4cd879515d686849eec5f718aeac62a70b067d82 ]
We don't stop device before reset owner, this means we could try to serve any virtqueue kick before reset dev->worker. This will result a warn since the work was pending at llist during owner resetting. Fix this by stopping device during owner reset.
--- drivers/vhost/net.c | 1 + 1 file changed, 1 insertion(+)
drivers/vhost/net.c +1 -0
@@ -982,6 +982,7 @@ static long vhost_net_reset_owner(struct vhost_net *n) }vhost_net_stop (n, &tx_sock, &rx_sock);vhost_net_flush (n); +vhost_dev_stop (&n->dev);vhost_dev_reset_owner (&n->dev, memory);vhost_net_vq_reset (n); done:
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] media: soc_camera: soc_scale_crop: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
In reply to Sasha LevinFrom: Jesse Chan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5331aec1bf9c9da557668174e0a4bfcee39f1121 ]
This change resolves a new compile-time warning
when built as a loadable module:
WARNING: modpost: missing MODULE_LICENSE() in drivers/media/platform/soc_camera/soc_scale_crop.o see include/linux/module.h for more information
This adds the license as "GPL", which matches the header of the file.
MODULE_DESCRIPTION and MODULE_AUTHOR are also added.
--- drivers/media/platform/soc_camera/soc_scale_crop.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/platform/soc_camera/soc_scale_crop.c +4 -0
@@ -400,3 +400,7 @@ void soc_camera_calc_client_output(struct soc_camera_device *icd, mf->height =soc_camera_shift_scale (rect->height, shift, scale_v); }EXPORT_SYMBOL (soc_camera_calc_client_output); + +MODULE_DESCRIPTION ("soc-camera scaling-cropping functions" ); +MODULE_AUTHOR ("Guennadi Liakhovetski <[email protected]>" ); +MODULE_LICENSE ("GPL" );
Signature · 1 line
2.14.1