3.4.70-stable review
Greg Kroah-Hartman
maintainercover 3.4.70-stable review
This is the start of the stable review cycle for the 3.4.70 release. There are 12 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Nov 20 18:41:11 UTC 2013. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.4.70-rc1.gz
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 3.4.70-rc1
Krzysztof Mazur <[email protected]>
usb: fix cleanup after failure in hub_configure()
Rafael J. Wysocki <[email protected]>
PCI/PM: Clear state_saved during suspend
Nicolas Pitre <[email protected]>
ARM: 7670/1: fix the memset fix
Ivan Djelic <[email protected]>
ARM: 7668/1: fix memset-related crashes caused by recent GCC (4.7.2) optimizations
Steven Rostedt <[email protected]>
tracing: Fix potential out-of-bounds in trace_get_user()
Patrick McHardy <[email protected]>
netfilter: nf_ct_sip: don't drop packets with offsets pointing outside the packet
Takashi Iwai <[email protected]>
ALSA: hda - Move one-time init codes from generic_hdmi_init()
Rui li <[email protected]>
USB: add new zte 3g-dongle's pid to option.c
Nikhil P Rao <[email protected]>
PCI: fix truncation of resource size to 32 bits
Jason Wang <[email protected]>
net: flow_dissector: fail on evil iph->ihl
Wei Liu <[email protected]>
xen-netback: use jiffies_64 value to calculate credit timeout
Ben Hutchings <[email protected]>
cxgb3: Fix length calculation in write_ofld_wr() on 32-bit architectures
-------------
Diffstat:
Makefile | 4 +- arch/arm/lib/memset.S | 100 +++++++++++++++---------------- drivers/net/ethernet/chelsio/cxgb3/sge.c | 3 +- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 3 +- drivers/net/xen-netback/netback.c | 10 ++-- drivers/pci/pci-driver.c | 4 ++ drivers/pci/setup-res.c | 3 +- drivers/usb/core/hub.c | 1 + drivers/usb/serial/option.c | 17 ++++++ kernel/trace/trace.c | 5 +- net/core/flow_dissector.c | 2 +- net/netfilter/nf_conntrack_sip.c | 2 +- sound/pci/hda/patch_hdmi.c | 22 +++++-- 14 files changed, 106 insertions(+), 71 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/12 cxgb3: Fix length calculation in write_ofld_wr() on 32-bit architectures
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
[ Upstream commit 262e827fe745642589450ae241b7afd3912c3f25 ]
The length calculation here is now invalid on 32-bit architectures, since sk_buff::tail is a pointer and sk_buff::transport_header is an integer offset:
drivers/net/ethernet/chelsio/cxgb3/sge.c: In function 'write_ofld_wr':drivers/net/ethernet/chelsio/cxgb3/sge.c:1603:9: warning: passing argument 4 of 'make_sgl' makes integer from pointer without a cast [enabled by default]
adap->pdev);
^
drivers/net/ethernet/chelsio/cxgb3/sge.c:964:28: note: expected 'unsigned int' but argument is of type 'sk_buff_data_t'
static inline unsigned int make_sgl(const struct sk_buff *skb,
^Use the appropriate skb accessor functions.
Compile-tested only.
--- drivers/net/ethernet/chelsio/cxgb3/sge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb3/sge.c +2 -1
@@ -1600,7 +1600,8 @@ static void write_ofld_wr(struct adapter flits =skb_transport_offset (skb) /8 ; sgp = ndesc ==1 ? (struct sg_ent *)&d->flit[flits] : sgl; sgl_flits =make_sgl (skb, sgp,skb_transport_header (skb), - skb->tail - skb->transport_header, +skb_tail_pointer (skb) - +skb_transport_header (skb), adap->pdev);if (need_skb_unmap ()) {setup_deferred_unmapping (skb, adap->pdev, sgp, sgl_flits);
Re: [PATCH 3.4 01/12] cxgb3: Fix length calculation in write_ofld_wr() on 32-bit architectures
Hi Greg,
Quoted 2 lines · Greg Kroah-Hartman
3.4-stable review patch. If anyone has any objections, please let me know.
I guess you can drop this commit because, as Ben has already pointed out, it is required for kernels >= 3.11.
Cheers,
--
Luis
Quoted 48 lines
------------------
From: Ben Hutchings <[email protected]>
[ Upstream commit
262e827fe745642589450ae241b7afd3912c3f25]The length calculation here is now invalid on 32-bit architectures, since
sk_buff::tailis a pointer andsk_buff::transport_headeris an integer offset:
drivers/net/ethernet/chelsio/cxgb3/sge.c: In function 'write_ofld_wr':drivers/net/ethernet/chelsio/cxgb3/sge.c:1603:9: warning: passing argument 4 of 'make_sgl' makes integer from pointer without a cast [enabled by default]adap->pdev); ^ drivers/net/ethernet/chelsio/cxgb3/sge.c:964:28: note: expected 'unsigned int' but argument is of type 'sk_buff_data_t' static inline unsigned int make_sgl(const struct sk_buff *skb, ^Use the appropriate skb accessor functions.
Compile-tested only.
Signed-off-by Ben Hutchings <[email protected]>Fixes 1a37e412a022 ('net: Use 16bits for *_headers fields of struct skbuff')Signed-off-by David S. Miller <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/net/ethernet/chelsio/cxgb3/sge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/chelsio/cxgb3/sge.c +2
-2@@ -1600,7 +1600,8 @@ static void write_ofld_wr(struct adapter flits =skb_transport_offset (skb) /8 ; sgp = ndesc ==1 ? (struct sg_ent *)&d->flit[flits] : sgl; sgl_flits =make_sgl (skb, sgp,skb_transport_header (skb), - skb->tail - skb->transport_header, +skb_tail_pointer (skb) - +skb_transport_header (skb), adap->pdev);if (need_skb_unmap ()) {setup_deferred_unmapping (skb, adap->pdev, sgp, sgl_flits); --To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg Kroah-Hartman
maintainerRe: [PATCH 3.4 01/12] cxgb3: Fix length calculation in write_ofld_wr() on 32-bit architectures
Quoted 8 lines · Luis Henriques
Hi Greg,
Quoted 2 lines · Greg Kroah-Hartman
3.4-stable review patch. If anyone has any objections, please let me know.
I guess you can drop this commit because, as Ben has already pointed out, it is required for kernels >= 3.11.
Good point, now dropped, thanks.
greg k-h
Re: [PATCH 3.4 01/12] cxgb3: Fix length calculation in write_ofld_wr() on 32-bit architectures
Quoted 12 lines · Greg Kroah-Hartman
Quoted 8 lines · Luis Henriques
Hi Greg,
Quoted 2 lines · Greg Kroah-Hartman
3.4-stable review patch. If anyone has any objections, please let me know.
I guess you can drop this commit because, as Ben has already pointed out, it is required for kernels >= 3.11.
Good point, now dropped, thanks.
No negative impact on builds:
total: 103 pass: 89 skipped: 10 fail: 4
qemu tests still pass.
Guenter
Greg Kroah-Hartman
maintainerPATCH 2/12 xen-netback: use jiffies_64 value to calculate credit timeout
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Liu <[email protected]>
[ Upstream commit 059dfa6a93b779516321e5112db9d7621b1367ba ]
time_after_eq() only works if the delta is < MAX_ULONG/2.
For a 32bit Dom0, if netfront sends packets at a very low rate, the time between subsequent calls to tx_credit_exceeded() may exceed MAX_ULONG/2 and the test for timer_after_eq() will be incorrect. Credit will not be replenished and the guest may become unable to send packets (e.g., if prior to the long gap, all credit was exhausted).
Use jiffies_64 variant to mitigate this problem for 32bit Dom0.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 3 +-- drivers/net/xen-netback/netback.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -88,6 +88,7 @@ struct xenvif {unsigned long credit_usec;unsigned long remaining_credit;struct timer_list credit_timeout; +u64 credit_window_start;/* Statistics */ unsigned long rx_gso_checksum_fixup;
drivers/net/xen-netback/interface.c +1 -2
@@ -273,8 +273,7 @@ struct xenvif *xenvif_alloc(struct devic vif->credit_bytes = vif->remaining_credit = ~0UL ; vif->credit_usec =0UL ;init_timer (&vif->credit_timeout); -/* Initialize 'expires' now: it's used to track the credit window. */ - vif->credit_timeout.expires = jiffies; + vif->credit_window_start =get_jiffies_64 (); dev->netdev_ops = &xenvif_netdev_ops; dev->hw_features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO ;
drivers/net/xen-netback/netback.c +5 -5
@@ -1197,9 +1197,8 @@ out:static bool tx_credit_exceeded (struct xenvif *vif,unsigned size) { -unsigned long now = jiffies; -unsigned long next_credit = - vif->credit_timeout.expires + +u64 now =get_jiffies_64 (); +u64 next_credit = vif->credit_window_start +msecs_to_jiffies (vif->credit_usec /1000 );/* Timer could already be pending in rare cases. */
@@ -1207,8 +1206,8 @@ static bool tx_credit_exceeded(struct xereturn true;/* Passed the point where we can replenish credit? */ -if (time_after_eq (now, next_credit)) { - vif->credit_timeout.expires = now; +if (time_after_eq64 (now, next_credit)) { + vif->credit_window_start = now;tx_add_credit (vif); }
@@ -1220,6 +1219,7 @@ static bool tx_credit_exceeded(struct xe tx_credit_callback;mod_timer (&vif->credit_timeout, next_credit); + vif->credit_window_start = next_credit;return true; }
Greg Kroah-Hartman
maintainerPATCH 3/12 net: flow_dissector: fail on evil iph->ihl
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Wang <[email protected]>
[ Upstream commit 6f092343855a71e03b8d209815d8c45bf3a27fcd ]
We don't validate iph->ihl which may lead a dead loop if we meet a IPIP skb whose iph->ihl is zero. Fix this by failing immediately when iph->ihl is evil (less than 5).
This issue were introduced by commit ec5efe7946280d1e84603389a1030ccec0a767ae (rps: support IPIP encapsulation).
--- net/core/flow_dissector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/flow_dissector.c +1 -1
@@ -35,7 +35,7 @@ again:struct iphdr _iph; ip: iph =skb_header_pointer (skb, nhoff,sizeof (_iph), &_iph); -if (!iph) +if (!iph || iph->ihl <5 )return false;if (ip_is_fragment (iph))
Greg Kroah-Hartman
maintainerPATCH 4/12 PCI: fix truncation of resource size to 32 bits
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P Rao <[email protected]>
commit d6776e6d5c2f8db0252f447b09736075e1bbe387 upstream.
_pci_assign_resource() took an int "size" argument, which meant that sizes larger than 4GB were truncated. Change type to resource_size_t.
--- drivers/pci/setup-res.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/setup-res.c +2 -1
@@ -206,7 +206,8 @@ static int pci_revert_fw_address(structreturn ret; } -static int _pci_assign_resource (struct pci_dev *dev,int resno,int size,resource_size_t min_align) +static int _pci_assign_resource (struct pci_dev *dev,int resno, +resource_size_t size,resource_size_t min_align) {struct resource *res = dev->resource + resno;struct pci_bus *bus;
Greg Kroah-Hartman
maintainerPATCH 5/12 USB: add new zte 3g-dongles pid to option.c
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rui li <[email protected]>
commit 0636fc507a976cdc40f21bdbcce6f0b98ff1dfe9 upstream.
--- drivers/usb/serial/option.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/usb/serial/option.c +17 -0
@@ -1391,6 +1391,23 @@ static const struct usb_device_id option .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */ .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1533, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1534, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1535, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1545, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1546, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1547, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1565, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1566, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1567, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1589, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1590, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1591, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1592, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1594, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1596, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1598, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1600, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
Greg Kroah-Hartman
maintainerPATCH 6/12 ALSA: hda - Move one-time init codes from generic_hdmi_init()
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 8b8d654b55648561287bd8baca0f75f964a17038 upstream.
The codes to initialize work struct or create a proc interface should be called only once and never although it's called many times through the init callback. Move that stuff into patch_generic_hdmi() so that it's called only once.
--- sound/pci/hda/patch_hdmi.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
sound/pci/hda/patch_hdmi.c +17 -5
@@ -1282,23 +1282,34 @@ static int generic_hdmi_build_controls(sreturn 0 ; } -static int generic_hdmi_init (struct hda_codec *codec) +static int generic_hdmi_init_per_pins (struct hda_codec *codec) {struct hdmi_spec *spec = codec->spec;int pin_idx;for (pin_idx =0 ; pin_idx < spec->num_pins; pin_idx++) {struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; -hda_nid_t pin_nid = per_pin->pin_nid;struct hdmi_eld *eld = &per_pin->sink_eld; -hdmi_init_pin (codec, pin_nid); -snd_hda_jack_detect_enable (codec, pin_nid, pin_nid); - per_pin->codec = codec;INIT_DELAYED_WORK (&per_pin->work, hdmi_repoll_eld);snd_hda_eld_proc_new (codec, eld, pin_idx); } +return 0 ; +} + +static int generic_hdmi_init (struct hda_codec *codec) +{ +struct hdmi_spec *spec = codec->spec; +int pin_idx; + +for (pin_idx =0 ; pin_idx < spec->num_pins; pin_idx++) { +struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; +hda_nid_t pin_nid = per_pin->pin_nid; + +hdmi_init_pin (codec, pin_nid); +snd_hda_jack_detect_enable (codec, pin_nid, pin_nid); + }snd_hda_jack_report_sync (codec);return 0 ; }
@@ -1343,6 +1354,7 @@ static int patch_generic_hdmi(struct hdareturn -EINVAL ; } codec->patch_ops = generic_hdmi_patch_ops; +generic_hdmi_init_per_pins (codec);init_channel_allocations ();
Greg Kroah-Hartman
maintainerPATCH 7/12 netfilter: nf_ct_sip: dont drop packets with offsets pointing outside the packet
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick McHardy <[email protected]>
commit 3a7b21eaf4fb3c971bdb47a98f570550ddfe4471 upstream.
Some Cisco phones create huge messages that are spread over multiple packets. After calculating the offset of the SIP body, it is validated to be within the packet and the packet is dropped otherwise. This breaks operation of these phones. Since connection tracking is supposed to be passive, just let those packets pass unmodified and untracked.
--- net/netfilter/nf_conntrack_sip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_sip.c +1 -1
@@ -1468,7 +1468,7 @@ static int sip_help_tcp(struct sk_buff * msglen = origlen = end - dptr;if (msglen > datalen) -return NF_DROP ; +return NF_ACCEPT ; ret =process_sip_msg (skb, ct, dataoff, &dptr, &msglen);if (ret !=NF_ACCEPT )
Greg Kroah-Hartman
maintainerPATCH 8/12 tracing: Fix potential out-of-bounds in trace_get_user()
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit 057db8488b53d5e4faa0cedb2f39d4ae75dfbdbb upstream.
Andrey reported the following report:
ERROR: AddressSanitizer: heap-buffer-overflow on address ffff8800359c99f3 ffff8800359c99f3 is located 0 bytes to the right of 243-byte region [ffff8800359c9900, ffff8800359c99f3) Accessed by thread T13003:
#0 ffffffff810dd2da (asan_report_error+0x32a/0x440)
#1 ffffffff810dc6b0 (asan_check_region+0x30/0x40)
#2 ffffffff810dd4d3 (__tsan_write1+0x13/0x20)
#3 ffffffff811cd19e (ftrace_regex_release+0x1be/0x260)
#4 ffffffff812a1065 (__fput+0x155/0x360)
#5 ffffffff812a12de (____fput+0x1e/0x30)
#6 ffffffff8111708d (task_work_run+0x10d/0x140)
#7 ffffffff810ea043 (do_exit+0x433/0x11f0)
#8 ffffffff810eaee4 (do_group_exit+0x84/0x130)
#9 ffffffff810eafb1 (SyS_exit_group+0x21/0x30)
#10 ffffffff81928782 (system_call_fastpath+0x16/0x1b)
Allocated by thread T5167:
#0 ffffffff810dc778 (asan_slab_alloc+0x48/0xc0) #1 ffffffff8128337c (__kmalloc+0xbc/0x500) #2 ffffffff811d9d54 (trace_parser_get_init+0x34/0x90) #3 ffffffff811cd7b3 (ftrace_regex_open+0x83/0x2e0) #4 ffffffff811cda7d (ftrace_filter_open+0x2d/0x40) #5 ffffffff8129b4ff (do_dentry_open+0x32f/0x430) #6 ffffffff8129b668 (finish_open+0x68/0xa0) #7 ffffffff812b66ac (do_last+0xb8c/0x1710) #8 ffffffff812b7350 (path_openat+0x120/0xb50) #9 ffffffff812b8884 (do_filp_open+0x54/0xb0) #10 ffffffff8129d36c (do_sys_open+0x1ac/0x2c0) #11 ffffffff8129d4b7 (SyS_open+0x37/0x50) #12 ffffffff81928782 (system_call_fastpath+0x16/0x1b)
Shadow bytes around the buggy address:
ffff8800359c9700: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
ffff8800359c9780: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
ffff8800359c9800: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
ffff8800359c9880: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
ffff8800359c9900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>ffff8800359c9980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00[03]fb
ffff8800359c9a00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
ffff8800359c9a80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
ffff8800359c9b00: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
ffff8800359c9b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8800359c9c00: 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap redzone: fa Heap kmalloc redzone: fb Freed heap region: fd Shadow gap: fe
The out-of-bounds access happens on 'parser->buffer[parser->idx] = 0;'
Although the crash happened in ftrace_regex_open() the real bug occurred in trace_get_user() where there's an incrementation to parser->idx without a check against the size. The way it is triggered is if userspace sends in 128 characters (EVENT_BUF_SIZE + 1), the loop that reads the last character stores it and then breaks out because there is no more characters. Then the last character is read to determine what to do next, and the index is incremented without checking size.
Then the caller of trace_get_user() usually nulls out the last character with a zero, but since the index is equal to the size, it writes a nul character after the allocated space, which can corrupt memory.
Luckily, only root user has write access to this file.
--- kernel/trace/trace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/trace/trace.c +4 -1
@@ -590,9 +590,12 @@ int trace_get_user(struct trace_parser *if (isspace (ch)) { parser->buffer[parser->idx] =0 ; parser->cont = false; - }else { + }else if (parser->idx < parser->size -1 ) { parser->cont = true; parser->buffer[parser->idx++] = ch; + }else { + ret = -EINVAL ; + goto out; } *ppos += read;
Greg Kroah-Hartman
maintainerPATCH 9/12 ARM: 7668/1: fix memset-related crashes caused by recent GCC (4.7.2) optimizations
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Djelic <[email protected]>
commit 455bd4c430b0c0a361f38e8658a0d6cb469942b5 upstream.
Recent GCC versions (e.g. GCC-4.7.2) perform optimizations based on assumptions about the implementation of memset and similar functions. The current ARM optimized memset code does not return the value of its first argument, as is usually expected from standard implementations.
For instance in the following function:
void debug_mutex_lock_common(struct mutex *lock, struct mutex_waiter *waiter)
{
memset(waiter, MUTEX_DEBUG_INIT, sizeof(*waiter));
waiter->magic = waiter;
INIT_LIST_HEAD(&waiter->list);
}compiled as:
800554d0 <debug_mutex_lock_common>:
800554d0: e92d4008 push {r3, lr}
800554d4: e1a00001 mov r0, r1
800554d8: e3a02010 mov r2, #16 ; 0x10
800554dc: e3a01011 mov r1, #17 ; 0x11
800554e0: eb04426e bl 80165ea0 <memset>
800554e4: e1a03000 mov r3, r0
800554e8: e583000c str r0, [r3, #12]
800554ec: e5830000 str r0, [r3]
800554f0: e5830004 str r0, [r3, #4]
800554f4: e8bd8008 pop {r3, pc}GCC assumes memset returns the value of pointer 'waiter' in register r0; causing register/memory corruptions.
This patch fixes the return value of the assembly version of memset. It adds a 'mov' instruction and merges an additional load+store into existing load/store instructions.
For ease of review, here is a breakdown of the patch into 4 simple steps:
Step 1
======
Perform the following substitutions:
ip -> r8, then
r0 -> ip,
and insert 'mov ip, r0' as the first statement of the function. At this point, we have a memset() implementation returning the proper result, but corrupting r8 on some paths (the ones that were using ip).
Step 2
======
Make sure r8 is saved and restored when (! CALGN(1)+0) == 1:
save r8:
- str lr, [sp, #-4]!
+ stmfd sp!, {r8, lr}and restore r8 on both exit paths:
- ldmeqfd sp!, {pc} @ Now <64 bytes to go.
+ ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go.
(...)
tst r2, #16
stmneia ip!, {r1, r3, r8, lr}
- ldr lr, [sp], #4
+ ldmfd sp!, {r8, lr}Step 3
======
Make sure r8 is saved and restored when (! CALGN(1)+0) == 0:
save r8:
- stmfd sp!, {r4-r7, lr}
+ stmfd sp!, {r4-r8, lr}and restore r8 on both exit paths:
bgt 3b
- ldmeqfd sp!, {r4-r7, pc}
+ ldmeqfd sp!, {r4-r8, pc}
(...)
tst r2, #16
stmneia ip!, {r4-r7}
- ldmfd sp!, {r4-r7, lr}
+ ldmfd sp!, {r4-r8, lr}Step 4
======
Rewrite register list "r4-r7, r8" as "r4-r8".
--- arch/arm/lib/memset.S | 85 +++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 41 deletions(-)
arch/arm/lib/memset.S +44 -41
@@ -19,9 +19,9 @@ 1: subs r2, r2, #4 @ 1 do we have enough blt 5f @ 1 bytes to align with? cmp r3, #2 @ 1 - strltb r1, [r0], #1 @ 1 - strleb r1, [r0], #1 @ 1 - strb r1, [r0], #1 @ 1 + strltb r1, [ip], #1 @ 1 + strleb r1, [ip], #1 @ 1 + strb r1, [ip], #1 @ 1 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3)) /* * The pointer is now aligned and the length is adjusted. Try doing the
@@ -29,10 +29,14 @@ */ ENTRY(memset) - ands r3, r0, #3 @ 1 unaligned? +/* + * Preserve the contents of r0 for the return value. + */ + mov ip, r0 + ands r3, ip, #3 @ 1 unaligned? bne 1b @ 1 /* - * we know that the pointer in r0 is aligned to a word boundary. + * we know that the pointer in ip is aligned to a word boundary. */ orr r1, r1, r1, lsl #8 orr r1, r1, r1, lsl #16
@@ -43,29 +47,28 @@ ENTRY(memset) #if ! CALGN(1)+0 /* - * We need an extra register for this loop - save the return address and - * use the LR + * We need 2 extra registers for this loop - use r8 and the LR */ - str lr, [sp, #-4]! - mov ip, r1 + stmfd sp!, {r8, lr} + mov r8, r1 mov lr, r1 2: subs r2, r2, #64 - stmgeia r0!, {r1, r3, ip, lr} @ 64 bytes at a time. - stmgeia r0!, {r1, r3, ip, lr} - stmgeia r0!, {r1, r3, ip, lr} - stmgeia r0!, {r1, r3, ip, lr} + stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time. + stmgeia ip!, {r1, r3, r8, lr} + stmgeia ip!, {r1, r3, r8, lr} + stmgeia ip!, {r1, r3, r8, lr} bgt 2b - ldmeqfd sp!, {pc} @ Now <64 bytes to go. + ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go. /* * No need to correct the count; we're only testing bits from now on */ tst r2, #32 - stmneia r0!, {r1, r3, ip, lr} - stmneia r0!, {r1, r3, ip, lr} + stmneia ip!, {r1, r3, r8, lr} + stmneia ip!, {r1, r3, r8, lr} tst r2, #16 - stmneia r0!, {r1, r3, ip, lr} - ldr lr, [sp], #4 + stmneia ip!, {r1, r3, r8, lr} + ldmfd sp!, {r8, lr} #else
@@ -74,54 +77,54 @@ ENTRY(memset) * whole cache lines at once. */ - stmfd sp!, {r4-r7, lr} + stmfd sp!, {r4-r8, lr} mov r4, r1 mov r5, r1 mov r6, r1 mov r7, r1 - mov ip, r1 + mov r8, r1 mov lr, r1 cmp r2, #96 - tstgt r0, #31 + tstgt ip, #31 ble 3f - and ip, r0, #31 - rsb ip, ip, #32 - sub r2, r2, ip - movs ip, ip, lsl #(32 - 4) - stmcsia r0!, {r4, r5, r6, r7} - stmmiia r0!, {r4, r5} - tst ip, #(1 << 30) - mov ip, r1 - strne r1, [r0], #4 + and r8, ip, #31 + rsb r8, r8, #32 + sub r2, r2, r8 + movs r8, r8, lsl #(32 - 4) + stmcsia ip!, {r4, r5, r6, r7} + stmmiia ip!, {r4, r5} + tst r8, #(1 << 30) + mov r8, r1 + strne r1, [ip], #4 3: subs r2, r2, #64 - stmgeia r0!, {r1, r3-r7, ip, lr} - stmgeia r0!, {r1, r3-r7, ip, lr} + stmgeia ip!, {r1, r3-r8, lr} + stmgeia ip!, {r1, r3-r8, lr} bgt 3b - ldmeqfd sp!, {r4-r7, pc} + ldmeqfd sp!, {r4-r8, pc} tst r2, #32 - stmneia r0!, {r1, r3-r7, ip, lr} + stmneia ip!, {r1, r3-r8, lr} tst r2, #16 - stmneia r0!, {r4-r7} - ldmfd sp!, {r4-r7, lr} + stmneia ip!, {r4-r7} + ldmfd sp!, {r4-r8, lr} #endif 4: tst r2, #8 - stmneia r0!, {r1, r3} + stmneia ip!, {r1, r3} tst r2, #4 - strne r1, [r0], #4 + strne r1, [ip], #4 /* * When we get here, we've got less than 4 bytes to zero. We * may have an unaligned pointer as well. */ 5: tst r2, #2 - strneb r1, [r0], #1 - strneb r1, [r0], #1 + strneb r1, [ip], #1 + strneb r1, [ip], #1 tst r2, #1 - strneb r1, [r0], #1 + strneb r1, [ip], #1 mov pc, lr ENDPROC(memset)
Greg Kroah-Hartman
maintainerPATCH 10/12 ARM: 7670/1: fix the memset fix
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Pitre <[email protected]>
commit 418df63adac56841ef6b0f1fcf435bc64d4ed177 upstream.
Commit 455bd4c430b0 ("ARM: 7668/1: fix memset-related crashes caused by recent GCC (4.7.2) optimizations") attempted to fix a compliance issue with the memset return value. However the memset itself became broken by that patch for misaligned pointers.
This fixes the above by branching over the entry code from the misaligned fixup code to avoid reloading the original pointer.
Also, because the function entry alignment is wrong in the Thumb mode compilation, that fixup code is moved to the end.
While at it, the entry instructions are slightly reworked to help dual issue pipelines.
--- arch/arm/lib/memset.S | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
arch/arm/lib/memset.S +13 -20
@@ -14,31 +14,15 @@ .text .align 5 - .word 0 - -1: subs r2, r2, #4 @ 1 do we have enough - blt 5f @ 1 bytes to align with? - cmp r3, #2 @ 1 - strltb r1, [ip], #1 @ 1 - strleb r1, [ip], #1 @ 1 - strb r1, [ip], #1 @ 1 - add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3)) -/* - * The pointer is now aligned and the length is adjusted. Try doing the - * memset again. - */ ENTRY(memset) -/* - * Preserve the contents of r0 for the return value. - */ - mov ip, r0 - ands r3, ip, #3 @ 1 unaligned? - bne 1b @ 1 + ands r3, r0, #3 @ 1 unaligned? + mov ip, r0 @ preserve r0 as return value + bne 6f @ 1 /* * we know that the pointer in ip is aligned to a word boundary. */ - orr r1, r1, r1, lsl #8 +1: orr r1, r1, r1, lsl #8 orr r1, r1, r1, lsl #16 mov r3, r1 cmp r2, #16
@@ -127,4 +111,13 @@ ENTRY(memset) tst r2, #1 strneb r1, [ip], #1 mov pc, lr + +6: subs r2, r2, #4 @ 1 do we have enough + blt 5b @ 1 bytes to align with? + cmp r3, #2 @ 1 + strltb r1, [ip], #1 @ 1 + strleb r1, [ip], #1 @ 1 + strb r1, [ip], #1 @ 1 + add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3)) + b 1b ENDPROC(memset)
Greg Kroah-Hartman
maintainerPATCH 11/12 PCI/PM: Clear state_saved during suspend
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Rafael J. Wysocki" <[email protected]>
commit 82fee4d67ab86d6fe5eb0f9a9e988ca9d654d765 upstream.
This patch clears pci_dev->state_saved at the beginning of suspending. PCI config state may be saved long before that. Some drivers call pci_save_state() from the ->probe() callback to get snapshot of sane configuration space to use in the ->slot_reset() callback.
--- drivers/pci/pci-driver.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/pci-driver.c +4 -0
@@ -680,6 +680,7 @@ static int pci_pm_suspend(struct device goto Fixup; } + pci_dev->state_saved = false;if (pm->suspend) {pci_power_t prev = pci_dev->current_state;int error;
@@ -826,6 +827,7 @@ static int pci_pm_freeze(struct device *return 0 ; } + pci_dev->state_saved = false;if (pm->freeze) {int error;
@@ -914,6 +916,7 @@ static int pci_pm_poweroff(struct device goto Fixup; } + pci_dev->state_saved = false;if (pm->poweroff) {int error;
@@ -1032,6 +1035,7 @@ static int pci_pm_runtime_suspend(structif (!pm || !pm->runtime_suspend)return -ENOSYS ; + pci_dev->state_saved = false; error = pm->runtime_suspend (dev);suspend_report_result (pm->runtime_suspend, error);if (error)
Greg Kroah-Hartman
maintainerPATCH 12/12 usb: fix cleanup after failure in hub_configure()
In reply to Greg Kroah-Hartman3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Mazur <[email protected]>
commit d0308d4b6b02597f39fc31a9bddf7bb3faad5622 upstream.
If the hub_configure() fails after setting the hdev->maxchild the hub->ports might be NULL or point to uninitialized kzallocated memory causing NULL pointer dereference in hub_quiesce() during cleanup.
Now after such error the hdev->maxchild is set to 0 to avoid cleanup of uninitialized ports.
--- drivers/usb/core/hub.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/core/hub.c +1 -0
@@ -1335,6 +1335,7 @@ static int hub_configure(struct usb_hubreturn 0 ; fail: + hdev->maxchild =0 ;dev_err (hub_dev,"config failed, %s (err %d)\n" , message, ret);/* hub_disconnect() frees urb and descriptor */
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.4.70 release. There are 12 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 7 lines
Responses should be made by Wed Nov 20 18:41:11 UTC 2013. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.4.70-rc1.gzand the diffstat can be found below.
Build test results:
total: 103 pass: 89 skipped: 10 fail: 4
qemu tests all pass.
Results match the results seen with the previous release and are as expected.
Guenter
Greg Kroah-Hartman
maintainerQuoted 14 lines · Guenter Roeck
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.4.70 release. There are 12 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 7 lines
Responses should be made by Wed Nov 20 18:41:11 UTC 2013. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.4.70-rc1.gzand the diffstat can be found below.
Quoted 6 lines
Build test results:
total: 103 pass: 89 skipped: 10 fail: 4qemu tests all pass.
Results match the results seen with the previous release and are as expected.
Thanks for testing all 4 of these and letting me know all is well.
greg k-h
At Mon, 18 Nov 2013 10:41:33 -0800,
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.4.70 release. There are 12 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Nov 20 18:41:11 UTC 2013. Anything received after that time might be too late.
This kernel can be built and boot without any problem. Building a kernel with this kernel also works fine.
- Build Machine: debian jessy x86_64
CPU: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz x 4
memory: 8GB
- Test machine: debian jessy x86_64(KVM guest on the Build Machine)
vCPU: x2
memory: 2GB
Thanks,
Satoru
Greg Kroah-Hartman
maintainerQuoted 14 lines · Satoru Takeuchi
At Mon, 18 Nov 2013 10:41:33 -0800,
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.4.70 release. There are 12 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Nov 20 18:41:11 UTC 2013. Anything received after that time might be too late.
This kernel can be built and boot without any problem. Building a kernel with this kernel also works fine.
Quoted 7 lines
- Build Machine: debian jessy
x86_64
CPU: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz x 4
memory: 8GB- Test machine: debian jessy
x86_64(KVM guest on the Build Machine)
vCPU: x2
memory: 2GB
Thanks for testing this one, and the 3 others and letting me know they all work.
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.4.70 release. There are 12 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Nov 20 18:41:11 UTC 2013. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.4.70-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
3.4.70:
patches applied cleanly
Compile test - passed
Boot tests - passed
dmesg regression tests - passed
[dmesgs look good. No regressions compared to the previous dmesgs for this release. dmesg emerg, crit, alert, err are clean. No regressions in warn.]
Cross-compile testing - limited tests passed (alpha, arm, arm64, blackfin, c6x, powerpc, sh, sparc, tile)
Test systems:
Samsung Series 9 900X4C Intel Corei5 (3.4 and later)
HP ProBook 6475b AMD A10-4600M APU with Radeon(tm) HD Graphics HP Compaq dc7700 SFF desktop: x86-64 Intel Core-i2 (cross-compile testing)
-- Shuah
Signature · 4 lines
Shuah Khan Senior Linux Kernel Developer - Open Source Group Samsung Research America(Silicon Valley) [email protected] | (970) 672-0658
Greg Kroah-Hartman
maintainerQuoted 29 lines · Shuah Khan
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.4.70 release. There are 12 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed Nov 20 18:41:11 UTC 2013. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.4.70-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
3.4.70:
patches applied cleanly
Compile test - passed
Boot tests - passeddmesg regression tests - passed
[dmesgs look good. No regressions compared to the previous dmesgs for this release. dmesg emerg, crit, alert, err are clean. No regressions in warn.]
Quoted 7 lines
Cross-compile testing - limited tests passed (alpha, arm, arm64, blackfin, c6x, powerpc, sh, sparc, tile)
Test systems:
Samsung Series 9 900X4C Intel Corei5 (3.4 and later)
HP ProBook 6475b AMD A10-4600M APU with Radeon(tm) HD Graphics HP Compaq dc7700 SFF desktop: x86-64 Intel Core-i2 (cross-compile testing)
Thanks for testing all 4 kernels and letting me know they work.
greg k-h