3.16.39-rc1 review
Subsystems (11)
PATCH 157/346 drm/edid: Add 6 bpc quirk for display AEO model 0.
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mario Kleiner <[email protected]>
commit e10aec652f31ec61d6a0b4d00d8ef8d2b66fa0fd upstream.
Bugzilla https://bugzilla.kernel.org/show_bug.cgi?id=105331
reports that the "AEO model 0" display is driven with 8 bpc without dithering by default, which looks bad because that panel is apparently a 6 bpc DP panel with faulty EDID.
A fix for this was made by commit 013dd9e03872 ("drm/i915/dp: fall back to 18 bpp when sink capability is unknown").
That commit triggers new regressions in precision for DP->DVI and DP->VGA displays. A patch is out to revert that commit, but it will revert video output for the AEO model 0 panel to 8 bpc without dithering.
The EDID 1.3 of that panel, as decoded from the xrandr output attached to that bugzilla bug report, is somewhat faulty, and beyond other problems also sets the "DFP 1.x compliant TMDS" bit, which according to DFP spec means to drive the panel with 8 bpc and no dithering in absence of other colorimetry information.
Try to make the original bug reporter happy despite the faulty EDID by adding a quirk to mark that panel as 6 bpc, so 6 bpc output with dithering creates a nice picture.
Tested by injecting the edid from the fdo bug into a DP connector via drm_kms_helper.edid_firmware and verifying the 6 bpc + dithering is selected.
This patch should be backported to stable.
--- drivers/gpu/drm/drm_edid.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/drm_edid.c +8 -0
@@ -72,6 +72,8 @@#define EDID_QUIRK_FORCE_8BPC (1 << 8)/* Force 12bpc */ #define EDID_QUIRK_FORCE_12BPC (1 << 9) +/* Force 6bpc */ +#define EDID_QUIRK_FORCE_6BPC (1 << 10)struct detailed_mode_closure {struct drm_connector *connector;
@@ -98,6 +100,9 @@ static struct edid_quirk {/* Unknown Acer */ { "ACR", 2423, EDID_QUIRK_FIRST_DETAILED_PREFERRED }, +/* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ + { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, +/* Belinea 10 15 55 */ { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 },
@@ -3667,6 +3672,9 @@ int drm_add_edid_modes(struct drm_connecdrm_add_display_info (edid, &connector->display_info, connector); +if (quirks &EDID_QUIRK_FORCE_6BPC ) + connector->display_info.bpc =6 ; +if (quirks &EDID_QUIRK_FORCE_8BPC ) connector->display_info.bpc =8 ;
PATCH 158/346 drm/i915/dp: Revert "drm/i915/dp: fall back to 18 bpp when sink capability is unknown"
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mario Kleiner <[email protected]>
commit 196f954e250943df414efd3d632254c29be38e59 upstream.
This reverts commit 013dd9e03872
("drm/i915/dp: fall back to 18 bpp when sink capability is unknown")
This commit introduced a regression into stable kernels, as it reduces output color depth to 6 bpc for any video sink connected to a Displayport connector if that sink doesn't report a specific color depth via EDID, or if our EDID parser doesn't actually recognize the proper bpc from EDID.
Affected are active DisplayPort->VGA converters and active DisplayPort->DVI converters. Both should be able to handle 8 bpc, but are degraded to 6 bpc with this patch.
The reverted commit was meant to fix
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=105331
A followup patch implements a fix for that specific bug, which is caused by a faulty EDID of the affected DP panel by adding a new EDID quirk for that panel.
DP 18 bpp fallback handling and other improvements to DP sink bpc detection will be handled for future kernels in a separate series of patches.
Please backport to stable.
--- drivers/gpu/drm/i915/intel_display.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/intel_display.c +5 -15
@@ -9475,21 +9475,11 @@ connected_sink_compute_bpp(struct intel_ pipe_config->pipe_bpp = connector->base.display_info.bpc*3 ; } -/* Clamp bpp to default limit on screens without EDID 1.4 */ -if (connector->base.display_info.bpc ==0 ) { -int type = connector->base.connector_type; -int clamp_bpp =24 ; - -/* Fall back to 18 bpp when DP sink capability is unknown. */ -if (type == DRM_MODE_CONNECTOR_DisplayPort || - type == DRM_MODE_CONNECTOR_eDP) - clamp_bpp =18 ; - -if (bpp > clamp_bpp) { -DRM_DEBUG_KMS ("clamping display bpp (was %d) to default limit of %d\n" , - bpp, clamp_bpp); - pipe_config->pipe_bpp = clamp_bpp; - } +/* Clamp bpp to 8 on screens without EDID 1.4 */ +if (connector->base.display_info.bpc ==0 && bpp >24 ) { +DRM_DEBUG_KMS ("clamping display bpp (was %d) to default limit of 24\n" , + bpp); + pipe_config->pipe_bpp =24 ; } }
PATCH 159/346 aacraid: Check size values after double-fetch from user
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dave Carroll <[email protected]>
commit fa00c437eef8dc2e7b25f8cd868cfa405fcc2bb3 upstream.
In aacraid's ioctl_send_fib() we do two fetches from userspace, one the get the fib header's size and one for the fib itself. Later we use the size field from the second fetch to further process the fib. If for some reason the size from the second fetch is different than from the first fix, we may encounter an out-of- bounds access in aac_fib_send(). We also check the sender size to insure it is not out of bounds. This was reported in https://bugzilla.kernel.org/show_bug.cgi?id=116751 and was assigned CVE-2016-6480.
--- drivers/scsi/aacraid/commctrl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/scsi/aacraid/commctrl.c +11 -2
@@ -63,7 +63,7 @@ static int ioctl_send_fib(struct aac_devstruct fib *fibptr;struct hw_fib * hw_fib = (struct hw_fib *)0 ;dma_addr_t hw_fib_pa = (dma_addr_t )0LL ; -unsigned size; +unsigned int size, osize;int retval;if (dev->in_reset) {
@@ -87,7 +87,8 @@ static int ioctl_send_fib(struct aac_dev* will not overrun the buffer when we copy the memory. Return * an error if we would. */ - size =le16_to_cpu (kfib->header.Size) +sizeof (struct aac_fibhdr ); + osize = size =le16_to_cpu (kfib->header.Size) + +sizeof (struct aac_fibhdr );if (size <le16_to_cpu (kfib->header.SenderSize)) size =le16_to_cpu (kfib->header.SenderSize);if (size > dev->max_fib_size) {
@@ -118,6 +119,14 @@ static int ioctl_send_fib(struct aac_dev goto cleanup; } +/* Sanity check the second copy */ +if ((osize !=le16_to_cpu (kfib->header.Size) + +sizeof (struct aac_fibhdr )) + || (size <le16_to_cpu (kfib->header.SenderSize))) { + retval = -EINVAL ; + goto cleanup; + } +if (kfib->header.Command ==cpu_to_le16 (TakeABreakPt)) {aac_adapter_interrupt (dev);/*
PATCH 160/346 powerpc/powernv: Fix MCE handler to avoid trashing CR0/CR1 registers.
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mahesh Salgaonkar <[email protected]>
commit bc14c49195e49b3231c01e4c44e3e5456c940b94 upstream.
The current implementation of MCE early handling modifies CR0/1 registers without saving its old values. Fix this by moving early check for powersaving mode to machine_check_handle_early().
The power architecture 2.06 or later allows the possibility of getting machine check while in nap/sleep/winkle. The last bit of HSPRG0 is set to 1, if thread is woken up from winkle. Hence, clear the last bit of HSPRG0 (r13) before MCE handler starts using it as paca pointer.
Also, the current code always puts the thread into nap state irrespective of whatever idle state it woke up from. Fix that by looking at paca->thread_idle_state and put the thread back into same state where it came from.
--- arch/powerpc/kernel/exceptions-64s.S | 69 +++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 29 deletions(-)
arch/powerpc/kernel/exceptions-64s.S +13 -28
@@ -153,29 +153,14 @@ machine_check_pSeries_1: */ HMT_MEDIUM_PPR_DISCARD SET_SCRATCH0(r13) /* save r13 */ -#ifdef CONFIG_PPC_P7_NAP -BEGIN_FTR_SECTION - /* Running native on arch 2.06 or later, check if we are - * waking up from nap. We only handle no state loss and - * supervisor state loss. We do -not- handle hypervisor - * state loss at this time. - */ - mfspr r13,SPRN_SRR1 - rlwinm. r13,r13,47-31,30,31 - OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) - beq 9f - - mfspr r13,SPRN_SRR1 - rlwinm. r13,r13,47-31,30,31 - /* waking up from powersave (nap) state */ - cmpwi cr1,r13,2 - /* Total loss of HV state is fatal. let's just stay stuck here */ - OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) - bgt cr1,. -9: - OPT_SET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR) -END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) -#endif /* CONFIG_PPC_P7_NAP */ + /* + * Running native on arch 2.06 or later, we may wakeup from winkle + * inside machine check. If yes, then last bit of HSPGR0 would be set + * to 1. Hence clear it unconditionally. + */ + GET_PACA(r13) + clrrdi r13,r13,1 + SET_PACA(r13) EXCEPTION_PROLOG_0(PACA_EXMC) BEGIN_FTR_SECTION b machine_check_pSeries_early
@@ -1418,17 +1403,17 @@ machine_check_handle_early: * Check if thread was in power saving mode. We come here when any * of the following is true: * a. thread wasn't in power saving mode - * b. thread was in power saving mode with no state loss or - * supervisor state loss + * b. thread was in power saving mode with no state loss, + * supervisor state loss or hypervisor state loss. * - * Go back to nap again if (b) is true. + * Go back to nap/sleep/winkle mode again if (b) is true. */ rlwinm. r11,r12,47-31,30,31 /* Was it in power saving mode? */ beq 4f /* No, it wasn;t */ /* Thread was in power saving mode. Go back to nap again. */ cmpwi r11,2 - bne 3f - /* Supervisor state loss */ + blt 3f + /* Supervisor/Hypervisor state loss */ li r0,1 stb r0,PACA_NAPSTATELOST(r13) 3: bl machine_check_queue_event
PATCH 161/346 netfilter: nf_ct_expect: remove the redundant slash when policy name is empty
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Liping Zhang <[email protected]>
commit b173a28f62cf929324a8a6adcc45adadce311d16 upstream.
The 'name' filed in struct nf_conntrack_expect_policy{} is not a pointer, so check it is NULL or not will always return true. Even if the name is empty, slash will always be displayed like follows:
# cat /proc/net/nf_conntrack_expect
297 l3proto = 2 proto=6 src=1.1.1.1 dst=2.2.2.2 sport=1 dport=1025 ftp/
^--- net/netfilter/nf_conntrack_expect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_expect.c +1 -1
@@ -556,7 +556,7 @@ static int exp_seq_show(struct seq_file helper =rcu_dereference (nfct_help (expect->master)->helper);if (helper) {seq_printf (s,"%s%s" , expect->flags ?" " :"" , helper->name); -if (helper->expect_policy[expect->class].name) +if (helper->expect_policy[expect->class].name[0 ])seq_printf (s,"/%s" , helper->expect_policy[expect->class].name); }
PATCH 162/346 netfilter: nfnetlink_queue: reject verdict request from different portid
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Liping Zhang <[email protected]>
commit 00a3101f561816e58de054a470484996f78eb5eb upstream.
Like NFQNL_MSG_VERDICT_BATCH do, we should also reject the verdict request when the portid is not same with the initial portid(maybe from another process).
--- net/netfilter/nfnetlink_queue_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/netfilter/nfnetlink_queue_core.c +2 -4
@@ -985,10 +985,8 @@ nfqnl_recv_verdict(struct sock *ctnl, ststruct net *net =sock_net (ctnl);struct nfnl_queue_net *q =nfnl_queue_pernet (net); - queue =instance_lookup (q, queue_num); -if (!queue) - queue =verdict_instance_lookup (q, queue_num, -NETLINK_CB (skb).portid); + queue =verdict_instance_lookup (q, queue_num, +NETLINK_CB (skb).portid);if (IS_ERR (queue))return PTR_ERR (queue);
PATCH 163/346 powerpc/book3s: Fix MCE console messages for unrecoverable MCE.
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mahesh Salgaonkar <[email protected]>
commit c74dd88e77d3ecbc9e55c78796d82c9aa21cabad upstream.
When machine check occurs with MSR(RI=0), it means MC interrupt is unrecoverable and kernel goes down to panic path. But the console message still shows it as recovered. This patch fixes the MCE console messages.
--- arch/powerpc/kernel/mce.c | 3 ++- arch/powerpc/platforms/powernv/opal.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kernel/mce.c +2 -1
@@ -92,7 +92,8 @@ void save_mce_event(struct pt_regs *regs mce->in_use =1 ; mce->initiator =MCE_INITIATOR_CPU ; -if (handled) +/* Mark it recovered if we have handled it and MSR(RI=1). */ +if (handled && (regs->msr &MSR_RI )) mce->disposition =MCE_DISPOSITION_RECOVERED ;else mce->disposition =MCE_DISPOSITION_NOT_RECOVERED ;
arch/powerpc/platforms/powernv/opal.c +1 -0
@@ -459,6 +459,7 @@ static int opal_recover_mce(struct pt_reif (!(regs->msr &MSR_RI )) {/* If MSR_RI isn't set, we cannot recover */ +pr_err ("Machine check interrupt unrecoverable: MSR(RI=0)\n" ); recovered =0 ; }else if (evt->disposition ==MCE_DISPOSITION_RECOVERED ) {/* Platform corrected itself */
PATCH 164/346 crypto: caam - fix non-hmac hashes
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
commit a0118c8b2be9297aed8e915c60b4013326b256d4 upstream.
Since 6de62f15b581 ("crypto: algif_hash - Require setkey before accept(2)"), the AF_ALG interface requires userspace to provide a key to any algorithm that has a setkey method. However, the non-HMAC algorithms are not keyed, so setting a key is unnecessary.
Fix this by removing the setkey method from the non-keyed hash algorithms.
--- drivers/crypto/caam/caamhash.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/caam/caamhash.c +1 -0
@@ -1778,6 +1778,7 @@ caam_hash_alloc(struct caam_hash_templat template->name);snprintf (alg->cra_driver_name,CRYPTO_MAX_ALG_NAME ,"%s" , template->driver_name); + t_alg->ahash_alg.setkey =NULL ; } alg->cra_module =THIS_MODULE ; alg->cra_init = caam_hash_cra_init;
PATCH 165/346 USB: validate wMaxPacketValue entries in endpoint descriptors
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit aed9d65ac3278d4febd8665bd7db59ef53e825fe upstream.
Erroneous or malicious endpoint descriptors may have non-zero bits in reserved positions, or out-of-bounds values. This patch helps prevent these from causing problems by bounds-checking the wMaxPacketValue entries in endpoint descriptors and capping the values at the maximum allowed.
This issue was first discovered and tests were conducted by Jake Lamberson <[email protected]>, an intern working for Rosie Hall.
--- drivers/usb/core/config.c | 66 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 3 deletions(-)
drivers/usb/core/config.c +62 -3
@@ -142,6 +142,31 @@ static void usb_parse_ss_endpoint_compan } } +static const unsigned short low_speed_maxpacket_maxes[4 ] = { + [USB_ENDPOINT_XFER_CONTROL ] =8 , + [USB_ENDPOINT_XFER_ISOC ] =0 , + [USB_ENDPOINT_XFER_BULK ] =0 , + [USB_ENDPOINT_XFER_INT ] =8 , +}; +static const unsigned short full_speed_maxpacket_maxes[4 ] = { + [USB_ENDPOINT_XFER_CONTROL ] =64 , + [USB_ENDPOINT_XFER_ISOC ] =1023 , + [USB_ENDPOINT_XFER_BULK ] =64 , + [USB_ENDPOINT_XFER_INT ] =64 , +}; +static const unsigned short high_speed_maxpacket_maxes[4 ] = { + [USB_ENDPOINT_XFER_CONTROL ] =64 , + [USB_ENDPOINT_XFER_ISOC ] =1024 , + [USB_ENDPOINT_XFER_BULK ] =512 , + [USB_ENDPOINT_XFER_INT ] =1023 , +}; +static const unsigned short super_speed_maxpacket_maxes[4 ] = { + [USB_ENDPOINT_XFER_CONTROL ] =512 , + [USB_ENDPOINT_XFER_ISOC ] =1024 , + [USB_ENDPOINT_XFER_BULK ] =1024 , + [USB_ENDPOINT_XFER_INT ] =1024 , +}; +static int usb_parse_endpoint (struct device *ddev,int cfgno,int inum,int asnum,struct usb_host_interface *ifp,int num_ep,unsigned char *buffer,int size)
@@ -150,6 +175,8 @@ static int usb_parse_endpoint(struct devstruct usb_endpoint_descriptor *d;struct usb_host_endpoint *endpoint;int n, i, j, retval; +unsigned int maxp; +const unsigned short *maxpacket_maxes; d = (struct usb_endpoint_descriptor *) buffer; buffer += d->bLength;
@@ -256,6 +283,41 @@ static int usb_parse_endpoint(struct dev endpoint->desc.wMaxPacketSize =cpu_to_le16 (8 ); } +/* Validate the wMaxPacketSize field */ + maxp =usb_endpoint_maxp (&endpoint->desc); + +/* Find the highest legal maxpacket size for this endpoint */ + i =0 ;/* additional transactions per microframe */ +switch (to_usb_device (ddev)->speed) { +case USB_SPEED_LOW : + maxpacket_maxes = low_speed_maxpacket_maxes; +break ; +case USB_SPEED_FULL : + maxpacket_maxes = full_speed_maxpacket_maxes; +break ; +case USB_SPEED_HIGH : +/* Bits 12..11 are allowed only for HS periodic endpoints */ +if (usb_endpoint_xfer_int (d) ||usb_endpoint_xfer_isoc (d)) { + i = maxp & (BIT (12 ) |BIT (11 )); + maxp &= ~i; + } +/* fallthrough */ +default : + maxpacket_maxes = high_speed_maxpacket_maxes; +break ; +case USB_SPEED_SUPER : + maxpacket_maxes = super_speed_maxpacket_maxes; +break ; + } + j = maxpacket_maxes[usb_endpoint_type (&endpoint->desc)]; + +if (maxp > j) { +dev_warn (ddev,"config %d interface %d altsetting %d endpoint 0x%X has invalid maxpacket %d, setting to %d\n" , + cfgno, inum, asnum, d->bEndpointAddress, maxp, j); + maxp = j; + endpoint->desc.wMaxPacketSize =cpu_to_le16 (i | maxp); + } +/* * Some buggy high speed devices have bulk endpoints using * maxpacket sizes other than 512. High speed HCDs may not
@@ -263,9 +325,6 @@ static int usb_parse_endpoint(struct dev*/ if (to_usb_device (ddev)->speed ==USB_SPEED_HIGH &&usb_endpoint_xfer_bulk (d)) { -unsigned maxp; - - maxp =usb_endpoint_maxp (&endpoint->desc) &0x07ff ;if (maxp !=512 ) dev_warn(ddev, "config %d interface %d altsetting %d " "bulk endpoint 0x%X has invalid maxpacket %d\n",
PATCH 166/346 cpuset: make sure new tasks conform to the current config of the cpuset
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Zefan Li <[email protected]>
commit 06f4e94898918bcad00cdd4d349313a439d6911e upstream.
A new task inherits cpus_allowed and mems_allowed masks from its parent, but if someone changes cpuset's config by writing to cpuset.cpus/cpuset.mems before this new task is inserted into the cgroup's task list, the new task won't be updated accordingly.
--- kernel/cpuset.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
kernel/cpuset.c +15 -0
@@ -1963,6 +1963,20 @@ static void cpuset_css_free(struct cgroukfree (cs); } +/* +* Make sure the new task conform to the current state of its parent, +* which could have been changed by cpuset just after it inherits the +* state from the parent and before it sits on the cgroup's task list. +*/ +void cpuset_fork (struct task_struct *task) +{ +if (task_css_is_root (task, cpuset_cgrp_id)) +return ; + +set_cpus_allowed_ptr (task, ¤t->cpus_allowed); + task->mems_allowed = current->mems_allowed; +} +struct cgroup_subsys cpuset_cgrp_subsys = { .css_alloc = cpuset_css_alloc, .css_online = cpuset_css_online,
@@ -1971,6 +1985,7 @@ struct cgroup_subsys cpuset_cgrp_subsys .can_attach = cpuset_can_attach, .cancel_attach = cpuset_cancel_attach, .attach = cpuset_attach, + .fork = cpuset_fork, .base_cftypes = files, .early_init = 1, };
PATCH 167/346 s390/dasd: fix hanging device after clear subchannel
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <[email protected]>
commit 9ba333dc55cbb9523553df973adb3024d223e905 upstream.
When a device is in a status where CIO has killed all I/O by itself the interrupt for a clear request may not contain an irb to determine the clear function. Instead it contains an error pointer -EIO. This was ignored by the DASD int_handler leading to a hanging device waiting for a clear interrupt.
Handle -EIO error pointer correctly for requests that are clear pending and treat the clear as successful.
--- drivers/s390/block/dasd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/s390/block/dasd.c +9 -1
@@ -1613,9 +1613,18 @@ void dasd_int_handler(struct ccw_deviceunsigned long long now;int expires; + cqr = (struct dasd_ccw_req *) intparm;if (IS_ERR (irb)) {switch (PTR_ERR (irb)) {case -EIO : +if (cqr && cqr->status ==DASD_CQR_CLEAR_PENDING ) { + device = (struct dasd_device *) cqr->startdev; + cqr->status =DASD_CQR_CLEARED ; +dasd_device_clear_timer (device); +wake_up (&dasd_flush_wq); +dasd_schedule_device_bh (device); +return ; + }break ;case -ETIMEDOUT : DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: "
@@ -1631,7 +1640,6 @@ void dasd_int_handler(struct ccw_device } now =get_tod_clock (); - cqr = (struct dasd_ccw_req *) intparm;/* check for conditions that should be handled immediately */ if (!cqr || !(scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
PATCH 168/346 usb: dwc3: gadget: increment request->actual once
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit c7de573471832dff7d31f0c13b0f143d6f017799 upstream.
When using SG lists, we would end up settingrequest->actual to:
num_mapped_sgs * (request->length - count)
Let's fix that up by incrementing request->actual
only once.
--- drivers/usb/dwc3/gadget.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/usb/dwc3/gadget.c +11 -8
@@ -1943,14 +1943,6 @@ static int __dwc3_cleanup_done_trbs(stru s_pkt =1 ; } -/* -* We assume here we will always receive the entire data block -* which we should receive. Meaning, if we program RX to -* receive 4K but we receive only 2K, we assume that's all we -* should receive and we simply bounce the request back to the -* gadget driver for further processing. -*/ - req->request.actual += req->request.length - count;if (s_pkt)return 1 ; if ((event->status & DEPEVT_STATUS_LST) &&
@@ -1970,6 +1962,7 @@ static int dwc3_cleanup_done_reqs(structstruct dwc3_trb *trb;unsigned int slot;unsigned int i; +int count =0 ;int ret; do {
@@ -1986,6 +1979,8 @@ static int dwc3_cleanup_done_reqs(struct slot++; slot %=DWC3_TRB_NUM ; trb = &dep->trb_pool[slot]; + count += trb->size &DWC3_TRB_SIZE_MASK ; + ret =__dwc3_cleanup_done_trbs (dwc, dep, req, trb, event, status);
@@ -1993,6 +1988,14 @@ static int dwc3_cleanup_done_reqs(structbreak ; }while (++i < req->request.num_mapped_sgs); +/* +* We assume here we will always receive the entire data block +* which we should receive. Meaning, if we program RX to +* receive 4K but we receive only 2K, we assume that's all we +* should receive and we simply bounce the request back to the +* gadget driver for further processing. +*/ + req->request.actual += req->request.length - count;dwc3_gadget_giveback (dep, req, status);if (ret)
PATCH 169/346 x86/mm: Disable preemption during CR3 read+write
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 5cf0791da5c162ebc14b01eb01631cfa7ed4fa6e upstream.
There's a subtle preemption race on UP kernels:
Usually current->mm (and therefore mm->pgd) stays the same during the lifetime of a task so it does not matter if a task gets preempted during the read and write of the CR3.
But then, there is this scenario on x86-UP:
TaskA is in do_exit() and exit_mm() sets current->mm = NULL followed by:
-> mmput()
-> exit_mmap()
-> tlb_finish_mmu()
-> tlb_flush_mmu()
-> tlb_flush_mmu_tlbonly()
-> tlb_flush()
-> flush_tlb_mm_range()
-> __flush_tlb_up()
-> __flush_tlb()
-> __native_flush_tlb()
At this point current->mm is NULL but current->active_mm still points to the "old" mm.
Let's preempt taskA _after_ native_read_cr3() by taskB. TaskB has its own mm so CR3 has changed.
Now preempt back to taskA. TaskA has no ->mm set so it borrows taskB's mm and so CR3 remains unchanged. Once taskA gets active it continues where it was interrupted and that means it writes its old CR3 value back. Everything is fine because userland won't need its memory anymore.
Now the fun part:
Let's preempt taskA one more time and get back to taskB. This time switch_mm() won't do a thing because oldmm (->active_mm) is the same as mm (as per context_switch()). So we remain with a bad CR3 / PGD and return to userland.
The next thing that happens is handle_mm_fault() with an address for the execution of its code in userland. handle_mm_fault() realizes that it has a PTE with proper rights so it returns doing nothing. But the CPU looks at the wrong PGD and insists that something is wrong and faults again. And again. And one more time…
This pagefault circle continues until the scheduler gets tired of it and puts another task on the CPU. It gets little difficult if the task is a RT task with a high priority. The system will either freeze or it gets fixed by the software watchdog thread which usually runs at RT-max prio. But waiting for the watchdog will increase the latency of the RT task which is no good.
Fix this by disabling preemption across the critical code section.
--- arch/x86/include/asm/tlbflush.h | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/include/asm/tlbflush.h +7 -0
@@ -17,7 +17,14 @@static inline void __native_flush_tlb (void ) { +/* +* If current->mm == NULL then we borrow a mm which may change during a +* task switch and therefore we must not be preempted while we write CR3 +* back: +*/ +preempt_disable ();native_write_cr3 (native_read_cr3 ()); +preempt_enable (); }static inline void __native_flush_tlb_global_irq_disabled (void )
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 170/346 ARC: Call trace_hardirqs_on() before enabling irqs
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Mentz <[email protected]>
commit 18b43e89d295cc65151c505c643c98fb2c320e59 upstream.
trace_hardirqs_on_caller() in lockdep.c expects to be called before, not after interrupts are actually enabled.
The following comment in kernel/locking/lockdep.c substantiates this claim:
"
/*
* We're enabling irqs and according to our state above irqs weren't
* already enabled, yet we find the hardware thinks they are in fact
* enabled.. someone messed up their IRQ state tracing. */
"
An example can be found in include/linux/irqflags.h:
do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)Without this change, we hit the following DEBUG_LOCKS_WARN_ON.
[ 7.760000] ------------[ cut here ]------------ [ 7.760000] WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:2711 resume_user_mode_begin+0x48/0xf0 [ 7.770000] DEBUG_LOCKS_WARN_ON(!irqs_disabled()) [ 7.780000] Modules linked in: [ 7.780000] CPU: 0 PID: 1 Comm: init Not tainted 4.7.0-00003-gc668bb9-dirty #366 [ 7.790000] [ 7.790000] Stack Trace: [ 7.790000] arc_unwind_core.constprop.1+0xa4/0x118 [ 7.800000] warn_slowpath_fmt+0x72/0x158 [ 7.800000] resume_user_mode_begin+0x48/0xf0 [ 7.810000] ---[ end trace 6f6a7a8fae20d2f0 ]---
--- arch/arc/include/asm/irqflags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/include/asm/irqflags.h +1 -1
@@ -179,10 +179,10 @@ static inline void arch_unmask_irq(unsig .endm .macro IRQ_ENABLE scratch +TRACE_ASM_IRQ_ENABLE lr \scratch, [status32] or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK) flag \scratch - TRACE_ASM_IRQ_ENABLE .endm #endif /* __ASSEMBLY__ */
PATCH 171/346 arm: oabi compat: add missing access checks
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dave Weinstein <[email protected]>
commit 7de249964f5578e67b99699c5f0b405738d820a2 upstream.
Add access checks to sys_oabi_epoll_wait() and sys_oabi_semtimedop(). This fixes CVE-2016-3857, a local privilege escalation under CONFIG_OABI_COMPAT.
--- arch/arm/kernel/sys_oabi-compat.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/arm/kernel/sys_oabi-compat.c +7 -1
@@ -279,8 +279,12 @@ asmlinkage long sys_oabi_epoll_wait(intmm_segment_t fs;long ret, err, i; -if (maxevents <=0 || maxevents > (INT_MAX /sizeof (struct epoll_event ))) +if (maxevents <=0 || + maxevents > (INT_MAX /sizeof (*kbuf)) || + maxevents > (INT_MAX /sizeof (*events)))return -EINVAL ; +if (!access_ok (VERIFY_WRITE , events,sizeof (*events) * maxevents)) +return -EFAULT ; kbuf =kmalloc (sizeof (*kbuf) * maxevents,GFP_KERNEL );if (!kbuf)return -ENOMEM ;
@@ -317,6 +321,8 @@ asmlinkage long sys_oabi_semtimedop(intif (nsops <1 || nsops >SEMOPM )return -EINVAL ; +if (!access_ok (VERIFY_READ , tsops,sizeof (*tsops) * nsops)) +return -EFAULT ; sops =kmalloc (sizeof (*sops) * nsops,GFP_KERNEL );if (!sops)return -ENOMEM ;
PATCH 172/346 megaraid_sas: Fix probing cards without io port
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yinghai Lu <[email protected]>
commit e7f851684efb3377e9c93aca7fae6e76212e5680 upstream.
Found one megaraid_sas HBA probe fails,
[ 187.235190] scsi host2: Avago SAS based MegaRAID driver [ 191.112365] megaraid_sas 0000:89:00.0: BAR 0: can't reserve [io 0x0000-0x00ff] [ 191.120548] megaraid_sas 0000:89:00.0: IO memory region busy!
and the card has resource like,
[ 125.097714] pci 0000:89:00.0: [1000:005d] type 00 class 0x010400 [ 125.104446] pci 0000:89:00.0: reg 0x10: [io 0x0000-0x00ff] [ 125.110686] pci 0000:89:00.0: reg 0x14: [mem 0xce400000-0xce40ffff 64bit] [ 125.118286] pci 0000:89:00.0: reg 0x1c: [mem 0xce300000-0xce3fffff 64bit] [ 125.125891] pci 0000:89:00.0: reg 0x30: [mem 0xce200000-0xce2fffff pref]
that does not io port resource allocated from BIOS, and kernel can not assign one as io port shortage.
The driver is only looking for MEM, and should not fail.
It turns out megasas_init_fw() etc are using bar index as mask. index 1 is used as mask 1, so that pci_request_selected_regions() is trying to request BAR0 instead of BAR1.
Fix all related reference.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 6 +++--- drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +3 -3
@@ -3996,7 +3996,7 @@ static int megasas_init_fw(struct megasa/* Find first memory bar */ bar_list =pci_select_bars (instance->pdev,IORESOURCE_MEM ); instance->bar =find_first_bit (&bar_list,sizeof (unsigned long )); -if (pci_request_selected_regions (instance->pdev, instance->bar, +if (pci_request_selected_regions (instance->pdev,1 <<instance->bar,"megasas: LSI" )) {printk (KERN_DEBUG "megasas: IO memory region busy!\n" );return -EBUSY ;
@@ -4261,7 +4261,7 @@ fail_ready_state:iounmap (instance->reg_set); fail_ioremap: -pci_release_selected_regions (instance->pdev, instance->bar); +pci_release_selected_regions (instance->pdev,1 <<instance->bar);return -EINVAL ; }
@@ -4282,7 +4282,7 @@ static void megasas_release_mfi(struct miounmap (instance->reg_set); -pci_release_selected_regions (instance->pdev, instance->bar); +pci_release_selected_regions (instance->pdev,1 <<instance->bar); }/**
drivers/scsi/megaraid/megaraid_sas_fusion.c +1 -1
@@ -2190,7 +2190,7 @@ megasas_release_fusion(struct megasas_iniounmap (instance->reg_set); -pci_release_selected_regions (instance->pdev, instance->bar); +pci_release_selected_regions (instance->pdev,1 <<instance->bar); }/**
PATCH 173/346 usb: gadget: fsl_qe_udc: off by one in setup_received_handle()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 7442e6db5bdd0dce4615205508301f9b22e502d6 upstream.
The udc->eps[] array has USB_MAX_ENDPOINTS elements so > should be >=.
--- drivers/usb/gadget/fsl_qe_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/fsl_qe_udc.c +1 -1
@@ -2057,7 +2057,7 @@ static void setup_received_handle(structstruct qe_ep *ep;if (wValue !=0 || wLength !=0 - || pipe >USB_MAX_ENDPOINTS ) + || pipe >=USB_MAX_ENDPOINTS )break ; ep = &udc->eps[pipe];
PATCH 174/346 usb: misc: usbtest: add fix for driver hang
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
commit 539587511835ea12d8daa444cbed766cf2bc3612 upstream.
In sg_timeout(), req->status is set to "-ETIMEDOUT" before calling into usb_sg_cancel(). usb_sg_cancel() will do nothing and return directly if req->status has been set to a non-zero value. This will cause driver hang whenever transfer time out is triggered.
This patch fixes this issue. It could be backported to stable kernel with version later than v3.15.
--- drivers/usb/misc/usbtest.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/misc/usbtest.c +4 -3
@@ -488,7 +488,6 @@ static void sg_timeout(unsigned long _re {struct usb_sg_request *req = (struct usb_sg_request *) _req; - req->status = -ETIMEDOUT ;usb_sg_cancel (req); }
@@ -519,8 +518,10 @@ static int perform_sglist(mod_timer (&sg_timer, jiffies +msecs_to_jiffies (SIMPLE_IO_TIMEOUT ));usb_sg_wait (req); -del_timer_sync (&sg_timer); - retval = req->status; +if (!del_timer_sync (&sg_timer)) + retval = -ETIMEDOUT ; +else + retval = req->status;/* FIXME check resulting data pattern */
PATCH 175/346 MIPS: KVM: Fix mapped fault broken commpage handling
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit c604cffa93478f8888bec62b23d6073dad03d43a upstream.
kvm_mips_handle_mapped_seg_tlb_fault() appears to map the guest page at virtual address 0 to PFN 0 if the guest has created its own mapping there. The intention is unclear, but it may have been an attempt to protect the zero page from being mapped to anything but the comm page in code paths you wouldn't expect from genuine commpage accesses (guest kernel mode cache instructions on that address, hitting trapping instructions when executing from that address with a coincidental TLB eviction during the KVM handling, and guest user mode accesses to that address).
Fix this to check for mappings exactly at KVM_GUEST_COMMPAGE_ADDR (it may not be at address 0 since commit 42aa12e74e91 ("MIPS: KVM: Move commpage so 0x0 is unmapped")), and set the corresponding EntryLo to be interpreted as 0 (invalid).
---
arch/mips/kvm/kvm_tlb.c +26 -15
@@ -361,21 +361,32 @@ kvm_mips_handle_mapped_seg_tlb_fault(strunsigned long entryhi =0 , entrylo0 =0 , entrylo1 =0 ;struct kvm *kvm = vcpu->kvm;pfn_t pfn0, pfn1; +long tlb_lo[2 ]; -if ((tlb->tlb_hi &VPN2_MASK ) ==0 ) { - pfn0 =0 ; - pfn1 =0 ; - }else { -if (kvm_mips_map_page (kvm,mips3_tlbpfn_to_paddr (tlb->tlb_lo0) >>PAGE_SHIFT ) <0 ) -return -1 ; - -if (kvm_mips_map_page (kvm,mips3_tlbpfn_to_paddr (tlb->tlb_lo1) >>PAGE_SHIFT ) <0 ) -return -1 ; - - pfn0 = kvm->arch.guest_pmap[mips3_tlbpfn_to_paddr (tlb->tlb_lo0) >>PAGE_SHIFT ]; - pfn1 = kvm->arch.guest_pmap[mips3_tlbpfn_to_paddr (tlb->tlb_lo1) >>PAGE_SHIFT ]; - } + tlb_lo[0 ] = tlb->tlb_lo0; + tlb_lo[1 ] = tlb->tlb_lo1; + +/* +* The commpage address must not be mapped to anything else if the guest +* TLB contains entries nearby, or commpage accesses will break. +*/ +if (!((tlb->tlb_hi ^KVM_GUEST_COMMPAGE_ADDR ) & +VPN2_MASK & (PAGE_MASK <<1 ))) + tlb_lo[(KVM_GUEST_COMMPAGE_ADDR >>PAGE_SHIFT ) &1 ] =0 ; + +if (kvm_mips_map_page (kvm,mips3_tlbpfn_to_paddr (tlb_lo[0 ]) + >>PAGE_SHIFT ) <0 ) +return -1 ; + +if (kvm_mips_map_page (kvm,mips3_tlbpfn_to_paddr (tlb_lo[1 ]) + >>PAGE_SHIFT ) <0 ) +return -1 ; + + pfn0 = kvm->arch.guest_pmap[ +mips3_tlbpfn_to_paddr (tlb_lo[0 ]) >>PAGE_SHIFT ]; + pfn1 = kvm->arch.guest_pmap[ +mips3_tlbpfn_to_paddr (tlb_lo[1 ]) >>PAGE_SHIFT ];if (hpa0) *hpa0 = pfn0 <<PAGE_SHIFT ;
@@ -387,9 +398,9 @@ kvm_mips_handle_mapped_seg_tlb_fault(str entryhi = (tlb->tlb_hi &VPN2_MASK ) | (KVM_GUEST_KERNEL_MODE (vcpu) ?kvm_mips_get_kernel_asid (vcpu) :kvm_mips_get_user_asid (vcpu)); entrylo0 =mips3_paddr_to_tlbpfn (pfn0 <<PAGE_SHIFT ) | (0x3 <<3 ) | - (tlb->tlb_lo0 &MIPS3_PG_D ) | (tlb->tlb_lo0 &MIPS3_PG_V ); + (tlb_lo[0 ] &MIPS3_PG_D ) | (tlb_lo[0 ] &MIPS3_PG_V ); entrylo1 =mips3_paddr_to_tlbpfn (pfn1 <<PAGE_SHIFT ) | (0x3 <<3 ) | - (tlb->tlb_lo1 &MIPS3_PG_D ) | (tlb->tlb_lo1 &MIPS3_PG_V ); + (tlb_lo[1 ] &MIPS3_PG_D ) | (tlb_lo[1 ] &MIPS3_PG_V );kvm_debug ("@ %#lx tlb_lo0: 0x%08lx tlb_lo1: 0x%08lx\n" , vcpu->arch.pc, tlb->tlb_lo0, tlb->tlb_lo1);
PATCH 176/346 MIPS: KVM: Add missing gfn range check
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 8985d50382359e5bf118fdbefc859d0dbf6cebc7 upstream.
kvm_mips_handle_mapped_seg_tlb_fault() calculates the guest frame number based on the guest TLB EntryLo values, however it is not range checked to ensure it lies within the guest_pmap. If the physical memory the guest refers to is out of range then dump the guest TLB and emit an internal error.
--- arch/mips/kvm/kvm_tlb.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
arch/mips/kvm/kvm_tlb.c +15 -8
@@ -361,6 +361,7 @@ kvm_mips_handle_mapped_seg_tlb_fault(strunsigned long entryhi =0 , entrylo0 =0 , entrylo1 =0 ;struct kvm *kvm = vcpu->kvm;pfn_t pfn0, pfn1; +gfn_t gfn0, gfn1;long tlb_lo[2 ];
@@ -375,18 +376,24 @@ kvm_mips_handle_mapped_seg_tlb_fault(str VPN2_MASK & (PAGE_MASK << 1))) tlb_lo[(KVM_GUEST_COMMPAGE_ADDR >>PAGE_SHIFT ) &1 ] =0 ; -if (kvm_mips_map_page (kvm,mips3_tlbpfn_to_paddr (tlb_lo[0 ]) - >>PAGE_SHIFT ) <0 ) + gfn0 =mips3_tlbpfn_to_paddr (tlb_lo[0 ]) >>PAGE_SHIFT ; + gfn1 =mips3_tlbpfn_to_paddr (tlb_lo[1 ]) >>PAGE_SHIFT ; +if (gfn0 >= kvm->arch.guest_pmap_npages || + gfn1 >= kvm->arch.guest_pmap_npages) { +kvm_err ("%s: Invalid gfn: [%#llx, %#llx], EHi: %#lx\n" , + __func__, gfn0, gfn1, tlb->tlb_hi); +kvm_mips_dump_guest_tlbs (vcpu);return -1 ; + } -if (kvm_mips_map_page (kvm,mips3_tlbpfn_to_paddr (tlb_lo[1 ]) - >>PAGE_SHIFT ) <0 ) +if (kvm_mips_map_page (kvm, gfn0) <0 )return -1 ; - pfn0 = kvm->arch.guest_pmap[ -mips3_tlbpfn_to_paddr (tlb_lo[0 ]) >>PAGE_SHIFT ]; - pfn1 = kvm->arch.guest_pmap[ -mips3_tlbpfn_to_paddr (tlb_lo[1 ]) >>PAGE_SHIFT ]; +if (kvm_mips_map_page (kvm, gfn1) <0 ) +return -1 ; + + pfn0 = kvm->arch.guest_pmap[gfn0]; + pfn1 = kvm->arch.guest_pmap[gfn1];if (hpa0) *hpa0 = pfn0 <<PAGE_SHIFT ;
PATCH 177/346 MIPS: KVM: Fix gfn range check in kseg0 tlb faults
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 0741f52d1b980dbeb290afe67d88fc2928edd8ab upstream.
Two consecutive gfns are loaded into host TLB, so ensure the range check isn't off by one if guest_pmap_npages is odd.
--- arch/mips/kvm/kvm_tlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kvm/kvm_tlb.c +1 -1
@@ -278,7 +278,7 @@ int kvm_mips_handle_kseg0_tlb_fault(unsi } gfn = (KVM_GUEST_CPHYSADDR (badvaddr) >>PAGE_SHIFT ); -if (gfn >= kvm->arch.guest_pmap_npages) { +if ((gfn |1 ) >= kvm->arch.guest_pmap_npages) {kvm_err ("%s: Invalid gfn: %#llx, BadVaddr: %#lx\n" , __func__, gfn, badvaddr);kvm_mips_dump_host_tlbs ();
PATCH 178/346 MIPS: KVM: Propagate kseg0/mapped tlb fault errors
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 9b731bcfdec4c159ad2e4312e25d69221709b96a upstream.
Propagate errors from kvm_mips_handle_kseg0_tlb_fault() and kvm_mips_handle_mapped_seg_tlb_fault(), usually triggering an internal error since they normally indicate the guest accessed bad physical memory or the commpage in an unexpected way.
---
arch/mips/kvm/kvm_mips_emul.c +27 -10
@@ -1481,9 +1481,13 @@ kvm_mips_emulate_cache(uint32_t inst, uipreempt_disable ();if (KVM_GUEST_KSEGX (va) ==KVM_GUEST_KSEG0 ) { - -if (kvm_mips_host_tlb_lookup (vcpu, va) <0 ) { -kvm_mips_handle_kseg0_tlb_fault (va, vcpu); +if (kvm_mips_host_tlb_lookup (vcpu, va) <0 && +kvm_mips_handle_kseg0_tlb_fault (va, vcpu)) { +kvm_err ("%s: handling mapped kseg0 tlb fault for %lx, vcpu: %p, ASID: %#lx\n" , + __func__, va, vcpu,read_c0_entryhi ()); + er =EMULATE_FAIL ; +preempt_enable (); + goto done; } }else if ((KVM_GUEST_KSEGX (va) <KVM_GUEST_KSEG0 ) ||KVM_GUEST_KSEGX (va) ==KVM_GUEST_KSEG23 ) {
@@ -1516,11 +1520,19 @@ kvm_mips_emulate_cache(uint32_t inst, ui run, vcpu);preempt_enable (); goto dont_update_pc; - }else { -/* We fault an entry from the guest tlb to the shadow host TLB */ -kvm_mips_handle_mapped_seg_tlb_fault (vcpu, tlb, -NULL , -NULL ); + } +/* +* We fault an entry from the guest tlb to the +* shadow host TLB +*/ +if (kvm_mips_handle_mapped_seg_tlb_fault (vcpu, tlb, +NULL ,NULL )) { +kvm_err ("%s: handling mapped seg tlb fault for %lx, index: %u, vcpu: %p, ASID: %#lx\n" , + __func__, va, index, vcpu, +read_c0_entryhi ()); + er =EMULATE_FAIL ; +preempt_enable (); + goto done; } } }else {
@@ -2335,8 +2347,13 @@ kvm_mips_handle_tlbmiss(unsigned long ca ("Injecting hi: %#lx, lo0: %#lx, lo1: %#lx into shadow host TLB\n" , tlb->tlb_hi, tlb->tlb_lo0, tlb->tlb_lo1);/* OK we have a Guest TLB entry, now inject it into the shadow host TLB */ -kvm_mips_handle_mapped_seg_tlb_fault (vcpu, tlb,NULL , -NULL ); +if (kvm_mips_handle_mapped_seg_tlb_fault (vcpu, tlb, +NULL ,NULL )) { +kvm_err ("%s: handling mapped seg tlb fault for %lx, index: %u, vcpu: %p, ASID: %#lx\n" , + __func__, va, index, vcpu, +read_c0_entryhi ()); + er =EMULATE_FAIL ; + } } }
arch/mips/kvm/kvm_tlb.c +10 -4
@@ -801,10 +801,16 @@ uint32_t kvm_get_inst(uint32_t *opc, strlocal_irq_restore (flags);return KVM_INVALID_INST ; } -kvm_mips_handle_mapped_seg_tlb_fault (vcpu, - &vcpu->arch. - guest_tlb[index], -NULL ,NULL ); +if (kvm_mips_handle_mapped_seg_tlb_fault (vcpu, + &vcpu->arch.guest_tlb[index], +NULL ,NULL )) { +kvm_err ("%s: handling mapped seg tlb fault failed for %p, index: %u, vcpu: %p, ASID: %#lx\n" , + __func__, opc, index, vcpu, +read_c0_entryhi ()); +kvm_mips_dump_guest_tlbs (vcpu); +local_irq_restore (flags); +return KVM_INVALID_INST ; + } inst = *(opc); }local_irq_restore (flags);
PATCH 179/346 power: supply: max17042_battery: fix model download bug.
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Van Asbroeck <[email protected]>
commit 5381cfb6f0422da24cfa9da35b0433c0415830e0 upstream.
The device's model download function returns the model data as an array of u32s, which is later compared to the reference model data. However, since the latter is an array of u16s, the comparison does not happen correctly, and model verification fails. This in turn breaks the POR initialization sequence.
--- drivers/power/max17042_battery.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/power/max17042_battery.c +9 -6
@@ -295,13 +295,16 @@ static inline void max17042_write_model_ }static inline void max17042_read_model_data (struct max17042_chip *chip, -u8 addr,u32 *data,int size) +u8 addr,u16 *data,int size) {struct regmap *map = chip->regmap;int i; +u32 tmp; -for (i =0 ; i < size; i++) -regmap_read (map, addr + i, &data[i]); +for (i =0 ; i < size; i++) { +regmap_read (map, addr + i, &tmp); + data[i] = (u16 )tmp; + } } static inline int max17042_model_data_compare(struct max17042_chip *chip,
@@ -324,7 +327,7 @@ static int max17042_init_model(struct ma {int ret;int table_size =ARRAY_SIZE (chip->pdata->config_data->cell_char_tbl); -u32 *temp_data; +u16 *temp_data; temp_data =kcalloc (table_size,sizeof (*temp_data),GFP_KERNEL );if (!temp_data)
@@ -339,7 +342,7 @@ static int max17042_init_model(struct ma ret =max17042_model_data_compare ( chip, chip->pdata->config_data->cell_char_tbl, - (u16 *)temp_data, + temp_data, table_size);max10742_lock_model (chip);
@@ -352,7 +355,7 @@ static int max17042_verify_model_lock(st {int i;int table_size =ARRAY_SIZE (chip->pdata->config_data->cell_char_tbl); -u32 *temp_data; +u16 *temp_data;int ret =0 ; temp_data =kcalloc (table_size,sizeof (*temp_data),GFP_KERNEL );
PATCH 180/346 PM / hibernate: Restore processor state before using per-CPU variables
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Garnier <[email protected]>
commit 62822e2ec4ad091ba31f823f577ef80db52e3c2c upstream.
Restore the processor state before calling any other functions to ensure per-CPU variables can be used with KASLR memory randomization.
Tracing functions use per-CPU variables (GS based on x86) and one was called just before restoring the processor state fully. It resulted in a double fault when both the tracing & the exception handler functions tried to use a per-CPU variable.
--- kernel/power/hibernate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/power/hibernate.c +2 -2
@@ -301,12 +301,12 @@ static int create_image(int platform_modsave_processor_state ();trace_suspend_resume (TPS ("machine_suspend" ),PM_EVENT_HIBERNATE , true); error =swsusp_arch_suspend (); +/* Restore control flow magically appears here */ +restore_processor_state ();trace_suspend_resume (TPS ("machine_suspend" ),PM_EVENT_HIBERNATE , false);if (error)printk (KERN_ERR "PM: Error %d creating hibernation image\n" , error); -/* Restore control flow magically appears here */ -restore_processor_state ();if (!in_suspend) events_check_enabled = false;
PATCH 181/346 ipv6: suppress sparse warnings in IP6_ECN_set_ce()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit c15c0ab12fd62f2b19181d05c62d24bc9fa55a42 upstream.
Pass the correct type __wsum to csum_sub() and csum_add(). This doesn't really change anything since __wsum really *is* __be32, but removes the address space warnings from sparse.
--- include/net/inet_ecn.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/net/inet_ecn.h +2 -1
@@ -128,7 +128,8 @@ static inline int IP6_ECN_set_ce(struct to = from |htonl (INET_ECN_CE <<20 ); *(__be32 *)iph = to;if (skb->ip_summed ==CHECKSUM_COMPLETE ) - skb->csum =csum_add (csum_sub (skb->csum, from), to); + skb->csum =csum_add (csum_sub (skb->csum, (__force __wsum )from), + (__force __wsum )to);return 1 ; }
PATCH 182/346 USB: serial: mos7720: fix non-atomic allocation in write path
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Khoroshilov <[email protected]>
commit 5a5a1d614287a647b36dff3f40c2b0ceabbc83ec upstream.
There is an allocation with GFP_KERNEL flag in mos7720_write(), while it may be called from interrupt context.
Follow-up for commit 191252837626 ("USB: kobil_sct: fix non-atomic allocation in write path")
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/usb/serial/mos7720.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/mos7720.c +1 -1
@@ -1239,7 +1239,7 @@ static int mos7720_write(struct tty_struif (urb->transfer_buffer ==NULL ) { urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE , -GFP_KERNEL ); +GFP_ATOMIC );if (!urb->transfer_buffer) goto exit; }
PATCH 183/346 USB: serial: mos7840: fix non-atomic allocation in write path
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Khoroshilov <[email protected]>
commit 3b7c7e52efda0d4640060de747768360ba70a7c0 upstream.
There is an allocation with GFP_KERNEL flag in mos7840_write(), while it may be called from interrupt context.
Follow-up for commit 191252837626 ("USB: kobil_sct: fix non-atomic allocation in write path")
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/usb/serial/mos7840.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/serial/mos7840.c +2 -2
@@ -1372,8 +1372,8 @@ static int mos7840_write(struct tty_stru }if (urb->transfer_buffer ==NULL ) { - urb->transfer_buffer = -kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_KERNEL ); + urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE , +GFP_ATOMIC );if (!urb->transfer_buffer) goto exit; }
PATCH 184/346 cdc-acm: fix wrong pipe type on rx interrupt xfers
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gavin Li <[email protected]>
commit add125054b8727103631dce116361668436ef6a7 upstream.
This fixes the "BOGUS urb xfer" warning logged by usb_submit_urb().
--- drivers/usb/class/cdc-acm.c | 5 ++--- drivers/usb/class/cdc-acm.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/usb/class/cdc-acm.c +2 -3
@@ -1336,7 +1336,6 @@ made_compressed_probe:spin_lock_init (&acm->write_lock);spin_lock_init (&acm->read_lock);mutex_init (&acm->mutex); - acm->rx_endpoint =usb_rcvbulkpipe (usb_dev, epread->bEndpointAddress); acm->is_int_ep =usb_endpoint_xfer_int (epread);if (acm->is_int_ep) acm->bInterval = epread->bInterval;
@@ -1386,14 +1385,14 @@ made_compressed_probe: urb->transfer_dma = rb->dma;if (acm->is_int_ep) {usb_fill_int_urb (urb, acm->dev, - acm->rx_endpoint, +usb_rcvintpipe (usb_dev, epread->bEndpointAddress), rb->base, acm->readsize, acm_read_bulk_callback, rb, acm->bInterval); }else {usb_fill_bulk_urb (urb, acm->dev, - acm->rx_endpoint, +usb_rcvbulkpipe (usb_dev, epread->bEndpointAddress), rb->base, acm->readsize, acm_read_bulk_callback, rb);
drivers/usb/class/cdc-acm.h +0 -1
@@ -95,7 +95,6 @@ struct acm {struct urb *read_urbs[ACM_NR ];struct acm_rb read_buffers[ACM_NR ];int rx_buflimit; -int rx_endpoint;spinlock_t read_lock;int write_used;/* number of non-empty write buffers */ int transmitting;
PATCH 185/346 iio: proximity: as3935: set up buffer timestamps for non-zero values
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
commit f8adf645db03345af2d9a8b6095b02327ea50885 upstream.
Use the iio_pollfunc_store_time parameter during triggered buffer set-up to get valid timestamps.
--- drivers/iio/proximity/as3935.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/proximity/as3935.c +1 -1
@@ -389,7 +389,7 @@ static int as3935_probe(struct spi_devicreturn ret; } - ret =iio_triggered_buffer_setup (indio_dev,NULL , + ret =iio_triggered_buffer_setup (indio_dev, iio_pollfunc_store_time, &as3935_trigger_handler,NULL );if (ret) {
PATCH 186/346 iio: adc: at91: unbreak channel adc channel 3
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Anders Darander <[email protected]>
commit c2ab447454d498e709d9011c0f2d2945ee321f9b upstream.
The driver always assumes that an input device has been created when reading channel 3. This causes a kernel panic when dereferencing st->ts_input.
The change was introduced in
commit 84882b060301 ("iio: adc: at91_adc: Add support for touchscreens without TSMR"). Earlier versions only entered that part of the if-else statement if only the following flags are set:
AT91_ADC_IER_XRDY | AT91_ADC_IER_YRDY | AT91_ADC_IER_PRDY
--- drivers/iio/adc/at91_adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/at91_adc.c +2 -2
@@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt st->ts_bufferedmeasure = false;input_report_key (st->ts_input,BTN_TOUCH ,0 );input_sync (st->ts_input); - }else if (status &AT91_ADC_EOC (3 )) { -/* Conversion finished */ + }else if (status &AT91_ADC_EOC (3 ) && st->ts_input) { +/* Conversion finished and we've a touchscreen */ if (st->ts_bufferedmeasure) {/* * Last measurement is always discarded, since it can
PATCH 187/346 scsi: fix upper bounds check of sense key in scsi_sense_key_string()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tyrel Datwyler <[email protected]>
commit a87eeb900dbb9f8202f96604d56e47e67c936b9d upstream.
Commit 655ee63cf371 ("scsi constants: command, sense key + additional sense string") added a "Completed" sense string with key 0xF to snstext[], but failed to updated the upper bounds check of the sense key in scsi_sense_key_string().
--- drivers/scsi/constants.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/constants.c +3 -2
@@ -1335,9 +1335,10 @@ static const char * const snstext[] = {/* Get sense key string or NULL if not available */ const char * -scsi_sense_key_string (unsigned char key) { +scsi_sense_key_string (unsigned char key) +{#ifdef CONFIG_SCSI_CONSTANTS -if (key <=0xE ) +if (key <ARRAY_SIZE (snstext))return snstext[key];#endif return NULL ;
PATCH 188/346 xhci: always handle "Command Ring Stopped" events
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 33be126510974e2eb9679f1ca9bca4f67ee4c4c7 upstream.
Fix "Command completion event does not match command" errors by always handling the command ring stopped events.
The command ring stopped event is generated as a result of aborting or stopping the command ring with a register write. It is not caused by a command in the command queue, and thus won't have a matching command in the comman list.
Solve it by handling the command ring stopped event before checking for a matching command.
In most command time out cases we abort the command ring, and get a command ring stopped event. The events command pointer will point at the current command ring dequeue, which in most cases matches the timed out command in the command list, and no error messages are seen.
If we instead get a command aborted event before the command ring stopped event, the abort event will increse the command ring dequeue pointer, and the following command ring stopped events command pointer will point at the next, not yet queued command. This case triggered the error message
--- drivers/usb/host/xhci-ring.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/host/xhci-ring.c +7 -6
@@ -1351,12 +1351,6 @@ static void handle_cmd_completion(struct cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); -if (cmd->command_trb != xhci->cmd_ring->dequeue) { -xhci_err (xhci, -"Command completion event does not match command\n" ); -return ; - } -del_timer (&xhci->cmd_timer);trace_xhci_cmd_completion (cmd_trb, (struct xhci_generic_trb *) event);
@@ -1368,6 +1362,13 @@ static void handle_cmd_completion(structxhci_handle_stopped_cmd_ring (xhci, cmd);return ; } + +if (cmd->command_trb != xhci->cmd_ring->dequeue) { +xhci_err (xhci, +"Command completion event does not match command\n" ); +return ; + } +/* * Host aborted the command ring, check if the current command was * supposed to be aborted, otherwise continue normally.
PATCH 189/346 usb: xhci: Fix panic if disconnect
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jim Lin <[email protected]>
commit 88716a93766b8f095cdef37a8e8f2c93aa233b21 upstream.
After a device is disconnected, xhci_stop_device() will be invoked in xhci_bus_suspend().
Also the "disconnect" IRQ will have ISR to invoke xhci_free_virt_device() in this sequence.xhci_irq -> xhci_handle_event -> handle_cmd_completion -> xhci_handle_cmd_disable_slot -> xhci_free_virt_device
If xhci->devs[slot_id] has been assigned to NULL in xhci_free_virt_device(), then virt_dev->eps[i].ring in xhci_stop_device() may point to an invlid address to cause kernel panic.
virt_dev = xhci->devs[slot_id];
:
if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue)
[] Unable to handle kernel paging request at virtual address 00001a68 [] pgd=ffffffc001430000
[] [00001a68] *pgd=000000013c807003, *pud=000000013c807003, *pmd=000000013c808003, *pte=0000000000000000
[] Internal error: Oops: 96000006 [#1] PREEMPT SMP
[] CPU: 0 PID: 39 Comm: kworker/0:1 Tainted: G U
[] Workqueue: pm pm_runtime_work
[] task: ffffffc0bc0e0bc0 ti: ffffffc0bc0ec000 task.ti:ffffffc0bc0ec000
[] PC is at xhci_stop_device.constprop.11+0xb4/0x1a4
This issue is found when running with realtek ethernet device (0bda:8153).
--- drivers/usb/host/xhci-hub.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-hub.c +3 -0
@@ -276,6 +276,9 @@ static int xhci_stop_device(struct xhci_ ret =0 ; virt_dev = xhci->devs[slot_id]; +if (!virt_dev) +return -ENODEV ; + cmd =xhci_alloc_command (xhci, false, true,GFP_NOIO );if (!cmd) {xhci_dbg (xhci,"Couldn't allocate command structure.\n" );
PATCH 190/346 xhci: don't dereference a xhci member after removing xhci
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit f1f6d9a8b540df22b87a5bf6bc104edaade81f47 upstream.
Remove the hcd after checking for the xhci last quirks, not before.
This caused a hang on a Alpine Ridge xhci based maching which remove the whole xhci controller when unplugging the last usb device
--- drivers/usb/host/xhci-pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +2 -1
@@ -293,12 +293,13 @@ static void xhci_pci_remove(struct pci_dusb_remove_hcd (xhci->shared_hcd);usb_put_hcd (xhci->shared_hcd); } -usb_hcd_pci_remove (dev);/* Workaround for spurious wakeups at shutdown with HSW */ if (xhci->quirks &XHCI_SPURIOUS_WAKEUP )pci_set_power_state (dev, PCI_D3hot); +usb_hcd_pci_remove (dev); +kfree (xhci); }
PATCH 191/346 KVM: nVMX: postpone VMCS changes on MSR_IA32_APICBASE write
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Radim Krčmář <[email protected]>
commit dccbfcf52cebb8963246eba5b177b77f26b34da0 upstream.
If vmcs12 does not intercept APIC_BASE writes, then KVM will handle the write with vmcs02 as the current VMCS.
This will incorrectly apply modifications intended for vmcs01 to vmcs02 and L2 can use it to gain access to L0's x2APIC registers by disabling virtualized x2APIC while using msr bitmap that assumes enabled.
Postpone execution of vmx_set_virtual_x2apic_mode until vmcs01 is the current VMCS. An alternative solution would temporarily make vmcs01 the current VMCS, but it requires more care.
--- arch/x86/kvm/vmx.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/x86/kvm/vmx.c +13 -0
@@ -372,6 +372,7 @@ struct nested_vmx {struct list_head vmcs02_pool;int vmcs02_num;u64 vmcs01_tsc_offset; +bool change_vmcs01_virtual_x2apic_mode;/* L2 must run next, and mustn't decide to exit to L1. */ bool nested_run_pending;/*
@@ -7084,6 +7085,12 @@ static void vmx_set_virtual_x2apic_mode( {u32 sec_exec_control; +/* Postpone execution until vmcs01 is the current VMCS. */ +if (is_guest_mode (vcpu)) { +to_vmx (vcpu)->nested.change_vmcs01_virtual_x2apic_mode = true; +return ; + } +/* * There is not point to enable virtualize x2apic without enable * apicv
@@ -8784,6 +8791,12 @@ static void nested_vmx_vmexit(struct kvm/* Update TSC_OFFSET if TSC was changed while L2 ran */ vmcs_write64 (TSC_OFFSET , vmx->nested.vmcs01_tsc_offset); +if (vmx->nested.change_vmcs01_virtual_x2apic_mode) { + vmx->nested.change_vmcs01_virtual_x2apic_mode = false; +vmx_set_virtual_x2apic_mode (vcpu, + vcpu->arch.apic_base &X2APIC_ENABLE ); + } +/* This is needed for same reason as it was needed in prepare_vmcs02 */ vmx->host_rsp =0 ;
PATCH 192/346 bcache: register_bcache(): call blkdev_put() when cache_alloc() fails
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Wheeler <[email protected]>
commit d9dc1702b297ec4a6bb9c0326a70641b322ba886 upstream.
register_cache() is supposed to return an error string on error so that register_bcache() will will blkdev_put and cleanup other user counters, but it does not set 'char *err' when cache_alloc() fails (eg, due to memory pressure) and thus register_bcache() performs no cleanup.
register_bcache() <----------\ <- no jump to err_close, no blkdev_put()
| |
+->register_cache() | <- fails to set char *err
| |
+->cache_alloc() ---/ <- returns errorThis patch sets char *err for this failure case so that register_cache() will cause register_bcache() to correctly jump to err_close and do cleanup. This was tested under OOM conditions that triggered the bug.
--- drivers/md/bcache/super.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/md/bcache/super.c +7 -2
@@ -1854,7 +1854,7 @@ static int register_cache(struct cache_s struct block_device *bdev, struct cache *ca) { char name[BDEVNAME_SIZE]; -const char *err =NULL ; +const char *err =NULL ;/* must be set for any error case */ int ret =0 ;memcpy (&ca->sb, sb,sizeof (struct cache_sb ));
@@ -1871,8 +1871,13 @@ static int register_cache(struct cache_s ca->discard =CACHE_DISCARD (&ca->sb); ret =cache_alloc (sb, ca); -if (ret !=0 ) +if (ret !=0 ) { +if (ret == -ENOMEM ) + err ="cache_alloc(): -ENOMEM" ; +else + err ="cache_alloc(): unknown error" ; goto err; + }if (kobject_add (&ca->kobj, &part_to_dev (bdev->bd_part)->kobj,"bcache" )) { err ="error calling kobject_add" ;
PATCH 193/346 bcache: RESERVE_PRIO is too small by one when prio_buckets() is a power of two.
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Kent Overstreet <[email protected]>
commit acc9cf8c66c66b2cbbdb4a375537edee72be64df upstream.
This patch fixes a cachedev registration-time allocation deadlock. This can deadlock on boot if your initrd auto-registeres bcache devices:
Allocator thread:
[ 720.727614] INFO: task bcache_allocato:3833 blocked for more than 120 seconds. [ 720.732361] [<ffffffff816eeac7>] schedule+0x37/0x90 [ 720.732963] [<ffffffffa05192b8>] bch_bucket_alloc+0x188/0x360 [bcache] [ 720.733538] [<ffffffff810e6950>] ? prepare_to_wait_event+0xf0/0xf0 [ 720.734137] [<ffffffffa05302bd>] bch_prio_write+0x19d/0x340 [bcache] [ 720.734715] [<ffffffffa05190bf>] bch_allocator_thread+0x3ff/0x470 [bcache] [ 720.735311] [<ffffffff816ee41c>] ? __schedule+0x2dc/0x950 [ 720.735884] [<ffffffffa0518cc0>] ? invalidate_buckets+0x980/0x980 [bcache]
Registration thread:
[ 720.710403] INFO: task bash:3531 blocked for more than 120 seconds. [ 720.715226] [<ffffffff816eeac7>] schedule+0x37/0x90 [ 720.715805] [<ffffffffa05235cd>] __bch_btree_map_nodes+0x12d/0x150 [bcache] [ 720.716409] [<ffffffffa0522d30>] ? bch_btree_insert_check_key+0x1c0/0x1c0 [bcache] [ 720.717008] [<ffffffffa05236e4>] bch_btree_insert+0xf4/0x170 [bcache] [ 720.717586] [<ffffffff810e6950>] ? prepare_to_wait_event+0xf0/0xf0 [ 720.718191] [<ffffffffa0527d9a>] bch_journal_replay+0x14a/0x290 [bcache] [ 720.718766] [<ffffffff810cc90d>] ? ttwu_do_activate.constprop.94+0x5d/0x70 [ 720.719369] [<ffffffff810cf684>] ? try_to_wake_up+0x1d4/0x350 [ 720.719968] [<ffffffffa05317d0>] run_cache_set+0x580/0x8e0 [bcache] [ 720.720553] [<ffffffffa053302e>] register_bcache+0xe2e/0x13b0 [bcache] [ 720.721153] [<ffffffff81354cef>] kobj_attr_store+0xf/0x20 [ 720.721730] [<ffffffff812a2dad>] sysfs_kf_write+0x3d/0x50 [ 720.722327] [<ffffffff812a225a>] kernfs_fop_write+0x12a/0x180 [ 720.722904] [<ffffffff81225177>] __vfs_write+0x37/0x110 [ 720.723503] [<ffffffff81228048>] ? __sb_start_write+0x58/0x110 [ 720.724100] [<ffffffff812cedb3>] ? security_file_permission+0x23/0xa0 [ 720.724675] [<ffffffff812258a9>] vfs_write+0xa9/0x1b0 [ 720.725275] [<ffffffff8102479c>] ? do_audit_syscall_entry+0x6c/0x70 [ 720.725849] [<ffffffff81226755>] SyS_write+0x55/0xd0 [ 720.726451] [<ffffffff8106a390>] ? do_page_fault+0x30/0x80 [ 720.727045] [<ffffffff816f2cae>] system_call_fastpath+0x12/0x71
The fifo code in upstream bcache can't use the last element in the buffer, which was the cause of the bug: if you asked for a power of two size, it'd give you a fifo that could hold one less than what you asked for rather than allocating a buffer twice as big.
--- drivers/md/bcache/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/super.c +1 -1
@@ -1829,7 +1829,7 @@ static int cache_alloc(struct cache_sb * free =roundup_pow_of_two (ca->sb.nbuckets) >>10 ; if (!init_fifo(&ca->free[RESERVE_BTREE], 8, GFP_KERNEL) || - !init_fifo(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || + !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) ||
PATCH 194/346 tcp: fix use after free in tcp_xmit_retransmit_queue()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit bb1fceca22492109be12640d49f5ea5a544c6bb4 upstream.
When tcp_sendmsg() allocates a fresh and empty skb, it puts it at the tail of the write queue using tcp_add_write_queue_tail()
Then it attempts to copy user data into this fresh skb.
If the copy fails, we undo the work and remove the fresh skb.
Unfortunately, this undo lacks the change done to tp->highest_sack and we can leave a dangling pointer (to a freed skb)
Later, tcp_xmit_retransmit_queue() can dereference this pointer and access freed memory. For regular kernels where memory is not unmapped, this might cause SACK bugs because tcp_highest_sack_seq() is buggy, returning garbage instead of tp->snd_nxt, but with various debug features like CONFIG_DEBUG_PAGEALLOC, this can crash the kernel.
This bug was found by Marco Grassi thanks to syzkaller.
--- include/net/tcp.h | 2 ++ 1 file changed, 2 insertions(+)
include/net/tcp.h +2 -0
@@ -1413,6 +1413,8 @@ static inline void tcp_check_send_head(s {if (sk->sk_send_head == skb_unlinked) sk->sk_send_head =NULL ; +if (tcp_sk (sk)->highest_sack == skb_unlinked) +tcp_sk (sk)->highest_sack =NULL ; }static inline void tcp_init_send_head (struct sock *sk)
PATCH 195/346 gpio: Fix OF build problem on UM
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit 2527ecc9195e9c66252af24c4689e8a67cd4ccb9 upstream.
The UserMode (UM) Linux build was failing in gpiolib-of as it requires ioremap()/iounmap() to exist, which is absent from UM. The non-existence of IO memory is negatively defined as CONFIG_NO_IOMEM which means we need to depend on HAS_IOMEM.
--- drivers/gpio/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/Kconfig +1 -0
@@ -50,6 +50,7 @@ config GPIO_DEVRES config OF_GPIO def_bool y depends on OF + depends on HAS_IOMEM config GPIO_ACPI def_bool y
arch/mips/kvm/kvm_mips.c +1 -1
@@ -1211,7 +1211,7 @@ int __init kvm_mips_init(void)*/ kvm_mips_gfn_to_pfn = gfn_to_pfn; kvm_mips_release_pfn_clean = kvm_release_pfn_clean; - kvm_mips_is_error_pfn = is_error_pfn; + kvm_mips_is_error_pfn = is_error_noslot_pfn;pr_info ("KVM/MIPS Initialized\n" );return 0 ;
PATCH 196/346 MIPS: KVM: Check for pfn noslot case
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit ba913e4f72fc9cfd03dad968dfb110eb49211d80 upstream.
When mapping a page into the guest we error check using is_error_pfn(), however this doesn't detect a value of KVM_PFN_NOSLOT, indicating an error HVA for the page. This can only happen on MIPS right now due to unusual memslot management (e.g. being moved / removed / resized), or with an Enhanced Virtual Memory (EVA) configuration where the default KVM_HVA_ERR_* and kvm_is_error_hva() definitions are unsuitable (fixed in a later patch). This case will be treated as a pfn of zero, mapping the first page of physical memory into the guest.
It would appear the MIPS KVM port wasn't updated prior to being merged (in v3.10) to take commit 81c52c56e2b4 ("KVM: do not treat noslot pfn as a error pfn") into account (merged v3.8), which converted a bunch of is_error_pfn() calls to is_error_noslot_pfn(). Switch to using is_error_noslot_pfn() instead to catch this case properly.
--- arch/mips/kvm/kvm_tlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kvm/kvm_tlb.c +1 -1
@@ -155,7 +155,7 @@ static int kvm_mips_map_page(struct kvm srcu_idx =srcu_read_lock (&kvm->srcu); pfn =kvm_mips_gfn_to_pfn (kvm, gfn); -if (kvm_mips_is_error_pfn (pfn)) { +if (is_error_noslot_pfn (pfn)) {kvm_err ("Couldn't get pfn for gfn %#" PRIx64"!\n" , gfn); err = -EFAULT ; goto out;
PATCH 197/346 drm/radeon: fix radeon_move_blit on 32bit systems
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit 13f479b9df4e2bbf2d16e7e1b02f3f55f70e2455 upstream.
This bug seems to be present for a very long time.
--- drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +2 -2
@@ -232,8 +232,8 @@ static int radeon_move_blit(struct ttm_b rdev =radeon_get_rdev (bo->bdev); ridx =radeon_copy_ring_index (rdev); - old_start = old_mem->start <<PAGE_SHIFT ; - new_start = new_mem->start <<PAGE_SHIFT ; + old_start = (u64 )old_mem->start <<PAGE_SHIFT ; + new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) {case TTM_PL_VRAM :
PATCH 198/346 Input: i8042 - set up shared ps2_cmd_mutex for AUX ports
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit 47af45d684b5f3ae000ad448db02ce4f13f73273 upstream.
The commit 4097461897df ("Input: i8042 - break load dependency ...") correctly set up ps2_cmd_mutex pointer for the KBD port but forgot to do the same for AUX port(s), which results in communication on KBD and AUX ports to clash with each other.
--- drivers/input/serio/i8042.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/serio/i8042.c +1 -0
@@ -1258,6 +1258,7 @@ static int __init i8042_create_aux_port( serio->write = i8042_aux_write; serio->start = i8042_start; serio->stop = i8042_stop; + serio->ps2_cmd_mutex = &i8042_mutex; serio->port_data = port; serio->dev.parent = &i8042_platform_device->dev;if (idx <0 ) {
PATCH 199/346 net/mlx5: Added missing check of msg length in verifying its signature
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Blakey <[email protected]>
commit 2c0f8ce1b584a4d7b8ff53140d21dfed99834940 upstream.
Set and verify signature calculates the signature for each of the mailbox nodes, even for those that are unused (from cache). Added a missing length check to set and verify only those which are used.
While here, also moved the setting of msg's nodes token to where we already go over them. This saves a pass because checksum is disabled, and the only useful thing remaining that set signature does is setting the token.
adapters')
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 85 +++++++++++++++++---------- 1 file changed, 54 insertions(+), 31 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +53 -30
@@ -159,13 +159,14 @@ static struct mlx5_cmd_layout *get_inst(return cmd->cmd_buf + (idx << cmd->log_stride); } -static u8 xor8_buf (void *buf,int len) +static u8 xor8_buf (void *buf,size_t offset,int len) {u8 *ptr = buf;u8 sum =0 ;int i; +int end = len + offset; -for (i =0 ; i < len; i++) +for (i = offset; i < end; i++) sum ^= ptr[i];return sum;
@@ -173,41 +174,49 @@ static u8 xor8_buf(void *buf, int len)static int verify_block_sig (struct mlx5_cmd_prot_block *block) { -if (xor8_buf (block->rsvd0,sizeof (*block) -sizeof (block->data) -1 ) !=0xff ) +size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block , rsvd0); +int xor_len =sizeof (*block) -sizeof (block->data) -1 ; + +if (xor8_buf (block, rsvd0_off, xor_len) !=0xff )return -EINVAL ; -if (xor8_buf (block,sizeof (*block)) !=0xff ) +if (xor8_buf (block,0 ,sizeof (*block)) !=0xff )return -EINVAL ;return 0 ; } -static void calc_block_sig (struct mlx5_cmd_prot_block *block,u8 token, -int csum) +static void calc_block_sig (struct mlx5_cmd_prot_block *block) { - block->token = token; -if (csum) { - block->ctrl_sig = ~xor8_buf (block->rsvd0,sizeof (*block) - -sizeof (block->data) -2 ); - block->sig = ~xor8_buf (block,sizeof (*block) -1 ); - } +int ctrl_xor_len =sizeof (*block) -sizeof (block->data) -2 ; +size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block , rsvd0); + + block->ctrl_sig = ~xor8_buf (block, rsvd0_off, ctrl_xor_len); + block->sig = ~xor8_buf (block,0 ,sizeof (*block) -1 ); } -static void calc_chain_sig (struct mlx5_cmd_msg *msg,u8 token,int csum) +static void calc_chain_sig (struct mlx5_cmd_msg *msg) {struct mlx5_cmd_mailbox *next = msg->next; +int size = msg->len; +int blen = size -min_t (int,sizeof (msg->first.data), size); +int n = (blen +MLX5_CMD_DATA_BLOCK_SIZE -1 ) + /MLX5_CMD_DATA_BLOCK_SIZE ; +int i =0 ; -while (next) { -calc_block_sig (next->buf, token, csum); +for (i =0 ; i < n && next; i++) { +calc_block_sig (next->buf); next = next->next; } }static void set_signature (struct mlx5_cmd_work_ent *ent,int csum) { - ent->lay->sig = ~xor8_buf (ent->lay,sizeof (*ent->lay)); -calc_chain_sig (ent->in, ent->token, csum); -calc_chain_sig (ent->out, ent->token, csum); + ent->lay->sig = ~xor8_buf (ent->lay,0 ,sizeof (*ent->lay)); +if (csum) { +calc_chain_sig (ent->in); +calc_chain_sig (ent->out); + } }static void poll_timeout (struct mlx5_cmd_work_ent *ent)
@@ -238,12 +247,17 @@ static int verify_signature(struct mlx5_struct mlx5_cmd_mailbox *next = ent->out->next;int err;u8 sig; +int size = ent->out->len; +int blen = size -min_t (int,sizeof (ent->out->first.data), size); +int n = (blen +MLX5_CMD_DATA_BLOCK_SIZE -1 ) + /MLX5_CMD_DATA_BLOCK_SIZE ; +int i =0 ; - sig =xor8_buf (ent->lay,sizeof (*ent->lay)); + sig =xor8_buf (ent->lay,0 ,sizeof (*ent->lay));if (sig !=0xff )return -EINVAL ; -while (next) { +for (i =0 ; i < n && next; i++) { err =verify_block_sig (next->buf);if (err)return err;
@@ -555,7 +569,6 @@ static void cmd_work_handler(struct work ent->idx = cmd->max_reg_cmds; } - ent->token =alloc_token (cmd); cmd->ent_arr[ent->idx] = ent; lay =get_inst (cmd, ent->idx); ent->lay = lay;
@@ -654,7 +667,8 @@ static int wait_func(struct mlx5_core_destatic int mlx5_cmd_invoke (struct mlx5_core_dev *dev,struct mlx5_cmd_msg *in,struct mlx5_cmd_msg *out,void *uout,int uout_size,mlx5_cmd_cbk_t callback, -void *context,int page_queue,u8 *status) +void *context,int page_queue,u8 *status, +u8 token) {struct mlx5_cmd *cmd = &dev->cmd;struct mlx5_cmd_work_ent *ent;
@@ -672,6 +686,8 @@ static int mlx5_cmd_invoke(struct mlx5_cif (IS_ERR (ent))return PTR_ERR (ent); + ent->token = token; +if (!callback)init_completion (&ent->done);
@@ -746,7 +762,8 @@ static const struct file_operations fops .write = dbg_write, }; -static int mlx5_copy_to_msg (struct mlx5_cmd_msg *to,void *from,int size) +static int mlx5_copy_to_msg (struct mlx5_cmd_msg *to,void *from,int size, +u8 token) {struct mlx5_cmd_prot_block *block;struct mlx5_cmd_mailbox *next;
@@ -772,6 +789,7 @@ static int mlx5_copy_to_msg(struct mlx5_memcpy (block->data, from, copy); from += copy; size -= copy; + block->token = token; next = next->next; }
@@ -841,7 +859,8 @@ static void free_cmd_box(struct mlx5_cor }static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg (struct mlx5_core_dev *dev, -gfp_t flags,int size) +gfp_t flags,int size, +u8 token) {struct mlx5_cmd_mailbox *tmp, *head =NULL ;struct mlx5_cmd_prot_block *block;
@@ -870,6 +889,7 @@ static struct mlx5_cmd_msg *mlx5_alloc_c tmp->next = head; block->next =cpu_to_be64 (tmp->next ? tmp->next->dma :0 ); block->block_num =cpu_to_be32 (n - i -1 ); + block->token = token; head = tmp; } msg->next = head;
@@ -1239,7 +1259,7 @@ static struct mlx5_cmd_msg *alloc_msg(st }if (IS_ERR (msg)) - msg =mlx5_alloc_cmd_msg (dev, gfp, in_size); + msg =mlx5_alloc_cmd_msg (dev, gfp, in_size,0 );return msg; }
@@ -1258,6 +1278,7 @@ static int cmd_exec(struct mlx5_core_devgfp_t gfp;int err;u8 status =0 ; +u8 token; pages_queue =is_manage_pages (in); gfp = callback ?GFP_ATOMIC :GFP_KERNEL ;
@@ -1268,20 +1289,22 @@ static int cmd_exec(struct mlx5_core_devreturn err; } - err =mlx5_copy_to_msg (inb, in, in_size); + token =alloc_token (&dev->cmd); + + err =mlx5_copy_to_msg (inb, in, in_size, token);if (err) {mlx5_core_warn (dev,"err %d\n" , err); goto out_in; } - outb =mlx5_alloc_cmd_msg (dev, gfp, out_size); + outb =mlx5_alloc_cmd_msg (dev, gfp, out_size, token);if (IS_ERR (outb)) { err =PTR_ERR (outb); goto out_in; } err =mlx5_cmd_invoke (dev, inb, outb, out, out_size, callback, context, - pages_queue, &status); + pages_queue, &status, token);if (err) goto out_out;
@@ -1348,7 +1371,7 @@ static int create_msg_cache(struct mlx5_INIT_LIST_HEAD (&cmd->cache.med.head);for (i =0 ; i <NUM_LONG_LISTS ; i++) { - msg =mlx5_alloc_cmd_msg (dev,GFP_KERNEL ,LONG_LIST_SIZE ); + msg =mlx5_alloc_cmd_msg (dev,GFP_KERNEL ,LONG_LIST_SIZE ,0 );if (IS_ERR (msg)) { err =PTR_ERR (msg); goto ex_err;
@@ -1358,7 +1381,7 @@ static int create_msg_cache(struct mlx5_ }for (i =0 ; i <NUM_MED_LISTS ; i++) { - msg =mlx5_alloc_cmd_msg (dev,GFP_KERNEL ,MED_LIST_SIZE ); + msg =mlx5_alloc_cmd_msg (dev,GFP_KERNEL ,MED_LIST_SIZE ,0 );if (IS_ERR (msg)) { err =PTR_ERR (msg); goto ex_err;
PATCH 200/346 parisc: Fix order of EREFUSED define in errno.h
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 3eb53b20d7bd1374598cfb1feaa081fcac0e76cd upstream.
When building gccgo in userspace, errno.h gets parsed and the go include file sysinfo.go is generated.
Since EREFUSED is defined to the same value as ECONNREFUSED, and ECONNREFUSED is defined later on in errno.h, this leads to go complaining that EREFUSED isn't defined yet.
Fix this trivial problem by moving the define of EREFUSED down after ECONNREFUSED in errno.h (and clean up the indenting while touching this line).
--- arch/parisc/include/uapi/asm/errno.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/parisc/include/uapi/asm/errno.h +2 -2
@@ -97,10 +97,10 @@#define ENOTCONN 235/* Transport endpoint is not connected */ #define ESHUTDOWN 236/* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 237/* Too many references: cannot splice */ -#define EREFUSED ECONNREFUSED/* for HP's NFS apparently */ #define ETIMEDOUT 238/* Connection timed out */ #define ECONNREFUSED 239/* Connection refused */ -#define EREMOTERELEASE 240/* Remote peer released connection */ +#define EREFUSED ECONNREFUSED/* for HP's NFS apparently */ +#define EREMOTERELEASE 240/* Remote peer released connection */ #define EHOSTDOWN 241/* Host is down */ #define EHOSTUNREACH 242/* No route to host */
PATCH 201/346 USB: serial: option: add WeTelecom WM-D200
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Makarov <[email protected]>
commit 6695593e4a7659db49ac6eca98c164f7b5589f72 upstream.
Add support for WeTelecom WM-D200.
T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 4 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=22de ProdID=6801 Rev=00.00 S: Manufacturer=WeTelecom Incorporated S: Product=WeTelecom Mobile Products C: #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 3 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
--- drivers/usb/serial/option.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/option.c +5 -0
@@ -527,6 +527,10 @@ static void option_instat_callback(struc#define VIATELECOM_VENDOR_ID 0x15eb#define VIATELECOM_PRODUCT_CDS7 0x0001 +/* WeTelecom products */ +#define WETELECOM_VENDOR_ID 0x22de +#define WETELECOM_PRODUCT_WMD200 0x6801 +/* some devices interfaces need special handling due to a number of reasons */ enum option_blacklist_reason {OPTION_BLACKLIST_NONE =0 ,
@@ -2002,6 +2006,7 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */ { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, + { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) }, { } /* Terminating entry */ };MODULE_DEVICE_TABLE (usb, option_ids);
PATCH 202/346 staging: comedi: daqboard2000: bug fix board type matching code
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 80e162ee9b31d77d851b10f8c5299132be1e120f upstream.
daqboard2000_find_boardinfo() is supposed to check if the DaqBoard/2000 series model is supported, based on the PCI subvendor and subdevice ID. The current code is wrong as it is comparing the PCI device's subdevice ID to an expected, fixed value for the subvendor ID. It should be comparing the PCI device's subvendor ID to this fixed value. Correct it.
subsystem_device check")
--- drivers/staging/comedi/drivers/daqboard2000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/daqboard2000.c +1 -1
@@ -684,7 +684,7 @@ static const void *daqboard2000_find_boaconst struct daq200_boardtype *board;int i; -if (pcidev->subsystem_device !=PCI_VENDOR_ID_IOTECH ) +if (pcidev->subsystem_vendor !=PCI_VENDOR_ID_IOTECH )return NULL ;for (i =0 ; i <ARRAY_SIZE (boardtypes); i++) {
PATCH 203/346 staging: comedi: ni_mio_common: fix AO inttrig backwards compatibility
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit f0f4b0cc3a8cffd983f5940d46cd0227f3f5710a upstream.
Commit ebb657babfa9 ("staging: comedi: ni_mio_common: clarify the cmd->start_arg validation and use") introduced a backwards compatibility issue in the use of asynchronous commands on the AO subdevice when start_src is TRIG_EXT. Valid values for start_src are TRIG_INT (for internal, software trigger), and TRIG_EXT (for external trigger). When set to TRIG_EXT. In both cases, the driver relies on an internal, software trigger to set things up (allowing the user application to write sufficient samples to the data buffer before the trigger), so it acts as a software "pre-trigger" in the TRIG_EXT case. The software trigger is handled by ni_ao_inttrig().
Prior to the above change, when start_src was TRIG_INT, start_arg was required to be 0, and ni_ao_inttrig() checked that the software trigger number was also 0. After the above change, when start_src was TRIG_INT, any value was allowed for start_arg, and ni_ao_inttrig() checked that the software trigger number matched this start_arg value. The backwards compatibility issue is that the internal trigger number now has to match start_arg when start_src is TRIG_EXT when it previously had to be 0.
Fix the backwards compatibility issue in ni_ao_inttrig() by always allowing software trigger number 0 when start_src is something other than TRIG_INT.
Thanks to Spencer Olson for reporting the issue.
--- drivers/staging/comedi/drivers/ni_mio_common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/ni_mio_common.c +9 -1
@@ -2959,7 +2959,15 @@ static int ni_ao_inttrig(struct comedi_dint i;static const int timeout =1000 ; -if (trig_num != cmd->start_arg) +/* +* Require trig_num == cmd->start_arg when cmd->start_src == TRIG_INT. +* For backwards compatibility, also allow trig_num == 0 when +* cmd->start_src != TRIG_INT (i.e. when cmd->start_src == TRIG_EXT); +* in that case, the internal trigger is being used as a pre-trigger +* before the external trigger. +*/ +if (!(trig_num == cmd->start_arg || + (trig_num ==0 && cmd->start_src !=TRIG_INT )))return -EINVAL ;/* Null trig at beginning prevent ao start trigger from executing more than
PATCH 204/346 iio: adc: ti_am335x_adc: Protect FIFO1 from concurrent access
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh R <[email protected]>
commit 90c43ec6997a892448f1f86180a515f59cafd8a3 upstream.
It is possible that two or more ADC channels can be simultaneously requested for raw samples, in which case there can be race in access to FIFO data resulting in loss of samples.
If am335x_tsc_se_set_once() is called again from tiadc_read_raw(), when ADC is still acquired to sample one of the channels, the second process might be put into uninterruptible sleep state. Fix these issues, by protecting FIFO access and channel configurations with a mutex. Since tiadc_read_raw() might take anywhere between few microseconds to few milliseconds to finish execution (depending on averaging and delay values supplied via DT), its better to use mutex instead of spinlock.
--- drivers/iio/adc/ti_am335x_adc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/iio/adc/ti_am335x_adc.c +11 -3
@@ -32,6 +32,7 @@struct tiadc_device {struct ti_tscadc_dev *mfd_tscadc; +struct mutex fifo1_lock;/* to protect fifo access */ int channels;u8 channel_line[8 ];u8 channel_step[8 ];
@@ -341,6 +342,7 @@ static int tiadc_read_raw(struct iio_dev int *val, int *val2, long mask) { struct tiadc_device *adc_dev = iio_priv(indio_dev); +int ret =IIO_VAL_INT ;int i, map_val;unsigned int fifo1count, read, stepid;bool found = false;
@@ -354,6 +356,7 @@ static int tiadc_read_raw(struct iio_devif (!step_en)return -EINVAL ; +mutex_lock (&adc_dev->fifo1_lock); fifo1count =tiadc_readl (adc_dev,REG_FIFO1CNT );while (fifo1count--)tiadc_readl (adc_dev,REG_FIFO1 );
@@ -370,7 +373,8 @@ static int tiadc_read_raw(struct iio_devif (time_after (jiffies, timeout)) {am335x_tsc_se_adc_done (adc_dev->mfd_tscadc); -return -EAGAIN ; + ret = -EAGAIN ; + goto err_unlock; } } map_val = adc_dev->channel_step[chan->scan_index];
@@ -396,8 +400,11 @@ static int tiadc_read_raw(struct iio_devam335x_tsc_se_adc_done (adc_dev->mfd_tscadc);if (found == false) -return -EBUSY ; -return IIO_VAL_INT ; + ret = -EBUSY ; + +err_unlock: +mutex_unlock (&adc_dev->fifo1_lock); +return ret; }static const struct iio_info tiadc_info = {
@@ -444,6 +451,7 @@ static int tiadc_probe(struct platform_dtiadc_step_config (indio_dev);tiadc_writel (adc_dev,REG_FIFO1THR ,FIFO1_THRESHOLD ); +mutex_init (&adc_dev->fifo1_lock); err =tiadc_channel_init (indio_dev, adc_dev->channels);if (err <0 )
PATCH 205/346 iio: accel: kxsd9: Fix raw read return
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit 7ac61a062f3147dc23e3f12b9dfe7c4dd35f9cb8 upstream.
Any readings from the raw interface of the KXSD9 driver will return an empty string, because it does not return IIO_VAL_INT but rather some random value from the accelerometer to the caller.
--- drivers/iio/accel/kxsd9.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/kxsd9.c +1 -0
@@ -160,6 +160,7 @@ static int kxsd9_read_raw(struct iio_devif (ret <0 ) goto error_ret; *val = ret; + ret =IIO_VAL_INT ;break ;case IIO_CHAN_INFO_SCALE : ret =spi_w8r8 (st->us,KXSD9_READ (KXSD9_REG_CTRL_C ));
PATCH 206/346 powerpc/pseries: use pci_host_bridge.release_fn() to kfree(phb)
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mauricio Faria de Oliveira <[email protected]>
commit 2dd9c11b9d4dfbd6c070eab7b81197f65e82f1a0 upstream.
This patch leverages 'struct pci_host_bridge' from the PCI subsystem in order to free the pci_controller only after the last reference to its devices is dropped (avoiding an oops in pcibios_release_device() if the last reference is dropped after pcibios_free_controller()).
The patch relies on pci_host_bridge.release_fn() (and .release_data), which is called automatically by the PCI subsystem when the root bus is released (i.e., the last reference is dropped). Those fields are set via pci_set_host_bridge_release() (e.g. in the platform-specific implementation of pcibios_root_bridge_prepare()).
It introduces the 'pcibios_free_controller_deferred()' .release_fn() and it expects .release_data to hold a pointer to the pci_controller.
The function implictly calls 'pcibios_free_controller()', so an user must *NOT* explicitly call it if using the new _deferred() callback.
The functionality is enabled for pseries (although it isn't platform specific, and may be used by cxl).
Details on not-so-elegant design choices:
- Use 'pci_host_bridge.release_data' field as pointer to associated 'struct pci_controller' so *not* to 'pci_bus_to_host(bridge->bus)' in pcibios_free_controller_deferred().
That's because pci_remove_root_bus() sets 'host_bridge->bus = NULL' (so, if the last reference is released after pci_remove_root_bus() runs, which eventually reaches pcibios_free_controller_deferred(), that would hit a null pointer dereference).
The cxl/vphb.c code calls pci_remove_root_bus(), and the cxl folks are interested in this fix.
Test-case #1 (hold references)
# ls -ld /sys/block/sd* | grep -m1 0021:01:00.0 <...> /sys/block/sdaa -> ../devices/pci0021:01/0021:01:00.0/<...>
# ls -ld /sys/block/sd* | grep -m1 0021:01:00.1 <...> /sys/block/sdab -> ../devices/pci0021:01/0021:01:00.1/<...>
# cat >/dev/sdaa & pid1=$! # cat >/dev/sdab & pid2=$!
# drmgr -w 5 -d 1 -c phb -s 'PHB 33' -r Validating PHB DLPAR capability...yes. [ 594.306719] pci_hp_remove_devices: PCI: Removing devices on bus 0021:01 [ 594.306738] pci_hp_remove_devices: Removing 0021:01:00.0... ... [ 598.236381] pci_hp_remove_devices: Removing 0021:01:00.1... ... [ 611.972077] pci_bus 0021:01: busn_res: [bus 01-ff] is released [ 611.972140] rpadlpar_io: slot PHB 33 removed
# kill -9 $pid1 # kill -9 $pid2 [ 632.918088] pcibios_free_controller_deferred: domain 33, dynamic 1
Test-case #2 (don't hold references)
# drmgr -w 5 -d 1 -c phb -s 'PHB 33' -r Validating PHB DLPAR capability...yes. [ 916.357363] pci_hp_remove_devices: PCI: Removing devices on bus 0021:01 [ 916.357386] pci_hp_remove_devices: Removing 0021:01:00.0... ... [ 920.566527] pci_hp_remove_devices: Removing 0021:01:00.1... ... [ 933.955873] pci_bus 0021:01: busn_res: [bus 01-ff] is released [ 933.955977] pcibios_free_controller_deferred: domain 33, dynamic 1 [ 933.955999] rpadlpar_io: slot PHB 33 removed
--- arch/powerpc/include/asm/pci-bridge.h | 1 + arch/powerpc/kernel/pci-common.c | 36 ++++++++++++++++++++++++++++++ arch/powerpc/platforms/pseries/pci.c | 4 ++++ arch/powerpc/platforms/pseries/pci_dlpar.c | 7 ++++-- 4 files changed, 46 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +1 -0
@@ -246,6 +246,7 @@ extern void pci_process_bridge_OF_ranges/* Allocate & free a PCI host bridge structure */ extern struct pci_controller *pcibios_alloc_controller (struct device_node *dev);extern void pcibios_free_controller (struct pci_controller *phb); +extern void pcibios_free_controller_deferred (struct pci_host_bridge *bridge);#ifdef CONFIG_PCI extern int pcibios_vaddr_is_ioport (void __iomem *address);
arch/powerpc/kernel/pci-common.c +36 -0
@@ -102,6 +102,42 @@ void pcibios_free_controller(struct pci_ }/* +* This function is used to call pcibios_free_controller() +* in a deferred manner: a callback from the PCI subsystem. +* +* _*DO NOT*_ call pcibios_free_controller() explicitly if +* this is used (or it may access an invalid *phb pointer). +* +* The callback occurs when all references to the root bus +* are dropped (e.g., child buses/devices and their users). +* +* It's called as .release_fn() of 'struct pci_host_bridge' +* which is associated with the 'struct pci_controller.bus' +* (root bus) - it expects .release_data to hold a pointer +* to 'struct pci_controller'. +* +* In order to use it, register .release_fn()/release_data +* like this: +* +* pci_set_host_bridge_release(bridge, +* pcibios_free_controller_deferred +* (void *) phb); +* +* e.g. in the pcibios_root_bridge_prepare() callback from +* pci_create_root_bus(). +*/ +void pcibios_free_controller_deferred (struct pci_host_bridge *bridge) +{ +struct pci_controller *phb = (struct pci_controller *) + bridge->release_data; + +pr_debug ("domain %d, dynamic %d\n" , phb->global_number, phb->is_dynamic); + +pcibios_free_controller (phb); +} +EXPORT_SYMBOL_GPL (pcibios_free_controller_deferred); + +/* * The function is used to return the minimal alignment * for memory or I/O windows of the associated P2P bridge. * By default, 4KiB alignment for I/O windows and 1MiB for
arch/powerpc/platforms/pseries/pci.c +4 -0
@@ -118,6 +118,10 @@ int pseries_root_bridge_prepare(struct p bus = bridge->bus; +/* Rely on the pcibios_free_controller_deferred() callback. */ +pci_set_host_bridge_release (bridge, pcibios_free_controller_deferred, + (void *)pci_bus_to_host (bus)); + dn =pcibios_get_phb_of_node (bus);if (!dn)return 0 ;
arch/powerpc/platforms/pseries/pci_dlpar.c +5 -2
@@ -135,8 +135,11 @@ int remove_phb_dynamic(struct pci_controrelease_resource (res); } -/* Free pci_controller data structure */ -pcibios_free_controller (phb); +/* +* The pci_controller data structure is freed by +* the pcibios_free_controller_deferred() callback; +* see pseries_root_bridge_prepare(). +*/ return 0 ; }
PATCH 207/346 powerpc/prom: Fix sub-processor option passed to ibm, client-architecture-support
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit 66443efa83dc73775100b7442962ce2cb0d4472e upstream.
When booting from an OpenFirmware which supports it, we use the "ibm,client-architecture-support" firmware call to communicate our capabilities to firmware.
The format of the structure we pass to firmware is specified in PAPR (Power Architecture Platform Requirements), or the public version LoPAPR (Linux on Power Architecture Platform Reference).
Referring to table 244 in LoPAPR v1.1, option vector 5 contains a 4 byte field at bytes 17-20 for the "Platform Facilities Enable". This is followed by a 1 byte field at byte 21 for "Sub-Processor Represenation Level".
Comparing to the code, there we have the Platform Facilities options (OV5_PFO_*) at byte 17, but we fail to pad that field out to its full width of 4 bytes. This means the OV5_SUB_PROCESSORS option is incorrectly placed at byte 18.
Fix it by adding zero bytes for bytes 18, 19, 20, and comment the bytes to hopefully make it clearer in future.
As far as I'm aware nothing actually consumes this value at this time, so the effect of this bug is nil in practice.
It does mean we've been incorrectly setting bit 15 of the "Platform Facilities Enable" option for the past ~3 1/2 years, so we should avoid allocating that bit to anything else in future.
[bwh: Backported to 3.16:
- Adjust context
- Length calculations don't use VECTOR_LENGTH()]
--- arch/powerpc/kernel/prom_init.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/powerpc/kernel/prom_init.c +6 -3
@@ -685,7 +685,7 @@ unsigned char ibm_architecture_vec[] = {OV4_MIN_ENT_CAP ,/* minimum VP entitled capacity */ /* option vector 5: PAPR/OF options */ -19 -2 ,/* length */ +22 -2 ,/* length */ 0 ,/* don't ignore, don't halt */ OV5_FEAT (OV5_LPAR ) |OV5_FEAT (OV5_SPLPAR ) |OV5_FEAT (OV5_LARGE_PAGES ) | OV5_FEAT(OV5_DRCONF_MEMORY) | OV5_FEAT(OV5_DONATE_DEDICATE_CPU) |
@@ -716,8 +716,11 @@ unsigned char ibm_architecture_vec[] = {0 ,0 ,OV5_FEAT (OV5_PFO_HW_RNG ) |OV5_FEAT (OV5_PFO_HW_ENCR ) | -OV5_FEAT (OV5_PFO_HW_842 ), -OV5_FEAT (OV5_SUB_PROCESSORS ), +OV5_FEAT (OV5_PFO_HW_842 ),/* Byte 17 */ +0 ,/* Byte 18 */ +0 ,/* Byte 19 */ +0 ,/* Byte 20 */ +OV5_FEAT (OV5_SUB_PROCESSORS ),/* Byte 21 */ /* option vector 6: IBM PAPR hints */ 4 -2 ,/* length */ 0,
PATCH 208/346 drm: Reject page_flip for !DRIVER_MODESET
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Vetter <[email protected]>
commit 6f00975c619064a18c23fd3aced325ae165a73b9 upstream.
Somehow this one slipped through, which means drivers without modeset support can be oopsed (since those also don't call drm_mode_config_init, which means the crtc lookup will chase an uninitalized idr).
--- drivers/gpu/drm/drm_crtc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_crtc.c +3 -0
@@ -4236,6 +4236,9 @@ int drm_mode_page_flip_ioctl(struct drm_unsigned long flags;int ret = -EINVAL ; +if (!drm_core_check_feature (dev,DRIVER_MODESET )) +return -EINVAL ; +if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS || page_flip->reserved !=0 )return -EINVAL ;
PATCH 209/346 usb: gadget: fsl_qe_udc: signedness bug in qe_get_frame()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit f4693b08cc901912a87369c46537b94ed4084ea0 upstream.
We can't assign -EINVAL to a u16.
--- drivers/usb/gadget/fsl_qe_udc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/gadget/fsl_qe_udc.c +2 -5
@@ -1881,11 +1881,8 @@ static int qe_get_frame(struct usb_gadge tmp =in_be16 (&udc->usb_param->frame_n);if (tmp &0x8000 ) - tmp = tmp &0x07ff ; -else - tmp = -EINVAL ; - -return (int )tmp; +return tmp &0x07ff ; +return -EINVAL ; } static int fsl_qe_start(struct usb_gadget *gadget,
PATCH 210/346 Input: tegra-kbc - fix inverted reset logic
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
commit fae16989be77b09bab86c79233e4b511ea769cea upstream.
Commit fe6b0dfaba68 ("Input: tegra-kbc - use reset framework") accidentally converted _deassert to _assert, so there is no code to wake up this hardware.
--- drivers/input/keyboard/tegra-kbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/tegra-kbc.c +1 -1
@@ -376,7 +376,7 @@ static int tegra_kbc_start(struct tegra_/* Reset the KBC controller to clear all previous status.*/ reset_control_assert (kbc->rst);udelay (100 ); -reset_control_assert (kbc->rst); +reset_control_deassert (kbc->rst);udelay (100 );tegra_kbc_config_pins (kbc);
PATCH 211/346 USB: fix typo in wMaxPacketSize validation
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 6c73358c83ce870c0cf32413e5cadb3b9a39c606 upstream.
The maximum value allowed for wMaxPacketSize of a high-speed interrupt endpoint is 1024 bytes, not 1023.
--- drivers/usb/core/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/config.c +1 -1
@@ -158,7 +158,7 @@ static const unsigned short high_speed_m [USB_ENDPOINT_XFER_CONTROL] = 64, [USB_ENDPOINT_XFER_ISOC] = 1024, [USB_ENDPOINT_XFER_BULK] = 512, - [USB_ENDPOINT_XFER_INT] = 1023, + [USB_ENDPOINT_XFER_INT] = 1024, };static const unsigned short super_speed_maxpacket_maxes[4 ] = { [USB_ENDPOINT_XFER_CONTROL ] =512 ,
PATCH 212/346 ASoC: omap-mcpdm: Fix irq resource handling
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit a8719670687c46ed2e904c0d05fa4cd7e4950cd1 upstream.
Managed irq request will not doing any good in ASoC probe level as it is not going to free up the irq when the driver is unbound from the sound card.
--- sound/soc/omap/omap-mcpdm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/omap/omap-mcpdm.c +3 -2
@@ -390,8 +390,8 @@ static int omap_mcpdm_probe(struct snd_spm_runtime_get_sync (mcpdm->dev);omap_mcpdm_write (mcpdm,MCPDM_REG_CTRL ,0x00 ); - ret =devm_request_irq (mcpdm->dev, mcpdm->irq, omap_mcpdm_irq_handler, -0 ,"McPDM" , (void *)mcpdm); + ret =request_irq (mcpdm->irq, omap_mcpdm_irq_handler,0 ,"McPDM" , + (void *)mcpdm);pm_runtime_put_sync (mcpdm->dev);
@@ -416,6 +416,7 @@ static int omap_mcpdm_remove(struct snd_ {struct omap_mcpdm *mcpdm =snd_soc_dai_get_drvdata (dai); +free_irq (mcpdm->irq, (void *)mcpdm);pm_runtime_disable (mcpdm->dev);return 0 ;
PATCH 213/346 USB: avoid left shift by -1
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 53e5f36fbd2453ad69a3369a1db62dc06c30a4aa upstream.
UBSAN complains about a left shift by -1 in proc_do_submiturb(). This can occur when an URB is submitted for a bulk or control endpoint on a high-speed device, since the code doesn't bother to check the endpoint type; normally only interrupt or isochronous endpoints have a nonzero bInterval value.
Aside from the fact that the operation is illegal, it shouldn't matter because the result isn't used. Still, in theory it could cause a hardware exception or other problem, so we should work around it. This patch avoids doing the left shift unless the shift amount is >= 0.
The same piece of code has another problem. When checking the device speed (the exponential encoding for interrupt endpoints is used only by high-speed or faster devices), we need to look for speed >= USB_SPEED_SUPER as well as speed == USB_SPEED HIGH. The patch adds this check.
--- drivers/usb/core/devio.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/usb/core/devio.c +11 -5
@@ -1527,11 +1527,17 @@ static int proc_do_submiturb(struct usb_ as->urb->start_frame = uurb->start_frame; as->urb->number_of_packets = number_of_packets; as->urb->stream_id = stream_id; -if (uurb->type ==USBDEVFS_URB_TYPE_ISO || - ps->dev->speed ==USB_SPEED_HIGH ) - as->urb->interval =1 <<min (15 , ep->desc.bInterval -1 ); -else - as->urb->interval = ep->desc.bInterval; + +if (ep->desc.bInterval) { +if (uurb->type ==USBDEVFS_URB_TYPE_ISO || + ps->dev->speed ==USB_SPEED_HIGH || + ps->dev->speed >=USB_SPEED_SUPER ) + as->urb->interval =1 << +min (15 , ep->desc.bInterval -1 ); +else + as->urb->interval = ep->desc.bInterval; + } + as->urb->context = as; as->urb->complete = async_completed;for (totlen = u =0 ; u < number_of_packets; u++) {
PATCH 214/346 ubifs: Fix assertion in layout_in_gaps()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Stehlé <[email protected]>
commit c0082e985fdf77b02fc9e0dac3b58504dcf11b7a upstream.
An assertion in layout_in_gaps() verifies that the gap_lebs pointer is below the maximum bound. When computing this maximum bound the idx_lebs count is multiplied by sizeof(int), while C pointers arithmetic does take into account the size of the pointed elements implicitly already. Remove the multiplication to fix the assertion.
--- fs/ubifs/tnc_commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ubifs/tnc_commit.c +1 -1
@@ -370,7 +370,7 @@ static int layout_in_gaps(struct ubifs_i p = c->gap_lebs; do { - ubifs_assert(p < c->gap_lebs + sizeof(int) * c->lst.idx_lebs); + ubifs_assert(p < c->gap_lebs + c->lst.idx_lebs); written = layout_leb_in_gaps(c, p); if (written < 0) { err = written;
PATCH 215/346 tun: fix transmit timestamp support
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Soheil Hassas Yeganeh <[email protected]>
commit 7b996243fab46092fb3a29c773c54be8152366e4 upstream.
Instead of using sock_tx_timestamp, use skb_tx_timestamp to record software transmit timestamp of a packet.
sock_tx_timestamp resets and overrides the tx_flags of the skb. The function is intended to be called from within the protocol layer when creating the skb, not from a device driver. This is inconsistent with other drivers and will cause issues for TCP.
In TCP, we intend to sample the timestamps for the last byte for each sendmsg/sendpage. For that reason, tcp_sendmsg calls tcp_tx_timestamp only with the last skb that it generates. For example, if a 128KB message is split into two 64KB packets we want to sample the SND timestamp of the last packet. The current code in the tun driver, however, will result in sampling the SND timestamp for both packets.
Also, when the last packet is split into smaller packets for retranmission (see tcp_fragment), the tun driver will record timestamps for all of the retransmitted packets and not only the last packet.
--- drivers/net/tun.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/tun.c +1 -4
@@ -794,10 +794,7 @@ static netdev_tx_t tun_net_xmit(struct sif (unlikely (skb_orphan_frags (skb,GFP_ATOMIC ))) goto drop; -if (skb->sk) { -sock_tx_timestamp (skb->sk, &skb_shinfo (skb)->tx_flags); -sw_tx_timestamp (skb); - } +skb_tx_timestamp (skb);/* Orphan the skb - required as we might hang on to it * for indefinite time.
PATCH 216/346 timekeeping: Cap array access in timekeeping_debug
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: John Stultz <[email protected]>
commit a4f8f6667f099036c88f231dcad4cf233652c824 upstream.
It was reported that hibernation could fail on the 2nd attempt, where the system hangs at hibernate() -> syscore_resume() -> i8237A_resume() -> claim_dma_lock(), because the lock has already been taken.
However there is actually no other process would like to grab this lock on that problematic platform.
Further investigation showed that the problem is triggered by setting /sys/power/pm_trace to 1 before the 1st hibernation.
Since once pm_trace is enabled, the rtc becomes unmeaningful after suspend, and meanwhile some BIOSes would like to adjust the 'invalid' RTC (e.g, smaller than 1970) to the release date of that motherboard during POST stage, thus after resumed, it may seem that the system had a significant long sleep time which is a completely meaningless value.
Then in timekeeping_resume -> tk_debug_account_sleep_time, if the bit31 of the sleep time happened to be set to 1, fls() returns 32 and we add 1 to sleep_time_bin[32], which causes an out of bounds array access and therefor memory being overwritten.
As depicted by System.map:0xffffffff81c9d080 b sleep_time_bin 0xffffffff81c9d100 B dma_spin_lock
the dma_spin_lock.val is set to 1, which caused this problem.
This patch adds a sanity check in tk_debug_account_sleep_time() to ensure we don't index past the sleep_time_bin array.
[jstultz: Problem diagnosed and original patch by Chen Yu, I've solved the
issue slightly differently, but borrowed his excelent explanation of the issue here.]
--- kernel/time/timekeeping_debug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/time/timekeeping_debug.c +7 -2
@@ -23,7 +23,9 @@#include "timekeeping_internal.h" -static unsigned int sleep_time_bin[32 ] = {0 }; +#define NUM_BINS 32 + +static unsigned int sleep_time_bin[NUM_BINS ] = {0 };static int tk_debug_show_sleep_time (struct seq_file *s,void *data) {
@@ -69,6 +71,9 @@ late_initcall(tk_debug_sleep_time_init);void tk_debug_account_sleep_time (struct timespec *t) { - sleep_time_bin[fls (t->tv_sec)]++; +/* Cap bin index so we don't overflow the array */ +int bin =min (fls (t->tv_sec),NUM_BINS -1 ); + + sleep_time_bin[bin]++; }
PATCH 217/346 x86/apic: Do not init irq remapping if ioapic is disabled
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wanpeng Li <[email protected]>
commit 2e63ad4bd5dd583871e6602f9d398b9322d358d9 upstream.
native_smp_prepare_cpus
-> default_setup_apic_routing
-> enable_IR_x2apic
-> irq_remapping_prepare
-> intel_prepare_irq_remapping
-> intel_setup_irq_remappingSo IR table is setup even if "noapic" boot parameter is added. As a result we crash later when the interrupt affinity is set due to a half initialized remapping infrastructure.
Prevent remap initialization when IOAPIC is disabled.
--- arch/x86/kernel/apic/apic.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/apic/apic.c +3 -0
@@ -1615,6 +1615,9 @@ void __init enable_IR_x2apic(void)int ret, x2apic_enabled =0 ;int hardware_init_ret; +if (skip_ioapic_setup) +return ; +/* Make sure irq_remap_ops are initialized */ setup_irq_remapping_ops ();
PATCH 218/346 USB: serial: option: add WeTelecom 0x6802 and 0x6803 products
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Makarov <[email protected]>
commit 40d9c32525cba79130612650b1abc47c0c0f19a8 upstream.
These product IDs are listed in Windows driver.0x6803 corresponds to WeTelecom WM-D300.0x6802 name is unknown.
--- drivers/usb/serial/option.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/option.c +4 -0
@@ -530,6 +530,8 @@ static void option_instat_callback(struc/* WeTelecom products */ #define WETELECOM_VENDOR_ID 0x22de#define WETELECOM_PRODUCT_WMD200 0x6801 +#define WETELECOM_PRODUCT_6802 0x6802 +#define WETELECOM_PRODUCT_WMD300 0x6803/* some devices interfaces need special handling due to a number of reasons */ enum option_blacklist_reason {
@@ -2007,6 +2009,8 @@ static const struct usb_device_id option { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_6802, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD300, 0xff, 0xff, 0xff) }, { } /* Terminating entry */ };MODULE_DEVICE_TABLE (usb, option_ids);
PATCH 219/346 usb: gadget: udc: core: don't starve DMA resources
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit 23fd537c9508fb6e3b93ddf23982f51afc087781 upstream.
Always unmap all SG entries as required by DMA API
--- drivers/usb/gadget/udc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc-core.c +1 -1
@@ -91,7 +91,7 @@ void usb_gadget_unmap_request(struct usbreturn ;if (req->num_mapped_sgs) { -dma_unmap_sg (&gadget->dev, req->sg, req->num_mapped_sgs, +dma_unmap_sg (&gadget->dev, req->sg, req->num_sgs, is_in ?DMA_TO_DEVICE :DMA_FROM_DEVICE ); req->num_mapped_sgs =0 ;
PATCH 220/346 qdisc: fix a module refcount leak in qdisc_create_dflt()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 166ee5b87866de07a3e56c1b757f2b5cabba72a5 upstream.
Should qdisc_alloc() fail, we must release the module refcount we got right before.
--- net/sched/sch_generic.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/sched/sch_generic.c +5 -4
@@ -590,18 +590,19 @@ struct Qdisc *qdisc_create_dflt(struct nstruct Qdisc *sch;if (!try_module_get (ops->owner)) - goto errout; +return NULL ; sch =qdisc_alloc (dev_queue, ops); -if (IS_ERR (sch)) - goto errout; +if (IS_ERR (sch)) { +module_put (ops->owner); +return NULL ; + } sch->parent = parentid;if (!ops->init || ops->init (sch,NULL ) ==0 )return sch;qdisc_destroy (sch); -errout:return NULL ; }EXPORT_SYMBOL (qdisc_create_dflt);
PATCH 221/346 ARM: kirkwood: ib62x0: fix size of u-boot environment partition
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Simon Baatz <[email protected]>
commit a778937888867aac17a33887d1c429120790fbc2 upstream.
Commit 148c274ea644 ("ARM: kirkwood: ib62x0: add u-boot environment partition") split the "u-boot" partition into "u-boot" and "u-boot environment". However, instead of the size of the environment, an offset was given, resulting in overlapping partitions.
--- arch/arm/boot/dts/kirkwood-ib62x0.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/kirkwood-ib62x0.dts +1 -1
@@ -113,7 +113,7 @@ partition@e0000 { label = "u-boot environment"; - reg = <0xe0000 0x100000>; + reg = <0xe0000 0x20000>; }; partition@100000 {
PATCH 222/346 batman-adv: Add missing refcnt for last_candidate
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 936523441bb64cdc9a5b263e8fd2782e70313a57 upstream.
batadv_find_router dereferences last_bonding_candidate from orig_node without making sure that it has a valid reference. This reference has to be retrieved by increasing the reference counter while holding neigh_list_lock. The lock is required to avoid that batadv_last_bonding_replace removes the current last_bonding_candidate, reduces the reference counter and maybe destroys the object in this process.
[bwh: Backported to 3.16:
- s/kref_get/atomic_inc/
- s/_put/_free_ref/]
--- net/batman-adv/routing.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
net/batman-adv/routing.c +27 -1
@@ -425,6 +425,29 @@ static int batadv_check_unicast_packet(s }/** +* batadv_last_bonding_get - Get last_bonding_candidate of orig_node +* @orig_node: originator node whose last bonding candidate should be retrieved +* +* Return: last bonding candidate of router or NULL if not found +* +* The object is returned with refcounter increased by 1. +*/ +static struct batadv_orig_ifinfo * +batadv_last_bonding_get (struct batadv_orig_node *orig_node) +{ +struct batadv_orig_ifinfo *last_bonding_candidate; + +spin_lock_bh (&orig_node->neigh_list_lock); + last_bonding_candidate = orig_node->last_bonding_candidate; + +if (last_bonding_candidate) +atomic_inc (&last_bonding_candidate->refcount); +spin_unlock_bh (&orig_node->neigh_list_lock); + +return last_bonding_candidate; +} + +/** * batadv_last_bonding_replace - Replace last_bonding_candidate of orig_node * @orig_node: originator node whose bonding candidates should be replaced * @new_candidate: new bonding candidate or NULL
@@ -492,7 +515,7 @@ batadv_find_router(struct batadv_priv *b* router - obviously there are no other candidates. */ rcu_read_lock (); - last_candidate = orig_node->last_bonding_candidate; + last_candidate =batadv_last_bonding_get (orig_node);if (last_candidate) last_cand_router =rcu_dereference (last_candidate->router);
@@ -584,6 +607,9 @@ next:batadv_orig_ifinfo_free_ref (next_candidate); } +if (last_candidate) +batadv_orig_ifinfo_free_ref (last_candidate); +return router; }
PATCH 223/346 clocksource/drivers/sun4i: Clear interrupts after stopping timer in probe function
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
commit b53e7d000d9e6e9fd2c6eb6b82d2783c67fd599e upstream.
The bootloader (U-boot) sometimes uses this timer for various delays. It uses it as a ongoing counter, and does comparisons on the current counter value. The timer counter is never stopped.
In some cases when the user interacts with the bootloader, or lets it idle for some time before loading Linux, the timer may expire, and an interrupt will be pending. This results in an unexpected interrupt when the timer interrupt is enabled by the kernel, at which point the event_handler isn't set yet. This results in a NULL pointer dereference exception, panic, and no way to reboot.
Clear any pending interrupts after we stop the timer in the probe function to avoid this.
--- drivers/clocksource/sun4i_timer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clocksource/sun4i_timer.c +8 -1
@@ -120,12 +120,16 @@ static struct clock_event_device sun4i_c .set_next_event = sun4i_clkevt_next_event, }; +static void sun4i_timer_clear_interrupt (void ) +{ +writel (TIMER_IRQ_EN (0 ), timer_base +TIMER_IRQ_ST_REG ); +}static irqreturn_t sun4i_timer_interrupt (int irq,void *dev_id) {struct clock_event_device *evt = (struct clock_event_device *)dev_id; -writel (0x1 , timer_base +TIMER_IRQ_ST_REG ); +sun4i_timer_clear_interrupt (); evt->event_handler (evt);return IRQ_HANDLED ;
@@ -182,6 +186,9 @@ static void __init sun4i_timer_init(stru/* Make sure timer is stopped before playing with interrupts */ sun4i_clkevt_time_stop (0 ); +/* clear timer0 interrupt */ +sun4i_timer_clear_interrupt (); + sun4i_clockevent.cpumask = cpu_possible_mask; sun4i_clockevent.irq = irq;
PATCH 224/346 ARM: sa1100: clear reset status prior to reboot
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
commit da60626e7d02a4f385cae80e450afc8b07035368 upstream.
Clear the current reset status prior to rebooting the platform. This adds the bit missing from 04fef228fb00 ("[ARM] pxa: introduce reset_status and clear_reset_status for driver's usage").
--- arch/arm/mach-sa1100/generic.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-sa1100/generic.c +3 -0
@@ -31,6 +31,7 @@#include <mach/hardware.h> #include <mach/irqs.h> +#include <mach/reset.h> #include "generic.h"
@@ -91,6 +92,8 @@ static void sa1100_power_off(void)void sa11x0_restart (enum reboot_mode mode,const char *cmd) { +clear_reset_status (RESET_STATUS_ALL ); +if (mode ==REBOOT_SOFT ) {/* Jump into ROM at address 0 */ soft_restart (0 );
PATCH 225/346 printk: fix parsing of "brl=" option
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Iooss <[email protected]>
commit ae6c33ba6e37eea3012fe2640b22400ef3f2d0f3 upstream.
Commit bbeddf52adc1 ("printk: move braille console support into separate braille.[ch] files") moved the parsing of braille-related options into _braille_console_setup(), changing the type of variable str from char* to char**. In this commit, memcmp(str, "brl,", 4) was correctly updated to memcmp(*str, "brl,", 4) but not memcmp(str, "brl=", 4).
Update the code to make "brl=" option work again and replace memcmp() with strncmp() to make the compiler able to detect such an issue.
--- kernel/printk/braille.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/printk/braille.c +2 -2
@@ -9,10 +9,10 @@char *_braille_console_setup (char **str,char **brl_options) { -if (!memcmp (*str,"brl," ,4 )) { +if (!strncmp (*str,"brl," ,4 )) { *brl_options ="" ; *str +=4 ; - }else if (!memcmp (str,"brl=" ,4 )) { + }else if (!strncmp (*str,"brl=" ,4 )) { *brl_options = *str +4 ; *str =strchr (*brl_options,',' );if (!*str)
PATCH 226/346 fs/seq_file: fix out-of-bounds read
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vegard Nossum <[email protected]>
commit 088bf2ff5d12e2e32ee52a4024fec26e582f44d3 upstream.
seq_read() is a nasty piece of work, not to mention buggy.
It has (I think) an old bug which allows unprivileged userspace to read beyond the end of m->buf.
I was getting these:
BUG: KASAN: slab-out-of-bounds in seq_read+0xcd2/0x1480 at addr ffff880116889880
Read of size 2713 by task trinity-c2/1329
CPU: 2 PID: 1329 Comm: trinity-c2 Not tainted 4.8.0-rc1+ #96
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
Call Trace:
kasan_object_err+0x1c/0x80
kasan_report_error+0x2cb/0x7e0
kasan_report+0x4e/0x80
check_memory_region+0x13e/0x1a0
kasan_check_read+0x11/0x20
seq_read+0xcd2/0x1480
proc_reg_read+0x10b/0x260
do_loop_readv_writev.part.5+0x140/0x2c0
do_readv_writev+0x589/0x860
vfs_readv+0x7b/0xd0
do_readv+0xd8/0x2c0
SyS_readv+0xb/0x10
do_syscall_64+0x1b3/0x4b0
entry_SYSCALL64_slow_path+0x25/0x25
Object at ffff880116889100, in cache kmalloc-4096 size: 4096
Allocated:
PID = 1329
save_stack_trace+0x26/0x80
save_stack+0x46/0xd0
kasan_kmalloc+0xad/0xe0
__kmalloc+0x1aa/0x4a0
seq_buf_alloc+0x35/0x40
seq_read+0x7d8/0x1480
proc_reg_read+0x10b/0x260
do_loop_readv_writev.part.5+0x140/0x2c0
do_readv_writev+0x589/0x860
vfs_readv+0x7b/0xd0
do_readv+0xd8/0x2c0
SyS_readv+0xb/0x10
do_syscall_64+0x1b3/0x4b0
return_from_SYSCALL_64+0x0/0x6a
Freed:
PID = 0
(stack is not available)
Memory state around the buggy address:
ffff88011688a000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88011688a080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88011688a100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff88011688a180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88011688a200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Disabling lock debugging due to kernel taintThis seems to be the same thing that Dave Jones was seeing here:
https://lkml.org/lkml/2016/8/12/334
There are multiple issues here:
1) If we enter the function with a non-empty buffer, there is an attempt to flush it. But it was not clearing m->from after doing so, which means that if we try to do this flush twice in a row without any call to traverse() in between, we are going to be reading from the wrong place -- the splat above, fixed by this patch.
2) If there's a short write to userspace because of page faults, the buffer may already contain multiple lines (i.e. pos has advanced by more than 1), but we don't save the progress that was made so the next call will output what we've already returned previously. Since that is a much less serious issue (and I have a headache after staring at seq_read() for the past 8 hours), I'll leave that for now.
--- fs/seq_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/seq_file.c +3 -1
@@ -219,8 +219,10 @@ ssize_t seq_read(struct file *file, char size -= n; buf += n; copied += n; -if (!m->count) +if (!m->count) { + m->from =0 ; m->index++; + }if (!size) goto Done; }
PATCH 227/346 drm/msm: use mutex_lock_interruptible for submit ioctl
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <[email protected]>
commit b5b4c264df4d270819676b290cef9a11d04c35f0 upstream.
Be kinder to things that do lots of signal handling (ie. Xorg)
---
drivers/gpu/drm/msm/msm_gem_submit.c +5 -2
@@ -339,12 +339,14 @@ int msm_ioctl_gem_submit(struct drm_deviif (args->nr_cmds >MAX_CMDS )return -EINVAL ; -mutex_lock (&dev->struct_mutex); + ret =mutex_lock_interruptible (&dev->struct_mutex); +if (ret) +return ret; submit =submit_create (dev, gpu, args->nr_bos);if (!submit) { ret = -ENOMEM ; - goto out; + goto out_unlock; } ret =submit_lookup_objects (submit, args, file);
@@ -422,6 +424,7 @@ int msm_ioctl_gem_submit(struct drm_devi out:if (submit)submit_cleanup (submit, !!ret); +out_unlock:mutex_unlock (&dev->struct_mutex);return ret; }
PATCH 228/346 drm/msm: fix use of copy_from_user() while holding spinlock
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <[email protected]>
commit 89f82cbb0d5c0ab768c8d02914188aa2211cd2e3 upstream.
Use instead __copy_from_user_inatomic() and fallback to slow-path where we drop and re-aquire the lock in case of fault.
--- drivers/gpu/drm/msm/msm_gem_submit.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/msm_gem_submit.c +22 -5
@@ -55,6 +55,14 @@ static struct msm_gem_submit *submit_crereturn submit; } +static inline unsigned long __must_check +copy_from_user_inatomic (void *to,const void __user *from,unsigned long n) +{ +if (access_ok (VERIFY_READ , from, n)) +return __copy_from_user_inatomic (to, from, n); +return -EFAULT ; +} +static int submit_lookup_objects (struct msm_gem_submit *submit,struct drm_msm_gem_submit *args,struct drm_file *file) {
@@ -62,6 +70,7 @@ static int submit_lookup_objects(structint ret =0 ;spin_lock (&file->table_lock); +pagefault_disable ();for (i =0 ; i < args->nr_bos; i++) {struct drm_msm_gem_submit_bo submit_bo;
@@ -70,10 +79,15 @@ static int submit_lookup_objects(structvoid __user *userptr =to_user_ptr (args->bos + (i *sizeof (submit_bo))); - ret =copy_from_user (&submit_bo, userptr,sizeof (submit_bo)); -if (ret) { - ret = -EFAULT ; - goto out_unlock; + ret =copy_from_user_inatomic (&submit_bo, userptr,sizeof (submit_bo)); +if (unlikely (ret)) { +pagefault_enable (); +spin_unlock (&file->table_lock); + ret =copy_from_user (&submit_bo, userptr,sizeof (submit_bo)); +if (ret) + goto out; +spin_lock (&file->table_lock); +pagefault_disable (); }if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS ) {
@@ -113,9 +127,12 @@ static int submit_lookup_objects(struct } out_unlock: - submit->nr_bos = i; +pagefault_enable ();spin_unlock (&file->table_lock); +out: + submit->nr_bos = i; +return ret; }
PATCH 229/346 drm/msm: protect against faults from copy_from_user() in submit ioctl
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <[email protected]>
commit d78d383ab354b0b9e1d23404ae0d9fbdeb9aa035 upstream.
An evil userspace could try to cause deadlock by passing an unfaulted-in GEM bo as submit->bos (or submit->cmds) table. Which will trigger msm_gem_fault() while we already hold struct_mutex. See:
https://github.com/freedreno/msmtest/blob/master/evilsubmittest.c
--- drivers/gpu/drm/msm/msm_drv.h | 6 ++++++ drivers/gpu/drm/msm/msm_gem.c | 9 +++++++++ drivers/gpu/drm/msm/msm_gem_submit.c | 3 +++ 3 files changed, 18 insertions(+)
drivers/gpu/drm/msm/msm_drv.h +6 -0
@@ -124,6 +124,12 @@ struct msm_drm_private {*/ struct drm_mm mm; } vram; + +/* task holding struct_mutex.. currently only used in submit path +* to detect and reject faults from copy_from_user() for submit +* ioctl. +*/ +struct task_struct *struct_mutex_task; };struct msm_format {
drivers/gpu/drm/msm/msm_gem.c +9 -0
@@ -188,11 +188,20 @@ int msm_gem_fault(struct vm_area_struct {struct drm_gem_object *obj = vma->vm_private_data;struct drm_device *dev = obj->dev; +struct msm_drm_private *priv = dev->dev_private;struct page **pages;unsigned long pfn;pgoff_t pgoff;int ret; +/* This should only happen if userspace tries to pass a mmap'd +* but unfaulted gem bo vaddr into submit ioctl, triggering +* a page fault while struct_mutex is already held. This is +* not a valid use-case so just bail. +*/ +if (priv->struct_mutex_task == current) +return VM_FAULT_SIGBUS ; +/* Make sure we don't parallel update on a fault, nor move or remove * something from beneath our feet */
drivers/gpu/drm/msm/msm_gem_submit.c +3 -0
@@ -360,6 +360,8 @@ int msm_ioctl_gem_submit(struct drm_deviif (ret)return ret; + priv->struct_mutex_task = current; + submit =submit_create (dev, gpu, args->nr_bos);if (!submit) { ret = -ENOMEM ;
@@ -442,6 +444,7 @@ out:if (submit)submit_cleanup (submit, !!ret); out_unlock: + priv->struct_mutex_task =NULL ;mutex_unlock (&dev->struct_mutex);return ret; }
PATCH 230/346 powerpc/powernv : Drop reference added by kset_find_obj()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
commit a9cbf0b2195b695cbeeeecaa4e2770948c212e9a upstream.
In a situation, where Linux kernel gets notified about duplicate error log from OPAL, it is been observed that kernel fails to remove sysfs entries (/sys/firmware/opal/elog/0xXXXXXXXX) of such error logs. This is because, we currently search the error log/dump kobject in the kset list via 'kset_find_obj()' routine. Which eventually increment the reference count by one, once it founds the kobject.
So, unless we decrement the reference count by one after it found the kobject, we would not be able to release the kobject properly later.
This patch adds the 'kobject_put()' which was missing earlier.
--- arch/powerpc/platforms/powernv/opal-dump.c | 7 ++++++- arch/powerpc/platforms/powernv/opal-elog.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-)
arch/powerpc/platforms/powernv/opal-dump.c +6 -1
@@ -365,6 +365,7 @@ static int process_dump(void)uint32_t dump_id, dump_size, dump_type;struct dump_obj *dump;char name[22 ]; +struct kobject *kobj; rc =dump_read_info (&dump_id, &dump_size, &dump_type);if (rc !=OPAL_SUCCESS )
@@ -376,8 +377,12 @@ static int process_dump(void)* that gracefully and not create two conflicting * entries. */ -if (kset_find_obj (dump_kset, name)) + kobj =kset_find_obj (dump_kset, name); +if (kobj) { +/* Drop reference added by kset_find_obj() */ +kobject_put (kobj);return 0 ; + } dump =create_dump_obj (dump_id, dump_size, dump_type);if (!dump)
arch/powerpc/platforms/powernv/opal-elog.c +6 -1
@@ -246,6 +246,7 @@ static void elog_work_fn(struct work_struint64_t elog_type;int rc;char name[2 +16 +1 ]; +struct kobject *kobj; rc =opal_get_elog_size (&id, &size, &type);if (rc !=OPAL_SUCCESS ) {
@@ -268,8 +269,12 @@ static void elog_work_fn(struct work_str* that gracefully and not create two conflicting * entries. */ -if (kset_find_obj (elog_kset, name)) + kobj =kset_find_obj (elog_kset, name); +if (kobj) { +/* Drop reference added by kset_find_obj() */ +kobject_put (kobj);return ; + }create_elog_obj (log_id, elog_size, elog_type); }
PATCH 231/346 ALSA: timer: fix division by zero after SNDRV_TIMER_IOCTL_CONTINUE
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vegard Nossum <[email protected]>
commit 6b760bb2c63a9e322c0e4a0b5daf335ad93d5a33 upstream.
I got this:
divide error: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 1327 Comm: a.out Not tainted 4.8.0-rc2+ #189
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
task: ffff8801120a9580 task.stack: ffff8801120b0000
RIP: 0010:[<ffffffff82c8bd9a>] [<ffffffff82c8bd9a>] snd_hrtimer_callback+0x1da/0x3f0
RSP: 0018:ffff88011aa87da8 EFLAGS: 00010006
RAX: 0000000000004f76 RBX: ffff880112655e88 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff880112655ea0 RDI: 0000000000000001
RBP: ffff88011aa87e00 R08: ffff88013fff905c R09: ffff88013fff9048
R10: ffff88013fff9050 R11: 00000001050a7b8c R12: ffff880114778a00
R13: ffff880114778ab4 R14: ffff880114778b30 R15: 0000000000000000
FS: 00007f071647c700(0000) GS:ffff88011aa80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000603001 CR3: 0000000112021000 CR4: 00000000000006e0
Stack:
0000000000000000 ffff880114778ab8 ffff880112655ea0 0000000000004f76
ffff880112655ec8 ffff880112655e80 ffff880112655e88 ffff88011aa98fc0
00000000b97ccf2b dffffc0000000000 ffff88011aa98fc0 ffff88011aa87ef0
Call Trace:
<IRQ>
[<ffffffff813abce7>] __hrtimer_run_queues+0x347/0xa00
[<ffffffff82c8bbc0>] ? snd_hrtimer_close+0x130/0x130
[<ffffffff813ab9a0>] ? retrigger_next_event+0x1b0/0x1b0
[<ffffffff813ae1a6>] ? hrtimer_interrupt+0x136/0x4b0
[<ffffffff813ae220>] hrtimer_interrupt+0x1b0/0x4b0
[<ffffffff8120f91e>] local_apic_timer_interrupt+0x6e/0xf0
[<ffffffff81227ad3>] ? kvm_guest_apic_eoi_write+0x13/0xc0
[<ffffffff83c35086>] smp_apic_timer_interrupt+0x76/0xa0
[<ffffffff83c3416c>] apic_timer_interrupt+0x8c/0xa0
<EOI>
[<ffffffff83c3239c>] ? _raw_spin_unlock_irqrestore+0x2c/0x60
[<ffffffff82c8185d>] snd_timer_start1+0xdd/0x670
[<ffffffff82c87015>] snd_timer_continue+0x45/0x80
[<ffffffff82c88100>] snd_timer_user_ioctl+0x1030/0x2830
[<ffffffff8159f3a0>] ? __follow_pte.isra.49+0x430/0x430
[<ffffffff82c870d0>] ? snd_timer_pause+0x80/0x80
[<ffffffff815a26fa>] ? do_wp_page+0x3aa/0x1c90
[<ffffffff815aa4f8>] ? handle_mm_fault+0xbc8/0x27f0
[<ffffffff815a9930>] ? __pmd_alloc+0x370/0x370
[<ffffffff82c870d0>] ? snd_timer_pause+0x80/0x80
[<ffffffff816b0733>] do_vfs_ioctl+0x193/0x1050
[<ffffffff816b05a0>] ? ioctl_preallocate+0x200/0x200
[<ffffffff81002f2f>] ? syscall_trace_enter+0x3cf/0xdb0
[<ffffffff815045ba>] ? __context_tracking_exit.part.4+0x9a/0x1e0
[<ffffffff81002b60>] ? exit_to_usermode_loop+0x190/0x190
[<ffffffff82001a97>] ? check_preemption_disabled+0x37/0x1e0
[<ffffffff81d93889>] ? security_file_ioctl+0x89/0xb0
[<ffffffff816b167f>] SyS_ioctl+0x8f/0xc0
[<ffffffff816b15f0>] ? do_vfs_ioctl+0x1050/0x1050
[<ffffffff81005524>] do_syscall_64+0x1c4/0x4e0
[<ffffffff83c32b2a>] entry_SYSCALL64_slow_path+0x25/0x25
Code: e8 fc 42 7b fe 8b 0d 06 8a 50 03 49 0f af cf 48 85 c9 0f 88 7c 01 00 00 48 89 4d a8 e8 e0 42 7b fe 48 8b 45 c0 48 8b 4d a8 48 99 <48> f7 f9 49 01 c7 e8 cb 42 7b fe 48 8b 55 d0 48 b8 00 00 00 00
RIP [<ffffffff82c8bd9a>] snd_hrtimer_callback+0x1da/0x3f0
RSP <ffff88011aa87da8>
---[ end trace 6aa380f756a21074 ]---The problem happens when you call ioctl(SNDRV_TIMER_IOCTL_CONTINUE) on a completely new/unused timer -- it will have ->sticks == 0, which causes a divide by 0 in snd_hrtimer_callback().
--- sound/core/timer.c | 1 + 1 file changed, 1 insertion(+)
sound/core/timer.c +1 -0
@@ -839,6 +839,7 @@ int snd_timer_new(struct snd_card *card, timer->tmr_subdevice = tid->subdevice;if (id)strlcpy (timer->id, id,sizeof (timer->id)); + timer->sticks =1 ;INIT_LIST_HEAD (&timer->device_list);INIT_LIST_HEAD (&timer->open_list_head);INIT_LIST_HEAD (&timer->active_list_head);
PATCH 232/346 ALSA: timer: fix NULL pointer dereference on memory allocation failure
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vegard Nossum <[email protected]>
commit 8ddc05638ee42b18ba4fe99b5fb647fa3ad20456 upstream.
I hit this with syzkaller:
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 1327 Comm: a.out Not tainted 4.8.0-rc2+ #190
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
task: ffff88011278d600 task.stack: ffff8801120c0000
RIP: 0010:[<ffffffff82c8ba07>] [<ffffffff82c8ba07>] snd_hrtimer_start+0x77/0x100
RSP: 0018:ffff8801120c7a60 EFLAGS: 00010006
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000007
RDX: 0000000000000009 RSI: 1ffff10023483091 RDI: 0000000000000048
RBP: ffff8801120c7a78 R08: ffff88011a5cf768 R09: ffff88011a5ba790
R10: 0000000000000002 R11: ffffed00234b9ef1 R12: ffff880114843980
R13: ffffffff84213c00 R14: ffff880114843ab0 R15: 0000000000000286
FS: 00007f72958f3700(0000) GS:ffff88011aa00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000603001 CR3: 00000001126ab000 CR4: 00000000000006f0
Stack:
ffff880114843980 ffff880111eb2dc0 ffff880114843a34 ffff8801120c7ad0
ffffffff82c81ab1 0000000000000000 ffffffff842138e0 0000000100000000
ffff880111eb2dd0 ffff880111eb2dc0 0000000000000001 ffff880111eb2dc0
Call Trace:
[<ffffffff82c81ab1>] snd_timer_start1+0x331/0x670
[<ffffffff82c85bfd>] snd_timer_start+0x5d/0xa0
[<ffffffff82c8795e>] snd_timer_user_ioctl+0x88e/0x2830
[<ffffffff8159f3a0>] ? __follow_pte.isra.49+0x430/0x430
[<ffffffff82c870d0>] ? snd_timer_pause+0x80/0x80
[<ffffffff815a26fa>] ? do_wp_page+0x3aa/0x1c90
[<ffffffff8132762f>] ? put_prev_entity+0x108f/0x21a0
[<ffffffff82c870d0>] ? snd_timer_pause+0x80/0x80
[<ffffffff816b0733>] do_vfs_ioctl+0x193/0x1050
[<ffffffff813510af>] ? cpuacct_account_field+0x12f/0x1a0
[<ffffffff816b05a0>] ? ioctl_preallocate+0x200/0x200
[<ffffffff81002f2f>] ? syscall_trace_enter+0x3cf/0xdb0
[<ffffffff815045ba>] ? __context_tracking_exit.part.4+0x9a/0x1e0
[<ffffffff81002b60>] ? exit_to_usermode_loop+0x190/0x190
[<ffffffff82001a97>] ? check_preemption_disabled+0x37/0x1e0
[<ffffffff81d93889>] ? security_file_ioctl+0x89/0xb0
[<ffffffff816b167f>] SyS_ioctl+0x8f/0xc0
[<ffffffff816b15f0>] ? do_vfs_ioctl+0x1050/0x1050
[<ffffffff81005524>] do_syscall_64+0x1c4/0x4e0
[<ffffffff83c32b2a>] entry_SYSCALL64_slow_path+0x25/0x25
Code: c7 c7 c4 b9 c8 82 48 89 d9 4c 89 ee e8 63 88 7f fe e8 7e 46 7b fe 48 8d 7b 48 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 04 84 c0 7e 65 80 7b 48 00 74 0e e8 52 46
RIP [<ffffffff82c8ba07>] snd_hrtimer_start+0x77/0x100
RSP <ffff8801120c7a60>
---[ end trace 5955b08db7f2b029 ]---This can happen if snd_hrtimer_open() fails to allocate memory and returns an error, which is currently not checked by snd_timer_open():
ioctl(SNDRV_TIMER_IOCTL_SELECT)
- snd_timer_user_tselect()
- snd_timer_close()
- snd_hrtimer_close()
- (struct snd_timer *) t->private_data = NULL
- snd_timer_open()
- snd_hrtimer_open()
- kzalloc() fails; t->private_data is still NULL
ioctl(SNDRV_TIMER_IOCTL_START)
- snd_timer_user_start()
- snd_timer_start()
- snd_timer_start1()
- snd_hrtimer_start()
- t->private_data == NULL // boom
--- sound/core/timer.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
sound/core/timer.c +15 -2
@@ -296,8 +296,21 @@ int snd_timer_open(struct snd_timer_instget_device (&timer->card->card_dev); timeri->slave_class = tid->dev_sclass; timeri->slave_id = slave_id; -if (list_empty (&timer->open_list_head) && timer->hw.open) - timer->hw.open (timer); + +if (list_empty (&timer->open_list_head) && timer->hw.open) { +int err = timer->hw.open (timer); +if (err) { +kfree (timeri->owner); +kfree (timeri); + +if (timer->card) +put_device (&timer->card->card_dev); +module_put (timer->module); +mutex_unlock (®ister_mutex); +return err; + } + } +list_add_tail (&timeri->open_list, &timer->open_list_head);snd_timer_check_master (timeri);mutex_unlock (®ister_mutex);
PATCH 233/346 NFSv4.x: Fix a refcount leak in nfs_callback_up_net
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 98b0f80c2396224bbbed81792b526e6c72ba9efa upstream.
On error, the callers expect us to return without bumping nn->cb_users[].
--- fs/nfs/callback.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/callback.c +1 -0
@@ -301,6 +301,7 @@ static int nfs_callback_up_net(int minor err_socks:svc_rpcb_cleanup (serv, net); err_bind: + nn->cb_users[minorversion]--;dprintk ("NFS: Couldn't create callback socket: err = %d; " "net = %p\n" , ret, net);return ret;
PATCH 234/346 dm crypt: fix free of bad values after tfm allocation failure
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 5d0be84ec0cacfc7a6d6ea548afdd07d481324cd upstream.
If crypt_alloc_tfms() had to allocate multiple tfms and it failed before the last allocation, then it would call crypt_free_tfms() and could free pointers from uninitialized memory -- due to the crypt_free_tfms() check for non-zero cc->tfms[i]. Fix by allocating zeroed memory.
--- drivers/md/dm-crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-crypt.c +1 -1
@@ -1400,7 +1400,7 @@ static int crypt_alloc_tfms(struct cryptunsigned i;int err; - cc->tfms =kmalloc (cc->tfms_count *sizeof (struct crypto_ablkcipher *), + cc->tfms =kzalloc (cc->tfms_count *sizeof (struct crypto_ablkcipher *),GFP_KERNEL );if (!cc->tfms)return -ENOMEM ;
PATCH 235/346 kernfs: don't depend on d_find_any_alias() when generating notifications
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit df6a58c5c5aa8ecb1e088ecead3fa33ae70181f1 upstream.
kernfs_notify_workfn() sends out file modified events for the scheduled kernfs_nodes. Because the modifications aren't from userland, it doesn't have the matching file struct at hand and can't use fsnotify_modify(). Instead, it looked up the inode and then used d_find_any_alias() to find the dentry and used fsnotify_parent() and fsnotify() directly to generate notifications.
The assumption was that the relevant dentries would have been pinned if there are listeners, which isn't true as inotify doesn't pin dentries at all and watching the parent doesn't pin the child dentries even for dnotify. This led to, for example, inotify watchers not getting notifications if the system is under memory pressure and the matching dentries got reclaimed. It can also be triggered through /proc/sys/vm/drop_caches or a remount attempt which involves shrinking dcache.
fsnotify_parent() only uses the dentry to access the parent inode, which kernfs can do easily. Update kernfs_notify_workfn() so that it uses fsnotify() directly for both the parent and target inodes without going through d_find_any_alias(). While at it, supply the target file name to fsnotify() from kernfs_node->name.
--- fs/kernfs/file.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
fs/kernfs/file.c +21 -7
@@ -828,21 +828,35 @@ repeat:mutex_lock (&kernfs_mutex);list_for_each_entry (info, &kernfs_root (kn)->supers, node) { +struct kernfs_node *parent;struct inode *inode; -struct dentry *dentry; +/* +* We want fsnotify_modify() on @kn but as the +* modifications aren't originating from userland don't +* have the matching @file available. Look up the inodes +* and generate the events manually. +*/ inode =ilookup (info->sb, kn->ino);if (!inode)continue ; - dentry =d_find_any_alias (inode); -if (dentry) { -fsnotify_parent (NULL , dentry,FS_MODIFY ); -fsnotify (inode,FS_MODIFY , inode,FSNOTIFY_EVENT_INODE , -NULL ,0 ); -dput (dentry); + parent =kernfs_get_parent (kn); +if (parent) { +struct inode *p_inode; + + p_inode =ilookup (info->sb, parent->ino); +if (p_inode) { +fsnotify (p_inode,FS_MODIFY |FS_EVENT_ON_CHILD , + inode,FSNOTIFY_EVENT_INODE , kn->name,0 ); +iput (p_inode); + } + +kernfs_put (parent); } +fsnotify (inode,FS_MODIFY , inode,FSNOTIFY_EVENT_INODE , + kn->name,0 );iput (inode); }
PATCH 236/346 ALSA: fireworks: accessing to user space outside spinlock
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
commit 6b1ca4bcadf9ef077cc5f03c6822ba276ed14902 upstream.
In hwdep interface of fireworks driver, accessing to user space is in a critical section with disabled local interrupt. Depending on architecture, accessing to user space can cause page fault exception. Then local processor stores machine status and handles the synchronous event. A handler corresponding to the event can call task scheduler to wait for preparing pages. In a case of usage of single core processor, the state to disable local interrupt is worse because it don't handle usual interrupts from hardware.
This commit fixes this bug, performing the accessing outside spinlock. This commit also gives up counting the number of queued response messages to simplify ring-buffer management.
--- sound/firewire/fireworks/fireworks.h | 1 - sound/firewire/fireworks/fireworks_hwdep.c | 71 +++++++++++++++++------- sound/firewire/fireworks/fireworks_proc.c | 4 +- sound/firewire/fireworks/fireworks_transaction.c | 5 +- 4 files changed, 56 insertions(+), 25 deletions(-)
sound/firewire/fireworks/fireworks.h +0 -1
@@ -106,7 +106,6 @@ struct snd_efw {u8 *resp_buf;u8 *pull_ptr;u8 *push_ptr; -unsigned int resp_queues; }; int snd_efw_transaction_cmd(struct fw_unit *unit,
sound/firewire/fireworks/fireworks_hwdep.c +52 -19
138 lines not on this page · raw message
sound/firewire/fireworks/fireworks_proc.c +2 -2
@@ -188,8 +188,8 @@ proc_read_queues_state(struct snd_info_eelse consumed = (unsigned int )(efw->push_ptr - efw->pull_ptr); -snd_iprintf (buffer,"%d %d/%d\n" , - efw->resp_queues, consumed, snd_efw_resp_buf_size); +snd_iprintf (buffer,"%d/%d\n" , + consumed, snd_efw_resp_buf_size); } static void
sound/firewire/fireworks/fireworks_transaction.c +2 -3
@@ -121,11 +121,11 @@ copy_resp_to_buf(struct snd_efw *efw, vosize_t capacity, till_end;struct snd_efw_transaction *t; -spin_lock_irq (&efw->lock); - t = (struct snd_efw_transaction *)data; length =min_t (size_t,be32_to_cpu (t->length) *sizeof (u32), length); +spin_lock_irq (&efw->lock); +if (efw->push_ptr < efw->pull_ptr) capacity = (unsigned int )(efw->pull_ptr - efw->push_ptr);else
@@ -155,7 +155,6 @@ copy_resp_to_buf(struct snd_efw *efw, vo }/* for hwdep */ - efw->resp_queues++;wake_up (&efw->hwdep_wait); *rcode =RCODE_COMPLETE ;
PATCH 237/346 serial: 8250: added acces i/o products quad and octal serial cards
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jimi Damon <[email protected]>
commit c8d192428f52f244130b84650ad616df09f2b1e1 upstream.
Added devices ids for acces i/o products quad and octal serial cards that make use of existing Pericom PI7C9X7954 and PI7C9X7958 configurations .
--- drivers/tty/serial/8250/8250_pci.c | 139 +++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+)
drivers/tty/serial/8250/8250_pci.c +139 -0
@@ -1821,6 +1821,43 @@ pci_wch_ch353_setup(struct serial_privat#define PCI_DEVICE_ID_PERICOM_PI7C9X7954 0x7954#define PCI_DEVICE_ID_PERICOM_PI7C9X7958 0x7958 +#define PCI_VENDOR_ID_ACCESIO 0x494f +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB 0x1051 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S 0x1053 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB 0x105C +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S 0x105E +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB 0x1091 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2 0x1093 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB 0x1099 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4 0x109B +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB 0x10D1 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM 0x10D3 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB 0x10DA +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM 0x10DC +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1 0x1108 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2 0x1110 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2 0x1111 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4 0x1118 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4 0x1119 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S 0x1152 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S 0x115A +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2 0x1190 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2 0x1191 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4 0x1198 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4 0x1199 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM 0x11D0 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4 0x105A +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4 0x105B +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8 0x106A +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8 0x106B +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4 0x1098 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8 0x10A9 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM 0x10D9 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM 0x10E9 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM 0x11D8 + + +/* Unknown vendors/cards - this should not be in linux/pci_ids.h */ #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584#define PCI_SUBDEVICE_ID_UNKNOWN_0x1588 0x1588
@@ -4890,6 +4927,108 @@ static struct pci_device_id serial_pci_t0 , 0, pbn_pericom_PI7C9X7958 },/* +* ACCES I/O Products quad +*/ + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7954 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM, +PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 , + pbn_pericom_PI7C9X7958 }, +/* * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke) */ { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560,
PATCH 238/346 ipv6: add missing netconf notif when 'all' is updated
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dichtel <[email protected]>
commit d26c638c16cb54f6fb1507e27df93ede692db572 upstream.
The 'default' value was not advertised.
--- net/ipv6/addrconf.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/ipv6/addrconf.c +7 -0
@@ -723,7 +723,14 @@ static int addrconf_fixup_forwarding(str }if (p == &net->ipv6.devconf_all->forwarding) { +int old_dflt = net->ipv6.devconf_dflt->forwarding; + net->ipv6.devconf_dflt->forwarding = newf; +if ((!newf) ^ (!old_dflt)) +inet6_netconf_notify_devconf (net,NETCONFA_FORWARDING , +NETCONFA_IFINDEX_DEFAULT , + net->ipv6.devconf_dflt); +addrconf_forward_change (net, newf);if ((!newf) ^ (!old)) inet6_netconf_notify_devconf(net, NETCONFA_FORWARDING,
PATCH 239/346 tcp: fastopen: fix rcv_wup initialization for TFO server on SYN/data
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Neal Cardwell <[email protected]>
commit 28b346cbc0715ae45b2814d857f1d8a7e6817ed8 upstream.
Yuchung noticed that on the first TFO server data packet sent after the (TFO) handshake, the server echoed the TCP timestamp value in the SYN/data instead of the timestamp value in the final ACK of the handshake. This problem did not happen on regular opens.
The tcp_replace_ts_recent() logic that decides whether to remember an incoming TS value needs tp->rcv_wup to hold the latest receive sequence number that we have ACKed (latest tp->rcv_nxt we have ACKed). This commit fixes this issue by ensuring that a TFO server properly updates tp->rcv_wup to match tp->rcv_nxt at the time it sends a SYN/ACK for the SYN/data.
--- net/ipv4/tcp_fastopen.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/tcp_fastopen.c +1 -0
@@ -213,6 +213,7 @@ static bool tcp_fastopen_create_child(st } }tcp_rsk (req)->rcv_nxt = tp->rcv_nxt = end_seq; + tp->rcv_wup = tp->rcv_nxt; sk->sk_data_ready (sk);bh_unlock_sock (child);sock_put (child);
PATCH 240/346 kernel/fork: fix CLONE_CHILD_CLEARTID regression in nscd
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Michal Hocko <[email protected]>
commit 735f2770a770156100f534646158cb58cb8b2939 upstream.
Commit fec1d0115240 ("[PATCH] Disable CLONE_CHILD_CLEARTID for abnormal exit") has caused a subtle regression in nscd which uses CLONE_CHILD_CLEARTID to clear the nscd_certainly_running flag in the shared databases, so that the clients are notified when nscd is restarted. Now, when nscd uses a non-persistent database, clients that have it mapped keep thinking the database is being updated by nscd, when in fact nscd has created a new (anonymous) one (for non-persistent databases it uses an unlinked file as backend).
The original proposal for the CLONE_CHILD_CLEARTID change claimed
(https://lkml.org/lkml/2006/10/25/233):
: The NPTL library uses the CLONE_CHILD_CLEARTID flag on clone() syscalls : on behalf of pthread_create() library calls. This feature is used to : request that the kernel clear the thread-id in user space (at an address : provided in the syscall) when the thread disassociates itself from the : address space, which is done in mm_release().
:
: Unfortunately, when a multi-threaded process incurs a core dump (such as : from a SIGSEGV), the core-dumping thread sends SIGKILL signals to all of : the other threads, which then proceed to clear their user-space tids : before synchronizing in exit_mm() with the start of core dumping. This : misrepresents the state of process's address space at the time of the : SIGSEGV and makes it more difficult for someone to debug NPTL and glibc : problems (misleading him/her to conclude that the threads had gone away : before the fault).
:
: The fix below is to simply avoid the CLONE_CHILD_CLEARTID action if a : core dump has been initiated.
The resulting patch from Roland (https://lkml.org/lkml/2006/10/26/269)
seems to have a larger scope than the original patch asked for. It seems that limitting the scope of the check to core dumping should work for SIGSEGV issue describe above.
--- kernel/fork.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
kernel/fork.c +4 -6
@@ -777,14 +777,12 @@ void mm_release(struct task_struct *tsk,deactivate_mm (tsk, mm);/* -* If we're exiting normally, clear a user-space tid field if -* requested. We leave this alone when dying by signal, to leave -* the value intact in a core dump, and to save the unnecessary -* trouble, say, a killed vfork parent shouldn't touch this mm. -* Userland only wants this done for a sys_exit. +* Signal userspace if we're not exiting with a core dump +* because we want to leave the value intact for debugging +* purposes. */ if (tsk->clear_child_tid) { -if (!(tsk->flags &PF_SIGNALED ) && +if (!(tsk->signal->flags &SIGNAL_GROUP_COREDUMP ) &&atomic_read (&mm->mm_users) >1 ) {/* * We don't check the error code - if userspace has
PATCH 241/346 ALSA: timer: fix NULL pointer dereference in read()/ioctl() race
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vegard Nossum <[email protected]>
commit 11749e086b2766cccf6217a527ef5c5604ba069c upstream.
I got this with syzkaller:
==================================================================
BUG: KASAN: null-ptr-deref on address 0000000000000020
Read of size 32 by task syz-executor/22519
CPU: 1 PID: 22519 Comm: syz-executor Not tainted 4.8.0-rc2+ #169
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2
014
0000000000000001 ffff880111a17a00 ffffffff81f9f141 ffff880111a17a90
ffff880111a17c50 ffff880114584a58 ffff880114584a10 ffff880111a17a80
ffffffff8161fe3f ffff880100000000 ffff880118d74a48 ffff880118d74a68
Call Trace:
[<ffffffff81f9f141>] dump_stack+0x83/0xb2
[<ffffffff8161fe3f>] kasan_report_error+0x41f/0x4c0
[<ffffffff8161ff74>] kasan_report+0x34/0x40
[<ffffffff82c84b54>] ? snd_timer_user_read+0x554/0x790
[<ffffffff8161e79e>] check_memory_region+0x13e/0x1a0
[<ffffffff8161e9c1>] kasan_check_read+0x11/0x20
[<ffffffff82c84b54>] snd_timer_user_read+0x554/0x790
[<ffffffff82c84600>] ? snd_timer_user_info_compat.isra.5+0x2b0/0x2b0
[<ffffffff817d0831>] ? proc_fault_inject_write+0x1c1/0x250
[<ffffffff817d0670>] ? next_tgid+0x2a0/0x2a0
[<ffffffff8127c278>] ? do_group_exit+0x108/0x330
[<ffffffff8174653a>] ? fsnotify+0x72a/0xca0
[<ffffffff81674dfe>] __vfs_read+0x10e/0x550
[<ffffffff82c84600>] ? snd_timer_user_info_compat.isra.5+0x2b0/0x2b0
[<ffffffff81674cf0>] ? do_sendfile+0xc50/0xc50
[<ffffffff81745e10>] ? __fsnotify_update_child_dentry_flags+0x60/0x60
[<ffffffff8143fec6>] ? kcov_ioctl+0x56/0x190
[<ffffffff81e5ada2>] ? common_file_perm+0x2e2/0x380
[<ffffffff81746b0e>] ? __fsnotify_parent+0x5e/0x2b0
[<ffffffff81d93536>] ? security_file_permission+0x86/0x1e0
[<ffffffff816728f5>] ? rw_verify_area+0xe5/0x2b0
[<ffffffff81675355>] vfs_read+0x115/0x330
[<ffffffff81676371>] SyS_read+0xd1/0x1a0
[<ffffffff816762a0>] ? vfs_write+0x4b0/0x4b0
[<ffffffff82001c2c>] ? __this_cpu_preempt_check+0x1c/0x20
[<ffffffff8150455a>] ? __context_tracking_exit.part.4+0x3a/0x1e0
[<ffffffff816762a0>] ? vfs_write+0x4b0/0x4b0
[<ffffffff81005524>] do_syscall_64+0x1c4/0x4e0
[<ffffffff810052fc>] ? syscall_return_slowpath+0x16c/0x1d0
[<ffffffff83c3276a>] entry_SYSCALL64_slow_path+0x25/0x25
==================================================================There are a couple of problems that I can see:
- ioctl(SNDRV_TIMER_IOCTL_SELECT), which potentially sets tu->queue/tu->tqueue to NULL on memory allocation failure, so read() would get a NULL pointer dereference like the above splat
- the same ioctl() can free tu->queue/to->tqueue which means read() could potentially see (and dereference) the freed pointer
We can fix both by taking the ioctl_lock mutex when dereferencing ->queue/->tqueue, since that's always held over all the ioctl() code.
Just looking at the code I find it likely that there are more problems here such as tu->qhead pointing outside the buffer if the size is changed concurrently using SNDRV_TIMER_IOCTL_PARAMS.
--- sound/core/timer.c | 2 ++ 1 file changed, 2 insertions(+)
sound/core/timer.c +2 -0
@@ -1985,6 +1985,7 @@ static ssize_t snd_timer_user_read(struc tu->qused--;spin_unlock_irq (&tu->qlock); +mutex_lock (&tu->ioctl_lock);if (tu->tread) {if (copy_to_user (buffer, &tu->tqueue[qhead],sizeof (struct snd_timer_tread )))
@@ -1994,6 +1995,7 @@ static ssize_t snd_timer_user_read(struc sizeof(struct snd_timer_read))) err = -EFAULT ; } +mutex_unlock (&tu->ioctl_lock);spin_lock_irq (&tu->qlock);if (err <0 )
PATCH 242/346 x86/paravirt: Do not trace _paravirt_ident_*() functions
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit 15301a570754c7af60335d094dd2d1808b0641a5 upstream.
Łukasz Daniluk reported that on a RHEL kernel that his machine would lock up after enabling function tracer. I asked him to bisect the functions within available_filter_functions, which he did and it came down to three:
_paravirt_nop(), _paravirt_ident_32() and _paravirt_ident_64()
It was found that this is only an issue when noreplace-paravirt is added to the kernel command line.
This means that those functions are most likely called within critical sections of the funtion tracer, and must not be traced.
In newer kenels _paravirt_nop() is defined within gcc asm(), and is no longer an issue. But both _paravirt_ident_{32,64}() causes the following splat when they are traced:
mm/pgtable-generic.c:33: bad pmd ffff8800d2435150(0000000001d00054) mm/pgtable-generic.c:33: bad pmd ffff8800d3624190(0000000001d00070) mm/pgtable-generic.c:33: bad pmd ffff8800d36a5110(0000000001d00054) mm/pgtable-generic.c:33: bad pmd ffff880118eb1450(0000000001d00054) NMI watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [systemd-journal:469]
Modules linked in: e1000e CPU: 2 PID: 469 Comm: systemd-journal Not tainted 4.6.0-rc4-test+ #513 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v02.05 05/07/2012 task: ffff880118f740c0 ti: ffff8800d4aec000 task.ti: ffff8800d4aec000 RIP: 0010:[<ffffffff81134148>] [<ffffffff81134148>] queued_spin_lock_slowpath+0x118/0x1a0 RSP: 0018:ffff8800d4aefb90 EFLAGS: 00000246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88011eb16d40 RDX: ffffffff82485760 RSI: 000000001f288820 RDI: ffffea0000008030 RBP: ffff8800d4aefb90 R08: 00000000000c0000 R09: 0000000000000000 R10: ffffffff821c8e0e R11: 0000000000000000 R12: ffff880000200fb8 R13: 00007f7a4e3f7000 R14: ffffea000303f600 R15: ffff8800d4b562e0 FS: 00007f7a4e3d7840(0000) GS:ffff88011eb00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f7a4e3f7000 CR3: 00000000d3e71000 CR4: 00000000001406e0 Call Trace: _raw_spin_lock+0x27/0x30 handle_pte_fault+0x13db/0x16b0 handle_mm_fault+0x312/0x670 __do_page_fault+0x1b1/0x4e0 do_page_fault+0x22/0x30 page_fault+0x28/0x30 __vfs_read+0x28/0xe0 vfs_read+0x86/0x130 SyS_read+0x46/0xa0 entry_SYSCALL_64_fastpath+0x1e/0xa8 Code: 12 48 c1 ea 0c 83 e8 01 83 e2 30 48 98 48 81 c2 40 6d 01 00 48 03 14 c5 80 6a 5d 82 48 89 0a 8b 41 08 85 c0 75 09 f3 90 8b 41 08 <85> c0 74 f7 4c 8b 09 4d 85 c9 74 08 41 0f 18 09 eb 02 f3 90 8b
--- arch/x86/kernel/paravirt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/paravirt.c +2 -2
@@ -55,12 +55,12 @@ asm (".pushsection .entry.text, \"ax\"\n ".popsection");/* identity function, which can be inlined */ -u32 _paravirt_ident_32 (u32 x) +u32 notrace _paravirt_ident_32(u32 x) {return x; } -u64 _paravirt_ident_64 (u64 x) +u64 notrace _paravirt_ident_64(u64 x) {return x; }
PATCH 243/346 IB/core: Fix use after free in send_leave function
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Erez Shitrit <[email protected]>
commit 68c6bcdd8bd00394c234b915ab9b97c74104130c upstream.
The function send_leave sets the member: group->query_id (group->query_id = ret) after calling the sa_query, but leave_handler can be executed before the setting and it might delete the group object, and will get a memory corruption.
Additionally, this patch gets rid of group->query_id variable which is not used.
--- drivers/infiniband/core/multicast.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/infiniband/core/multicast.c +2 -11
@@ -106,7 +106,6 @@ struct mcast_group {atomic_t refcount;enum mcast_group_state state;struct ib_sa_query *query; -int query_id;u16 pkey_index;u8 leave_state;int retries;
@@ -339,11 +338,7 @@ static int send_join(struct mcast_group member->multicast.comp_mask,3000 ,GFP_KERNEL , join_handler, group, &group->query); -if (ret >=0 ) { - group->query_id = ret; - ret =0 ; - } -return ret; +return (ret >0 ) ?0 : ret; }static int send_leave (struct mcast_group *group,u8 leave_state)
@@ -363,11 +358,7 @@ static int send_leave(struct mcast_groupIB_SA_MCMEMBER_REC_JOIN_STATE ,3000 ,GFP_KERNEL , leave_handler, group, &group->query); -if (ret >=0 ) { - group->query_id = ret; - ret =0 ; - } -return ret; +return (ret >0 ) ?0 : ret; } static void join_group(struct mcast_group *group, struct mcast_member *member,
PATCH 244/346 IB/ipoib: Fix memory corruption in ipoib cm mode connect flow
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Erez Shitrit <[email protected]>
commit 546481c2816ea3c061ee9d5658eb48070f69212e upstream.
When a new CM connection is being requested, ipoib driver copies data from the path pointer in the CM/tx object, the path object might be invalid at the point and memory corruption will happened later when now the CM driver will try using that data.
The next scenario demonstrates it:
neigh_add_path --> ipoib_cm_create_tx --> queue_work (pointer to path is in the cm/tx struct) #while the work is still in the queue, #the port goes down and causes the ipoib_flush_paths: ipoib_flush_paths --> path_free --> kfree(path) #at this point the work scheduled starts. ipoib_cm_tx_start --> copy from the (invalid)path pointer: (memcpy(&pathrec, &p->path->pathrec, sizeof pathrec);) -> memory corruption.
To fix that the driver now starts the CM/tx connection only if that specific path exists in the general paths database.
This check is protected with the relevant locks, and uses the gid from the neigh member in the CM/tx object which is valid according to the ref count that was taken by the CM/tx.
--- drivers/infiniband/ulp/ipoib/ipoib.h | 1 + drivers/infiniband/ulp/ipoib/ipoib_cm.c | 16 ++++++++++++++++ drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/ipoib/ipoib.h +1 -0
@@ -463,6 +463,7 @@ void ipoib_send(struct net_device *dev, struct ipoib_ah *address, u32 qpn);void ipoib_reap_ah (struct work_struct *work); +struct ipoib_path *__path_find (struct net_device *dev,void *gid);void ipoib_mark_paths_invalid (struct net_device *dev);void ipoib_flush_paths (struct net_device *dev);struct ipoib_dev_priv *ipoib_intf_alloc (const char *format);
drivers/infiniband/ulp/ipoib/ipoib_cm.c +16 -0
@@ -1303,6 +1303,8 @@ void ipoib_cm_destroy_tx(struct ipoib_cm } } +#define QPN_AND_OPTIONS_OFFSET 4 +static void ipoib_cm_tx_start (struct work_struct *work) { struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv,
@@ -1311,6 +1313,7 @@ static void ipoib_cm_tx_start(struct worstruct ipoib_neigh *neigh;struct ipoib_cm_tx *p;unsigned long flags; +struct ipoib_path *path;int ret;struct ib_sa_path_rec pathrec;
@@ -1323,7 +1326,19 @@ static void ipoib_cm_tx_start(struct wor p =list_entry (priv->cm.start_list.next,typeof (*p), list);list_del_init (&p->list); neigh = p->neigh; + qpn =IPOIB_QPN (neigh->daddr); +/* +* As long as the search is with these 2 locks, +* path existence indicates its validity. +*/ + path =__path_find (dev, neigh->daddr +QPN_AND_OPTIONS_OFFSET ); +if (!path) { +pr_info ("%s ignore not valid path %pI6\n" , + __func__, + neigh->daddr +QPN_AND_OPTIONS_OFFSET ); + goto free_neigh; + }memcpy (&pathrec, &p->path->pathrec,sizeof pathrec);spin_unlock_irqrestore (&priv->lock, flags);
@@ -1335,6 +1350,7 @@ static void ipoib_cm_tx_start(struct worspin_lock_irqsave (&priv->lock, flags);if (ret) { +free_neigh: neigh = p->neigh;if (neigh) { neigh->cm =NULL ;
drivers/infiniband/ulp/ipoib/ipoib_main.c +1 -1
@@ -253,7 +253,7 @@ int ipoib_set_mode(struct net_device *dereturn -EINVAL ; } -static struct ipoib_path *__path_find (struct net_device *dev,void *gid) +struct ipoib_path *__path_find (struct net_device *dev,void *gid) {struct ipoib_dev_priv *priv =netdev_priv (dev);struct rb_node *n = priv->path_tree.rb_node;
PATCH 245/346 x86/AMD: Apply erratum 665 on machines without a BIOS fix
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Emanuel Czirai <[email protected]>
commit d1992996753132e2dafe955cccb2fb0714d3cfc4 upstream.
AMD F12h machines have an erratum which can cause DIV/IDIV to behave unpredictably. The workaround is to set MSRC001_1029[31] but sometimes there is no BIOS update containing that workaround so let's do it ourselves unconditionally. It is simple enough.
[ Borislav: Wrote commit message. ]
[bwh: Backported to 3.16:
- Add an if-statement to init_amd() in place of the switch
- Adjust context]
---
arch/x86/kernel/cpu/amd.c +14 -0
@@ -522,6 +522,17 @@ static const int amd_erratum_383[];static const int amd_erratum_400[];static bool cpu_has_amd_erratum (struct cpuinfo_x86 *cpu,const int *erratum); +#define MSR_AMD64_DE_CFG 0xC0011029 + +static void init_amd_ln (struct cpuinfo_x86 *c) +{ +/* +* Apply erratum 665 fix unconditionally so machines without a BIOS +* fix work. +*/ +msr_set_bit (MSR_AMD64_DE_CFG ,31 ); +} +static void init_amd (struct cpuinfo_x86 *c) {u32 dummy;
@@ -614,6 +625,9 @@ static void init_amd(struct cpuinfo_x86 } } +if (c->x86 ==0x12 ) +init_amd_ln (c); +/* re-enable TopologyExtensions if switched off by BIOS */ if ((c->x86 == 0x15) && (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
PATCH 246/346 l2tp: fix use-after-free during module unload
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
commit 2f86953e7436c9b9a4690909c5e2db24799e173b upstream.
Tunnel deletion is delayed by both a workqueue (l2tp_tunnel_delete -> wq
-> l2tp_tunnel_del_work) and RCU (sk_destruct -> RCU ->l2tp_tunnel_destruct).
By the time l2tp_tunnel_destruct() runs to destroy the tunnel and finish destroying the socket, the private data reserved via the net_generic mechanism has already been freed, but l2tp_tunnel_destruct() actually uses this data.
Make sure tunnel deletion for the netns has completed before returning from l2tp_exit_net() by first flushing the tunnel removal workqueue, and then waiting for RCU callbacks to complete.
--- net/l2tp/l2tp_core.c | 3 +++ 1 file changed, 3 insertions(+)
net/l2tp/l2tp_core.c +3 -0
@@ -1892,6 +1892,9 @@ static __net_exit void l2tp_exit_net(str (void )l2tp_tunnel_delete (tunnel); }rcu_read_unlock_bh (); + +flush_workqueue (l2tp_wq); +rcu_barrier (); }static struct pernet_operations l2tp_net_ops = {
PATCH 247/346 iio: fix pressure data output unit in hid-sensor-attributes
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Kweh, Hock Leong" <[email protected]>
commit 36afb176d3c9580651d7f410ed7f000ec48b5137 upstream.
According to IIO ABI definition, IIO_PRESSURE data output unit is kilopascal:
http://lxr.free-electrons.com/source/Documentation/ABI/testing/sysfs-bus-iio
This patch fix output unit of HID pressure sensor IIO driver from pascal to kilopascal to follow IIO ABI definition.
--- 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
@@ -56,8 +56,8 @@ struct { {HID_USAGE_SENSOR_ALS, 0, 1, 0}, {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0}, - {HID_USAGE_SENSOR_PRESSURE, 0, 100000, 0}, - {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 1, 0}, + {HID_USAGE_SENSOR_PRESSURE, 0, 100, 0}, + {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000}, };static int pow_10 (unsigned power)
PATCH 248/346 iio: accel: kxsd9: Fix scaling bug
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit 307fe9dd11ae44d4f8881ee449a7cbac36e1f5de upstream.
All the scaling of the KXSD9 involves multiplication with a fraction number < 1.
However the scaling value returned from IIO_INFO_SCALE was unpredictable as only the micros of the value was assigned, and not the integer part, resulting in scaling like this:
$cat in_accel_scale
-1057462640.011978
Fix this by assigning zero to the integer part.
--- drivers/iio/accel/kxsd9.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/kxsd9.c +1 -0
@@ -166,6 +166,7 @@ static int kxsd9_read_raw(struct iio_dev ret =spi_w8r8 (st->us,KXSD9_READ (KXSD9_REG_CTRL_C ));if (ret <0 ) goto error_ret; + *val =0 ; *val2 = kxsd9_micro_scales[ret &KXSD9_FS_MASK ]; ret =IIO_VAL_INT_PLUS_MICRO ;break ;
PATCH 249/346 sched/core: Fix a race between try_to_wake_up() and a woken up task
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Balbir Singh <[email protected]>
commit 135e8c9250dd5c8c9aae5984fde6f230d0cbfeaf upstream.
The origin of the issue I've seen is related to
a missing memory barrier between check for task->state and the check for task->on_rq.
The task being woken up is already awake from a schedule() and is doing the following:
do {
schedule()
set_current_state(TASK_(UN)INTERRUPTIBLE);
} while (!cond);The waker, actually gets stuck doing the following in try_to_wake_up():
while (p->on_cpu) cpu_relax();
Analysis:
The instance I've seen involves the following race:
CPU1 CPU2
while () {
if (cond)
break;
do {
schedule();
set_current_state(TASK_UN..) } while (!cond);
wakeup_routine()
spin_lock_irqsave(wait_lock)
raw_spin_lock_irqsave(wait_lock) wake_up_process()
} try_to_wake_up()
set_current_state(TASK_RUNNING); ..
list_del(&waiter.list);
CPU2 wakes up CPU1, but before it can get the wait_lock and set current state to TASK_RUNNING the following occurs:
CPU3
wakeup_routine()
raw_spin_lock_irqsave(wait_lock)
if (!list_empty)
wake_up_process()
try_to_wake_up()
raw_spin_lock_irqsave(p->pi_lock)
..
if (p->on_rq && ttwu_wakeup())
..
while (p->on_cpu)
cpu_relax()
..
CPU3 tries to wake up the task on CPU1 again since it finds it on the wait_queue, CPU1 is spinning on wait_lock, but immediately after CPU2, CPU3 got it.
CPU3 checks the state of p on CPU1, it is TASK_UNINTERRUPTIBLE and the task is spinning on the wait_lock. Interestingly since p->on_rq is checked under pi_lock, I've noticed that try_to_wake_up() finds p->on_rq to be 0. This was the most confusing bit of the analysis, but p->on_rq is changed under runqueue lock, rq_lock, the p->on_rq check is not reliable without this fix IMHO. The race is visible (based on the analysis) only when ttwu_queue() does a remote wakeup via ttwu_queue_remote. In which case the p->on_rq change is not done uder the pi_lock.
The result is that after a while the entire system locks up on the raw_spin_irqlock_save(wait_lock) and the holder spins infintely
Reproduction of the issue:
The issue can be reproduced after a long run on my system with 80 threads and having to tweak available memory to very low and running memory stress-ng mmapfork test. It usually takes a long time to reproduce. I am trying to work on a test case that can reproduce the issue faster, but thats work in progress. I am still testing the changes on my still in a loop and the tests seem OK thus far.
Big thanks to Benjamin and Nick for helping debug this as well. Ben helped catch the missing barrier, Nick caught every missing bit in my theory.
[ Updated comment to clarify matching barriers. Many
architectures do not have a full barrier in switch_to() so that cannot be relied upon. ]
--- kernel/sched/core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
kernel/sched/core.c +22 -0
@@ -1696,6 +1696,28 @@ try_to_wake_up(struct task_struct *p, un success =1 ;/* we're going to change ->state */ cpu =task_cpu (p); +/* +* Ensure we load p->on_rq _after_ p->state, otherwise it would +* be possible to, falsely, observe p->on_rq == 0 and get stuck +* in smp_cond_load_acquire() below. +* +* sched_ttwu_pending() try_to_wake_up() +* [S] p->on_rq = 1; [L] P->state +* UNLOCK rq->lock -----. +* \ +* +--- RMB +* schedule() / +* LOCK rq->lock -----' +* UNLOCK rq->lock +* +* [task p] +* [S] p->state = UNINTERRUPTIBLE [L] p->on_rq +* +* Pairs with the UNLOCK+LOCK on rq->lock from the +* last wakeup of our task and the schedule that got our task +* current. +*/ +smp_rmb ();if (p->on_rq &&ttwu_remote (p, wake_flags)) goto stat;
PATCH 250/346 usb: renesas_usbhs: fix clearing the {BRDY,BEMP}STS condition
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Yoshihiro Shimoda <[email protected]>
commit 519d8bd4b5d3d82c413eac5bb42b106bb4b9ec15 upstream.
The previous driver is possible to stop the transfer wrongly. For example:
1) An interrupt happens, but not BRDY interruption.
2) Read INTSTS0. And than state->intsts0 is not set to BRDY.
3) BRDY is set to 1 here.
4) Read BRDYSTS.
5) Clear the BRDYSTS. And then. the BRDY is cleared wrongly.
Remarks:
- The INTSTS0.BRDY is read only.
- If any bits of BRDYSTS are set to 1, the BRDY is set to 1.
- If BRDYSTS is 0, the BRDY is set to 0.
So, this patch adds condition to avoid such situation. (And about NRDYSTS, this is not used for now. But, avoiding any side effects, this patch doesn't touch it.)
--- drivers/usb/renesas_usbhs/mod.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/usb/renesas_usbhs/mod.c +9 -2
@@ -272,9 +272,16 @@ static irqreturn_t usbhs_interrupt(int iusbhs_write (priv,INTSTS0 , ~irq_state.intsts0 &INTSTS0_MAGIC );usbhs_write (priv,INTSTS1 , ~irq_state.intsts1 &INTSTS1_MAGIC ); -usbhs_write (priv,BRDYSTS , ~irq_state.brdysts); +/* +* The driver should not clear the xxxSTS after the line of +* "call irq callback functions" because each "if" statement is +* possible to call the callback function for avoiding any side effects. +*/ +if (irq_state.intsts0 &BRDY ) +usbhs_write (priv,BRDYSTS , ~irq_state.brdysts);usbhs_write (priv,NRDYSTS , ~irq_state.nrdysts); -usbhs_write (priv,BEMPSTS , ~irq_state.bempsts); +if (irq_state.intsts0 &BEMP ) +usbhs_write (priv,BEMPSTS , ~irq_state.bempsts);/* * call irq callback functions
PATCH 251/346 efi/libstub: Allocate headspace in efi_get_memory_map()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeffrey Hugo <[email protected]>
commit dadb57abc37499f565b23933dbf49b435c3ba8af upstream.
efi_get_memory_map() allocates a buffer to store the memory map that it retrieves. This buffer may need to be reused by the client after ExitBootServices() is called, at which point allocations are not longer permitted. To support this usecase, provide the allocated buffer size back to the client, and allocate some additional headroom to account for any reasonable growth in the map that is likely to happen between the call to efi_get_memory_map() and the client reusing the buffer.
[bwh: Backported to 3.16:
- Adjust filenames, context
- In allocate_new_fdt_and_exit_boot(), only fill memory_map
- Drop changes to efi_random_alloc()]
---
arch/x86/boot/compressed/eboot.c +12 -6
@@ -1266,7 +1266,7 @@ static efi_status_t exit_boot(struct boo void *handle, bool is64) {struct efi_info *efi = &boot_params->efi_info; -unsigned long map_sz, key, desc_size; +unsigned long map_sz, key, desc_size, buff_size;efi_memory_desc_t *mem_map;struct setup_data *e820ext;const char *signature;
@@ -1277,14 +1277,20 @@ static efi_status_t exit_boot(struct boobool called_exit = false;u8 nr_entries;int i; +struct efi_boot_memmap map; - nr_desc =0 ; - e820ext =NULL ; - e820ext_size =0 ; + nr_desc =0 ; + e820ext =NULL ; + e820ext_size =0 ; + map.map = &mem_map; + map.map_size = &map_sz; + map.desc_size = &desc_size; + map.desc_ver = &desc_version; + map.key_ptr = &key; + map.buff_size = &buff_size; get_map: - status =efi_get_memory_map (sys_table, &mem_map, &map_sz, &desc_size, - &desc_version, &key); + status =efi_get_memory_map (sys_table, &map);if (status !=EFI_SUCCESS )return status;
drivers/firmware/efi/efi-stub-helper.c +66 -30
163 lines not on this page · raw message
drivers/firmware/efi/fdt.c +10 -3
@@ -178,12 +178,20 @@ efi_status_t allocate_new_fdt_and_exit_b unsigned long fdt_addr, unsigned long fdt_size) { -unsigned long map_size, desc_size; +unsigned long map_size, desc_size, buff_size;u32 desc_ver;unsigned long mmap_key;efi_memory_desc_t *memory_map;unsigned long new_fdt_size;efi_status_t status; +struct efi_boot_memmap map; + + map.map = &memory_map; + map.map_size = &map_size; + map.desc_size = &desc_size; + map.desc_ver = &desc_ver; + map.key_ptr = &mmap_key; + map.buff_size = &buff_size;/* * Estimate size of new FDT, and allocate memory for it. We
@@ -204,8 +212,7 @@ efi_status_t allocate_new_fdt_and_exit_b* we can get the memory map key needed for * exit_boot_services(). */ - status =efi_get_memory_map (sys_table, &memory_map, &map_size, - &desc_size, &desc_ver, &mmap_key); + status =efi_get_memory_map (sys_table, &map);if (status !=EFI_SUCCESS ) goto fail_free_new_fdt;
include/linux/efi.h +9 -0
@@ -117,6 +117,15 @@ typedef struct {u32 imagesize; } efi_capsule_header_t; +struct efi_boot_memmap { +efi_memory_desc_t **map; +unsigned long *map_size; +unsigned long *desc_size; +u32 *desc_ver; +unsigned long *key_ptr; +unsigned long *buff_size; +}; +/* * Allocation types for calls to boottime->allocate_pages. */
PATCH 252/346 iio:core: fix IIO_VAL_FRACTIONAL sign handling
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Gregor Boirie <[email protected]>
commit 171c0091837c81ed5c949fec6966bb5afff2d1cf upstream.
7985e7c100 ("iio: Introduce a new fractional value type") introduced a new IIO_VAL_FRACTIONAL value type meant to represent rational type numbers expressed by a numerator and denominator combination.
Formating of IIO_VAL_FRACTIONAL values relies upon do_div() usage. This fails handling negative values properly since parameters are reevaluated as unsigned values.
Fix this by using div_s64_rem() instead. Computed integer part will carry properly signed value. Formatted fractional part will always be positive.
--- drivers/iio/industrialio-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/industrialio-core.c +2 -3
@@ -404,9 +404,8 @@ ssize_t iio_format_value(char *buf, unsireturn sprintf (buf,"%d.%09u\n" , vals[0 ], vals[1 ]);case IIO_VAL_FRACTIONAL : tmp =div_s64 ((s64 )vals[0 ] *1000000000LL , vals[1 ]); - vals[1 ] =do_div (tmp,1000000000LL ); - vals[0 ] = tmp; -return sprintf (buf,"%d.%09u\n" , vals[0 ], vals[1 ]); + vals[0 ] = (int )div_s64_rem (tmp,1000000000 , &vals[1 ]); +return sprintf (buf,"%d.%09u\n" , vals[0 ],abs (vals[1 ]));case IIO_VAL_FRACTIONAL_LOG2 : tmp = (s64 )vals[0 ] *1000000000LL >> vals[1 ]; vals[1 ] =do_div (tmp,1000000000LL );
PATCH 253/346 Btrfs: add missing blk_finish_plug in btrfs_sync_log()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Forrest Liu <[email protected]>
commit 3da5ab56482f322a9736c484db8773899c5c731b upstream.
Add missing blk_finish_plug in btrfs_sync_log()
--- fs/btrfs/tree-log.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/tree-log.c +1 -0
@@ -2600,6 +2600,7 @@ int btrfs_sync_log(struct btrfs_trans_ha }if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) { +blk_finish_plug (&plug);mutex_unlock (&log_root_tree->log_mutex); ret = root_log_ctx.log_ret; goto out;
PATCH 254/346 Btrfs: remove root_log_ctx from ctx list before btrfs_sync_log returns
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit cbd60aa7cd17d81a434234268c55192862147439 upstream.
We use a btrfs_log_ctx structure to pass information into the tree log commit, and get error values out. It gets added to a per log-transaction list which we walk when things go bad.
Commit d1433debe added an optimization to skip waiting for the log commit, but didn't take root_log_ctx out of the list. This patch makes sure we remove things before exiting.
--- fs/btrfs/tree-log.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/tree-log.c +1 -0
@@ -2601,6 +2601,7 @@ int btrfs_sync_log(struct btrfs_trans_haif (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) {blk_finish_plug (&plug); +list_del_init (&root_log_ctx.list);mutex_unlock (&log_root_tree->log_mutex); ret = root_log_ctx.log_ret; goto out;
PATCH 255/346 ipv6: addrconf: fix dev refcont leak when DAD failed
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Wei Yongjun <[email protected]>
commit 751eb6b6042a596b0080967c1a529a9fe98dac1d upstream.
In general, when DAD detected IPv6 duplicate address, ifp->state will be set to INET6_IFADDR_STATE_ERRDAD and DAD is stopped by a delayed work, the call tree should be like this:
ndisc_recv_ns
-> addrconf_dad_failure <- missing ifp put
-> addrconf_mod_dad_work
-> schedule addrconf_dad_work()
-> addrconf_dad_stop() <- missing ifp hold before call itaddrconf_dad_failure() called with ifp refcont holding but not put. addrconf_dad_work() call addrconf_dad_stop() without extra holding refcount. This will not cause any issue normally.
But the race between addrconf_dad_failure() and addrconf_dad_work() may cause ifp refcount leak and netdevice can not be unregister, dmesg show the following messages:
IPv6: eth0: IPv6 duplicate address fe80::XX:XXXX:XXXX:XX detected!
...unregister_netdevice: waiting for eth0 to become free. Usage count = 1
to workqueue")
--- net/ipv6/addrconf.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/addrconf.c +2 -0
@@ -1686,6 +1686,7 @@ void addrconf_dad_failure(struct inet6_ispin_unlock_bh (&ifp->state_lock);addrconf_mod_dad_work (ifp,0 ); +in6_ifa_put (ifp); }/* Join to solicited addr multicast group.
@@ -3262,6 +3263,7 @@ static void addrconf_dad_work(struct woraddrconf_dad_begin (ifp); goto out; }else if (action ==DAD_ABORT ) { +in6_ifa_hold (ifp);addrconf_dad_stop (ifp,1 ); goto out; }
PATCH 256/346 crypto: cryptd - initialize child shash_desc on import
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 0bd2223594a4dcddc1e34b15774a3a4776f7749e upstream.
When calling .import() on a cryptd ahash_request, the structure members that describe the child transform in the shash_desc need to be initialized like they are when calling .init()
--- crypto/cryptd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
crypto/cryptd.c +7 -2
@@ -565,9 +565,14 @@ static int cryptd_hash_export(struct ahastatic int cryptd_hash_import (struct ahash_request *req,const void *in) { -struct cryptd_hash_request_ctx *rctx =ahash_request_ctx (req); +struct crypto_ahash *tfm =crypto_ahash_reqtfm (req); +struct cryptd_hash_ctx *ctx =crypto_ahash_ctx (tfm); +struct shash_desc *desc =cryptd_shash_desc (req); -return crypto_shash_import (&rctx->desc, in); + desc->tfm = ctx->child; + desc->flags = req->base.flags; + +return crypto_shash_import (desc, in); } static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
PATCH 257/346 ALSA: timer: Fix zero-division by continue of uninitialized instance
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 9f8a7658bcafb2a7853f7a2eae8a94e87e6e695b upstream.
When a user timer instance is continued without the explicit start beforehand, the system gets eventually zero-division error like:
divide error: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN
CPU: 1 PID: 27320 Comm: syz-executor Not tainted 4.8.0-rc3-next-20160825+ #8 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff88003c9b2280 task.stack: ffff880027280000 RIP: 0010:[<ffffffff858e1a6c>] [< inline >] ktime_divns include/linux/ktime.h:195 RIP: 0010:[<ffffffff858e1a6c>] [<ffffffff858e1a6c>] snd_hrtimer_callback+0x1bc/0x3c0 sound/core/hrtimer.c:62 Call Trace: <IRQ> [< inline >] __run_hrtimer kernel/time/hrtimer.c:1238 [<ffffffff81504335>] __hrtimer_run_queues+0x325/0xe70 kernel/time/hrtimer.c:1302 [<ffffffff81506ceb>] hrtimer_interrupt+0x18b/0x420 kernel/time/hrtimer.c:1336 [<ffffffff8126d8df>] local_apic_timer_interrupt+0x6f/0xe0 arch/x86/kernel/apic/apic.c:933 [<ffffffff86e13056>] smp_apic_timer_interrupt+0x76/0xa0 arch/x86/kernel/apic/apic.c:957 [<ffffffff86e1210c>] apic_timer_interrupt+0x8c/0xa0 arch/x86/entry/entry_64.S:487 <EOI> .....
Although a similar issue was spotted and a fix patch was merged in commit [6b760bb2c63a: ALSA: timer: fix division by zero after SNDRV_TIMER_IOCTL_CONTINUE], it seems covering only a part of iceberg.
In this patch, we fix the issue a bit more drastically. Basically the continue of an uninitialized timer is supposed to be a fresh start, so we do it for user timers. For the direct snd_timer_continue() call, there is no way to pass the initial tick value, so we kick out for the uninitialized case.
[bwh: Backported to 3.16:
- Adjust context
- In _snd_timer_stop(), check the value of 'event' instead of 'stop']
--- sound/core/timer.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
sound/core/timer.c +14 -0
@@ -35,6 +35,9 @@#include <sound/initval.h> #include <linux/kmod.h> +/* internal flags */ +#define SNDRV_TIMER_IFLG_PAUSED 0x00010000 +#if IS_ENABLED (CONFIG_SND_HRTIMER )#define DEFAULT_TIMER_LIMIT 4#elif IS_ENABLED (CONFIG_SND_RTCTIMER )
@@ -569,6 +572,10 @@ static int _snd_timer_stop(struct snd_ti } } timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING |SNDRV_TIMER_IFLG_START ); +if (event ==SNDRV_TIMER_EVENT_STOP ) + timeri->flags &= ~SNDRV_TIMER_IFLG_PAUSED ; +else + timeri->flags |=SNDRV_TIMER_IFLG_PAUSED ;spin_unlock_irqrestore (&timer->lock, flags); __end:if (event !=SNDRV_TIMER_EVENT_RESOLUTION )
@@ -611,6 +618,10 @@ int snd_timer_continue(struct snd_timer_if (timeri ==NULL )return result; +/* timer can continue only after pause */ +if (!(timeri->flags &SNDRV_TIMER_IFLG_PAUSED )) +return -EINVAL ; +if (timeri->flags &SNDRV_TIMER_IFLG_SLAVE )return snd_timer_start_slave (timeri); timer = timeri->timer;
@@ -1844,6 +1855,9 @@ static int snd_timer_user_continue(struc tu = file->private_data;if (!tu->timeri)return -EBADFD ; +/* start timer instead of continue if it's not used before */ +if (!(tu->timeri->flags &SNDRV_TIMER_IFLG_PAUSED )) +return snd_timer_user_start (file); tu->timeri->lost =0 ;return (err =snd_timer_continue (tu->timeri)) <0 ? err :0 ; }
PATCH 258/346 ALSA: rawmidi: Fix possible deadlock with virmidi registration
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 816f318b2364262a51024096da7ca3b84e78e3b5 upstream.
When a seq-virmidi driver is initialized, it registers a rawmidi instance with its callback to create an associated seq kernel client. Currently it's done throughly in rawmidi's register_mutex context. Recently it was found that this may lead to a deadlock another rawmidi device that is being attached with the sequencer is accessed, as both open with the same register_mutex. This was actually triggered by syzkaller, as Dmitry Vyukov reported:
======================================================
[ INFO: possible circular locking dependency detected ]
4.8.0-rc1+ #11 Not tainted
-------------------------------------------------------
syz-executor/7154 is trying to acquire lock:
(register_mutex#5){+.+.+.}, at: [<ffffffff84fd6d4b>] snd_rawmidi_kernel_open+0x4b/0x260 sound/core/rawmidi.c:341
but task is already holding lock:
(&grp->list_mutex){++++.+}, at: [<ffffffff850138bb>] check_and_subscribe_port+0x5b/0x5c0 sound/core/seq/seq_ports.c:495
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (&grp->list_mutex){++++.+}:
[<ffffffff8147a3a8>] lock_acquire+0x208/0x430 kernel/locking/lockdep.c:3746
[<ffffffff863f6199>] down_read+0x49/0xc0 kernel/locking/rwsem.c:22
[< inline >] deliver_to_subscribers sound/core/seq/seq_clientmgr.c:681
[<ffffffff85005c5e>] snd_seq_deliver_event+0x35e/0x890 sound/core/seq/seq_clientmgr.c:822
[<ffffffff85006e96>] > snd_seq_kernel_client_dispatch+0x126/0x170 sound/core/seq/seq_clientmgr.c:2418
[<ffffffff85012c52>] snd_seq_system_broadcast+0xb2/0xf0 sound/core/seq/seq_system.c:101
[<ffffffff84fff70a>] snd_seq_create_kernel_client+0x24a/0x330 sound/core/seq/seq_clientmgr.c:2297
[< inline >] snd_virmidi_dev_attach_seq sound/core/seq/seq_virmidi.c:383
[<ffffffff8502d29f>] snd_virmidi_dev_register+0x29f/0x750 sound/core/seq/seq_virmidi.c:450
[<ffffffff84fd208c>] snd_rawmidi_dev_register+0x30c/0xd40 sound/core/rawmidi.c:1645
[<ffffffff84f816d3>] __snd_device_register.part.0+0x63/0xc0 sound/core/device.c:164
[< inline >] __snd_device_register sound/core/device.c:162
[<ffffffff84f8235d>] snd_device_register_all+0xad/0x110 sound/core/device.c:212
[<ffffffff84f7546f>] snd_card_register+0xef/0x6c0 sound/core/init.c:749
[<ffffffff85040b7f>] snd_virmidi_probe+0x3ef/0x590 sound/drivers/virmidi.c:123
[<ffffffff833ebf7b>] platform_drv_probe+0x8b/0x170 drivers/base/platform.c:564
......-> #0 (register_mutex#5){+.+.+.}:
[< inline >] check_prev_add kernel/locking/lockdep.c:1829
[< inline >] check_prevs_add kernel/locking/lockdep.c:1939
[< inline >] validate_chain kernel/locking/lockdep.c:2266
[<ffffffff814791f4>] __lock_acquire+0x4d44/0x4d80 kernel/locking/lockdep.c:3335
[<ffffffff8147a3a8>] lock_acquire+0x208/0x430 kernel/locking/lockdep.c:3746
[< inline >] __mutex_lock_common kernel/locking/mutex.c:521
[<ffffffff863f0ef1>] mutex_lock_nested+0xb1/0xa20 kernel/locking/mutex.c:621
[<ffffffff84fd6d4b>] snd_rawmidi_kernel_open+0x4b/0x260 sound/core/rawmidi.c:341
[<ffffffff8502e7c7>] midisynth_subscribe+0xf7/0x350 sound/core/seq/seq_midi.c:188
[< inline >] subscribe_port sound/core/seq/seq_ports.c:427
[<ffffffff85013cc7>] check_and_subscribe_port+0x467/0x5c0 sound/core/seq/seq_ports.c:510
[<ffffffff85015da9>] snd_seq_port_connect+0x2c9/0x500 sound/core/seq/seq_ports.c:579
[<ffffffff850079b8>] snd_seq_ioctl_subscribe_port+0x1d8/0x2b0 sound/core/seq/seq_clientmgr.c:1480
[<ffffffff84ffe9e4>] snd_seq_do_ioctl+0x184/0x1e0 sound/core/seq/seq_clientmgr.c:2225
[<ffffffff84ffeae8>] snd_seq_kernel_client_ctl+0xa8/0x110 sound/core/seq/seq_clientmgr.c:2440
[<ffffffff85027664>] snd_seq_oss_midi_open+0x3b4/0x610 sound/core/seq/oss/seq_oss_midi.c:375
[<ffffffff85023d67>] snd_seq_oss_synth_setup_midi+0x107/0x4c0 sound/core/seq/oss/seq_oss_synth.c:281
[<ffffffff8501b0a8>] snd_seq_oss_open+0x748/0x8d0 sound/core/seq/oss/seq_oss_init.c:274
[<ffffffff85019d8a>] odev_open+0x6a/0x90 sound/core/seq/oss/seq_oss.c:138
[<ffffffff84f7040f>] soundcore_open+0x30f/0x640 sound/sound_core.c:639
......other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&grp->list_mutex);
lock(register_mutex#5);
lock(&grp->list_mutex); lock(register_mutex#5);
*** DEADLOCK ***
======================================================
The fix is to simply move the registration parts in snd_rawmidi_dev_register() to the outside of the register_mutex lock. The lock is needed only to manage the linked list, and it's not necessarily to cover the whole initialization process.
--- sound/core/rawmidi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/core/rawmidi.c +3 -1
@@ -1637,12 +1637,14 @@ static int snd_rawmidi_dev_register(strureturn -EBUSY ; }list_add_tail (&rmidi->list, &snd_rawmidi_devices); +mutex_unlock (®ister_mutex);sprintf (name,"midiC%iD%i" , rmidi->card->number, rmidi->device);if ((err =snd_register_device (SNDRV_DEVICE_TYPE_RAWMIDI , rmidi->card, rmidi->device, &snd_rawmidi_f_ops, rmidi, name)) <0 ) {rmidi_err (rmidi,"unable to register rawmidi device %i:%i\n" , rmidi->card->number, rmidi->device); +mutex_lock (®ister_mutex);list_del (&rmidi->list);mutex_unlock (®ister_mutex);return err;
@@ -1650,6 +1652,7 @@ static int snd_rawmidi_dev_register(struif (rmidi->ops && rmidi->ops->dev_register && (err = rmidi->ops->dev_register (rmidi)) <0 ) {snd_unregister_device (SNDRV_DEVICE_TYPE_RAWMIDI , rmidi->card, rmidi->device); +mutex_lock (®ister_mutex);list_del (&rmidi->list);mutex_unlock (®ister_mutex);return err;
@@ -1682,7 +1685,6 @@ static int snd_rawmidi_dev_register(stru } }#endif /* CONFIG_SND_OSSEMUL */ -mutex_unlock (®ister_mutex);sprintf (name,"midi%d" , rmidi->device); entry =snd_info_create_card_entry (rmidi->card, name, rmidi->card->proc_root);if (entry) {
PATCH 259/346 xfrm_user: propagate sec ctx allocation errors
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Krause <[email protected]>
commit 2f30ea5090cbc57ea573cdc66421264b3de3fb0a upstream.
When we fail to attach the security context in xfrm_state_construct() we'll return 0 as error value which, in turn, will wrongly claim success to userland when, in fact, we won't be adding / updating the XFRM state.
This is a regression introduced by commit fd21150a0fe1 ("[XFRM] netlink:
Inline attach_encap_tmpl(), attach_sec_ctx(), and attach_one_addr()").
Fix it by propagating the error returned by security_xfrm_state_alloc() in this case.
--- net/xfrm/xfrm_user.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/xfrm/xfrm_user.c +6 -3
@@ -559,9 +559,12 @@ static struct xfrm_state *xfrm_state_conif (err) goto error; -if (attrs[XFRMA_SEC_CTX ] && -security_xfrm_state_alloc (x,nla_data (attrs[XFRMA_SEC_CTX ]))) - goto error; +if (attrs[XFRMA_SEC_CTX ]) { + err =security_xfrm_state_alloc (x, +nla_data (attrs[XFRMA_SEC_CTX ])); +if (err) + goto error; + }if ((err =xfrm_alloc_replay_state_esn (&x->replay_esn, &x->preplay_esn, attrs[XFRMA_REPLAY_ESN_VAL ])))
PATCH 260/346 kvm-arm: Unmap shadow pagetables properly
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Suzuki K Poulose <[email protected]>
commit 293f293637b55db4f9f522a5a72514e98a541076 upstream.
On arm/arm64, we depend on the kvm_unmap_hva* callbacks (via mmu_notifiers::invalidate_*) to unmap the stage2 pagetables when the userspace buffer gets unmapped. However, when the Hypervisor process exits without explicit unmap of the guest buffers, the only notifier we get is kvm_arch_flush_shadow_all() (via mmu_notifier::release ) which does nothing on arm. Later this causes us to access pages that were already released [via exit_mmap() -> unmap_vmas()] when we actually get to unmap the stage2 pagetable [via kvm_arch_destroy_vm() -> kvm_free_stage2_pgd()]. This triggers crashes with CONFIG_DEBUG_PAGEALLOC, which unmaps any free'd pages from the linear map.
[ 757.644120] Unable to handle kernel paging request at virtual address ffff800661e00000 [ 757.652046] pgd = ffff20000b1a2000 [ 757.655471] [ffff800661e00000] *pgd=00000047fffe3003, *pud=00000047fcd8c003, *pmd=00000047fcc7c003, *pte=00e8004661e00712 [ 757.666492] Internal error: Oops: 96000147 [#3] PREEMPT SMP [ 757.672041] Modules linked in: [ 757.675100] CPU: 7 PID: 3630 Comm: qemu-system-aar Tainted: G D 4.8.0-rc1 #3 [ 757.683240] Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene Mustang Board, BIOS 3.06.15 Aug 19 2016 [ 757.692938] task: ffff80069cdd3580 task.stack: ffff8006adb7c000 [ 757.698840] PC is at __flush_dcache_area+0x1c/0x40 [ 757.703613] LR is at kvm_flush_dcache_pmd+0x60/0x70 [ 757.708469] pc : [<ffff20000809dbdc>] lr : [<ffff2000080b4a70>] pstate: 20000145 ... [ 758.357249] [<ffff20000809dbdc>] __flush_dcache_area+0x1c/0x40 [ 758.363059] [<ffff2000080b6748>] unmap_stage2_range+0x458/0x5f0 [ 758.368954] [<ffff2000080b708c>] kvm_free_stage2_pgd+0x34/0x60 [ 758.374761] [<ffff2000080b2280>] kvm_arch_destroy_vm+0x20/0x68 [ 758.380570] [<ffff2000080aa330>] kvm_put_kvm+0x210/0x358 [ 758.385860] [<ffff2000080aa524>] kvm_vm_release+0x2c/0x40 [ 758.391239] [<ffff2000082ad234>] __fput+0x114/0x2e8 [ 758.396096] [<ffff2000082ad46c>] ____fput+0xc/0x18 [ 758.400869] [<ffff200008104658>] task_work_run+0x108/0x138 [ 758.406332] [<ffff2000080dc8ec>] do_exit+0x48c/0x10e8 [ 758.411363] [<ffff2000080dd5fc>] do_group_exit+0x6c/0x130 [ 758.416739] [<ffff2000080ed924>] get_signal+0x284/0xa18 [ 758.421943] [<ffff20000808a098>] do_signal+0x158/0x860 [ 758.427060] [<ffff20000808aad4>] do_notify_resume+0x6c/0x88 [ 758.432608] [<ffff200008083624>] work_pending+0x10/0x14 [ 758.437812] Code: 9ac32042 8b010001 d1000443 8a230000 (d50b7e20)
This patch fixes the issue by moving the kvm_free_stage2_pgd() to kvm_arch_flush_shadow_all().
--- arch/arm/kvm/arm.c | 2 -- arch/arm/kvm/mmu.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-)
arch/arm/kvm/arm.c +0 -2
@@ -164,8 +164,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm {int i; -kvm_free_stage2_pgd (kvm); -for (i =0 ; i <KVM_MAX_VCPUS ; ++i) {if (kvm->vcpus[i]) {kvm_arch_vcpu_free (kvm->vcpus[i]);
arch/arm/kvm/mmu.c +1 -0
@@ -1257,6 +1257,7 @@ void kvm_arch_memslots_updated(struct kvvoid kvm_arch_flush_shadow_all (struct kvm *kvm) { +kvm_free_stage2_pgd (kvm); } void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
PATCH 261/346 arm64: spinlocks: implement smp_mb__before_spinlock() as smp_mb()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit 872c63fbf9e153146b07f0cece4da0d70b283eeb upstream.
smp_mb__before_spinlock() is intended to upgrade a spin_lock() operation to a full barrier, such that prior stores are ordered with respect to loads and stores occuring inside the critical section.
Unfortunately, the core code defines the barrier as smp_wmb(), which is insufficient to provide the required ordering guarantees when used in conjunction with our load-acquire-based spinlock implementation.
This patch overrides the arm64 definition of smp_mb__before_spinlock() to map to a full smp_mb().
--- arch/arm64/include/asm/spinlock.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/include/asm/spinlock.h +10 -0
@@ -231,4 +231,14 @@ static inline int arch_read_trylock(arch#define arch_read_relax (lock) cpu_relax()#define arch_write_relax (lock) cpu_relax() +/* +* Accesses appearing in program order before a spin_lock() operation +* can be reordered with accesses inside the critical section, by virtue +* of arch_spin_lock being constructed using acquire semantics. +* +* In cases where this is problematic (e.g. try_to_wake_up), an +* smp_mb__before_spinlock() can restore the required ordering. +*/ +#define smp_mb__before_spinlock () smp_mb() +#endif /* __ASM_SPINLOCK_H */
PATCH 262/346 alpha: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 2561d309dfd1555e781484af757ed0115035ddb3 upstream.
it should clear the destination even when access_ok() fails.
--- arch/alpha/include/asm/uaccess.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
arch/alpha/include/asm/uaccess.h +8 -11
@@ -371,14 +371,6 @@ __copy_tofrom_user_nocheck(void *to, conreturn __cu_len; } -extern inline long -__copy_tofrom_user (void *to,const void *from,long len,const void __user *validate) -{ -if (__access_ok ((unsigned long )validate, len,get_fs ())) - len =__copy_tofrom_user_nocheck (to, from, len); -return len; -} -#define __copy_to_user (to,from,n) \ ({ \ __chk_user_ptr(to); \
@@ -393,17 +385,22 @@ __copy_tofrom_user(void *to, const void#define __copy_to_user_inatomic __copy_to_user#define __copy_from_user_inatomic __copy_from_user -extern inline long copy_to_user (void __user *to,const void *from,long n) { -return __copy_tofrom_user ((__force void *)to, from, n, to); +if (likely (__access_ok ((unsigned long )to, n,get_fs ()))) + n =__copy_tofrom_user_nocheck ((__force void *)to, from, n); +return n; }extern inline long copy_from_user (void *to,const void __user *from,long n) { -return __copy_tofrom_user (to, (__force void *)from, n, from); +if (likely (__access_ok ((unsigned long )from, n,get_fs ()))) + n =__copy_tofrom_user_nocheck (to, (__force void *)from, n); +else +memset (to,0 , n); +return n; }extern void __do_clear_user (void );
PATCH 263/346 asm-generic: make copy_from_user() zero the destination properly
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 2545e5da080b4839dd859e3b09343a884f6ab0e3 upstream.
... in all cases, including the failing access_ok()
Note that some architectures using asm-generic/uaccess.h have __copy_from_user() not zeroing the tail on failure halfway through. This variant works either way.
--- include/asm-generic/uaccess.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
include/asm-generic/uaccess.h +6 -4
@@ -255,11 +255,13 @@ extern int __get_user_bad(void) __attribstatic inline long copy_from_user (void *to,const void __user * from,unsigned long n) { +unsigned long res = n;might_fault (); -if (access_ok (VERIFY_READ , from, n)) -return __copy_from_user (to, from, n); -else -return n; +if (likely (access_ok (VERIFY_READ , from, n))) + res =__copy_from_user (to, from, n); +if (unlikely (res)) +memset (to + (n - res),0 , res); +return res; } static inline long copy_to_user(void __user *to,
PATCH 264/346 mtd: nand: davinci: Reinitialize the HW ECC engine in 4bit hwctl
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Karl Beldan <[email protected]>
commit f6d7c1b5598b6407c3f1da795dd54acf99c1990c upstream.
This fixes subpage writes when using 4-bit HW ECC.
There has been numerous reports about ECC errors with devices using this driver for a while. Also the 4-bit ECC has been reported as broken with subpages in [1] and with 16 bits NANDs in the driver and in mach* board files both in mainline and in the vendor BSPs.
What I saw with 4-bit ECC on a 16bits NAND (on an LCDK) which got me to try reinitializing the ECC engine:
- R/W on whole pages properly generates/checks RS code
- try writing the 1st subpage only of a blank page, the subpage is well written and the RS code properly generated, re-reading the same page the HW detects some ECC error, reading the same page again no ECC error is detected
Note that the ECC engine is already reinitialized in the 1-bit case.
Tested on my LCDK with UBI+UBIFS using subpages.
This could potentially get rid of the issue workarounded in [1].
[1] 28c015a9daab ("mtd: davinci-nand: disable subpage write for keystone-nand")
--- drivers/mtd/nand/davinci_nand.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/nand/davinci_nand.c +3 -0
@@ -241,6 +241,9 @@ static void nand_davinci_hwctl_4bit(struunsigned long flags;u32 val; +/* Reset ECC hardware */ +davinci_nand_readl (info,NAND_4BIT_ECC1_OFFSET ); +spin_lock_irqsave (&davinci_nand_lock, flags);/* Start 4-bit ECC calculation for read/write */
PATCH 265/346 NFSv4.1: Fix the CREATE_SESSION slot number accounting
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit b519d408ea32040b1c7e10b155a3ee9a36660947 upstream.
Ensure that we conform to the algorithm described in RFC5661, section 18.36.4 for when to bump the sequence id. In essence we do it for all cases except when the RPC call timed out, or in case of the server returning NFS4ERR_DELAY or NFS4ERR_STALE_CLIENTID.
[bwh: Backported to 3.16:
- Add the 'out' label
- Adjust context]
---
fs/nfs/nfs4proc.c +11 -2
@@ -7063,13 +7063,22 @@ static int _nfs4_proc_create_session(str status =rpc_call_sync (session->clp->cl_rpcclient, &msg,RPC_TASK_TIMEOUT );trace_nfs4_create_session (clp, status); +switch (status) { +case -NFS4ERR_STALE_CLIENTID : +case -NFS4ERR_DELAY : +case -ETIMEDOUT : +case -EACCES : +case -EAGAIN : + goto out; + }; + + clp->cl_seqid++;if (!status) {/* Verify the session's negotiated channel_attrs values */ status =nfs4_verify_channel_attrs (&args, session); -/* Increment the clientid slot sequence id */ - clp->cl_seqid++; } +out:return status; }
PATCH 266/346 USB: serial: simple: add support for another Infineon flashloader
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Daniele Palmas <[email protected]>
commit f190fd92458da3e869b4e2c6289e2c617490ae53 upstream.
This patch adds support for Infineon flashloader 0x8087/0x0801.
The flashloader is used in Telit LE940B modem family with Telit flashing application.
--- drivers/usb/serial/usb-serial-simple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/serial/usb-serial-simple.c +2 -1
@@ -48,7 +48,8 @@ DEVICE(funsoft, FUNSOFT_IDS);/* Infineon Flashloader driver */ #define FLASHLOADER_IDS () \ { USB_DEVICE_INTERFACE_CLASS(0x058b, 0x0041, USB_CLASS_CDC_DATA) }, \ - { USB_DEVICE(0x8087, 0x0716) } + { USB_DEVICE(0x8087, 0x0716) }, \ + { USB_DEVICE(0x8087, 0x0801) }DEVICE (flashloader,FLASHLOADER_IDS );/* Google Serial USB SubClass */
PATCH 267/346 ARM: sa1111: fix pcmcia suspend/resume
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
commit 06dfe5cc0cc684e735cb0232fdb756d30780b05d upstream.
SA1111 PCMCIA was broken when PCMCIA switched to using dev_pm_ops for the PCMCIA socket class. PCMCIA used to handle suspend/resume via the socket hosting device, which happened at normal device suspend/resume time.
However, the referenced commit changed this: much of the resume now happens much earlier, in the noirq resume handler of dev_pm_ops.
However, on SA1111, the PCMCIA device is not accessible as the SA1111 has not been resumed at _noirq time. It's slightly worse than that, because the SA1111 has already been put to sleep at _noirq time, so suspend doesn't work properly.
Fix this by converting the core SA1111 code to use dev_pm_ops as well, and performing its own suspend/resume at noirq time.
This fixes these errors in the kernel log:
pcmcia_socket pcmcia_socket0: time out after reset pcmcia_socket pcmcia_socket1: time out after reset
and the resulting lack of PCMCIA cards after a S2RAM cycle.
--- arch/arm/common/sa1111.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
arch/arm/common/sa1111.c +13 -9
@@ -872,9 +872,9 @@ struct sa1111_save_data {#ifdef CONFIG_PM -static int sa1111_suspend (struct platform_device *dev,pm_message_t state) +static int sa1111_suspend_noirq (struct device *dev) { -struct sa1111 *sachip =platform_get_drvdata (dev); +struct sa1111 *sachip =dev_get_drvdata (dev);struct sa1111_save_data *save;unsigned long flags;unsigned int val;
@@ -937,9 +937,9 @@ static int sa1111_suspend(struct platfor* restored by their respective drivers, and must be called * via LDM after this function. */ -static int sa1111_resume (struct platform_device *dev) +static int sa1111_resume_noirq (struct device *dev) { -struct sa1111 *sachip =platform_get_drvdata (dev); +struct sa1111 *sachip =dev_get_drvdata (dev);struct sa1111_save_data *save;unsigned long flags, id;void __iomem *base;
@@ -955,7 +955,7 @@ static int sa1111_resume(struct platform id =sa1111_readl (sachip->base +SA1111_SKID );if ((id &SKID_ID_MASK ) !=SKID_SA1111_ID ) {__sa1111_remove (sachip); -platform_set_drvdata (dev,NULL ); +dev_set_drvdata (dev,NULL );kfree (save);return 0 ; }
@@ -1006,8 +1006,8 @@ static int sa1111_resume(struct platform }#else -#define sa1111_suspend NULL -#define sa1111_resume NULL +#define sa1111_suspend_noirq NULL +#define sa1111_resume_noirq NULL#endif static int sa1111_probe (struct platform_device *pdev)
@@ -1041,6 +1041,11 @@ static int sa1111_remove(struct platformreturn 0 ; } +static struct dev_pm_ops sa1111_pm_ops = { + .suspend_noirq = sa1111_suspend_noirq, + .resume_noirq = sa1111_resume_noirq, +}; +/* * Not sure if this should be on the system bus or not yet. * We really want some way to register a system device at
@@ -1053,11 +1058,10 @@ static int sa1111_remove(struct platformstatic struct platform_driver sa1111_device_driver = { .probe = sa1111_probe, .remove = sa1111_remove, - .suspend = sa1111_suspend, - .resume = sa1111_resume, .driver = { .name ="sa1111" , .owner =THIS_MODULE , + .pm = &sa1111_pm_ops, }, };
PATCH 268/346 crypto: skcipher - Fix blkcipher walk OOM crash
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit acdb04d0b36769b3e05990c488dc74d8b7ac8060 upstream.
When we need to allocate a temporary blkcipher_walk_next and it fails, the code is supposed to take the slow path of processing the data block by block. However, due to an unrelated change we instead end up dereferencing the NULL pointer.
This patch fixes it by moving the unrelated bsize setting out of the way so that we enter the slow path as inteded.
--- crypto/blkcipher.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
crypto/blkcipher.c +2 -1
@@ -233,6 +233,8 @@ static int blkcipher_walk_next(struct blreturn blkcipher_walk_done (desc, walk, -EINVAL ); } + bsize =min (walk->walk_blocksize, n); + walk->flags &= ~(BLKCIPHER_WALK_SLOW |BLKCIPHER_WALK_COPY |BLKCIPHER_WALK_DIFF ); if (!scatterwalk_aligned(&walk->in, walk->alignmask) ||
@@ -245,7 +247,6 @@ static int blkcipher_walk_next(struct bl } } - bsize =min (walk->walk_blocksize, n); n =scatterwalk_clamp (&walk->in, n); n =scatterwalk_clamp (&walk->out, n);
PATCH 269/346 crypto: arm64/aes-ctr - fix NULL dereference in tail processing
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 2db34e78f126c6001d79d3b66ab1abb482dc7caa upstream.
The AES-CTR glue code avoids calling into the blkcipher API for the tail portion of the walk, by comparing the remainder of walk.nbytes modulo AES_BLOCK_SIZE with the residual nbytes, and jumping straight into the tail processing block if they are equal. This tail processing block checks whether nbytes != 0, and does nothing otherwise.
However, in case of an allocation failure in the blkcipher layer, we may enter this code with walk.nbytes == 0, while nbytes > 0. In this case, we should not dereference the source and destination pointers, since they may be NULL. So instead of checking for nbytes != 0, check for (walk.nbytes % AES_BLOCK_SIZE) != 0, which implies the former in non-error conditions.
--- arch/arm64/crypto/aes-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/crypto/aes-glue.c +1 -1
@@ -205,7 +205,7 @@ static int ctr_encrypt(struct blkcipher_ err =blkcipher_walk_done (desc, &walk, walk.nbytes %AES_BLOCK_SIZE ); } -if (nbytes) { +if (walk.nbytes %AES_BLOCK_SIZE ) {u8 *tdst = walk.dst.virt.addr + blocks *AES_BLOCK_SIZE ;u8 *tsrc = walk.src.virt.addr + blocks *AES_BLOCK_SIZE ;u8 __aligned(8) tail[AES_BLOCK_SIZE ];
PATCH 270/346 MIPS: paravirt: Fix undefined reference to smp_bootstrap
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Redfearn <[email protected]>
commit 951c39cd3bc0aedf67fbd8fb4b9380287e6205d1 upstream.
If the paravirt machine is compiles without CONFIG_SMP, the following linker error occurs
arch/mips/kernel/head.o: In function `kernel_entry':
(.ref.text+0x10): undefined reference to `smp_bootstrap'
due to the kernel entry macro always including SMP startup code. Wrap this code in CONFIG_SMP to fix the error.
Patchwork: https://patchwork.linux-mips.org/patch/14212/
--- arch/mips/include/asm/mach-paravirt/kernel-entry-init.h | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/include/asm/mach-paravirt/kernel-entry-init.h +2 -0
@@ -11,11 +11,13 @@#define CP0_EBASE $15, 1 .macro kernel_entry_setup +#ifdef CONFIG_SMP mfc0 t0,CP0_EBASE andi t0, t0, 0x3ff # CPUNum beqz t0, 1f # CPUs other than zero goto smp_bootstrap j smp_bootstrap +#endif /* CONFIG_SMP */ 1: .endm
PATCH 271/346 nl80211: validate number of probe response CSA counters
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit ad5987b47e96a0fb6d13fea250e936aed000093c upstream.
Due to an apparent copy/paste bug, the number of counters for the beacon configuration were checked twice, instead of checking the number of probe response counters. Fix this to check the number of probe response counters before parsing those.
--- net/wireless/nl80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/nl80211.c +1 -1
@@ -5980,7 +5980,7 @@ static int nl80211_channel_switch(struct params.n_counter_offsets_presp = len /sizeof (u16);if (rdev->wiphy.max_num_csa_counters && - (params.n_counter_offsets_beacon > + (params.n_counter_offsets_presp > rdev->wiphy.max_num_csa_counters))return -EINVAL ;
PATCH 272/346 asm-generic: make get_user() clear the destination on errors
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 9ad18b75c2f6e4a78ce204e79f37781f8815c0fa upstream.
both for access_ok() failures and for faults halfway through
--- include/asm-generic/uaccess.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
include/asm-generic/uaccess.h +7 -3
@@ -228,14 +228,18 @@ extern int __put_user_bad(void) __attribmight_fault (); \access_ok (VERIFY_READ , ptr,sizeof (*ptr)) ? \__get_user (x, ptr) : \ - -EFAULT ; \ + ((x) = (__typeof__ (*(ptr )))0 ,-EFAULT ); \ })#ifndef __get_user_fnstatic inline int __get_user_fn (size_t size,const void __user *ptr,void *x) { - size =__copy_from_user (x, ptr, size); -return size ? -EFAULT : size; +size_t n =__copy_from_user (x, ptr, size); +if (unlikely (n)) { +memset (x + (size - n),0 , n); +return -EFAULT ; + } +return 0 ; }#define __get_user_fn (sz, u, k) __get_user_fn(sz, u, k)
PATCH 273/346 cris: buggered copy_from_user/copy_to_user/clear_user
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit eb47e0293baaa3044022059f1fa9ff474bfe35cb upstream.
* copy_from_user() on access_ok() failure ought to zero the destination
* none of those primitives should skip the access_ok() check in case of small constant size.
--- arch/cris/include/asm/uaccess.h | 71 +++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 39 deletions(-)
arch/cris/include/asm/uaccess.h +34 -41
@@ -176,30 +176,6 @@ extern unsigned long __copy_user(void __extern unsigned long __copy_user_zeroing (void *to,const void __user *from,unsigned long n);extern unsigned long __do_clear_user (void __user *to,unsigned long n); -static inline unsigned long -__generic_copy_to_user (void __user *to,const void *from,unsigned long n) -{ -if (access_ok (VERIFY_WRITE , to, n)) -return __copy_user (to,from,n); -return n; -} - -static inline unsigned long -__generic_copy_from_user (void *to,const void __user *from,unsigned long n) -{ -if (access_ok (VERIFY_READ , from, n)) -return __copy_user_zeroing (to,from,n); -return n; -} - -static inline unsigned long -__generic_clear_user (void __user *to,unsigned long n) -{ -if (access_ok (VERIFY_WRITE , to, n)) -return __do_clear_user (to,n); -return n; -} -static inline long __strncpy_from_user (char *dst,const char __user *src,long count) {
@@ -262,7 +238,7 @@ __constant_copy_from_user(void *to, conselse if (n ==24 )__asm_copy_from_user_24 (to, from, ret);else - ret =__generic_copy_from_user (to, from, n); + ret =__copy_user_zeroing (to, from, n);return ret; }
@@ -312,7 +288,7 @@ __constant_copy_to_user(void __user *to,else if (n ==24 )__asm_copy_to_user_24 (to, from, ret);else - ret =__generic_copy_to_user (to, from, n); + ret =__copy_user (to, from, n);return ret; }
@@ -344,26 +320,43 @@ __constant_clear_user(void __user *to, uelse if (n ==24 )__asm_clear_24 (to, ret);else - ret =__generic_clear_user (to, n); + ret =__do_clear_user (to, n);return ret; } -#define clear_user (to, n) \ -(__builtin_constant_p(n) ? \ - __constant_clear_user(to, n) : \ - __generic_clear_user(to, n)) - -#define copy_from_user (to, from, n) \ -(__builtin_constant_p(n) ? \ - __constant_copy_from_user(to, from, n) : \ - __generic_copy_from_user(to, from, n)) - -#define copy_to_user (to, from, n) \ -(__builtin_constant_p(n) ? \ - __constant_copy_to_user(to, from, n) : \ - __generic_copy_to_user(to, from, n)) +static inline size_t clear_user (void __user *to,size_t n) +{ +if (unlikely (!access_ok (VERIFY_WRITE , to, n))) +return n; +if (__builtin_constant_p (n)) +return __constant_clear_user (to, n); +else +return __do_clear_user (to, n); +} + +static inline size_t copy_from_user (void *to,const void __user *from,size_t n) +{ +if (unlikely (!access_ok (VERIFY_READ , from, n))) { +memset (to,0 , n); +return n; + } +if (__builtin_constant_p (n)) +return __constant_copy_from_user (to, from, n); +else +return __copy_user_zeroing (to, from, n); +} + +static inline size_t copy_to_user (void __user *to,const void *from,size_t n) +{ +if (unlikely (!access_ok (VERIFY_WRITE , to, n))) +return n; +if (__builtin_constant_p (n)) +return __constant_copy_to_user (to, from, n); +else +return __copy_user (to, from, n); +}/* We let the __ versions of copy_from/to_user inline, because they're often * used in fast paths and have only a small space overhead.
PATCH 274/346 frv: fix clear_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 3b8767a8f00cc6538ba6b1cf0f88502e2fd2eb90 upstream.
It should check access_ok(). Otherwise a bunch of places turn into trivially exploitable rootholes.
--- arch/frv/include/asm/uaccess.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/frv/include/asm/uaccess.h +9 -3
@@ -263,19 +263,25 @@ do { \extern long __memset_user (void *dst,unsigned long count);extern long __memcpy_user (void *dst,const void *src,unsigned long count); -#define clear_user (dst,count) __memset_user(____force(dst), (count)) +#define __clear_user (dst,count) __memset_user(____force(dst), (count))#define __copy_from_user_inatomic (to, from, n) __memcpy_user((to), ____force(from), (n))#define __copy_to_user_inatomic (to, from, n) __memcpy_user(____force(to), (from), (n))#else -#define clear_user (dst,count) (memset(____force(dst), 0, (count)), 0) +#define __clear_user (dst,count) (memset(____force(dst), 0, (count)), 0)#define __copy_from_user_inatomic (to, from, n) (memcpy((to), ____force(from), (n)), 0)#define __copy_to_user_inatomic (to, from, n) (memcpy(____force(to), (from), (n)), 0)#endif -#define __clear_user clear_user +static inline unsigned long __must_check +clear_user (void __user *to,unsigned long n) +{ +if (likely (__access_ok (to, n))) + n =__clear_user (to, n); +return n; +}static inline unsigned long __must_check __copy_to_user (void __user *to,const void *from,unsigned long n)
PATCH 275/346 hexagon: fix strncpy_from_user() error return
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit f35c1e0671728d1c9abc405d05ef548b5fcb2fc4 upstream.
It's -EFAULT, not -1 (and contrary to the comment in there, __strnlen_user() can return 0 - on faults).
--- arch/hexagon/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/hexagon/include/asm/uaccess.h +2 -1
@@ -102,7 +102,8 @@ static inline long hexagon_strncpy_from_ {long res =__strnlen_user (src, n); -/* return from strnlen can't be zero -- that would be rubbish. */ +if (unlikely (!res)) +return -EFAULT ;if (res > n) {copy_from_user (dst, src, n);
PATCH 276/346 ia64: copy_from_user() should zero the destination on access_ok() failure
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit a5e541f796f17228793694d64b507f5f57db4cd7 upstream.
---
arch/ia64/include/asm/uaccess.h +9 -11
@@ -262,17 +262,15 @@ __copy_from_user (void *to, const void _ __cu_len; \ }) -#define copy_from_user (to, from, n) \ -({ \ - void *__cu_to = (to); \ - const void __user *__cu_from = (from); \ - long __cu_len = (n); \ - \ - __chk_user_ptr(__cu_from); \ - if (__access_ok(__cu_from, __cu_len, get_fs())) \ - __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \ - __cu_len; \ -}) +static inline unsigned long +copy_from_user (void *to,const void __user *from,unsigned long n) +{ +if (likely (__access_ok (from, n,get_fs ()))) + n =__copy_user ((__force void __user *) to, from, n); +else +memset (to,0 , n); +return n; +}#define __copy_in_user (to, from, size) __copy_user((to), (from), (size))
PATCH 277/346 metag: copy_from_user() should zero the destination on access_ok() failure
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 8ae95ed4ae5fc7c3391ed668b2014c9e2079533b upstream.
--- arch/metag/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/metag/include/asm/uaccess.h +2 -1
@@ -199,8 +199,9 @@ extern unsigned long __must_check __copystatic inline unsigned long copy_from_user (void *to,const void __user *from,unsigned long n) { -if (access_ok (VERIFY_READ , from, n)) +if (likely (access_ok (VERIFY_READ , from, n)))return __copy_user_zeroing (to, from, n); +memset (to,0 , n);return n; }
PATCH 278/346 ARC: uaccess: get_user to zero out dest in cause of fault
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit 05d9d0b96e53c52a113fd783c0c97c830c8dc7af upstream.
Al reported potential issue with ARC get_user() as it wasn't clearing out destination pointer in case of fault due to bad address etc.
Verified using following
| {
| u32 bogus1 = 0xdeadbeef;
| u64 bogus2 = 0xdead;
| int rc1, rc2;
|
| pr_info("Orig values %x %llx\n", bogus1, bogus2);
| rc1 = get_user(bogus1, (u32 __user *)0x40000000);
| rc2 = get_user(bogus2, (u64 __user *)0x50000000);
| pr_info("access %d %d, new values %x %llx\n",
| rc1, rc2, bogus1, bogus2);
| }| [ARCLinux]# insmod /mnt/kernel-module/qtn.ko | Orig values deadbeef dead | access -14 -14, new values 0 0
--- arch/arc/include/asm/uaccess.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arc/include/asm/uaccess.h +9 -2
@@ -83,7 +83,10 @@"2: ;nop\n" \" .section .fixup, \"ax\"\n" \" .align 4\n" \ -"3: mov %0, %3\n" \ +"3: # return -EFAULT\n" \ +" mov %0, %3\n" \ +" # zero out dst ptr\n" \ +" mov %1, 0\n" \" j 2b\n" \" .previous\n" \" .section __ex_table, \"a\"\n" \
@@ -101,7 +104,11 @@"2: ;nop\n" \" .section .fixup, \"ax\"\n" \" .align 4\n" \ -"3: mov %0, %3\n" \ +"3: # return -EFAULT\n" \ +" mov %0, %3\n" \ +" # zero out dst ptr\n" \ +" mov %1, 0\n" \ +" mov %R1, 0\n" \" j 2b\n" \" .previous\n" \" .section __ex_table, \"a\"\n" \
PATCH 279/346 mips: copy_from_user() must zero the destination on access_ok() failure
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit e69d700535ac43a18032b3c399c69bf4639e89a2 upstream.
--- arch/mips/include/asm/uaccess.h | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/include/asm/uaccess.h +3 -0
@@ -14,6 +14,7 @@#include <linux/kernel.h> #include <linux/errno.h> #include <linux/thread_info.h> +#include <linux/string.h> #include <asm/asm-eva.h> /*
@@ -1139,6 +1140,8 @@ extern size_t __copy_in_user_eva(void *_ __cu_len =__invoke_copy_from_user (__cu_to, \ __cu_from, \ __cu_len); \ + }else { \ +memset (__cu_to,0 , __cu_len); \ } \ } \ __cu_len; \
PATCH 280/346 mn10300: failing __get_user() and get_user() should zero
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 43403eabf558d2800b429cd886e996fd555aa542 upstream.
--- arch/mn10300/include/asm/uaccess.h | 1 + 1 file changed, 1 insertion(+)
arch/mn10300/include/asm/uaccess.h +1 -0
@@ -181,6 +181,7 @@ struct __large_struct { unsigned long bu"2:\n" \" .section .fixup,\"ax\"\n" \"3:\n\t" \ +" mov 0,%1\n" \" mov %3,%0\n" \" jmp 2b\n" \" .previous\n" \
PATCH 281/346 mn10300: copy_from_user() should zero on access_ok() failure...
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit ae7cc577ec2a4a6151c9e928fd1f595d953ecef1 upstream.
--- arch/mn10300/lib/usercopy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mn10300/lib/usercopy.c +3 -1
@@ -9,7 +9,7 @@* as published by the Free Software Foundation; either version * 2 of the Licence, or (at your option) any later version. */ -#include <asm/uaccess.h> +#include <linux/uaccess.h> unsigned long __generic_copy_to_user (void *to,const void *from,unsigned long n)
@@ -24,6 +24,8 @@ __generic_copy_from_user(void *to, const {if (access_ok (VERIFY_READ , from, n))__copy_user_zeroing (to, from, n); +else +memset (to,0 , n);return n; }
PATCH 282/346 openrisc: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit acb2505d0119033a80c85ac8d02dccae41271667 upstream.
... that should zero on faults. Also remove the <censored> helpful logics wrt range truncation copied from ppc32. Where it had ever been needed only in case of copy_from_user() *and* had not been merged into the mainline until a month after the need had disappeared. A decade before openrisc went into mainline, I might add...
--- arch/openrisc/include/asm/uaccess.h | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-)
arch/openrisc/include/asm/uaccess.h +10 -23
@@ -273,28 +273,20 @@ __copy_tofrom_user(void *to, const voidstatic inline unsigned long copy_from_user (void *to,const void *from,unsigned long n) { -unsigned long over; +unsigned long res = n; -if (access_ok (VERIFY_READ , from, n)) -return __copy_tofrom_user (to, from, n); -if ((unsigned long )from <TASK_SIZE ) { - over = (unsigned long )from + n -TASK_SIZE ; -return __copy_tofrom_user (to, from, n - over) + over; - } -return n; +if (likely (access_ok (VERIFY_READ , from, n))) + n =__copy_tofrom_user (to, from, n); +if (unlikely (res)) +memset (to + (n - res),0 , res); +return res; }static inline unsigned long copy_to_user (void *to,const void *from,unsigned long n) { -unsigned long over; - -if (access_ok (VERIFY_WRITE , to, n)) -return __copy_tofrom_user (to, from, n); -if ((unsigned long )to <TASK_SIZE ) { - over = (unsigned long )to + n -TASK_SIZE ; -return __copy_tofrom_user (to, from, n - over) + over; - } +if (likely (access_ok (VERIFY_WRITE , to, n))) + n =__copy_tofrom_user (to, from, n);return n; }
@@ -303,13 +295,8 @@ extern unsigned long __clear_user(void *static inline __must_check unsigned long clear_user (void *addr,unsigned long size) { - -if (access_ok (VERIFY_WRITE , addr, size)) -return __clear_user (addr, size); -if ((unsigned long )addr <TASK_SIZE ) { -unsigned long over = (unsigned long )addr + size -TASK_SIZE ; -return __clear_user (addr, size - over) + over; - } +if (likely (access_ok (VERIFY_WRITE , addr, size))) + size =__clear_user (addr, size);return size; }
PATCH 283/346 parisc: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit aace880feea38875fbc919761b77e5732a3659ef upstream.
---
arch/parisc/include/asm/uaccess.h +5 -2
@@ -9,6 +9,8 @@#include <asm/errno.h> #include <asm-generic/uaccess-unaligned.h> +#include <linux/string.h> +#define VERIFY_READ 0#define VERIFY_WRITE 1
@@ -248,13 +250,14 @@ static inline unsigned long __must_check unsigned long n) {int sz =__compiletime_object_size (to); -int ret = -EFAULT ; +unsigned long ret = n;if (likely (sz ==-1 || !__builtin_constant_p (n) || sz >= n)) ret =__copy_from_user (to, from, n);else copy_from_user_overflow (); - +if (unlikely (ret)) +memset (to + (n - ret),0 , ret);return ret; }
PATCH 284/346 ppc32: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 224264657b8b228f949b42346e09ed8c90136a8e upstream.
should clear on access_ok() failures. Also remove the useless range truncation logics.
---
arch/powerpc/include/asm/uaccess.h +2 -19
@@ -323,30 +323,17 @@ extern unsigned long __copy_tofrom_user(static inline unsigned long copy_from_user (void *to,const void __user *from,unsigned long n) { -unsigned long over; - -if (access_ok (VERIFY_READ , from, n)) +if (likely (access_ok (VERIFY_READ , from, n)))return __copy_tofrom_user ((__force void __user *)to, from, n); -if ((unsigned long )from <TASK_SIZE ) { - over = (unsigned long )from + n -TASK_SIZE ; -return __copy_tofrom_user ((__force void __user *)to, from, - n - over) + over; - } +memset (to,0 , n);return n; }static inline unsigned long copy_to_user (void __user *to,const void *from,unsigned long n) { -unsigned long over; -if (access_ok (VERIFY_WRITE , to, n))return __copy_tofrom_user (to, (__force void __user *)from, n); -if ((unsigned long )to <TASK_SIZE ) { - over = (unsigned long )to + n -TASK_SIZE ; -return __copy_tofrom_user (to, (__force void __user *)from, - n - over) + over; - }return n; }
@@ -437,10 +424,6 @@ static inline unsigned long clear_user(vmight_fault ();if (likely (access_ok (VERIFY_WRITE , addr, size)))return __clear_user (addr, size); -if ((unsigned long )addr <TASK_SIZE ) { -unsigned long over = (unsigned long )addr + size -TASK_SIZE ; -return __clear_user (addr, size - over) + over; - }return size; }
PATCH 285/346 s390: get_user() should zero on failure
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit fd2d2b191fe75825c4c7a6f12f3fef35aaed7dd7 upstream.
--- arch/s390/include/asm/uaccess.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/s390/include/asm/uaccess.h +4 -4
@@ -213,28 +213,28 @@ int __put_user_bad(void) __attribute__((__chk_user_ptr (ptr); \switch (sizeof (*(ptr))) { \case 1 : { \ -unsigned char __x; \ +unsigned char __x =0 ; \ __gu_err =__get_user_fn (&__x, ptr, \sizeof (*(ptr))); \ (x) = *(__force __typeof__(*(ptr)) *) &__x; \break ; \ }; \case 2 : { \ -unsigned short __x; \ +unsigned short __x =0 ; \ __gu_err =__get_user_fn (&__x, ptr, \sizeof (*(ptr))); \ (x) = *(__force __typeof__(*(ptr)) *) &__x; \break ; \ }; \case 4 : { \ -unsigned int __x; \ +unsigned int __x =0 ; \ __gu_err =__get_user_fn (&__x, ptr, \sizeof (*(ptr))); \ (x) = *(__force __typeof__(*(ptr)) *) &__x; \break ; \ }; \case 8 : { \ -unsigned long long __x; \ +unsigned long long __x =0 ; \ __gu_err =__get_user_fn (&__x, ptr, \sizeof (*(ptr))); \ (x) = *(__force __typeof__(*(ptr)) *) &__x; \
PATCH 286/346 score: fix __get_user/get_user
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit c2f18fa4cbb3ad92e033a24efa27583978ce9600 upstream.
* should zero on any failure
* __get_user() should use __copy_from_user(), not copy_from_user()
--- arch/score/include/asm/uaccess.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/score/include/asm/uaccess.h +4 -1
@@ -158,7 +158,7 @@ do { \__get_user_asm (val,"lw" , ptr); \break ; \case 8 : \ -if ((copy_from_user ((void *)&val, ptr,8 )) ==0 ) \ +if (__copy_from_user ((void *)&val, ptr,8 ) ==0 ) \ __gu_err =0 ; \else \ __gu_err = -EFAULT ; \
@@ -183,6 +183,8 @@ do { \ \if (likely (access_ok (VERIFY_READ , __gu_ptr, size))) \__get_user_common ((x), size, __gu_ptr); \ +else \ + (x) =0 ; \ \ __gu_err; \ })
@@ -196,6 +198,7 @@ do { \"2:\n" \".section .fixup,\"ax\"\n" \"3:li %0, %4\n" \ +"li %1, 0\n" \"j 2b\n" \".previous\n" \".section __ex_table,\"a\"\n" \
PATCH 287/346 score: fix copy_from_user() and friends
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit b615e3c74621e06cd97f86373ca90d43d6d998aa upstream.
--- arch/score/include/asm/uaccess.h | 41 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 21 deletions(-)
arch/score/include/asm/uaccess.h +20 -21
@@ -296,35 +296,34 @@ extern int __copy_tofrom_user(void *to,static inline unsigned long copy_from_user (void *to,const void *from,unsigned long len) { -unsigned long over; +unsigned long res = len; -if (access_ok (VERIFY_READ , from, len)) -return __copy_tofrom_user (to, from, len); +if (likely (access_ok (VERIFY_READ , from, len))) + res =__copy_tofrom_user (to, from, len); -if ((unsigned long )from <TASK_SIZE ) { - over = (unsigned long )from + len -TASK_SIZE ; -return __copy_tofrom_user (to, from, len - over) + over; - } -return len; +if (unlikely (res)) +memset (to + (len - res),0 , res); + +return res; }static inline unsigned long copy_to_user (void *to,const void *from,unsigned long len) { -unsigned long over; - -if (access_ok (VERIFY_WRITE , to, len)) -return __copy_tofrom_user (to, from, len); +if (likely (access_ok (VERIFY_WRITE , to, len))) + len =__copy_tofrom_user (to, from, len); -if ((unsigned long )to <TASK_SIZE ) { - over = (unsigned long )to + len -TASK_SIZE ; -return __copy_tofrom_user (to, from, len - over) + over; - }return len; } -#define __copy_from_user (to, from, len) \ - __copy_tofrom_user((to), (from), (len)) +static inline unsigned long +__copy_from_user (void *to,const void *from,unsigned long len) +{ +unsigned long left =__copy_tofrom_user (to, from, len); +if (unlikely (left)) +memset (to + (len - left),0 , left); +return left; +}#define __copy_to_user (to, from, len) \ __copy_tofrom_user((to), (from), (len))
@@ -338,17 +337,17 @@ __copy_to_user_inatomic(void *to, conststatic inline unsigned long __copy_from_user_inatomic (void *to,const void *from,unsigned long len) { -return __copy_from_user (to, from, len); +return __copy_tofrom_user (to, from, len); } -#define __copy_in_user (to, from, len) __copy_from_user(to, from, len) +#define __copy_in_user (to, from, len) __copy_tofrom_user(to, from, len)static inline unsigned long copy_in_user (void *to,const void *from,unsigned long len) {if (access_ok (VERIFY_READ , from, len) &&access_ok (VERFITY_WRITE , to, len)) -return copy_from_user (to, from, len); +return __copy_tofrom_user (to, from, len); }/*
PATCH 288/346 sh64: failing __get_user() should zero
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit c6852389228df9fb3067f94f3b651de2a7921b36 upstream.
It could be done in exception-handling bits in __get_user_b() et.al., but the surgery involved would take more knowledge of sh64 details than I have or _want_ to have.
--- arch/sh/include/asm/uaccess_64.h | 1 + 1 file changed, 1 insertion(+)
arch/sh/include/asm/uaccess_64.h +1 -0
@@ -24,6 +24,7 @@#define __get_user_size (x,ptr,size,retval) \ do { \ retval = 0; \ + x = 0; \ switch (size) { \ case 1: \ retval = __get_user_asm_b((void *)&x, \
PATCH 289/346 sh: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 6e050503a150b2126620c1a1e9b3a368fcd51eac upstream.
--- arch/sh/include/asm/uaccess.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/sh/include/asm/uaccess.h +4 -1
@@ -151,7 +151,10 @@ copy_from_user(void *to, const void __us__kernel_size_t __copy_size = (__kernel_size_t ) n;if (__copy_size &&__access_ok (__copy_from, __copy_size)) -return __copy_user (to, from, __copy_size); + __copy_size =__copy_user (to, from, __copy_size); + +if (unlikely (__copy_size)) +memset (to + (n - __copy_size),0 , __copy_size);return __copy_size; }
PATCH 290/346 sparc32: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 917400cecb4b52b5cde5417348322bb9c8272fa6 upstream.
--- arch/sparc/include/asm/uaccess_32.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/sparc/include/asm/uaccess_32.h +3 -1
@@ -265,8 +265,10 @@ static inline unsigned long copy_from_us {if (n &&__access_ok ((unsigned long ) from, n))return __copy_user ((__force void __user *) to, from, n); -else +else { +memset (to,0 , n);return n; + } }static inline unsigned long __copy_from_user (void *to,const void __user *from,unsigned long n)
PATCH 291/346 blackfin: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 8f035983dd826d7e04f67b28acf8e2f08c347e41 upstream.
--- arch/blackfin/include/asm/uaccess.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/blackfin/include/asm/uaccess.h +5 -4
@@ -177,11 +177,12 @@ static inline int bad_user_access_lengthstatic inline unsigned long __must_check copy_from_user (void *to,const void __user *from,unsigned long n) { -if (access_ok (VERIFY_READ , from, n)) +if (likely (access_ok (VERIFY_READ , from, n))) {memcpy (to, (const void __force *)from, n); -else -return n; -return 0 ; +return 0 ; + } +memset (to,0 , n); +return n; } static inline unsigned long __must_check
PATCH 292/346 m32r: fix __get_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit c90a3bc5061d57e7931a9b7ad14784e1a0ed497d upstream.
--- arch/m32r/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m32r/include/asm/uaccess.h +1 -1
@@ -215,7 +215,7 @@ extern int fixup_exception(struct pt_reg#define __get_user_nocheck (x,ptr,size) \ ({ \ long __gu_err = 0; \ - unsigned long __gu_val; \ + unsigned long __gu_val = 0; \ might_fault(); \ __get_user_size(__gu_val,(ptr),(size),__gu_err); \ (x) = (__typeof__(*(ptr)))__gu_val; \
PATCH 293/346 microblaze: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit d0cf385160c12abd109746cad1f13e3b3e8b50b8 upstream.
--- arch/microblaze/include/asm/uaccess.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/microblaze/include/asm/uaccess.h +6 -3
@@ -371,10 +371,13 @@ extern long __user_bad(void);static inline long copy_from_user (void *to,const void __user *from,unsigned long n) { +unsigned long res = n;might_fault (); -if (access_ok (VERIFY_READ , from, n)) -return __copy_from_user (to, from, n); -return n; +if (likely (access_ok (VERIFY_READ , from, n))) + res =__copy_from_user (to, from, n); +if (unlikely (res)) +memset (to + (n - res),0 , res); +return res; }#define __copy_to_user (to, from, n) \
PATCH 294/346 microblaze: fix __get_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit e98b9e37ae04562d52c96f46b3cf4c2e80222dc1 upstream.
--- arch/microblaze/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/microblaze/include/asm/uaccess.h +1 -1
@@ -226,7 +226,7 @@ extern long __user_bad(void);#define __get_user (x, ptr) \ ({ \ - unsigned long __gu_val; \ + unsigned long __gu_val = 0; \/*unsigned long __gu_ptr = (unsigned long)(ptr);*/ \long __gu_err; \switch (sizeof (*(ptr))) { \
PATCH 295/346 avr32: fix copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 8630c32275bac2de6ffb8aea9d9b11663e7ad28e upstream.
really ugly, but apparently avr32 compilers turns access_ok() into something so bad that they want it in assembler. Left that way, zeroing added in inline wrapper.
--- arch/avr32/include/asm/uaccess.h | 11 ++++++++++- arch/avr32/kernel/avr32_ksyms.c | 2 +- arch/avr32/lib/copy_user.S | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-)
arch/avr32/include/asm/uaccess.h +10 -1
@@ -74,7 +74,7 @@ extern __kernel_size_t __copy_user(voidextern __kernel_size_t copy_to_user (void __user *to,const void *from,__kernel_size_t n); -extern __kernel_size_t copy_from_user (void *to,const void __user *from, +extern __kernel_size_t ___copy_from_user (void *to,const void __user *from,__kernel_size_t n); static inline __kernel_size_t __copy_to_user(void __user *to, const void *from,
@@ -88,6 +88,15 @@ static inline __kernel_size_t __copy_fro {return __copy_user (to, (const void __force *)from, n); } +static inline __kernel_size_t copy_from_user (void *to, +const void __user *from, +__kernel_size_t n) +{ +size_t res =___copy_from_user (to, from, n); +if (unlikely (res)) +memset (to + (n - res),0 , res); +return res; +}#define __copy_to_user_inatomic __copy_to_user#define __copy_from_user_inatomic __copy_from_user
arch/avr32/kernel/avr32_ksyms.c +1 -1
@@ -36,7 +36,7 @@ EXPORT_SYMBOL(copy_page);/* * Userspace access stuff. */ -EXPORT_SYMBOL (copy_from_user); +EXPORT_SYMBOL (___copy_from_user);EXPORT_SYMBOL (copy_to_user);EXPORT_SYMBOL (__copy_user);EXPORT_SYMBOL (strncpy_from_user);
arch/avr32/lib/copy_user.S +2 -2
@@ -25,11 +25,11 @@ .align 1 .global copy_from_user .type copy_from_user, @function -copy_from_user: +___copy_from_user: branch_if_kernel r8, __copy_user ret_if_privileged r8, r11, r10, r10 rjmp __copy_user - .size copy_from_user, . - copy_from_user + .size ___copy_from_user, . - ___copy_from_user .global copy_to_user .type copy_to_user, @function
PATCH 296/346 fix minor infoleak in get_user_ex()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 1c109fabbd51863475cd12ac206bdd249aee35af upstream.
get_user_ex(x, ptr) should zero x on failure. It's not a lot of a leak (at most we are leaking uninitialized 64bit value off the kernel stack, and in a fairly constrained situation, at that), but the fix is trivial, so...
--- arch/x86/include/asm/uaccess.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/include/asm/uaccess.h +5 -1
@@ -391,7 +391,11 @@ do { \#define __get_user_asm_ex (x, addr, itype, rtype, ltype) \ asm volatile("1: mov"itype" %1,%"rtype"0\n" \ "2:\n" \ - _ASM_EXTABLE_EX(1b, 2b) \ + ".section .fixup,\"ax\"\n" \ + "3:xor"itype" %"rtype"0,%"rtype"0\n" \ + " jmp 2b\n" \ + ".previous\n" \ + _ASM_EXTABLE_EX(1b, 3b) \ : ltype(x) : "m" (__m(addr)))#define __put_user_nocheck (x, ptr, size) \
A message that is not in the archive (sent off-list or not yet received): CA+55aFyrySgb5rGq=0aON5tPu5_UR5CNn8T0FUqonMqSJUTXrQ@mail.gmail.com
Re: [PATCH 3.16 296/346] fix minor infoleak in get_user_ex()
Quoted 4 lines · Linus Torvalds
No, this is no good.
I had a slightly different version of this that is OK for older kernels.
And I thought I'd dropped this after you mentioned the problem at Kernel Summit. Thanks for checking.
Sasha, this still needs to be reverted in 3.18 and 4.1 stable branches.
Ben.
Quoted 45 lines
Linus
Quoted 41 lines · Ben Hutchings
3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit
1c109fabbd51863475cd12ac206bdd249aee35afupstream.
get_user_ex(x, ptr)should zero x on failure. It's not a lot of a leak (at most we are leaking uninitialized 64bit value off the kernel stack, and in a fairly constrained situation, at that), but the fix is trivial, so...Quoted 1 line
Signed-off-by Al Viro <[email protected]>[ This sat in different branch from the uaccess fixes since mid-August ]Signed-off-by Linus Torvalds <[email protected]>Signed-off-by Ben Hutchings <[email protected]>---
arch/x86/include/asm/uaccess.h | 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)arch/x86/include/asm/uaccess.h +5
-1@@ -391,7 +391,11 @@ do { \ #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \ asm volatile("1: mov"itype" %1,%"rtype"0\n" \ "2:\n" \ - _ASM_EXTABLE_EX(1b, 2b) \ + ".section .fixup,\"ax\"\n" \ + "3:xor"itype" %"rtype"0,%"rtype"0\n" \ + " jmp 2b\n" \ + ".previous\n" \ + _ASM_EXTABLE_EX(1b, 3b) \ : ltype(x) : "m" (__m(addr)))#define
__put_user_nocheck(x, ptr, size)\
Signature · 2 lines
Ben Hutchings If more than one person is responsible for a bug, no one is at fault.
PATCH 297/346 perf/x86/amd: Make HW_CACHE_REFERENCES and HW_CACHE_MISSES measure L2
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fleming <[email protected]>
commit 080fe0b790ad438fc1b61621dac37c1964ce7f35 upstream.
While the Intel PMU monitors the LLC when perf enables the HW_CACHE_REFERENCES and HW_CACHE_MISSES events, these events monitor L1 instruction cache fetches (0x0080) and instruction cache misses (0x0081) on the AMD PMU.
This is extremely confusing when monitoring the same workload across Intel and AMD machines, since parameters like,
$ perf stat -e cache-references,cache-misses
measure completely different things.
Instead, make the AMD PMU measure instruction/data cache and TLB fill requests to the L2 and instruction/data cache and TLB misses in the L2 when HW_CACHE_REFERENCES and HW_CACHE_MISSES are enabled, respectively. That way the events measure unified caches on both platforms.
[bwh: Backported to 3.16:
- Drop KVM PMU changes
- Adjust filename]
---
arch/x86/kernel/cpu/perf_event_amd.c +2 -2
@@ -119,8 +119,8 @@ static const u64 amd_perfmon_event_map[] { [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, - [PERF_COUNT_HW_CACHE_REFERENCES] = 0x0080, - [PERF_COUNT_HW_CACHE_MISSES] = 0x0081, + [PERF_COUNT_HW_CACHE_REFERENCES] = 0x077d, + [PERF_COUNT_HW_CACHE_MISSES] = 0x077e, [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2, [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3, [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00d0, /* "Decoder empty" event */
PATCH 298/346 USB: change bInterval default to 10 ms
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 08c5cd37480f59ea39682f4585d92269be6b1424 upstream.
Some full-speed mceusb infrared transceivers contain invalid endpoint descriptors for their interrupt endpoints, with bInterval set to 0. In the past they have worked out okay with the mceusb driver, because the driver sets the bInterval field in the descriptor to 1, overwriting whatever value may have been there before. However, this approach was never sanctioned by the USB core, and in fact it does not work with xHCI controllers, because they use the bInterval value that was present when the configuration was installed.
Currently usbcore uses 32 ms as the default interval if the value in the endpoint descriptor is invalid. It turns out that these IR transceivers don't work properly unless the interval is set to 10 ms or below. To work around this mceusb problem, this patch changes the endpoint-descriptor parsing routine, making the default interval value be 10 ms rather than 32 ms.
--- drivers/usb/core/config.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/usb/core/config.c +17 -11
@@ -211,8 +211,10 @@ static int usb_parse_endpoint(struct devmemcpy (&endpoint->desc, d, n);INIT_LIST_HEAD (&endpoint->urb_list); -/* Fix up bInterval values outside the legal range. Use 32 ms if no -* proper value can be guessed. */ +/* +* Fix up bInterval values outside the legal range. +* Use 10 or 8 ms if no proper value can be guessed. +*/ i =0 ;/* i = min, j = max, n = default */ j =255 ;if (usb_endpoint_xfer_int (d)) {
@@ -220,13 +222,15 @@ static int usb_parse_endpoint(struct devswitch (to_usb_device (ddev)->speed) {case USB_SPEED_SUPER :case USB_SPEED_HIGH : -/* Many device manufacturers are using full-speed +/* +* Many device manufacturers are using full-speed * bInterval values in high-speed interrupt endpoint -* descriptors. Try to fix those and fall back to a -* 32 ms default value otherwise. */ +* descriptors. Try to fix those and fall back to an +* 8-ms default value otherwise. +*/ n =fls (d->bInterval*8 );if (n ==0 ) - n =9 ;/* 32 ms = 2^(9-1) uframes */ + n =7 ;/* 8 ms = 2^(7-1) uframes */ j =16 ;/*
@@ -241,10 +245,12 @@ static int usb_parse_endpoint(struct dev }break ;default :/* USB_SPEED_FULL or _LOW */ -/* For low-speed, 10 ms is the official minimum. +/* +* For low-speed, 10 ms is the official minimum. * But some "overclocked" devices might want faster -* polling so we'll allow it. */ - n =32 ; +* polling so we'll allow it. +*/ + n =10 ;break ; } }else if (usb_endpoint_xfer_isoc (d)) {
@@ -252,10 +258,10 @@ static int usb_parse_endpoint(struct dev j =16 ;switch (to_usb_device (ddev)->speed) {case USB_SPEED_HIGH : - n =9 ;/* 32 ms = 2^(9-1) uframes */ + n =7 ;/* 8 ms = 2^(7-1) uframes */ break ;default :/* USB_SPEED_FULL */ - n =6 ;/* 32 ms = 2^(6-1) frames */ + n =4 ;/* 8 ms = 2^(4-1) frames */ break ; } }
PATCH 299/346 IB/ipoib: Don't allow MC joins during light MC flush
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alex Vesker <[email protected]>
commit 344bacca8cd811809fc33a249f2738ab757d327f upstream.
This fix solves a race between light flush and on the fly joins. Light flush doesn't set the device to down and unset IPOIB_OPER_UP flag, this means that if while flushing we have a MC join in progress and the QP was attached to BC MGID we can have a mismatches when re-attaching a QP to the BC MGID.
The light flush would set the broadcast group to NULL causing an on the fly join to rejoin and reattach to the BC MCG as well as adding the BC MGID to the multicast list. The flush process would later on remove the BC MGID and detach it from the QP. On the next flush the BC MGID is present in the multicast list but not found when trying to detach it because of the previous double attach and single detach.
[18332.714265] ------------[ cut here ]------------ [18332.717775] WARNING: CPU: 6 PID: 3767 at drivers/infiniband/core/verbs.c:280 ib_dealloc_pd+0xff/0x120 [ib_core] ... [18332.775198] Hardware name: Red Hat KVM, BIOS Bochs 01/01/2011 [18332.779411] 0000000000000000 ffff8800b50dfbb0 ffffffff813fed47 0000000000000000 [18332.784960] 0000000000000000 ffff8800b50dfbf0 ffffffff8109add1 0000011832f58300 [18332.790547] ffff880226a596c0 ffff880032482000 ffff880032482830 ffff880226a59280 [18332.796199] Call Trace: [18332.798015] [<ffffffff813fed47>] dump_stack+0x63/0x8c [18332.801831] [<ffffffff8109add1>] __warn+0xd1/0xf0 [18332.805403] [<ffffffff8109aebd>] warn_slowpath_null+0x1d/0x20 [18332.809706] [<ffffffffa025d90f>] ib_dealloc_pd+0xff/0x120 [ib_core] [18332.814384] [<ffffffffa04f3d7c>] ipoib_transport_dev_cleanup+0xfc/0x1d0 [ib_ipoib] [18332.820031] [<ffffffffa04ed648>] ipoib_ib_dev_cleanup+0x98/0x110 [ib_ipoib] [18332.825220] [<ffffffffa04e62c8>] ipoib_dev_cleanup+0x2d8/0x550 [ib_ipoib] [18332.830290] [<ffffffffa04e656f>] ipoib_uninit+0x2f/0x40 [ib_ipoib] [18332.834911] [<ffffffff81772a8a>] rollback_registered_many+0x1aa/0x2c0 [18332.839741] [<ffffffff81772bd1>] rollback_registered+0x31/0x40 [18332.844091] [<ffffffff81773b18>] unregister_netdevice_queue+0x48/0x80 [18332.848880] [<ffffffffa04f489b>] ipoib_vlan_delete+0x1fb/0x290 [ib_ipoib] [18332.853848] [<ffffffffa04df1cd>] delete_child+0x7d/0xf0 [ib_ipoib] [18332.858474] [<ffffffff81520c08>] dev_attr_store+0x18/0x30 [18332.862510] [<ffffffff8127fe4a>] sysfs_kf_write+0x3a/0x50 [18332.866349] [<ffffffff8127f4e0>] kernfs_fop_write+0x120/0x170 [18332.870471] [<ffffffff81207198>] __vfs_write+0x28/0xe0 [18332.874152] [<ffffffff810e09bf>] ? percpu_down_read+0x1f/0x50 [18332.878274] [<ffffffff81208062>] vfs_write+0xa2/0x1a0 [18332.881896] [<ffffffff812093a6>] SyS_write+0x46/0xa0 [18332.885632] [<ffffffff810039b7>] do_syscall_64+0x57/0xb0 [18332.889709] [<ffffffff81883321>] entry_SYSCALL64_slow_path+0x25/0x25 [18332.894727] ---[ end trace 09ebbe31f831ef17 ]---
--- drivers/infiniband/ulp/ipoib/ipoib_ib.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_ib.c +9 -0
@@ -1030,8 +1030,17 @@ static void __ipoib_ib_dev_flush(struct }if (level ==IPOIB_FLUSH_LIGHT ) { +int oper_up;ipoib_mark_paths_invalid (dev); +/* Set IPoIB operation as down to prevent races between: +* the flush flow which leaves MCG and on the fly joins +* which can happen during that time. mcast restart task +* should deal with join requests we missed. +*/ + oper_up =test_and_clear_bit (IPOIB_FLAG_OPER_UP , &priv->flags);ipoib_mcast_dev_flush (dev); +if (oper_up) +set_bit (IPOIB_FLAG_OPER_UP , &priv->flags); }if (level >=IPOIB_FLUSH_NORMAL )
PATCH 300/346 IB/mlx4: Fix incorrect MC join state bit-masking on SR-IOV
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alex Vesker <[email protected]>
commit e5ac40cd66c2f3cd11bc5edc658f012661b16347 upstream.
Because of an incorrect bit-masking done on the join state bits, when handling a join request we failed to detect a difference between the group join state and the request join state when joining as send only full member (0x8). This caused the MC join request not to be sent. This issue is relevant only when SRIOV is enabled and SM supports send only full member.
This fix separates scope bits and join states bits a nibble each.
--- drivers/infiniband/hw/mlx4/mcg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/infiniband/hw/mlx4/mcg.c +7 -7
@@ -485,7 +485,7 @@ static u8 get_leave_state(struct mcast_gif (!group->members[i]) leave_state |= (1 << i); -return leave_state & (group->rec.scope_join_state &7 ); +return leave_state & (group->rec.scope_join_state &0xf ); }static int join_group (struct mcast_group *group,int slave,u8 join_mask)
@@ -560,8 +560,8 @@ static void mlx4_ib_mcg_timeout_handler( }else mcg_warn_group (group,"DRIVER BUG\n" ); }else if (group->state ==MCAST_LEAVE_SENT ) { -if (group->rec.scope_join_state &7 ) - group->rec.scope_join_state &=0xf8 ; +if (group->rec.scope_join_state &0xf ) + group->rec.scope_join_state &=0xf0 ; group->state =MCAST_IDLE ;mutex_unlock (&group->lock);if (release_group (group,1 ))
@@ -601,7 +601,7 @@ static int handle_leave_req(struct mcaststatic int handle_join_req (struct mcast_group *group,u8 join_mask,struct mcast_req *req) { -u8 group_join_state = group->rec.scope_join_state &7 ; +u8 group_join_state = group->rec.scope_join_state &0xf ;int ref =0 ;u16 status;struct ib_sa_mcmember_data *sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data;
@@ -686,8 +686,8 @@ static void mlx4_ib_mcg_work_handler(stru8 cur_join_state; resp_join_state = ((struct ib_sa_mcmember_data *) - group->response_sa_mad.data)->scope_join_state &7 ; - cur_join_state = group->rec.scope_join_state &7 ; + group->response_sa_mad.data)->scope_join_state &0xf ; + cur_join_state = group->rec.scope_join_state &0xf ;if (method ==IB_MGMT_METHOD_GET_RESP ) {/* successfull join */
@@ -706,7 +706,7 @@ process_requests: req = list_first_entry(&group->pending_list, struct mcast_req, group_list); sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data; - req_join_state = sa_data->scope_join_state &0x7 ; + req_join_state = sa_data->scope_join_state &0xf ;/* For a leave request, we will immediately answer the VF, and * update our internal counters. The actual leave will be sent
PATCH 301/346 IB/mlx4: Fix code indentation in QP1 MAD flow
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jack Morgenstein <[email protected]>
commit baa0be7026e2f7d1d40bfd45909044169e9e3c68 upstream.
The indentation in the QP1 GRH flow in procedure build_mlx_header is really confusing. Fix it, in preparation for a commit which touches this code.
--- drivers/infiniband/hw/mlx4/qp.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)
drivers/infiniband/hw/mlx4/qp.c +19 -17
@@ -2149,24 +2149,26 @@ static int build_mlx_header(struct mlx4_ sqp->ud_header.grh.flow_label = ah->av.ib.sl_tclass_flowlabel &cpu_to_be32 (0xfffff ); sqp->ud_header.grh.hop_limit = ah->av.ib.hop_limit; -if (is_eth) +if (is_eth) {memcpy (sqp->ud_header.grh.source_gid.raw, sgid.raw,16 ); -else { -if (mlx4_is_mfunc (to_mdev (ib_dev)->dev)) { -/* When multi-function is enabled, the ib_core gid -* indexes don't necessarily match the hw ones, so -* we must use our own cache */ - sqp->ud_header.grh.source_gid.global.subnet_prefix = -to_mdev (ib_dev)->sriov.demux[sqp->qp.port -1 ]. - subnet_prefix; - sqp->ud_header.grh.source_gid.global.interface_id = -to_mdev (ib_dev)->sriov.demux[sqp->qp.port -1 ]. - guid_cache[ah->av.ib.gid_index]; - }else -ib_get_cached_gid (ib_dev, -be32_to_cpu (ah->av.ib.port_pd) >>24 , - ah->av.ib.gid_index, - &sqp->ud_header.grh.source_gid); + }else { +if (mlx4_is_mfunc (to_mdev (ib_dev)->dev)) { +/* When multi-function is enabled, the ib_core gid +* indexes don't necessarily match the hw ones, so +* we must use our own cache +*/ + sqp->ud_header.grh.source_gid.global.subnet_prefix = +to_mdev (ib_dev)->sriov.demux[sqp->qp.port -1 ]. + subnet_prefix; + sqp->ud_header.grh.source_gid.global.interface_id = +to_mdev (ib_dev)->sriov.demux[sqp->qp.port -1 ]. + guid_cache[ah->av.ib.gid_index]; + }else { +ib_get_cached_gid (ib_dev, +be32_to_cpu (ah->av.ib.port_pd) >>24 , + ah->av.ib.gid_index, + &sqp->ud_header.grh.source_gid); + } }memcpy (sqp->ud_header.grh.destination_gid.raw, ah->av.ib.dgid,16 );
PATCH 302/346 IB/mlx4: Use correct subnet-prefix in QP1 mads under SR-IOV
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jack Morgenstein <[email protected]>
commit 8ec07bf8a8b57d6c58927a16a0a22c0115cf2855 upstream.
When sending QP1 MAD packets which use a GRH, the source GID (which consists of the 64-bit subnet prefix, and the 64 bit port GUID) must be included in the packet GRH.
For SR-IOV, a GID cache is used, since the source GID needs to be the slave's source GID, and not the Hypervisor's GID. This cache also included a subnet_prefix. Unfortunately, the subnet_prefix field in the cache was never initialized (to the default subnet prefix 0xfe80::0). As a result, this field remained all zeroes. Therefore, when SR-IOV was active, all QP1 packets which included a GRH had a source GID subnet prefix of all-zeroes.
However, the subnet-prefix should initially be 0xfe80::0 (the default subnet prefix). In addition, if OpenSM modifies a port's subnet prefix, the new subnet prefix must be used in the GRH when sending QP1 packets. To fix this we now initialize the subnet prefix in the SR-IOV GID cache to the default subnet prefix. We update the cached value if/when OpenSM modifies the port's subnet prefix. We take this cached value when sending QP1 packets when SR-IOV is active.
Note that the value is stored as an atomic64. This eliminates any need for locking when the subnet prefix is being updated.
Note also that we depend on the FW generating the "port management change" event for tracking subnet-prefix changes performed by OpenSM. If running early FW (before 2.9.4630), subnet prefix changes will not be tracked (but the default subnet prefix still will be stored in the cache; therefore users who do not modify the subnet prefix will not have a problem). IF there is a need for such tracking also for early FW, we will add that capability in a subsequent patch.
--- drivers/infiniband/hw/mlx4/mad.c | 23 +++++++++++++++++++++++ drivers/infiniband/hw/mlx4/mlx4_ib.h | 2 +- drivers/infiniband/hw/mlx4/qp.c | 5 +++-- 3 files changed, 27 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx4/mad.c +23 -0
@@ -1062,6 +1062,27 @@ void handle_port_mgmt_change_event(struc/* Generate GUID changed event */ if (changed_attr &MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK ) { +if (mlx4_is_master (dev->dev)) { +union ib_gid gid; +int err =0 ; + +if (!eqe->event.port_mgmt_change.params.port_info.gid_prefix) + err =__mlx4_ib_query_gid (&dev->ib_dev, port,0 , &gid,1 ); +else + gid.global.subnet_prefix = + eqe->event.port_mgmt_change.params.port_info.gid_prefix; +if (err) { +pr_warn ("Could not change QP1 subnet prefix for port %d: query_gid error (%d)\n" , + port, err); + }else { +pr_debug ("Changing QP1 subnet prefix for port %d. old=0x%llx. new=0x%llx\n" , + port, + (u64 )atomic64_read (&dev->sriov.demux[port -1 ].subnet_prefix), +be64_to_cpu (gid.global.subnet_prefix)); +atomic64_set (&dev->sriov.demux[port -1 ].subnet_prefix, +be64_to_cpu (gid.global.subnet_prefix)); + } + }mlx4_ib_dispatch_event (dev, port,IB_EVENT_GID_CHANGE );/*if master, notify all slaves*/ if (mlx4_is_master (dev->dev))
@@ -2134,6 +2155,8 @@ int mlx4_ib_init_sriov(struct mlx4_ib_deif (err) goto demux_err; dev->sriov.demux[i].guid_cache[0 ] = gid.global.interface_id; +atomic64_set (&dev->sriov.demux[i].subnet_prefix, +be64_to_cpu (gid.global.subnet_prefix)); err =alloc_pv_object (dev,mlx4_master_func_num (dev->dev), i +1 , &dev->sriov.sqps[i]);if (err)
drivers/infiniband/hw/mlx4/mlx4_ib.h +1 -1
@@ -417,7 +417,7 @@ struct mlx4_ib_demux_ctx {struct workqueue_struct *wq;struct workqueue_struct *ud_wq;spinlock_t ud_lock; -__be64 subnet_prefix; +atomic64_t subnet_prefix;__be64 guid_cache[128 ];struct mlx4_ib_dev *dev;/* the following lock protects both mcg_table and mcg_mgid0_list */
drivers/infiniband/hw/mlx4/qp.c +3 -2
@@ -2158,8 +2158,9 @@ static int build_mlx_header(struct mlx4_* we must use our own cache */ sqp->ud_header.grh.source_gid.global.subnet_prefix = -to_mdev (ib_dev)->sriov.demux[sqp->qp.port -1 ]. - subnet_prefix; +cpu_to_be64 (atomic64_read (&(to_mdev (ib_dev)->sriov. + demux[sqp->qp.port -1 ]. + subnet_prefix))); sqp->ud_header.grh.source_gid.global.interface_id =to_mdev (ib_dev)->sriov.demux[sqp->qp.port -1 ]. guid_cache[ah->av.ib.gid_index];
PATCH 303/346 irda: Free skb on irda_accept error path.
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "[email protected]" <[email protected]>
commit 8ab86c00e349cef9fb14719093a7f198bcc72629 upstream.
skb is not freed if newsk is NULL. Rework the error path so free_skb is unconditionally called on function exit.
--- net/irda/af_irda.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/irda/af_irda.c +2 -3
@@ -843,7 +843,7 @@ static int irda_accept(struct socket *sostruct sock *sk = sock->sk;struct irda_sock *new, *self =irda_sk (sk);struct sock *newsk; -struct sk_buff *skb; +struct sk_buff *skb =NULL ;int err;IRDA_DEBUG (2 ,"%s()\n" , __func__);
@@ -913,7 +913,6 @@ static int irda_accept(struct socket *so err = -EPERM ;/* value does not seem to make sense. -arnd */ if (!new->tsap) {IRDA_DEBUG (0 ,"%s(), dup failed!\n" , __func__); -kfree_skb (skb); goto out; }
@@ -932,7 +931,6 @@ static int irda_accept(struct socket *so/* Clean up the original one to keep it in listen state */ irttp_listen (self->tsap); -kfree_skb (skb); sk->sk_ack_backlog--; newsock->state =SS_CONNECTED ;
@@ -940,6 +938,7 @@ static int irda_accept(struct socket *soirda_connect_response (new); err =0 ; out: +kfree_skb (skb);release_sock (sk);return err; }
PATCH 304/346 avr32: fix 'undefined reference to `___copy_from_user'
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit 65c0044ca8d7c7bbccae37f0ff2972f0210e9f41 upstream.
avr32 builds fail with:
arch/avr32/kernel/built-in.o: In function `arch_ptrace':
(.text+0x650): undefined reference to ___copy_from_user' arch/avr32/kernel/built-in.o:(___ksymtab+___copy_from_user+0x0): undefined reference to ___copy_from_user'kernel/built-in.o: In function `proc_doulongvec_ms_jiffies_minmax':
(.text+0x5dd8): undefined reference to ___copy_from_user' kernel/built-in.o: In function proc_dointvec_minmax_sysadmin':
sysctl.c:(.text+0x6174): undefined reference to ___copy_from_user' kernel/built-in.o: In function ptrace_has_cap':
ptrace.c:(.text+0x69c0): undefined reference to ___copy_from_user' kernel/built-in.o:ptrace.c:(.text+0x6b90): more undefined references to ___copy_from_user' follow
--- arch/avr32/lib/copy_user.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/avr32/lib/copy_user.S +2 -2
@@ -23,8 +23,8 @@ */ .text .align 1 - .global copy_from_user - .type copy_from_user, @function + .global ___copy_from_user + .type ___copy_from_user, @function ___copy_from_user: branch_if_kernel r8, __copy_user ret_if_privileged r8, r11, r10, r10
PATCH 305/346 openrisc: fix the fix of copy_from_user()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit 8e4b72054f554967827e18be1de0e8122e6efc04 upstream.
Since commit acb2505d0119 ("openrisc: fix copy_from_user()"), copy_from_user() returns the number of bytes requested, not the number of bytes not copied.
--- arch/openrisc/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/openrisc/include/asm/uaccess.h +1 -1
@@ -276,7 +276,7 @@ copy_from_user(void *to, const void *frounsigned long res = n;if (likely (access_ok (VERIFY_READ , from, n))) - n =__copy_tofrom_user (to, from, n); + res =__copy_tofrom_user (to, from, n);if (unlikely (res))memset (to + (n - res),0 , res);return res;
PATCH 306/346 xfrm: Fix memory leak of aead algorithm name
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ilan Tayari <[email protected]>
commit b588479358ce26f32138e0f0a7ab0678f8e3e601 upstream.
commit 1a6509d99122 ("[IPSEC]: Add support for combined mode algorithms") introduced aead. The function attach_aead kmemdup()s the algorithm name during xfrm_state_construct().
However this memory is never freed.
Implementation has since been slightly modified in
commit ee5c23176fcc ("xfrm: Clone states properly on migration") without resolving this leak.
This patch adds a kfree() call for the aead algorithm name.
--- net/xfrm/xfrm_state.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_state.c +1 -0
@@ -339,6 +339,7 @@ static void xfrm_state_gc_destroy(struct {tasklet_hrtimer_cancel (&x->mtimer);del_timer_sync (&x->rtimer); +kfree (x->aead);kfree (x->aalg);kfree (x->ealg);kfree (x->calg);
PATCH 307/346 can: flexcan: fix resume function
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
commit 4de349e786a3a2d51bd02d56f3de151bbc3c3df9 upstream.
On a imx6ul-pico board the following error is seen during system suspend:
dpm_run_callback(): platform_pm_resume+0x0/0x54 returns -110
PM: Device 2090000.flexcan failed to resume: error -110
The reason for this suspend error is because when the CAN interface is not active the clocks are disabled and then flexcan_chip_enable() will always fail due to a timeout error.
In order to fix this issue, only call flexcan_chip_enable/disable() when the CAN interface is active.
Based on a patch from Dong Aisheng in the NXP kernel.
--- drivers/net/can/flexcan.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/can/flexcan.c +8 -5
@@ -1248,11 +1248,10 @@ static int __maybe_unused flexcan_suspenstruct flexcan_priv *priv =netdev_priv (dev);int err; - err =flexcan_chip_disable (priv); -if (err) -return err; -if (netif_running (dev)) { + err =flexcan_chip_disable (priv); +if (err) +return err;netif_stop_queue (dev);netif_device_detach (dev); }
@@ -1265,13 +1264,17 @@ static int __maybe_unused flexcan_resume {struct net_device *dev =dev_get_drvdata (device);struct flexcan_priv *priv =netdev_priv (dev); +int err; priv->can.state =CAN_STATE_ERROR_ACTIVE ;if (netif_running (dev)) {netif_device_attach (dev);netif_start_queue (dev); + err =flexcan_chip_enable (priv); +if (err) +return err; } -return flexcan_chip_enable (priv); +return 0 ; } static SIMPLE_DEV_PM_OPS(flexcan_pm_ops, flexcan_suspend, flexcan_resume);
PATCH 308/346 ocfs2/dlm: fix race between convert and migration
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
commit e6f0c6e6170fec175fe676495f29029aecdf486c upstream.
Commit ac7cf246dfdb ("ocfs2/dlm: fix race between convert and recovery") checks if lockres master has changed to identify whether new master has finished recovery or not. This will introduce a race that right after old master does umount ( means master will change), a new convert request comes.
In this case, it will reset lockres state to DLM_RECOVERING and then retry convert, and then fail with lockres->l_action being set to OCFS2_AST_INVALID, which will cause inconsistent lock level between ocfs2 and dlm, and then finally BUG.
Since dlm recovery will clear lock->convert_pending in dlm_move_lockres_to_recovery_list, we can use it to correctly identify the race case between convert and recovery. So fix it.
--- fs/ocfs2/dlm/dlmconvert.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/ocfs2/dlm/dlmconvert.c +6 -6
@@ -262,7 +262,6 @@ enum dlm_status dlmconvert_remote(struct struct dlm_lock *lock, int flags, int type) { enum dlm_status status; -u8 old_owner = res->owner;mlog (0 ,"type=%d, convert_type=%d, busy=%d\n" , lock->ml.type, lock->ml.convert_type, res->state &DLM_LOCK_RES_IN_PROGRESS );
@@ -329,7 +328,6 @@ enum dlm_status dlmconvert_remote(structspin_lock (&res->spinlock); res->state &= ~DLM_LOCK_RES_IN_PROGRESS ; - lock->convert_pending =0 ;/* if it failed, move it back to granted queue. * if master returns DLM_NORMAL and then down before sending ast, * it may have already been moved to granted queue, reset to
@@ -338,12 +336,14 @@ enum dlm_status dlmconvert_remote(structif (status !=DLM_NOTQUEUED )dlm_error (status);dlm_revert_pending_convert (res, lock); - }else if ((res->state &DLM_LOCK_RES_RECOVERING ) || - (old_owner != res->owner)) { -mlog (0 ,"res %.*s is in recovering or has been recovered.\n" , - res->lockname.len, res->lockname.name); + }else if (!lock->convert_pending) { +mlog (0 ,"%s: res %.*s, owner died and lock has been moved back " +"to granted list, retry convert.\n" , + dlm->name, res->lockname.len, res->lockname.name); status =DLM_RECOVERING ; } + + lock->convert_pending =0 ; bail:spin_unlock (&res->spinlock);
PATCH 309/346 fsnotify: add a way to stop queueing events on group shutdown
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 12703dbfeb15402260e7554d32a34ac40c233990 upstream.
Implement a function that can be called when a group is being shutdown to stop queueing new events to the group. Fanotify will use this.
--- fs/notify/group.c | 19 +++++++++++++++++++ fs/notify/notification.c | 8 +++++++- include/linux/fsnotify_backend.h | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-)
fs/notify/group.c +19 -0
@@ -40,6 +40,17 @@ void fsnotify_final_destroy_group(struct }/* +* Stop queueing new events for this group. Once this function returns +* fsnotify_add_event() will not add any new events to the group's queue. +*/ +void fsnotify_group_stop_queueing (struct fsnotify_group *group) +{ +mutex_lock (&group->notification_mutex); + group->shutdown = true; +mutex_unlock (&group->notification_mutex); +} + +/* * Trying to get rid of a group. Remove all marks, flush all events and release * the group reference. * Note that another thread calling fsnotify_clear_marks_by_group() may still
@@ -47,6 +58,14 @@ void fsnotify_final_destroy_group(struct*/ void fsnotify_destroy_group (struct fsnotify_group *group) { +/* +* Stop queueing new events. The code below is careful enough to not +* require this but fanotify needs to stop queuing events even before +* fsnotify_destroy_group() is called and this makes the other callers +* of fsnotify_destroy_group() to see the same behavior. +*/ +fsnotify_group_stop_queueing (group); +/* clear all inode marks for this group */ fsnotify_clear_marks_by_group (group);
fs/notify/notification.c +7 -1
@@ -82,7 +82,8 @@ void fsnotify_destroy_event(struct fsnot* Add an event to the group notification queue. The group can later pull this * event off the queue to deal with. The function returns 0 if the event was * added to the queue, 1 if the event was merged with some other queued event, -* 2 if the queue of events has overflown. +* 2 if the event was not queued - either the queue of events has overflown +* or the group is shutting down. */ int fsnotify_add_notify_event(struct fsnotify_group *group, struct fsnotify_event *event,
@@ -96,6 +97,11 @@ int fsnotify_add_notify_event(struct fsnmutex_lock (&group->notification_mutex); +if (group->shutdown) { +mutex_unlock (&group->notification_mutex); +return 2 ; + } +if (group->q_len >= group->max_events) { ret =2 ;/* Queue overflow event only if it isn't already queued */
include/linux/fsnotify_backend.h +3 -0
@@ -150,6 +150,7 @@ struct fsnotify_group {#define FS_PRIO_1 1/* fanotify content based access control */ #define FS_PRIO_2 2/* fanotify pre-content access */ unsigned int priority; +bool shutdown;/* group is being shut down, don't queue more events */ /* stores all fastpath marks assoc with this group so they can be cleaned on unregister */ struct mutex mark_mutex;/* protect marks_list */
@@ -314,6 +315,8 @@ extern struct fsnotify_group *fsnotify_aextern void fsnotify_get_group (struct fsnotify_group *group);/* drop reference on a group from fsnotify_alloc_group */ extern void fsnotify_put_group (struct fsnotify_group *group); +/* group destruction begins, stop queuing new events */ +extern void fsnotify_group_stop_queueing (struct fsnotify_group *group);/* destroy group */ extern void fsnotify_destroy_group (struct fsnotify_group *group);/* fasync handler function */
PATCH 310/346 fanotify: fix list corruption in fanotify_get_response()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 96d41019e3ac55f6f0115b0ce97e4f24a3d636d2 upstream.
fanotify_get_response() calls fsnotify_remove_event() when it finds that group is being released from fanotify_release() (bypass_perm is set).
However the event it removes need not be only in the group's notification queue but it can have already moved to access_list (userspace read the event before closing the fanotify instance fd) which is protected by a different lock. Thus when fsnotify_remove_event() races with fanotify_release() operating on access_list, the list can get corrupted.
Fix the problem by moving all the logic removing permission events from the lists to one place - fanotify_release().
[bwh: Backported to 3.16:
- s/fsnotify_remove_first_event/fsnotify_remove_notify_event/
- Adjust context]
--- fs/notify/fanotify/fanotify.c | 13 +------------ fs/notify/fanotify/fanotify_user.c | 36 ++++++++++++++++++++++++------------ fs/notify/notification.c | 15 --------------- include/linux/fsnotify_backend.h | 3 --- 4 files changed, 25 insertions(+), 42 deletions(-)
fs/notify/fanotify/fanotify.c +1 -12
@@ -67,18 +67,7 @@ static int fanotify_get_response(structpr_debug ("%s: group=%p event=%p\n" , __func__, group, event); -wait_event (group->fanotify_data.access_waitq, event->response || -atomic_read (&group->fanotify_data.bypass_perm)); - -if (!event->response) {/* bypass_perm set */ -/* -* Event was canceled because group is being destroyed. Remove -* it from group's event list because we are responsible for -* freeing the permission event. -*/ -fsnotify_remove_event (group, &event->fae.fse); -return 0 ; - } +wait_event (group->fanotify_data.access_waitq, event->response);/* userspace responded, convert to something usable */ switch (event->response) {
fs/notify/fanotify/fanotify_user.c +24 -12
@@ -358,16 +358,20 @@ static int fanotify_release(struct inode#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS struct fanotify_perm_event_info *event, *next; +struct fsnotify_event *fsn_event;/* -* There may be still new events arriving in the notification queue -* but since userspace cannot use fanotify fd anymore, no event can -* enter or leave access_list by now. +* Stop new events from arriving in the notification queue. since +* userspace cannot use fanotify fd anymore, no event can enter or +* leave access_list by now either. */ -spin_lock (&group->fanotify_data.access_lock); - -atomic_inc (&group->fanotify_data.bypass_perm); +fsnotify_group_stop_queueing (group); +/* +* Process all permission events on access_list and notification queue +* and simulate reply from userspace. +*/ +spin_lock (&group->fanotify_data.access_lock);list_for_each_entry_safe (event, next, &group->fanotify_data.access_list, fae.fse.list) { pr_debug("%s: found group=%p event=%p\n", __func__, group,
@@ -379,12 +383,21 @@ static int fanotify_release(struct inodespin_unlock (&group->fanotify_data.access_lock);/* -* Since bypass_perm is set, newly queued events will not wait for -* access response. Wake up the already sleeping ones now. -* synchronize_srcu() in fsnotify_destroy_group() will wait for all -* processes sleeping in fanotify_handle_event() waiting for access -* response and thus also for all permission events to be freed. +* Destroy all non-permission events. For permission events just +* dequeue them and set the response. They will be freed once the +* response is consumed and fanotify_get_response() returns. */ +mutex_lock (&group->notification_mutex); +while (!fsnotify_notify_queue_is_empty (group)) { + fsn_event =fsnotify_remove_notify_event (group); +if (!(fsn_event->mask &FAN_ALL_PERM_EVENTS )) +fsnotify_destroy_event (group, fsn_event); +else +FANOTIFY_PE (fsn_event)->response =FAN_ALLOW ; + } +mutex_unlock (&group->notification_mutex); + +/* Response for all permission events it set, wakeup waiters */ wake_up (&group->fanotify_data.access_waitq);#endif
@@ -742,7 +755,6 @@ SYSCALL_DEFINE2(fanotify_init, unsignedspin_lock_init (&group->fanotify_data.access_lock);init_waitqueue_head (&group->fanotify_data.access_waitq);INIT_LIST_HEAD (&group->fanotify_data.access_list); -atomic_set (&group->fanotify_data.bypass_perm,0 );#endif switch (flags &FAN_ALL_CLASS_BITS ) {case FAN_CLASS_NOTIF :
fs/notify/notification.c +0 -15
@@ -132,21 +132,6 @@ queue: }/* -* Remove @event from group's notification queue. It is the responsibility of -* the caller to destroy the event. -*/ -void fsnotify_remove_event (struct fsnotify_group *group, -struct fsnotify_event *event) -{ -mutex_lock (&group->notification_mutex); -if (!list_empty (&event->list)) { -list_del_init (&event->list); - group->q_len--; - } -mutex_unlock (&group->notification_mutex); -} - -/* * Remove and return the first event from the notification list. It is the * responsibility of the caller to destroy the obtained event */
include/linux/fsnotify_backend.h +0 -3
@@ -182,7 +182,6 @@ struct fsnotify_group {spinlock_t access_lock;struct list_head access_list;wait_queue_head_t access_waitq; -atomic_t bypass_perm;#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */ int f_flags;unsigned int max_marks;
@@ -329,8 +328,6 @@ extern int fsnotify_add_notify_event(strstruct fsnotify_event *event, int (*merge)(struct list_head *, struct fsnotify_event *)); -/* Remove passed event from groups notification queue */ -extern void fsnotify_remove_event (struct fsnotify_group *group,struct fsnotify_event *event);/* true if the group notification queue is empty */ extern bool fsnotify_notify_queue_is_empty (struct fsnotify_group *group);/* return, but do not dequeue the first event on the notification queue */
PATCH 311/346 ocfs2: fix start offset to ocfs2_zero_range_for_truncate()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Ashish Samant <[email protected]>
commit d21c353d5e99c56cdd5b5c1183ffbcaf23b8b960 upstream.
If we punch a hole on a reflink such that following conditions are met:
1. start offset is on a cluster boundary
2. end offset is not on a cluster boundary
3. (end offset is somewhere in another extent) or
(hole range > MAX_CONTIG_BYTES(1MB)),
we dont COW the first cluster starting at the start offset. But in this case, we were wrongly passing this cluster to ocfs2_zero_range_for_truncate() to zero out. This will modify the cluster in place and zero it in the source too.
Fix this by skipping this cluster in such a scenario.
To reproduce:
1. Create a random file of say 10 MB
xfs_io -c 'pwrite -b 4k 0 10M' -f 10MBfile
2. Reflink it
reflink -f 10MBfile reflnktest
3. Punch a hole at starting at cluster boundary with range greater that 1MB. You can also use a range that will put the end offset in another extent.
fallocate -p -o 0 -l 1048615 reflnktest
4. sync
5. Check the first cluster in the source file. (It will be zeroed out). dd if=10MBfile iflag=direct bs=<cluster size> count=1 | hexdump -C
--- fs/ocfs2/file.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
fs/ocfs2/file.c +26 -12
@@ -1516,7 +1516,8 @@ static int ocfs2_zero_partial_clusters(s u64 start, u64 len) { int ret = 0; -u64 tmpend, end = start + len; +u64 tmpend =0 ; +u64 end = start + len;struct ocfs2_super *osb =OCFS2_SB (inode->i_sb);unsigned int csize = osb->s_clustersize;handle_t *handle;
@@ -1548,18 +1549,31 @@ static int ocfs2_zero_partial_clusters(s }/* -* We want to get the byte offset of the end of the 1st cluster. +* If start is on a cluster boundary and end is somewhere in another +* cluster, we have not COWed the cluster starting at start, unless +* end is also within the same cluster. So, in this case, we skip this +* first call to ocfs2_zero_range_for_truncate() truncate and move on +* to the next one. */ - tmpend = (u64 )osb->s_clustersize + (start & ~(osb->s_clustersize -1 )); -if (tmpend > end) - tmpend = end; - -trace_ocfs2_zero_partial_clusters_range1 ((unsigned long long )start, - (unsigned long long )tmpend); - - ret =ocfs2_zero_range_for_truncate (inode, handle, start, tmpend); -if (ret) -mlog_errno (ret); +if ((start & (csize -1 )) !=0 ) { +/* +* We want to get the byte offset of the end of the 1st +* cluster. +*/ + tmpend = (u64 )osb->s_clustersize + + (start & ~(osb->s_clustersize -1 )); +if (tmpend > end) + tmpend = end; + +trace_ocfs2_zero_partial_clusters_range1 ( + (unsigned long long )start, + (unsigned long long )tmpend); + + ret =ocfs2_zero_range_for_truncate (inode, handle, start, + tmpend); +if (ret) +mlog_errno (ret); + }if (tmpend < end) {/*
PATCH 312/346 fix fault_in_multipages_...() on architectures with no-op access_ok()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit e23d4159b109167126e5bcd7f3775c95de7fee47 upstream.
Switching iov_iter fault-in to multipages variants has exposed an old bug in underlying fault_in_multipages_...(); they break if the range passed to them wraps around. Normally access_ok() done by callers will prevent such (and it's a guaranteed EFAULT - ERR_PTR() values fall into such a range and they should not point to any valid objects).
However, on architectures where userland and kernel live in different MMU contexts (e.g. s390) access_ok() is a no-op and on those a range with a wraparound can reach fault_in_multipages_...().
Since any wraparound means EFAULT there, the fix is trivial - turn those
while (uaddr <= end)
...
into
if (unlikely(uaddr > end))
return -EFAULT;
do
...
while (uaddr <= end);--- include/linux/pagemap.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
include/linux/pagemap.h +19 -19
@@ -599,56 +599,56 @@ static inline int fault_in_pages_readabl*/ static inline int fault_in_multipages_writeable (char __user *uaddr,int size) { -int ret =0 ;char __user *end = uaddr + size -1 ;if (unlikely (size ==0 )) -return ret; +return 0 ; +if (unlikely (uaddr > end)) +return -EFAULT ;/* * Writing zeroes into userspace here is OK, because we know that if * the zero gets there, we'll be overwriting it. */ -while (uaddr <= end) { - ret =__put_user (0 , uaddr); -if (ret !=0 ) -return ret; +do { +if (unlikely (__put_user (0 , uaddr) !=0 )) +return -EFAULT ; uaddr +=PAGE_SIZE ; - } + }while (uaddr <= end);/* Check whether the range spilled into the next page. */ if (((unsigned long )uaddr &PAGE_MASK ) == ((unsigned long )end &PAGE_MASK )) - ret =__put_user (0 , end); +return __put_user (0 , end); -return ret; +return 0 ; }static inline int fault_in_multipages_readable (const char __user *uaddr,int size) {volatile char c; -int ret =0 ;const char __user *end = uaddr + size -1 ;if (unlikely (size ==0 )) -return ret; +return 0 ; + +if (unlikely (uaddr > end)) +return -EFAULT ; -while (uaddr <= end) { - ret =__get_user (c, uaddr); -if (ret !=0 ) -return ret; +do { +if (unlikely (__get_user (c, uaddr) !=0 )) +return -EFAULT ; uaddr +=PAGE_SIZE ; - } + }while (uaddr <= end);/* Check whether the range spilled into the next page. */ if (((unsigned long )uaddr &PAGE_MASK ) == ((unsigned long )end &PAGE_MASK )) { - ret =__get_user (c, end); - (void )c; +return __get_user (c, end); } -return ret; +return 0 ; } int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
PATCH 313/346 i2c-eg20t: fix race between i2c init and interrupt enable
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Yadi.hu" <[email protected]>
commit 371a015344b6e270e7e3632107d9554ec6d27a6b upstream.
the eg20t driver call request_irq() function before the pch_base_address, base address of i2c controller's register, is assigned an effective value.
there is one possible scenario that an interrupt which isn't inside eg20t arrives immediately after request_irq() is executed when i2c controller shares an interrupt number with others. since the interrupt handler pch_i2c_handler() has already active as shared action, it will be called and read its own register to determine if this interrupt is from itself.
At that moment, since base address of i2c registers is not remapped in kernel space yet,so the INT handler will access an illegal address and then a error occurs.
--- drivers/i2c/busses/i2c-eg20t.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-eg20t.c +11 -7
@@ -777,13 +777,6 @@ static int pch_i2c_probe(struct pci_dev/* Set the number of I2C channel instance */ adap_info->ch_num = id->driver_data; - ret =request_irq (pdev->irq, pch_i2c_handler,IRQF_SHARED , -KBUILD_MODNAME , adap_info); -if (ret) { -pch_pci_err (pdev,"request_irq FAILED\n" ); - goto err_request_irq; - } -for (i =0 ; i < adap_info->ch_num; i++) { pch_adap = &adap_info->pch_data[i].pch_adapter; adap_info->pch_i2c_suspended = false;
@@ -800,6 +793,17 @@ static int pch_i2c_probe(struct pci_dev adap_info->pch_data[i].pch_base_address = base_addr +0x100 * i; pch_adap->dev.parent = &pdev->dev; + } + + ret =request_irq (pdev->irq, pch_i2c_handler,IRQF_SHARED , +KBUILD_MODNAME , adap_info); +if (ret) { +pch_pci_err (pdev,"request_irq FAILED\n" ); + goto err_request_irq; + } + +for (i =0 ; i < adap_info->ch_num; i++) { + pch_adap = &adap_info->pch_data[i].pch_adapter;pch_i2c_init (&adap_info->pch_data[i]);
PATCH 314/346 i2c: mux: pca954x: retry updating the mux selection on failure
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Peter Rosin <[email protected]>
commit 463e8f845cbf1c01e4cc8aeef1703212991d8e1e upstream.
The cached value of the last selected channel prevents retries on the next call, even on failure to update the selected channel. Fix that.
--- drivers/i2c/muxes/i2c-mux-pca954x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/muxes/i2c-mux-pca954x.c +1 -1
@@ -161,7 +161,7 @@ static int pca954x_select_chan(struct i2/* Only select the channel if its different from the last channel */ if (data->last_chan != regval) { ret =pca954x_reg_write (adap, client, regval); - data->last_chan = regval; + data->last_chan = ret ?0 : regval; }return ret;
PATCH 315/346 btrfs: ensure that file descriptor used with subvol ioctls is a dir
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Mahoney <[email protected]>
commit 325c50e3cebb9208009083e841550f98a863bfa0 upstream.
If the subvol/snapshot create/destroy ioctls are passed a regular file with execute permissions set, we'll eventually Oops while trying to do inode->i_op->lookup via lookup_one_len.
This patch ensures that the file descriptor refers to a directory.
--- fs/btrfs/ioctl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/btrfs/ioctl.c +12 -0
@@ -1649,6 +1649,9 @@ static noinline int btrfs_ioctl_snap_creint namelen;int ret =0 ; +if (!S_ISDIR (file_inode (file)->i_mode)) +return -ENOTDIR ; + ret =mnt_want_write_file (file);if (ret) goto out;
@@ -1706,6 +1709,9 @@ static noinline int btrfs_ioctl_snap_crestruct btrfs_ioctl_vol_args *vol_args;int ret; +if (!S_ISDIR (file_inode (file)->i_mode)) +return -ENOTDIR ; + vol_args =memdup_user (arg,sizeof (*vol_args));if (IS_ERR (vol_args))return PTR_ERR (vol_args);
@@ -1729,6 +1735,9 @@ static noinline int btrfs_ioctl_snap_crebool readonly = false;struct btrfs_qgroup_inherit *inherit =NULL ; +if (!S_ISDIR (file_inode (file)->i_mode)) +return -ENOTDIR ; + vol_args =memdup_user (arg,sizeof (*vol_args));if (IS_ERR (vol_args))return PTR_ERR (vol_args);
@@ -2355,6 +2364,9 @@ static noinline int btrfs_ioctl_snap_desint ret;int err =0 ; +if (!S_ISDIR (dir->i_mode)) +return -ENOTDIR ; + vol_args =memdup_user (arg,sizeof (*vol_args));if (IS_ERR (vol_args))return PTR_ERR (vol_args);
PATCH 316/346 can: dev: fix deadlock reported after bus-off
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Miroshnichenko <[email protected]>
commit 9abefcb1aaa58b9d5aa40a8bb12c87d02415e4c8 upstream.
A timer was used to restart after the bus-off state, leading to a relatively large can_restart() executed in an interrupt context, which in turn sets up pinctrl. When this happens during system boot, there is a high probability of grabbing the pinctrl_list_mutex, which is locked already by the probe() of other device, making the kernel suspect a deadlock condition [1].
To resolve this issue, the restart_timer is replaced by a delayed work.
[1] https://github.com/victronenergy/venus/issues/24
--- drivers/net/can/dev.c | 27 +++++++++++++++++---------- include/linux/can/dev.h | 3 ++- 2 files changed, 19 insertions(+), 11 deletions(-)
drivers/net/can/dev.c +17 -10
@@ -21,6 +21,7 @@#include <linux/slab.h> #include <linux/netdevice.h> #include <linux/if_arp.h> +#include <linux/workqueue.h> #include <linux/can.h> #include <linux/can/dev.h> #include <linux/can/skb.h>
@@ -392,9 +393,8 @@ EXPORT_SYMBOL_GPL(can_free_echo_skb);/* * CAN device restart for bus-off recovery */ -static void can_restart (unsigned long data) +static void can_restart (struct net_device *dev) { -struct net_device *dev = (struct net_device *)data;struct can_priv *priv =netdev_priv (dev);struct net_device_stats *stats = &dev->stats;struct sk_buff *skb;
@@ -434,6 +434,14 @@ restart:netdev_err (dev,"Error %d during restart" , err); } +static void can_restart_work (struct work_struct *work) +{ +struct delayed_work *dwork =to_delayed_work (work); + struct can_priv *priv = container_of(dwork, struct can_priv, restart_work); + +can_restart (priv->dev); +} +int can_restart_now (struct net_device *dev) {struct can_priv *priv =netdev_priv (dev);
@@ -447,8 +455,8 @@ int can_restart_now(struct net_device *dif (priv->state !=CAN_STATE_BUS_OFF )return -EBUSY ; -/* Runs as soon as possible in the timer context */ -mod_timer (&priv->restart_timer, jiffies); +cancel_delayed_work_sync (&priv->restart_work); +can_restart (dev);return 0 ; }
@@ -470,8 +478,8 @@ void can_bus_off(struct net_device *dev) priv->can_stats.bus_off++;if (priv->restart_ms) -mod_timer (&priv->restart_timer, - jiffies + (priv->restart_ms *HZ ) /1000 ); +schedule_delayed_work (&priv->restart_work, +msecs_to_jiffies (priv->restart_ms)); }EXPORT_SYMBOL_GPL (can_bus_off);
@@ -578,6 +586,7 @@ struct net_device *alloc_candev(int sizereturn NULL ; priv =netdev_priv (dev); + priv->dev = dev;if (echo_skb_max) { priv->echo_skb_max = echo_skb_max;
@@ -587,7 +596,7 @@ struct net_device *alloc_candev(int size priv->state =CAN_STATE_STOPPED ; -init_timer (&priv->restart_timer); +INIT_DELAYED_WORK (&priv->restart_work, can_restart_work);return dev; }
@@ -662,8 +671,6 @@ int open_candev(struct net_device *dev)if (!netif_carrier_ok (dev))netif_carrier_on (dev); -setup_timer (&priv->restart_timer, can_restart, (unsigned long )dev); -return 0 ; }EXPORT_SYMBOL_GPL (open_candev);
@@ -678,7 +685,7 @@ void close_candev(struct net_device *dev {struct can_priv *priv =netdev_priv (dev); -del_timer_sync (&priv->restart_timer); +cancel_delayed_work_sync (&priv->restart_work);can_flush_echo_skb (dev); }EXPORT_SYMBOL_GPL (close_candev);
include/linux/can/dev.h +2 -1
@@ -31,6 +31,7 @@ enum can_mode {* CAN common private data */ struct can_priv { +struct net_device *dev;struct can_device_stats can_stats;struct can_bittiming bittiming, data_bittiming;
@@ -43,7 +44,7 @@ struct can_priv {u32 ctrlmode_supported;int restart_ms; -struct timer_list restart_timer; +struct delayed_work restart_work;int (*do_set_bittiming)(struct net_device *dev);int (*do_set_data_bittiming)(struct net_device *dev);
PATCH 317/346 i2c: qup: skip qup_i2c_suspend if the device is already runtime suspended
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <[email protected]>
commit 331dcf421c34d227784d07943eb01e4023a42b0a upstream.
If the i2c device is already runtime suspended, if qup_i2c_suspend is executed during suspend-to-idle or suspend-to-ram it will result in the following splat:
WARNING: CPU: 3 PID: 1593 at drivers/clk/clk.c:476 clk_core_unprepare+0x80/0x90 Modules linked in: CPU: 3 PID: 1593 Comm: bash Tainted: G W 4.8.0-rc3 #14 Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) PC is at clk_core_unprepare+0x80/0x90 LR is at clk_unprepare+0x28/0x40 pc : [<ffff0000086eecf0>] lr : [<ffff0000086f0c58>] pstate: 60000145 Call trace: clk_core_unprepare+0x80/0x90 qup_i2c_disable_clocks+0x2c/0x68 qup_i2c_suspend+0x10/0x20 platform_pm_suspend+0x24/0x68 ...
This patch fixes the issue by executing qup_i2c_pm_suspend_runtime conditionally in qup_i2c_suspend.
--- drivers/i2c/busses/i2c-qup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-qup.c +2 -1
@@ -724,7 +724,8 @@ static int qup_i2c_pm_resume_runtime(str#ifdef CONFIG_PM_SLEEP static int qup_i2c_suspend (struct device *device) { -qup_i2c_pm_suspend_runtime (device); +if (!pm_runtime_suspended (device)) +return qup_i2c_pm_suspend_runtime (device);return 0 ; }
PATCH 318/346 tcp: fix a compile error in DBGUNDO()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 019b1c9fe32a2a32c1153e31375f87ec3e591273 upstream.
If DBGUNDO() is enabled (FASTRETRANS_DEBUG > 1), a compile error will happen, since inet6_sk(sk)->daddr became sk->sk_v6_daddr
--- net/ipv4/tcp_input.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/ipv4/tcp_input.c +1 -2
@@ -2316,10 +2316,9 @@ static void DBGUNDO(struct sock *sk, con }#if IS_ENABLED (CONFIG_IPV6 ) else if (sk->sk_family == AF_INET6) { -struct ipv6_pinfo *np =inet6_sk (sk);pr_debug ("Undo %s %pI6/%u c%u l%u ss%u/%u p%u\n" , msg, - &np->daddr,ntohs (inet->inet_dport), + &sk->sk_v6_daddr,ntohs (inet->inet_dport), tp->snd_cwnd,tcp_left_out (tp), tp->snd_ssthresh, tp->prior_ssthresh, tp->packets_out);
PATCH 319/346 ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path.
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Haishuang Yan <[email protected]>
commit 252f3f5a1189a7f6c309d8e4ff1c4c1888a27f13 upstream.
In gre6 xmit path, we are sending a GRE packet, so set fl6 proto to IPPROTO_GRE properly.
--- net/ipv6/ip6_gre.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/ip6_gre.c +1 -0
@@ -939,6 +939,7 @@ static void ip6gre_tnl_link_config(struc fl6->daddr = p->raddr; fl6->flowi6_oif = p->link; fl6->flowlabel =0 ; + fl6->flowi6_proto =IPPROTO_GRE ;if (!(p->flags&IP6_TNL_F_USE_ORIG_TCLASS )) fl6->flowlabel |=IPV6_TCLASS_MASK & p->flowinfo;
PATCH 320/346 ip6_gre: fix flowi6_proto value in ip6gre_xmit_other()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Lance Richardson <[email protected]>
commit db32e4e49ce2b0e5fcc17803d011a401c0a637f6 upstream.
Similar to commit 3be07244b733 ("ip6_gre: fix flowi6_proto value in xmit path"), set flowi6_proto to IPPROTO_GRE for output route lookup.
Up until now, ip6gre_xmit_other() has set flowi6_proto to a bogus value. This affected output route lookup for packets sent on an ip6gretap device in cases where routing was dependent on the value of flowi6_proto.
Since the correct proto is already set in the tunnel flowi6 template via commit 252f3f5a1189 ("ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path."), simply delete the line setting the incorrect flowi6_proto value.
--- net/ipv6/ip6_gre.c | 1 - 1 file changed, 1 deletion(-)
net/ipv6/ip6_gre.c +0 -1
@@ -881,7 +881,6 @@ static int ip6gre_xmit_other(struct sk_b encap_limit = t->parms.encap_limit;memcpy (&fl6, &t->fl.u.ip6,sizeof (fl6)); - fl6.flowi6_proto = skb->protocol; err =ip6gre_xmit2 (skb, dev,0 , &fl6, encap_limit, &mtu);
PATCH 321/346 tracing: Move mutex to protect against resetting of seq data
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (Red Hat)" <[email protected]>
commit 1245800c0f96eb6ebb368593e251d66c01e61022 upstream.
The iter->seq can be reset outside the protection of the mutex. So can reading of user data. Move the mutex up to the beginning of the function.
--- kernel/trace/trace.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
kernel/trace/trace.c +8 -7
@@ -4435,13 +4435,6 @@ tracing_read_pipe(struct file *filp, chastruct trace_array *tr = iter->tr;ssize_t sret; -/* return any leftover data */ - sret =trace_seq_to_user (&iter->seq, ubuf, cnt); -if (sret != -EBUSY ) -return sret; - -trace_seq_init (&iter->seq); -/* copy the tracer to avoid using a global lock all around */ mutex_lock (&trace_types_lock);if (unlikely (iter->trace->name != tr->current_trace->name))
@@ -4454,6 +4447,14 @@ tracing_read_pipe(struct file *filp, cha* is protected. */ mutex_lock (&iter->mutex); + +/* return any leftover data */ + sret =trace_seq_to_user (&iter->seq, ubuf, cnt); +if (sret != -EBUSY ) + goto out; + +trace_seq_init (&iter->seq); +if (iter->trace->read) { sret = iter->trace->read (iter, filp, ubuf, cnt, ppos);if (sret)
PATCH 322/346 ipmr, ip6mr: fix scheduling while atomic and a deadlock with ipmr_get_route
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
commit 2cf750704bb6d7ed8c7d732e071dd1bc890ea5e8 upstream.
Since the commit below the ipmr/ip6mr rtnl_unicast() code uses the portid instead of the previous dst_pid which was copied from in_skb's portid. Since the skb is new the portid is 0 at that point so the packets are sent to the kernel and we get scheduling while atomic or a deadlock (depending on where it happens) by trying to acquire rtnl two times.
Also since this is RTM_GETROUTE, it can be triggered by a normal user.
Here's the sleeping while atomic trace:
[ 7858.212557] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:620
[ 7858.212748] in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/0
[ 7858.212881] 2 locks held by swapper/0/0:
[ 7858.213013] #0: (((&mrt->ipmr_expire_timer))){+.-...}, at: [<ffffffff810fbbf5>] call_timer_fn+0x5/0x350
[ 7858.213422] #1: (mfc_unres_lock){+.....}, at: [<ffffffff8161e005>] ipmr_expire_process+0x25/0x130
[ 7858.213807] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.8.0-rc7+ #179
[ 7858.213934] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
[ 7858.214108] 0000000000000000 ffff88005b403c50 ffffffff813a7804 0000000000000000
[ 7858.214412] ffffffff81a1338e ffff88005b403c78 ffffffff810a4a72 ffffffff81a1338e
[ 7858.214716] 000000000000026c 0000000000000000 ffff88005b403ca8 ffffffff810a4b9f
[ 7858.215251] Call Trace:
[ 7858.215412] <IRQ> [<ffffffff813a7804>] dump_stack+0x85/0xc1
[ 7858.215662] [<ffffffff810a4a72>] ___might_sleep+0x192/0x250
[ 7858.215868] [<ffffffff810a4b9f>] __might_sleep+0x6f/0x100
[ 7858.216072] [<ffffffff8165bea3>] mutex_lock_nested+0x33/0x4d0
[ 7858.216279] [<ffffffff815a7a5f>] ? netlink_lookup+0x25f/0x460
[ 7858.216487] [<ffffffff8157474b>] rtnetlink_rcv+0x1b/0x40
[ 7858.216687] [<ffffffff815a9a0c>] netlink_unicast+0x19c/0x260
[ 7858.216900] [<ffffffff81573c70>] rtnl_unicast+0x20/0x30
[ 7858.217128] [<ffffffff8161cd39>] ipmr_destroy_unres+0xa9/0xf0
[ 7858.217351] [<ffffffff8161e06f>] ipmr_expire_process+0x8f/0x130
[ 7858.217581] [<ffffffff8161dfe0>] ? ipmr_net_init+0x180/0x180
[ 7858.217785] [<ffffffff8161dfe0>] ? ipmr_net_init+0x180/0x180
[ 7858.217990] [<ffffffff810fbc95>] call_timer_fn+0xa5/0x350
[ 7858.218192] [<ffffffff810fbbf5>] ? call_timer_fn+0x5/0x350
[ 7858.218415] [<ffffffff8161dfe0>] ? ipmr_net_init+0x180/0x180
[ 7858.218656] [<ffffffff810fde10>] run_timer_softirq+0x260/0x640
[ 7858.218865] [<ffffffff8166379b>] ? __do_softirq+0xbb/0x54f
[ 7858.219068] [<ffffffff816637c8>] __do_softirq+0xe8/0x54f
[ 7858.219269] [<ffffffff8107a948>] irq_exit+0xb8/0xc0
[ 7858.219463] [<ffffffff81663452>] smp_apic_timer_interrupt+0x42/0x50
[ 7858.219678] [<ffffffff816625bc>] apic_timer_interrupt+0x8c/0xa0
[ 7858.219897] <EOI> [<ffffffff81055f16>] ? native_safe_halt+0x6/0x10
[ 7858.220165] [<ffffffff810d64dd>] ? trace_hardirqs_on+0xd/0x10
[ 7858.220373] [<ffffffff810298e3>] default_idle+0x23/0x190
[ 7858.220574] [<ffffffff8102a20f>] arch_cpu_idle+0xf/0x20
[ 7858.220790] [<ffffffff810c9f8c>] default_idle_call+0x4c/0x60
[ 7858.221016] [<ffffffff810ca33b>] cpu_startup_entry+0x39b/0x4d0
[ 7858.221257] [<ffffffff8164f995>] rest_init+0x135/0x140
[ 7858.221469] [<ffffffff81f83014>] start_kernel+0x50e/0x51b
[ 7858.221670] [<ffffffff81f82120>] ? early_idt_handler_array+0x120/0x120
[ 7858.221894] [<ffffffff81f8243f>] x86_64_start_reservations+0x2a/0x2c
[ 7858.222113] [<ffffffff81f8257c>] x86_64_start_kernel+0x13b/0x14a--- include/linux/mroute.h | 2 +- include/linux/mroute6.h | 2 +- net/ipv4/ipmr.c | 3 ++- net/ipv4/route.c | 3 ++- net/ipv6/ip6mr.c | 5 +++-- net/ipv6/route.c | 4 +++- 6 files changed, 12 insertions(+), 7 deletions(-)
include/linux/mroute.h +1 -1
@@ -103,5 +103,5 @@ struct mfc_cache {struct rtmsg ;extern int ipmr_get_route (struct net *net,struct sk_buff *skb,__be32 saddr,__be32 daddr, -struct rtmsg *rtm,int nowait); +struct rtmsg *rtm,int nowait,u32 portid);#endif
include/linux/mroute6.h +1 -1
@@ -115,7 +115,7 @@ struct mfc6_cache {struct rtmsg ;extern int ip6mr_get_route (struct net *net,struct sk_buff *skb, -struct rtmsg *rtm,int nowait); +struct rtmsg *rtm,int nowait,u32 portid);#ifdef CONFIG_IPV6_MROUTE extern struct sock *mroute6_socket (struct net *net,struct sk_buff *skb);
net/ipv4/ipmr.c +2 -1
@@ -2188,7 +2188,7 @@ static int __ipmr_fill_mroute(struct mr_int ipmr_get_route (struct net *net,struct sk_buff *skb,__be32 saddr,__be32 daddr, -struct rtmsg *rtm,int nowait) +struct rtmsg *rtm,int nowait,u32 portid) {struct mfc_cache *cache;struct mr_table *mrt;
@@ -2233,6 +2233,7 @@ int ipmr_get_route(struct net *net, strureturn -ENOMEM ; } +NETLINK_CB (skb2).portid = portid;skb_push (skb2,sizeof (struct iphdr ));skb_reset_network_header (skb2); iph =ip_hdr (skb2);
net/ipv4/route.c +2 -1
@@ -2413,7 +2413,8 @@ static int rt_fill_info(struct net *net, IPV4_DEVCONF_ALL(net, MC_FORWARDING)) {int err =ipmr_get_route (net, skb, fl4->saddr, fl4->daddr, - r, nowait); + r, nowait, portid); +if (err <=0 ) {if (!nowait) {if (err ==0 )
net/ipv6/ip6mr.c +3 -2
@@ -2272,8 +2272,8 @@ static int __ip6mr_fill_mroute(struct mrreturn 1 ; } -int ip6mr_get_route (struct net *net, -struct sk_buff *skb,struct rtmsg *rtm,int nowait) +int ip6mr_get_route (struct net *net,struct sk_buff *skb,struct rtmsg *rtm, +int nowait,u32 portid) {int err;struct mr6_table *mrt;
@@ -2318,6 +2318,7 @@ int ip6mr_get_route(struct net *net,return -ENOMEM ; } +NETLINK_CB (skb2).portid = portid;skb_reset_transport_header (skb2);skb_put (skb2,sizeof (struct ipv6hdr ));
net/ipv6/route.c +3 -1
@@ -2618,7 +2618,9 @@ static int rt6_fill_node(struct net *netif (iif) {#ifdef CONFIG_IPV6_MROUTE if (ipv6_addr_is_multicast (&rt->rt6i_dst.addr)) { -int err =ip6mr_get_route (net, skb, rtm, nowait); +int err =ip6mr_get_route (net, skb, rtm, nowait, + portid); +if (err <=0 ) {if (!nowait) {if (err ==0 )
PATCH 323/346 drm/radeon/si/dpm: add workaround for for Jet parts
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 670bb4fd21c966d0d2a59ad4a99bb4889f9a2987 upstream.
Add clock quirks for Jet parts.
--- drivers/gpu/drm/radeon/si_dpm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/radeon/si_dpm.c +6 -0
@@ -3022,6 +3022,12 @@ static void si_apply_state_adjust_rules(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 ; + }/* XXX validate the min clocks required for display */
PATCH 324/346 mm,ksm: fix endless looping in allocating memory when ksm enable
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: zhong jiang <[email protected]>
commit 5b398e416e880159fe55eefd93c6588fa072cd66 upstream.
I hit the following hung task when runing a OOM LTP test case with 4.1 kernel.
Call trace: [<ffffffc000086a88>] __switch_to+0x74/0x8c [<ffffffc000a1bae0>] __schedule+0x23c/0x7bc [<ffffffc000a1c09c>] schedule+0x3c/0x94 [<ffffffc000a1eb84>] rwsem_down_write_failed+0x214/0x350 [<ffffffc000a1e32c>] down_write+0x64/0x80 [<ffffffc00021f794>] __ksm_exit+0x90/0x19c [<ffffffc0000be650>] mmput+0x118/0x11c [<ffffffc0000c3ec4>] do_exit+0x2dc/0xa74 [<ffffffc0000c46f8>] do_group_exit+0x4c/0xe4 [<ffffffc0000d0f34>] get_signal+0x444/0x5e0 [<ffffffc000089fcc>] do_signal+0x1d8/0x450 [<ffffffc00008a35c>] do_notify_resume+0x70/0x78
The oom victim cannot terminate because it needs to take mmap_sem for write while the lock is held by ksmd for read which loops in the page allocator
ksm_do_scan
scan_get_next_rmap_item
down_read
get_next_rmap_item
alloc_rmap_item #ksmd will loop permanently.
There is no way forward because the oom victim cannot release any memory in 4.1 based kernel. Since 4.6 we have the oom reaper which would solve this problem because it would release the memory asynchronously. Nevertheless we can relax alloc_rmap_item requirements and use __GFP_NORETRY because the allocation failure is acceptable as ksm_do_scan would just retry later after the lock got dropped.
Such a patch would be also easy to backport to older stable kernels which do not have oom_reaper.
While we are at it add GFP_NOWARN so the admin doesn't have to be alarmed by the allocation failure.
--- mm/ksm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/ksm.c +2 -1
@@ -283,7 +283,8 @@ static inline struct rmap_item *alloc_rm {struct rmap_item *rmap_item; - rmap_item =kmem_cache_zalloc (rmap_item_cache,GFP_KERNEL ); + rmap_item =kmem_cache_zalloc (rmap_item_cache,GFP_KERNEL | + __GFP_NORETRY | __GFP_NOWARN);if (rmap_item) ksm_rmap_items++;return rmap_item;
PATCH 325/346 ARM: 8617/1: dma: fix dma_max_pfn()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Roger Quadros <[email protected]>
commit d248220f0465b818887baa9829e691fe662b2c5e upstream.
Since commit 6ce0d2001692 ("ARM: dma: Use dma_pfn_offset for dma address translation"), dma_to_pfn() already returns the PFN with the physical memory start offset so we don't need to add it again.
This fixes USB mass storage lock-up problem on systems that can't do DMA over the entire physical memory range (e.g.) Keystone 2 systems with 4GB RAM can only do DMA over the first 2GB. [K2E-EVM].
What happens there is that without this patch SCSI layer sets a wrong bounce buffer limit in scsi_calculate_bounce_limit() for the USB mass storage device. dma_max_pfn() evaluates to 0x8fffff and bounce_limit is set to 0x8fffff000 whereas maximum DMA'ble physical memory on Keystone 2 is 0x87fffffff. This results in non DMA'ble pages being given to the USB controller and hence the lock-up.
NOTE: in the above case, USB-SCSI-device's dma_pfn_offset was showing as 0. This should have really been 0x780000 as on K2e, LOWMEM_START is 0x80000000 and HIGHMEM_START is 0x800000000. DMA zone is 2GB so dma_max_pfn should be 0x87ffff. The incorrect dma_pfn_offset for the USB storage device is because USB devices are not correctly inheriting the dma_pfn_offset from the USB host controller. This will be fixed by a separate patch.
--- arch/arm/include/asm/dma-mapping.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/dma-mapping.h +1 -1
@@ -117,7 +117,7 @@ static inline dma_addr_t virt_to_dma(str/* The ARM override for dma_max_pfn() */ static inline unsigned long dma_max_pfn (struct device *dev) { -return PHYS_PFN_OFFSET +dma_to_pfn (dev, *dev->dma_mask); +return dma_to_pfn (dev, *dev->dma_mask); }#define dma_max_pfn (dev) dma_max_pfn(dev)
PATCH 326/346 MIPS: Malta: Fix IOCU disable switch read for MIPS64
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit 305723ab439e14debc1d339aa04e835d488b8253 upstream.
Malta boards used with CPU emulators feature a switch to disable use of an IOCU. Software has to check this switch & ignore any present IOCU if the switch is closed. The read used to do this was unsafe for 64 bit kernels, as it simply casted the address 0xbf403000 to a pointer & dereferenced it. Whilst in a 32 bit kernel this would access kseg1, in a 64 bit kernel this attempts to access xuseg & results in an address error exception.
Fix by accessing a correctly formed ckseg1 address generated using the CKSEG1ADDR macro.
Whilst modifying this code, define the name of the register and the bit we care about within it, which indicates whether PCI DMA is routed to the IOCU or straight to DRAM. The code previously checked that bit 0 was also set, but the least significant 7 bits of the CONFIG_GEN0 register contain the value of the MReqInfo signal provided to the IOCU OCP bus, so singling out bit 0 makes little sense & that part of the check is dropped.
Patchwork: https://patchwork.linux-mips.org/patch/14187/
--- arch/mips/mti-malta/malta-setup.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/mips/mti-malta/malta-setup.c +7 -1
@@ -36,6 +36,9 @@#include <linux/console.h> #endif +#define ROCIT_CONFIG_GEN0 0x1f403000 +#define ROCIT_CONFIG_GEN0_PCI_IOCU BIT(7) +extern void malta_be_init (void );extern int malta_be_handler (struct pt_regs *regs,int is_fixup);
@@ -104,6 +107,8 @@ static void __init fd_activate(void)static int __init plat_enable_iocoherency (void ) {int supported =0 ; +u32 cfg; +if (mips_revision_sconid ==MIPS_REVISION_SCON_BONITO ) {if (BONITO_PCICACHECTRL &BONITO_PCICACHECTRL_CPUCOH_PRES ) {BONITO_PCICACHECTRL |=BONITO_PCICACHECTRL_CPUCOH_EN ;
@@ -126,7 +131,8 @@ static int __init plat_enable_iocoherenc }else if (mips_cm_numiocu () !=0 ) {/* Nothing special needs to be done to enable coherency */ pr_info ("CMP IOCU detected\n" ); -if ((*(unsigned int *)0xbf403000 &0x81 ) !=0x81 ) { + cfg =__raw_readl ((u32 *)CKSEG1ADDR (ROCIT_CONFIG_GEN0 )); +if (!(cfg &ROCIT_CONFIG_GEN0_PCI_IOCU )) {pr_crit ("IOCU OPERATION DISABLED BY SWITCH - DEFAULTING TO SW IO COHERENCY\n" );return 0 ; }
PATCH 327/346 mm: workingset: fix crash in shadow node shrinker caused by replace_page_cache_page()
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit 22f2ac51b6d643666f4db093f13144f773ff3f3a upstream.
Antonio reports the following crash when using fuse under memory pressure:
kernel BUG at /build/linux-a2WvEb/linux-4.4.0/mm/workingset.c:346! invalid opcode: 0000 [#1] SMP
Modules linked in: all of them
CPU: 2 PID: 63 Comm: kswapd0 Not tainted 4.4.0-36-generic #55-Ubuntu
Hardware name: System manufacturer System Product Name/P8H67-M PRO, BIOS 3904 04/27/2013
task: ffff88040cae6040 ti: ffff880407488000 task.ti: ffff880407488000
RIP: shadow_lru_isolate+0x181/0x190
Call Trace:
__list_lru_walk_one.isra.3+0x8f/0x130
list_lru_walk_one+0x23/0x30
scan_shadow_nodes+0x34/0x50
shrink_slab.part.40+0x1ed/0x3d0
shrink_zone+0x2ca/0x2e0
kswapd+0x51e/0x990
kthread+0xd8/0xf0
ret_from_fork+0x3f/0x70which corresponds to the following sanity check in the shadow node tracking:
BUG_ON(node->count & RADIX_TREE_COUNT_MASK);
The workingset code tracks radix tree nodes that exclusively contain shadow entries of evicted pages in them, and this (somewhat obscure) line checks whether there are real pages left that would interfere with reclaim of the radix tree node under memory pressure.
While discussing ways how fuse might sneak pages into the radix tree past the workingset code, Miklos pointed to replace_page_cache_page(), and indeed there is a problem there: it properly accounts for the old page being removed - __delete_from_page_cache() does that - but then does a raw raw radix_tree_insert(), not accounting for the replacement page. Eventually the page count bits in node->count underflow while leaving the node incorrectly linked to the shadow node LRU.
To address this, make sure replace_page_cache_page() uses the tracked page insertion code, page_cache_tree_insert(). This fixes the page accounting and makes sure page-containing nodes are properly unlinked from the shadow node LRU again.
Also, make the sanity checks a bit less obscure by using the helpers for checking the number of pages and shadows in a radix tree node.
[bwh: Backported to 3.16:
- Implementation of page_cache_tree_insert() is different
- Adjust context]
---
include/linux/swap.h +2 -0
@@ -274,6 +274,7 @@ static inline void workingset_node_pagesstatic inline void workingset_node_pages_dec (struct radix_tree_node *node) { +VM_BUG_ON (!workingset_node_pages (node)); node->count--; }
@@ -289,6 +290,7 @@ static inline void workingset_node_shadostatic inline void workingset_node_shadows_dec (struct radix_tree_node *node) { +VM_BUG_ON (!workingset_node_shadows (node)); node->count -=1U <<RADIX_TREE_COUNT_SHIFT ; }
mm/filemap.c +43 -43
104 lines not on this page · raw message
mm/workingset.c +4 -6
@@ -340,21 +340,19 @@ static enum lru_status shadow_lru_isolat* no pages, so we expect to be able to remove them all and * delete and free the empty node afterwards. */ - -BUG_ON (!node->count); -BUG_ON (node->count &RADIX_TREE_COUNT_MASK ); +BUG_ON (!workingset_node_shadows (node)); +BUG_ON (workingset_node_pages (node));for (i =0 ; i <RADIX_TREE_MAP_SIZE ; i++) {if (node->slots[i]) {BUG_ON (!radix_tree_exceptional_entry (node->slots[i])); node->slots[i] =NULL ; -BUG_ON (node->count < (1U <<RADIX_TREE_COUNT_SHIFT )); - node->count -=1U <<RADIX_TREE_COUNT_SHIFT ; +workingset_node_shadows_dec (node);BUG_ON (!mapping->nrshadows); mapping->nrshadows--; } } -BUG_ON (node->count); +BUG_ON (workingset_node_shadows (node));inc_zone_state (page_zone (virt_to_page (node)),WORKINGSET_NODERECLAIM );if (!__radix_tree_delete_node (&mapping->page_tree, node))BUG ();
Re: [PATCH 3.16 327/346] mm: workingset: fix crash in shadow node shrinker caused by replace_page_cache_page()
Quoted 60 lines · Ben Hutchings
3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit
22f2ac51b6d643666f4db093f13144f773ff3f3aupstream.Antonio reports the following crash when using fuse under memory pressure:
kernel BUG at /build/linux-a2WvEb/linux-4.4.0/mm/workingset.c:346! invalid opcode: 0000 [#1] SMP
Modules linked in: all of them CPU: 2 PID: 63 Comm: kswapd0 Not tainted 4.4.0-36-generic #55-Ubuntu Hardware name: System manufacturer System Product Name/P8H67-M PRO, BIOS 3904 04/27/2013 task: ffff88040cae6040 ti: ffff880407488000 task.ti: ffff880407488000 RIP: shadow_lru_isolate+0x181/0x190 Call Trace: __list_lru_walk_one.isra.3+0x8f/0x130 list_lru_walk_one+0x23/0x30 scan_shadow_nodes+0x34/0x50 shrink_slab.part.40+0x1ed/0x3d0 shrink_zone+0x2ca/0x2e0 kswapd+0x51e/0x990 kthread+0xd8/0xf0 ret_from_fork+0x3f/0x70which corresponds to the following sanity check in the shadow node tracking:
BUG_ON(node->count & RADIX_TREE_COUNT_MASK);The workingset code tracks radix tree nodes that exclusively contain shadow entries of evicted pages in them, and this (somewhat obscure) line checks whether there are real pages left that would interfere with reclaim of the radix tree node under memory pressure.
While discussing ways how fuse might sneak pages into the radix tree past the workingset code, Miklos pointed to
replace_page_cache_page(), and indeed there is a problem there: it properly accounts for the old page being removed -__delete_from_page_cache()does that - but then does a raw rawradix_tree_insert(), not accounting for the replacement page. Eventually the page count bits innode->countunderflow while leaving the node incorrectly linked to the shadow node LRU.To address this, make sure
replace_page_cache_page()uses the tracked page insertion code,page_cache_tree_insert(). This fixes the page accounting and makes sure page-containing nodes are properly unlinked from the shadow node LRU again.Also, make the sanity checks a bit less obscure by using the helpers for checking the number of pages and shadows in a radix tree node.
Fixes 449dd6984d0e ("mm: keep page cache radix tree nodes in check")Signed-off-by Johannes Weiner <[email protected]>Reported-by Antonio SJ Musumeci <[email protected]>Debugged-by Miklos Szeredi <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>
Quoted 4 lines
[bwh: Backported to 3.16:
- Implementation ofpage_cache_tree_insert()is different
- Adjust context]Signed-off-by Ben Hutchings <[email protected]>
The added sanity checks in this patch can crash kernels built with CONFIG_DEBUG_VM. While I doubt many people run 3.16 with that enabled, please also consider taking the following two changes. The first one changes the new VM_BUG_ONs to mere warnings, and the second patch addresses the underlying issue that triggered them in the first place.
21f54ddae449 Using BUG_ON() as an assert() is _never_ acceptable d3798ae8c6f3 mm: filemap: don't plant shadow entries without radix tree node
Attaching the latter below, since it's drastically different than the upstream change, but a lot simpler because it predates the DAX stuff.
Thanks
---
Quoted 1 line
From
06313bb20559e6da67dcc7fe6c66e928f713d061Mon Sep 17 00:00:00 2001
From: Johannes Weiner <[email protected]>
Date: Tue, 4 Oct 2016 22:02:08 +0200
Subject: [PATCH] mm: filemap: don't plant shadow entries without radix tree
node
commit d3798ae8c6f3767c726403c2ca6ecc317752c9dd upstream.
When the underflow checks were added to workingset_node_shadow_dec(), they triggered immediately:
kernel BUG at ./include/linux/swap.h:276!
invalid opcode: 0000 [#1] SMP
Modules linked in: isofs usb_storage fuse xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun nf_conntrack_netbios_ns nf_conntrack_broadcast ip6t_REJECT nf_reject_ipv6
soundcore wmi acpi_als pinctrl_sunrisepoint kfifo_buf tpm_tis industrialio acpi_pad pinctrl_intel tpm_tis_core tpm nfsd auth_rpcgss nfs_acl lockd grace sunrpc dm_crypt
CPU: 0 PID: 20929 Comm: blkid Not tainted 4.8.0-rc8-00087-gbe67d60ba944 #1
Hardware name: System manufacturer System Product Name/Z170-K, BIOS 1803 05/06/2016
task: ffff8faa93ecd940 task.stack: ffff8faa7f478000
RIP: page_cache_tree_insert+0xf1/0x100
Call Trace:
__add_to_page_cache_locked+0x12e/0x270
add_to_page_cache_lru+0x4e/0xe0
mpage_readpages+0x112/0x1d0
blkdev_readpages+0x1d/0x20
__do_page_cache_readahead+0x1ad/0x290
force_page_cache_readahead+0xaa/0x100
page_cache_sync_readahead+0x3f/0x50
generic_file_read_iter+0x5af/0x740
blkdev_read_iter+0x35/0x40
__vfs_read+0xe1/0x130
vfs_read+0x96/0x130
SyS_read+0x55/0xc0
entry_SYSCALL_64_fastpath+0x13/0x8f
Code: 03 00 48 8b 5d d8 65 48 33 1c 25 28 00 00 00 44 89 e8 75 19 48 83 c4 18 5b 41 5c 41 5d 41 5e 5d c3 0f 0b 41 bd ef ff ff ff eb d7 <0f> 0b e8 88 68 ef ff 0f 1f 84 00
RIP page_cache_tree_insert+0xf1/0x100This is a long-standing bug in the way shadow entries are accounted in the radix tree nodes. The shrinker needs to know when radix tree nodes contain only shadow entries, no pages, so node->count is split in half to count shadows in the upper bits and pages in the lower bits.
Unfortunately, the radix tree implementation doesn't know of this and assumes all entries are in node->count. When there is a shadow entry directly in root->rnode and the tree is later extended, the radix tree implementation will copy that entry into the new node and and bump its node->count, i.e. increases the page count bits. Once the shadow gets removed and we subtract from the upper counter, node->count underflows and triggers the warning. Afterwards, without node->count reaching 0 again, the radix tree node is leaked.
Limit shadow entries to when we have actual radix tree nodes and can count them properly. That means we lose the ability to detect refaults from files that had only the first page faulted in at eviction time.
--- mm/filemap.c | 7 +++++++ 1 file changed, 7 insertions(+)
mm/filemap.c +7 -0
@@ -121,6 +121,13 @@ static void page_cache_tree_delete(struct address_space *mapping,__radix_tree_lookup (&mapping->page_tree, page->index, &node, &slot); +/* +* We need a node to properly account shadow +* entries. Don't plant any without. XXX +*/ +if (!node) + shadow =NULL ; +if (shadow) { mapping->nrshadows++;/*
Signature · 1 line
2.10.1
Re: [PATCH 3.16 327/346] mm: workingset: fix crash in shadow node shrinker caused by replace_page_cache_page()
Quoted 8 lines · Johannes Weiner
Quoted 7 lines · Ben Hutchings
3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit
22f2ac51b6d643666f4db093f13144f773ff3f3aupstream.
[...]
Quoted 11 lines
The added sanity checks in this patch can crash kernels built with
CONFIG_DEBUG_VM. While I doubt many people run 3.16 with that enabled, please also consider taking the following two changes. The first one changes the newVM_BUG_ONsto mere warnings, and the second patch addresses the underlying issue that triggered them in the first place.
21f54ddae449UsingBUG_ON()as anassert()is _never_ acceptabled3798ae8c6f3mm: filemap: don't plant shadow entries without radix tree nodeAttaching the latter below, since it's drastically different than the upstream change, but a lot simpler because it predates the DAX stuff.
[...]
Thanks, I've added these two.
Ben.
Signature · 4 lines
Ben Hutchings Lowery's Law: If it jams, force it. If it breaks, it needed replacing anyway.
PATCH 328/346 ARM: 8618/1: decompressor: reset ttbcr fields to use TTBR0 on ARMv7
In reply to Ben Hutchings3.16.39-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Ramana <[email protected]>
commit 117e5e9c4cfcb7628f08de074fbfefec1bb678b7 upstream.
If the bootloader uses the long descriptor format and jumps to kernel decompressor code, TTBCR may not be in a right state. Before enabling the MMU, it is required to clear the TTBCR.PD0 field to use TTBR0 for translation table walks.
The commit dbece45894d3a ("ARM: 7501/1: decompressor:
reset ttbcr for VMSA ARMv7 cores") does the reset of TTBCR.N, but doesn't consider all the bits for the size of TTBCR.N.
Clear TTBCR.PD0 field and reset all the three bits of TTBCR.N to indicate the use of TTBR0 and the correct base address width.
--- arch/arm/boot/compressed/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/compressed/head.S +1 -1
@@ -726,7 +726,7 @@ __armv7_mmu_cache_on: orrne r0, r0, #1 @ MMU enabled movne r1, #0xfffffffd @ domain 0 = client bic r6, r6, #1 << 31 @ 32-bit translation system - bic r6, r6, #3 << 0 @ use only ttbr0 + bic r6, r6, #(7 << 0) | (1 << 4) @ use only ttbr0 mcrne p15, 0, r3, c2, c0, 0 @ load page table pointer mcrne p15, 0, r1, c3, c0, 0 @ load domain access control mcrne p15, 0, r6, c2, c0, 2 @ load ttb control