3.16.40-rc1 review
Subsystems (5)
PATCH 132/306 mmc: rtsx_usb_sdmmc: Handle runtime PM while changing the led
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ulf Hansson <[email protected]>
commit 4f48aa7a11bfed9502a7c85a5b68cd40ea827f73 upstream.
Accesses of the rtsx sdmmc's parent device, which is the rtsx usb device, must be done when it's runtime resumed. Currently this isn't case when changing the led, so let's fix this by adding a pm_runtime_get_sync() and a pm_runtime_put() around those operations.
--- drivers/mmc/host/rtsx_usb_sdmmc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mmc/host/rtsx_usb_sdmmc.c +2 -0
@@ -1309,6 +1309,7 @@ static void rtsx_usb_update_led(struct w container_of(work, struct rtsx_usb_sdmmc, led_work);struct rtsx_ucr *ucr = host->ucr; +pm_runtime_get_sync (sdmmc_dev (host));mutex_lock (&ucr->dev_mutex);if (host->led.brightness ==LED_OFF )
@@ -1317,6 +1318,7 @@ static void rtsx_usb_update_led(struct wrtsx_usb_turn_on_led (ucr);mutex_unlock (&ucr->dev_mutex); + pm_runtime_put(sdmmc_dev(host)); }#endif
PATCH 133/306 memstick: rtsx_usb_ms: Runtime resume the device when polling for cards
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 796aa46adf1d90eab36ae06a42e6d3f10b28a75c upstream.
Accesses to the rtsx usb device, which is the parent of the rtsx memstick device, must not be done unless it's runtime resumed.
Therefore when the rtsx_usb_ms driver polls for inserted memstick cards, let's add pm_runtime_get|put*() to make sure accesses is done when the rtsx usb device is runtime resumed.
--- drivers/memstick/host/rtsx_usb_ms.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/memstick/host/rtsx_usb_ms.c +2 -0
@@ -681,6 +681,7 @@ static int rtsx_usb_detect_ms_card(voidint err;for (;;) { +pm_runtime_get_sync (ms_dev (host));mutex_lock (&ucr->dev_mutex);/* Check pending MS card changes */
@@ -703,6 +704,7 @@ static int rtsx_usb_detect_ms_card(void } poll_again: +pm_runtime_put (ms_dev (host));if (host->eject)break ;
PATCH 134/306 memstick: rtsx_usb_ms: Manage runtime PM when accessing the device
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ulf Hansson <[email protected]>
commit 9158cb29e7c2f10dd325eb1589f0fe745a271257 upstream.
Accesses to the rtsx usb device, which is the parent of the rtsx memstick device, must not be done unless it's runtime resumed. This is currently not the case and it could trigger various errors.
Fix this by properly deal with runtime PM in this regards. This means making sure the device is runtime resumed, when serving requests via the ->request() callback or changing settings via the ->set_param() callbacks.
--- drivers/memstick/host/rtsx_usb_ms.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/memstick/host/rtsx_usb_ms.c +4 -0
@@ -524,6 +524,7 @@ static void rtsx_usb_ms_handle_req(strucint rc;if (!host->req) { +pm_runtime_get_sync (ms_dev (host)); do { rc = memstick_next_req(msh, &host->req); dev_dbg(ms_dev(host), "next req %d\n", rc);
@@ -544,6 +545,7 @@ static void rtsx_usb_ms_handle_req(struc host->req->error); } }while (!rc); +pm_runtime_put (ms_dev (host)); } }
@@ -570,6 +572,7 @@ static int rtsx_usb_ms_set_param(structdev_dbg (ms_dev (host),"%s: param = %d, value = %d\n" , __func__, param, value); +pm_runtime_get_sync (ms_dev (host));mutex_lock (&ucr->dev_mutex); err =rtsx_usb_card_exclusive_check (ucr,RTSX_USB_MS_CARD );
@@ -635,6 +638,7 @@ static int rtsx_usb_ms_set_param(struct } out:mutex_unlock (&ucr->dev_mutex); +pm_runtime_put (ms_dev (host));/* power-on delay */ if (param ==MEMSTICK_POWER && value ==MEMSTICK_POWER_ON )
PATCH 135/306 USB: serial: ftdi_sio: add support for Infineon TriBoard TC2X7
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Tauner <[email protected]>
commit ca006f785fbfd7a5c901900bd3fe2b26e946a1ee upstream.
This adds support to ftdi_sio for the Infineon TriBoard TC2X7 engineering board for first-generation Aurix SoCs with Tricore CPUs. Mere addition of the device IDs does the job.
--- drivers/usb/serial/ftdi_sio.c | 3 ++- drivers/usb/serial/ftdi_sio_ids.h | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/usb/serial/ftdi_sio.c +2 -1
@@ -999,7 +999,8 @@ static const struct usb_device_id id_tab/* ekey Devices */ { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) },/* Infineon Devices */ - { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) }, + { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_TC1798_PID, 1) }, + { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_TC2X7_PID, 1) },/* GE Healthcare devices */ { USB_DEVICE(GE_HEALTHCARE_VID, GE_HEALTHCARE_NEMO_TRACKER_PID) },/* Active Research (Actisense) devices */
drivers/usb/serial/ftdi_sio_ids.h +3 -2
@@ -626,8 +626,9 @@/* * Infineon Technologies */ -#define INFINEON_VID 0x058b -#define INFINEON_TRIBOARD_PID 0x0028/* DAS JTAG TriBoard TC1798 V1.0 */ +#define INFINEON_VID 0x058b +#define INFINEON_TRIBOARD_TC1798_PID 0x0028/* DAS JTAG TriBoard TC1798 V1.0 */ +#define INFINEON_TRIBOARD_TC2X7_PID 0x0043/* DAS JTAG TriBoard TC2X7 V1.0 */ /* * Acton Research Corp.
PATCH 136/306 arm64: kernel: Init MDCR_EL2 even in the absence of a PMU
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 850540351bb1a4fa5f192e5ce55b89928cc57f42 upstream.
Commit f436b2ac90a0 ("arm64: kernel: fix architected PMU registers unconditional access") made sure we wouldn't access unimplemented PMU registers, but also left MDCR_EL2 uninitialized in that case, leading to trap bits being potentially left set.
Make sure we always write something in that register.
--- arch/arm64/kernel/head.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/kernel/head.S +2 -1
@@ -322,8 +322,9 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // C b.lt 4f // Skip if no PMU present mrs x0, pmcr_el0 // Disable debug access traps ubfx x0, x0, #11, #5 // to EL2 and allow access to - msr mdcr_el2, x0 // all PMU counters from EL1 4: + csel x0, xzr, x0, lt // all PMU counters from EL1 + msr mdcr_el2, x0 // (if they exist) /* Stage-2 translation */ msr vttbr_el2, xzr
PATCH 137/306 netfilter: nf_tables: underflow in nft_parse_u32_check()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 09525a09ad3099efd9ba49b0b90bddc350d6b53a upstream.
We don't want to allow negatives here.
--- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
@@ -3725,7 +3725,7 @@ static int nf_tables_check_loops(const s*/ unsigned int nft_parse_u32_check (const struct nlattr *attr,int max,u32 *dest) { -int val; +u32 val; val =ntohl (nla_get_be32 (attr));if (val > max)
PATCH 138/306 ALSA: hda - allow 40 bit DMA mask for NVidia devices
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 3ab7511eafdd5c4f40d2832f09554478dfbea170 upstream.
Commit 49d9e77e72cf ("ALSA: hda - Fix system panic when DMA > 40 bits for Nvidia audio controllers") simply disabled any DMA exceeding 32 bits for NVidia devices, even though they are capable of performing DMA up to 40 bits. On some architectures (such as arm64), system memory is not guaranteed to be 32-bit addressable by PCI devices, and so this change prevents NVidia devices from working on platforms such as AMD Seattle.
Since the original commit already mentioned that up to 40 bits of DMA is supported, and given that the code has been updated in the meantime to support a 40 bit DMA mask on other devices, revert commit 49d9e77e72cf and explicitly set the DMA mask to 40 bits for NVidia devices.
--- sound/pci/hda/hda_intel.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/pci/hda/hda_intel.c +5 -2
@@ -258,8 +258,7 @@ enum {/* quirks for Nvidia */ #define AZX_DCAPS_PRESET_NVIDIA \ (AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\ - AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_NO_64BIT |\ - AZX_DCAPS_CORBRP_SELF_CLEAR) + AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_CORBRP_SELF_CLEAR)#define AZX_DCAPS_PRESET_CTHDA \ (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY |\
@@ -1371,6 +1370,10 @@ static int azx_first_init(struct azx *ch } } +/* NVidia hardware normally only supports up to 40 bits of DMA */ +if (chip->pci->vendor ==PCI_VENDOR_ID_NVIDIA ) + dma_bits =40 ; +/* disable 64bit DMA address on some devices */ if (chip->driver_caps &AZX_DCAPS_NO_64BIT ) {dev_dbg (card->dev,"Disabling 64bit DMA\n" );
PATCH 139/306 isofs: Do not return EACCES for unknown filesystems
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit a2ed0b391dd9c3ef1d64c7c3e370f4a5ffcd324a upstream.
When isofs_mount() is called to mount a device read-write, it returns EACCES even before it checks that the device actually contains an isofs filesystem. This may confuse mount(8) which then tries to mount all subsequent filesystem types in read-only mode.
Fix the problem by returning EACCES only once we verify that the device indeed contains an iso9660 filesystem.
--- fs/isofs/inode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/isofs/inode.c +5 -3
@@ -711,6 +711,11 @@ static int isofs_fill_super(struct super pri_bh =NULL ; root_found: +/* We don't support read-write mounts */ +if (!(s->s_flags &MS_RDONLY )) { + error = -EACCES ; + goto out_freebh; + }if (joliet_level && (pri ==NULL || !opt.rock)) {/* This is the case of Joliet with the norock mount flag.
@@ -1523,9 +1528,6 @@ struct inode *__isofs_iget(struct super_static struct dentry *isofs_mount (struct file_system_type *fs_type,int flags,const char *dev_name,void *data) { -/* We don't support read-write mounts */ -if (!(flags &MS_RDONLY )) -return ERR_PTR (-EACCES );return mount_bdev (fs_type, flags, dev_name, data, isofs_fill_super); }
PATCH 140/306 bridge: multicast: restore perm router ports on multicast enable
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
commit 7cb3f9214dfa443c1ccc2be637dcc6344cc203f0 upstream.
Satish reported a problem with the perm multicast router ports not getting reenabled after some series of events, in particular if it happens that the multicast snooping has been disabled and the port goes to disabled state then it will be deleted from the router port list, but if it moves into non-disabled state it will not be re-added because the mcast snooping is still disabled, and enabling snooping later does nothing.
Here are the steps to reproduce, setup br0 with snooping enabled and eth1 added as a perm router (multicast_router = 2):
1. $ echo 0 > /sys/class/net/br0/bridge/multicast_snooping
2. $ ip l set eth1 down
^ This step deletes the interface from the router list
3. $ ip l set eth1 up
^ This step does not add it again because mcast snooping is disabled
4. $ echo 1 > /sys/class/net/br0/bridge/multicast_snooping
5. $ bridge -d -s mdb show
<empty>
At this point we have mcast enabled and eth1 as a perm router (value = 2) but it is not in the router list which is incorrect.
After this change:
1. $ echo 0 > /sys/class/net/br0/bridge/multicast_snooping
2. $ ip l set eth1 down
^ This step deletes the interface from the router list
3. $ ip l set eth1 up
^ This step does not add it again because mcast snooping is disabled
4. $ echo 1 > /sys/class/net/br0/bridge/multicast_snooping
5. $ bridge -d -s mdb show
router ports on br0: eth1
Note: we can directly do br_multicast_enable_port for all because the querier timer already has checks for the port state and will simply expire if it's in blocking/disabled. See the comment added by commit 9aa66382163e7 ("bridge: multicast: add a comment to br_port_state_selection about blocking state")
--- net/bridge/br_multicast.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
net/bridge/br_multicast.c +14 -9
@@ -928,13 +928,12 @@ static void br_multicast_enable(struct bmod_timer (&query->timer, jiffies); } -void br_multicast_enable_port (struct net_bridge_port *port) +static void __br_multicast_enable_port (struct net_bridge_port *port) {struct net_bridge *br = port->br; -spin_lock (&br->multicast_lock);if (br->multicast_disabled || !netif_running (br->dev)) - goto out; +return ;br_multicast_enable (&port->ip4_own_query);#if IS_ENABLED (CONFIG_IPV6 )
@@ -942,8 +941,14 @@ void br_multicast_enable_port(struct net#endif if (port->multicast_router ==2 &&hlist_unhashed (&port->rlist))br_multicast_add_router (br, port); +} -out: +void br_multicast_enable_port (struct net_bridge_port *port) +{ +struct net_bridge *br = port->br; + +spin_lock (&br->multicast_lock); +__br_multicast_enable_port (port);spin_unlock (&br->multicast_lock); }
@@ -2047,8 +2052,9 @@ static void br_multicast_start_querier(sint br_multicast_toggle (struct net_bridge *br,unsigned long val) { -int err =0 ;struct net_bridge_mdb_htable *mdb; +struct net_bridge_port *port; +int err =0 ;spin_lock_bh (&br->multicast_lock);if (br->multicast_disabled == !val)
@@ -2076,10 +2082,9 @@ rollback: goto rollback; } -br_multicast_start_querier (br, &br->ip4_own_query); -#if IS_ENABLED (CONFIG_IPV6 ) -br_multicast_start_querier (br, &br->ip6_own_query); -#endif +br_multicast_open (br); +list_for_each_entry (port, &br->port_list, list) +__br_multicast_enable_port (port); unlock:spin_unlock_bh (&br->multicast_lock);
PATCH 141/306 hwrng: core - Don't use a stack buffer in add_early_randomness()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lutomirski <[email protected]>
commit 6d4952d9d9d4dc2bb9c0255d95a09405a1e958f7 upstream.
hw_random carefully avoids using a stack buffer except in add_early_randomness(). This causes a crash in virtio_rng if CONFIG_VMAP_STACK=y.
--- drivers/char/hw_random/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/hw_random/core.c +3 -3
@@ -65,12 +65,12 @@ static size_t rng_buffer_size(void)static void add_early_randomness (struct hwrng *rng) { -unsigned char bytes[16 ];int bytes_read; +size_t size =min_t (size_t,16 ,rng_buffer_size ()); - bytes_read =rng_get_data (rng, bytes,sizeof (bytes),1 ); + bytes_read =rng_get_data (rng, rng_buffer, size,1 );if (bytes_read >0 ) -add_device_randomness (bytes, bytes_read); +add_device_randomness (rng_buffer, bytes_read); }static inline int hwrng_init (struct hwrng *rng)
PATCH 142/306 Input: i8042 - add XMG C504 to keyboard reset table
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Scheuring <[email protected]>
commit da25311c7ca8b0254a686fc0d597075b9aa3b683 upstream.
The Schenker XMG C504 is a rebranded Gigabyte P35 v2 laptop. Therefore it also needs a keyboard reset to detect the Elantech touchpad. Otherwise the touchpad appears to be dead.
With this patch the touchpad is detected:
$ dmesg | grep -E "(i8042|Elantech|elantech)"
[ 2.675399] i8042: PNP: PS/2 Controller [PNP0303:PS2K,PNP0f13:PS2M] at 0x60,0x64 irq 1,12 [ 2.680372] i8042: Attempting to reset device connected to KBD port [ 2.789037] serio: i8042 KBD port at 0x60,0x64 irq 1 [ 2.791586] serio: i8042 AUX port at 0x60,0x64 irq 12 [ 2.813840] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input4 [ 3.811431] psmouse serio1: elantech: assuming hardware version 4 (with firmware version 0x361f0e) [ 3.825424] psmouse serio1: elantech: Synaptics capabilities query result 0x00, 0x15, 0x0f. [ 3.839424] psmouse serio1: elantech: Elan sample query result 03, 58, 74 [ 3.911349] input: ETPS/2 Elantech Touchpad as /devices/platform/i8042/serio1/input/input6
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -776,6 +776,13 @@ static const struct dmi_system_id __init DMI_MATCH(DMI_PRODUCT_NAME, "P34"), }, }, + { + /* Schenker XMG C504 - Elantech touchpad */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "XMG"), + DMI_MATCH(DMI_PRODUCT_NAME, "C504"), + }, + }, { } };
PATCH 143/306 ubifs: Fix xattr_names length in exit paths
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit 843741c5778398ea67055067f4cc65ae6c80ca0e upstream.
When the operation fails we also have to undo the changes we made to ->xattr_names. Otherwise listxattr() will report wrong lengths.
--- fs/ubifs/xattr.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/xattr.c +2 -0
@@ -167,6 +167,7 @@ out_cancel: host_ui->xattr_cnt -=1 ; host_ui->xattr_size -=CALC_DENT_SIZE (nm->len); host_ui->xattr_size -=CALC_XATTR_BYTES (size); + host_ui->xattr_names -= nm->len;mutex_unlock (&host_ui->ui_mutex); out_free:make_bad_inode (inode);
@@ -514,6 +515,7 @@ out_cancel: host_ui->xattr_cnt +=1 ; host_ui->xattr_size +=CALC_DENT_SIZE (nm->len); host_ui->xattr_size +=CALC_XATTR_BYTES (ui->data_len); + host_ui->xattr_names += nm->len;mutex_unlock (&host_ui->ui_mutex);ubifs_release_budget (c, &req);make_bad_inode (inode);
PATCH 144/306 ubifs: Abort readdir upon error
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit c83ed4c9dbb358b9e7707486e167e940d48bfeed upstream.
If UBIFS is facing an error while walking a directory, it reports this error and ubifs_readdir() returns the error code. But the VFS readdir logic does not make the getdents system call fail in all cases. When the readdir cursor indicates that more entries are present, the system call will just return and the libc wrapper will try again since it also knows that more entries are present.
This causes the libc wrapper to busy loop for ever when a directory is corrupted on UBIFS.
A common approach do deal with corrupted directory entries is skipping them by setting the cursor to the next entry. On UBIFS this approach is not possible since we cannot compute the next directory entry cursor position without reading the current entry. So all we can do is setting the cursor to the "no more entries" position and make getdents exit.
---
fs/ubifs/dir.c +3 -5
@@ -347,7 +347,7 @@ static unsigned int vfs_dent_type(uint8_*/ static int ubifs_readdir (struct file *file,struct dir_context *ctx) { -int err; +int err =0 ;struct qstr nm;union ubifs_key key;struct ubifs_dent_node *dent;
@@ -446,16 +446,14 @@ static int ubifs_readdir(struct file *fi } out: -if (err != -ENOENT ) { +if (err != -ENOENT )ubifs_err ("cannot find next direntry, error %d" , err); -return err; - }kfree (file->private_data); file->private_data =NULL ;/* 2 is a special value indicating that there are no more direntries */ ctx->pos =2 ; -return 0 ; +return err; }/* Free saved readdir() state when the directory is closed */
PATCH 145/306 target: Make EXTENDED_COPY 0xe4 failure return COPY TARGET DEVICE NOT REACHABLE
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit 449a137846c84829a328757cd21fd9ca65c08519 upstream.
This patch addresses a bug where EXTENDED_COPY across multiple LUNs results in a CHECK_CONDITION when the source + destination are not located on the same physical node.
ESX Host environments expect sense COPY_ABORTED w/ COPY TARGET DEVICE NOT REACHABLE to be returned when this occurs, in order to signal fallback to local copy method.
As described in section 6.3.3 of spc4r22:
"If it is not possible to complete processing of a segment because the
copy manager is unable to establish communications with a copy target device, because the copy target device does not respond to INQUIRY, or because the data returned in response to INQUIRY indicates an unsupported logical unit, then the EXTENDED COPY command shall be terminated with CHECK CONDITION status, with the sense key set to COPY ABORTED, and the additional sense code set to COPY TARGET DEVICE NOT REACHABLE."
Tested on v4.1.y with ESX v5.5u2+ with BlockCopy across multiple nodes.
[bwh: Backported to 3.16: generate the sense data in
transport_send_check_condition_and_sense() rather than adding to sense_info_table]
--- drivers/target/target_core_transport.c | 7 +++++++ drivers/target/target_core_xcopy.c | 22 ++++++++++++++++------ include/target/target_core_base.h | 1 + 3 files changed, 24 insertions(+), 6 deletions(-)
drivers/target/target_core_transport.c +11 -0
@@ -1634,6 +1634,7 @@ void transport_generic_request_failure(scase TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED :case TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED :case TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED : +case TCM_COPY_TARGET_DEVICE_NOT_REACHABLE :break ;case TCM_OUT_OF_RESOURCES : sense_reason =TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ;
@@ -2914,6 +2915,16 @@ transport_send_check_condition_and_sense buffer[SPC_ASCQ_KEY_OFFSET ] =0x03 ;transport_err_sector_info (buffer, cmd->bad_sector);break ; +case TCM_COPY_TARGET_DEVICE_NOT_REACHABLE : +/* CURRENT ERROR */ + buffer[0 ] =0x70 ; + buffer[SPC_ADD_SENSE_LEN_OFFSET ] =10 ; + buffer[SPC_SENSE_KEY_OFFSET ] =COPY_ABORTED ; + buffer[SPC_ASC_KEY_OFFSET ] =0x0d ; +/* COPY TARGET DEVICE NOT REACHABLE */ + buffer[SPC_ASCQ_KEY_OFFSET ] =0x02 ; +transport_err_sector_info (buffer, cmd->bad_sector); +break ;case TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE :default :/* CURRENT ERROR */
drivers/target/target_core_xcopy.c +16 -6
@@ -116,7 +116,7 @@ static int target_xcopy_locate_se_dev_e4 }mutex_unlock (&g_device_mutex); -pr_err ("Unable to locate 0xe4 descriptor for EXTENDED_COPY\n" ); +pr_debug_ratelimited ("Unable to locate 0xe4 descriptor for EXTENDED_COPY\n" );return -EINVAL ; }
@@ -197,7 +197,7 @@ static int target_xcopy_parse_tiddesc_e4static int target_xcopy_parse_target_descriptors (struct se_cmd *se_cmd,struct xcopy_op *xop,unsigned char *p, -unsigned short tdll) +unsigned short tdll,sense_reason_t *sense_ret) {struct se_device *local_dev = se_cmd->se_dev;unsigned char *desc = p;
@@ -205,6 +205,8 @@ static int target_xcopy_parse_target_desunsigned short start =0 ;bool src = true; + *sense_ret =TCM_INVALID_PARAMETER_LIST ; +if (offset !=0 ) {pr_err ("XCOPY target descriptor list length is not" " multiple of %d\n" ,XCOPY_TARGET_DESC_LEN );
@@ -255,9 +257,16 @@ static int target_xcopy_parse_target_des rc =target_xcopy_locate_se_dev_e4 (se_cmd, xop, true); else rc =target_xcopy_locate_se_dev_e4 (se_cmd, xop, false); - -if (rc <0 ) +/* +* If a matching IEEE NAA 0x83 descriptor for the requested device +* is not located on this node, return COPY_ABORTED with ASQ/ASQC +* 0x0d/0x02 - COPY_TARGET_DEVICE_NOT_REACHABLE to request the +* initiator to fall back to normal copy method. +*/ +if (rc <0 ) { + *sense_ret =TCM_COPY_TARGET_DEVICE_NOT_REACHABLE ; goto out; + }pr_debug ("XCOPY TGT desc: Source dev: %p NAA IEEE WWN: 0x%16phN\n" , xop->src_dev, &xop->src_tid_wwn[0 ]);
@@ -861,7 +870,8 @@ out:xcopy_pt_undepend_remotedev (xop);kfree (xop); -pr_warn ("target_xcopy_do_work: Setting X-COPY CHECK_CONDITION -> sending response\n" ); +pr_warn_ratelimited ("target_xcopy_do_work: rc: %d, Setting X-COPY CHECK_CONDITION" +" -> sending response\n" , rc); ec_cmd->scsi_status =SAM_STAT_CHECK_CONDITION ;target_complete_cmd (ec_cmd,SAM_STAT_CHECK_CONDITION ); }
@@ -920,7 +930,7 @@ sense_reason_t target_do_xcopy(struct se" tdll: %hu sdll: %u inline_dl: %u\n" , list_id, list_id_usage, tdll, sdll, inline_dl); - rc =target_xcopy_parse_target_descriptors (se_cmd, xop, &p[16 ], tdll); + rc =target_xcopy_parse_target_descriptors (se_cmd, xop, &p[16 ], tdll, &ret);if (rc <=0 ) goto out;
include/target/target_core_base.h +1 -0
@@ -211,6 +211,7 @@ enum tcm_sense_reason_table {TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED =R (0x15 ),TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED =R (0x16 ),TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED =R (0x17 ), +TCM_COPY_TARGET_DEVICE_NOT_REACHABLE =R (0x18 ), #undef R };
PATCH 146/306 target: Don't override EXTENDED_COPY xcopy_pt_cmd SCSI status code
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dinesh Israni <[email protected]>
commit 926317de33998c112c5510301868ea9aa34097e2 upstream.
This patch addresses a bug where a local EXTENDED_COPY WRITE or READ backend I/O request would always return SAM_STAT_CHECK_CONDITION, even if underlying xcopy_pt_cmd->se_cmd generated a different SCSI status code.
ESX host environments expect to hit SAM_STAT_RESERVATION_CONFLICT for certain scenarios, and SAM_STAT_CHECK_CONDITION results in non-retriable status for these cases.
Tested on v4.1.y with ESX v5.5u2+ with local IBLOCK backend copy.
--- drivers/target/target_core_xcopy.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/target/target_core_xcopy.c +12 -4
@@ -707,6 +707,7 @@ static int target_xcopy_read_source( rc =target_xcopy_setup_pt_cmd (xpt_cmd, xop, src_dev, &cdb[0 ], remote_port, true);if (rc <0 ) { + ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;transport_generic_free_cmd (se_cmd,0 );return rc; }
@@ -718,6 +719,7 @@ static int target_xcopy_read_source( rc =target_xcopy_issue_pt_cmd (xpt_cmd);if (rc <0 ) { + ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;transport_generic_free_cmd (se_cmd,0 );return rc; }
@@ -768,6 +770,7 @@ static int target_xcopy_write_destinatio remote_port, false);if (rc <0 ) {struct se_cmd *src_cmd = &xop->src_pt_cmd->se_cmd; + ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;/* * If the failure happened before the t_mem_list hand-off in * target_xcopy_setup_pt_cmd(), Reset memory + clear flag so that
@@ -783,6 +786,7 @@ static int target_xcopy_write_destinatio rc =target_xcopy_issue_pt_cmd (xpt_cmd);if (rc <0 ) { + ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status; se_cmd->se_cmd_flags &= ~SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC ;transport_generic_free_cmd (se_cmd,0 );return rc;
@@ -869,10 +873,14 @@ static void target_xcopy_do_work(struct out:xcopy_pt_undepend_remotedev (xop);kfree (xop); - -pr_warn_ratelimited ("target_xcopy_do_work: rc: %d, Setting X-COPY CHECK_CONDITION" -" -> sending response\n" , rc); - ec_cmd->scsi_status =SAM_STAT_CHECK_CONDITION ; +/* +* Don't override an error scsi status if it has already been set +*/ +if (ec_cmd->scsi_status ==SAM_STAT_GOOD ) { +pr_warn_ratelimited ("target_xcopy_do_work: rc: %d, Setting X-COPY" +" CHECK_CONDITION -> sending response\n" , rc); + ec_cmd->scsi_status =SAM_STAT_CHECK_CONDITION ; + }target_complete_cmd (ec_cmd,SAM_STAT_CHECK_CONDITION ); }
PATCH 147/306 xhci: add restart quirk for Intel Wildcatpoint PCH
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 4c39135aa412d2f1381e43802523da110ca7855c upstream.
xHC in Wildcatpoint-LP PCH is similar to LynxPoint-LP and need the same quirks to prevent machines from spurious restart while shutting them down.
--- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +3 -1
@@ -38,6 +38,7 @@#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 +#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
@@ -138,7 +139,8 @@ static void xhci_pci_quirks(struct devic xhci->quirks |=XHCI_SPURIOUS_REBOOT ; }if (pdev->vendor ==PCI_VENDOR_ID_INTEL && - pdev->device ==PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI ) { + (pdev->device ==PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI || + pdev->device ==PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI )) { xhci->quirks |=XHCI_SPURIOUS_REBOOT ; xhci->quirks |=XHCI_SPURIOUS_WAKEUP ; }
PATCH 148/306 xhci: workaround for hosts missing CAS bit
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 346e99736c3ce328fd42d678343b70243aca5f36 upstream.
If a device is unplugged and replugged during Sx system suspend some Intel xHC hosts will overwrite the CAS (Cold attach status) flag and no device connection is noticed in resume.
A device in this state can be identified in resume if its link state is in polling or compliance mode, and the current connect status is 0. A device in this state needs to be warm reset.
Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8
Observed on Cherryview and Apollolake as they go into compliance mode if LFPS times out during polling, and re-plugged devices are not discovered at resume.
--- drivers/usb/host/xhci-hub.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/usb/host/xhci-pci.c | 6 ++++++ drivers/usb/host/xhci.h | 3 +++ 3 files changed, 46 insertions(+)
drivers/usb/host/xhci-hub.c +37 -0
@@ -1222,6 +1222,35 @@ int xhci_bus_suspend(struct usb_hcd *hcdreturn 0 ; } +/* +* Workaround for missing Cold Attach Status (CAS) if device re-plugged in S3. +* warm reset a USB3 device stuck in polling or compliance mode after resume. +* See Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8 +*/ +static bool xhci_port_missing_cas_quirk (int port_index, +__le32 __iomem **port_array) +{ +u32 portsc; + + portsc =readl (port_array[port_index]); + +/* if any of these are set we are not stuck */ +if (portsc & (PORT_CONNECT |PORT_CAS )) +return false; + +if (((portsc &PORT_PLS_MASK ) !=XDEV_POLLING ) && + ((portsc &PORT_PLS_MASK ) !=XDEV_COMP_MODE )) +return false; + +/* clear wakeup/change bits, and do a warm port reset */ + portsc &= ~(PORT_RWC_BITS |PORT_CEC |PORT_WAKE_BITS ); + portsc |=PORT_WR ; +writel (portsc, port_array[port_index]); +/* flush write */ +readl (port_array[port_index]); +return true; +} +int xhci_bus_resume (struct usb_hcd *hcd) {struct xhci_hcd *xhci =hcd_to_xhci (hcd);
@@ -1256,6 +1285,14 @@ int xhci_bus_resume(struct usb_hcd *hcd)int slot_id; temp =readl (port_array[port_index]); + +/* warm reset CAS limited ports stuck in polling/compliance */ +if ((xhci->quirks &XHCI_MISSING_CAS ) && + (hcd->speed >=HCD_USB3 ) && +xhci_port_missing_cas_quirk (port_index, port_array)) { +xhci_dbg (xhci,"reset stuck port %d\n" , port_index); +continue ; + }if (DEV_SUPERSPEED (temp)) temp &= ~(PORT_RWC_BITS |PORT_CEC |PORT_WAKE_BITS );else
drivers/usb/host/xhci-pci.c +6 -0
@@ -44,6 +44,7 @@#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 +#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8static const char hcd_name[] ="xhci_hcd" ;
@@ -152,6 +153,11 @@ static void xhci_pci_quirks(struct devic pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) { xhci->quirks |=XHCI_PME_STUCK_QUIRK ; } +if (pdev->vendor ==PCI_VENDOR_ID_INTEL && + (pdev->device ==PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || + pdev->device ==PCI_DEVICE_ID_INTEL_APL_XHCI )) + xhci->quirks |=XHCI_MISSING_CAS ; +if (pdev->vendor ==PCI_VENDOR_ID_ETRON && pdev->device ==PCI_DEVICE_ID_ASROCK_P67 ) { xhci->quirks |=XHCI_RESET_ON_RESUME ;
drivers/usb/host/xhci.h +3 -0
@@ -286,6 +286,8 @@ struct xhci_op_regs {#define XDEV_U2 (0x2 << 5)#define XDEV_U3 (0x3 << 5)#define XDEV_INACTIVE (0x6 << 5) +#define XDEV_POLLING (0x7 << 5) +#define XDEV_COMP_MODE (0xa << 5)#define XDEV_RESUME (0xf << 5)/* true: port has power (see HCC_PPC) */ #define PORT_POWER (1 << 9)
@@ -1566,6 +1568,7 @@ struct xhci_hcd {/* For controllers with a broken beyond repair streams implementation */ #define XHCI_BROKEN_STREAMS (1 << 19)#define XHCI_PME_STUCK_QUIRK (1 << 20) +#define XHCI_MISSING_CAS (1 << 24)unsigned int num_active_eps;unsigned int limit_active_eps;/* There are two roothubs to keep track of bus suspend info for */
PATCH 149/306 batman-adv: fix splat on disabling an interface
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Lüssing <[email protected]>
commit 9799c50372b23ed774791bdb87d700f1286ee8a9 upstream.
As long as there is still a reference for a hard interface held, there might still be a forwarding packet relying on its attributes.
Therefore avoid setting hard_iface->soft_iface to NULL when disabling a hard interface.
This fixes the following, potential splat:
batman_adv: bat0: Interface deactivated: eth1
batman_adv: bat0: Removing interface: eth1
cgroup: new mount options do not match the existing superblock, will be ignored
batman_adv: bat0: Interface deactivated: eth3
batman_adv: bat0: Removing interface: eth3
------------[ cut here ]------------
WARNING: CPU: 3 PID: 1986 at ./net/batman-adv/bat_iv_ogm.c:549 batadv_iv_send_outstanding_bat_ogm_packet+0x145/0x643 [batman_adv]
Modules linked in: batman_adv(O-) <...>
CPU: 3 PID: 1986 Comm: kworker/u8:2 Tainted: G W O 4.6.0-rc6+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet [batman_adv]
0000000000000000 ffff88001d93bca0 ffffffff8126c26b 0000000000000000
0000000000000000 ffff88001d93bcf0 ffffffff81051615 ffff88001f19f818
000002251d93bd68 0000000000000046 ffff88001dc04a00 ffff88001becbe48
Call Trace:
[<ffffffff8126c26b>] dump_stack+0x67/0x90
[<ffffffff81051615>] __warn+0xc7/0xe5
[<ffffffff8105164b>] warn_slowpath_null+0x18/0x1a
[<ffffffffa0356f24>] batadv_iv_send_outstanding_bat_ogm_packet+0x145/0x643 [batman_adv]
[<ffffffff8108b01f>] ? __lock_is_held+0x32/0x54
[<ffffffff810689a2>] process_one_work+0x2a8/0x4f5
[<ffffffff81068856>] ? process_one_work+0x15c/0x4f5
[<ffffffff81068df2>] worker_thread+0x1d5/0x2c0
[<ffffffff81068c1d>] ? process_scheduled_works+0x2e/0x2e
[<ffffffff81068c1d>] ? process_scheduled_works+0x2e/0x2e
[<ffffffff8106dd90>] kthread+0xc0/0xc8
[<ffffffff8144de82>] ret_from_fork+0x22/0x40
[<ffffffff8106dcd0>] ? __init_kthread_worker+0x55/0x55
---[ end trace 647f9f325123dc05 ]---What happened here is, that there was still a forw_packet (here: a BATMAN IV OGM) in the queue of eth3 with the forw_packet->if_incoming set to eth1 and the forw_packet->if_outgoing set to eth3.
When eth3 is to be deactivated and removed, then this thread waits for the forw_packet queued on eth3 to finish. Because eth1 was deactivated and removed earlier and by that had forw_packet->if_incoming->soft_iface, set to NULL, the splat when trying to send/flush the OGM on eth3 occures.
--- net/batman-adv/hard-interface.c | 1 - 1 file changed, 1 deletion(-)
net/batman-adv/hard-interface.c +0 -1
@@ -522,7 +522,6 @@ void batadv_hardif_disable_interface(str }netdev_upper_dev_unlink (hard_iface->net_dev, hard_iface->soft_iface); - hard_iface->soft_iface =NULL ;batadv_hardif_free_ref (hard_iface); out:
Re: [PATCH 3.16 149/306] batman-adv: fix splat on disabling an interface
Quoted 7 lines · On Mittwoch, 15. Februar 2017 22:41:40 CET Ben Hutchings wrote:
3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Lüssing <[email protected]>
commit
9799c50372b23ed774791bdb87d700f1286ee8a9upstream.
Same objections as Linus had for the 3.2 patch:
Quoted 11 lines
Hi Ben,
This commit was reverted in
27915aa61060fd8954a68a86657784705955088a('batman-adv: Revert "fix splat on disabling an interface"').Greg dropped this patch from his stable queue back then, too [0].
Regards, Linus
Kind regards,
Sven
PATCH 150/306 USB: serial: fix potential NULL-dereference at probe
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 126d26f66d9890a69158812a6caa248c05359daa upstream.
Make sure we have at least one port before attempting to register a console.
Currently, at least one driver binds to a "dummy" interface and requests zero ports for it. Should such an interface also lack endpoints, we get a NULL-deref during probe.
--- drivers/usb/serial/usb-serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/serial/usb-serial.c +2 -1
@@ -1061,7 +1061,8 @@ static int usb_serial_probe(struct usb_i serial->disconnected =0 ; -usb_serial_console_init (serial->port[0 ]->minor); +if (num_ports >0 ) +usb_serial_console_init (serial->port[0 ]->minor); exit:module_put (type->driver.owner);return 0 ;
PATCH 151/306 drm/radeon/si_dpm: Limit clocks on HD86xx part
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tom St Denis <[email protected]>
commit fb9a5b0c1c9893db2e0d18544fd49e19d784a87d upstream.
Limit clocks on a specific HD86xx part to avoid crashes (while awaiting an appropriate PP fix).
--- drivers/gpu/drm/radeon/si_dpm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/radeon/si_dpm.c +6 -0
@@ -3028,6 +3028,12 @@ static void si_apply_state_adjust_rules( max_sclk =75000 ; max_mclk =80000 ; } +/* limit clocks on HD8600 series */ +if (rdev->pdev->device ==0x6660 && + rdev->pdev->revision ==0x83 ) { + max_sclk =75000 ; + max_mclk =80000 ; + }/* XXX validate the min clocks required for display */
PATCH 152/306 arm64: KVM: Take S1 walks into account when determining S2 write faults
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit 60e21a0ef54cd836b9eb22c7cb396989b5b11648 upstream.
The WnR bit in the HSR/ESR_EL2 indicates whether a data abort was generated by a read or a write instruction. For stage 2 data aborts generated by a stage 1 translation table walk (i.e. the actual page table access faults at EL2), the WnR bit therefore reports whether the instruction generating the walk was a load or a store, *not* whether the page table walker was reading or writing the entry.
For page tables marked as read-only at stage 2 (e.g. due to KSM merging them with the tables from another guest), this could result in livelock, where a page table walk generated by a load instruction attempts to set the access flag in the stage 1 descriptor, but fails to trigger CoW in the host since only a read fault is reported.
This patch modifies the arm64 kvm_vcpu_dabt_iswrite function to take into account stage 2 faults in stage 1 walks. Since DBM cannot be disabled at EL2 for CPUs that implement it, we assume that these faults are always causes by writes, avoiding the livelock situation at the expense of occasional, spurious CoWs.
We could, in theory, do a bit better by checking the guest TCR configuration and inspecting the page table to see why the PTE faulted. However, I doubt this is measurable in practice, and the threat of livelock is real.
[bwh: Backported to 3.16:
- Keep using ESR_EL2_WNR in the first part of the condition
- Adjust context]
--- arch/arm64/include/asm/kvm_emulate.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm64/include/asm/kvm_emulate.h +6 -5
@@ -135,11 +135,6 @@ static inline bool kvm_vcpu_dabt_isvalidreturn !!(kvm_vcpu_get_hsr (vcpu) &ESR_EL2_ISV ); } -static inline bool kvm_vcpu_dabt_iswrite (const struct kvm_vcpu *vcpu) -{ -return !!(kvm_vcpu_get_hsr (vcpu) &ESR_EL2_WNR ); -} -static inline bool kvm_vcpu_dabt_issext (const struct kvm_vcpu *vcpu) {return !!(kvm_vcpu_get_hsr (vcpu) &ESR_EL2_SSE );
@@ -160,6 +155,12 @@ static inline bool kvm_vcpu_dabt_iss1tw(return !!(kvm_vcpu_get_hsr (vcpu) &ESR_EL2_S1PTW ); } +static inline bool kvm_vcpu_dabt_iswrite (const struct kvm_vcpu *vcpu) +{ +return !!(kvm_vcpu_get_hsr (vcpu) &ESR_EL2_WNR ) || +kvm_vcpu_dabt_iss1tw (vcpu);/* AF/DBM update */ +} +static inline int kvm_vcpu_dabt_get_as (const struct kvm_vcpu *vcpu) {return 1 << ((kvm_vcpu_get_hsr (vcpu) &ESR_EL2_SAS ) >>ESR_EL2_SAS_SHIFT );
PATCH 153/306 powerpc: Convert cmp to cmpd in idle enter sequence
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Segher Boessenkool <[email protected]>
commit 80f23935cadb1c654e81951f5a8b7ceae0acc1b4 upstream.
PowerPC's "cmp" instruction has four operands. Normally people write "cmpw" or "cmpd" for the second cmp operand 0 or 1. But, frequently people forget, and write "cmp" with just three operands.
With older binutils this is silently accepted as if this was "cmpw", while often "cmpd" is wanted. With newer binutils GAS will complain about this for 64-bit code. For 32-bit code it still silently assumes "cmpw" is what is meant.
In this instance the code comes directly from ISA v2.07, including the cmp, but cmpd is correct. Backport to stable so that new toolchains can build old kernels.
--- arch/powerpc/kernel/idle_power7.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/idle_power7.S +1 -1
@@ -28,7 +28,7 @@ std r0,0(r1); \ ptesync; \ ld r0,0(r1); \ -1: cmp cr0,r0,r0; \ +1: cmpd cr0,r0,r0; \ bne 1b; \ IDLE_INST; \ b .
PATCH 154/306 ipv4: use the right lock for ping_group_range
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: WANG Cong <[email protected]>
commit 396a30cce15d084b2b1a395aa6d515c3d559c674 upstream.
This reverts commit a681574c99be23e4d20b769bf0e543239c364af5 ("ipv4: disable BH in set_ping_group_range()") because we never read ping_group_range in BH context (unlike local_port_range).
Then, since we already have a lock for ping_group_range, those using ip_local_ports.lock for ping_group_range are clearly typos.
We might consider to share a same lock for both ping_group_range and local_port_range w.r.t. space saving, but that should be for net-next.
[bwh: Backported to 3.16: we never applied "ipv4: disable BH in
set_ping_group_range()"]
--- net/ipv4/sysctl_net_ipv4.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/ipv4/sysctl_net_ipv4.c +4 -4
@@ -90,11 +90,11 @@ static void inet_get_ping_group_range_ta container_of(table->data, struct net, ipv4.ping_group_range.range);unsigned int seq;do { - seq =read_seqbegin (&net->ipv4.ip_local_ports.lock); + seq =read_seqbegin (&net->ipv4.ping_group_range.lock); *low = data[0 ]; *high = data[1 ]; - }while (read_seqretry (&net->ipv4.ip_local_ports.lock, seq)); + }while (read_seqretry (&net->ipv4.ping_group_range.lock, seq)); }/* Update system visible IP port range */
@@ -103,10 +103,10 @@ static void set_ping_group_range(structkgid_t *data = table->data;struct net *net = container_of(table->data, struct net, ipv4.ping_group_range.range); -write_seqlock (&net->ipv4.ip_local_ports.lock); +write_seqlock (&net->ipv4.ping_group_range.lock); data[0 ] = low; data[1 ] = high; -write_sequnlock (&net->ipv4.ip_local_ports.lock); +write_sequnlock (&net->ipv4.ping_group_range.lock); }/* Validate changes from /proc interface. */
PATCH 155/306 ACPI / APEI: Fix incorrect return value of ghes_proc()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Punit Agrawal <[email protected]>
commit 806487a8fc8f385af75ed261e9ab658fc845e633 upstream.
Although ghes_proc() tests for errors while reading the error status, it always return success (0). Fix this by propagating the return value.
--- drivers/acpi/apei/ghes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/ghes.c +1 -1
@@ -679,7 +679,7 @@ static int ghes_proc(struct ghes *ghes)ghes_do_proc (ghes, ghes->estatus); out:ghes_clear_estatus (ghes); -return 0 ; +return rc; }static void ghes_add_timer (struct ghes *ghes)
PATCH 156/306 dm table: fix missing dm_put_target_type() in dm_table_add_target()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "tang.junhui" <[email protected]>
commit dafa724bf582181d9a7d54f5cb4ca0bf8ef29269 upstream.
dm_get_target_type() was previously called so any error returned from dm_table_add_target() must first call dm_put_target_type(). Otherwise the DM target module's reference count will leak and the associated kernel module will be unable to be removed.
Also, leverage the fact that r is already -EINVAL and remove an extra newline.
--- drivers/md/dm-table.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/md/dm-table.c +9 -15
@@ -725,37 +725,32 @@ int dm_table_add_target(struct dm_table tgt->type =dm_get_target_type (type);if (!tgt->type) { -DMERR ("%s: %s: unknown target type" ,dm_device_name (t->md), - type); +DMERR ("%s: %s: unknown target type" ,dm_device_name (t->md), type);return -EINVAL ; }if (dm_target_needs_singleton (tgt->type)) {if (t->num_targets) { -DMERR ("%s: target type %s must appear alone in table" , -dm_device_name (t->md), type); -return -EINVAL ; + tgt->error ="singleton target type must appear alone in table" ; + goto bad; } t->singleton =1 ; }if (dm_target_always_writeable (tgt->type) && !(t->mode &FMODE_WRITE )) { -DMERR ("%s: target type %s may not be included in read-only tables" , -dm_device_name (t->md), type); -return -EINVAL ; + tgt->error ="target type may not be included in a read-only table" ; + goto bad; }if (t->immutable_target_type) {if (t->immutable_target_type != tgt->type) { -DMERR ("%s: immutable target type %s cannot be mixed with other target types" , -dm_device_name (t->md), t->immutable_target_type->name); -return -EINVAL ; + tgt->error ="immutable target type cannot be mixed with other target types" ; + goto bad; } }else if (dm_target_is_immutable (tgt->type)) {if (t->num_targets) { -DMERR ("%s: immutable target type %s cannot be mixed with other target types" , -dm_device_name (t->md), tgt->type->name); -return -EINVAL ; + tgt->error ="immutable target type cannot be mixed with other target types" ; + goto bad; } t->immutable_target_type = tgt->type; }
@@ -770,7 +765,6 @@ int dm_table_add_target(struct dm_table*/ if (!adjoin (t, tgt)) { tgt->error ="Gap in table" ; - r = -EINVAL ; goto bad; }
PATCH 157/306 mei: txe: don't clean an unprocessed interrupt cause.
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 43605e293eb13c07acb546c14f407a271837af17 upstream.
SEC registers are not accessible when the TXE device is in low power state, hence the SEC interrupt cannot be processed if device is not awake.
In some rare cases entrance to low power state (aliveness off) and input ready bits can be signaled at the same time, resulting in communication stall as input ready won't be signaled again after waking up. To resolve this IPC_HHIER_SEC bit in HHISR_REG should not be cleaned if the interrupt is not processed.
--- drivers/misc/mei/hw-txe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/misc/mei/hw-txe.c +4 -2
@@ -876,11 +876,13 @@ static bool mei_txe_check_and_ack_intrs( hisr =mei_txe_br_reg_read (hw,HISR_REG ); aliveness =mei_txe_aliveness_get (dev); -if (hhisr &IPC_HHIER_SEC && aliveness) +if (hhisr &IPC_HHIER_SEC && aliveness) { ipc_isr =mei_txe_sec_reg_read_silent (hw,SEC_IPC_HOST_INT_STATUS_REG ); -else + }else { ipc_isr =0 ; + hhisr &= ~IPC_HHIER_SEC ; + } generated = generated || (hisr & HISR_INT_STS_MSK) ||
PATCH 158/306 scsi: megaraid_sas: Fix data integrity failure for JBOD (passthrough) devices
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kashyap Desai <[email protected]>
commit 1e793f6fc0db920400574211c48f9157a37e3945 upstream.
Commit 02b01e010afe ("megaraid_sas: return sync cache call with success") modified the driver to successfully complete SYNCHRONIZE_CACHE commands without passing them to the controller. Disk drive caches are only explicitly managed by controller firmware when operating in RAID mode. So this commit effectively disabled writeback cache flushing for any drives used in JBOD mode, leading to data integrity failures.
[mkp: clarified patch description]
--- drivers/scsi/megaraid/megaraid_sas_base.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +5 -8
@@ -1586,16 +1586,13 @@ megasas_queue_command_lck(struct scsi_cm goto out_done; } -switch (scmd->cmnd[0 ]) { -case SYNCHRONIZE_CACHE : -/* -* FW takes care of flush cache on its own -* No need to send it down -*/ +/* +* FW takes care of flush cache on its own for Virtual Disk. +* No need to send it down for VD. For JBOD send SYNCHRONIZE_CACHE to FW. +*/ +if ((scmd->cmnd[0 ] ==SYNCHRONIZE_CACHE ) &&MEGASAS_IS_LOGICAL (scmd)) { scmd->result =DID_OK <<16 ; goto out_done; -default : -break ; }if (instance->instancet->build_and_issue_cmd (instance, scmd)) {
PATCH 159/306 hv: do not lose pending heartbeat vmbus packets
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
commit 407a3aee6ee2d2cb46d9ba3fc380bc29f35d020c upstream.
The host keeps sending heartbeat packets independent of the
guest responding to them. Even though we respond to the heartbeat messages at interrupt level, we can have situations where there maybe multiple heartbeat messages pending that have not been responded to. For instance this occurs when the VM is paused and the host continues to send the heartbeat messages. Address this issue by draining and responding to all
the heartbeat messages that maybe pending.
--- drivers/hv/hv_util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/hv/hv_util.c +7 -3
@@ -283,10 +283,14 @@ static void heartbeat_onchannelcallback(u8 *hbeat_txf_buf = util_heartbeat.recv_buffer;struct icmsg_negotiate *negop =NULL ; -vmbus_recvpacket (channel, hbeat_txf_buf, -PAGE_SIZE , &recvlen, &requestid); +while (1 ) { + +vmbus_recvpacket (channel, hbeat_txf_buf, +PAGE_SIZE , &recvlen, &requestid); + +if (!recvlen) +break ; -if (recvlen >0 ) { icmsghdrp = (struct icmsg_hdr *)&hbeat_txf_buf[sizeof (struct vmbuspipe_hdr )];
PATCH 160/306 ALSA: hda - Fix surround output pins for ASRock B150M mobo
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 1a3f099101b85cc93d864eb030d97e7725c72ea7 upstream.
ASRock B150M Pro4/D3 mobo with ALC892 codec doesn't seem to provide proper pins for the surround outputs, hence we need to specify the pincfgs manually with a couple of other corrections.
--- sound/pci/hda/patch_realtek.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/pci/hda/patch_realtek.c +12 -0
@@ -5842,6 +5842,7 @@ enum { ALC662_FIXUP_ASUS_Nx50, ALC668_FIXUP_ASUS_Nx51,ALC662_FIXUP_ACER_VERITON , + ALC892_FIXUP_ASROCK_MOBO, }; static const struct hda_fixup alc662_fixups[] = {
@@ -6090,6 +6091,16 @@ static const struct hda_fixup alc662_fix { } } }, + [ALC892_FIXUP_ASROCK_MOBO ] = { + .type =HDA_FIXUP_PINS , + .v.pins = (const struct hda_pintbl []) { + {0x15 ,0x40f000f0 },/* disabled */ + {0x16 ,0x40f000f0 },/* disabled */ + {0x18 ,0x01014011 },/* LO */ + {0x1a ,0x01014012 },/* LO */ + { } + } + }, };static const struct snd_pci_quirk alc662_fixup_tbl[] = {
@@ -6124,6 +6135,7 @@ static const struct snd_pci_quirk alc662SND_PCI_QUIRK (0x144d ,0xc051 ,"Samsung R720" ,ALC662_FIXUP_IDEAPAD ),SND_PCI_QUIRK (0x17aa ,0x38af ,"Lenovo Ideapad Y550P" ,ALC662_FIXUP_IDEAPAD ),SND_PCI_QUIRK (0x17aa ,0x3a0d ,"Lenovo Ideapad Y550" ,ALC662_FIXUP_IDEAPAD ), +SND_PCI_QUIRK (0x1849 ,0x5892 ,"ASRock B150M" ,ALC892_FIXUP_ASROCK_MOBO ),SND_PCI_QUIRK (0x19da ,0xa130 ,"Zotac Z68" ,ALC662_FIXUP_ZOTAC_Z68 ),SND_PCI_QUIRK (0x1b0a ,0x01b8 ,"ACER Veriton" ,ALC662_FIXUP_ACER_VERITON ), SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
PATCH 161/306 staging: iio: ad5933: avoid uninitialized variable in error case
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 34eee70a7b82b09dbda4cb453e0e21d460dae226 upstream.
The ad5933_i2c_read function returns an error code to indicate whether it could read data or not. However ad5933_work() ignores this return code and just accesses the data unconditionally, which gets detected by gcc as a possible bug:
drivers/staging/iio/impedance-analyzer/ad5933.c: In function 'ad5933_work':drivers/staging/iio/impedance-analyzer/ad5933.c:649:16: warning: 'status' may be used uninitialized in this function [-Wmaybe-uninitialized]
This adds minimal error handling so we only evaluate the data if it was correctly read.
--- drivers/staging/iio/impedance-analyzer/ad5933.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +10 -7
@@ -646,6 +646,7 @@ static void ad5933_work(struct work_strustruct iio_dev *indio_dev =i2c_get_clientdata (st->client);signed short buf[2 ];unsigned char status; +int ret;mutex_lock (&indio_dev->mlock);if (st->state ==AD5933_CTRL_INIT_START_FREQ ) {
@@ -653,19 +654,22 @@ static void ad5933_work(struct work_struad5933_cmd (st,AD5933_CTRL_START_SWEEP ); st->state =AD5933_CTRL_START_SWEEP ;schedule_delayed_work (&st->work, st->poll_time_jiffies); -mutex_unlock (&indio_dev->mlock); -return ; + goto out; } -ad5933_i2c_read (st->client,AD5933_REG_STATUS ,1 , &status); + ret =ad5933_i2c_read (st->client,AD5933_REG_STATUS ,1 , &status); +if (ret) + goto out;if (status &AD5933_STAT_DATA_VALID ) {int scan_count =bitmap_weight (indio_dev->active_scan_mask, indio_dev->masklength); -ad5933_i2c_read (st->client, + ret =ad5933_i2c_read (st->client,test_bit (1 , indio_dev->active_scan_mask) ?AD5933_REG_REAL_DATA :AD5933_REG_IMAG_DATA , scan_count *2 , (u8 *)buf); +if (ret) + goto out;if (scan_count ==2 ) { buf[0 ] =be16_to_cpu (buf[0 ]);
@@ -677,8 +681,7 @@ static void ad5933_work(struct work_stru }else {/* no data available - try again later */ schedule_delayed_work (&st->work, st->poll_time_jiffies); -mutex_unlock (&indio_dev->mlock); -return ; + goto out; }if (status &AD5933_STAT_SWEEP_DONE ) {
@@ -690,7 +693,7 @@ static void ad5933_work(struct work_struad5933_cmd (st,AD5933_CTRL_INC_FREQ );schedule_delayed_work (&st->work, st->poll_time_jiffies); } - +out:mutex_unlock (&indio_dev->mlock); }
PATCH 162/306 drm/radeon: drop register readback in cayman_cp_int_cntl_setup
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Stach <[email protected]>
commit 537b4b462caa8bfb9726d9695b8e56e2d5e6b41e upstream.
The read is taking a considerable amount of time (about 50us on this machine). The register does not ever hold anything other than the ring ID that is updated in this exact function, so there is no need for the read modify write cycle.
This chops off a big chunk of the time spent in hardirq disabled context, as this function is called multiple times in the interrupt handler. With this change applied radeon won't show up in the list of the worst IRQ latency offenders anymore, where it was a regular before.
--- drivers/gpu/drm/radeon/ni.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/radeon/ni.c +1 -3
@@ -1333,9 +1333,7 @@ static void cayman_pcie_gart_fini(structvoid cayman_cp_int_cntl_setup (struct radeon_device *rdev,int ring,u32 cp_int_cntl) { -u32 srbm_gfx_cntl =RREG32 (SRBM_GFX_CNTL ) & ~3 ; - -WREG32 (SRBM_GFX_CNTL , srbm_gfx_cntl | (ring &3 )); +WREG32 (SRBM_GFX_CNTL ,RINGID (ring));WREG32 (CP_INT_CNTL , cp_int_cntl); }
PATCH 163/306 KVM: MIPS: Make ERET handle ERL before EXL
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit ede5f3e7b54a4347be4d8525269eae50902bd7cd upstream.
The ERET instruction to return from exception is used for returning from exception level (Status.EXL) and error level (Status.ERL). If both bits are set however we should be returning from ERL first, as ERL can interrupt EXL, for example when an NMI is taken. KVM however checks EXL first.
Fix the order of the checks to match the pseudocode in the instruction set manual.
--- arch/mips/kvm/kvm_mips_emul.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/mips/kvm/kvm_mips_emul.c +4 -4
@@ -761,15 +761,15 @@ enum emulation_result kvm_mips_emul_eretstruct mips_coproc *cop0 = vcpu->arch.cop0;enum emulation_result er =EMULATE_DONE ; -if (kvm_read_c0_guest_status (cop0) &ST0_EXL ) { +if (kvm_read_c0_guest_status (cop0) &ST0_ERL ) { +kvm_clear_c0_guest_status (cop0,ST0_ERL ); + vcpu->arch.pc =kvm_read_c0_guest_errorepc (cop0); + }else if (kvm_read_c0_guest_status (cop0) &ST0_EXL ) {kvm_debug ("[%#lx] ERET to %#lx\n" , vcpu->arch.pc,kvm_read_c0_guest_epc (cop0));kvm_clear_c0_guest_status (cop0,ST0_EXL ); vcpu->arch.pc =kvm_read_c0_guest_epc (cop0); - }else if (kvm_read_c0_guest_status (cop0) &ST0_ERL ) { -kvm_clear_c0_guest_status (cop0,ST0_ERL ); - vcpu->arch.pc =kvm_read_c0_guest_errorepc (cop0); }else {printk ("[%#lx] ERET when MIPS_SR_EXL|MIPS_SR_ERL == 0\n" , vcpu->arch.pc);
PATCH 164/306 MIPS: KVM: Fix unused variable build warning
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Mc Guire <[email protected]>
commit 5f508c43a7648baa892528922402f1e13f258bd4 upstream.
As kvm_mips_complete_mmio_load() did not yet modify PC at this point as James Hogans <[email protected]> explained the curr_pc variable and the comments along with it can be dropped.
Patchwork: https://patchwork.linux-mips.org/patch/9993/
--- arch/mips/kvm/kvm_mips_emul.c | 6 ------ 1 file changed, 6 deletions(-)
arch/mips/kvm/kvm_mips_emul.c +0 -6
@@ -2172,7 +2172,6 @@ kvm_mips_complete_mmio_load(struct kvm_v {unsigned long *gpr = &vcpu->arch.gprs[vcpu->arch.io_gpr];enum emulation_result er =EMULATE_DONE ; -unsigned long curr_pc;if (run->mmio.len >sizeof (*gpr)) {printk ("Bad MMIO length: %d" , run->mmio.len);
@@ -2180,11 +2179,6 @@ kvm_mips_complete_mmio_load(struct kvm_v goto done; } -/* -* Update PC and hold onto current PC in case there is -* an error and we want to rollback the PC -*/ - curr_pc = vcpu->arch.pc; er =update_pc (vcpu, vcpu->arch.pending_load_cause);if (er ==EMULATE_FAIL )return er;
PATCH 165/306 KVM: MIPS: Precalculate MMIO load resume PC
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit e1e575f6b026734be3b1f075e780e91ab08ca541 upstream.
The advancing of the PC when completing an MMIO load is done before re-entering the guest, i.e. before restoring the guest ASID. However if the load is in a branch delay slot it may need to access guest code to read the prior branch instruction. This isn't safe in TLB mapped code at the moment, nor in the future when we'll access unmapped guest segments using direct user accessors too, as it could read the branch from host user memory instead.
Therefore calculate the resume PC in advance while we're still in the right context and save it in the new vcpu->arch.io_pc (replacing the no longer needed vcpu->arch.pending_load_cause), and restore it on MMIO completion.
---
arch/mips/include/asm/kvm_host.h +4 -3
@@ -403,7 +403,10 @@ struct kvm_vcpu_arch {/* Host KSEG0 address of the EI/DI offset */ void *kseg0_commpage; -u32 io_gpr;/* GPR used as IO source/target */ +/* Resume PC after MMIO completion */ +unsigned long io_pc; +/* GPR used as IO source/target */ +u32 io_gpr;struct hrtimer comparecount_timer;/* Count timer control KVM register */
@@ -425,8 +428,6 @@ struct kvm_vcpu_arch {/* Bitmask of pending exceptions to be cleared */ unsigned long pending_exceptions_clr; -unsigned long pending_load_cause; -/* Save/Restore the entryhi register when are are preempted/scheduled back in */ unsigned long preempt_entryhi;
arch/mips/kvm/kvm_mips_emul.c +15 -10
@@ -1328,6 +1328,7 @@ kvm_mips_emulate_load(uint32_t inst, uin struct kvm_run *run, struct kvm_vcpu *vcpu) { enum emulation_result er = EMULATE_DO_MMIO; +unsigned long curr_pc;int32_t op, base, rt, offset;uint32_t bytes;
@@ -1336,7 +1337,18 @@ kvm_mips_emulate_load(uint32_t inst, uin offset = inst &0xffff ; op = (inst >>26 ) &0x3f ; - vcpu->arch.pending_load_cause = cause; +/* +* Find the resume PC now while we have safe and easy access to the +* prior branch instruction, and save it for +* kvm_mips_complete_mmio_load() to restore later. +*/ + curr_pc = vcpu->arch.pc; + er =update_pc (vcpu, cause); +if (er ==EMULATE_FAIL ) +return er; + vcpu->arch.io_pc = vcpu->arch.pc; + vcpu->arch.pc = curr_pc; + vcpu->arch.io_gpr = rt;switch (op) {
@@ -2179,9 +2191,8 @@ kvm_mips_complete_mmio_load(struct kvm_v goto done; } - er =update_pc (vcpu, vcpu->arch.pending_load_cause); -if (er ==EMULATE_FAIL ) -return er; +/* Restore saved resume PC */ + vcpu->arch.pc = vcpu->arch.io_pc;switch (run->mmio.len) {case 4 :
@@ -2203,12 +2214,6 @@ kvm_mips_complete_mmio_load(struct kvm_vbreak ; } -if (vcpu->arch.pending_load_cause &CAUSEF_BD ) -kvm_debug - ("[%#lx] Completing %d byte BD Load to gpr %d (0x%08lx) type %d\n" , - vcpu->arch.pc, run->mmio.len, vcpu->arch.io_gpr, *gpr, - vcpu->mmio_needed); - done:return er; }
PATCH 166/306 drm/radeon/si_dpm: workaround for SI kickers
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 7dc86ef5ac91642dfc3eb93ee0f0458e702a343e upstream.
Consolidate existing quirks. Fixes stability issues on some kickers.
--- drivers/gpu/drm/radeon/si_dpm.c | 59 ++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 16 deletions(-)
drivers/gpu/drm/radeon/si_dpm.c +43 -16
@@ -2944,6 +2944,49 @@ static void si_apply_state_adjust_rules(int i;struct si_dpm_quirk *p = si_dpm_quirk_list; +/* limit all SI kickers */ +if (rdev->family ==CHIP_PITCAIRN ) { +if ((rdev->pdev->revision ==0x81 ) || + (rdev->pdev->device ==0x6810 ) || + (rdev->pdev->device ==0x6811 ) || + (rdev->pdev->device ==0x6816 ) || + (rdev->pdev->device ==0x6817 ) || + (rdev->pdev->device ==0x6806 )) + max_mclk =120000 ; + }else if (rdev->family ==CHIP_VERDE ) { +if ((rdev->pdev->revision ==0x81 ) || + (rdev->pdev->revision ==0x83 ) || + (rdev->pdev->revision ==0x87 ) || + (rdev->pdev->device ==0x6820 ) || + (rdev->pdev->device ==0x6821 ) || + (rdev->pdev->device ==0x6822 ) || + (rdev->pdev->device ==0x6823 ) || + (rdev->pdev->device ==0x682A ) || + (rdev->pdev->device ==0x682B )) { + max_sclk =75000 ; + max_mclk =80000 ; + } + }else if (rdev->family ==CHIP_OLAND ) { +if ((rdev->pdev->revision ==0xC7 ) || + (rdev->pdev->revision ==0x80 ) || + (rdev->pdev->revision ==0x81 ) || + (rdev->pdev->revision ==0x83 ) || + (rdev->pdev->device ==0x6604 ) || + (rdev->pdev->device ==0x6605 )) { + max_sclk =75000 ; + max_mclk =80000 ; + } + }else if (rdev->family ==CHIP_HAINAN ) { +if ((rdev->pdev->revision ==0x81 ) || + (rdev->pdev->revision ==0x83 ) || + (rdev->pdev->revision ==0xC3 ) || + (rdev->pdev->device ==0x6664 ) || + (rdev->pdev->device ==0x6665 ) || + (rdev->pdev->device ==0x6667 )) { + max_sclk =75000 ; + max_mclk =80000 ; + } + }/* Apply dpm quirks */ while (p && p->chip_device !=0 ) { if (rdev->pdev->vendor == p->chip_vendor &&
@@ -3018,22 +3061,6 @@ static void si_apply_state_adjust_rules( ps->performance_levels[i].sclk = max_sclk; } } -/* limit mclk on all R7 370 parts for stability */ -if (rdev->pdev->device ==0x6811 && - rdev->pdev->revision ==0x81 ) - max_mclk =120000 ; -/* limit sclk/mclk on Jet parts for stability */ -if (rdev->pdev->device ==0x6665 && - rdev->pdev->revision ==0xc3 ) { - max_sclk =75000 ; - max_mclk =80000 ; - } -/* limit clocks on HD8600 series */ -if (rdev->pdev->device ==0x6660 && - rdev->pdev->revision ==0x83 ) { - max_sclk =75000 ; - max_mclk =80000 ; - }/* XXX validate the min clocks required for display */
PATCH 167/306 scsi: scsi_debug: Fix memory leak if LBP enabled and module is unloaded
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Ewan D. Milne" <[email protected]>
commit 4d2b496f19f3c2cfaca1e8fa0710688b5ff3811d upstream.
map_storep was not being vfree()'d in the module_exit call.
--- drivers/scsi/scsi_debug.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/scsi_debug.c +1 -0
@@ -3478,6 +3478,7 @@ static void __exit scsi_debug_exit(void)bus_unregister (&pseudo_lld_bus);root_device_unregister (pseudo_primary); +vfree (map_storep);if (dif_storep)vfree (dif_storep);
PATCH 168/306 scsi: arcmsr: Send SYNCHRONIZE_CACHE command to firmware
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ching Huang <[email protected]>
commit 2bf7dc8443e113844d078fd6541b7f4aa544f92f upstream.
The arcmsr driver failed to pass SYNCHRONIZE CACHE to controller firmware. Depending on how drive caches are handled internally by controller firmware this could potentially lead to data integrity problems.
Ensure that cache flushes are passed to the controller.
[mkp: applied by hand and removed unused vars]
--- drivers/scsi/arcmsr/arcmsr_hba.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/scsi/arcmsr/arcmsr_hba.c +0 -9
@@ -2068,18 +2068,9 @@ static int arcmsr_queue_command_lck(strustruct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;struct CommandControlBlock *ccb;int target = cmd->device->id; -int lun = cmd->device->lun; -uint8_t scsicmd = cmd->cmnd[0 ]; cmd->scsi_done = done; cmd->host_scribble =NULL ; cmd->result =0 ; -if ((scsicmd ==SYNCHRONIZE_CACHE ) ||(scsicmd ==SEND_DIAGNOSTIC )){ -if (acb->devstate[target][lun] ==ARECA_RAID_GONE ) { - cmd->result = (DID_NO_CONNECT <<16 ); - } - cmd->scsi_done (cmd); -return 0 ; - }if (target ==16 ) {/* virtual device for iop message transfer */ arcmsr_handle_virtual_command (acb, cmd);
PATCH 169/306 ALSA: usb-audio: Add quirk for Syntek STK1160
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marcel Hasler <[email protected]>
commit bdc3478f90cd4d2928197f36629d5cf93b64dbe9 upstream.
The stk1160 chip needs QUIRK_AUDIO_ALIGN_TRANSFER. This patch resolves the issue reported on the mailing list
(http://marc.info/?l=linux-sound&m=139223599126215&w=2) and also fixes bug 180071 (https://bugzilla.kernel.org/show_bug.cgi?id=180071).
--- sound/usb/quirks-table.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
sound/usb/quirks-table.h +17 -0
@@ -2953,6 +2953,23 @@ AU0828_DEVICE(0x2040, 0x7260, "HauppaugeAU0828_DEVICE (0x2040 ,0x7213 ,"Hauppauge" ,"HVR-950Q" ),AU0828_DEVICE (0x2040 ,0x7270 ,"Hauppauge" ,"HVR-950Q" ), +/* Syntek STK1160 */ +{ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | +USB_DEVICE_ID_MATCH_INT_CLASS | +USB_DEVICE_ID_MATCH_INT_SUBCLASS , + .idVendor = 0x05e1, + .idProduct = 0x0408, + .bInterfaceClass = USB_CLASS_AUDIO, + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { + .vendor_name ="Syntek" , + .product_name ="STK1160" , + .ifnum =QUIRK_ANY_INTERFACE , + .type =QUIRK_AUDIO_ALIGN_TRANSFER + } +}, + /* Digidesign Mbox */ {/* Thanks to Clemens Ladisch <[email protected]> */
PATCH 170/306 tty: vt, fix bogus division in csi_J
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby <[email protected]>
commit 42acfc6615f47e465731c263bee0c799edb098f2 upstream.
In csi_J(3), the third parameter of scr_memsetw (vc_screenbuf_size) is divided by 2 inappropriatelly. But scr_memsetw expects size, not count, because it divides the size by 2 on its own before doing actual memset-by-words.
So remove the bogus division.
--- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vt/vt.c +1 -1
@@ -1164,7 +1164,7 @@ static void csi_J(struct vc_data *vc, inbreak ;case 3 :/* erase scroll-back buffer (and whole display) */ scr_memsetw (vc->vc_screenbuf, vc->vc_video_erase_char, - vc->vc_screenbuf_size >>1 ); + vc->vc_screenbuf_size);set_origin (vc);if (CON_IS_VISIBLE (vc))update_screen (vc);
PATCH 171/306 tty: limit terminal size to 4M chars
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Vyukov <[email protected]>
commit 32b2921e6a7461fe63b71217067a6cf4bddb132f upstream.
Size of kmalloc() in vc_do_resize() is controlled by user. Too large kmalloc() size triggers WARNING message on console. Put a reasonable upper bound on terminal size to prevent WARNINGs.
--- drivers/tty/vt/vt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/vt/vt.c +2 -0
@@ -863,6 +863,8 @@ static int vc_do_resize(struct tty_strucif (new_cols == vc->vc_cols && new_rows == vc->vc_rows)return 0 ; +if (new_screen_size > (4 <<20 )) +return -EINVAL ; newscreen =kmalloc (new_screen_size,GFP_USER );if (!newscreen)return -ENOMEM ;
PATCH 172/306 vt: clear selection before resizing
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Scot Doyle <[email protected]>
commit 009e39ae44f4191188aeb6dfbf661b771dbbe515 upstream.
When resizing a vt its selection may exceed the new size, resulting in an invalid memory access [1]. Clear the selection before resizing.
[1] http://lkml.kernel.org/r/CACT4Y+acDTwy4umEvf5ROBGiRJNrxHN4Cn5szCXE5Jw-d1B=Xw@mail.gmail.com
--- drivers/tty/vt/vt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/vt/vt.c +3 -0
@@ -869,6 +869,9 @@ static int vc_do_resize(struct tty_strucif (!newscreen)return -ENOMEM ; +if (vc == sel_cons) +clear_selection (); + old_rows = vc->vc_rows; old_row_size = vc->vc_size_row;
PATCH 173/306 netfilter: nf_conntrack_sip: extend request line validation
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ulrich Weber <[email protected]>
commit 444f901742d054a4cd5ff045871eac5131646cfb upstream.
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 handler = &sip_handlers[i];if (handler->request ==NULL )continue ; -if (*datalen < handler->len || +if (*datalen < handler->len +2 ||strnicmp (*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 ) {
PATCH 174/306 netfilter: nf_tables: fix type mismatch with error return from nft_parse_u32_check
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "John W. Linville" <[email protected]>
commit f1d505bb762e30bf316ff5d3b604914649d6aed3 upstream.
Commit 36b701fae12ac ("netfilter: nf_tables: validate maximum value of u32 netlink attributes") introduced nft_parse_u32_check with a return value of "unsigned int", yet on error it returns "-ERANGE".
This patch corrects the mismatch by changing the return value to "int", which happens to match the actual users of nft_parse_u32_check already.
Found by Coverity, CID 1373930.
Note that commit 21a9e0f1568ea ("netfilter: nft_exthdr: fix error handling in nft_exthdr_init()) attempted to address the issue, but did not address the return type of nft_parse_u32_check.
--- include/net/netfilter/nf_tables.h | 2 +- net/netfilter/nf_tables_api.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/net/netfilter/nf_tables.h +1 -1
@@ -113,7 +113,7 @@ static inline enum nft_registers nft_typreturn type ==NFT_DATA_VERDICT ?NFT_REG_VERDICT :NFT_REG_1 ; } -unsigned int nft_parse_u32_check (const struct nlattr *attr,int max,u32 *dest); +int nft_parse_u32_check (const struct nlattr *attr,int max,u32 *dest);int nft_validate_input_register (enum nft_registers reg);int nft_validate_output_register (enum nft_registers reg); int nft_validate_data_load(const struct nft_ctx *ctx, enum nft_registers reg,
net/netfilter/nf_tables_api.c +1 -1
@@ -3723,7 +3723,7 @@ static int nf_tables_check_loops(const s* Otherwise a 0 is returned and the attribute value is stored in the * destination variable. */ -unsigned int nft_parse_u32_check (const struct nlattr *attr,int max,u32 *dest) +int nft_parse_u32_check (const struct nlattr *attr,int max,u32 *dest) {u32 val;
PATCH 175/306 btrfs: fix races on root_log_ctx lists
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit 570dd45042a7c8a7aba1ee029c5dd0f5ccf41b9b upstream.
btrfs_remove_all_log_ctxs takes a shortcut where it avoids walking the list because it knows all of the waiters are patiently waiting for the commit to finish.
But, there's a small race where btrfs_sync_log can remove itself from the list if it finds a log commit is already done. Also, it uses list_del_init() to remove itself from the list, but there's no way to know if btrfs_remove_all_log_ctxs has already run, so we don't know for sure if it is safe to call list_del_init().
This gets rid of all the shortcuts for btrfs_remove_all_log_ctxs(), and just calls it with the proper locking.
This is part two of the corruption fixed by cbd60aa7cd1. I should have done this in the first place, but convinced myself the optimizations were safe. A 12 hour run of dbench 2048 will eventually trigger a list debug WARN_ON for the list_del_init() in btrfs_sync_log().
--- fs/btrfs/tree-log.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
fs/btrfs/tree-log.c +6 -14
@@ -2449,14 +2449,12 @@ static inline void btrfs_remove_all_log_ int index, int error) {struct btrfs_log_ctx *ctx; +struct btrfs_log_ctx *safe; -if (!error) { -INIT_LIST_HEAD (&root->log_ctxs[index]); -return ; - } - -list_for_each_entry (ctx, &root->log_ctxs[index], list) +list_for_each_entry_safe (ctx, safe, &root->log_ctxs[index], list) { +list_del_init (&ctx->list); ctx->log_ret = error; + }INIT_LIST_HEAD (&root->log_ctxs[index]); }
@@ -2686,13 +2684,9 @@ int btrfs_sync_log(struct btrfs_trans_hamutex_unlock (&root->log_mutex); out_wake_log_root: -/* -* We needn't get log_mutex here because we are sure all -* the other tasks are blocked. -*/ +mutex_lock (&log_root_tree->log_mutex);btrfs_remove_all_log_ctxs (log_root_tree, index2, ret); -mutex_lock (&log_root_tree->log_mutex); log_root_tree->log_transid_committed++;atomic_set (&log_root_tree->log_commit[index2],0 );mutex_unlock (&log_root_tree->log_mutex);
@@ -2700,10 +2694,8 @@ out_wake_log_root:if (waitqueue_active (&log_root_tree->log_commit_wait[index2]))wake_up (&log_root_tree->log_commit_wait[index2]); out: -/* See above. */ -btrfs_remove_all_log_ctxs (root, index1, ret); -mutex_lock (&root->log_mutex); +btrfs_remove_all_log_ctxs (root, index1, ret); root->log_transid_committed++;atomic_set (&root->log_commit[index1],0 );mutex_unlock (&root->log_mutex);
PATCH 176/306 lib/genalloc.c: start search from start of chunk
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Mentz <[email protected]>
commit 62e931fac45b17c2a42549389879411572f75804 upstream.
gen_pool_alloc_algo() iterates over the chunks of a pool trying to find a contiguous block of memory that satisfies the allocation request.
The shortcut
if (size > atomic_read(&chunk->avail)) continue;
makes the loop skip over chunks that do not have enough bytes left to fulfill the request. There are two situations, though, where an allocation might still fail:
(1) The available memory is not contiguous, i.e. the request cannot be fulfilled due to external fragmentation.
(2) A race condition. Another thread runs the same code concurrently and is quicker to grab the available memory.
In those situations, the loop calls pool->algo() to search the entire chunk, and pool->algo() returns some value that is >= end_bit to indicate that the search failed. This return value is then assigned to start_bit. The variables start_bit and end_bit describe the range that should be searched, and this range should be reset for every chunk that is searched. Today, the code fails to reset start_bit to 0. As a result, prefixes of subsequent chunks are ignored. Memory allocations might fail even though there is plenty of room left in these prefixes of those other chunks.
--- lib/genalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/genalloc.c +2 -1
@@ -273,7 +273,7 @@ unsigned long gen_pool_alloc(struct gen_struct gen_pool_chunk *chunk;unsigned long addr =0 ;int order = pool->min_alloc_order; -int nbits, start_bit =0 , end_bit, remain; +int nbits, start_bit, end_bit, remain;#ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG BUG_ON (in_nmi ());
@@ -288,6 +288,7 @@ unsigned long gen_pool_alloc(struct gen_if (size >atomic_read (&chunk->avail))continue ; + start_bit =0 ; end_bit =chunk_size (chunk) >> order; retry: start_bit = pool->algo(chunk->bits, end_bit, start_bit, nbits,
PATCH 177/306 s390/hypfs: Use get_free_page() instead of kmalloc to ensure page alignment
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michael Holzheu <[email protected]>
commit 237d6e6884136923b6bd26d5141ebe1d065960c9 upstream.
Since commit d86bd1bece6f ("mm/slub: support left redzone") it is no longer guaranteed that kmalloc(PAGE_SIZE) returns page aligned memory.
After the above commit we get an error for diag224 because aligned memory is required. This leads to the following user visible error:
# mount none -t s390_hypfs /sys/hypervisor/ mount: unknown filesystem type 's390_hypfs'
# dmesg | grep hypfs
hypfs.cccfb8: The hardware system does not provide all functions
required by hypfs
hypfs.7a79f0: Initialization of hypfs failed with rc=-61Fix this problem and use get_free_page() instead of kmalloc() to get correctly aligned memory.
--- arch/s390/hypfs/hypfs_diag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/hypfs/hypfs_diag.c +3 -3
@@ -517,11 +517,11 @@ static int diag224(void *ptr)static int diag224_get_name_table (void ) {/* memory must be below 2GB */ - diag224_cpu_names =kmalloc (PAGE_SIZE ,GFP_KERNEL |GFP_DMA ); + diag224_cpu_names = (char *)__get_free_page (GFP_KERNEL |GFP_DMA );if (!diag224_cpu_names)return -ENOMEM ;if (diag224 (diag224_cpu_names)) { -kfree (diag224_cpu_names); +free_page ((unsigned long ) diag224_cpu_names);return -EOPNOTSUPP ; }EBCASC (diag224_cpu_names +16 , (*diag224_cpu_names +1 ) *16 );
@@ -530,7 +530,7 @@ static int diag224_get_name_table(void)static void diag224_delete_name_table (void ) { -kfree (diag224_cpu_names); +free_page ((unsigned long ) diag224_cpu_names); }static int diag224_idx2name (int index,char *name)
PATCH 178/306 KVM: x86: fix wbinvd_dirty_mask use-after-free
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ido Yariv <[email protected]>
commit bd768e146624cbec7122ed15dead8daa137d909d upstream.
vcpu->arch.wbinvd_dirty_mask may still be used after freeing it, corrupting memory. For example, the following call trace may set a bit in an already freed cpu mask:
kvm_arch_vcpu_load
vcpu_load
vmx_free_vcpu_nested
vmx_free_vcpu
kvm_arch_vcpu_free
Fix this by deferring freeing of wbinvd_dirty_mask.
--- arch/x86/kvm/x86.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/x86.c +3 -1
@@ -6809,11 +6809,13 @@ void kvm_put_guest_fpu(struct kvm_vcpu *void kvm_arch_vcpu_free (struct kvm_vcpu *vcpu) { +void *wbinvd_dirty_mask = vcpu->arch.wbinvd_dirty_mask; +kvmclock_reset (vcpu); -free_cpumask_var (vcpu->arch.wbinvd_dirty_mask);fx_free (vcpu); kvm_x86_ops->vcpu_free (vcpu); +free_cpumask_var (wbinvd_dirty_mask); } struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
PATCH 179/306 GenWQE: Fix bad page access during abort of resource allocation
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gerald Schaefer <[email protected]>
commit a7a7aeefbca2982586ba2c9fd7739b96416a6d1d upstream.
When interrupting an application which was allocating DMAable memory, it was possible, that the DMA memory was deallocated twice, leading to the error symptoms below.
Thanks to Gerald, who analyzed the problem and provided this patch.
I agree with his analysis of the problem: ddcb_cmd_fixups() -> genwqe_alloc_sync_sgl() (fails in f/lpage, but sgl->sgl != NULL and f/lpage maybe also != NULL) -> ddcb_cmd_cleanup() -> genwqe_free_sync_sgl() (double free, because sgl->sgl != NULL and f/lpage maybe also != NULL)
In this scenario we would have exactly the kind of double free that would explain the WARNING / Bad page state, and as expected it is caused by broken error handling (cleanup).
Using the Ubuntu git source, tag Ubuntu-4.4.0-33.52, he was able to reproduce the "Bad page state" issue, and with the patch on top he could not reproduce it any more.
------------[ cut here ]------------
WARNING: at /build/linux-o03cxz/linux-4.4.0/arch/s390/include/asm/pci_dma.h:141
Modules linked in: qeth_l2 ghash_s390 prng aes_s390 des_s390 des_generic sha512_s390 sha256_s390 sha1_s390 sha_common genwqe_card qeth crc_itu_t qdio ccwgroup vmur dm_multipath dasd_eckd_mod dasd_mod
CPU: 2 PID: 3293 Comm: genwqe_gunzip Not tainted 4.4.0-33-generic #52-Ubuntu
task: 0000000032c7e270 ti: 00000000324e4000 task.ti: 00000000324e4000
Krnl PSW : 0404c00180000000 0000000000156346 (dma_update_cpu_trans+0x9e/0xa8)
R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 EA:3
Krnl GPRS: 00000000324e7bcd 0000000000c3c34a 0000000027628298 000000003215b400
0000000000000400 0000000000001fff 0000000000000400 0000000116853000
07000000324e7b1e 0000000000000001 0000000000000001 0000000000000001
0000000000001000 0000000116854000 0000000000156402 00000000324e7a38
Krnl Code: 000000000015633a: 95001000 cli 0(%r1),0
000000000015633e: a774ffc3 brc 7,1562c4
#0000000000156342: a7f40001 brc 15,156344
>0000000000156346: 92011000 mvi 0(%r1),1
000000000015634a: a7f4ffbd brc 15,1562c4
000000000015634e: 0707 bcr 0,%r7
0000000000156350: c00400000000 brcl 0,156350
0000000000156356: eb7ff0500024 stmg %r7,%r15,80(%r15)
Call Trace:
([<00000000001563e0>] dma_update_trans+0x90/0x228)
[<00000000001565dc>] s390_dma_unmap_pages+0x64/0x160
[<00000000001567c2>] s390_dma_free+0x62/0x98
[<000003ff801310ce>] __genwqe_free_consistent+0x56/0x70 [genwqe_card]
[<000003ff801316d0>] genwqe_free_sync_sgl+0xf8/0x160 [genwqe_card]
[<000003ff8012bd6e>] ddcb_cmd_cleanup+0x86/0xa8 [genwqe_card]
[<000003ff8012c1c0>] do_execute_ddcb+0x110/0x348 [genwqe_card]
[<000003ff8012c914>] genwqe_ioctl+0x51c/0xc20 [genwqe_card]
[<000000000032513a>] do_vfs_ioctl+0x3b2/0x518
[<0000000000325344>] SyS_ioctl+0xa4/0xb8
[<00000000007b86c6>] system_call+0xd6/0x264
[<000003ff9e8e520a>] 0x3ff9e8e520a
Last Breaking-Event-Address:
[<0000000000156342>] dma_update_cpu_trans+0x9a/0xa8
---[ end trace 35996336235145c8 ]---
BUG: Bad page state in process jbd2/dasdb1-8 pfn:3215b
page:000003d100c856c0 count:-1 mapcount:0 mapping: (null) index:0x0
flags: 0x3fffc0000000000()
page dumped because: nonzero _count--- drivers/misc/genwqe/card_utils.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/misc/genwqe/card_utils.c +11 -1
@@ -341,17 +341,27 @@ int genwqe_alloc_sync_sgl(struct genwqe_if (copy_from_user (sgl->lpage, user_addr + user_size - sgl->lpage_size, sgl->lpage_size)) { rc = -EFAULT ; - goto err_out1; + goto err_out2; } }return 0 ; + err_out2: +__genwqe_free_consistent (cd,PAGE_SIZE , sgl->lpage, + sgl->lpage_dma_addr); + sgl->lpage =NULL ; + sgl->lpage_dma_addr =0 ; err_out1:__genwqe_free_consistent (cd,PAGE_SIZE , sgl->fpage, sgl->fpage_dma_addr); + sgl->fpage =NULL ; + sgl->fpage_dma_addr =0 ; err_out:__genwqe_free_consistent (cd, sgl->sgl_size, sgl->sgl, sgl->sgl_dma_addr); + sgl->sgl =NULL ; + sgl->sgl_dma_addr =0 ; + sgl->sgl_size =0 ;return -ENOMEM ; }
PATCH 180/306 ubifs: Fix regression in ubifs_readdir()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
commit a00052a296e54205cf238c75bd98d17d5d02a6db upstream.
Commit c83ed4c9dbb35 ("ubifs: Abort readdir upon error") broke overlayfs support because the fix exposed an internal error code to VFS.
--- fs/ubifs/dir.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ubifs/dir.c +8 -0
@@ -448,6 +448,14 @@ static int ubifs_readdir(struct file *fi out:if (err != -ENOENT )ubifs_err ("cannot find next direntry, error %d" , err); +else +/* +* -ENOENT is a non-fatal error in this context, the TNC uses +* it to indicate that the cursor moved past the current directory +* and readdir() has to stop. +*/ + err =0 ; +kfree (file->private_data); file->private_data =NULL ;
PATCH 181/306 md: be careful not lot leak internal curr_resync value into metadata. -- (all)
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 1217e1d1999ed6c9c1e1b1acae0a74ab70464ae2 upstream.
mddev->curr_resync usually records where the current resync is up to, but during the starting phase it has some "magic" values.
1 - means that the array is trying to start a resync, but has yielded
to another array which shares physical devices, and also needs to start a resync
2 - means the array is trying to start resync, but has found another
array which shares physical devices and has already started resync.
3 - means that resync has commensed, but it is possible that nothing
has actually been resynced yet.
It is important that this value not be visible to user-space and particularly that it doesn't get written to the metadata, as the resync or recovery checkpoint. In part, this is because it may be slightly higher than the correct value, though this is very rare. In part, because it is not a multiple of 4K, and some devices only support 4K aligned accesses.
There are two places where this value is propagates into either ->curr_resync_completed or ->recovery_cp or ->recovery_offset. These currently avoid the propagation of values 1 and 3, but will allow 3 to leak through.
Change them to only propagate the value if it is > 3.
As this can cause an array to fail, the patch is suitable for -stable.
--- drivers/md/md.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/md.c +1 -1
@@ -7682,7 +7682,7 @@ void md_do_sync(struct md_thread *thread mddev->pers->sync_request (mddev, max_sectors, &skipped,1 );if (!test_bit (MD_RECOVERY_CHECK , &mddev->recovery) && - mddev->curr_resync >2 ) { + mddev->curr_resync >3 ) {if (test_bit (MD_RECOVERY_SYNC , &mddev->recovery)) {if (test_bit (MD_RECOVERY_INTR , &mddev->recovery)) {if (mddev->curr_resync >= mddev->recovery_cp) {
PATCH 182/306 net/mlx5: Avoid passing dma address 0 to firmware
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Noa Osherovich <[email protected]>
commit 6b276190c50a12511d889d9079ffb901ff94a822 upstream.
Currently the firmware can't work with a page with dma address 0. Passing such an address to the firmware will cause the give_pages command to fail.
To avoid this, in case we get a 0 dma address of a page from the dma engine, we avoid passing it to FW by remapping to get an address other than 0.
--- .../net/ethernet/mellanox/mlx5/core/pagealloc.c | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +18 -8
@@ -243,6 +243,7 @@ static void free_4k(struct mlx5_core_devstatic int alloc_system_page (struct mlx5_core_dev *dev,u16 func_id) {struct page *page; +u64 zero_addr =1 ;u64 addr;int err;
@@ -251,26 +252,35 @@ static int alloc_system_page(struct mlx5mlx5_core_warn (dev,"failed to allocate page\n" );return -ENOMEM ; } +map: addr =dma_map_page (&dev->pdev->dev, page,0 ,PAGE_SIZE ,DMA_BIDIRECTIONAL );if (dma_mapping_error (&dev->pdev->dev, addr)) {mlx5_core_warn (dev,"failed dma mapping page\n" ); err = -ENOMEM ; - goto out_alloc; + goto err_mapping; } + +/* Firmware doesn't support page with physical address 0 */ +if (addr ==0 ) { + zero_addr = addr; + goto map; + } + err =insert_page (dev, addr, page, func_id);if (err) {mlx5_core_err (dev,"failed to track allocated page\n" ); - goto out_mapping; +dma_unmap_page (&dev->pdev->dev, addr,PAGE_SIZE , +DMA_BIDIRECTIONAL ); } -return 0 ; - -out_mapping: -dma_unmap_page (&dev->pdev->dev, addr,PAGE_SIZE ,DMA_BIDIRECTIONAL ); +err_mapping: +if (err) +__free_page (page); -out_alloc: -__free_page (page); +if (zero_addr ==0 ) +dma_unmap_page (&dev->pdev->dev, zero_addr,PAGE_SIZE , +DMA_BIDIRECTIONAL );return err; }
PATCH 183/306 packet: on direct_xmit, limit tso and csum to supported devices
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
commit 104ba78c98808ae837d1f63aae58c183db5505df upstream.
When transmitting on a packet socket with PACKET_VNET_HDR and PACKET_QDISC_BYPASS, validate device support for features requested in vnet_hdr.
Drop TSO packets sent to devices that do not support TSO or have the feature disabled. Note that the latter currently do process those packets correctly, regardless of not advertising the feature.
Because of SKB_GSO_DODGY, it is not sufficient to test device features with netif_needs_gso. Full validate_xmit_skb is needed.
Switch to software checksum for non-TSO packets that request checksum offload if that device feature is unsupported or disabled. Note that similar to the TSO case, device drivers may perform checksum offload correctly even when not advertising it.
When switching to software checksum, packets hit skb_checksum_help, which has two BUG_ON checksum not in linear segment. Packet sockets always allocate at least up to csum_start + csum_off + 2 as linear.
Tested by running github.com/wdebruij/kerneltools/psock_txring_vnet.c
ethtool -K eth0 tso off tx on
psock_txring_vnet -d $dst -s $src -i eth0 -l 2000 -n 1 -q -v psock_txring_vnet -d $dst -s $src -i eth0 -l 2000 -n 1 -q -v -N
ethtool -K eth0 tx off
psock_txring_vnet -d $dst -s $src -i eth0 -l 1000 -n 1 -q -v -G psock_txring_vnet -d $dst -s $src -i eth0 -l 1000 -n 1 -q -v -G -N
v2:
- add EXPORT_SYMBOL_GPL(validate_xmit_skb_list)
[bwh: Backported to 3.16: open-code the necessary checks as we don't have
validate_xmit_skb_list()]
---
net/packet/af_packet.c +11 -0
@@ -251,9 +251,20 @@ static int packet_direct_xmit(struct sk_ goto drop; features =netif_skb_features (skb); +if (vlan_tx_tag_present (skb) && + !vlan_hw_offload_capable (features, skb->vlan_proto)) + goto drop; +if (netif_needs_gso (skb, features)) + goto drop;if (skb_needs_linearize (skb, features) &&__skb_linearize (skb)) goto drop; +if (skb->ip_summed ==CHECKSUM_PARTIAL ) { +skb_set_transport_header (skb,skb_checksum_start_offset (skb)); +if (!(features &NETIF_F_ALL_CSUM ) && +skb_checksum_help (skb)) + goto drop; + } queue_map =skb_get_queue_mapping (skb); txq =netdev_get_tx_queue (dev, queue_map);
PATCH 184/306 net/mlx4_core: Fix the resource-type enum in res tracker to conform to FW spec
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jack Morgenstein <[email protected]>
commit aa0c08feae8161b945520ada753d0dfe62b14fe7 upstream.
The resource type enum in the resource tracker was incorrect. RES_EQ was put in the position of RES_NPORT_ID (a FC resource).
Since the remaining resources maintain their current values, and RES_EQ is not passed from slaves to the hypervisor in any FW command, this change affects only the hypervisor. Therefore, there is no backwards-compatibility issue.
--- drivers/net/ethernet/mellanox/mlx4/mlx4.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/mlx4.h +2 -1
@@ -153,9 +153,10 @@ enum mlx4_resource {RES_MTT ,RES_MAC ,RES_VLAN , -RES_EQ , +RES_NPORT_ID ,RES_COUNTER ,RES_FS_RULE , +RES_EQ , MLX4_NUM_OF_RESOURCE_TYPE };
PATCH 185/306 net/mlx4_en: Resolve dividing by zero in 32-bit system
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eugenia Emantayev <[email protected]>
commit 4850cf4581578216468b7b3c3d06cc5abb0a697d upstream.
When doing roundup_pow_of_two for large enough number with bit 31, an overflow will occur and a value equal to 1 will be returned. In this case 1 will be subtracted from the return value and division by zero will be reached.
--- drivers/net/ethernet/mellanox/mlx4/en_clock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/en_clock.c +4 -1
@@ -294,8 +294,11 @@ static u32 freq_to_shift(u16 freq) {u32 freq_khz = freq *1000 ;u64 max_val_cycles = freq_khz *1000 *MLX4_EN_WRAP_AROUND_SEC ; +u64 tmp_rounded = +roundup_pow_of_two (max_val_cycles) > max_val_cycles ? +roundup_pow_of_two (max_val_cycles) -1 :UINT_MAX ;u64 max_val_cycles_rounded =is_power_of_2 (max_val_cycles +1 ) ? - max_val_cycles :roundup_pow_of_two (max_val_cycles) -1 ; + max_val_cycles : tmp_rounded;/* calculate max possible multiplier in order to fit in 64bit */ u64 max_mul =div_u64 (0xffffffffffffffffULL , max_val_cycles_rounded);
PATCH 186/306 net/mlx4_en: Process all completions in RX rings after port goes up
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Erez Shitrit <[email protected]>
commit 8d59de8f7bb3db296331c665779c653b0c8d13ba upstream.
Currently there is a race between incoming traffic and initialization flow. HW is able to receive the packets after INIT_PORT is done and unicast steering is configured. Before we set priv->port_up NAPI is not scheduled and receive queues become full. Therefore we never get new interrupts about the completions.
This issue could happen if running heavy traffic during bringing port up.
The resolution is to schedule NAPI once port_up is set. If receive queues were full this will process all cqes and release them.
--- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +7 -0
@@ -1733,6 +1733,13 @@ int mlx4_en_start_port(struct net_devicevxlan_get_rx_port (dev);#endif priv->port_up = true; + +/* Process all completions if exist to prevent +* the queues freezing if they are full +*/ +for (i =0 ; i < priv->rx_ring_num; i++) +napi_schedule (&priv->rx_cq[i]->napi); +netif_tx_start_all_queues (dev);netif_device_attach (dev);
PATCH 187/306 net/mlx4_en: Fix potential deadlock in port statistics flow
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jack Morgenstein <[email protected]>
commit d2582a03939ed0a80ffcd3ea5345505bc8067c54 upstream.
mlx4_en_DUMP_ETH_STATS took the *counter mutex* and then called the FW command, with WRAPPED attribute. As a result, the fw command is wrapped on the Hypervisor when it calls mlx4_en_DUMP_ETH_STATS. The FW command wrapper flow on the hypervisor takes the *slave_cmd_mutex* during processing.
At the same time, a VF could be in the process of coming up, and could call mlx4_QUERY_FUNC_CAP. On the hypervisor, the command flow takes the *slave_cmd_mutex*, then executes mlx4_QUERY_FUNC_CAP_wrapper. mlx4_QUERY_FUNC_CAP wrapper calls mlx4_get_default_counter_index(), which takes the *counter mutex*. DEADLOCK.
The fix is that the DUMP_ETH_STATS fw command should be called with the NATIVE attribute, so that on the hypervisor, this command does not enter the wrapper flow.
Since the Hypervisor no longer goes through the wrapper code, we also simply return 0 in mlx4_DUMP_ETH_STATS_wrapper (i.e.the function succeeds, but the returned data will be all zeroes).
No need to test if it is the Hypervisor going through the wrapper.
---
drivers/net/ethernet/mellanox/mlx4/en_port.c +1 -1
@@ -127,7 +127,7 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_ereturn PTR_ERR (mailbox); err =mlx4_cmd_box (mdev->dev,0 , mailbox->dma, in_mod,0 ,MLX4_CMD_DUMP_ETH_STATS ,MLX4_CMD_TIME_CLASS_B , -MLX4_CMD_WRAPPED ); +MLX4_CMD_NATIVE );if (err) goto out;
drivers/net/ethernet/mellanox/mlx4/mlx4.h +0 -2
@@ -1249,8 +1249,6 @@ int mlx4_SET_VLAN_FLTR_wrapper(struct ml struct mlx4_cmd_info *cmd);int mlx4_common_set_vlan_fltr (struct mlx4_dev *dev,int function,int port,void *buf); -int mlx4_common_dump_eth_stats (struct mlx4_dev *dev,int slave,u32 in_mod, -struct mlx4_cmd_mailbox *outbox); int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox,
drivers/net/ethernet/mellanox/mlx4/port.c +1 -12
@@ -1143,24 +1143,13 @@ int mlx4_SET_VLAN_FLTR_wrapper(struct mlreturn err; } -int mlx4_common_dump_eth_stats (struct mlx4_dev *dev,int slave, -u32 in_mod,struct mlx4_cmd_mailbox *outbox) -{ -return mlx4_cmd_box (dev,0 , outbox->dma, in_mod,0 , -MLX4_CMD_DUMP_ETH_STATS ,MLX4_CMD_TIME_CLASS_B , -MLX4_CMD_NATIVE ); -} -int mlx4_DUMP_ETH_STATS_wrapper (struct mlx4_dev *dev,int slave,struct mlx4_vhcr *vhcr,struct mlx4_cmd_mailbox *inbox,struct mlx4_cmd_mailbox *outbox,struct mlx4_cmd_info *cmd) { -if (slave != dev->caps.function) -return 0 ; -return mlx4_common_dump_eth_stats (dev, slave, - vhcr->in_modifier, outbox); +return 0 ; }void mlx4_set_stats_bitmap (struct mlx4_dev *dev,u64 *stats_bitmap)
PATCH 188/306 m68k: Fix ndelay() macro
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Boris Brezillon <[email protected]>
commit 7e251bb21ae08ca2e4fb28cc0981fac2685a8efa upstream.
The current ndelay() macro definition has an extra semi-colon at the end of the line thus leading to a compilation error when ndelay is used in a conditional block without curly braces like this one:
if (cond) ndelay(t); else ...
which, after the preprocessor pass gives:
if (cond) m68k_ndelay(t);; else ...
thus leading to the following gcc error:
error: 'else' without a previous 'if'
Remove this extra semi-colon.
--- arch/m68k/include/asm/delay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/include/asm/delay.h +1 -1
@@ -114,6 +114,6 @@ static inline void __udelay(unsigned lon*/ #define HZSCALE (268435456 / (1000000 / HZ)) -#define ndelay (n) __delay(DIV_ROUND_UP((n) * ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6), 1000)); +#define ndelay (n) __delay(DIV_ROUND_UP((n) * ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6), 1000))#endif /* defined(_M68K_DELAY_H) */
PATCH 189/306 iommu/vt-d: Fix IOMMU lookup for SR-IOV Virtual Functions
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ashok Raj <[email protected]>
commit 1c387188c60f53b338c20eee32db055dfe022a9b upstream.
The VT-d specification (§8.3.3) says:
‘Virtual Functions’ of a ‘Physical Function’ are under the scope of the same remapping unit as the ‘Physical Function’.
The BIOS is not required to list all the possible VFs in the scope tables, and arguably *shouldn't* make any attempt to do so, since there could be a huge number of them.
This has been broken basically for ever — the VF is never going to match against a specific unit's scope, so it ends up being assigned to the INCLUDE_ALL IOMMU. Which was always actually correct by coincidence, but now we're looking at Root-Complex integrated devices with SR-IOV support it's going to start being wrong.
Fix it to simply use pci_physfn() before doing the lookup for PCI devices.
--- drivers/iommu/dmar.c | 4 +++- drivers/iommu/intel-iommu.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
drivers/iommu/dmar.c +3 -1
@@ -299,7 +299,9 @@ static int dmar_pci_bus_notifier(structstruct pci_dev *pdev =to_pci_dev (data);struct dmar_pci_notify_info *info; -/* Only care about add/remove events for physical functions */ +/* Only care about add/remove events for physical functions. +* For VFs we actually do the lookup based on the corresponding +* PF in device_to_iommu() anyway. */ if (pdev->is_virtfn)return NOTIFY_DONE ;if (action !=BUS_NOTIFY_ADD_DEVICE && action !=BUS_NOTIFY_DEL_DEVICE )
drivers/iommu/intel-iommu.c +13 -0
@@ -684,7 +684,13 @@ static struct intel_iommu *device_to_iomreturn NULL ;if (dev_is_pci (dev)) { +struct pci_dev *pf_pdev; + pdev =to_pci_dev (dev); +/* VFs aren't listed in scope tables; we need to look up +* the PF instead to find the IOMMU. */ + pf_pdev =pci_physfn (pdev); + dev = &pf_pdev->dev; segment =pci_domain_nr (pdev->bus); }else if (ACPI_COMPANION (dev)) dev = &ACPI_COMPANION (dev)->dev;
@@ -697,6 +703,13 @@ static struct intel_iommu *device_to_iomfor_each_active_dev_scope (drhd->devices, drhd->devices_cnt, i, tmp) {if (tmp == dev) { +/* For a VF use its original BDF# not that of the PF +* which we used for the IOMMU lookup. Strictly speaking +* we could do this for all PCI devices; we only need to +* get the BDF# from the scope table for ACPI matches. */ +if (pdev->is_virtfn) + goto got_pdev; + *bus = drhd->devices[i].bus; *devfn = drhd->devices[i].devfn; goto out;
PATCH 190/306 virtio: console: Unlock vqs while freeing buffers
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Redfearn <[email protected]>
commit 34563769e438d2881f62cf4d9badc4e589ac0ec0 upstream.
Commit c6017e793b93 ("virtio: console: add locks around buffer removal in port unplug path") added locking around the freeing of buffers in the vq. However, when free_buf() is called with can_sleep = true and rproc is enabled, it calls dma_free_coherent() directly, requiring interrupts to be enabled. Currently a WARNING is triggered due to the spin locking around free_buf, with a call stack like this:
WARNING: CPU: 3 PID: 121 at ./include/linux/dma-mapping.h:433 free_buf+0x1a8/0x288 Call Trace: [<8040c538>] show_stack+0x74/0xc0 [<80757240>] dump_stack+0xd0/0x110 [<80430d98>] __warn+0xfc/0x130 [<80430ee0>] warn_slowpath_null+0x2c/0x3c [<807e7c6c>] free_buf+0x1a8/0x288 [<807ea590>] remove_port_data+0x50/0xac [<807ea6a0>] unplug_port+0xb4/0x1bc [<807ea858>] virtcons_remove+0xb0/0xfc [<807b6734>] virtio_dev_remove+0x58/0xc0 [<807f918c>] __device_release_driver+0xac/0x134 [<807f924c>] device_release_driver+0x38/0x50 [<807f7edc>] bus_remove_device+0xfc/0x130 [<807f4b74>] device_del+0x17c/0x21c [<807f4c38>] device_unregister+0x24/0x38 [<807b6b50>] unregister_virtio_device+0x28/0x44
Fix this by restructuring the loops to allow the locks to only be taken where it is necessary to protect the vqs, and release it while the buffer is being freed.
--- drivers/char/virtio_console.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/char/virtio_console.c +16 -6
@@ -1532,19 +1532,29 @@ static void remove_port_data(struct portspin_lock_irq (&port->inbuf_lock);/* Remove unused data this port might have received. */ discard_port_data (port); +spin_unlock_irq (&port->inbuf_lock);/* Remove buffers we queued up for the Host to send us data in. */ -while ((buf =virtqueue_detach_unused_buf (port->in_vq))) -free_buf (buf, true); -spin_unlock_irq (&port->inbuf_lock); +do { +spin_lock_irq (&port->inbuf_lock); + buf =virtqueue_detach_unused_buf (port->in_vq); +spin_unlock_irq (&port->inbuf_lock); +if (buf) +free_buf (buf, true); + }while (buf);spin_lock_irq (&port->outvq_lock);reclaim_consumed_buffers (port); +spin_unlock_irq (&port->outvq_lock);/* Free pending buffers from the out-queue. */ -while ((buf =virtqueue_detach_unused_buf (port->out_vq))) -free_buf (buf, true); -spin_unlock_irq (&port->outvq_lock); +do { +spin_lock_irq (&port->outvq_lock); + buf =virtqueue_detach_unused_buf (port->out_vq); +spin_unlock_irq (&port->outvq_lock); +if (buf) +free_buf (buf, true); + }while (buf); }/*
PATCH 191/306 netfilter: nf_tables: destroy the set if fail to add transaction
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Liping Zhang <[email protected]>
commit c17c3cdff10b9f59ef1244a14604f10949f17117 upstream.
When the memory is exhausted, then we will fail to add the NFT_MSG_NEWSET transaction. In such case, we should destroy the set before we free it.
--- net/netfilter/nf_tables_api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +3 -1
@@ -2642,12 +2642,14 @@ static int nf_tables_newset(struct sock err =nft_trans_set_add (&ctx,NFT_MSG_NEWSET , set);if (err <0 ) - goto err2; + goto err3;list_add_tail_rcu (&set->list, &table->sets); table->use++;return 0 ; +err3: + ops->destroy (set); err2:kfree (set); err1:
PATCH 192/306 mei: bus: fix received data size check in NFC fixup
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 582ab27a063a506ccb55fc48afcc325342a2deba upstream.
NFC version reply size checked against only header size, not against full message size. That may lead potentially to uninitialized memory access in version data.
That leads to warnings when version data is accessed:drivers/misc/mei/bus-fixup.c: warning: '*((void *)&ver+11)' may be used uninitialized in this function [-Wuninitialized]: => 212:2
Reported in
Build regressions/improvements in v4.9-rc3
https://lkml.org/lkml/2016/10/30/57
[bwh: Backported to 3.16:
- Drop change in mei_phy.c
- Adjust filename]
---
drivers/misc/mei/nfc.c +1 -1
@@ -292,7 +292,7 @@ static int mei_nfc_if_version(struct meireturn -ENOMEM ; bytes_recv =__mei_cl_recv (cl, (u8 *)reply, if_version_length); -if (bytes_recv <0 || bytes_recv <sizeof (struct mei_nfc_reply )) { +if (bytes_recv < if_version_length) {dev_err (&dev->pdev->dev,"Could not read IF version\n" ); ret = -EIO ; goto err;
PATCH 193/306 ipv6: Don't use ufo handling on later transformed packets
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Sitnicki <[email protected]>
commit f89c56ce710afa65e1b2ead555b52c4807f34ff7 upstream.
Similar to commit c146066ab802 ("ipv4: Don't use ufo handling on later transformed packets"), don't perform UFO on packets that will be IPsec transformed. To detect it we rely on the fact that headerlen in dst_entry is non-zero only for transformation bundles (xfrm_dst objects).
Unwanted segmentation can be observed with a NETIF_F_UFO capable device, such as a dummy device:
DEV=dum0 LEN=1493
ip li add $DEV type dummy
ip addr add fc00::1/64 dev $DEV nodad
ip link set $DEV up
ip xfrm policy add dir out src fc00::1 dst fc00::2 \
tmpl src fc00::1 dst fc00::2 proto esp spi 1
ip xfrm state add src fc00::1 dst fc00::2 \
proto esp spi 1 enc 'aes' 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
tcpdump -n -nn -i $DEV -t &
socat /dev/zero,readbytes=$LEN udp6:[fc00::2]:$LEN
tcpdump output before:
IP6 fc00::1 > fc00::2: frag (0|1448) ESP(spi=0x00000001,seq=0x1), length 1448 IP6 fc00::1 > fc00::2: frag (1448|48)
IP6 fc00::1 > fc00::2: ESP(spi=0x00000001,seq=0x2), length 88
... and after:
IP6 fc00::1 > fc00::2: frag (0|1448) ESP(spi=0x00000001,seq=0x1), length 1448 IP6 fc00::1 > fc00::2: frag (1448|80)
--- net/ipv6/ip6_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_output.c +1 -1
@@ -1296,7 +1296,7 @@ emsgsize:if (((length > mtu) || (skb &&skb_is_gso (skb))) && (sk->sk_protocol ==IPPROTO_UDP ) && - (rt->dst.dev->features &NETIF_F_UFO ) && + (rt->dst.dev->features &NETIF_F_UFO ) && !rt->dst.header_len && (sk->sk_type ==SOCK_DGRAM )) { err = ip6_ufo_append_data(sk, getfrag, from, length, hh_len, fragheaderlen, exthdrlen,
PATCH 194/306 can: bcm: fix warning in bcm_connect/proc_register
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
commit deb507f91f1adbf64317ad24ac46c56eeccfb754 upstream.
Andrey Konovalov reported an issue with proc_register in bcm.c. As suggested by Cong Wang this patch adds a lock_sock() protection and a check for unsuccessful proc_create_data() in bcm_connect().
Reference: http://marc.info/?l=linux-netdev&m=147732648731237
--- net/can/bcm.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-)
net/can/bcm.c +23 -9
@@ -1499,24 +1499,31 @@ static int bcm_connect(struct socket *sostruct sockaddr_can *addr = (struct sockaddr_can *)uaddr;struct sock *sk = sock->sk;struct bcm_sock *bo =bcm_sk (sk); +int ret =0 ;if (len <sizeof (*addr))return -EINVAL ; -if (bo->bound) -return -EISCONN ; +lock_sock (sk); + +if (bo->bound) { + ret = -EISCONN ; + goto fail; + }/* bind a device to this socket */ if (addr->can_ifindex) {struct net_device *dev; dev =dev_get_by_index (&init_net, addr->can_ifindex); -if (!dev) -return -ENODEV ; - +if (!dev) { + ret = -ENODEV ; + goto fail; + }if (dev->type !=ARPHRD_CAN ) {dev_put (dev); -return -ENODEV ; + ret = -ENODEV ; + goto fail; } bo->ifindex = dev->ifindex;
@@ -1527,17 +1534,24 @@ static int bcm_connect(struct socket *so bo->ifindex =0 ; } - bo->bound =1 ; -if (proc_dir) {/* unique socket address as filename */ sprintf (bo->procname,"%lu" ,sock_i_ino (sk)); bo->bcm_proc_read =proc_create_data (bo->procname,0644 , proc_dir, &bcm_proc_fops, sk); +if (!bo->bcm_proc_read) { + ret = -ENOMEM ; + goto fail; + } } -return 0 ; + bo->bound =1 ; + +fail: +release_sock (sk); + +return ret; } static int bcm_recvmsg(struct kiocb *iocb, struct socket *sock,
PATCH 195/306 bgmac: stop clearing DMA receive control register right after it is set
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andy Gospodarek <[email protected]>
commit fcdefccac976ee51dd6071832b842d8fb41c479c upstream.
Current bgmac code initializes some DMA settings in the receive control register for some hardware and then immediately clears those settings. Not clearing those settings results in ~420Mbps *improvement* in throughput; this system can now receive frames at line-rate on Broadcom 5871x hardware compared to ~520Mbps today. I also tested a few other values but found there to be no discernible difference in CPU utilization even if burst size and prefetching values are different.
On the hardware tested there was no need to keep the code that cleared all but bits 16-17, but since there is a wide variety of hardware that used this driver (I did not look at all hardware docs for hardware using this IP block), I find it wise to move this call up and clear bits just after reading the default value from the hardware rather than completely removing it.
This is a good candidate for -stable >=3.14 since that is when the code that was supposed to improve performance (but did not) was introduced.
--- drivers/net/ethernet/broadcom/bgmac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bgmac.c +4 -1
@@ -253,6 +253,10 @@ static void bgmac_dma_rx_enable(struct bu32 ctl; ctl =bgmac_read (bgmac, ring->mmio_base +BGMAC_DMA_RX_CTL ); + +/* preserve ONLY bits 16-17 from current hardware value */ + ctl &=BGMAC_DMA_RX_ADDREXT_MASK ; +if (bgmac->core->id.rev >=4 ) { ctl &= ~BGMAC_DMA_RX_BL_MASK ; ctl |=BGMAC_DMA_RX_BL_128 <<BGMAC_DMA_RX_BL_SHIFT ;
@@ -263,7 +267,6 @@ static void bgmac_dma_rx_enable(struct b ctl &= ~BGMAC_DMA_RX_PT_MASK ; ctl |=BGMAC_DMA_RX_PT_1 <<BGMAC_DMA_RX_PT_SHIFT ; } - ctl &=BGMAC_DMA_RX_ADDREXT_MASK ; ctl |=BGMAC_DMA_RX_ENABLE ; ctl |=BGMAC_DMA_RX_PARITY_DISABLE ; ctl |=BGMAC_DMA_RX_OVERFLOW_CONT ;
PATCH 196/306 usb: gadget: u_ether: remove interrupt throttling
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit fd9afd3cbe404998d732be6cc798f749597c5114 upstream.
According to Dave Miller "the networking stack has a hard requirement that all SKBs which are transmitted must have their completion signalled in a fininte amount of time. This is because, until the SKB is freed by the driver, it holds onto socket, netfilter, and other subsystem resources."
In summary, this means that using TX IRQ throttling for the networking gadgets is, at least, complex and we should avoid it for the time being.
---
drivers/usb/gadget/u_ether.c +0 -7
@@ -583,13 +583,6 @@ static netdev_tx_t eth_start_xmit(struct req->length = length; -/* throttle high/super speed IRQ rate back slightly */ -if (gadget_is_dualspeed (dev->gadget)) - req->no_interrupt = (dev->gadget->speed ==USB_SPEED_HIGH || - dev->gadget->speed ==USB_SPEED_SUPER ) - ? ((atomic_read (&dev->tx_qlen) % dev->qmult) !=0 ) - :0 ; - retval =usb_ep_queue (in, req,GFP_ATOMIC );switch (retval) {default :
PATCH 197/306 uwb: fix device reference leaks
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit d6124b409ca33c100170ffde51cd8dff761454a1 upstream.
This subsystem consistently fails to drop the device reference taken by class_find_device().
Note that some of these lookup functions already take a reference to the returned data, while others claim no reference is needed (or does not seem need one).
--- drivers/uwb/lc-rc.c | 16 +++++++++++++--- drivers/uwb/pal.c | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/uwb/lc-rc.c +13 -3
@@ -56,8 +56,11 @@ static struct uwb_rc *uwb_rc_find_by_indstruct uwb_rc *rc =NULL ; dev =class_find_device (&uwb_rc_class,NULL , &index, uwb_rc_index_match); -if (dev) +if (dev) { rc =dev_get_drvdata (dev); +put_device (dev); + } +return rc; }
@@ -368,7 +371,9 @@ struct uwb_rc *__uwb_rc_try_get(struct uif (dev) { rc =dev_get_drvdata (dev);__uwb_rc_get (rc); +put_device (dev); } +return rc; }EXPORT_SYMBOL_GPL (__uwb_rc_try_get);
@@ -421,8 +426,11 @@ struct uwb_rc *uwb_rc_get_by_grandpa(con dev =class_find_device (&uwb_rc_class,NULL , grandpa_dev, find_rc_grandpa); -if (dev) +if (dev) { rc =dev_get_drvdata (dev); +put_device (dev); + } +return rc; }EXPORT_SYMBOL_GPL (uwb_rc_get_by_grandpa);
@@ -454,8 +462,10 @@ struct uwb_rc *uwb_rc_get_by_dev(const sstruct uwb_rc *rc =NULL ; dev =class_find_device (&uwb_rc_class,NULL , addr, find_rc_dev); -if (dev) +if (dev) { rc =dev_get_drvdata (dev); +put_device (dev); + }return rc; }
drivers/uwb/pal.c +2 -0
@@ -97,6 +97,8 @@ static bool uwb_rc_class_device_exists(s dev =class_find_device (&uwb_rc_class,NULL , target_rc, find_rc); +put_device (dev); +return (dev !=NULL ); }
PATCH 198/306 gpio/mvebu: Use irq_domain_add_linear
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit 812d47889a8e418d7bea9bec383581a34c19183e upstream.
This fixes the irq allocation in this driver to not print:
irq: Cannot allocate irq_descs @ IRQ34, assuming pre-allocated
irq: Cannot allocate irq_descs @ IRQ66, assuming pre-allocated
Which happens because the driver already called irq_alloc_descs() and so the change to use irq_domain_add_simple resulted in calling irq_alloc_descs() twice.
Modernize the irq allocation in this driver to use the irq_domain_add_linear flow directly and eliminate the use of irq_domain_add_simple/legacy
[bwh: Backported to 3.16:
- Keep using irq_set_handler_data(), irq_set_chained_handler()
- Adjust context]
---
drivers/gpio/gpio-mvebu.c +47 -47
@@ -294,10 +294,10 @@ static void mvebu_gpio_irq_ack(struct ir {struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);struct mvebu_gpio_chip *mvchip = gc->private; -u32 mask = ~(1 << (d->irq - gc->irq_base)); +u32 mask = d->mask;irq_gc_lock (gc); -writel_relaxed (mask,mvebu_gpioreg_edge_cause (mvchip)); +writel_relaxed (~mask,mvebu_gpioreg_edge_cause (mvchip));irq_gc_unlock (gc); }
@@ -306,7 +306,7 @@ static void mvebu_gpio_edge_irq_mask(strstruct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);struct mvebu_gpio_chip *mvchip = gc->private;struct irq_chip_type *ct =irq_data_get_chip_type (d); -u32 mask =1 << (d->irq - gc->irq_base); +u32 mask = d->mask;irq_gc_lock (gc); ct->mask_cache_priv &= ~mask;
@@ -320,8 +320,7 @@ static void mvebu_gpio_edge_irq_unmask(sstruct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);struct mvebu_gpio_chip *mvchip = gc->private;struct irq_chip_type *ct =irq_data_get_chip_type (d); - -u32 mask =1 << (d->irq - gc->irq_base); +u32 mask = d->mask;irq_gc_lock (gc); ct->mask_cache_priv |= mask;
@@ -334,8 +333,7 @@ static void mvebu_gpio_level_irq_mask(ststruct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);struct mvebu_gpio_chip *mvchip = gc->private;struct irq_chip_type *ct =irq_data_get_chip_type (d); - -u32 mask =1 << (d->irq - gc->irq_base); +u32 mask = d->mask;irq_gc_lock (gc); ct->mask_cache_priv &= ~mask;
@@ -348,8 +346,7 @@ static void mvebu_gpio_level_irq_unmask(struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);struct mvebu_gpio_chip *mvchip = gc->private;struct irq_chip_type *ct =irq_data_get_chip_type (d); - -u32 mask =1 << (d->irq - gc->irq_base); +u32 mask = d->mask;irq_gc_lock (gc); ct->mask_cache_priv |= mask;
@@ -464,7 +461,7 @@ static void mvebu_gpio_irq_handler(unsigfor (i =0 ; i < mvchip->chip.ngpio; i++) {int irq; - irq = mvchip->irqbase + i; + irq =irq_find_mapping (mvchip->domain, i);if (!(cause & (1 << i)))continue ;
@@ -572,8 +569,10 @@ static int mvebu_gpio_probe(struct platfstruct irq_chip_type *ct;struct clk *clk;unsigned int ngpios; +bool have_irqs;int soc_variant;int i, cpu, id; +int err; match =of_match_device (mvebu_gpio_of_match, &pdev->dev);if (match)
@@ -581,6 +580,9 @@ static int mvebu_gpio_probe(struct platfelse soc_variant =MVEBU_GPIO_SOC_VARIANT_ORION ; +/* Some gpio controllers do not provide irq support */ + have_irqs =of_irq_count (np) !=0 ; + mvchip =devm_kzalloc (&pdev->dev,sizeof (struct mvebu_gpio_chip ),GFP_KERNEL );if (!mvchip)return -ENOMEM ;
@@ -610,7 +612,8 @@ static int mvebu_gpio_probe(struct platf mvchip->chip.get = mvebu_gpio_get; mvchip->chip.direction_output = mvebu_gpio_direction_output; mvchip->chip.set = mvebu_gpio_set; - mvchip->chip.to_irq = mvebu_gpio_to_irq; +if (have_irqs) + mvchip->chip.to_irq = mvebu_gpio_to_irq; mvchip->chip.base = id *MVEBU_MAX_GPIO_PER_BANK ; mvchip->chip.ngpio = ngpios; mvchip->chip.can_sleep = false;
@@ -671,34 +674,30 @@ static int mvebu_gpio_probe(struct platfgpiochip_add (&mvchip->chip);/* Some gpio controllers do not provide irq support */ -if (!of_irq_count (np)) +if (!have_irqs)return 0 ; -/* Setup the interrupt handlers. Each chip can have up to 4 -* interrupt handlers, with each handler dealing with 8 GPIO -* pins. */ -for (i =0 ; i <4 ; i++) { -int irq; - irq =platform_get_irq (pdev, i); -if (irq <0 ) -continue ; -irq_set_handler_data (irq, mvchip); -irq_set_chained_handler (irq, mvebu_gpio_irq_handler); - } - - mvchip->irqbase =irq_alloc_descs (-1 ,0 , ngpios,-1 ); -if (mvchip->irqbase <0 ) { -dev_err (&pdev->dev,"no irqs\n" ); -return mvchip->irqbase; + mvchip->domain = +irq_domain_add_linear (np, ngpios, &irq_generic_chip_ops,NULL ); +if (!mvchip->domain) { +dev_err (&pdev->dev,"couldn't allocate irq domain %s (DT).\n" , + mvchip->chip.label); +return -ENODEV ; } - gc =irq_alloc_generic_chip ("mvebu_gpio_irq" ,2 , mvchip->irqbase, - mvchip->membase, handle_level_irq); -if (!gc) { -dev_err (&pdev->dev,"Cannot allocate generic irq_chip\n" ); -return -ENOMEM ; + err =irq_alloc_domain_generic_chips ( + mvchip->domain, ngpios,2 , np->name, handle_level_irq, +IRQ_NOREQUEST |IRQ_NOPROBE |IRQ_LEVEL ,0 ,0 ); +if (err) { +dev_err (&pdev->dev,"couldn't allocate irq chips %s (DT).\n" , + mvchip->chip.label); + goto err_domain; } +/* NOTE: The common accessors cannot be used because of the percpu +* access to the mask registers +*/ + gc =irq_get_domain_generic_chip (mvchip->domain,0 ); gc->private = mvchip; ct = &gc->chip_types[0 ]; ct->type =IRQ_TYPE_LEVEL_HIGH |IRQ_TYPE_LEVEL_LOW ;
@@ -716,24 +715,25 @@ static int mvebu_gpio_probe(struct platf ct->handler = handle_edge_irq; ct->chip.name = mvchip->chip.label; -irq_setup_generic_chip (gc,IRQ_MSK (ngpios),0 , -IRQ_NOREQUEST ,IRQ_LEVEL |IRQ_NOPROBE ); +/* Setup the interrupt handlers. Each chip can have up to 4 +* interrupt handlers, with each handler dealing with 8 GPIO +* pins. +*/ +for (i =0 ; i <4 ; i++) { +int irq =platform_get_irq (pdev, i); -/* Setup irq domain on top of the generic chip. */ - mvchip->domain =irq_domain_add_simple (np, mvchip->chip.ngpio, - mvchip->irqbase, - &irq_domain_simple_ops, - mvchip); -if (!mvchip->domain) { -dev_err (&pdev->dev,"couldn't allocate irq domain %s (DT).\n" , - mvchip->chip.label); -irq_remove_generic_chip (gc,IRQ_MSK (ngpios),IRQ_NOREQUEST , -IRQ_LEVEL |IRQ_NOPROBE ); -kfree (gc); -return -ENODEV ; +if (irq <0 ) +continue ; +irq_set_handler_data (irq, mvchip); +irq_set_chained_handler (irq, mvebu_gpio_irq_handler); }return 0 ; + +err_domain: +irq_domain_remove (mvchip->domain); + +return err; }static struct platform_driver mvebu_gpio_driver = {
PATCH 199/306 PM / sleep: fix device reference leak in test_suspend
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ceb75787bc75d0a7b88519ab8a68067ac690f55a upstream.
Make sure to drop the reference taken by class_find_device() after opening the RTC device.
--- kernel/power/suspend_test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/power/suspend_test.c +3 -1
@@ -169,8 +169,10 @@ static int __init test_suspend(void)/* RTCs have initialized by now too ... can we use one? */ dev =class_find_device (rtc_class,NULL ,NULL , has_wakealarm); -if (dev) +if (dev) { rtc =rtc_class_open (dev_name (dev)); +put_device (dev); + }if (!rtc) {printk (warn_no_rtc); goto done;
PATCH 200/306 ip6_tunnel: Clear IP6CB in ip6tunnel_xmit()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eli Cooper <[email protected]>
commit 23f4ffedb7d751c7e298732ba91ca75d224bc1a6 upstream.
skb->cb may contain data from previous layers. In the observed scenario, the garbage data were misinterpreted as IP6CB(skb)->frag_max_size, so that small packets sent through the tunnel are mistakenly fragmented.
This patch unconditionally clears the control buffer in ip6tunnel_xmit(), which affects ip6_tunnel, ip6_udp_tunnel and ip6_gre. Currently none of these tunnels set IP6CB(skb)->flags, otherwise it needs to be done earlier.
--- include/net/ip6_tunnel.h | 1 + 1 file changed, 1 insertion(+)
include/net/ip6_tunnel.h +1 -0
@@ -75,6 +75,7 @@ static inline void ip6tunnel_xmit(structstruct net_device_stats *stats = &dev->stats;int pkt_len, err; +memset (skb->cb,0 ,sizeof (struct inet6_skb_parm )); pkt_len = skb->len; err =ip6_local_out (skb);
PATCH 201/306 parisc: Ensure consistent state when switching to kernel stack at syscall entry
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit 6ed518328d0189e0fdf1bb7c73290d546143ea66 upstream.
We have one critical section in the syscall entry path in which we switch from the userspace stack to kernel stack. In the event of an external interrupt, the interrupt code distinguishes between those two states by analyzing the value of sr7. If sr7 is zero, it uses the kernel stack. Therefore it's important, that the value of sr7 is in sync with the currently enabled stack.
This patch now disables interrupts while executing the critical section. This prevents the interrupt handler to possibly see an inconsistent state which in the worst case can lead to crashes.
Interestingly, in the syscall exit path interrupts were already disabled in the critical section which switches back to the userspace stack.
--- arch/parisc/kernel/syscall.S | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/parisc/kernel/syscall.S +9 -2
@@ -106,8 +106,6 @@ linux_gateway_entry: mtsp %r0,%sr4 /* get kernel space into sr4 */ mtsp %r0,%sr5 /* get kernel space into sr5 */ mtsp %r0,%sr6 /* get kernel space into sr6 */ - mfsp %sr7,%r1 /* save user sr7 */ - mtsp %r1,%sr3 /* and store it in sr3 */ #ifdef CONFIG_64BIT /* for now we can *always* set the W bit on entry to the syscall
@@ -133,6 +131,14 @@ linux_gateway_entry: depdi 0, 31, 32, %r21 1: #endif + + /* We use a rsm/ssm pair to prevent sr3 from being clobbered + * by external interrupts. + */ + mfsp %sr7,%r1 /* save user sr7 */ + rsm PSW_SM_I, %r0 /* disable interrupts */ + mtsp %r1,%sr3 /* and store it in sr3 */ + mfctl %cr30,%r1 xor %r1,%r30,%r30 /* ye olde xor trick */ xor %r1,%r30,%r1
@@ -147,6 +153,7 @@ linux_gateway_entry: */ mtsp %r0,%sr7 /* get kernel space into sr7 */ + ssm PSW_SM_I, %r0 /* enable interrupts */ STREGM %r1,FRAME_SIZE(%r30) /* save r1 (usp) here for now */ mfctl %cr30,%r1 /* get task ptr in %r1 */ LDREG TI_TASK(%r1),%r1
PATCH 202/306 firewire: net: fix fragmented datagram_size off-by-one
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Richter <[email protected]>
commit e9300a4b7bbae83af1f7703938c94cf6dc6d308f upstream.
RFC 2734 defines the datagram_size field in fragment encapsulation headers thus:
datagram_size: The encoded size of the entire IP datagram. The value of datagram_size [...] SHALL be one less than the value of Total Length in the datagram's IP header (see STD 5, RFC 791).
Accordingly, the eth1394 driver of Linux 2.6.36 and older set and got this field with a -/+1 offset:
ether1394_tx() /* transmit */
ether1394_encapsulate_prep()
hdr->ff.dg_size = dg_size - 1;
ether1394_data_handler() /* receive */
if (hdr->common.lf == ETH1394_HDR_LF_FF)
dg_size = hdr->ff.dg_size + 1;
else
dg_size = hdr->sf.dg_size + 1;Likewise, I observe OS X 10.4 and Windows XP Pro SP3 to transmit 1500 byte sized datagrams in fragments with datagram_size=1499 if link fragmentation is required.
Only firewire-net sets and gets datagram_size without this offset. The result is lacking interoperability of firewire-net with OS X, Windows XP, and presumably Linux' eth1394. (I did not test with the latter.) For example, FTP data transfers to a Linux firewire-net box with max_rec smaller than the 1500 bytes MTU
- from OS X fail entirely,
- from Win XP start out with a bunch of fragmented datagrams which time out, then continue with unfragmented datagrams because Win XP temporarily reduces the MTU to 576 bytes.
So let's fix firewire-net's datagram_size accessors.
Note that firewire-net thereby loses interoperability with unpatched firewire-net, but only if link fragmentation is employed. (This happens with large broadcast datagrams, and with large datagrams on several FireWire CardBus cards with smaller max_rec than equivalent PCI cards, and it can be worked around by setting a small enough MTU.)
--- drivers/firewire/net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/firewire/net.c +4 -4
@@ -73,13 +73,13 @@ struct rfc2734_header {#define fwnet_get_hdr_lf (h) (((h)->w0 & 0xc0000000) >> 30)#define fwnet_get_hdr_ether_type (h) (((h)->w0 & 0x0000ffff)) -#define fwnet_get_hdr_dg_size (h) (((h)->w0 & 0x0fff0000) >> 16) +#define fwnet_get_hdr_dg_size (h) ((((h)->w0 & 0x0fff0000) >> 16) + 1)#define fwnet_get_hdr_fg_off (h) (((h)->w0 & 0x00000fff))#define fwnet_get_hdr_dgl (h) (((h)->w1 & 0xffff0000) >> 16) -#define fwnet_set_hdr_lf (lf) ((lf) << 30) +#define fwnet_set_hdr_lf (lf) ((lf) << 30)#define fwnet_set_hdr_ether_type (et) (et) -#define fwnet_set_hdr_dg_size (dgs) ((dgs) << 16) +#define fwnet_set_hdr_dg_size (dgs) (((dgs) - 1) << 16)#define fwnet_set_hdr_fg_off (fgo) (fgo)#define fwnet_set_hdr_dgl (dgl) ((dgl) << 16)
@@ -635,7 +635,7 @@ static int fwnet_incoming_packet(struct fg_off =fwnet_get_hdr_fg_off (&hdr); } datagram_label =fwnet_get_hdr_dgl (&hdr); - dg_size =fwnet_get_hdr_dg_size (&hdr);/* ??? + 1 */ + dg_size =fwnet_get_hdr_dg_size (&hdr);if (fg_off + len > dg_size)return 0 ;
PATCH 203/306 HID: usbhid: Add HID_QUIRK_NOGET for Aten DVI KVM switch
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Laura Abbott <[email protected]>
commit 849eca7b9dae0364e2fbe8afdf0fb610d12c9c8f upstream.
Like other KVM switches, the Aten DVI KVM switch needs a quirk to avoid spewing errors:
[791759.606542] usb 1-5.4: input irq status -75 received [791759.614537] usb 1-5.4: input irq status -75 received [791759.622542] usb 1-5.4: input irq status -75 received
Add it.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -164,6 +164,7 @@#define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204#define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205#define USB_DEVICE_ID_ATEN_4PORTKVMC 0x2208 +#define USB_DEVICE_ID_ATEN_CS682 0x2213#define USB_VENDOR_ID_ATMEL 0x03eb#define USB_DEVICE_ID_ATMEL_MULTITOUCH 0x211c
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -61,6 +61,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS682, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FIGHTERSTICK, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE, HID_QUIRK_NOGET },
PATCH 204/306 HID: usbhid: add ATEN CS962 to list of quirky devices
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit cf0ea4da4c7df11f7a508b2f37518e0f117f3791 upstream.
Like many similar devices it needs a quirk to work. Issuing the request gets the device into an irrecoverable state.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -165,6 +165,7 @@#define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205#define USB_DEVICE_ID_ATEN_4PORTKVMC 0x2208#define USB_DEVICE_ID_ATEN_CS682 0x2213 +#define USB_DEVICE_ID_ATEN_CS692 0x8021#define USB_VENDOR_ID_ATMEL 0x03eb#define USB_DEVICE_ID_ATMEL_MULTITOUCH 0x211c
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -62,6 +62,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS682, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS692, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FIGHTERSTICK, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE, HID_QUIRK_NOGET },
PATCH 205/306 ipv4: allow local fragmentation in ip_finish_output_gso()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lance Richardson <[email protected]>
commit 9ee6c5dc816aa8256257f2cd4008a9291ec7e985 upstream.
Some configurations (e.g. geneve interface with default MTU of 1500 over an ethernet interface with 1500 MTU) result in the transmission of packets that exceed the configured MTU. While this should be considered to be a "bad" configuration, it is still allowed and should not result in the sending of packets that exceed the configured MTU.
Fix by dropping the assumption in ip_finish_output_gso() that locally originated gso packets will never need fragmentation. Basic testing using iperf (observing CPU usage and bandwidth) have shown no measurable performance impact for traffic not requiring fragmentation.
---
net/ipv4/ip_output.c +2 -3
@@ -217,9 +217,8 @@ static int ip_finish_output_gso(struct sstruct sk_buff *segs;int ret =0 ; -/* common case: locally created skb or seglen is <= mtu */ -if (((IPCB (skb)->flags &IPSKB_FORWARDED ) ==0 ) || -skb_gso_network_seglen (skb) <=ip_skb_dst_mtu (skb)) +/* common case: seglen is <= mtu */ +if (skb_gso_network_seglen (skb) <=ip_skb_dst_mtu (skb))return ip_finish_output2 (skb);/* Slowpath - GSO segment length is exceeding the dst MTU.
PATCH 206/306 i2c: core: fix NULL pointer dereference under race condition
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
commit 147b36d5b70c083cc76770c47d60b347e8eaf231 upstream.
Race condition between registering an I2C device driver and deregistering an I2C adapter device which is assumed to manage that I2C device may lead to a NULL pointer dereference due to the uninitialized list head of driver clients.
The root cause of the issue is that the I2C bus may know about the registered device driver and thus it is matched by bus_for_each_drv(), but the list of clients is not initialized and commonly it is NULL, because I2C device drivers define struct i2c_driver as static and clients field is expected to be initialized by I2C core:
i2c_register_driver() i2c_del_adapter()
driver_register() ...
bus_add_driver() ...
... bus_for_each_drv(..., __process_removed_adapter)
... i2c_do_del_adapter()
... list_for_each_entry_safe(..., &driver->clients, ...)
INIT_LIST_HEAD(&driver->clients);To solve the problem it is sufficient to do clients list head initialization before calling driver_register().
The problem was found while using an I2C device driver with a sluggish registration routine on a bus provided by a physically detachable I2C master controller, but practically the oops may be reproduced under the race between arbitraty I2C device driver registration and managing I2C bus device removal e.g. by unbinding the latter over sysfs:
% echo 21a4000.i2c > /sys/bus/platform/drivers/imx-i2c/unbind
Unable to handle kernel NULL pointer dereference at virtual address 00000000 Internal error: Oops: 17 [#1] SMP ARM CPU: 2 PID: 533 Comm: sh Not tainted 4.9.0-rc3+ #61 Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) task: e5ada400 task.stack: e4936000 PC is at i2c_do_del_adapter+0x20/0xcc LR is at __process_removed_adapter+0x14/0x1c Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none Control: 10c5387d Table: 35bd004a DAC: 00000051 Process sh (pid: 533, stack limit = 0xe4936210) Stack: (0xe4937d28 to 0xe4938000) Backtrace: [<c0667be0>] (i2c_do_del_adapter) from [<c0667cc0>] (__process_removed_adapter+0x14/0x1c) [<c0667cac>] (__process_removed_adapter) from [<c0516998>] (bus_for_each_drv+0x6c/0xa0) [<c051692c>] (bus_for_each_drv) from [<c06685ec>] (i2c_del_adapter+0xbc/0x284) [<c0668530>] (i2c_del_adapter) from [<bf0110ec>] (i2c_imx_remove+0x44/0x164 [i2c_imx]) [<bf0110a8>] (i2c_imx_remove [i2c_imx]) from [<c051a838>] (platform_drv_remove+0x2c/0x44) [<c051a80c>] (platform_drv_remove) from [<c05183d8>] (__device_release_driver+0x90/0x12c) [<c0518348>] (__device_release_driver) from [<c051849c>] (device_release_driver+0x28/0x34) [<c0518474>] (device_release_driver) from [<c0517150>] (unbind_store+0x80/0x104) [<c05170d0>] (unbind_store) from [<c0516520>] (drv_attr_store+0x28/0x34) [<c05164f8>] (drv_attr_store) from [<c0298acc>] (sysfs_kf_write+0x50/0x54) [<c0298a7c>] (sysfs_kf_write) from [<c029801c>] (kernfs_fop_write+0x100/0x214) [<c0297f1c>] (kernfs_fop_write) from [<c0220130>] (__vfs_write+0x34/0x120) [<c02200fc>] (__vfs_write) from [<c0221088>] (vfs_write+0xa8/0x170) [<c0220fe0>] (vfs_write) from [<c0221e74>] (SyS_write+0x4c/0xa8) [<c0221e28>] (SyS_write) from [<c0108a20>] (ret_fast_syscall+0x0/0x1c)
--- drivers/i2c/i2c-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.c +1 -1
@@ -1558,6 +1558,7 @@ int i2c_register_driver(struct module *o/* add the driver to the list of i2c drivers in the driver core */ driver->driver.owner = owner; driver->driver.bus = &i2c_bus_type; +INIT_LIST_HEAD (&driver->clients);/* When registration returns, the driver core * will have called probe() for all matching-but-unbound devices.
@@ -1576,7 +1577,6 @@ int i2c_register_driver(struct module *opr_debug ("i2c-core: driver [%s] registered\n" , driver->driver.name); -INIT_LIST_HEAD (&driver->clients);/* Walk the adapters that are already present */ i2c_for_each_dev (driver, __process_new_driver);
PATCH 207/306 iio: hid-sensors: Fix compilation warning
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sachin Kamat <[email protected]>
commit a034234277d2f51104deadd559dd9584ba00a8cc upstream.
Move the 'static' keyword to beginning of definition to silence the
following compilation warning:drivers/iio/common/hid-sensors/hid-sensor-attributes.c:34:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]
--- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +2 -2
@@ -26,12 +26,12 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> -struct { +static struct {u32 usage_id;int unit;/* 0 for default others from HID sensor spec */ int scale_val0;/* scale, whole number */ int scale_val1;/* scale, fraction in micros */ -}static unit_conversion[] = { +} unit_conversion[] = { {HID_USAGE_SENSOR_ACCEL_3D ,0 ,9 ,806650 }, {HID_USAGE_SENSOR_ACCEL_3D ,HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD ,1 ,0 },
PATCH 208/306 iio: hid-sensors: Increase the precision of scale to fix wrong reading interpretation.
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Song Hongyan <[email protected]>
commit 6f77199e9e4b84340c751c585691d7642a47d226 upstream.
While testing, it was observed that on some platforms the scale value from iio sysfs for gyroscope is always 0 (E.g. Yoga 260). This results in the final angular velocity component values to be zeros.
This is caused by insufficient precision of scale value displayed in sysfs. If the precision is changed to nano from current micro, then this is sufficient to display the scale value on this platform.
Since this can be a problem for all other HID sensors, increase scale precision of all HID sensors to nano from current micro.
Results on Yoga 260:
name scale before scale now
--------------------------------------------gyro_3d 0.000000 0.000000174
als 0.001000 0.001000000magn_3d 0.000001 0.000001000accel_3d 0.000009 0.000009806
--- .../iio/common/hid-sensors/hid-sensor-attributes.c | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +28 -28
@@ -30,26 +30,26 @@ static struct {u32 usage_id;int unit;/* 0 for default others from HID sensor spec */ int scale_val0;/* scale, whole number */ -int scale_val1;/* scale, fraction in micros */ +int scale_val1;/* scale, fraction in nanos */ } unit_conversion[] = { - {HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650}, + {HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650000}, {HID_USAGE_SENSOR_ACCEL_3D, HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD, 1, 0}, {HID_USAGE_SENSOR_ACCEL_3D, - HID_USAGE_SENSOR_UNITS_G, 9, 806650}, + HID_USAGE_SENSOR_UNITS_G, 9, 806650000}, - {HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453}, + {HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453293}, {HID_USAGE_SENSOR_GYRO_3D, HID_USAGE_SENSOR_UNITS_RADIANS_PER_SECOND, 1, 0}, {HID_USAGE_SENSOR_GYRO_3D, - HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453}, + HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453293}, - {HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000}, + {HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000000}, {HID_USAGE_SENSOR_COMPASS_3D, HID_USAGE_SENSOR_UNITS_GAUSS, 1, 0}, - {HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453}, + {HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453293}, {HID_USAGE_SENSOR_INCLINOMETER_3D, - HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453}, + HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453293}, {HID_USAGE_SENSOR_INCLINOMETER_3D, HID_USAGE_SENSOR_UNITS_RADIANS, 1, 0},
@@ -57,7 +57,7 @@ static struct { {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0}, {HID_USAGE_SENSOR_PRESSURE, 0, 100, 0}, - {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000}, + {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000000}, };static int pow_10 (unsigned power)
@@ -266,15 +266,15 @@ EXPORT_SYMBOL(hid_sensor_write_raw_hyst_/* * This fuction applies the unit exponent to the scale. * For example: -* 9.806650 ->exp:2-> val0[980]val1[665000] -* 9.000806 ->exp:2-> val0[900]val1[80600] -* 0.174535 ->exp:2-> val0[17]val1[453500] -* 1.001745 ->exp:0-> val0[1]val1[1745] -* 1.001745 ->exp:2-> val0[100]val1[174500] -* 1.001745 ->exp:4-> val0[10017]val1[450000] -* 9.806650 ->exp:-2-> val0[0]val1[98066] +* 9.806650000 ->exp:2-> val0[980]val1[665000000] +* 9.000806000 ->exp:2-> val0[900]val1[80600000] +* 0.174535293 ->exp:2-> val0[17]val1[453529300] +* 1.001745329 ->exp:0-> val0[1]val1[1745329] +* 1.001745329 ->exp:2-> val0[100]val1[174532900] +* 1.001745329 ->exp:4-> val0[10017]val1[453290000] +* 9.806650000 ->exp:-2-> val0[0]val1[98066500] */ -static void adjust_exponent_micro (int *val0,int *val1,int scale0, +static void adjust_exponent_nano (int *val0,int *val1,int scale0,int scale1,int exp) {int i;
@@ -285,32 +285,32 @@ static void adjust_exponent_micro(int *vif (exp >0 ) { *val0 = scale0 *pow_10 (exp); res =0 ; -if (exp >6 ) { +if (exp >9 ) { *val1 =0 ;return ; }for (i =0 ; i < exp; ++i) { - x = scale1 /pow_10 (5 - i); + x = scale1 /pow_10 (8 - i); res += (pow_10 (exp -1 - i) * x); - scale1 = scale1 %pow_10 (5 - i); + scale1 = scale1 %pow_10 (8 - i); } *val0 += res; *val1 = scale1 *pow_10 (exp); }else if (exp <0 ) { exp =abs (exp); -if (exp >6 ) { +if (exp >9 ) { *val0 = *val1 =0 ;return ; } *val0 = scale0 /pow_10 (exp); rem = scale0 %pow_10 (exp); res =0 ; -for (i =0 ; i < (6 - exp); ++i) { - x = scale1 /pow_10 (5 - i); - res += (pow_10 (5 - exp - i) * x); - scale1 = scale1 %pow_10 (5 - i); +for (i =0 ; i < (9 - exp); ++i) { + x = scale1 /pow_10 (8 - i); + res += (pow_10 (8 - exp - i) * x); + scale1 = scale1 %pow_10 (8 - i); } - *val1 = rem *pow_10 (6 - exp) + res; + *val1 = rem *pow_10 (9 - exp) + res; }else { *val0 = scale0; *val1 = scale1;
@@ -332,14 +332,14 @@ int hid_sensor_format_scale(u32 usage_id unit_conversion[i].unit == attr_info->units) { exp =hid_sensor_convert_exponent ( attr_info->unit_expo); -adjust_exponent_micro (val0, val1, +adjust_exponent_nano (val0, val1, unit_conversion[i].scale_val0, unit_conversion[i].scale_val1, exp);break ; } } -return IIO_VAL_INT_PLUS_MICRO ; +return IIO_VAL_INT_PLUS_NANO ; }EXPORT_SYMBOL (hid_sensor_format_scale);
PATCH 209/306 USB: serial: ftdi_sio: add support for TI CC3200 LaunchPad
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Doug Brown <[email protected]>
commit 9bfef729a3d11f04d12788d749a3ce6b47645734 upstream.
This patch adds support for the TI CC3200 LaunchPad board, which uses a custom USB vendor ID and product ID. Channel A is used for JTAG, and channel B is used for a UART.
--- drivers/usb/serial/ftdi_sio.c | 2 ++ drivers/usb/serial/ftdi_sio_ids.h | 6 ++++++ 2 files changed, 8 insertions(+)
drivers/usb/serial/ftdi_sio.c +2 -0
@@ -1025,6 +1025,8 @@ static const struct usb_device_id id_tab { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) }, { USB_DEVICE(ICPDAS_VID, ICPDAS_I7563U_PID) }, { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) }, + { USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID), + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, { } /* Terminating entry */ };
drivers/usb/serial/ftdi_sio_ids.h +6 -0
@@ -596,6 +596,12 @@#define STK541_PID 0x2109/* Zigbee Controller */ /* +* Texas Instruments +*/ +#define TI_VID 0x0451 +#define TI_CC3200_LAUNCHPAD_PID 0xC32A/* SimpleLink Wi-Fi CC3200 LaunchPad */ + +/* * Blackfin gnICE JTAG * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice */
PATCH 210/306 drivers: staging: nvec: remove bogus reset command for PS/2 interface
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Fertser <[email protected]>
commit d8f8a74d5fece355d2234e1731231d1aebc66b38 upstream.
This command was sent behind serio's back and the answer to it was confusing atkbd probe function which lead to the elantech touchpad getting detected as a keyboard.
To prevent this from happening just let every party do its part of the job.
--- drivers/staging/nvec/nvec_ps2.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/staging/nvec/nvec_ps2.c +0 -4
@@ -104,7 +104,6 @@ static int nvec_mouse_probe(struct platf {struct nvec_chip *nvec =dev_get_drvdata (pdev->dev.parent);struct serio *ser_dev; -char mouse_reset[] = {NVEC_PS2 ,SEND_COMMAND ,PSMOUSE_RST ,3 }; ser_dev =devm_kzalloc (&pdev->dev,sizeof (struct serio ),GFP_KERNEL );if (ser_dev ==NULL )
@@ -125,9 +124,6 @@ static int nvec_mouse_probe(struct platfserio_register_port (ser_dev); -/* mouse reset */ -nvec_write_async (nvec, mouse_reset,sizeof (mouse_reset)); -return 0 ; }
PATCH 211/306 Revert "staging: nvec: ps2: change serio type to passthrough"
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Fertser <[email protected]>
commit 17c1c9ba15b238ef79b51cf40d855c05b58d5934 upstream.
This reverts commit 36b30d6138f4677514aca35ab76c20c1604baaad.
This is necessary to detect paz00 (ac100) touchpad properly as one speaking ETPS/2 protocol. Without it X.org's synaptics driver doesn't work as the touchpad is detected as an ImPS/2 mouse instead.
Commit ec6184b1c717b8768122e25fe6d312f609cc1bb4 changed the way auto-detection is performed on ports marked as pass through and made the issue apparent.
A pass through port is an additional PS/2 port used to connect a slave device to a master device that is using PS/2 to communicate with the host (so slave's PS/2 communication is tunneled over master's PS/2 link). "Synaptics PS/2 TouchPad Interfacing Guide" describes such a setup (PS/2 PASS-THROUGH OPTION section).
Since paz00's embedded controller is not connected to a PS/2 port itself, the PS/2 interface it exposes is not a pass-through one.
--- drivers/staging/nvec/nvec_ps2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/nvec/nvec_ps2.c +1 -1
@@ -109,7 +109,7 @@ static int nvec_mouse_probe(struct platfif (ser_dev ==NULL )return -ENOMEM ; - ser_dev->id.type =SERIO_PS_PSTHRU ; + ser_dev->id.type =SERIO_8042 ; ser_dev->write = ps2_sendcommand; ser_dev->start = ps2_startstreaming; ser_dev->stop = ps2_stopstreaming;
PATCH 212/306 staging: nvec: remove managed resource from PS2 driver
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marc Dietrich <[email protected]>
commit 68fae2f3df455f53d0dfe33483a49020b3b758f3 upstream.
This basicly reverts commit e534f3e9 (staging:nvec: Introduce the use of the managed version of kzalloc). Serio struct should never by managed because it is refcounted. Doing so will lead to a double free oops on module remove.
--- drivers/staging/nvec/nvec_ps2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/nvec/nvec_ps2.c +1 -1
@@ -105,7 +105,7 @@ static int nvec_mouse_probe(struct platfstruct nvec_chip *nvec =dev_get_drvdata (pdev->dev.parent);struct serio *ser_dev; - ser_dev =devm_kzalloc (&pdev->dev,sizeof (struct serio ),GFP_KERNEL ); + ser_dev =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (ser_dev ==NULL )return -ENOMEM ;
PATCH 213/306 mmc: mxs: Initialize the spinlock prior to using it
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
commit f91346e8b5f46aaf12f1df26e87140584ffd1b3f upstream.
An interrupt may occur right after devm_request_irq() is called and prior to the spinlock initialization, leading to a kernel oops, as the interrupt handler uses the spinlock.
In order to prevent this problem, move the spinlock initialization prior to requesting the interrupts.
--- drivers/mmc/host/mxs-mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/mxs-mmc.c +2 -2
@@ -658,13 +658,13 @@ static int mxs_mmc_probe(struct platformplatform_set_drvdata (pdev, mmc); +spin_lock_init (&host->lock); + ret =devm_request_irq (&pdev->dev, irq_err, mxs_mmc_irq_handler,0 ,DRIVER_NAME , host);if (ret) goto out_free_dma; -spin_lock_init (&host->lock); - ret =mmc_add_host (mmc);if (ret) goto out_free_dma;
PATCH 214/306 net: ethernet: ti: cpsw: fix device and of_node leaks
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit c7262aaace1b17a650598063e3b9ee1785fde377 upstream.
Make sure to drop the references taken by of_get_child_by_name() and bus_find_device() before returning from cpsw_phy_sel().
Note that holding a reference to the cpsw-phy-sel device does not prevent the devres-managed private data from going away.
--- drivers/net/ethernet/ti/cpsw-phy-sel.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/ti/cpsw-phy-sel.c +3 -0
@@ -152,9 +152,12 @@ void cpsw_phy_sel(struct device *dev, ph } dev =bus_find_device (&platform_bus_type,NULL , node, match); +of_node_put (node); priv =dev_get_drvdata (dev); priv->cpsw_phy_sel (priv, phy_mode, slave); + +put_device (dev); }EXPORT_SYMBOL_GPL (cpsw_phy_sel);
PATCH 215/306 kbuild: add -fno-PIE
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 8ae94224c9d72fc4d9aaac93b2d7833cf46d7141 upstream.
Debian started to build the gcc with -fPIE by default so the kernel build ends before it starts properly with:
|kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
Also add to KBUILD_AFLAGS due to:
|gcc -Wp,-MD,arch/x86/entry/vdso/vdso32/.note.o.d … -mfentry -DCC_USING_FENTRY … vdso/vdso32/note.S |arch/x86/entry/vdso/vdso32/note.S:1:0: sorry, unimplemented: -mfentry isn’t supported for 32-bit in combination with -fpic
Tagging it stable so it is possible to compile recent stable kernels as well.
--- Makefile | 2 ++ 1 file changed, 2 insertions(+)
Makefile +2 -0
@@ -615,6 +615,8 @@ all: vmlinux include $(srctree)/arch/$(SRCARCH)/Makefile KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) +KBUILD_CFLAGS += $(call cc-option,-fno-PIE) +KBUILD_AFLAGS += $(call cc-option,-fno-PIE) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
PATCH 216/306 scsi: megaraid_sas: fix macro MEGASAS_IS_LOGICAL to avoid regression
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sumit Saxena <[email protected]>
commit 5e5ec1759dd663a1d5a2f10930224dd009e500e8 upstream.
This patch will fix regression caused by commit 1e793f6fc0db ("scsi:megaraid_sas: Fix data integrity failure for JBOD (passthrough) devices").
The problem was that the MEGASAS_IS_LOGICAL macro did not have braces and as a result the driver ended up exposing a lot of non-existing SCSI devices (all SCSI commands to channels 1,2,3 were returned as SUCCESS-DID_OK by driver).
[mkp: clarified patch description]
--- drivers/scsi/megaraid/megaraid_sas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas.h +1 -1
@@ -1734,7 +1734,7 @@ struct megasas_instance_template { };#define MEGASAS_IS_LOGICAL (scp) \ - (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1 + ((scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1)#define MEGASAS_DEV_INDEX (inst, scp) \ ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
PATCH 217/306 scripts/has-stack-protector: add -fno-PIE
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 82031ea29e454b574bc6f49a33683a693ca5d907 upstream.
Adding -no-PIE to the fstack protector check. -no-PIE was introduced before -fstack-protector so there is no need for a runtime check.
Without it the build stops:
|Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong available but compiler is broken
due to -mcmodel=kernel + -fPIE if -fPIE is enabled by default.
Tagging it stable so it is possible to compile recent stable kernels as well.
--- scripts/gcc-x86_64-has-stack-protector.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gcc-x86_64-has-stack-protector.sh +1 -1
@@ -1,6 +1,6 @@ #!/bin/sh -echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs" +echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs" if [ "$?" -eq "0" ] ; then echo y else
PATCH 218/306 rtnl: reset calcit fptr in rtnl_unregister()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Krause <[email protected]>
commit f567e950bf51290755a2539ff2aaef4c26f735d3 upstream.
To avoid having dangling function pointers left behind, reset calcit in rtnl_unregister(), too.
This is no issue so far, as only the rtnl core registers a netlink handler with a calcit hook which won't be unregistered, but may become one if new code makes use of the calcit hook.
--- net/core/rtnetlink.c | 1 + 1 file changed, 1 insertion(+)
net/core/rtnetlink.c +1 -0
@@ -250,6 +250,7 @@ int rtnl_unregister(int protocol, int ms rtnl_msg_handlers[protocol][msgindex].doit =NULL ; rtnl_msg_handlers[protocol][msgindex].dumpit =NULL ; + rtnl_msg_handlers[protocol][msgindex].calcit =NULL ;return 0 ; }
PATCH 219/306 ALSA: hda - add a new condition to check if it is thinkpad
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hui Wang <[email protected]>
commit 2ecb704a1290edb5e3d53a75529192e7ed2a1a28 upstream.
Latest Thinkpad laptops use the HKEY_HID LEN0268 instead of the LEN0068, as a result neither audio mute led nor mic mute led can work any more.
After adding the new HKEY_HID into the is_thinkpad(), both of them works well as before.
---
sound/pci/hda/thinkpad_helper.c +3 -0
@@ -26,6 +26,9 @@ static bool is_thinkpad(struct hda_codecif (ACPI_SUCCESS (acpi_get_devices ("LEN0068" , acpi_check_cb, &found,NULL )) && found)return true; found = false; +if (ACPI_SUCCESS (acpi_get_devices ("LEN0268" , acpi_check_cb, &found,NULL )) && found) +return true; + found = false;return ACPI_SUCCESS (acpi_get_devices ("IBM0068" , acpi_check_cb, &found,NULL )) && found; }
PATCH 220/306 USB: cdc-acm: fix TIOCMIWAIT
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 18266403f3fe507f0246faa1d5432333a2f139ca upstream.
The TIOCMIWAIT implementation would return -EINVAL if any of the three supported signals were included in the mask.
Instead of returning an error in case TIOCM_CTS is included, simply drop the mask check completely, which is in accordance with how other drivers implement this ioctl.
--- drivers/usb/class/cdc-acm.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/class/cdc-acm.c +0 -2
@@ -867,8 +867,6 @@ static int wait_serial_change(struct acmDECLARE_WAITQUEUE (wait, current);struct async_icount old, new; -if (arg & (TIOCM_DSR |TIOCM_RI |TIOCM_CD )) -return -EINVAL ; do { spin_lock_irq(&acm->read_lock); old = acm->oldcount;
PATCH 221/306 PM / sleep: don't suspend parent when async child suspend_{noirq, late} fails
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Brian Norris <[email protected]>
commit 6f75c3fd56daf547d684127a7f83c283c3c160d1 upstream.
Consider two devices, A and B, where B is a child of A, and B utilizes asynchronous suspend (it does not matter whether A is sync or async). If B fails to suspend_noirq() or suspend_late(), or is interrupted by a wakeup (pm_wakeup_pending()), then it aborts and sets the async_error variable. However, device A does not (immediately) check the async_error variable; it may continue to run its own suspend_noirq()/suspend_late() callback. This is bad.
We can resolve this problem by doing our error and wakeup checking (particularly, for the async_error flag) after waiting for children to suspend, instead of before. This also helps align the logic for the noirq and late suspend cases with the logic in __device_suspend().
It's easy to observe this erroneous behavior by, for example, forcing a device to sleep a bit in its suspend_noirq() (to ensure the parent is waiting for the child to complete), then return an error, and watch the parent suspend_noirq() still get called. (Or similarly, fake a wakeup event at the right (or is it wrong?) time.)
--- drivers/base/power/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/base/power/main.c +4 -4
@@ -1014,6 +1014,8 @@ static int __device_suspend_noirq(structchar *info =NULL ;int error =0 ; +dpm_wait_for_children (dev, async); +if (async_error) goto Complete;
@@ -1025,8 +1027,6 @@ static int __device_suspend_noirq(structif (dev->power.syscore || dev->power.direct_complete) goto Complete; -dpm_wait_for_children (dev, async); -if (dev->pm_domain) { info ="noirq power domain " ; callback =pm_noirq_op (&dev->pm_domain->ops, state);
@@ -1155,6 +1155,8 @@ static int __device_suspend_late(struct__pm_runtime_disable (dev, false); +dpm_wait_for_children (dev, async); +if (async_error) goto Complete;
@@ -1166,8 +1168,6 @@ static int __device_suspend_late(structif (dev->power.syscore || dev->power.direct_complete) goto Complete; -dpm_wait_for_children (dev, async); -if (dev->pm_domain) { info ="late power domain " ; callback =pm_late_early_op (&dev->pm_domain->ops, state);
PATCH 222/306 ALSA: hda - Fix mic regression by ASRock mobo fixup
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 9a2541910dc7eaaa6859eea8a0ffda673059a623 upstream.
The commit [1a3f099101b8: ALSA: hda - Fix surround output pins for ASRock B150M mobo] introduced a fixup of pin configs for ASRock mobos to fix the surround outputs. However, this overrides the pin configs of the mic pins as if they are outputs-only, effectively disabling the mic inputs. Of course, it's a regression wrt mic functionality.
Actually the pins 0x18 and 0x1a don't need to be changed; we just need to disable the bogus pins 0x14 and 0x15. Then the auto-parser will pick up mic pins as switchable and assign the surround outputs there.
This patch removes the incorrect pin overrides of NID 0x18 and 0x1a from the ASRock fixup.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=187431
--- sound/pci/hda/patch_realtek.c | 2 -- 1 file changed, 2 deletions(-)
sound/pci/hda/patch_realtek.c +0 -2
@@ -6096,8 +6096,6 @@ static const struct hda_fixup alc662_fix .v.pins = (const struct hda_pintbl[]) { {0x15 ,0x40f000f0 },/* disabled */ {0x16 ,0x40f000f0 },/* disabled */ - {0x18 ,0x01014011 },/* LO */ - {0x1a ,0x01014012 },/* LO */ { } } },
PATCH 223/306 swapfile: fix memory corruption via malformed swapfile
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit dd111be69114cc867f8e826284559bfbc1c40e37 upstream.
When root activates a swap partition whose header has the wrong endianness, nr_badpages elements of badpages are swabbed before nr_badpages has been checked, leading to a buffer overrun of up to 8GB.
This normally is not a security issue because it can only be exploited by root (more specifically, a process with CAP_SYS_ADMIN or the ability to modify a swap file/partition), and such a process can already e.g. modify swapped-out memory of any other userspace process on the system.
--- mm/swapfile.c | 2 ++ 1 file changed, 2 insertions(+)
mm/swapfile.c +2 -0
@@ -2185,6 +2185,8 @@ static unsigned long read_swap_header(stswab32s (&swap_header->info.version);swab32s (&swap_header->info.last_page);swab32s (&swap_header->info.nr_badpages); +if (swap_header->info.nr_badpages >MAX_SWAP_BADPAGES ) +return 0 ;for (i =0 ; i < swap_header->info.nr_badpages; i++)swab32s (&swap_header->info.badpages[i]); }
PATCH 224/306 coredump: fix unfreezable coredumping task
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ryabinin <[email protected]>
commit 70d78fe7c8b640b5acfad56ad341985b3810998a upstream.
It could be not possible to freeze coredumping task when it waits for 'core_state->startup' completion, because threads are frozen in get_signal() before they got a chance to complete 'core_state->startup'.
Inability to freeze a task during suspend will cause suspend to fail. Also CRIU uses cgroup freezer during dump operation. So with an unfreezable task the CRIU dump will fail because it waits for a transition from 'FREEZING' to 'FROZEN' state which will never happen.
Use freezer_do_not_count() to tell freezer to ignore coredumping task while it waits for core_state->startup completion.
--- fs/coredump.c | 3 +++ 1 file changed, 3 insertions(+)
fs/coredump.c +3 -0
@@ -1,6 +1,7 @@#include <linux/slab.h> #include <linux/file.h> #include <linux/fdtable.h> +#include <linux/freezer.h> #include <linux/mm.h> #include <linux/stat.h> #include <linux/fcntl.h>
@@ -385,7 +386,9 @@ static int coredump_wait(int exit_code,if (core_waiters >0 ) {struct core_thread *ptr; +freezer_do_not_count ();wait_for_completion (&core_state->startup); +freezer_count ();/* * Wait for all the threads to become inactive, so that * all the thread context (extended register state, like
PATCH 225/306 dib0700: fix nec repeat handling
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
commit ba13e98f2cebd55a3744c5ffaa08f9dca73bf521 upstream.
When receiving a nec repeat, ensure the correct scancode is repeated rather than a random value from the stack. This removes the need for the bogus uninitialized_var() and also fixes the warnings:
drivers/media/usb/dvb-usb/dib0700_core.c: In function ‘dib0700_rc_urb_completion’:
drivers/media/usb/dvb-usb/dib0700_core.c:679: warning: ‘protocol’ may be used uninitialized in this function
[sean addon: So after writing the patch and submitting it, I've bought the
hardware on ebay. Without this patch you get random scancodes on nec repeats, which the patch indeed fixes.]
--- drivers/media/usb/dvb-usb/dib0700_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/usb/dvb-usb/dib0700_core.c +3 -2
@@ -674,7 +674,7 @@ static void dib0700_rc_urb_completion(st {struct dvb_usb_device *d = purb->context;struct dib0700_rc_response *poll_reply; -u32 uninitialized_var (keycode ); +u32 keycode;u8 toggle;deb_info ("%s()\n" , __func__);
@@ -713,7 +713,8 @@ static void dib0700_rc_urb_completion(stif ((poll_reply->system ==0x00 ) && (poll_reply->data ==0x00 ) && (poll_reply->not_data ==0xff )) { poll_reply->data_state =2 ; -break ; +rc_repeat (d->rc_dev); + goto resubmit; }if ((poll_reply->system ^ poll_reply->not_system) !=0xff ) {
PATCH 226/306 scsi: mpt3sas: Fix secure erase premature termination
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Grodzovsky <[email protected]>
commit 18f6084a989ba1b38702f9af37a2e4049a924be6 upstream.
This is a work around for a bug with LSI Fusion MPT SAS2 when perfoming secure erase. Due to the very long time the operation takes, commands issued during the erase will time out and will trigger execution of the abort hook. Even though the abort hook is called for the specific command which timed out, this leads to entire device halt (scsi_state terminated) and premature termination of the secure erase.
Set device state to busy while ATA passthrough commands are in progress.
[mkp: hand applied to 4.9/scsi-fixes, tweaked patch description]
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +14 -1
@@ -1625,7 +1625,10 @@ _scsih_get_volume_capabilities(struct MPreturn 0 ; } - +static inline bool ata_12_16_cmd (struct scsi_cmnd *scmd) +{ +return (scmd->cmnd[0 ] ==ATA_12 || scmd->cmnd[0 ] ==ATA_16 ); +}/** * _scsih_enable_tlr - setting TLR flags
@@ -3541,6 +3544,13 @@ _scsih_qcmd(struct Scsi_Host *shost, strscsi_print_command (scmd);#endif +/* +* Lock the device for any subsequent command until command is +* done. +*/ +if (ata_12_16_cmd (scmd)) +scsi_internal_device_block (scmd->device); + sas_device_priv_data = scmd->device->hostdata;if (!sas_device_priv_data || !sas_device_priv_data->sas_target) { scmd->result =DID_NO_CONNECT <<16 ;
@@ -4041,6 +4051,9 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *iif (scmd ==NULL )return 1 ; +if (ata_12_16_cmd (scmd)) +scsi_internal_device_unblock (scmd->device,SDEV_RUNNING ); + mpi_request =mpt3sas_base_get_msg_frame (ioc, smid);if (mpi_reply ==NULL ) {
PATCH 227/306 neigh: check error pointer instead of NULL for ipv4_neigh_lookup()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: WANG Cong <[email protected]>
commit 2c1a4311b61072afe2309d4152a7993e92caa41c upstream.
--- net/ipv4/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +1 -1
@@ -747,7 +747,7 @@ static void __ip_do_redirect(struct rtab } n =ipv4_neigh_lookup (&rt->dst,NULL , &new_gw); -if (n) { +if (!IS_ERR (n)) {if (!(n->nud_state &NUD_VALID )) {neigh_event_send (n,NULL ); }else {
PATCH 228/306 ipv4: use new_gw for redirect neigh lookup
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Suryaputra Lin <[email protected]>
commit 969447f226b451c453ddc83cac6144eaeac6f2e3 upstream.
In v2.6, ip_rt_redirect() calls arp_bind_neighbour() which returns 0 and then the state of the neigh for the new_gw is checked. If the state isn't valid then the redirected route is deleted. This behavior is maintained up to v3.5.7 by check_peer_redirect() because rt->rt_gateway is assigned to peer->redirect_learned.a4 before calling ipv4_neigh_lookup().
After commit 5943634fc559 ("ipv4: Maintain redirect and PMTU info in struct rtable again."), ipv4_neigh_lookup() is performed without the rt_gateway assigned to the new_gw. In the case when rt_gateway (old_gw) isn't zero, the function uses it as the key. The neigh is most likely valid since the old_gw is the one that sends the ICMP redirect message. Then the new_gw is assigned to fib_nh_exception. The problem is: the new_gw ARP may never gets resolved and the traffic is blackholed.
So, use the new_gw for neigh lookup.
Changes from v1:
- use __ipv4_neigh_lookup instead (per Eric Dumazet).
--- net/ipv4/route.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/route.c +3 -1
@@ -746,7 +746,9 @@ static void __ip_do_redirect(struct rtab goto reject_redirect; } - n =ipv4_neigh_lookup (&rt->dst,NULL , &new_gw); + n =__ipv4_neigh_lookup (rt->dst.dev, new_gw); +if (!n) + n =neigh_create (&arp_tbl, &new_gw, rt->dst.dev);if (!IS_ERR (n)) {if (!(n->nud_state &NUD_VALID )) {neigh_event_send (n,NULL );
PATCH 229/306 Fix USB CB/CBI storage devices with CONFIG_VMAP_STACK=y
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Petr Vandrovec <[email protected]>
commit 2ce9d2272b98743b911196c49e7af5841381c206 upstream.
Some code (all error handling) submits CDBs that are allocated on the stack. This breaks with CB/CBI code that tries to create URB directly from SCSI command buffer - which happens to be in vmalloced memory with vmalloced kernel stacks.
Let's make copy of the command in usb_stor_CB_transport.
--- drivers/usb/storage/transport.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/storage/transport.c +6 -1
@@ -919,10 +919,15 @@ int usb_stor_CB_transport(struct scsi_cm/* COMMAND STAGE */ /* let's send the command via the control pipe */ +/* +* Command is sometime (f.e. after scsi_eh_prep_cmnd) on the stack. +* Stack may be vmallocated. So no DMA for us. Make a copy. +*/ +memcpy (us->iobuf, srb->cmnd, srb->cmd_len); result =usb_stor_ctrl_transfer (us, us->send_ctrl_pipe,US_CBI_ADSC ,USB_TYPE_CLASS |USB_RECIP_INTERFACE ,0 , - us->ifnum, srb->cmnd, srb->cmd_len); + us->ifnum, us->iobuf, srb->cmd_len);/* check the return code for the command */ usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d\n",
PATCH 230/306 fuse: fix fuse_write_end() if zero bytes were copied
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 59c3b76cc61d1d676f965c192cc7969aa5cb2744 upstream.
If pos is at the beginning of a page and copied is zero then page is not zeroed but is marked uptodate.
Fix by skipping everything except unlock/put of page if zero bytes were copied.
--- fs/fuse/file.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/fuse/file.c +6 -0
@@ -2058,6 +2058,10 @@ static int fuse_write_end(struct file *f {struct inode *inode = page->mapping->host; +/* Haven't copied anything? Skip zeroing, size extending, dirtying. */ +if (!copied) + goto unlock; +if (!PageUptodate (page)) {/* Zero any unwritten bytes at the end of the page */ size_t endoff = (pos + copied) & ~PAGE_CACHE_MASK ;
@@ -2068,6 +2072,8 @@ static int fuse_write_end(struct file *ffuse_write_update_size (inode, pos + copied);set_page_dirty (page); + +unlock:unlock_page (page);page_cache_release (page);
PATCH 231/306 kbuild: Steal gcc's pie from the very beginning
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov <[email protected]>
commit c6a385539175ebc603da53aafb7753d39089f32e upstream.
So Sebastian turned off the PIE for kernel builds but that was too late
- Kbuild.include already uses KBUILD_CFLAGS and trying to disable gcc options with, say cc-disable-warning, fails:
gcc -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
...
-Wno-sign-compare -fno-asynchronous-unwind-tables -Wframe-address -c -x c /dev/null -o .31392.tmp /dev/null:1:0: error: code model kernel does not support PIC mode
because that returns an error and we can't disable the warning. For example in this case:
KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
which leads to gcc issuing all those warnings again.
So let's turn off PIE/PIC at the earliest possible moment, when we declare KBUILD_CFLAGS so that cc-disable-warning picks it up too.
Also, we need the $(call cc-option ...) because -fno-PIE is supported since gcc v3.4 and our lowest supported gcc version is 3.2 right now.
--- Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Makefile +3 -4
@@ -407,11 +407,12 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstric -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration \ -Wno-format-security \ - -std=gnu89 + -std=gnu89 $(call cc-option,-fno-PIE) + KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := -KBUILD_AFLAGS := -D__ASSEMBLY__ +KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE) KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
@@ -615,8 +616,6 @@ all: vmlinux include $(srctree)/arch/$(SRCARCH)/Makefile KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) -KBUILD_CFLAGS += $(call cc-option,-fno-PIE) -KBUILD_AFLAGS += $(call cc-option,-fno-PIE) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
PATCH 232/306 usb: chipidea: move the lock initialization to core file
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Chen <[email protected]>
commit a5d906bb261cde5f881a949d3b0fbaa285dcc574 upstream.
This can fix below dump when the lock is accessed at host mode due to it is not initialized.
[ 46.119638] INFO: trying to register non-static key. [ 46.124643] the code is fine but needs lockdep annotation. [ 46.130144] turning off the locking correctness validator. [ 46.135659] CPU: 0 PID: 690 Comm: cat Not tainted 4.9.0-rc3-00079-g4b75f1d #1210 [ 46.143075] Hardware name: Freescale i.MX6 SoloX (Device Tree) [ 46.148923] Backtrace: [ 46.151448] [<c010c460>] (dump_backtrace) from [<c010c658>] (show_stack+0x18/0x1c) [ 46.159038] r7:edf52000 [ 46.161412] r6:60000193 [ 46.163967] r5:00000000 [ 46.165035] r4:c0e25c2c
[ 46.169109] [<c010c640>] (show_stack) from [<c03f58a4>] (dump_stack+0xb4/0xe8) [ 46.176362] [<c03f57f0>] (dump_stack) from [<c016d690>] (register_lock_class+0x4fc/0x56c) [ 46.184554] r10:c0e25d24 [ 46.187014] r9:edf53e70 [ 46.189569] r8:c1642444 [ 46.190637] r7:ee9da024 [ 46.193191] r6:00000000 [ 46.194258] r5:00000000 [ 46.196812] r4:00000000 [ 46.199185] r3:00000001
[ 46.203259] [<c016d194>] (register_lock_class) from [<c0171294>] (__lock_acquire+0x80/0x10f0) [ 46.211797] r10:c0e25d24 [ 46.214257] r9:edf53e70 [ 46.216813] r8:ee9da024 [ 46.217880] r7:c1642444 [ 46.220435] r6:edcd1800 [ 46.221502] r5:60000193 [ 46.224057] r4:00000000
[ 46.227953] [<c0171214>] (__lock_acquire) from [<c01726c0>] (lock_acquire+0x74/0x94) [ 46.235710] r10:00000001 [ 46.238169] r9:edf53e70 [ 46.240723] r8:edf53f80 [ 46.241790] r7:00000001 [ 46.244344] r6:00000001 [ 46.245412] r5:60000193 [ 46.247966] r4:00000000
[ 46.251866] [<c017264c>] (lock_acquire) from [<c096c8fc>] (_raw_spin_lock_irqsave+0x40/0x54) [ 46.260319] r7:ee1c6a00 [ 46.262691] r6:c062a570 [ 46.265247] r5:20000113 [ 46.266314] r4:ee9da014
[ 46.270393] [<c096c8bc>] (_raw_spin_lock_irqsave) from [<c062a570>] (ci_port_test_show+0x2c/0x70) [ 46.279280] r6:eebd2000 [ 46.281652] r5:ee9da010 [ 46.284207] r4:ee9da014
[ 46.286810] [<c062a544>] (ci_port_test_show) from [<c0248d04>] (seq_read+0x1ac/0x4f8) [ 46.294655] r9:edf53e70 [ 46.297028] r8:edf53f80 [ 46.299583] r7:ee1c6a00 [ 46.300650] r6:00000001 [ 46.303205] r5:00000000 [ 46.304273] r4:eebd2000 [ 46.306850] [<c0248b58>] (seq_read) from [<c039e864>] (full_proxy_read+0x54/0x6c) [ 46.314348] r10:00000000 [ 46.316808] r9:c0a6ad30 [ 46.319363] r8:edf53f80 [ 46.320430] r7:00020000 [ 46.322986] r6:b6de3000 [ 46.324053] r5:ee1c6a00 [ 46.326607] r4:c0248b58
[ 46.330505] [<c039e810>] (full_proxy_read) from [<c021ec98>] (__vfs_read+0x34/0x118) [ 46.338262] r9:edf52000 [ 46.340635] r8:c0107fc4 [ 46.343190] r7:00020000 [ 46.344257] r6:edf53f80 [ 46.346812] r5:c039e810 [ 46.347879] r4:ee1c6a00 [ 46.350447] [<c021ec64>] (__vfs_read) from [<c021fbd0>] (vfs_read+0x8c/0x11c) [ 46.357597] r9:edf52000 [ 46.359969] r8:c0107fc4 [ 46.362524] r7:edf53f80 [ 46.363592] r6:b6de3000 [ 46.366147] r5:ee1c6a00 [ 46.367214] r4:00020000 [ 46.369782] [<c021fb44>] (vfs_read) from [<c0220a4c>] (SyS_read+0x4c/0xa8) [ 46.376672] r8:c0107fc4 [ 46.379045] r7:00020000 [ 46.381600] r6:b6de3000 [ 46.382667] r5:ee1c6a00 [ 46.385222] r4:ee1c6a00
[ 46.387817] [<c0220a00>] (SyS_read) from [<c0107e20>] (ret_fast_syscall+0x0/0x1c) [ 46.395314] r7:00000003 [ 46.397687] r6:b6de3000 [ 46.400243] r5:00020000 [ 46.401310] r4:00020000
ci13xxx variables from udc to ci")
--- drivers/usb/chipidea/core.c | 1 + drivers/usb/chipidea/udc.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/usb/chipidea/core.c +1 -0
@@ -584,6 +584,7 @@ static int ci_hdrc_probe(struct platformreturn -ENOMEM ; } +spin_lock_init (&ci->lock); ci->dev = dev; ci->platdata =dev_get_platdata (dev); ci->imx28_write_fix = !!(ci->platdata->flags &
drivers/usb/chipidea/udc.c +0 -2
@@ -1798,8 +1798,6 @@ static int udc_start(struct ci_hdrc *ci)struct device *dev = ci->dev;int retval =0 ; -spin_lock_init (&ci->lock); - ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ;
PATCH 233/306 igmp: do not remove igmp souce list info when set link down
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
commit 24803f38a5c0b6c57ed800b47e695f9ce474bc3a upstream.
In commit 24cf3af3fed5 ("igmp: call ip_mc_clear_src..."), we forgot to remove igmpv3_clear_delrec() in ip_mc_down(), which also called ip_mc_clear_src(). This make us clear all IGMPv3 source filter info after NETDEV_DOWN. Move igmpv3_clear_delrec() to ip_mc_destroy_dev() and then no need ip_mc_clear_src() in ip_mc_destroy_dev().
On the other hand, we should restore back instead of free all source filter info in igmpv3_del_delrec(). Or we will not able to restore IGMPv3 source filter info after NETDEV_UP and NETDEV_POST_TYPE_CHANGE.
[bwh: Backported to 3.16: use IGMP_Unsolicited_Report_Count instead of
sysctl_igmp_qrv]
---
net/ipv4/igmp.c +35 -14
@@ -164,7 +164,7 @@ static int unsolicited_report_interval(s }static void igmpv3_add_delrec (struct in_device *in_dev,struct ip_mc_list *im); -static void igmpv3_del_delrec (struct in_device *in_dev,__be32 multiaddr); +static void igmpv3_del_delrec (struct in_device *in_dev,struct ip_mc_list *im);static void igmpv3_clear_delrec (struct in_device *in_dev);static int sf_setstate (struct ip_mc_list *pmc);static void sf_markstate (struct ip_mc_list *pmc);
@@ -1104,10 +1104,14 @@ static void igmpv3_add_delrec(struct in_spin_unlock_bh (&in_dev->mc_tomb_lock); } -static void igmpv3_del_delrec (struct in_device *in_dev,__be32 multiaddr) +/* +* restore ip_mc_list deleted records +*/ +static void igmpv3_del_delrec (struct in_device *in_dev,struct ip_mc_list *im) {struct ip_mc_list *pmc, *pmc_prev; -struct ip_sf_list *psf, *psf_next; +struct ip_sf_list *psf; +__be32 multiaddr = im->multiaddr;spin_lock_bh (&in_dev->mc_tomb_lock); pmc_prev =NULL ;
@@ -1123,16 +1127,26 @@ static void igmpv3_del_delrec(struct in_ in_dev->mc_tomb = pmc->next; }spin_unlock_bh (&in_dev->mc_tomb_lock); + +spin_lock_bh (&im->lock);if (pmc) { -for (psf = pmc->tomb; psf; psf = psf_next) { - psf_next = psf->sf_next; -kfree (psf); + im->interface = pmc->interface; + im->crcount = in_dev->mr_qrv ?: IGMP_Unsolicited_Report_Count; + im->sfmode = pmc->sfmode; +if (pmc->sfmode ==MCAST_INCLUDE ) { + im->tomb = pmc->tomb; + im->sources = pmc->sources; +for (psf = im->sources; psf; psf = psf->sf_next) + psf->sf_crcount = im->crcount; }in_dev_put (pmc->interface); -kfree (pmc); } +spin_unlock_bh (&im->lock); } +/* +* flush ip_mc_list deleted records +*/ static void igmpv3_clear_delrec (struct in_device *in_dev) {struct ip_mc_list *pmc, *nextpmc;
@@ -1330,7 +1344,7 @@ void ip_mc_inc_group(struct in_device *iip_mc_hash_add (in_dev, im);#ifdef CONFIG_IP_MULTICAST -igmpv3_del_delrec (in_dev, im->multiaddr); +igmpv3_del_delrec (in_dev, im);#endif igmp_group_added (im);if (!in_dev->dead)
@@ -1421,8 +1435,12 @@ void ip_mc_remap(struct in_device *in_deASSERT_RTNL (); -for_each_pmc_rtnl (in_dev, pmc) +for_each_pmc_rtnl (in_dev, pmc) { +#ifdef CONFIG_IP_MULTICAST +igmpv3_del_delrec (in_dev, pmc); +#endif igmp_group_added (pmc); + } }/* Device going down */
@@ -1443,7 +1461,6 @@ void ip_mc_down(struct in_device *in_dev in_dev->mr_gq_running =0 ;if (del_timer (&in_dev->mr_gq_timer))__in_dev_put (in_dev); -igmpv3_clear_delrec (in_dev);#endif ip_mc_dec_group (in_dev,IGMP_ALL_HOSTS );
@@ -1474,8 +1491,12 @@ void ip_mc_up(struct in_device *in_dev)ip_mc_inc_group (in_dev,IGMP_ALL_HOSTS ); -for_each_pmc_rtnl (in_dev, pmc) +for_each_pmc_rtnl (in_dev, pmc) { +#ifdef CONFIG_IP_MULTICAST +igmpv3_del_delrec (in_dev, pmc); +#endif igmp_group_added (pmc); + } }/*
@@ -1490,13 +1511,13 @@ void ip_mc_destroy_dev(struct in_device/* Deactivate timers */ ip_mc_down (in_dev); +#ifdef CONFIG_IP_MULTICAST +igmpv3_clear_delrec (in_dev); +#endif while ((i =rtnl_dereference (in_dev->mc_list)) !=NULL ) { in_dev->mc_list = i->next_rcu; in_dev->mc_count--; - -/* We've dropped the groups in ip_mc_down already */ -ip_mc_clear_src (i);ip_ma_put (i); } }
PATCH 234/306 rtnetlink: fix rtnl_vfinfo_size
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
commit 7e75f74a171a8146cc3ee92d5562878b40c25fb5 upstream.
The size reported by rtnl_vfinfo_size doesn't match the space used by rtnl_fill_vfinfo.
rtnl_vfinfo_size currently doesn't account for the nest attributes used by statistics (added in commit 3b766cd83232), nor for struct ifla_vf_tx_rate (since commit ed616689a3d9, which added ifla_vf_rate to the dump without removing ifla_vf_tx_rate, but replaced ifla_vf_tx_rate with ifla_vf_rate in the size computation).
--- net/core/rtnetlink.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/core/rtnetlink.c +4 -3
@@ -794,12 +794,13 @@ static inline int rtnl_vfinfo_size(constif (dev->dev.parent &&dev_is_pci (dev->dev.parent) && (ext_filter_mask &RTEXT_FILTER_VF )) {int num_vfs =dev_num_vf (dev->dev.parent); -size_t size =nla_total_size (sizeof (struct nlattr )); - size +=nla_total_size (num_vfs *sizeof (struct nlattr )); +size_t size =nla_total_size (0 ); size += num_vfs * - (nla_total_size (sizeof (struct ifla_vf_mac )) + + (nla_total_size (0 ) + +nla_total_size (sizeof (struct ifla_vf_mac )) +nla_total_size (sizeof (struct ifla_vf_vlan )) +nla_total_size (sizeof (struct ifla_vf_spoofchk )) + +nla_total_size (sizeof (struct ifla_vf_tx_rate )) +nla_total_size (sizeof (struct ifla_vf_rate )) +nla_total_size (sizeof (struct ifla_vf_link_state )));return size;
PATCH 235/306 mfd: core: Fix device reference leak in mfd_clone_cell
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 722f191080de641f023feaa7d5648caf377844f5 upstream.
Make sure to drop the reference taken by bus_find_device_by_name() before returning from mfd_clone_cell().
--- drivers/mfd/mfd-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/mfd-core.c +2 -0
@@ -285,6 +285,8 @@ int mfd_clone_cell(const char *cell, con clones[i]); } +put_device (dev); +return 0 ; }EXPORT_SYMBOL (mfd_clone_cell);
PATCH 236/306 USB: serial: cp210x: add ID for the Zone DPMX
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Jakma <[email protected]>
commit 2ab13292d7a314fa45de0acc808e41aaad31989c upstream.
The BRIM Brothers Zone DPMX is a bicycle powermeter. This ID is for the USB serial interface in its charging dock for the control pods, via which some settings for the pods can be modified.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -130,6 +130,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */ { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */ { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */ + { USB_DEVICE(0x10C4, 0x8962) }, /* Brim Brothers charging dock */ { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */ { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */ { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
PATCH 237/306 nvme/pci: Don't free queues on error
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
commit d48756228ee9161ac8836b346589a43fabdc9f3c upstream.
The nvme_remove function tears down all allocated resources in the correct order, so no need to free queues on error during initialization. This fixes possible use-after-free errors when queues are still associated with a blk-mq hctx.
[bwh: Backported to 3.16:
- Adjust filename, context
- Only nvme_setup_io_queues() needs to be fixed]
---
drivers/block/nvme-core.c +1 -5
@@ -2196,7 +2196,7 @@ static int nvme_setup_io_queues(struct n result =queue_request_irq (dev, adminq, adminq->irqname);if (result) { adminq->q_suspended =1 ; - goto free_queues; +return result; }/* Free previously allocated queues that are no longer usable */
@@ -2204,10 +2204,6 @@ static int nvme_setup_io_queues(struct nnvme_assign_io_queues (dev);return 0 ; - - free_queues: -nvme_free_queues (dev,1 ); -return result; }/*
PATCH 238/306 IB/uverbs: Fix leak of XRC target QPs
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tariq Toukan <[email protected]>
commit 5b810a242c28e1d8d64d718cebe75b79d86a0b2d upstream.
The real QP is destroyed in case of the ref count reaches zero, but for XRC target QPs this call was missed and caused to QP leaks.
Let's call to destroy for all flows.
--- drivers/infiniband/core/uverbs_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/infiniband/core/uverbs_main.c +2 -5
@@ -240,12 +240,9 @@ static int ib_uverbs_cleanup_ucontext(st container_of(uobj, struct ib_uqp_object, uevent.uobject);idr_remove_uobj (&ib_uverbs_qp_idr, uobj); -if (qp != qp->real_qp) { -ib_close_qp (qp); - }else { +if (qp == qp->real_qp)ib_uverbs_detach_umcast (qp, uqp); -ib_destroy_qp (qp); - } +ib_destroy_qp (qp);ib_uverbs_release_uevent (file, &uqp->uevent);kfree (uqp); }
PATCH 239/306 IB/cm: Mark stale CM id's whenever the mad agent was unregistered
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mark Bloch <[email protected]>
commit 9db0ff53cb9b43ed75bacd42a89c1a0ab048b2b0 upstream.
When there is a CM id object that has port assigned to it, it means that the cm-id asked for the specific port that it should go by it, but if that port was removed (hot-unplug event) the cm-id was not updated. In order to fix that the port keeps a list of all the cm-id's that are planning to go by it, whenever the port is removed it marks all of them as invalid.
This commit fixes a kernel panic which happens when running traffic between guests and we force reboot a guest mid traffic, it triggers a kernel panic:
Call Trace: [<ffffffff815271fa>] ? panic+0xa7/0x16f [<ffffffff8152b534>] ? oops_end+0xe4/0x100 [<ffffffff8104a00b>] ? no_context+0xfb/0x260 [<ffffffff81084db2>] ? del_timer_sync+0x22/0x30 [<ffffffff8104a295>] ? __bad_area_nosemaphore+0x125/0x1e0 [<ffffffff81084240>] ? process_timeout+0x0/0x10 [<ffffffff8104a363>] ? bad_area_nosemaphore+0x13/0x20 [<ffffffff8104aabf>] ? __do_page_fault+0x31f/0x480 [<ffffffff81065df0>] ? default_wake_function+0x0/0x20 [<ffffffffa0752675>] ? free_msg+0x55/0x70 [mlx5_core] [<ffffffffa0753434>] ? cmd_exec+0x124/0x840 [mlx5_core] [<ffffffff8105a924>] ? find_busiest_group+0x244/0x9f0 [<ffffffff8152d45e>] ? do_page_fault+0x3e/0xa0 [<ffffffff8152a815>] ? page_fault+0x25/0x30 [<ffffffffa024da25>] ? cm_alloc_msg+0x35/0xc0 [ib_cm] [<ffffffffa024e821>] ? ib_send_cm_dreq+0xb1/0x1e0 [ib_cm] [<ffffffffa024f836>] ? cm_destroy_id+0x176/0x320 [ib_cm] [<ffffffffa024fb00>] ? ib_destroy_cm_id+0x10/0x20 [ib_cm] [<ffffffffa034f527>] ? ipoib_cm_free_rx_reap_list+0xa7/0x110 [ib_ipoib] [<ffffffffa034f590>] ? ipoib_cm_rx_reap+0x0/0x20 [ib_ipoib] [<ffffffffa034f5a5>] ? ipoib_cm_rx_reap+0x15/0x20 [ib_ipoib] [<ffffffff81094d20>] ? worker_thread+0x170/0x2a0 [<ffffffff8109b2a0>] ? autoremove_wake_function+0x0/0x40 [<ffffffff81094bb0>] ? worker_thread+0x0/0x2a0 [<ffffffff8109aef6>] ? kthread+0x96/0xa0 [<ffffffff8100c20a>] ? child_rip+0xa/0x20 [<ffffffff8109ae60>] ? kthread+0x0/0xa0 [<ffffffff8100c200>] ? child_rip+0x0/0x20
---
drivers/infiniband/core/cm.c +109 -16
@@ -80,6 +80,8 @@ static struct ib_cm {__be32 random_id_operand;struct list_head timewait_list;struct workqueue_struct *wq; +/* Sync on cm change port state */ +spinlock_t state_lock; } cm;/* Counter indexes ordered by attribute ID */
@@ -161,6 +163,8 @@ struct cm_port {struct ib_mad_agent *mad_agent;struct kobject port_obj;u8 port_num; +struct list_head cm_priv_prim_list; +struct list_head cm_priv_altr_list;struct cm_counter_group counter_group[CM_COUNTER_GROUPS ]; };
@@ -240,6 +244,12 @@ struct cm_id_private {u8 service_timeout;u8 target_ack_delay; +struct list_head prim_list; +struct list_head altr_list; +/* Indicates that the send port mad is registered and av is set */ +int prim_send_port_not_ready; +int altr_send_port_not_ready; +struct list_head work_list;atomic_t work_count; };
@@ -258,19 +268,46 @@ static int cm_alloc_msg(struct cm_id_pristruct ib_mad_agent *mad_agent;struct ib_mad_send_buf *m;struct ib_ah *ah; +struct cm_av *av; +unsigned long flags, flags2; +int ret =0 ; +/* don't let the port to be released till the agent is down */ +spin_lock_irqsave (&cm.state_lock, flags2); +spin_lock_irqsave (&cm.lock, flags); +if (!cm_id_priv->prim_send_port_not_ready) + av = &cm_id_priv->av; +else if (!cm_id_priv->altr_send_port_not_ready && + (cm_id_priv->alt_av.port)) + av = &cm_id_priv->alt_av; +else { +pr_info ("%s: not valid CM id\n" , __func__); + ret = -ENODEV ; +spin_unlock_irqrestore (&cm.lock, flags); + goto out; + } +spin_unlock_irqrestore (&cm.lock, flags); +/* Make sure the port haven't released the mad yet */ mad_agent = cm_id_priv->av.port->mad_agent; - ah =ib_create_ah (mad_agent->qp->pd, &cm_id_priv->av.ah_attr); -if (IS_ERR (ah)) -return PTR_ERR (ah); +if (!mad_agent) { +pr_info ("%s: not a valid MAD agent\n" , __func__); + ret = -ENODEV ; + goto out; + } + ah =ib_create_ah (mad_agent->qp->pd, &av->ah_attr); +if (IS_ERR (ah)) { + ret =PTR_ERR (ah); + goto out; + } m =ib_create_send_mad (mad_agent, cm_id_priv->id.remote_cm_qpn, - cm_id_priv->av.pkey_index, + av->pkey_index,0 ,IB_MGMT_MAD_HDR ,IB_MGMT_MAD_DATA ,GFP_ATOMIC );if (IS_ERR (m)) {ib_destroy_ah (ah); -return PTR_ERR (m); + ret =PTR_ERR (m); + goto out; }/* Timeout set by caller if response is expected. */
@@ -280,7 +317,10 @@ static int cm_alloc_msg(struct cm_id_priatomic_inc (&cm_id_priv->refcount); m->context[0 ] = cm_id_priv; *msg = m; -return 0 ; + +out: +spin_unlock_irqrestore (&cm.state_lock, flags2); +return ret; } static int cm_alloc_response_msg(struct cm_port *port,
@@ -349,7 +389,8 @@ static void cm_init_av_for_response(stru grh, &av->ah_attr); } -static int cm_init_av_by_path (struct ib_sa_path_rec *path,struct cm_av *av) +static int cm_init_av_by_path (struct ib_sa_path_rec *path,struct cm_av *av, +struct cm_id_private *cm_id_priv) {struct cm_device *cm_dev;struct cm_port *port =NULL ;
@@ -382,7 +423,17 @@ static int cm_init_av_by_path(struct ib_memcpy (av->smac, path->smac,sizeof (av->smac)); av->valid =1 ; -return 0 ; +spin_lock_irqsave (&cm.lock, flags); +if (&cm_id_priv->av == av) +list_add_tail (&cm_id_priv->prim_list, &port->cm_priv_prim_list); +else if (&cm_id_priv->alt_av == av) +list_add_tail (&cm_id_priv->altr_list, &port->cm_priv_altr_list); +else + ret = -EINVAL ; + +spin_unlock_irqrestore (&cm.lock, flags); + +return ret; }static int cm_alloc_id (struct cm_id_private *cm_id_priv)
@@ -719,6 +770,8 @@ struct ib_cm_id *ib_create_cm_id(structspin_lock_init (&cm_id_priv->lock);init_completion (&cm_id_priv->comp);INIT_LIST_HEAD (&cm_id_priv->work_list); +INIT_LIST_HEAD (&cm_id_priv->prim_list); +INIT_LIST_HEAD (&cm_id_priv->altr_list);atomic_set (&cm_id_priv->work_count,-1 );atomic_set (&cm_id_priv->refcount,1 );return &cm_id_priv->id;
@@ -917,6 +970,15 @@ retest:break ; } +spin_lock_irq (&cm.lock); +if (!list_empty (&cm_id_priv->altr_list) && + (!cm_id_priv->altr_send_port_not_ready)) +list_del (&cm_id_priv->altr_list); +if (!list_empty (&cm_id_priv->prim_list) && + (!cm_id_priv->prim_send_port_not_ready)) +list_del (&cm_id_priv->prim_list); +spin_unlock_irq (&cm.lock); +cm_free_id (cm_id->local_id);cm_deref_id (cm_id_priv);wait_for_completion (&cm_id_priv->comp);
@@ -1140,12 +1202,13 @@ int ib_send_cm_req(struct ib_cm_id *cm_i goto out; } - ret =cm_init_av_by_path (param->primary_path, &cm_id_priv->av); + ret =cm_init_av_by_path (param->primary_path, &cm_id_priv->av, + cm_id_priv);if (ret) goto error1;if (param->alternate_path) { ret =cm_init_av_by_path (param->alternate_path, - &cm_id_priv->alt_av); + &cm_id_priv->alt_av, cm_id_priv);if (ret) goto error1; }
@@ -1568,7 +1631,7 @@ static int cm_req_handler(struct cm_workmemcpy (work->path[0 ].dmac, cm_id_priv->av.ah_attr.dmac,ETH_ALEN ); work->path[0 ].vlan_id = cm_id_priv->av.ah_attr.vlan_id; - ret =cm_init_av_by_path (&work->path[0 ], &cm_id_priv->av); + ret =cm_init_av_by_path (&work->path[0 ], &cm_id_priv->av, cm_id_priv);if (ret) {ib_get_cached_gid (work->port->cm_dev->ib_device, work->port->port_num,0 , &work->path[0 ].sgid);
@@ -1578,7 +1641,8 @@ static int cm_req_handler(struct cm_work goto rejected; }if (req_msg->alt_local_lid) { - ret =cm_init_av_by_path (&work->path[1 ], &cm_id_priv->alt_av); + ret =cm_init_av_by_path (&work->path[1 ], &cm_id_priv->alt_av, + cm_id_priv);if (ret) { ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_ALT_GID, &work->path[0].sgid,
@@ -2633,7 +2697,8 @@ int ib_send_cm_lap(struct ib_cm_id *cm_i goto out; } - ret =cm_init_av_by_path (alternate_path, &cm_id_priv->alt_av); + ret =cm_init_av_by_path (alternate_path, &cm_id_priv->alt_av, + cm_id_priv);if (ret) goto out; cm_id_priv->alt_av.timeout =
@@ -2745,7 +2810,8 @@ static int cm_lap_handler(struct cm_workcm_init_av_for_response (work->port, work->mad_recv_wc->wc, work->mad_recv_wc->recv_buf.grh, &cm_id_priv->av); -cm_init_av_by_path (param->alternate_path, &cm_id_priv->alt_av); +cm_init_av_by_path (param->alternate_path, &cm_id_priv->alt_av, + cm_id_priv); ret =atomic_inc_and_test (&cm_id_priv->work_count);if (!ret)list_add_tail (&work->list, &cm_id_priv->work_list);
@@ -2937,7 +3003,7 @@ int ib_send_cm_sidr_req(struct ib_cm_idreturn -EINVAL ; cm_id_priv = container_of(cm_id, struct cm_id_private, id); - ret =cm_init_av_by_path (param->path, &cm_id_priv->av); + ret =cm_init_av_by_path (param->path, &cm_id_priv->av, cm_id_priv);if (ret) goto out;
@@ -3358,7 +3424,9 @@ out:static int cm_migrate (struct ib_cm_id *cm_id) {struct cm_id_private *cm_id_priv; +struct cm_av tmp_av;unsigned long flags; +int tmp_send_port_not_ready;int ret =0 ; cm_id_priv = container_of(cm_id, struct cm_id_private, id);
@@ -3367,7 +3435,14 @@ static int cm_migrate(struct ib_cm_id *c (cm_id->lap_state == IB_CM_LAP_UNINIT || cm_id->lap_state == IB_CM_LAP_IDLE)) { cm_id->lap_state =IB_CM_LAP_IDLE ; +/* Swap address vector */ + tmp_av = cm_id_priv->av; cm_id_priv->av = cm_id_priv->alt_av; + cm_id_priv->alt_av = tmp_av; +/* Swap port send ready state */ + tmp_send_port_not_ready = cm_id_priv->prim_send_port_not_ready; + cm_id_priv->prim_send_port_not_ready = cm_id_priv->altr_send_port_not_ready; + cm_id_priv->altr_send_port_not_ready = tmp_send_port_not_ready; } else ret = -EINVAL ;spin_unlock_irqrestore (&cm_id_priv->lock, flags);
@@ -3799,6 +3874,9 @@ static void cm_add_one(struct ib_device port->cm_dev = cm_dev; port->port_num = i; +INIT_LIST_HEAD (&port->cm_priv_prim_list); +INIT_LIST_HEAD (&port->cm_priv_altr_list); + ret =cm_create_port_fs (port);if (ret) goto error1;
@@ -3845,6 +3923,8 @@ static void cm_remove_one(struct ib_devi {struct cm_device *cm_dev;struct cm_port *port; +struct cm_id_private *cm_id_priv; +struct ib_mad_agent *cur_mad_agent;struct ib_port_modify port_modify = { .clr_port_cap_mask =IB_PORT_CM_SUP };
@@ -3862,10 +3942,22 @@ static void cm_remove_one(struct ib_devifor (i =1 ; i <= ib_device->phys_port_cnt; i++) { port = cm_dev->port[i-1 ];ib_modify_port (ib_device, port->port_num,0 , &port_modify); -ib_unregister_mad_agent (port->mad_agent); +/* Mark all the cm_id's as not valid */ +spin_lock_irq (&cm.lock); +list_for_each_entry (cm_id_priv, &port->cm_priv_altr_list, altr_list) + cm_id_priv->altr_send_port_not_ready =1 ; +list_for_each_entry (cm_id_priv, &port->cm_priv_prim_list, prim_list) + cm_id_priv->prim_send_port_not_ready =1 ; +spin_unlock_irq (&cm.lock); +spin_lock_irq (&cm.state_lock); + cur_mad_agent = port->mad_agent; + port->mad_agent =NULL ; +spin_unlock_irq (&cm.state_lock); +ib_unregister_mad_agent (cur_mad_agent);flush_workqueue (cm.wq);cm_remove_port_fs (port); } +device_unregister (cm_dev->device);kfree (cm_dev); }
@@ -3878,6 +3970,7 @@ static int __init ib_cm_init(void)INIT_LIST_HEAD (&cm.device_list);rwlock_init (&cm.device_lock);spin_lock_init (&cm.lock); +spin_lock_init (&cm.state_lock); cm.listen_service_table =RB_ROOT ; cm.listen_service_id =be64_to_cpu (IB_CM_ASSIGN_SERVICE_ID ); cm.remote_id_table =RB_ROOT ;
PATCH 240/306 IB/core: Avoid unsigned int overflow in sg_alloc_table
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mark Bloch <[email protected]>
commit 3c7ba5760ab8eedec01159b267bb9bfcffe522ac upstream.
sg_alloc_table gets unsigned int as parameter while the driver returns it as size_t. Check npages isn't greater than maximum unsigned int.
--- drivers/infiniband/core/umem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem.c +1 -1
@@ -156,7 +156,7 @@ struct ib_umem *ib_umem_get(struct ib_uc cur_base = addr &PAGE_MASK ; -if (npages ==0 ) { +if (npages ==0 || npages >UINT_MAX ) { ret = -EINVAL ; goto out; }
PATCH 241/306 IB/mlx5: Use cache line size to select CQE stride
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Jurgens <[email protected]>
commit 16b0e0695a73b68d8ca40288c8f9614ef208917b upstream.
When creating kernel CQs use 128B CQE stride if the cache line size is 128B, 64B otherwise. This prevents multiple CQEs from residing in a 128B cache line, which can cause retries when there are concurrent read and writes in one cache line.
Tested with IPoIB on PPC64, saw ~5% throughput
improvement.
--- drivers/infiniband/hw/mlx5/cq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/cq.c +1 -2
@@ -771,8 +771,7 @@ struct ib_cq *mlx5_ib_create_cq(struct iif (err) goto err_create; }else { -/* for now choose 64 bytes till we have a proper interface */ - cqe_size =64 ; + cqe_size =cache_line_size () ==128 ?128 :64 ; err =create_cq_kernel (dev, cq, entries, cqe_size, &cqb, &index, &inlen);if (err)
PATCH 242/306 IB/mlx5: Resolve soft lock on massive reg MRs
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Moshe Lazer <[email protected]>
commit 6bc1a656ab9f57f0112823b4a36930c9a29d1f89 upstream.
When calling reg_mr of large MRs (e.g. 4GB) from multiple processes and MR caches can't supply the required amount of MRs the slow-path of MR allocation may be used. In this case we need to serialize the slow-path between the processes to avoid soft lock.
--- drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 ++ drivers/infiniband/hw/mlx5/mr.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -0
@@ -376,6 +376,8 @@ struct mlx5_ib_dev {struct mlx5_ib_resources devr;struct mlx5_mr_cache cache;struct timer_list delay_timer; +/* Prevents soft lock on massive reg MRs */ +struct mutex slow_path_mutex;int fill_delay; };
drivers/infiniband/hw/mlx5/mr.c +5 -1
@@ -554,6 +554,7 @@ int mlx5_mr_cache_init(struct mlx5_ib_deint err;int i; +mutex_init (&dev->slow_path_mutex); cache->wq =create_singlethread_workqueue ("mkey_cache" );if (!cache->wq) {mlx5_ib_warn (dev,"failed to create work queue\n" );
@@ -909,9 +910,12 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct } } -if (!mr) +if (!mr) { +mutex_lock (&dev->slow_path_mutex); mr =reg_create (pd, virt_addr, length, umem, ncont, page_shift, access_flags); +mutex_unlock (&dev->slow_path_mutex); + }if (IS_ERR (mr)) { err =PTR_ERR (mr);
PATCH 243/306 IB/mlx5: Fix NULL pointer dereference on debug print
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eli Cohen <[email protected]>
commit a1ab8402d15d2305d2315d96ec3294bfdf16587e upstream.
For XRC QP CQs may not exist. Check before attempting dereference.
---
drivers/infiniband/hw/mlx5/qp.c +3 -2
@@ -1205,8 +1205,9 @@ struct ib_qp *mlx5_ib_create_qp(struct i qp->ibqp.qp_num = qp->mqp.qpn;mlx5_ib_dbg (dev,"ib qpnum 0x%x, mlx qpn 0x%x, rcqn 0x%x, scqn 0x%x\n" , - qp->ibqp.qp_num, qp->mqp.qpn,to_mcq (init_attr->recv_cq)->mcq.cqn, -to_mcq (init_attr->send_cq)->mcq.cqn); + qp->ibqp.qp_num, qp->mqp.qpn, + init_attr->recv_cq ?to_mcq (init_attr->recv_cq)->mcq.cqn :-1 , + init_attr->send_cq ?to_mcq (init_attr->send_cq)->mcq.cqn :-1 ); qp->xrcdn = xrcdn;
PATCH 244/306 IB/mlx4: Fix create CQ error flow
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matan Barak <[email protected]>
commit 593ff73bcfdc79f79a8a0df55504f75ad3e5d1a9 upstream.
Currently, if ib_copy_to_udata fails, the CQ won't be deleted from the radix tree and the HW (HW2SW).
--- drivers/infiniband/hw/mlx4/cq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/cq.c +4 -1
@@ -239,11 +239,14 @@ struct ib_cq *mlx4_ib_create_cq(struct iif (context)if (ib_copy_to_udata (udata, &cq->mcq.cqn,sizeof (__u32))) { err = -EFAULT ; - goto err_dbmap; + goto err_cq_free; }return &cq->ibcq; +err_cq_free: +mlx4_cq_free (dev->dev, &cq->mcq); + err_dbmap:if (context)mlx4_ib_db_unmap_user (to_mucontext (context), &cq->db);
PATCH 245/306 mwifiex: printk() overflow with 32-byte SSIDs
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Brian Norris <[email protected]>
commit fcd2042e8d36cf644bd2d69c26378d17158b17df upstream.
SSIDs aren't guaranteed to be 0-terminated. Let's cap the max length when we print them out.
This can be easily noticed by connecting to a network with a 32-octet SSID:
[ 3903.502925] mwifiex_pcie 0000:01:00.0: info: trying to associate to
'0123456789abcdef0123456789abcdef <uninitialized mem>' bssid xx:xx:xx:xx:xx:xx
--- drivers/net/wireless/mwifiex/cfg80211.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/wireless/mwifiex/cfg80211.c +7 -6
@@ -1734,8 +1734,9 @@ done: is_scanning_required =1 ; }else {dev_dbg (priv->adapter->dev, -"info: trying to associate to '%s' bssid %pM\n" , - (char *) req_ssid.ssid, bss->bssid); +"info: trying to associate to '%.*s' bssid %pM\n" , + req_ssid.ssid_len, (char *)req_ssid.ssid, + bss->bssid);memcpy (&priv->cfg_bssid, bss->bssid,ETH_ALEN );break ; }
@@ -1776,8 +1777,8 @@ mwifiex_cfg80211_connect(struct wiphy *wreturn -EINVAL ; } -wiphy_dbg (wiphy,"info: Trying to associate to %s and bssid %pM\n" , - (char *) sme->ssid, sme->bssid); +wiphy_dbg (wiphy,"info: Trying to associate to %.*s and bssid %pM\n" , + (int )sme->ssid_len, (char *)sme->ssid, sme->bssid); ret =mwifiex_cfg80211_assoc (priv, sme->ssid_len, sme->ssid, sme->bssid, priv->bss_mode, sme->channel, sme,0 );
@@ -1900,8 +1901,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy goto done; } -wiphy_dbg (wiphy,"info: trying to join to %s and bssid %pM\n" , - (char *) params->ssid, params->bssid); +wiphy_dbg (wiphy,"info: trying to join to %.*s and bssid %pM\n" , + params->ssid_len, (char *)params->ssid, params->bssid);mwifiex_set_ibss_params (priv, params);
PATCH 246/306 of_mdio: fix node leak in of_phy_register_fixed_link error path
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 48c1699d5335bc045b50989a06b1c526b17a25ff upstream.
Make sure to drop the of_node reference also on failure to parse the speed property in of_phy_register_fixed_link().
--- drivers/of/of_mdio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/of/of_mdio.c +4 -1
@@ -291,8 +291,11 @@ int of_phy_register_fixed_link(struct de status.link =1 ; status.duplex =of_property_read_bool (fixed_link_node,"full-duplex" ); -if (of_property_read_u32 (fixed_link_node,"speed" , &status.speed)) +if (of_property_read_u32 (fixed_link_node,"speed" , + &status.speed)) { +of_node_put (fixed_link_node);return -EINVAL ; + } status.pause =of_property_read_bool (fixed_link_node,"pause" ); status.asym_pause =of_property_read_bool (fixed_link_node,"asym-pause" );
PATCH 247/306 cfg80211: limit scan results cache size
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 9853a55ef1bb66d7411136046060bbfb69c714fa upstream.
It's possible to make scanning consume almost arbitrary amounts of memory, e.g. by sending beacon frames with random BSSIDs at high rates while somebody is scanning.
Limit the number of BSS table entries we're willing to cache to 1000, limiting maximum memory usage to maybe 4-5MB, but lower in practice - that would be the case for having both full-sized beacon and probe response frames for each entry; this seems not possible in practice, so a limit of 1000 entries will likely be closer to 0.5 MB.
--- net/wireless/core.h | 1 + net/wireless/scan.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)
net/wireless/core.h +1 -0
@@ -61,6 +61,7 @@ struct cfg80211_registered_device {struct list_head bss_list;struct rb_root bss_tree;u32 bss_generation; +u32 bss_entries;struct cfg80211_scan_request *scan_req;/* protected by RTNL */ struct sk_buff *scan_msg;struct cfg80211_sched_scan_request *sched_scan_req;
net/wireless/scan.c +69 -0
112 lines not on this page · raw message
PATCH 248/306 net: ethernet: ti: cpsw: fix bad register access in probe error path
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit c46ab7e08c79be7400f6d59edbc6f26a91941c5a upstream.
Make sure to keep the platform device runtime-resumed throughout probe to avoid accessing the CPSW registers in the error path (e.g. for deferred probe) with clocks disabled:
Unhandled fault: external abort on non-linefetch (0x1008) at 0xd0872d08
...
[<c04fabcc>] (cpsw_ale_control_set) from [<c04fb8b4>] (cpsw_ale_destroy+0x2c/0x44) [<c04fb8b4>] (cpsw_ale_destroy) from [<c04fea58>] (cpsw_probe+0xbd0/0x10c4) [<c04fea58>] (cpsw_probe) from [<c047b2a0>] (platform_drv_probe+0x5c/0xc0)
[bwh: Backported to 3.16:
- s/cpsw->/priv->/g
- Adjust context]
--- drivers/net/ethernet/ti/cpsw.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/ti/cpsw.c +7 -4
@@ -2140,13 +2140,12 @@ static int cpsw_probe(struct platform_de*/ pm_runtime_get_sync (&pdev->dev); priv->version =readl (&priv->regs->id_ver); -pm_runtime_put_sync (&pdev->dev); res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); priv->wr_regs =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (priv->wr_regs)) { ret =PTR_ERR (priv->wr_regs); - goto clean_runtime_disable_ret; + goto clean_pm_runtime_put_ret; }memset (&dma_params,0 ,sizeof (dma_params));
@@ -2183,7 +2182,7 @@ static int cpsw_probe(struct platform_dedefault :dev_err (priv->dev,"unknown version 0x%08x\n" , priv->version); ret = -ENODEV ; - goto clean_runtime_disable_ret; + goto clean_pm_runtime_put_ret; }for (i =0 ; i < priv->data.slaves; i++) {struct cpsw_slave *slave = &priv->slaves[i];
@@ -2211,7 +2210,7 @@ static int cpsw_probe(struct platform_deif (!priv->dma) {dev_err (priv->dev,"error initializing dma\n" ); ret = -ENOMEM ; - goto clean_runtime_disable_ret; + goto clean_pm_runtime_put_ret; } priv->txch = cpdma_chan_create(priv->dma, tx_chan_num(0),
@@ -2283,6 +2282,8 @@ static int cpsw_probe(struct platform_de } } +pm_runtime_put (&pdev->dev); +return 0 ; clean_ale_ret:
@@ -2291,6 +2292,8 @@ clean_dma_ret:cpdma_chan_destroy (priv->txch);cpdma_chan_destroy (priv->rxch);cpdma_ctlr_destroy (priv->dma); +clean_pm_runtime_put_ret: +pm_runtime_put_sync (&pdev->dev); clean_runtime_disable_ret:pm_runtime_disable (&pdev->dev); clean_ndev_ret:
PATCH 249/306 net: ethernet: ti: cpsw: fix mdio device reference leak
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 86e1d5adcef961eb383ce4eacbe0ef22f06e2045 upstream.
Make sure to drop the reference taken by of_find_device_by_node() when looking up an mdio device from a phy_id property during probe.
pointers")
--- drivers/net/ethernet/ti/cpsw.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/ti/cpsw.c +1 -0
@@ -1939,6 +1939,7 @@ static int cpsw_probe_dt(struct cpsw_pla }snprintf (slave_data->phy_id,sizeof (slave_data->phy_id),PHY_ID_FMT , mdio->name, phyid); +put_device (&mdio->dev); mac_addr =of_get_mac_address (slave_node);if (mac_addr)
PATCH 250/306 net: ethernet: ti: cpsw: fix secondary-emac probe error path
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit a7fe9d466f6a33558a38c7ca9d58bcc83512d577 upstream.
Make sure to deregister the primary device in case the secondary emac fails to probe.
kernel BUG at /home/johan/work/omicron/src/linux/net/core/dev.c:7743!
...
[<c05b3dec>] (free_netdev) from [<c04fe6c0>] (cpsw_probe+0x9cc/0xe50) [<c04fe6c0>] (cpsw_probe) from [<c047b28c>] (platform_drv_probe+0x5c/0xc0)
implementation")
--- drivers/net/ethernet/ti/cpsw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw.c +3 -1
@@ -2279,7 +2279,7 @@ static int cpsw_probe(struct platform_de ret =cpsw_probe_dual_emac (pdev, priv);if (ret) {cpsw_err (priv, probe,"error probe slave 2 emac interface\n" ); - goto clean_ale_ret; + goto clean_unregister_netdev_ret; } }
@@ -2287,6 +2287,8 @@ static int cpsw_probe(struct platform_dereturn 0 ; +clean_unregister_netdev_ret: +unregister_netdev (ndev); clean_ale_ret:cpsw_ale_destroy (priv->ale); clean_dma_ret:
PATCH 251/306 KVM: Disable irq while unregistering user notifier
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ignacio Alvarado <[email protected]>
commit 1650b4ebc99da4c137bfbfc531be4a2405f951dd upstream.
Function user_notifier_unregister should be called only once for each registered user notifier.
Function kvm_arch_hardware_disable can be executed from an IPI context which could cause a race condition with a VCPU returning to user mode and attempting to unregister the notifier.
--- arch/x86/kvm/x86.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +11 -2
@@ -180,7 +180,18 @@ static void kvm_on_user_return(struct usstruct kvm_shared_msrs *locals = container_of(urn, struct kvm_shared_msrs, urn);struct kvm_shared_msr_values *values; +unsigned long flags; +/* +* Disabling irqs at this point since the following code could be +* interrupted and executed through kvm_arch_hardware_disable() +*/ +local_irq_save (flags); +if (locals->registered) { + locals->registered = false; +user_return_notifier_unregister (urn); + } +local_irq_restore (flags);for (slot =0 ; slot < shared_msrs_global.nr; ++slot) { values = &locals->values[slot];if (values->host != values->curr) {
@@ -188,8 +199,6 @@ static void kvm_on_user_return(struct us values->curr = values->host; } } - locals->registered = false; -user_return_notifier_unregister (urn); }static void shared_msr_update (unsigned slot,u32 msr)
PATCH 252/306 KVM: x86: fix missed SRCU usage in kvm_lapic_set_vapic_addr
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit 7301d6abaea926d685832f7e1f0c37dd206b01f4 upstream.
Reported by syzkaller:
[ INFO: suspicious RCU usage. ]
4.9.0-rc4+ #47 Not tainted
-------------------------------
./include/linux/kvm_host.h:536 suspicious rcu_dereference_check() usage!
stack backtrace:
CPU: 1 PID: 6679 Comm: syz-executor Not tainted 4.9.0-rc4+ #47
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
ffff880039e2f6d0 ffffffff81c2e46b ffff88003e3a5b40 0000000000000000
0000000000000001 ffffffff83215600 ffff880039e2f700 ffffffff81334ea9
ffffc9000730b000 0000000000000004 ffff88003c4f8420 ffff88003d3f8000
Call Trace:
[< inline >] __dump_stack lib/dump_stack.c:15
[<ffffffff81c2e46b>] dump_stack+0xb3/0x118 lib/dump_stack.c:51
[<ffffffff81334ea9>] lockdep_rcu_suspicious+0x139/0x180 kernel/locking/lockdep.c:4445
[< inline >] __kvm_memslots include/linux/kvm_host.h:534
[< inline >] kvm_memslots include/linux/kvm_host.h:541
[<ffffffff8105d6ae>] kvm_gfn_to_hva_cache_init+0xa1e/0xce0 virt/kvm/kvm_main.c:1941
[<ffffffff8112685d>] kvm_lapic_set_vapic_addr+0xed/0x140 arch/x86/kvm/lapic.c:2217--- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/x86.c +3 -0
@@ -3305,6 +3305,7 @@ long kvm_arch_vcpu_ioctl(struct file *fi };case KVM_SET_VAPIC_ADDR : {struct kvm_vapic_addr va; +int idx; r = -EINVAL ;if (!irqchip_in_kernel (vcpu->kvm))
@@ -3312,7 +3313,9 @@ long kvm_arch_vcpu_ioctl(struct file *fi r = -EFAULT ;if (copy_from_user (&va, argp,sizeof va)) goto out; + idx =srcu_read_lock (&vcpu->kvm->srcu); r =kvm_lapic_set_vapic_addr (vcpu, va.vapic_addr); +srcu_read_unlock (&vcpu->kvm->srcu, idx);break ; }case KVM_X86_SETUP_MCE : {
PATCH 253/306 ext4: sanity check the block and cluster size at mount time
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 8cdf3372fe8368f56315e66bea9f35053c418093 upstream.
If the block size or cluster size is insane, reject the mount. This is important for security reasons (although we shouldn't be just depending on this check).
Ref: http://www.securityfocus.com/archive/1/539661
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1332506
--- fs/ext4/ext4.h | 1 + fs/ext4/super.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
fs/ext4/ext4.h +1 -0
@@ -234,6 +234,7 @@ struct ext4_io_submit {#define EXT4_MAX_BLOCK_SIZE 65536#define EXT4_MIN_BLOCK_LOG_SIZE 10#define EXT4_MAX_BLOCK_LOG_SIZE 16 +#define EXT4_MAX_CLUSTER_LOG_SIZE 30#ifdef __KERNEL__# define EXT4_BLOCK_SIZE (s) ((s)->s_blocksize)#else
fs/ext4/super.c +16 -1
@@ -3666,7 +3666,15 @@ static int ext4_fill_super(struct super_if (blocksize <EXT4_MIN_BLOCK_SIZE || blocksize >EXT4_MAX_BLOCK_SIZE ) {ext4_msg (sb,KERN_ERR , -"Unsupported filesystem blocksize %d" , blocksize); +"Unsupported filesystem blocksize %d (%d log_block_size)" , + blocksize,le32_to_cpu (es->s_log_block_size)); + goto failed_mount; + } +if (le32_to_cpu (es->s_log_block_size) > + (EXT4_MAX_BLOCK_LOG_SIZE -EXT4_MIN_BLOCK_LOG_SIZE )) { +ext4_msg (sb,KERN_ERR , +"Invalid log block size: %u" , +le32_to_cpu (es->s_log_block_size)); goto failed_mount; }
@@ -3788,6 +3796,13 @@ static int ext4_fill_super(struct super_ "block size (%d)", clustersize, blocksize); goto failed_mount; } +if (le32_to_cpu (es->s_log_cluster_size) > + (EXT4_MAX_CLUSTER_LOG_SIZE -EXT4_MIN_BLOCK_LOG_SIZE )) { +ext4_msg (sb,KERN_ERR , +"Invalid log cluster size: %u" , +le32_to_cpu (es->s_log_cluster_size)); + goto failed_mount; + } sbi->s_cluster_bits =le32_to_cpu (es->s_log_cluster_size) -le32_to_cpu (es->s_log_block_size); sbi->s_clusters_per_group =
PATCH 254/306 l2tp: fix racy SOCK_ZAPPED flag check in l2tp_ip{,6}_bind()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Nault <[email protected]>
commit 32c231164b762dddefa13af5a0101032c70b50ef upstream.
Lock socket before checking the SOCK_ZAPPED flag in l2tp_ip6_bind(). Without lock, a concurrent call could modify the socket flags between the sock_flag(sk, SOCK_ZAPPED) test and the lock_sock() call. This way, a socket could be inserted twice in l2tp_ip6_bind_table. Releasing it would then leave a stale pointer there, generating use-after-free errors when walking through the list or modifying adjacent entries.
BUG: KASAN: use-after-free in l2tp_ip6_close+0x22e/0x290 at addr ffff8800081b0ed8
Write of size 8 by task syz-executor/10987
CPU: 0 PID: 10987 Comm: syz-executor Not tainted 4.8.0+ #39
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014
ffff880031d97838 ffffffff829f835b ffff88001b5a1640 ffff8800081b0ec0
ffff8800081b15a0 ffff8800081b6d20 ffff880031d97860 ffffffff8174d3cc
ffff880031d978f0 ffff8800081b0e80 ffff88001b5a1640 ffff880031d978e0
Call Trace:
[<ffffffff829f835b>] dump_stack+0xb3/0x118 lib/dump_stack.c:15
[<ffffffff8174d3cc>] kasan_object_err+0x1c/0x70 mm/kasan/report.c:156
[< inline >] print_address_description mm/kasan/report.c:194
[<ffffffff8174d666>] kasan_report_error+0x1f6/0x4d0 mm/kasan/report.c:283
[< inline >] kasan_report mm/kasan/report.c:303
[<ffffffff8174db7e>] __asan_report_store8_noabort+0x3e/0x40 mm/kasan/report.c:329
[< inline >] __write_once_size ./include/linux/compiler.h:249
[< inline >] __hlist_del ./include/linux/list.h:622
[< inline >] hlist_del_init ./include/linux/list.h:637
[<ffffffff8579047e>] l2tp_ip6_close+0x22e/0x290 net/l2tp/l2tp_ip6.c:239
[<ffffffff850b2dfd>] inet_release+0xed/0x1c0 net/ipv4/af_inet.c:415
[<ffffffff851dc5a0>] inet6_release+0x50/0x70 net/ipv6/af_inet6.c:422
[<ffffffff84c4581d>] sock_release+0x8d/0x1d0 net/socket.c:570
[<ffffffff84c45976>] sock_close+0x16/0x20 net/socket.c:1017
[<ffffffff817a108c>] __fput+0x28c/0x780 fs/file_table.c:208
[<ffffffff817a1605>] ____fput+0x15/0x20 fs/file_table.c:244
[<ffffffff813774f9>] task_work_run+0xf9/0x170
[<ffffffff81324aae>] do_exit+0x85e/0x2a00
[<ffffffff81326dc8>] do_group_exit+0x108/0x330
[<ffffffff81348cf7>] get_signal+0x617/0x17a0 kernel/signal.c:2307
[<ffffffff811b49af>] do_signal+0x7f/0x18f0
[<ffffffff810039bf>] exit_to_usermode_loop+0xbf/0x150 arch/x86/entry/common.c:156
[< inline >] prepare_exit_to_usermode arch/x86/entry/common.c:190
[<ffffffff81006060>] syscall_return_slowpath+0x1a0/0x1e0 arch/x86/entry/common.c:259
[<ffffffff85e4d726>] entry_SYSCALL_64_fastpath+0xc4/0xc6
Object at ffff8800081b0ec0, in cache L2TP/IPv6 size: 1448
Allocated:
PID = 10987
[ 1116.897025] [<ffffffff811ddcb6>] save_stack_trace+0x16/0x20
[ 1116.897025] [<ffffffff8174c736>] save_stack+0x46/0xd0
[ 1116.897025] [<ffffffff8174c9ad>] kasan_kmalloc+0xad/0xe0
[ 1116.897025] [<ffffffff8174cee2>] kasan_slab_alloc+0x12/0x20
[ 1116.897025] [< inline >] slab_post_alloc_hook mm/slab.h:417
[ 1116.897025] [< inline >] slab_alloc_node mm/slub.c:2708
[ 1116.897025] [< inline >] slab_alloc mm/slub.c:2716
[ 1116.897025] [<ffffffff817476a8>] kmem_cache_alloc+0xc8/0x2b0 mm/slub.c:2721
[ 1116.897025] [<ffffffff84c4f6a9>] sk_prot_alloc+0x69/0x2b0 net/core/sock.c:1326
[ 1116.897025] [<ffffffff84c58ac8>] sk_alloc+0x38/0xae0 net/core/sock.c:1388
[ 1116.897025] [<ffffffff851ddf67>] inet6_create+0x2d7/0x1000 net/ipv6/af_inet6.c:182
[ 1116.897025] [<ffffffff84c4af7b>] __sock_create+0x37b/0x640 net/socket.c:1153
[ 1116.897025] [< inline >] sock_create net/socket.c:1193
[ 1116.897025] [< inline >] SYSC_socket net/socket.c:1223
[ 1116.897025] [<ffffffff84c4b46f>] SyS_socket+0xef/0x1b0 net/socket.c:1203
[ 1116.897025] [<ffffffff85e4d685>] entry_SYSCALL_64_fastpath+0x23/0xc6
Freed:
PID = 10987
[ 1116.897025] [<ffffffff811ddcb6>] save_stack_trace+0x16/0x20
[ 1116.897025] [<ffffffff8174c736>] save_stack+0x46/0xd0
[ 1116.897025] [<ffffffff8174cf61>] kasan_slab_free+0x71/0xb0
[ 1116.897025] [< inline >] slab_free_hook mm/slub.c:1352
[ 1116.897025] [< inline >] slab_free_freelist_hook mm/slub.c:1374
[ 1116.897025] [< inline >] slab_free mm/slub.c:2951
[ 1116.897025] [<ffffffff81748b28>] kmem_cache_free+0xc8/0x330 mm/slub.c:2973
[ 1116.897025] [< inline >] sk_prot_free net/core/sock.c:1369
[ 1116.897025] [<ffffffff84c541eb>] __sk_destruct+0x32b/0x4f0 net/core/sock.c:1444
[ 1116.897025] [<ffffffff84c5aca4>] sk_destruct+0x44/0x80 net/core/sock.c:1452
[ 1116.897025] [<ffffffff84c5ad33>] __sk_free+0x53/0x220 net/core/sock.c:1460
[ 1116.897025] [<ffffffff84c5af23>] sk_free+0x23/0x30 net/core/sock.c:1471
[ 1116.897025] [<ffffffff84c5cb6c>] sk_common_release+0x28c/0x3e0 ./include/net/sock.h:1589
[ 1116.897025] [<ffffffff8579044e>] l2tp_ip6_close+0x1fe/0x290 net/l2tp/l2tp_ip6.c:243
[ 1116.897025] [<ffffffff850b2dfd>] inet_release+0xed/0x1c0 net/ipv4/af_inet.c:415
[ 1116.897025] [<ffffffff851dc5a0>] inet6_release+0x50/0x70 net/ipv6/af_inet6.c:422
[ 1116.897025] [<ffffffff84c4581d>] sock_release+0x8d/0x1d0 net/socket.c:570
[ 1116.897025] [<ffffffff84c45976>] sock_close+0x16/0x20 net/socket.c:1017
[ 1116.897025] [<ffffffff817a108c>] __fput+0x28c/0x780 fs/file_table.c:208
[ 1116.897025] [<ffffffff817a1605>] ____fput+0x15/0x20 fs/file_table.c:244
[ 1116.897025] [<ffffffff813774f9>] task_work_run+0xf9/0x170
[ 1116.897025] [<ffffffff81324aae>] do_exit+0x85e/0x2a00
[ 1116.897025] [<ffffffff81326dc8>] do_group_exit+0x108/0x330
[ 1116.897025] [<ffffffff81348cf7>] get_signal+0x617/0x17a0 kernel/signal.c:2307
[ 1116.897025] [<ffffffff811b49af>] do_signal+0x7f/0x18f0
[ 1116.897025] [<ffffffff810039bf>] exit_to_usermode_loop+0xbf/0x150 arch/x86/entry/common.c:156
[ 1116.897025] [< inline >] prepare_exit_to_usermode arch/x86/entry/common.c:190
[ 1116.897025] [<ffffffff81006060>] syscall_return_slowpath+0x1a0/0x1e0 arch/x86/entry/common.c:259
[ 1116.897025] [<ffffffff85e4d726>] entry_SYSCALL_64_fastpath+0xc4/0xc6
Memory state around the buggy address:
ffff8800081b0d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8800081b0e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8800081b0e80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff8800081b0f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8800081b0f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb==================================================================
The same issue exists with l2tp_ip_bind() and l2tp_ip_bind_table.
--- net/l2tp/l2tp_ip.c | 5 +++-- net/l2tp/l2tp_ip6.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
net/l2tp/l2tp_ip.c +3 -2
@@ -251,8 +251,6 @@ static int l2tp_ip_bind(struct sock *sk,int ret;int chk_addr_ret; -if (!sock_flag (sk,SOCK_ZAPPED )) -return -EINVAL ;if (addr_len <sizeof (struct sockaddr_l2tpip ))return -EINVAL ;if (addr->l2tp_family !=AF_INET )
@@ -267,6 +265,9 @@ static int l2tp_ip_bind(struct sock *sk,read_unlock_bh (&l2tp_ip_lock);lock_sock (sk); +if (!sock_flag (sk,SOCK_ZAPPED )) + goto out; +if (sk->sk_state !=TCP_CLOSE || addr_len <sizeof (struct sockaddr_l2tpip )) goto out;
net/l2tp/l2tp_ip6.c +3 -2
@@ -266,8 +266,6 @@ static int l2tp_ip6_bind(struct sock *skint addr_type;int err; -if (!sock_flag (sk,SOCK_ZAPPED )) -return -EINVAL ;if (addr->l2tp_family !=AF_INET6 )return -EINVAL ;if (addr_len <sizeof (*addr))
@@ -293,6 +291,9 @@ static int l2tp_ip6_bind(struct sock *sklock_sock (sk); err = -EINVAL ; +if (!sock_flag (sk,SOCK_ZAPPED )) + goto out_unlock; +if (sk->sk_state !=TCP_CLOSE ) goto out_unlock;
PATCH 255/306 apparmor: fix change_hat not finding hat after policy replacement
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
commit 3d40658c977769ce2138f286cf131537bf68bdfe upstream.
After a policy replacement, the task cred may be out of date and need to be updated. However change_hat is using the stale profiles from the out of date cred resulting in either: a stale profile being applied or, incorrect failure when searching for a hat profile as it has been migrated to the new parent profile.
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000287
--- security/apparmor/domain.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
security/apparmor/domain.c +4 -2
@@ -627,8 +627,8 @@ int aa_change_hat(const char *hats[], in/* released below */ cred =get_current_cred (); cxt =cred_cxt (cred); - profile =aa_cred_profile (cred); - previous_profile = cxt->previous; + profile =aa_get_newest_profile (aa_cred_profile (cred)); + previous_profile =aa_get_newest_profile (cxt->previous);if (unconfined (profile)) { info ="unconfined" ;
@@ -724,6 +724,8 @@ audit: out:aa_put_profile (hat);kfree (name); +aa_put_profile (profile); +aa_put_profile (previous_profile);put_cred (cred);return error;
PATCH 256/306 x86/traps: Ignore high word of regs->cs in early_fixup_exception()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andy Lutomirski <[email protected]>
commit fc0e81b2bea0ebceb71889b61d2240856141c9ee upstream.
On the 80486 DX, it seems that some exceptions may leave garbage in the high bits of CS. This causes sporadic failures in which early_fixup_exception() refuses to fix up an exception.
As far as I can tell, this has been buggy for a long time, but the problem seems to have been exacerbated by commits:
1e02ce4cccdc ("x86: Store a per-cpu shadow copy of CR4") e1bfc11c5a6f ("x86/init: Fix cr4_init_shadow() on CR4-less machines")
This appears to have broken for as long as we've had early exception handling.
[ This backport should apply to kernels from 3.4 - 4.5. ]
--- arch/x86/kernel/head_32.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/head_32.S +1 -1
@@ -564,7 +564,7 @@ early_idt_handler_common: movl %eax,%ds movl %eax,%es - cmpl $(__KERNEL_CS),32(%esp) + cmpw $(__KERNEL_CS),32(%esp) jne 10f leal 28(%esp),%eax # Pointer to %eip
PATCH 257/306 tile: avoid using clocksource_cyc2ns with absolute cycle count
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Chris Metcalf <[email protected]>
commit e658a6f14d7c0243205f035979d0ecf6c12a036f upstream.
For large values of "mult" and long uptimes, the intermediate result of "cycles * mult" can overflow 64 bits. For example, the tile platform calls clocksource_cyc2ns with a 1.2 GHz clock; we have mult = 853, and after 208.5 days, we overflow 64 bits.
Since clocksource_cyc2ns() is intended to be used for relative cycle counts, not absolute cycle counts, performance is more importance than accepting a wider range of cycle values. So, just use mult_frac() directly in tile's sched_clock().
Commit 4cecf6d401a0 ("sched, x86: Avoid unnecessary overflow in sched_clock") by Salman Qazi results in essentially the same generated code for x86 as this change does for tile. In fact, a follow-on change by Salman introduced mult_frac() and switched to using it, so the C code was largely identical at that point too.
Peter Zijlstra then added mul_u64_u32_shr() and switched x86 to use it. This is, in principle, better; by optimizing the 64x64->64 multiplies to be 32x32->64 multiplies we can potentially save some time. However, the compiler piplines the 64x64->64 multiplies pretty well, and the conditional branch in the generic mul_u64_u32_shr() causes some bubbles in execution, with the result that it's pretty much a wash. If tilegx provided its own implementation of mul_u64_u32_shr() without the conditional branch, we could potentially save 3 cycles, but that seems like small gain for a fair amount of additional build scaffolding; no other platform currently provides a mul_u64_u32_shr() override, and tile doesn't currently have an <asm/div64.h> header to put the override in.
Additionally, gcc currently has an optimization bug that prevents it from recognizing the opportunity to use a 32x32->64 multiply, and so the result would be no better than the existing mult_frac() until such time as the compiler is fixed.
For now, just using mult_frac() seems like the right answer.
--- arch/tile/kernel/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/tile/kernel/time.c +2 -2
@@ -216,8 +216,8 @@ void do_timer_interrupt(struct pt_regs **/ unsigned long long sched_clock (void ) { -return clocksource_cyc2ns (get_cycles (), - sched_clock_mult,SCHED_CLOCK_SHIFT ); +return mult_frac (get_cycles (), + sched_clock_mult,1ULL <<SCHED_CLOCK_SHIFT ); }int setup_profiling_timer (unsigned int multiplier)
PATCH 258/306 xc2028: Fix use-after-free bug properly
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 22a1e7783e173ab3d86018eb590107d68df46c11 upstream.
The commit 8dfbcc4351a0 ("[media] xc2028: avoid use after free") tried to address the reported use-after-free by clearing the reference.
However, it's clearing the wrong pointer; it sets NULL to priv->ctrl.fname, but it's anyway overwritten by the next line memcpy(&priv->ctrl, p, sizeof(priv->ctrl)).
OTOH, the actual code accessing the freed string is the strcmp() call with priv->fname:
if (!firmware_name[0] && p->fname && priv->fname && strcmp(p->fname, priv->fname)) free_firmware(priv);
where priv->fname points to the previous file name, and this was already freed by kfree().
For fixing the bug properly, this patch does the following:
- Keep the copy of firmware file name in only priv->fname, priv->ctrl.fname isn't changed;
- The allocation is done only when the firmware gets loaded;
- The kfree() is called in free_firmware() commonly
--- drivers/media/tuners/tuner-xc2028.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
drivers/media/tuners/tuner-xc2028.c +16 -21
@@ -281,6 +281,14 @@ static void free_firmware(struct xc2028_int i;tuner_dbg ("%s called\n" , __func__); +/* free allocated f/w string */ +if (priv->fname != firmware_name) +kfree (priv->fname); + priv->fname =NULL ; + + priv->state =XC2028_NO_FIRMWARE ; +memset (&priv->cur_fw,0 ,sizeof (priv->cur_fw)); +if (!priv->firm)return ;
@@ -291,9 +299,6 @@ static void free_firmware(struct xc2028_ priv->firm =NULL ; priv->firm_size =0 ; - priv->state =XC2028_NO_FIRMWARE ; - -memset (&priv->cur_fw,0 ,sizeof (priv->cur_fw)); } static int load_all_firmwares(struct dvb_frontend *fe,
@@ -884,9 +889,8 @@ read_not_reliable:return 0 ; fail: - priv->state =XC2028_NO_FIRMWARE ; +free_firmware (priv); -memset (&priv->cur_fw,0 ,sizeof (priv->cur_fw));if (retry_count <8 ) {msleep (50 ); retry_count++;
@@ -1332,11 +1336,8 @@ static int xc2028_dvb_release(struct dvbmutex_lock (&xc2028_list_mutex);/* only perform final cleanup if this is the last instance */ -if (hybrid_tuner_report_instance_count (priv) ==1 ) { +if (hybrid_tuner_report_instance_count (priv) ==1 )free_firmware (priv); -kfree (priv->ctrl.fname); - priv->ctrl.fname =NULL ; - }if (priv)hybrid_tuner_release_state (priv);
@@ -1399,19 +1400,8 @@ static int xc2028_set_config(struct dvb_/* * Copy the config data. -* For the firmware name, keep a local copy of the string, -* in order to avoid troubles during device release. */ -kfree (priv->ctrl.fname); - priv->ctrl.fname =NULL ;memcpy (&priv->ctrl, p,sizeof (priv->ctrl)); -if (p->fname) { - priv->ctrl.fname =kstrdup (p->fname,GFP_KERNEL ); -if (priv->ctrl.fname ==NULL ) { - rc = -ENOMEM ; - goto unlock; - } - }/* * If firmware name changed, frees firmware. As free_firmware will
@@ -1426,10 +1416,15 @@ static int xc2028_set_config(struct dvb_if (priv->state ==XC2028_NO_FIRMWARE ) {if (!firmware_name[0 ]) - priv->fname = priv->ctrl.fname; + priv->fname =kstrdup (p->fname,GFP_KERNEL );else priv->fname = firmware_name; +if (!priv->fname) { + rc = -ENOMEM ; + goto unlock; + } + rc = request_firmware_nowait(THIS_MODULE, 1, priv->fname, priv->i2c_props.adap->dev.parent,
PATCH 259/306 x86/apic/uv: Silence a shift wrapping warning
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit c4597fd756836a5fb7900f2091797ab564390ad0 upstream.
'm_io' is stored in 6 bits so it's a number in the 0-63 range. Static analysis tools complain that 1 << 63 will wrap so I have changed it to 1ULL << m_io.
This code is over three years old so presumably the bug doesn't happen very frequently in real life or someone would have complained by now.
--- arch/x86/kernel/apic/x2apic_uv_x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/apic/x2apic_uv_x.c +2 -2
@@ -633,9 +633,9 @@ static __init void map_mmioh_high_uv3(in l = li; } addr1 = (base << shift) + - f * (unsigned long )(1 << m_io); + f * (1ULL << m_io); addr2 = (base << shift) + - (l +1 ) * (unsigned long )(1 << m_io); + (l +1 ) * (1ULL << m_io);pr_info ("UV: %s[%03d..%03d] NASID 0x%04x ADDR 0x%016lx - 0x%016lx\n" , id, fi, li, lnasid, addr1, addr2);if (max_io < l)
PATCH 260/306 KVM: x86: drop error recovery in em_jmp_far and em_ret_far
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Radim Krčmář <[email protected]>
commit 2117d5398c81554fbf803f5fd1dc55eb78216c0c upstream.
em_jmp_far and em_ret_far assumed that setting IP can only fail in 64 bit mode, but syzkaller proved otherwise (and SDM agrees). Code segment was restored upon failure, but it was left uninitialized outside of long mode, which could lead to a leak of host kernel stack. We could have fixed that by always saving and restoring the CS, but we take a simpler approach and just break any guest that manages to fail as the error recovery is error-prone and modern CPUs don't need emulator for this.
Found by syzkaller:
WARNING: CPU: 2 PID: 3668 at arch/x86/kvm/emulate.c:2217 em_ret_far+0x428/0x480 Kernel panic - not syncing: panic_on_warn set ... CPU: 2 PID: 3668 Comm: syz-executor Not tainted 4.9.0-rc4+ #49 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 [...] Call Trace: [...] __dump_stack lib/dump_stack.c:15 [...] dump_stack+0xb3/0x118 lib/dump_stack.c:51 [...] panic+0x1b7/0x3a3 kernel/panic.c:179 [...] __warn+0x1c4/0x1e0 kernel/panic.c:542 [...] warn_slowpath_null+0x2c/0x40 kernel/panic.c:585 [...] em_ret_far+0x428/0x480 arch/x86/kvm/emulate.c:2217 [...] em_ret_far_imm+0x17/0x70 arch/x86/kvm/emulate.c:2227 [...] x86_emulate_insn+0x87a/0x3730 arch/x86/kvm/emulate.c:5294 [...] x86_emulate_instruction+0x520/0x1ba0 arch/x86/kvm/x86.c:5545 [...] emulate_instruction arch/x86/include/asm/kvm_host.h:1116 [...] complete_emulated_io arch/x86/kvm/x86.c:6870 [...] complete_emulated_mmio+0x4e9/0x710 arch/x86/kvm/x86.c:6934 [...] kvm_arch_vcpu_ioctl_run+0x3b7a/0x5a90 arch/x86/kvm/x86.c:6978 [...] kvm_vcpu_ioctl+0x61e/0xdd0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2557 [...] vfs_ioctl fs/ioctl.c:43 [...] do_vfs_ioctl+0x18c/0x1040 fs/ioctl.c:679 [...] SYSC_ioctl fs/ioctl.c:694 [...] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:685 [...] entry_SYSCALL_64_fastpath+0x1f/0xc2
--- arch/x86/kvm/emulate.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-)
arch/x86/kvm/emulate.c +11 -25
@@ -1981,16 +1981,10 @@ static int em_iret(struct x86_emulate_ctstatic int em_jmp_far (struct x86_emulate_ctxt *ctxt) {int rc; -unsigned short sel, old_sel; -struct desc_struct old_desc, new_desc; -const struct x86_emulate_ops *ops = ctxt->ops; +unsigned short sel; +struct desc_struct new_desc;u8 cpl = ctxt->ops->cpl (ctxt); -/* Assignment of RIP may only fail in 64-bit mode */ -if (ctxt->mode ==X86EMUL_MODE_PROT64 ) - ops->get_segment (ctxt, &old_sel, &old_desc,NULL , -VCPU_SREG_CS ); -memcpy (&sel, ctxt->src.valptr + ctxt->op_bytes,2 ); rc = __load_segment_descriptor(ctxt, sel, VCPU_SREG_CS, cpl, false,
@@ -1999,12 +1993,10 @@ static int em_jmp_far(struct x86_emulatereturn rc; rc =assign_eip_far (ctxt, ctxt->src.val, new_desc.l); -if (rc !=X86EMUL_CONTINUE ) { -WARN_ON (ctxt->mode !=X86EMUL_MODE_PROT64 ); -/* assigning eip failed; restore the old cs */ - ops->set_segment (ctxt, old_sel, &old_desc,0 ,VCPU_SREG_CS ); -return rc; - } +/* Error handling is not implemented. */ +if (rc !=X86EMUL_CONTINUE ) +return X86EMUL_UNHANDLEABLE ; +return rc; }
@@ -2070,14 +2062,8 @@ static int em_ret_far(struct x86_emulate {int rc;unsigned long eip, cs; -u16 old_cs;int cpl = ctxt->ops->cpl (ctxt); -struct desc_struct old_desc, new_desc; -const struct x86_emulate_ops *ops = ctxt->ops; - -if (ctxt->mode ==X86EMUL_MODE_PROT64 ) - ops->get_segment (ctxt, &old_cs, &old_desc,NULL , -VCPU_SREG_CS ); +struct desc_struct new_desc; rc =emulate_pop (ctxt, &eip, ctxt->op_bytes);if (rc !=X86EMUL_CONTINUE )
@@ -2093,10 +2079,10 @@ static int em_ret_far(struct x86_emulateif (rc !=X86EMUL_CONTINUE )return rc; rc =assign_eip_far (ctxt, eip, new_desc.l); -if (rc !=X86EMUL_CONTINUE ) { -WARN_ON (ctxt->mode !=X86EMUL_MODE_PROT64 ); - ops->set_segment (ctxt, old_cs, &old_desc,0 ,VCPU_SREG_CS ); - } +/* Error handling is not implemented. */ +if (rc !=X86EMUL_CONTINUE ) +return X86EMUL_UNHANDLEABLE ; +return rc; }
PATCH 261/306 mpi: Fix NULL ptr dereference in mpi_powm() [ver #3]
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ryabinin <[email protected]>
commit f5527fffff3f002b0a6b376163613b82f69de073 upstream.
This fixes CVE-2016-8650.
If mpi_powm() is given a zero exponent, it wants to immediately return either 1 or 0, depending on the modulus. However, if the result was initalised with zero limb space, no limbs space is allocated and a NULL-pointer exception ensues.
Fix this by allocating a minimal amount of limb space for the result when the 0-exponent case when the result is 1 and not touching the limb space when the result is 0.
This affects the use of RSA keys and X.509 certificates that carry them.
BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffff8138ce5d>] mpi_powm+0x32/0x7e6 PGD 0 Oops: 0002 [#1] SMP Modules linked in: CPU: 3 PID: 3014 Comm: keyctl Not tainted 4.9.0-rc6-fscache+ #278 Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014 task: ffff8804011944c0 task.stack: ffff880401294000 RIP: 0010:[<ffffffff8138ce5d>] [<ffffffff8138ce5d>] mpi_powm+0x32/0x7e6 RSP: 0018:ffff880401297ad8 EFLAGS: 00010212 RAX: 0000000000000000 RBX: ffff88040868bec0 RCX: ffff88040868bba0 RDX: ffff88040868b260 RSI: ffff88040868bec0 RDI: ffff88040868bee0 RBP: ffff880401297ba8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000047 R11: ffffffff8183b210 R12: 0000000000000000 R13: ffff8804087c7600 R14: 000000000000001f R15: ffff880401297c50 FS: 00007f7a7918c700(0000) GS:ffff88041fb80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000000401250000 CR4: 00000000001406e0 Stack: ffff88040868bec0 0000000000000020 ffff880401297b00 ffffffff81376cd4 0000000000000100 ffff880401297b10 ffffffff81376d12 ffff880401297b30 ffffffff81376f37 0000000000000100 0000000000000000 ffff880401297ba8 Call Trace: [<ffffffff81376cd4>] ? __sg_page_iter_next+0x43/0x66 [<ffffffff81376d12>] ? sg_miter_get_next_page+0x1b/0x5d [<ffffffff81376f37>] ? sg_miter_next+0x17/0xbd [<ffffffff8138ba3a>] ? mpi_read_raw_from_sgl+0xf2/0x146 [<ffffffff8132a95c>] rsa_verify+0x9d/0xee [<ffffffff8132acca>] ? pkcs1pad_sg_set_buf+0x2e/0xbb [<ffffffff8132af40>] pkcs1pad_verify+0xc0/0xe1 [<ffffffff8133cb5e>] public_key_verify_signature+0x1b0/0x228 [<ffffffff8133d974>] x509_check_for_self_signed+0xa1/0xc4 [<ffffffff8133cdde>] x509_cert_parse+0x167/0x1a1 [<ffffffff8133d609>] x509_key_preparse+0x21/0x1a1 [<ffffffff8133c3d7>] asymmetric_key_preparse+0x34/0x61 [<ffffffff812fc9f3>] key_create_or_update+0x145/0x399 [<ffffffff812fe227>] SyS_add_key+0x154/0x19e [<ffffffff81001c2b>] do_syscall_64+0x80/0x191 [<ffffffff816825e4>] entry_SYSCALL64_slow_path+0x25/0x25 Code: 56 41 55 41 54 53 48 81 ec a8 00 00 00 44 8b 71 04 8b 42 04 4c 8b 67 18 45 85 f6 89 45 80 0f 84 b4 06 00 00 85 c0 75 2f 41 ff ce <49> c7 04 24 01 00 00 00 b0 01 75 0b 48 8b 41 18 48 83 38 01 0f RIP [<ffffffff8138ce5d>] mpi_powm+0x32/0x7e6 RSP <ffff880401297ad8> CR2: 0000000000000000 ---[ end trace d82015255d4a5d8d ]---
Basically, this is a backport of a libgcrypt patch:
http://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=patch;h=6e1adb05d290aeeb1c230c763970695f4a538526
--- lib/mpi/mpi-pow.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
lib/mpi/mpi-pow.c +6 -1
@@ -64,8 +64,13 @@ int mpi_powm(MPI res, MPI base, MPI exp,if (!esize) {/* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 * depending on if MOD equals 1. */ - rp[0 ] =1 ; res->nlimbs = (msize ==1 && mod->d[0 ] ==1 ) ?0 :1 ; +if (res->nlimbs) { +if (mpi_resize (res,1 ) <0 ) + goto enomem; + rp = res->d; + rp[0 ] =1 ; + } res->sign =0 ; goto leave; }
PATCH 262/306 parisc: Fix race in pci-dma.c
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit c0452fb9fb8f49c7d68ab9fa0ad092016be7b45f upstream.
We are still troubled by occasional random segmentation faults and memory memory corruption on SMP machines. The causes quite a few package builds to fail on the Debian buildd machines for parisc. When gcc-6 failed to build three times in a row, I looked again at the TLB related code. I found a couple of issues. This is the first.
In general, we need to ensure page table updates and corresponding TLB purges are atomic. The attached patch fixes an instance in pci-dma.c where the page table update was not guarded by the TLB lock.
Tested on rp3440 and c8000. So far, no further random segmentation faults have been observed.
--- arch/parisc/kernel/pci-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/pci-dma.c +1 -1
@@ -95,8 +95,8 @@ static inline int map_pte_uncached(pte_tif (!pte_none (*pte))printk (KERN_ERR "map_pte_uncached: page already exists\n" ); -set_pte (pte,__mk_pte (*paddr_ptr,PAGE_KERNEL_UNC ));purge_tlb_start (flags); +set_pte (pte,__mk_pte (*paddr_ptr,PAGE_KERNEL_UNC ));pdtlb_kernel (orig_vaddr);purge_tlb_end (flags); vaddr +=PAGE_SIZE ;
PATCH 263/306 parisc: Also flush data TLB in flush_icache_page_asm
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit 5035b230e7b67ac12691ed3b5495bbb617027b68 upstream.
This is the second issue I noticed in reviewing the parisc TLB code.
The fic instruction may use either the instruction or data TLB in flushing the instruction cache. Thus, on machines with a split TLB, we should also flush the data TLB after setting up the temporary alias registers.
Although this has no functional impact, I changed the pdtlb and pitlb instructions to consistently use the index register %r0. These instructions do not support integer displacements.
Tested on rp3440 and c8000.
--- arch/parisc/kernel/pacache.S | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
arch/parisc/kernel/pacache.S +22 -15
@@ -96,7 +96,7 @@ fitmanyloop: /* Loop if LOOP >= 2 */ fitmanymiddle: /* Loop if LOOP >= 2 */ addib,COND(>) -1, %r31, fitmanymiddle /* Adjusted inner loop decr */ - pitlbe 0(%sr1, %r28) + pitlbe %r0(%sr1, %r28) pitlbe,m %arg1(%sr1, %r28) /* Last pitlbe and addr adjust */ addib,COND(>) -1, %r29, fitmanymiddle /* Middle loop decr */ copy %arg3, %r31 /* Re-init inner loop count */
@@ -139,7 +139,7 @@ fdtmanyloop: /* Loop if LOOP >= 2 */ fdtmanymiddle: /* Loop if LOOP >= 2 */ addib,COND(>) -1, %r31, fdtmanymiddle /* Adjusted inner loop decr */ - pdtlbe 0(%sr1, %r28) + pdtlbe %r0(%sr1, %r28) pdtlbe,m %arg1(%sr1, %r28) /* Last pdtlbe and addr adjust */ addib,COND(>) -1, %r29, fdtmanymiddle /* Middle loop decr */ copy %arg3, %r31 /* Re-init inner loop count */
@@ -620,12 +620,12 @@ ENTRY(copy_user_page_asm) /* Purge any old translations */ #ifdef CONFIG_PA20 - pdtlb,l 0(%r28) - pdtlb,l 0(%r29) + pdtlb,l %r0(%r28) + pdtlb,l %r0(%r29) #else tlb_lock %r20,%r21,%r22 - pdtlb 0(%r28) - pdtlb 0(%r29) + pdtlb %r0(%r28) + pdtlb %r0(%r29) tlb_unlock %r20,%r21,%r22 #endif
@@ -768,10 +768,10 @@ ENTRY(clear_user_page_asm) /* Purge any old translation */ #ifdef CONFIG_PA20 - pdtlb,l 0(%r28) + pdtlb,l %r0(%r28) #else tlb_lock %r20,%r21,%r22 - pdtlb 0(%r28) + pdtlb %r0(%r28) tlb_unlock %r20,%r21,%r22 #endif
@@ -852,10 +852,10 @@ ENTRY(flush_dcache_page_asm) /* Purge any old translation */ #ifdef CONFIG_PA20 - pdtlb,l 0(%r28) + pdtlb,l %r0(%r28) #else tlb_lock %r20,%r21,%r22 - pdtlb 0(%r28) + pdtlb %r0(%r28) tlb_unlock %r20,%r21,%r22 #endif
@@ -892,10 +892,10 @@ ENTRY(flush_dcache_page_asm) sync #ifdef CONFIG_PA20 - pdtlb,l 0(%r25) + pdtlb,l %r0(%r25) #else tlb_lock %r20,%r21,%r22 - pdtlb 0(%r25) + pdtlb %r0(%r25) tlb_unlock %r20,%r21,%r22 #endif
@@ -925,13 +925,18 @@ ENTRY(flush_icache_page_asm) depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */ #endif - /* Purge any old translation */ + /* Purge any old translation. Note that the FIC instruction + * may use either the instruction or data TLB. Given that we + * have a flat address space, it's not clear which TLB will be + * used. So, we purge both entries. */ #ifdef CONFIG_PA20 + pdtlb,l %r0(%r28) pitlb,l %r0(%sr4,%r28) #else tlb_lock %r20,%r21,%r22 - pitlb (%sr4,%r28) + pdtlb %r0(%r28) + pitlb %r0(%sr4,%r28) tlb_unlock %r20,%r21,%r22 #endif
@@ -970,10 +975,12 @@ ENTRY(flush_icache_page_asm) sync #ifdef CONFIG_PA20 + pdtlb,l %r0(%r28) pitlb,l %r0(%sr4,%r25) #else tlb_lock %r20,%r21,%r22 - pitlb (%sr4,%r25) + pdtlb %r0(%r28) + pitlb %r0(%sr4,%r25) tlb_unlock %r20,%r21,%r22 #endif
PATCH 264/306 net: ethernet: mvneta: Remove IFF_UNICAST_FLT which is not implemented
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lunn <[email protected]>
commit 97db8afa2ab919fc400fe982f5054060868bdf07 upstream.
The mvneta driver advertises it supports IFF_UNICAST_FLT. However, it actually does not. The hardware probably does support it, but there is no code to configure the filter. As a quick and simple fix, remove the flag. This will cause the core to fall back to promiscuous mode.
--- drivers/net/ethernet/marvell/mvneta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvneta.c +1 -1
@@ -3078,7 +3078,7 @@ static int mvneta_probe(struct platform_ dev->features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO ; dev->hw_features |= dev->features; dev->vlan_features |= dev->features; - dev->priv_flags |=IFF_UNICAST_FLT |IFF_LIVE_ADDR_CHANGE ; + dev->priv_flags |=IFF_LIVE_ADDR_CHANGE ; dev->gso_max_segs =MVNETA_MAX_TSO_SEGS ; err =register_netdev (dev);
PATCH 265/306 net/mlx4: Fix uninitialized fields in rule when adding promiscuous mode to device managed flow steering
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jack Morgenstein <[email protected]>
commit 44b911e77793d686b481608770d0c55c18055ba0 upstream.
In procedure mlx4_flow_steer_promisc_add(), several fields were left uninitialized in the rule structure. Correctly initialize these fields.
--- drivers/net/ethernet/mellanox/mlx4/mcg.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/mcg.c +6 -1
@@ -1296,7 +1296,12 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_detach)int mlx4_flow_steer_promisc_add (struct mlx4_dev *dev,u8 port,u32 qpn,enum mlx4_net_trans_promisc_mode mode) { -struct mlx4_net_trans_rule rule; +struct mlx4_net_trans_rule rule = { + .queue_mode =MLX4_NET_TRANS_Q_FIFO , + .exclusive =0 , + .allow_loopback =1 , + }; +u64 *regid_p;switch (mode) {
PATCH 266/306 pwm: Fix device reference leak
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 0e1614ac84f1719d87bed577963bb8140d0c9ce8 upstream.
Make sure to drop the reference to the parent device taken by class_find_device() after "unexporting" any children when deregistering a PWM chip.
--- drivers/pwm/sysfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pwm/sysfs.c +2 -0
@@ -356,6 +356,8 @@ void pwmchip_sysfs_unexport_children(strif (test_bit (PWMF_EXPORTED , &pwm->flags))pwm_unexport_child (parent, pwm); } + +put_device (parent); }static int __init pwm_sysfs_init (void )
PATCH 267/306 netfilter: arp_tables: fix invoking 32bit "iptable -P INPUT ACCEPT" failed in 64bit kernel
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Hongxu Jia <[email protected]>
commit 17a49cd549d9dc8707dc9262210166455c612dde upstream.
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
@@ -1332,8 +1332,8 @@ static int translate_compat_table(struct 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;
PATCH 268/306 powerpc/eeh: Fix deadlock when PE frozen state can't be cleared
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Donnellan <[email protected]>
commit 409bf7f8a02ef88db5a0f2cdcf9489914f4b8508 upstream.
In eeh_reset_device(), we take the pci_rescan_remove_lock immediately after after we call eeh_reset_pe() to reset the PCI controller. We then call eeh_clear_pe_frozen_state(), which can return an error. In this case, we bail out of eeh_reset_device() without calling pci_unlock_rescan_remove().
Add a call to pci_unlock_rescan_remove() in the eeh_clear_pe_frozen_state() error path so that we don't cause a deadlock later on.
--- arch/powerpc/kernel/eeh_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kernel/eeh_driver.c +3 -1
@@ -541,8 +541,10 @@ static int eeh_reset_device(struct eeh_p/* Clear frozen state */ rc =eeh_clear_pe_frozen_state (pe); -if (rc) +if (rc) { +pci_unlock_rescan_remove ();return rc; + }/* Give the system 5 seconds to finish running the user-space * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes,
PATCH 269/306 batman-adv: Check for alloc errors when preparing TT local data
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit c2d0f48a13e53b4747704c9e692f5e765e52041a upstream.
batadv_tt_prepare_tvlv_local_data can fail to allocate the memory for the new TVLV block. The caller is informed about this problem with the returned length of 0. Not checking this value results in an invalid memory access when either tt_data or tt_change is accessed.
--- net/batman-adv/translation-table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/batman-adv/translation-table.c +2 -2
@@ -2722,7 +2722,7 @@ static bool batadv_send_my_tt_response(s &tvlv_tt_data, &tt_change, &tt_len); -if (!tt_len) +if (!tt_len || !tvlv_len) goto unlock;/* Copy the last orig_node's OGM buffer */
@@ -2740,7 +2740,7 @@ static bool batadv_send_my_tt_response(s &tvlv_tt_data, &tt_change, &tt_len); -if (!tt_len) +if (!tt_len || !tvlv_len) goto out;/* fill the rest of the tvlv with the real TT entries */
PATCH 270/306 locking/rtmutex: Prevent dequeue vs. unlock race
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit dbb26055defd03d59f678cb5f2c992abe05b064a upstream.
David reported a futex/rtmutex state corruption. It's caused by the following problem:
CPU0 CPU1 CPU2
l->owner=T1
rt_mutex_lock(l)
lock(l->wait_lock)
l->owner = T1 | HAS_WAITERS;
enqueue(T2)
boost()
unlock(l->wait_lock)
schedule()
rt_mutex_lock(l)
lock(l->wait_lock)
l->owner = T1 | HAS_WAITERS;
enqueue(T3)
boost()
unlock(l->wait_lock)
schedule()
signal(->T2) signal(->T3)
lock(l->wait_lock)
dequeue(T2)
deboost()
unlock(l->wait_lock)
lock(l->wait_lock)
dequeue(T3)
===> wait list is now empty
deboost()
unlock(l->wait_lock)
lock(l->wait_lock)
fixup_rt_mutex_waiters()
if (wait_list_empty(l)) {
owner = l->owner & ~HAS_WAITERS;
l->owner = owner
==> l->owner = T1
}
lock(l->wait_lock)
rt_mutex_unlock(l) fixup_rt_mutex_waiters()
if (wait_list_empty(l)) {
owner = l->owner & ~HAS_WAITERS;
cmpxchg(l->owner, T1, NULL)
===> Success (l->owner = NULL)
l->owner = owner
==> l->owner = T1
}That means the problem is caused by fixup_rt_mutex_waiters() which does the RMW to clear the waiters bit unconditionally when there are no waiters in the rtmutexes rbtree.
This can be fatal: A concurrent unlock can release the rtmutex in the fastpath because the waiters bit is not set. If the cmpxchg() gets in the middle of the RMW operation then the previous owner, which just unlocked the rtmutex is set as the owner again when the write takes place after the successfull cmpxchg().
The solution is rather trivial: verify that the owner member of the rtmutex has the waiters bit set before clearing it. This does not require a cmpxchg() or other atomic operations because the waiters bit can only be set and cleared with the rtmutex wait_lock held. It's also safe against the fast path unlock attempt. The unlock attempt via cmpxchg() will either see the bit set and take the slowpath or see the bit cleared and release it atomically in the fastpath.
It's remarkable that the test program provided by David triggers on ARM64 and MIPS64 really quick, but it refuses to reproduce on x86-64, while the problem exists there as well. That refusal might explain that this got not discovered earlier despite the bug existing from day one of the rtmutex implementation more than 10 years ago.
Thanks to David for meticulously instrumenting the code and providing the information which allowed to decode this subtle problem.
--- kernel/locking/rtmutex.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-)
kernel/locking/rtmutex.c +66 -2
@@ -65,8 +65,72 @@ static inline void clear_rt_mutex_waiterstatic void fixup_rt_mutex_waiters (struct rt_mutex *lock) { -if (!rt_mutex_has_waiters (lock)) -clear_rt_mutex_waiters (lock); +unsigned long owner, *p = (unsigned long *) &lock->owner; + +if (rt_mutex_has_waiters (lock)) +return ; + +/* +* The rbtree has no waiters enqueued, now make sure that the +* lock->owner still has the waiters bit set, otherwise the +* following can happen: +* +* CPU 0 CPU 1 CPU2 +* l->owner=T1 +* rt_mutex_lock(l) +* lock(l->lock) +* l->owner = T1 | HAS_WAITERS; +* enqueue(T2) +* boost() +* unlock(l->lock) +* block() +* +* rt_mutex_lock(l) +* lock(l->lock) +* l->owner = T1 | HAS_WAITERS; +* enqueue(T3) +* boost() +* unlock(l->lock) +* block() +* signal(->T2) signal(->T3) +* lock(l->lock) +* dequeue(T2) +* deboost() +* unlock(l->lock) +* lock(l->lock) +* dequeue(T3) +* ==> wait list is empty +* deboost() +* unlock(l->lock) +* lock(l->lock) +* fixup_rt_mutex_waiters() +* if (wait_list_empty(l) { +* l->owner = owner +* owner = l->owner & ~HAS_WAITERS; +* ==> l->owner = T1 +* } +* lock(l->lock) +* rt_mutex_unlock(l) fixup_rt_mutex_waiters() +* if (wait_list_empty(l) { +* owner = l->owner & ~HAS_WAITERS; +* cmpxchg(l->owner, T1, NULL) +* ===> Success (l->owner = NULL) +* +* l->owner = owner +* ==> l->owner = T1 +* } +* +* With the check for the waiter bit in place T3 on CPU2 will not +* overwrite. All tasks fiddling with the waiters bit are +* serialized by l->lock, so nothing else can modify the waiters +* bit. If the bit is set then nothing can change l->owner either +* so the simple RMW is safe. The cmpxchg() will simply fail if it +* happens in the middle of the RMW because the waiters bit is +* still set. +*/ + owner =ACCESS_ONCE (*p); +if (owner &RT_MUTEX_HAS_WAITERS ) +ACCESS_ONCE (*p) = owner & ~RT_MUTEX_HAS_WAITERS ; }/*
PATCH 271/306 packet: fix race condition in packet_set_ring
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Philip Pettersson <[email protected]>
commit 84ac7260236a49c79eede91617700174c2c19b0c upstream.
When packet_set_ring creates a ring buffer it will initialize a struct timer_list if the packet version is TPACKET_V3. This value can then be raced by a different thread calling setsockopt to set the version to TPACKET_V1 before packet_set_ring has finished.
This leads to a use-after-free on a function pointer in the struct timer_list when the socket is closed as the previously initialized timer will not be deleted.
The bug is fixed by taking lock_sock(sk) in packet_setsockopt when changing the packet version while also taking the lock at the start of packet_set_ring.
--- net/packet/af_packet.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
net/packet/af_packet.c +12 -6
@@ -3304,19 +3304,25 @@ packet_setsockopt(struct socket *sock, iif (optlen !=sizeof (val))return -EINVAL ; -if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) -return -EBUSY ;if (copy_from_user (&val, optval,sizeof (val)))return -EFAULT ;switch (val) {case TPACKET_V1 :case TPACKET_V2 :case TPACKET_V3 : - po->tp_version = val; -return 0 ; +break ;default :return -EINVAL ; } +lock_sock (sk); +if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) { + ret = -EBUSY ; + }else { + po->tp_version = val; + ret =0 ; + } +release_sock (sk); +return ret; }case PACKET_RESERVE : {
@@ -3779,6 +3785,7 @@ static int packet_set_ring(struct sock */* Added to avoid minimal code churn */ struct tpacket_req *req = &req_u->req; +lock_sock (sk);/* Opening a Tx-ring is NOT supported in TPACKET_V3 */ if (!closing && tx_ring && (po->tp_version >TPACKET_V2 )) {WARN (1 ,"Tx-ring is not supported.\n" );
@@ -3860,7 +3867,6 @@ static int packet_set_ring(struct sock * goto out; } -lock_sock (sk);/* Detach socket from network */ spin_lock (&po->bind_lock);
@@ -3909,11 +3915,11 @@ static int packet_set_ring(struct sock *if (!tx_ring)prb_shutdown_retire_blk_timer (po, tx_ring, rb_queue); } -release_sock (sk);if (pg_vec)free_pg_vec (pg_vec, order, req->tp_block_nr); out: +release_sock (sk);return err; }
PATCH 272/306 ipv4: Set skb->protocol properly for local output
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eli Cooper <[email protected]>
commit f4180439109aa720774baafdd798b3234ab1a0d2 upstream.
When xfrm is applied to TSO/GSO packets, it follows this path:
xfrm_output() -> xfrm_output_gso() -> skb_gso_segment()
where skb_gso_segment() relies on skb->protocol to function properly.
This patch sets skb->protocol to ETH_P_IP before dst_output() is called, fixing a bug where GSO packets sent through a sit tunnel are dropped when xfrm is involved.
--- net/ipv4/ip_output.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/ip_output.c +2 -0
@@ -97,6 +97,8 @@ int __ip_local_out(struct sk_buff *skb) iph->tot_len =htons (skb->len);ip_send_check (iph); + skb->protocol =htons (ETH_P_IP ); +return nf_hook (NFPROTO_IPV4 ,NF_INET_LOCAL_OUT , skb,NULL ,skb_dst (skb)->dev, dst_output); }
PATCH 273/306 ipv6: Set skb->protocol properly for local output
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eli Cooper <[email protected]>
commit b4e479a96fc398ccf83bb1cffb4ffef8631beaf1 upstream.
When xfrm is applied to TSO/GSO packets, it follows this path:
xfrm_output() -> xfrm_output_gso() -> skb_gso_segment()
where skb_gso_segment() relies on skb->protocol to function properly.
This patch sets skb->protocol to ETH_P_IPV6 before dst_output() is called, fixing a bug where GSO packets sent through an ipip6 tunnel are dropped when xfrm is involved.
--- net/ipv6/output_core.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/output_core.c +2 -0
@@ -114,6 +114,8 @@ int __ip6_local_out(struct sk_buff *skb)ipv6_hdr (skb)->payload_len =htons (len);IP6CB (skb)->nhoff = offsetof(struct ipv6hdr , nexthdr); + skb->protocol =htons (ETH_P_IPV6 ); +return nf_hook (NFPROTO_IPV6 ,NF_INET_LOCAL_OUT , skb,NULL ,skb_dst (skb)->dev, dst_output); }
PATCH 274/306 net: bcmgenet: Utilize correct struct device for all DMA operations
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit 8c4799ac799665065f9bf1364fd71bf4f7dc6a4a upstream.
__bcmgenet_tx_reclaim() and bcmgenet_free_rx_buffers() are not using the same struct device during unmap that was used for the map operation, which makes DMA-API debugging warn about it. Fix this by always using &priv->pdev->dev throughout the driver, using an identical device reference for all map/unmap calls.
[bwh: Backported to 3.16:
- Adjust context
- Also fix call from bcmgenet_desc_rx(), fixed upstream in commit d6707bec5986 "net: bcmgenet: rewrite bcmgenet_rx_refill()"]
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +7 -4
@@ -878,6 +878,7 @@ static void __bcmgenet_tx_reclaim(struct struct bcmgenet_tx_ring *ring) {struct bcmgenet_priv *priv =netdev_priv (dev); +struct device *kdev = &priv->pdev->dev;int last_tx_cn, last_c_index, num_tx_bds;struct enet_cb *tx_cb_ptr;struct netdev_queue *txq;
@@ -907,7 +908,7 @@ static void __bcmgenet_tx_reclaim(struct tx_cb_ptr = ring->cbs + last_c_index;if (tx_cb_ptr->skb) { dev->stats.tx_bytes += tx_cb_ptr->skb->len; -dma_unmap_single (&dev->dev, +dma_unmap_single (kdev,dma_unmap_addr (tx_cb_ptr, dma_addr),dma_unmap_len (tx_cb_ptr, dma_len),DMA_TO_DEVICE );
@@ -915,7 +916,7 @@ static void __bcmgenet_tx_reclaim(struct }else if (dma_unmap_addr (tx_cb_ptr, dma_addr)) { dev->stats.tx_bytes +=dma_unmap_len (tx_cb_ptr, dma_len); -dma_unmap_page (&dev->dev, +dma_unmap_page (kdev,dma_unmap_addr (tx_cb_ptr, dma_addr),dma_unmap_len (tx_cb_ptr, dma_len),DMA_TO_DEVICE );
@@ -1257,6 +1258,7 @@ static unsigned int bcmgenet_desc_rx(str unsigned int budget) {struct net_device *dev = priv->dev; +struct device *kdev = &priv->pdev->dev;struct enet_cb *cb;struct sk_buff *skb;u32 dma_length_status;
@@ -1288,7 +1290,7 @@ static unsigned int bcmgenet_desc_rx(str*/ cb = &priv->rx_cbs[priv->rx_read_ptr]; skb = cb->skb; -dma_unmap_single (&dev->dev,dma_unmap_addr (cb, dma_addr), +dma_unmap_single (kdev,dma_unmap_addr (cb, dma_addr), priv->rx_buf_len,DMA_FROM_DEVICE );if (!priv->desc_64b_en) {
@@ -1428,6 +1430,7 @@ static int bcmgenet_alloc_rx_buffers(strstatic void bcmgenet_free_rx_buffers (struct bcmgenet_priv *priv) { +struct device *kdev = &priv->pdev->dev;struct enet_cb *cb;int i;
@@ -1435,7 +1438,7 @@ static void bcmgenet_free_rx_buffers(str cb = &priv->rx_cbs[i];if (dma_unmap_addr (cb, dma_addr)) { -dma_unmap_single (&priv->dev->dev, +dma_unmap_single (kdev,dma_unmap_addr (cb, dma_addr), priv->rx_buf_len,DMA_FROM_DEVICE );dma_unmap_addr_set (cb, dma_addr,0 );
PATCH 275/306 sh_eth: remove unchecked interrupts for RZ/A1
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Chris Brandt <[email protected]>
commit 33d446dbba4d4d6a77e1e900d434fa99e0f02c86 upstream.
When streaming a lot of data and the RZ/A1 can't keep up, some status bits will get set that are not being checked or cleared which cause the following messages and the Ethernet driver to stop working. This patch fixes that issue.
irq 21: nobody cared (try booting with the "irqpoll" option) handlers:
[<c036b71c>] sh_eth_interrupt
Disabling IRQ #21
--- drivers/net/ethernet/renesas/sh_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/renesas/sh_eth.c +1 -1
@@ -795,7 +795,7 @@ static struct sh_eth_cpu_data r7s72100_d .ecsr_value = ECSR_ICD, .ecsipr_value = ECSIPR_ICDIP, - .eesipr_value = 0xff7f009f, + .eesipr_value = 0xe77f009f, .tx_check = EESR_TC1 | EESR_FTC, .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT |
PATCH 276/306 tipc: check minimum bearer MTU
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michal Kubeček <[email protected]>
commit 3de81b758853f0b29c61e246679d20b513c4cfec upstream.
Qian Zhang (张谦) reported a potential socket buffer overflow in tipc_msg_build() which is also known as CVE-2016-8632: due to insufficient checks, a buffer overflow can occur if MTU is too short for even tipc headers. As anyone can set device MTU in a user/net namespace, this issue can be abused by a regular user.
As agreed in the discussion on Ben Hutchings' original patch, we should check the MTU at the moment a bearer is attached rather than for each processed packet. We also need to repeat the check when bearer MTU is adjusted to new device MTU. UDP case also needs a check to avoid overflow when calculating bearer MTU.
[bwh: Backported to 3.16:
- Adjust context
- Duplicate macro definitions in bearer.h to avoid mutual inclusion
- NETDEV_DOWN and NETDEV_CHANGEMTU cases in net notifier were combined
- Drop changes in udp_media.c]
---
net/tipc/bearer.c +11 -2
@@ -420,6 +420,10 @@ int tipc_enable_l2_media(struct tipc_bea dev =dev_get_by_name (&init_net, driver_name);if (!dev)return -ENODEV ; +if (tipc_mtu_bad (dev,0 )) { +dev_put (dev); +return -EINVAL ; + }/* Associate TIPC bearer with L2 bearer */ rcu_assign_pointer (b->media_ptr, dev);
@@ -564,14 +568,19 @@ static int tipc_l2_device_event(struct nif (!b_ptr)return NOTIFY_DONE ; - b_ptr->mtu = dev->mtu; -switch (evt) {case NETDEV_CHANGE :if (netif_carrier_ok (dev))break ;case NETDEV_DOWN : +tipc_reset_bearer (b_ptr); +break ;case NETDEV_CHANGEMTU : +if (tipc_mtu_bad (dev,0 )) { +bearer_disable (b_ptr, false); +break ; + } + b_ptr->mtu = dev->mtu;tipc_reset_bearer (b_ptr);break ;case NETDEV_CHANGEADDR :
net/tipc/bearer.h +16 -0
@@ -50,6 +50,13 @@#define TIPC_MEDIA_ADDR_SIZE 32#define TIPC_MEDIA_TYPE_OFFSET 3 +/* Message header sizes from msg.h - duplicated to avoid mutual inclusion */ +#define INT_H_SIZE 40 +#define MAX_H_SIZE 60 + +/* minimum bearer MTU */ +#define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE) +/* * Identifiers of supported TIPC media types */
@@ -196,4 +203,13 @@ void tipc_bearer_stop(void);void tipc_bearer_send (u32 bearer_id,struct sk_buff *buf,struct tipc_media_addr *dest); +/* check if device MTU is too low for tipc headers */ +static inline bool tipc_mtu_bad (struct net_device *dev,unsigned int reserve) +{ +if (dev->mtu >=TIPC_MIN_BEARER_MTU + reserve) +return false; +netdev_warn (dev,"MTU too low for tipc bearer\n" ); +return true; +} +#endif /* _TIPC_BEARER_H */
PATCH 277/306 net: ping: check minimum size on ICMP header length
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 0eab121ef8750a5c8637d51534d5e9143fb0633f upstream.
Prior to commit c0371da6047a ("put iov_iter into msghdr") in v3.19, there was no check that the iovec contained enough bytes for an ICMP header, and the read loop would walk across neighboring stack contents. Since the iov_iter conversion, bad arguments are noticed, but the returned error is EFAULT. Returning EINVAL is a clearer error and also solves the problem prior to v3.19.
This was found using trinity with KASAN on v3.18:
BUG: KASAN: stack-out-of-bounds in memcpy_fromiovec+0x60/0x114 at addr ffffffc071077da0 Read of size 8 by task trinity-c2/9623 page:ffffffbe034b9a08 count:0 mapcount:0 mapping: (null) index:0x0 flags: 0x0() page dumped because: kasan: bad access detected CPU: 0 PID: 9623 Comm: trinity-c2 Tainted: G BU 3.18.0-dirty #15 Hardware name: Google Tegra210 Smaug Rev 1,3+ (DT) Call trace: [<ffffffc000209c98>] dump_backtrace+0x0/0x1ac arch/arm64/kernel/traps.c:90 [<ffffffc000209e54>] show_stack+0x10/0x1c arch/arm64/kernel/traps.c:171 [< inline >] __dump_stack lib/dump_stack.c:15 [<ffffffc000f18dc4>] dump_stack+0x7c/0xd0 lib/dump_stack.c:50 [< inline >] print_address_description mm/kasan/report.c:147 [< inline >] kasan_report_error mm/kasan/report.c:236 [<ffffffc000373dcc>] kasan_report+0x380/0x4b8 mm/kasan/report.c:259 [< inline >] check_memory_region mm/kasan/kasan.c:264 [<ffffffc00037352c>] __asan_load8+0x20/0x70 mm/kasan/kasan.c:507 [<ffffffc0005b9624>] memcpy_fromiovec+0x5c/0x114 lib/iovec.c:15 [< inline >] memcpy_from_msg include/linux/skbuff.h:2667 [<ffffffc000ddeba0>] ping_common_sendmsg+0x50/0x108 net/ipv4/ping.c:674 [<ffffffc000dded30>] ping_v4_sendmsg+0xd8/0x698 net/ipv4/ping.c:714 [<ffffffc000dc91dc>] inet_sendmsg+0xe0/0x12c net/ipv4/af_inet.c:749 [< inline >] __sock_sendmsg_nosec net/socket.c:624 [< inline >] __sock_sendmsg net/socket.c:632 [<ffffffc000cab61c>] sock_sendmsg+0x124/0x164 net/socket.c:643 [< inline >] SYSC_sendto net/socket.c:1797 [<ffffffc000cad270>] SyS_sendto+0x178/0x1d8 net/socket.c:1761
CVE-2016-8399
--- net/ipv4/ping.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv4/ping.c +4 -0
@@ -661,6 +661,10 @@ int ping_common_sendmsg(int family, struif (len >0xFFFF )return -EMSGSIZE ; +/* Must have at least a full ICMP header. */ +if (len < icmph_len) +return -EINVAL ; +/* * Check the flags. */
PATCH 278/306 net: ep93xx_eth: Do not crash unloading module
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
commit c823abac17926767fb50175e098f087a6ac684c3 upstream.
When we unload the ep93xx_eth, whether we have opened the network interface or not, we will either hit a kernel paging request error, or a simple NULL pointer de-reference because:
- if ep93xx_open has been called, we have created a valid DMA mapping for ep->descs, when we call ep93xx_stop, we also call ep93xx_free_buffers, ep->descs now has a stale value
- if ep93xx_open has not been called, we have a NULL pointer for ep->descs, so performing any operation against that address just won't work
Fix this by adding a NULL pointer check for ep->descs which means that ep93xx_free_buffers() was able to successfully tear down the descriptors and free the DMA cookie as well.
--- drivers/net/ethernet/cirrus/ep93xx_eth.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/cirrus/ep93xx_eth.c +4 -0
@@ -468,6 +468,9 @@ static void ep93xx_free_buffers(struct estruct device *dev = ep->dev->dev.parent;int i; +if (!ep->descs) +return ; +for (i =0 ; i <RX_QUEUE_ENTRIES ; i++) {dma_addr_t d;
@@ -492,6 +495,7 @@ static void ep93xx_free_buffers(struct edma_free_coherent (dev,sizeof (struct ep93xx_descs ), ep->descs, ep->descs_dma_addr); + ep->descs =NULL ; }static int ep93xx_alloc_buffers (struct ep93xx_priv *ep)
PATCH 279/306 perf/x86: Fix full width counter, counter overflow
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Peter Zijlstra (Intel)" <[email protected]>
commit 7f612a7f0bc13a2361a152862435b7941156b6af upstream.
Lukasz reported that perf stat counters overflow handling is broken on KNL/SLM.
Both these parts have full_width_write set, and that does indeed have a problem. In order to deal with counter wrap, we must sample the counter at at least half the counter period (see also the sampling theorem) such that we can unambiguously reconstruct the count.
However commit:
069e0c3c4058 ("perf/x86/intel: Support full width counting")
sets the sampling interval to the full period, not half.
Fixing that exposes another issue, in that we must not sign extend the delta value when we shift it right; the counter cannot have decremented after all.
With both these issues fixed, counter overflow functions correctly again.
--- arch/x86/kernel/cpu/perf_event.c | 2 +- arch/x86/kernel/cpu/perf_event_intel.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event.c +1 -1
@@ -64,7 +64,7 @@ u64 x86_perf_event_update(struct perf_evint shift =64 - x86_pmu.cntval_bits;u64 prev_raw_count, new_raw_count;int idx = hwc->idx; -s64 delta; +u64 delta;if (idx ==INTEL_PMC_IDX_FIXED_BTS )return 0 ;
arch/x86/kernel/cpu/perf_event_intel.c +1 -1
@@ -2669,7 +2669,7 @@ __init int intel_pmu_init(void)/* Support full width counters using alternative MSR range */ if (x86_pmu.intel_cap.full_width_write) { - x86_pmu.max_period = x86_pmu.cntval_mask; + x86_pmu.max_period = x86_pmu.cntval_mask >>1 ; x86_pmu.perfctr =MSR_IA32_PMC0 ;pr_cont ("full-width counters, " ); }
PATCH 280/306 fuse: fix clearing suid, sgid for chown()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit c01638f5d919728f565bf8b5e0a6a159642df0d9 upstream.
Basically, the pjdfstests set the ownership of a file to 06555, and then chowns it (as root) to a new uid/gid. Prior to commit a09f99eddef4 ("fuse:
fix killing s[ug]id in setattr"), fuse would send down a setattr with both the uid/gid change and a new mode. Now, it just sends down the uid/gid change.
Technically this is NOTABUG, since POSIX doesn't _require_ that we clear these bits for a privileged process, but Linux (wisely) has done that and I think we don't want to change that behavior here.
This is caused by the use of should_remove_suid(), which will always return 0 when the process has CAP_FSETID.
In fact we really don't need to be calling should_remove_suid() at all, since we've already been indicated that we should remove the suid, we just don't want to use a (very) stale mode for that.
This patch should fix the above as well as simplify the logic.
--- fs/fuse/dir.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
fs/fuse/dir.c +2 -5
@@ -1829,8 +1829,6 @@ static int fuse_setattr(struct dentry *ereturn -EACCES ;if (attr->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) { -int kill; - attr->ia_valid &= ~(ATTR_KILL_SUID |ATTR_KILL_SGID |ATTR_MODE );/*
@@ -1842,12 +1840,11 @@ static int fuse_setattr(struct dentry *ereturn ret; attr->ia_mode = inode->i_mode; - kill =should_remove_suid (entry); -if (kill &ATTR_KILL_SUID ) { +if (inode->i_mode &S_ISUID ) { attr->ia_valid |=ATTR_MODE ; attr->ia_mode &= ~S_ISUID ; } -if (kill &ATTR_KILL_SGID ) { +if ((inode->i_mode & (S_ISGID |S_IXGRP )) == (S_ISGID |S_IXGRP )) { attr->ia_valid |=ATTR_MODE ; attr->ia_mode &= ~S_ISGID ; }
PATCH 281/306 parisc: Purge TLB before setting PTE
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit c78e710c1c9fbeff43dddc0aa3d0ff458e70b0cc upstream.
The attached change interchanges the order of purging the TLB and setting the corresponding page table entry. TLB purges are strongly ordered. It occurred to me one night that setting the PTE first might have subtle ordering issues on SMP machines and cause random memory corruption.
A TLB lock guards the insertion of user TLB entries. So after the TLB is purged, a new entry can't be inserted until the lock is released. This ensures that the new PTE value is used when the lock is released.
Since making this change, no random segmentation faults have been observed on the Debian hppa buildd servers.
--- arch/parisc/include/asm/pgtable.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/parisc/include/asm/pgtable.h +4 -4
@@ -48,8 +48,8 @@ extern void purge_tlb_entries(struct mm_do { \unsigned long flags; \spin_lock_irqsave (&pa_dbit_lock, flags); \ -set_pte (ptep, pteval); \purge_tlb_entries (mm, addr); \ +set_pte (ptep, pteval); \spin_unlock_irqrestore (&pa_dbit_lock, flags); \ }while (0 )
@@ -452,8 +452,8 @@ static inline int ptep_test_and_clear_yospin_unlock_irqrestore (&pa_dbit_lock, flags);return 0 ; } -set_pte (ptep,pte_mkold (pte));purge_tlb_entries (vma->vm_mm, addr); +set_pte (ptep,pte_mkold (pte));spin_unlock_irqrestore (&pa_dbit_lock, flags);return 1 ; }
@@ -466,8 +466,8 @@ static inline pte_t ptep_get_and_clear(sspin_lock_irqsave (&pa_dbit_lock, flags); old_pte = *ptep; -pte_clear (mm,addr,ptep);purge_tlb_entries (mm, addr); +pte_clear (mm,addr,ptep);spin_unlock_irqrestore (&pa_dbit_lock, flags);return old_pte;
@@ -477,8 +477,8 @@ static inline void ptep_set_wrprotect(st {unsigned long flags;spin_lock_irqsave (&pa_dbit_lock, flags); -set_pte (ptep,pte_wrprotect (*ptep));purge_tlb_entries (mm, addr); +set_pte (ptep,pte_wrprotect (*ptep));spin_unlock_irqrestore (&pa_dbit_lock, flags); }
PATCH 282/306 parisc: Remove unnecessary TLB purges from flush_dcache_page_asm and flush_icache_page_asm
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit febe42964fe182281859b3d43d844bb25ca49367 upstream.
We have four routines in pacache.S that use temporary alias pages:copy_user_page_asm(), clear_user_page_asm(), flush_dcache_page_asm() and flush_icache_page_asm(). copy_user_page_asm() and clear_user_page_asm() don't purge the TLB entry used for the operation. flush_dcache_page_asm() and flush_icache_page_asm do purge the entry.
Presumably, this was thought to optimize TLB use. However, the operation is quite heavy weight on PA 1.X processors as we need to take the TLB lock and a TLB broadcast is sent to all processors.
This patch removes the purges from flush_dcache_page_asm() and flush_icache_page_asm.
--- arch/parisc/kernel/pacache.S | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
arch/parisc/kernel/pacache.S +1 -21
@@ -886,19 +886,10 @@ ENTRY(flush_dcache_page_asm) fdc,m r31(%r28) fdc,m r31(%r28) fdc,m r31(%r28) - cmpb,COND(<<) %r28, %r25,1b + cmpb,COND(<<) %r28, %r25,1b fdc,m r31(%r28) sync - -#ifdef CONFIG_PA20 - pdtlb,l %r0(%r25) -#else - tlb_lock %r20,%r21,%r22 - pdtlb %r0(%r25) - tlb_unlock %r20,%r21,%r22 -#endif - bv %r0(%r2) nop .exit
@@ -973,17 +964,6 @@ ENTRY(flush_icache_page_asm) fic,m %r31(%sr4,%r28) sync - -#ifdef CONFIG_PA20 - pdtlb,l %r0(%r28) - pitlb,l %r0(%sr4,%r25) -#else - tlb_lock %r20,%r21,%r22 - pdtlb %r0(%r28) - pitlb %r0(%sr4,%r25) - tlb_unlock %r20,%r21,%r22 -#endif - bv %r0(%r2) nop .exit
PATCH 283/306 can: raw: raw_setsockopt: limit number of can_filter that can be set
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
commit 332b05ca7a438f857c61a3c21a88489a21532364 upstream.
This patch adds a check to limit the number of can_filters that can be set via setsockopt on CAN_RAW sockets. Otherwise allocations > MAX_ORDER are not prevented resulting in a warning.
Reference: https://lkml.org/lkml/2016/12/2/230
--- include/uapi/linux/can.h | 1 + net/can/raw.c | 3 +++ 2 files changed, 4 insertions(+)
include/uapi/linux/can.h +1 -0
@@ -190,5 +190,6 @@ struct can_filter { };#define CAN_INV_FILTER 0x20000000U/* to be set in can_filter.can_id */ +#define CAN_RAW_FILTER_MAX 512/* maximum number of can_filter set via setsockopt() */ #endif /* !_UAPI_CAN_H */
net/can/raw.c +3 -0
@@ -466,6 +466,9 @@ static int raw_setsockopt(struct socketif (optlen %sizeof (struct can_filter ) !=0 )return -EINVAL ; +if (optlen >CAN_RAW_FILTER_MAX *sizeof (struct can_filter )) +return -EINVAL ; + count = optlen /sizeof (struct can_filter );if (count >1 ) {
PATCH 284/306 can: peak: fix bad memory access and free sequence
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: 추지호 <[email protected]>
commit b67d0dd7d0dc9e456825447bbeb935d8ef43ea7c upstream.
Fix for bad memory access while disconnecting. netdev is freed before private data free, and dev is accessed after freeing netdev.
This makes a slub problem, and it raise kernel oops with slub debugger config.
--- drivers/net/can/usb/peak_usb/pcan_usb_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb_core.c +4 -2
@@ -826,23 +826,25 @@ lbl_free_candev:static void peak_usb_disconnect (struct usb_interface *intf) {struct peak_usb_device *dev; +struct peak_usb_device *dev_prev_siblings;/* unregister as many netdev devices as siblings */ -for (dev =usb_get_intfdata (intf); dev; dev = dev->prev_siblings) { +for (dev =usb_get_intfdata (intf); dev; dev = dev_prev_siblings) {struct net_device *netdev = dev->netdev;char name[IFNAMSIZ ]; + dev_prev_siblings = dev->prev_siblings; dev->state &= ~PCAN_USB_STATE_CONNECTED ;strncpy (name, netdev->name,IFNAMSIZ );unregister_netdev (netdev); -free_candev (netdev);kfree (dev->cmd_buf); dev->next_siblings =NULL ;if (dev->adapter->dev_free) dev->adapter->dev_free (dev); +free_candev (netdev);dev_info (&intf->dev,"%s removed\n" , name); }
PATCH 285/306 ser_gigaset: return -ENOMEM on error instead of success
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 93a97c50cbf1c007caf12db5cc23e0d5b9c8473c upstream.
If we can't allocate the resources in gigaset_initdriver() then we should return -ENOMEM instead of zero.
--- drivers/isdn/gigaset/ser-gigaset.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/isdn/gigaset/ser-gigaset.c +3 -1
@@ -791,8 +791,10 @@ static int __init ser_gigaset_init(void) driver =gigaset_initdriver (GIGASET_MINOR ,GIGASET_MINORS ,GIGASET_MODULENAME ,GIGASET_DEVNAME , &ops,THIS_MODULE ); -if (!driver) +if (!driver) { + rc = -ENOMEM ; goto error; + } rc =tty_register_ldisc (N_GIGASET_M101 , &gigaset_ldisc);if (rc !=0 ) {
PATCH 286/306 sg: Fix double-free when drives detach during SG_IO
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Calvin Owens <[email protected]>
commit f3951a3709ff50990bf3e188c27d346792103432 upstream.
In sg_common_write(), we free the block request and return -ENODEV if the device is detached in the middle of the SG_IO ioctl().
Unfortunately, sg_finish_rem_req() also tries to free srp->rq, so we end up freeing rq->cmd in the already free rq object, and then free the object itself out from under the current user.
This ends up corrupting random memory via the list_head on the rq object. The most common crash trace I saw is this:
------------[ cut here ]------------
kernel BUG at block/blk-core.c:1420!
Call Trace:
[<ffffffff81281eab>] blk_put_request+0x5b/0x80
[<ffffffffa0069e5b>] sg_finish_rem_req+0x6b/0x120 [sg]
[<ffffffffa006bcb9>] sg_common_write.isra.14+0x459/0x5a0 [sg]
[<ffffffff8125b328>] ? selinux_file_alloc_security+0x48/0x70
[<ffffffffa006bf95>] sg_new_write.isra.17+0x195/0x2d0 [sg]
[<ffffffffa006cef4>] sg_ioctl+0x644/0xdb0 [sg]
[<ffffffff81170f80>] do_vfs_ioctl+0x90/0x520
[<ffffffff81258967>] ? file_has_perm+0x97/0xb0
[<ffffffff811714a1>] SyS_ioctl+0x91/0xb0
[<ffffffff81602afb>] tracesys+0xdd/0xe2
RIP [<ffffffff81281e04>] __blk_put_request+0x154/0x1a0The solution is straightforward: just set srp->rq to NULL in the failure branch so that sg_finish_rem_req() doesn't attempt to re-free it.
Additionally, since sg_rq_end_io() will never be called on the object when this happens, we need to free memory backing ->cmd if it isn't embedded in the object itself.
KASAN was extremely helpful in finding the root cause of this bug.
[bwh: Backported to 3.16:
- sg_finish_rem_req() would not free srp->rq->cmd so don't do it here either
- Adjust context]
--- drivers/scsi/sg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/scsi/sg.c +4 -1
@@ -766,8 +766,11 @@ sg_common_write(Sg_fd * sfp, Sg_requestreturn k;/* probably out of space --> ENOMEM */ }if (sdp->detached) { -if (srp->bio) +if (srp->bio) {blk_end_request_all (srp->rq, -EIO ); + srp->rq =NULL ; + } +sg_finish_rem_req (srp);return -ENODEV ; }
PATCH 287/306 perf: Fix race in swevent hash
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 12ca6ad2e3a896256f086497a7c7406a547ee373 upstream.
There's a race on CPU unplug where we free the swevent hash array while it can still have events on. This will result in a use-after-free which is BAD.
Simply do not free the hash array on unplug. This leaves the thing around and no use-after-free takes place.
When the last swevent dies, we do a for_each_possible_cpu() iteration anyway to clean these up, at which time we'll free it, so no leakage will occur.
--- kernel/events/core.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
kernel/events/core.c +1 -19
@@ -5595,9 +5595,6 @@ struct swevent_htable {/* Recursion avoidance in each contexts */ int recursion[PERF_NR_CONTEXTS ]; - -/* Keeps track of cpu being initialized/exited */ -bool online; }; static DEFINE_PER_CPU(struct swevent_htable, swevent_htable);
@@ -5844,14 +5841,8 @@ static int perf_swevent_add(struct perf_ hwc->state = !(flags &PERF_EF_START ); head =find_swevent_head (swhash, event); -if (!head) { -/* -* We can race with cpu hotplug code. Do not -* WARN if the cpu just got unplugged. -*/ -WARN_ON_ONCE (swhash->online); +if (WARN_ON_ONCE (!head))return -EINVAL ; - }hlist_add_head_rcu (&event->hlist_entry, head);
@@ -5918,7 +5909,6 @@ static int swevent_hlist_get_cpu(structint err =0 ;mutex_lock (&swhash->hlist_mutex); -if (!swevent_hlist_deref (swhash) &&cpu_online (cpu)) {struct swevent_hlist *hlist;
@@ -8050,7 +8040,6 @@ static void perf_event_init_cpu(int cpu)struct swevent_htable *swhash = &per_cpu (swevent_htable, cpu);mutex_lock (&swhash->hlist_mutex); - swhash->online = true;if (swhash->hlist_refcount >0 ) {struct swevent_hlist *hlist;
@@ -8103,14 +8092,7 @@ static void perf_event_exit_cpu_context(static void perf_event_exit_cpu (int cpu) { -struct swevent_htable *swhash = &per_cpu (swevent_htable, cpu); -perf_event_exit_cpu_context (cpu); - -mutex_lock (&swhash->hlist_mutex); - swhash->online = false; -swevent_hlist_release (swhash); -mutex_unlock (&swhash->hlist_mutex); }#else static inline void perf_event_exit_cpu (int cpu) { }
PATCH 288/306 tty: Prevent ldisc drivers from re-using stale tty fields
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Hurley <[email protected]>
commit dd42bf1197144ede075a9d4793123f7689e164bc upstream.
Line discipline drivers may mistakenly misuse ldisc-related fields when initializing. For example, a failure to initialize tty->receive_room in the N_GIGASET_M101 line discipline was recently found and fixed [1]. Now, the N_X25 line discipline has been discovered accessing the previous line discipline's already-freed private data [2].
Harden the ldisc interface against misuse by initializing revelant tty fields before instancing the new line discipline.
[1]
commit fd98e9419d8d622a4de91f76b306af6aa627aa9c
Author: Tilman Schmidt <[email protected]>
Date: Tue Jul 14 00:37:13 2015 +0200
isdn/gigaset: reset tty->receive_room when attaching ser_gigaset[2] Report from Sasha Levin <[email protected]>
[ 634.336761] ==================================================================
[ 634.338226] BUG: KASAN: use-after-free in x25_asy_open_tty+0x13d/0x490 at addr ffff8800a743efd0
[ 634.339558] Read of size 4 by task syzkaller_execu/8981
[ 634.340359] =============================================================================
[ 634.341598] BUG kmalloc-512 (Not tainted): kasan: bad access detected
...
[ 634.405018] Call Trace:
[ 634.405277] dump_stack (lib/dump_stack.c:52)
[ 634.405775] print_trailer (mm/slub.c:655)
[ 634.406361] object_err (mm/slub.c:662)
[ 634.406824] kasan_report_error (mm/kasan/report.c:138 mm/kasan/report.c:236)
[ 634.409581] __asan_report_load4_noabort (mm/kasan/report.c:279)
[ 634.411355] x25_asy_open_tty (drivers/net/wan/x25_asy.c:559 (discriminator 1))
[ 634.413997] tty_ldisc_open.isra.2 (drivers/tty/tty_ldisc.c:447)
[ 634.414549] tty_set_ldisc (drivers/tty/tty_ldisc.c:567)
[ 634.415057] tty_ioctl (drivers/tty/tty_io.c:2646 drivers/tty/tty_io.c:2879)
[ 634.423524] do_vfs_ioctl (fs/ioctl.c:43 fs/ioctl.c:607)
[ 634.427491] SyS_ioctl (fs/ioctl.c:622 fs/ioctl.c:613)
[ 634.427945] entry_SYSCALL_64_fastpath (arch/x86/entry/entry_64.S:188)--- drivers/tty/tty_ldisc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/tty/tty_ldisc.c +7 -0
@@ -414,6 +414,10 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);* they are not on hot paths so a little discipline won't do * any harm. * +* The line discipline-related tty_struct fields are reset to +* prevent the ldisc driver from re-using stale information for +* the new ldisc instance. +* * Locking: takes termios_rwsem */
@@ -422,6 +426,9 @@ static void tty_set_termios_ldisc(structdown_write (&tty->termios_rwsem); tty->termios.c_line = num;up_write (&tty->termios_rwsem); + + tty->disc_data =NULL ; + tty->receive_room =0 ; }/**
PATCH 289/306 perf: Fix event->ctx locking
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit f63a8daa5812afef4f06c962351687e1ff9ccb2b upstream.
There have been a few reported issues wrt. the lack of locking around changing event->ctx. This patch tries to address those.
It avoids the whole rwsem thing; and while it appears to work, please give it some thought in review.
What I did fail at is sensible runtime checks on the use of event->ctx, the RCU use makes it very hard.
--- kernel/events/core.c | 244 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 207 insertions(+), 37 deletions(-)
kernel/events/core.c +207 -37
@@ -903,6 +903,77 @@ static void put_ctx(struct perf_event_co }/* +* Because of perf_event::ctx migration in sys_perf_event_open::move_group and +* perf_pmu_migrate_context() we need some magic. +* +* Those places that change perf_event::ctx will hold both +* perf_event_ctx::mutex of the 'old' and 'new' ctx value. +* +* Lock ordering is by mutex address. There is one other site where +* perf_event_context::mutex nests and that is put_event(). But remember that +* that is a parent<->child context relation, and migration does not affect +* children, therefore these two orderings should not interact. +* +* The change in perf_event::ctx does not affect children (as claimed above) +* because the sys_perf_event_open() case will install a new event and break +* the ctx parent<->child relation, and perf_pmu_migrate_context() is only +* concerned with cpuctx and that doesn't have children. +* +* The places that change perf_event::ctx will issue: +* +* perf_remove_from_context(); +* synchronize_rcu(); +* perf_install_in_context(); +* +* to affect the change. The remove_from_context() + synchronize_rcu() should +* quiesce the event, after which we can install it in the new location. This +* means that only external vectors (perf_fops, prctl) can perturb the event +* while in transit. Therefore all such accessors should also acquire +* perf_event_context::mutex to serialize against this. +* +* However; because event->ctx can change while we're waiting to acquire +* ctx->mutex we must be careful and use the below perf_event_ctx_lock() +* function. +* +* Lock order: +* task_struct::perf_event_mutex +* perf_event_context::mutex +* perf_event_context::lock +* perf_event::child_mutex; +* perf_event::mmap_mutex +* mmap_sem +*/ +static struct perf_event_context *perf_event_ctx_lock (struct perf_event *event) +{ +struct perf_event_context *ctx; + +again: +rcu_read_lock (); + ctx =ACCESS_ONCE (event->ctx); +if (!atomic_inc_not_zero (&ctx->refcount)) { +rcu_read_unlock (); + goto again; + } +rcu_read_unlock (); + +mutex_lock (&ctx->mutex); +if (event->ctx != ctx) { +mutex_unlock (&ctx->mutex); +put_ctx (ctx); + goto again; + } + +return ctx; +} + +static void perf_event_ctx_unlock (struct perf_event *event, +struct perf_event_context *ctx) +{ +mutex_unlock (&ctx->mutex); +put_ctx (ctx); +} + +/* * This must be done under the ctx->lock, such as to serialize against * context_equiv(), therefore we cannot call put_ctx() since that might end up * calling scheduler related locks and ctx->lock nests inside those.
@@ -1606,7 +1677,7 @@ int __perf_event_disable(void *info)* is the current context on this CPU and preemption is disabled, * hence we can't get into perf_event_task_sched_out for this context. */ -void perf_event_disable (struct perf_event *event) +static void _perf_event_disable (struct perf_event *event) {struct perf_event_context *ctx = event->ctx;struct task_struct *task = ctx->task;
@@ -1647,6 +1718,19 @@ retry: }raw_spin_unlock_irq (&ctx->lock); } + +/* +* Strictly speaking kernel users cannot create groups and therefore this +* interface does not need the perf_event_ctx_lock() magic. +*/ +void perf_event_disable (struct perf_event *event) +{ +struct perf_event_context *ctx; + + ctx =perf_event_ctx_lock (event); +_perf_event_disable (event); +perf_event_ctx_unlock (event, ctx); +}EXPORT_SYMBOL_GPL (perf_event_disable); static void perf_set_shadow_time(struct perf_event *event,
@@ -2107,7 +2191,7 @@ unlock:* perf_event_for_each_child or perf_event_for_each as described * for perf_event_disable. */ -void perf_event_enable (struct perf_event *event) +static void _perf_event_enable (struct perf_event *event) {struct perf_event_context *ctx = event->ctx;struct task_struct *task = ctx->task;
@@ -2163,9 +2247,21 @@ retry: out:raw_spin_unlock_irq (&ctx->lock); } + +/* +* See perf_event_disable(); +*/ +void perf_event_enable (struct perf_event *event) +{ +struct perf_event_context *ctx; + + ctx =perf_event_ctx_lock (event); +_perf_event_enable (event); +perf_event_ctx_unlock (event, ctx); +}EXPORT_SYMBOL_GPL (perf_event_enable); -int perf_event_refresh (struct perf_event *event,int refresh) +static int _perf_event_refresh (struct perf_event *event,int refresh) {/* * not supported on inherited events
@@ -2174,10 +2270,25 @@ int perf_event_refresh(struct perf_eventreturn -EINVAL ;atomic_add (refresh, &event->event_limit); -perf_event_enable (event); +_perf_event_enable (event);return 0 ; } + +/* +* See perf_event_disable() +*/ +int perf_event_refresh (struct perf_event *event,int refresh) +{ +struct perf_event_context *ctx; +int ret; + + ctx =perf_event_ctx_lock (event); + ret =_perf_event_refresh (event, refresh); +perf_event_ctx_unlock (event, ctx); + +return ret; +}EXPORT_SYMBOL_GPL (perf_event_refresh); static void ctx_sched_out(struct perf_event_context *ctx,
@@ -3373,7 +3484,16 @@ static void put_event(struct perf_eventrcu_read_unlock ();if (owner) { -mutex_lock (&owner->perf_event_mutex); +/* +* If we're here through perf_event_exit_task() we're already +* holding ctx->mutex which would be an inversion wrt. the +* normal lock order. +* +* However we can safely take this lock because its the child +* ctx->mutex. +*/ +mutex_lock_nested (&owner->perf_event_mutex,SINGLE_DEPTH_NESTING ); +/* * We have to re-check the event->owner field, if it is cleared * we raced with perf_event_exit_task(), acquiring the mutex
@@ -3449,12 +3569,13 @@ static int perf_event_read_group(struct u64 read_format, char __user *buf) { struct perf_event *leader = event->group_leader, *sub; -int n =0 , size =0 , ret = -EFAULT ;struct perf_event_context *ctx = leader->ctx; -u64 values[5 ]; +int n =0 , size =0 , ret;u64 count, enabled, running; +u64 values[5 ]; + +lockdep_assert_held (&ctx->mutex); -mutex_lock (&ctx->mutex); count =perf_event_read_value (leader, &enabled, &running); values[n++] =1 + leader->nr_siblings;
@@ -3469,7 +3590,7 @@ static int perf_event_read_group(struct size = n *sizeof (u64);if (copy_to_user (buf, values, size)) - goto unlock; +return -EFAULT ; ret = size;
@@ -3483,14 +3604,11 @@ static int perf_event_read_group(struct size = n *sizeof (u64);if (copy_to_user (buf + ret, values, size)) { - ret = -EFAULT ; - goto unlock; +return -EFAULT ; } ret += size; } -unlock: -mutex_unlock (&ctx->mutex);return ret; }
@@ -3549,8 +3667,14 @@ static ssize_t perf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct perf_event *event = file->private_data; +struct perf_event_context *ctx; +int ret; -return perf_read_hw (event, buf, count); + ctx =perf_event_ctx_lock (event); + ret =perf_read_hw (event, buf, count); +perf_event_ctx_unlock (event, ctx); + +return ret; }static unsigned int perf_poll (struct file *file,poll_table *wait)
@@ -3574,7 +3698,7 @@ static unsigned int perf_poll(struct filreturn events; } -static void perf_event_reset (struct perf_event *event) +static void _perf_event_reset (struct perf_event *event) { (void )perf_event_read (event);local64_set (&event->count,0 );
@@ -3593,6 +3717,7 @@ static void perf_event_for_each_child(ststruct perf_event *child;WARN_ON_ONCE (event->ctx->parent_ctx); +mutex_lock (&event->child_mutex);func (event);list_for_each_entry (child, &event->child_list, child_list)
@@ -3606,14 +3731,13 @@ static void perf_event_for_each(struct pstruct perf_event_context *ctx = event->ctx;struct perf_event *sibling; -WARN_ON_ONCE (ctx->parent_ctx); -mutex_lock (&ctx->mutex); +lockdep_assert_held (&ctx->mutex); + event = event->group_leader;perf_event_for_each_child (event, func);list_for_each_entry (sibling, &event->sibling_list, group_entry)perf_event_for_each_child (sibling, func); -mutex_unlock (&ctx->mutex); }struct period_event {
@@ -3725,25 +3849,24 @@ static int perf_event_set_output(struct struct perf_event *output_event);static int perf_event_set_filter (struct perf_event *event,void __user *arg); -static long perf_ioctl (struct file *file,unsigned int cmd,unsigned long arg) +static long _perf_ioctl (struct perf_event *event,unsigned int cmd,unsigned long arg) { -struct perf_event *event = file->private_data;void (*func)(struct perf_event *);u32 flags = arg;switch (cmd) {case PERF_EVENT_IOC_ENABLE : - func = perf_event_enable; + func = _perf_event_enable;break ;case PERF_EVENT_IOC_DISABLE : - func = perf_event_disable; + func = _perf_event_disable;break ;case PERF_EVENT_IOC_RESET : - func = perf_event_reset; + func = _perf_event_reset;break ;case PERF_EVENT_IOC_REFRESH : -return perf_event_refresh (event, arg); +return _perf_event_refresh (event, arg);case PERF_EVENT_IOC_PERIOD :return perf_event_period (event, (u64 __user *)arg);
@@ -3790,6 +3913,19 @@ static long perf_ioctl(struct file *filereturn 0 ; } +static long perf_ioctl (struct file *file,unsigned int cmd,unsigned long arg) +{ +struct perf_event *event = file->private_data; +struct perf_event_context *ctx; +long ret; + + ctx =perf_event_ctx_lock (event); + ret =_perf_ioctl (event, cmd, arg); +perf_event_ctx_unlock (event, ctx); + +return ret; +} +#ifdef CONFIG_COMPAT static long perf_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg)
@@ -3812,11 +3948,15 @@ static long perf_compat_ioctl(struct filint perf_event_task_enable (void ) { +struct perf_event_context *ctx;struct perf_event *event;mutex_lock (¤t->perf_event_mutex); -list_for_each_entry (event, ¤t->perf_event_list, owner_entry) -perf_event_for_each_child (event, perf_event_enable); +list_for_each_entry (event, ¤t->perf_event_list, owner_entry) { + ctx =perf_event_ctx_lock (event); +perf_event_for_each_child (event, _perf_event_enable); +perf_event_ctx_unlock (event, ctx); + }mutex_unlock (¤t->perf_event_mutex);return 0 ;
@@ -3824,11 +3964,15 @@ int perf_event_task_enable(void)int perf_event_task_disable (void ) { +struct perf_event_context *ctx;struct perf_event *event;mutex_lock (¤t->perf_event_mutex); -list_for_each_entry (event, ¤t->perf_event_list, owner_entry) -perf_event_for_each_child (event, perf_event_disable); +list_for_each_entry (event, ¤t->perf_event_list, owner_entry) { + ctx =perf_event_ctx_lock (event); +perf_event_for_each_child (event, _perf_event_disable); +perf_event_ctx_unlock (event, ctx); + }mutex_unlock (¤t->perf_event_mutex);return 0 ;
@@ -7158,6 +7302,15 @@ out:return ret; } +static void mutex_lock_double (struct mutex *a,struct mutex *b) +{ +if (b < a) +swap (a, b); + +mutex_lock (a); +mutex_lock_nested (b,SINGLE_DEPTH_NESTING ); +} +/** * sys_perf_event_open - open a performance event, associate it to a task/cpu *
@@ -7173,7 +7326,7 @@ SYSCALL_DEFINE5(perf_event_open,struct perf_event *group_leader =NULL , *output_event =NULL ;struct perf_event *event, *sibling;struct perf_event_attr attr; -struct perf_event_context *ctx; +struct perf_event_context *ctx, *uninitialized_var (gctx );struct file *event_file =NULL ;struct fd group = {NULL ,0 };struct task_struct *task =NULL ;
@@ -7369,9 +7522,14 @@ SYSCALL_DEFINE5(perf_event_open, }if (move_group) { -struct perf_event_context *gctx = group_leader->ctx; + gctx = group_leader->ctx; + +/* +* See perf_event_ctx_lock() for comments on the details +* of swizzling perf_event::ctx. +*/ +mutex_lock_double (&gctx->mutex, &ctx->mutex); -mutex_lock (&gctx->mutex);perf_remove_from_context (group_leader, false);/*
@@ -7386,15 +7544,19 @@ SYSCALL_DEFINE5(perf_event_open,perf_event__state_init (sibling);put_ctx (gctx); } -mutex_unlock (&gctx->mutex); -put_ctx (gctx); + }else { +mutex_lock (&ctx->mutex); }WARN_ON_ONCE (ctx->parent_ctx); -mutex_lock (&ctx->mutex);if (move_group) { +/* +* Wait for everybody to stop referencing the events through +* the old lists, before installing it on new lists. +*/ synchronize_rcu (); +perf_install_in_context (ctx, group_leader, group_leader->cpu);get_ctx (ctx); list_for_each_entry(sibling, &group_leader->sibling_list,
@@ -7406,6 +7568,11 @@ SYSCALL_DEFINE5(perf_event_open,perf_install_in_context (ctx, event, event->cpu);perf_unpin_context (ctx); + +if (move_group) { +mutex_unlock (&gctx->mutex); +put_ctx (gctx); + }mutex_unlock (&ctx->mutex);put_online_cpus ();
@@ -7508,7 +7675,11 @@ void perf_pmu_migrate_context(struct pmu src_ctx = &per_cpu_ptr (pmu->pmu_cpu_context, src_cpu)->ctx; dst_ctx = &per_cpu_ptr (pmu->pmu_cpu_context, dst_cpu)->ctx; -mutex_lock (&src_ctx->mutex); +/* +* See perf_event_ctx_lock() for comments on the details +* of swizzling perf_event::ctx. +*/ +mutex_lock_double (&src_ctx->mutex, &dst_ctx->mutex);list_for_each_entry_safe (event, tmp, &src_ctx->event_list, event_entry) {perf_remove_from_context (event, false);
@@ -7516,11 +7687,9 @@ void perf_pmu_migrate_context(struct pmuput_ctx (src_ctx);list_add (&event->migrate_entry, &events); } -mutex_unlock (&src_ctx->mutex);synchronize_rcu (); -mutex_lock (&dst_ctx->mutex);list_for_each_entry_safe (event, tmp, &events, migrate_entry) {list_del (&event->migrate_entry);if (event->state >=PERF_EVENT_STATE_OFF )
@@ -7530,6 +7699,7 @@ void perf_pmu_migrate_context(struct pmuget_ctx (dst_ctx); }mutex_unlock (&dst_ctx->mutex); +mutex_unlock (&src_ctx->mutex); }EXPORT_SYMBOL_GPL (perf_pmu_migrate_context);
PATCH 290/306 perf: Do not double free
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 130056275ade730e7a79c110212c8815202773ee upstream.
In case of: err_file: fput(event_file), we'll end up calling perf_release() which in turn will free the event.
Do not then free the event _again_.
--- kernel/events/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/events/core.c +6 -1
@@ -7603,7 +7603,12 @@ err_context:perf_unpin_context (ctx);put_ctx (ctx); err_alloc: -free_event (event); +/* +* If event_file is set, the fput() above will have called ->release() +* and that will take care of freeing the event. +*/ +if (!event_file) +free_event (event); err_cpus:put_online_cpus (); err_task:
PATCH 291/306 perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 321027c1fe77f892f4ea07846aeae08cefbbb290 upstream.
Di Shen reported a race between two concurrent sys_perf_event_open() calls where both try and move the same pre-existing software group into a hardware context.
The problem is exactly that described in commit:
f63a8daa5812 ("perf: Fix event->ctx locking")
... where, while we wait for a ctx->mutex acquisition, the event->ctx relation can have changed under us.
That very same commit failed to recognise sys_perf_event_context() as an external access vector to the events and thereby didn't apply the established locking rules correctly.
So while one sys_perf_event_open() call is stuck waiting on mutex_lock_double(), the other (which owns said locks) moves the group about. So by the time the former sys_perf_event_open() acquires the locks, the context we've acquired is stale (and possibly dead).
Apply the established locking rules as per perf_event_ctx_lock_nested() to the mutex_lock_double() for the 'move_group' case. This obviously means we need to validate state after we acquire the locks.
[bwh: Backported to 3.16:
- Use ACCESS_ONCE() instead of READ_ONCE()
- Test perf_event::group_flags instead of group_caps
- Add the err_locked cleanup block, which we didn't need before
- Adjust context]
--- kernel/events/core.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-)
kernel/events/core.c +58 -7
@@ -7311,6 +7311,37 @@ static void mutex_lock_double(struct mutmutex_lock_nested (b,SINGLE_DEPTH_NESTING ); } +/* +* Variation on perf_event_ctx_lock_nested(), except we take two context +* mutexes. +*/ +static struct perf_event_context * +__perf_event_ctx_lock_double (struct perf_event *group_leader, +struct perf_event_context *ctx) +{ +struct perf_event_context *gctx; + +again: +rcu_read_lock (); + gctx =ACCESS_ONCE (group_leader->ctx); +if (!atomic_inc_not_zero (&gctx->refcount)) { +rcu_read_unlock (); + goto again; + } +rcu_read_unlock (); + +mutex_lock_double (&gctx->mutex, &ctx->mutex); + +if (group_leader->ctx != gctx) { +mutex_unlock (&ctx->mutex); +mutex_unlock (&gctx->mutex); +put_ctx (gctx); + goto again; + } + +return gctx; +} +/** * sys_perf_event_open - open a performance event, associate it to a task/cpu *
@@ -7522,14 +7553,31 @@ SYSCALL_DEFINE5(perf_event_open, }if (move_group) { - gctx = group_leader->ctx; + gctx =__perf_event_ctx_lock_double (group_leader, ctx); + +/* +* Check if we raced against another sys_perf_event_open() call +* moving the software group underneath us. +*/ +if (!(group_leader->group_flags &PERF_GROUP_SOFTWARE )) { +/* +* If someone moved the group out from under us, check +* if this new event wound up on the same ctx, if so +* its the regular !move_group case, otherwise fail. +*/ +if (gctx != ctx) { + err = -EINVAL ; + goto err_locked; + }else { +perf_event_ctx_unlock (group_leader, gctx); + move_group =0 ; + } + }/* * See perf_event_ctx_lock() for comments on the details * of swizzling perf_event::ctx. */ -mutex_lock_double (&gctx->mutex, &ctx->mutex); -perf_remove_from_context (group_leader, false);/*
@@ -7569,10 +7617,8 @@ SYSCALL_DEFINE5(perf_event_open,perf_install_in_context (ctx, event, event->cpu);perf_unpin_context (ctx); -if (move_group) { -mutex_unlock (&gctx->mutex); -put_ctx (gctx); - } +if (move_group) +perf_event_ctx_unlock (group_leader, gctx);mutex_unlock (&ctx->mutex);put_online_cpus ();
@@ -7599,6 +7645,11 @@ SYSCALL_DEFINE5(perf_event_open,fd_install (event_fd, event_file);return event_fd; +err_locked: +if (move_group) +perf_event_ctx_unlock (group_leader, gctx); +mutex_unlock (&ctx->mutex); +fput (event_file); err_context:perf_unpin_context (ctx);put_ctx (ctx);
PATCH 292/306 usb: gadget: f_fs: Fix use-after-free
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit 38740a5b87d53ceb89eb2c970150f6e94e00373a upstream.
When using asynchronous read or write operations on the USB endpoints the issuer of the IO request is notified by calling the ki_complete() callback of the submitted kiocb when the URB has been completed.
Calling this ki_complete() callback will free kiocb. Make sure that the structure is no longer accessed beyond that point, otherwise undefined behaviour might occur.
[bwh: Backported to 3.16:
- Adjust filename
- We only use kiocb::private, not kiocb::ki_flags]
---
drivers/usb/gadget/f_fs.c +0 -1
@@ -669,7 +669,6 @@ static void ffs_user_copy_worker(structusb_ep_free_request (io_data->ep, io_data->req); - io_data->kiocb->private =NULL ;if (io_data->read)kfree (io_data->iovec);kfree (io_data->buf);
PATCH 293/306 HID: core: prevent out-of-bound readings
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Tissoires <[email protected]>
commit 50220dead1650609206efe91f0cc116132d59b3f upstream.
Plugging a Logitech DJ receiver with KASAN activated raises a bunch of out-of-bound readings.
The fields are allocated up to MAX_USAGE, meaning that potentially, we do not have enough fields to fit the incoming values.
Add checks and silence KASAN.
--- drivers/hid/hid-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hid/hid-core.c +3 -0
@@ -1208,6 +1208,7 @@ static void hid_input_field(struct hid_d/* Ignore report if ErrorRollOver */ if (!(field->flags &HID_MAIN_ITEM_VARIABLE ) && value[n] >= min && value[n] <= max && + value[n] - min < field->maxusage && field->usage[value[n] - min].hid ==HID_UP_KEYBOARD +1 ) goto exit; }
@@ -1220,11 +1221,13 @@ static void hid_input_field(struct hid_d }if (field->value[n] >= min && field->value[n] <= max + && field->value[n] - min < field->maxusage && field->usage[field->value[n] - min].hid &&search (value, field->value[n], count))hid_process_event (hid, field, &field->usage[field->value[n] - min],0 , interrupt);if (value[n] >= min && value[n] <= max + && value[n] - min < field->maxusage && field->usage[value[n] - min].hid &&search (field->value, value[n], count))hid_process_event (hid, field, &field->usage[value[n] - min],1 , interrupt);
PATCH 294/306 netfilter: nfnetlink: correctly validate length of batch messages
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Phil Turnbull <[email protected]>
commit c58d6c93680f28ac58984af61d0a7ebf4319c241 upstream.
If nlh->nlmsg_len is zero then an infinite loop is triggered because 'skb_pull(skb, msglen);' pulls zero bytes.
The calculation in nlmsg_len() underflows if 'nlh->nlmsg_len < NLMSG_HDRLEN' which bypasses the length validation and will later trigger an out-of-bound read.
If the length validation does fail then the malformed batch message is copied back to userspace. However, we cannot do this because the nlh->nlmsg_len can be invalid. This leads to an out-of-bounds read in netlink_ack:
[ 41.455421] ==================================================================
[ 41.456431] BUG: KASAN: slab-out-of-bounds in memcpy+0x1d/0x40 at addr ffff880119e79340
[ 41.456431] Read of size 4294967280 by task a.out/987
[ 41.456431] =============================================================================
[ 41.456431] BUG kmalloc-512 (Not tainted): kasan: bad access detected
[ 41.456431] -----------------------------------------------------------------------------
...
[ 41.456431] Bytes b4 ffff880119e79310: 00 00 00 00 d5 03 00 00 b0 fb fe ff 00 00 00 00 ................
[ 41.456431] Object ffff880119e79320: 20 00 00 00 10 00 05 00 00 00 00 00 00 00 00 00 ...............
[ 41.456431] Object ffff880119e79330: 14 00 0a 00 01 03 fc 40 45 56 11 22 33 10 00 05 .......@EV."3...
[ 41.456431] Object ffff880119e79340: f0 ff ff ff 88 99 aa bb 00 14 00 0a 00 06 fe fb ................
^^ start of batch nlmsg with
nlmsg_len=4294967280
...
[ 41.456431] Memory state around the buggy address:
[ 41.456431] ffff880119e79400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 41.456431] ffff880119e79480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 41.456431] >ffff880119e79500: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc
[ 41.456431] ^
[ 41.456431] ffff880119e79580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 41.456431] ffff880119e79600: fc fc fc fc fc fc fc fc fc fc fb fb fb fb fb fb
[ 41.456431] ==================================================================Fix this with better validation of nlh->nlmsg_len and by setting NFNL_BATCH_FAILURE if any batch message fails length validation.
CAP_NET_ADMIN is required to trigger the bugs.
[bwh: Backported to 3.16:
- We don't have an error list so don't call nfnl_err_reset()
- Set 'success' variable instead of 'status']
---
net/netfilter/nfnetlink.c +5 -4
@@ -273,10 +273,11 @@ replay: nlh =nlmsg_hdr (skb); err =0 ; -if (nlmsg_len (nlh) <sizeof (struct nfgenmsg ) || - skb->len < nlh->nlmsg_len) { - err = -EINVAL ; - goto ack; +if (nlh->nlmsg_len <NLMSG_HDRLEN || + skb->len < nlh->nlmsg_len || +nlmsg_len (nlh) <sizeof (struct nfgenmsg )) { + success = false; + goto done; }/* Only requests are handled by the kernel */
PATCH 295/306 fbdev: color map copying bounds checking
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 2dc705a9930b4806250fbf5a76e55266e59389f2 upstream.
Copying color maps to userspace doesn't check the value of to->start, which will cause kernel heap buffer OOB read due to signedness wraps.
CVE-2016-8405
--- drivers/video/fbdev/core/fbcmap.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/video/fbdev/core/fbcmap.c +14 -12
@@ -163,17 +163,18 @@ void fb_dealloc_cmap(struct fb_cmap *cmap)int fb_copy_cmap (const struct fb_cmap *from,struct fb_cmap *to) { -int tooff =0 , fromoff =0 ; -int size; +unsigned int tooff =0 , fromoff =0 ; +size_t size;if (to->start > from->start) fromoff = to->start - from->start;else tooff = from->start - to->start; - size = to->len - tooff; -if (size > (int ) (from->len - fromoff)) - size = from->len - fromoff; -if (size <=0 ) +if (fromoff >= from->len || tooff >= to->len) +return -EINVAL ; + + size =min_t (size_t, to->len - tooff, from->len - fromoff); +if (size ==0 )return -EINVAL ; size *=sizeof (u16);
@@ -187,17 +188,18 @@ int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to)int fb_cmap_to_user (const struct fb_cmap *from,struct fb_cmap_user *to) { -int tooff =0 , fromoff =0 ; -int size; +unsigned int tooff =0 , fromoff =0 ; +size_t size;if (to->start > from->start) fromoff = to->start - from->start;else tooff = from->start - to->start; - size = to->len - tooff; -if (size > (int ) (from->len - fromoff)) - size = from->len - fromoff; -if (size <=0 ) +if (fromoff >= from->len || tooff >= to->len) +return -EINVAL ; + + size =min_t (size_t, to->len - tooff, from->len - fromoff); +if (size ==0 )return -EINVAL ; size *=sizeof (u16);
PATCH 296/306 net: Add __sock_queue_rcv_skb()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
Extraxcted from commit e6afc8ace6dd5cef5e812f26c72579da8806f5ac "udp: remove headers from UDP packets before queueing".
---
include/net/sock.h +1 -0
@@ -2026,6 +2026,7 @@ void sk_reset_timer(struct sock *sk, strvoid sk_stop_timer (struct sock *sk,struct timer_list *timer); +int __sock_queue_rcv_skb (struct sock *sk,struct sk_buff *skb);int sock_queue_rcv_skb (struct sock *sk,struct sk_buff *skb);int sock_queue_err_skb (struct sock *sk,struct sk_buff *skb);
net/core/sock.c +13 -6
@@ -432,9 +432,8 @@ static void sock_disable_timestamp(struc } -int sock_queue_rcv_skb (struct sock *sk,struct sk_buff *skb) +int __sock_queue_rcv_skb (struct sock *sk,struct sk_buff *skb) { -int err;int skb_len;unsigned long flags;struct sk_buff_head *list = &sk->sk_receive_queue;
@@ -445,10 +444,6 @@ int sock_queue_rcv_skb(struct sock *sk,return -ENOMEM ; } - err =sk_filter (sk, skb); -if (err) -return err; -if (!sk_rmem_schedule (sk, skb, skb->truesize)) {atomic_inc (&sk->sk_drops);return -ENOBUFS ;
@@ -478,6 +473,18 @@ int sock_queue_rcv_skb(struct sock *sk, sk->sk_data_ready (sk);return 0 ; } +EXPORT_SYMBOL (__sock_queue_rcv_skb); + +int sock_queue_rcv_skb (struct sock *sk,struct sk_buff *skb) +{ +int err; + + err =sk_filter (sk, skb); +if (err) +return err; + +return __sock_queue_rcv_skb (sk, skb); +}EXPORT_SYMBOL (sock_queue_rcv_skb);int sk_receive_skb (struct sock *sk,struct sk_buff *skb,const int nested)
PATCH 297/306 rose: limit sk_filter trim to payload
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
commit f4979fcea7fd36d8e2f556abef86f80e0d5af1ba upstream.
Sockets can have a filter program attached that drops or trims incoming packets based on the filter program return value.
Rose requires data packets to have at least ROSE_MIN_LEN bytes. It verifies this on arrival in rose_route_frame and unconditionally pulls the bytes in rose_recvmsg. The filter can trim packets to below this value in-between, causing pull to fail, leaving the partial header at the time of skb_copy_datagram_msg.
Place a lower bound on the size to which sk_filter may trim packets by introducing sk_filter_trim_cap and call this for rose packets.
--- include/linux/filter.h | 6 +++++- net/core/filter.c | 10 +++++----- net/rose/rose_in.c | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-)
include/linux/filter.h +5 -1
@@ -346,7 +346,11 @@ static inline unsigned int sk_filter_siz#define sk_filter_proglen (fprog) \ (fprog->len * sizeof(fprog->filter[0])) -int sk_filter (struct sock *sk,struct sk_buff *skb); +int sk_filter_trim_cap (struct sock *sk,struct sk_buff *skb,unsigned int cap); +static inline int sk_filter (struct sock *sk,struct sk_buff *skb) +{ +return sk_filter_trim_cap (sk, skb,1 ); +}void sk_filter_select_runtime (struct sk_filter *fp);void sk_filter_free (struct sk_filter *fp);
net/core/filter.c +5 -5
@@ -94,9 +94,10 @@ static inline void *load_pointer(const s }/** -* sk_filter - run a packet through a socket filter +* sk_filter_trim_cap - run a packet through a socket filter * @sk: sock associated with &sk_buff * @skb: buffer to filter +* @cap: limit on how short the eBPF program may trim the packet * * Run the filter code and then cut skb->data to correct size returned by * sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller
@@ -105,7 +106,7 @@ static inline void *load_pointer(const s* be accepted or -EPERM if the packet should be tossed. * */ -int sk_filter (struct sock *sk,struct sk_buff *skb) +int sk_filter_trim_cap (struct sock *sk,struct sk_buff *skb,unsigned int cap) {int err;struct sk_filter *filter;
@@ -126,14 +127,13 @@ int sk_filter(struct sock *sk, struct sk filter =rcu_dereference (sk->sk_filter);if (filter) {unsigned int pkt_len =SK_RUN_FILTER (filter, skb); - - err = pkt_len ?pskb_trim (skb, pkt_len) : -EPERM ; + err = pkt_len ?pskb_trim (skb,max (cap, pkt_len)) : -EPERM ; }rcu_read_unlock ();return err; } -EXPORT_SYMBOL (sk_filter); +EXPORT_SYMBOL (sk_filter_trim_cap);/* Base function for offset calculation. Needs to go into .text section, * therefore keeping it non-static as well; will also be used by JITs
net/rose/rose_in.c +2 -1
@@ -164,7 +164,8 @@ static int rose_state3_machine(struct sorose_frames_acked (sk, nr);if (ns == rose->vr) {rose_start_idletimer (sk); -if (sock_queue_rcv_skb (sk, skb) ==0 ) { +if (sk_filter_trim_cap (sk, skb,ROSE_MIN_LEN ) ==0 && +__sock_queue_rcv_skb (sk, skb) ==0 ) { rose->vr = (rose->vr +1 ) %ROSE_MODULUS ; queued =1 ; }else {
PATCH 298/306 dccp: limit sk_filter trim to payload
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
commit 4f0c40d94461cfd23893a17335b2ab78ecb333c8 upstream.
Dccp verifies packet integrity, including length, at initial rcv in dccp_invalid_packet, later pulls headers in dccp_enqueue_skb.
A call to sk_filter in-between can cause __skb_pull to wrap skb->len. skb_copy_datagram_msg interprets this as a negative value, so (correctly) fails with EFAULT. The negative length is reported in ioctl SIOCINQ or possibly in a DCCP_WARN in dccp_close.
Introduce an sk_receive_skb variant that caps how small a filter program can trim packets, and call this in dccp with the header length. Excessively trimmed packets are now processed normally and queued for reception as 0B payloads.
--- include/net/sock.h | 8 +++++++- net/core/sock.c | 7 ++++--- net/dccp/ipv4.c | 2 +- net/dccp/ipv6.c | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-)
include/net/sock.h +7 -1
@@ -1669,7 +1669,13 @@ static inline void sock_put(struct sock*/ void sock_gen_put (struct sock *sk); -int sk_receive_skb (struct sock *sk,struct sk_buff *skb,const int nested); +int __sk_receive_skb (struct sock *sk,struct sk_buff *skb,const int nested, +unsigned int trim_cap); +static inline int sk_receive_skb (struct sock *sk,struct sk_buff *skb, +const int nested) +{ +return __sk_receive_skb (sk, skb, nested,1 ); +}static inline void sk_tx_queue_set (struct sock *sk,int tx_queue) {
net/core/sock.c +4 -3
@@ -487,11 +487,12 @@ int sock_queue_rcv_skb(struct sock *sk, }EXPORT_SYMBOL (sock_queue_rcv_skb); -int sk_receive_skb (struct sock *sk,struct sk_buff *skb,const int nested) +int __sk_receive_skb (struct sock *sk,struct sk_buff *skb, +const int nested,unsigned int trim_cap) {int rc =NET_RX_SUCCESS ; -if (sk_filter (sk, skb)) +if (sk_filter_trim_cap (sk, skb, trim_cap)) goto discard_and_relse; skb->dev =NULL ;
@@ -527,7 +528,7 @@ discard_and_relse:kfree_skb (skb); goto out; } -EXPORT_SYMBOL (sk_receive_skb); +EXPORT_SYMBOL (__sk_receive_skb);struct dst_entry *__sk_dst_check (struct sock *sk,u32 cookie) {
net/dccp/ipv4.c +1 -1
@@ -890,7 +890,7 @@ static int dccp_v4_rcv(struct sk_buff *s goto discard_and_relse;nf_reset (skb); -return sk_receive_skb (sk, skb,1 ); +return __sk_receive_skb (sk, skb,1 , dh->dccph_doff *4 ); no_dccp_socket:if (!xfrm4_policy_check (NULL ,XFRM_POLICY_IN , skb))
net/dccp/ipv6.c +1 -1
@@ -804,7 +804,7 @@ static int dccp_v6_rcv(struct sk_buff *sif (!xfrm6_policy_check (sk,XFRM_POLICY_IN , skb)) goto discard_and_relse; -return sk_receive_skb (sk, skb,1 ) ?-1 :0 ; +return __sk_receive_skb (sk, skb,1 , dh->dccph_doff *4 ) ?-1 :0 ; no_dccp_socket:if (!xfrm6_policy_check (NULL ,XFRM_POLICY_IN , skb))
PATCH 299/306 tcp: take care of truncations done by sk_filter()
In reply to Ben Hutchings3.16.40-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit ac6e780070e30e4c35bd395acfe9191e6268bdd3 upstream.
With syzkaller help, Marco Grassi found a bug in TCP stack, crashing in tcp_collapse()
Root cause is that sk_filter() can truncate the incoming skb, but TCP stack was not really expecting this to happen. It probably was expecting a simple DROP or ACCEPT behavior.
We first need to make sure no part of TCP header could be removed. Then we need to adjust TCP_SKB_CB(skb)->end_seq
Many thanks to syzkaller team and Marco for giving us a reproducer.
--- include/net/tcp.h | 1 + net/ipv4/tcp_ipv4.c | 19 ++++++++++++++++++- net/ipv6/tcp_ipv6.c | 6 ++++-- 3 files changed, 23 insertions(+), 3 deletions(-)
include/net/tcp.h +1 -0
@@ -1053,6 +1053,7 @@ static inline void tcp_prequeue_init(str }bool tcp_prequeue (struct sock *sk,struct sk_buff *skb); +int tcp_filter (struct sock *sk,struct sk_buff *skb);#undef STATE_TRACE
net/ipv4/tcp_ipv4.c +18 -1
@@ -1697,6 +1697,21 @@ bool tcp_prequeue(struct sock *sk, struc }EXPORT_SYMBOL (tcp_prequeue); +int tcp_filter (struct sock *sk,struct sk_buff *skb) +{ +struct tcphdr *th = (struct tcphdr *)skb->data; +unsigned int eaten = skb->len; +int err; + + err =sk_filter_trim_cap (sk, skb, th->doff *4 ); +if (!err) { + eaten -= skb->len; +TCP_SKB_CB (skb)->end_seq -= eaten; + } +return err; +} +EXPORT_SYMBOL (tcp_filter); +/* * From tcp_input.c */
@@ -1760,8 +1775,10 @@ process: goto discard_and_relse;nf_reset (skb); -if (sk_filter (sk, skb)) +if (tcp_filter (sk, skb)) goto discard_and_relse; + th = (const struct tcphdr *)skb->data; + iph =ip_hdr (skb);sk_mark_napi_id (sk, skb); skb->dev =NULL ;
net/ipv6/tcp_ipv6.c +4 -2
@@ -1359,7 +1359,7 @@ static int tcp_v6_do_rcv(struct sock *sk goto discard;#endif -if (sk_filter (sk, skb)) +if (tcp_filter (sk, skb)) goto discard;/*
@@ -1531,8 +1531,10 @@ process:if (!xfrm6_policy_check (sk,XFRM_POLICY_IN , skb)) goto discard_and_relse; -if (sk_filter (sk, skb)) +if (tcp_filter (sk, skb)) goto discard_and_relse; + th = (const struct tcphdr *)skb->data; + hdr =ipv6_hdr (skb);sk_mark_napi_id (sk, skb); skb->dev =NULL ;