Bluetooth: btusb: fix QCA Rome suspend/resume
Subsystems (215)
From: Leif Liddy <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fd865802c66bc451dc515ed89360f84376ce1a56 ]
There's been numerous reported instances where BTUSB_QCA_ROME bluetooth controllers stop functioning upon resume from suspend. These devices seem to be losing power during suspend. Patch will detect a status change on resume and perform a reset.
--- drivers/bluetooth/btusb.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/bluetooth/btusb.c +6 -0
@@ -3207,6 +3207,12 @@ static int btusb_probe(struct usb_interface *intf,if (id->driver_info &BTUSB_QCA_ROME ) { data->setup_on_usb = btusb_setup_qca; hdev->set_bdaddr = btusb_set_bdaddr_ath3012; + +/* QCA Rome devices lose their updated firmware over suspend, +* but the USB hub doesn't notice any status change. +* Explicitly request a device reset on resume. +*/ +set_bit (BTUSB_RESET_RESUME , &data->flags); }if (id->driver_info &BTUSB_REALTEK )
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] more bio_map_user_iov() leak fixes
From: Al Viro <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2b04e8f6bbb196cab4b232af0f8d48ff2c7a8058 ]
we need to take care of failure exit as well - pages already in bio should be dropped by analogue of bio_unmap_pages(), since their refcounts had been bumped only once per reference in bio.
--- block/bio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
block/bio.c +9 -5
@@ -1290,6 +1290,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,int ret, offset;struct iov_iter i;struct iovec iov; +struct bio_vec *bvec;iov_for_each (iov, i, *iter) {unsigned long uaddr = (unsigned long ) iov.iov_base;
@@ -1334,7 +1335,12 @@ struct bio *bio_map_user_iov(struct request_queue *q, ret =get_user_pages_fast (uaddr, local_nr_pages, (iter->type &WRITE ) !=WRITE , &pages[cur_page]); -if (ret < local_nr_pages) { +if (unlikely (ret < local_nr_pages)) { +for (j = cur_page; j < page_limit; j++) { +if (!pages[j]) +break ; +put_page (pages[j]); + } ret = -EFAULT ; goto out_unmap; }
@@ -1396,10 +1402,8 @@ struct bio *bio_map_user_iov(struct request_queue *q,return bio; out_unmap: -for (j =0 ; j < nr_pages; j++) { -if (!pages[j]) -break ; -page_cache_release (pages[j]); +bio_for_each_segment_all (bvec, bio, j) { +put_page (bvec->bv_page); } out:kfree (pages);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5553b142be11e794ebc0805950b2e8313f93d718 ]
VTTBR_BADDR_MASK is used to sanity check the size and alignment of the VTTBR address. It seems to currently be off by one, thereby only allowing up to 39-bit addresses (instead of 40-bit) and also insufficiently checking the alignment. This patch fixes it.
This patch is the 32bit pendent of Kristina's arm64 fix, and she deserves the actual kudos for pinpointing that one.
--- arch/arm/include/asm/kvm_arm.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/include/asm/kvm_arm.h +1 -2
@@ -161,8 +161,7 @@#else #define VTTBR_X (5 - KVM_T0SZ)#endif -#define VTTBR_BADDR_SHIFT (VTTBR_X - 1) -#define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT) +#define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_X)#define VTTBR_VMID_SHIFT (48LLU)#define VTTBR_VMID_MASK (0xffLLU << VTTBR_VMID_SHIFT)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] arm64: Initialise high_memory global variable earlier
In reply to Sasha LevinFrom: Steve Capper <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f24e5834a2c3f6c5f814a417f858226f0a010ade ]
The high_memory global variable is used bycma_declare_contiguous(.) before it is defined.
We don't notice this as we compute __pa(high_memory - 1), and it looks like we're processing a VA from the direct linear map.
This problem becomes apparent when we flip the kernel virtual address space and the linear map is moved to the bottom of the kernel VA space.
This patch moves the initialisation of high_memory before it used.
--- arch/arm64/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/mm/init.c +1 -1
@@ -177,6 +177,7 @@ void __init arm64_memblock_init(void) arm64_dma_phys_limit =max_zone_dma_phys (); else arm64_dma_phys_limit =PHYS_MASK +1 ; + high_memory =__va (memblock_end_of_DRAM () -1 ) +1 ;dma_contiguous_reserve (arm64_dma_phys_limit);memblock_allow_resize ();
@@ -201,7 +202,6 @@ void __init bootmem_init(void)sparse_init ();zone_sizes_init (min, max); - high_memory =__va ((max <<PAGE_SHIFT ) -1 ) +1 ; max_pfn = max_low_pfn = max; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: hda - add support for docking station for HP 820 G2
In reply to Sasha LevinFrom: Jaroslav Kysela <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 04d5466a976b096364a39a63ac264c1b3a5f8fa1 ]
This tested patch adds missing initialization for Line-In/Out PINs for the docking station for HP 820 G2.
--- sound/pci/hda/patch_realtek.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
sound/pci/hda/patch_realtek.c +13 -1
@@ -4732,6 +4732,7 @@ enum {ALC286_FIXUP_HP_GPIO_LED ,ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY ,ALC280_FIXUP_HP_DOCK_PINS , +ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED ,ALC280_FIXUP_HP_9480M ,ALC288_FIXUP_DELL_HEADSET_MODE , ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
@@ -5270,6 +5271,16 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id =ALC280_FIXUP_HP_GPIO4 }, + [ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x1b ,0x21011020 },/* line-out */ + {0x18 ,0x2181103f },/* line-in */ + { }, + }, + .chained = true, + .chain_id =ALC269_FIXUP_HP_GPIO_MIC1_LED + }, [ALC280_FIXUP_HP_9480M] = { .type = HDA_FIXUP_FUNC, .v.func = alc280_fixup_hp_9480m,
@@ -5522,7 +5533,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x2256 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ),SND_PCI_QUIRK (0x103c ,0x2257 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ),SND_PCI_QUIRK (0x103c ,0x2259 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ), -SND_PCI_QUIRK (0x103c ,0x225a ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ), +SND_PCI_QUIRK (0x103c ,0x225a ,"HP" ,ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED ),SND_PCI_QUIRK (0x103c ,0x2260 ,"HP" ,ALC269_FIXUP_HP_MUTE_LED_MIC1 ),SND_PCI_QUIRK (0x103c ,0x2263 ,"HP" ,ALC269_FIXUP_HP_MUTE_LED_MIC1 ), SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
@@ -5684,6 +5695,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"}, {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"}, + {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"}, {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"}, {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"}, {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Add INVPCID helpers
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 060a402a1ddb551455ee410de2eadd3349f2801b ]
This adds helpers for each of the four currently-specified INVPCID modes.
--- arch/x86/include/asm/tlbflush.h | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
arch/x86/include/asm/tlbflush.h +48 -0
@@ -7,6 +7,54 @@#include <asm/processor.h> #include <asm/special_insns.h> +static inline void __invpcid (unsigned long pcid,unsigned long addr, +unsigned long type) +{ +u64 desc[2 ] = { pcid, addr }; + +/* +* The memory clobber is because the whole point is to invalidate +* stale TLB entries and, especially if we're flushing global +* mappings, we don't want the compiler to reorder any subsequent +* memory accesses before the TLB flush. +* +* The hex opcode is invpcid (%ecx), %eax in 32-bit mode and +* invpcid (%rcx), %rax in long mode. +*/ + asmvolatile (".byte 0x66, 0x0f, 0x38, 0x82, 0x01" + : :"m" (desc),"a" (type),"c" (desc) :"memory" ); +} + +#define INVPCID_TYPE_INDIV_ADDR 0 +#define INVPCID_TYPE_SINGLE_CTXT 1 +#define INVPCID_TYPE_ALL_INCL_GLOBAL 2 +#define INVPCID_TYPE_ALL_NON_GLOBAL 3 + +/* Flush all mappings for a given pcid and addr, not including globals. */ +static inline void invpcid_flush_one (unsigned long pcid, +unsigned long addr) +{ +__invpcid (pcid, addr,INVPCID_TYPE_INDIV_ADDR ); +} + +/* Flush all mappings for a given PCID, not including globals. */ +static inline void invpcid_flush_single_context (unsigned long pcid) +{ +__invpcid (pcid,0 ,INVPCID_TYPE_SINGLE_CTXT ); +} + +/* Flush all mappings, including globals, for all PCIDs. */ +static inline void invpcid_flush_all (void ) +{ +__invpcid (0 ,0 ,INVPCID_TYPE_ALL_INCL_GLOBAL ); +} + +/* Flush all mappings for all PCIDs except globals. */ +static inline void invpcid_flush_all_nonglobals (void ) +{ +__invpcid (0 ,0 ,INVPCID_TYPE_ALL_NON_GLOBAL ); +} +#ifdef CONFIG_PARAVIRT #include <asm/paravirt.h> #else
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Fix INVPCID asm constraint
In reply to Sasha LevinFrom: Borislav Petkov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e2c7698cd61f11d4077fdb28148b2d31b82ac848 ]
So we want to specify the dependency on both @pcid and @addr so that the compiler doesn't reorder accesses to them *before* the TLB flush. But for that to work, we need to express this properly in the inline asm and deref the whole desc array, not the pointer to it. See clwb() for an example.
This fixes the build error on 32-bit:
arch/x86/include/asm/tlbflush.h: In function ‘__invpcid’:
arch/x86/include/asm/tlbflush.h:26:18: error: memory input 0 is not directly addressable
which gcc4.7 caught but 5.x didn't. Which is strange. :-\
--- arch/x86/include/asm/tlbflush.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/tlbflush.h +2 -2
@@ -10,7 +10,7 @@static inline void __invpcid (unsigned long pcid,unsigned long addr,unsigned long type) { -u64 desc[2 ] = { pcid, addr }; +struct {u64 d[2 ]; } desc = { { pcid, addr } };/* * The memory clobber is because the whole point is to invalidate
@@ -22,7 +22,7 @@ static inline void __invpcid(unsigned long pcid, unsigned long addr,* invpcid (%rcx), %rax in long mode. */ asmvolatile (".byte 0x66, 0x0f, 0x38, 0x82, 0x01" - : :"m" (desc),"a" (type),"c" (desc) :"memory" ); + : :"m" (desc),"a" (type),"c" (&desc) :"memory" ); }#define INVPCID_TYPE_INDIV_ADDR 0
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] arm: kprobes: Fix the return address of multiple kretprobes
In reply to Sasha LevinFrom: Masami Hiramatsu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 06553175f585b52509c7df37d6f4a50aacb7b211 ]
This is arm port of commit 737480a0d525 ("kprobes/x86:
Fix the return address of multiple kretprobes").
Fix the return address of subsequent kretprobes when multiple kretprobes are set on the same function.
For example:
# cd /sys/kernel/debug/tracing # echo "r:event1 sys_symlink" > kprobe_events # echo "r:event2 sys_symlink" >> kprobe_events # echo 1 > events/kprobes/enable # ln -s /tmp/foo /tmp/bar
(without this patch)
# cat trace | grep -v ^#
ln-82 [000] dn.2 68.446525: event1: (kretprobe_trampoline+0x0/0x18 <- SyS_symlink)
ln-82 [000] dn.2 68.447831: event2: (ret_fast_syscall+0x0/0x1c <- SyS_symlink)(with this patch)
# cat trace | grep -v ^#
ln-81 [000] dn.1 39.463469: event1: (ret_fast_syscall+0x0/0x1c <- SyS_symlink)
ln-81 [000] dn.1 39.464701: event2: (ret_fast_syscall+0x0/0x1c <- SyS_symlink)--- arch/arm/probes/kprobes/core.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
arch/arm/probes/kprobes/core.c +22 -2
@@ -433,6 +433,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)struct hlist_node *tmp;unsigned long flags, orig_ret_address =0 ;unsigned long trampoline_address = (unsigned long )&kretprobe_trampoline; +kprobe_opcode_t *correct_ret_addr =NULL ;INIT_HLIST_HEAD (&empty_rp);kretprobe_hash_lock (current, &head, &flags);
@@ -455,14 +456,34 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)/* another task is sharing our hash bucket */ continue ; + orig_ret_address = (unsigned long )ri->ret_addr; + +if (orig_ret_address != trampoline_address) +/* +* This is the real return address. Any other +* instances associated with this task are for +* other calls deeper on the call stack +*/ +break ; + } + +kretprobe_assert (ri, orig_ret_address, trampoline_address); + + correct_ret_addr = ri->ret_addr; +hlist_for_each_entry_safe (ri, tmp, head, hlist) { +if (ri->task != current) +/* another task is sharing our hash bucket */ +continue ; + + orig_ret_address = (unsigned long )ri->ret_addr;if (ri->rp && ri->rp->handler) {__this_cpu_write (current_kprobe, &ri->rp->kp);get_kprobe_ctlblk ()->kprobe_status =KPROBE_HIT_ACTIVE ; + ri->ret_addr = correct_ret_addr; ri->rp->handler (ri, regs);__this_cpu_write (current_kprobe,NULL ); } - orig_ret_address = (unsigned long )ri->ret_addr;recycle_rp_inst (ri, &empty_rp);if (orig_ret_address != trampoline_address)
@@ -474,7 +495,6 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)break ; } -kretprobe_assert (ri, orig_ret_address, trampoline_address);kretprobe_hash_unlock (current, &flags);hlist_for_each_entry_safe (ri, tmp, &empty_rp, hlist) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Add a 'noinvpcid' boot option to turn off INVPCID
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d12a72b844a49d4162f24cefdab30bed3f86730e ]
This adds a chicken bit to turn off INVPCID in case something goes wrong. It's an early_param() because we do TLB flushes before we parse __setup() parameters.
--- Documentation/kernel-parameters.txt | 2 ++ arch/x86/kernel/cpu/common.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
Documentation/kernel-parameters.txt +2 -0
@@ -2435,6 +2435,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. nointroute [IA-64] + noinvpcid [X86] Disable the INVPCID cpu feature. + nojitter [IA-64] Disables jitter checking for ITC timers. no-kvmclock [X86,KVM] Disable paravirtualized KVM clock driver
arch/x86/kernel/cpu/common.c +16 -0
@@ -172,6 +172,22 @@ static int __init x86_xsaves_setup(char *s) }__setup ("noxsaves" , x86_xsaves_setup); +static int __init x86_noinvpcid_setup (char *s) +{ +/* noinvpcid doesn't accept parameters */ +if (s) +return -EINVAL ; + +/* do not emit a message if the feature is not present */ +if (!boot_cpu_has (X86_FEATURE_INVPCID )) +return 0 ; + +setup_clear_cpu_cap (X86_FEATURE_INVPCID ); +pr_info ("noinvpcid: INVPCID feature disabled\n" ); +return 0 ; +} +early_param ("noinvpcid" , x86_noinvpcid_setup); +#ifdef CONFIG_X86_32 static int cachesize_override =-1 ;static int disable_x86_serial_nr =1 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: If INVPCID is available, use it to flush global mappings
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d8bced79af1db6734f66b42064cc773cada2ce99 ]
On my Skylake laptop, INVPCID function 2 (flush absolutely everything) takes about 376ns, whereas saving flags, twiddling CR4.PGE to flush global mappings, and restoring flags takes about 539ns.
--- arch/x86/include/asm/tlbflush.h | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/include/asm/tlbflush.h +9 -0
@@ -152,6 +152,15 @@ static inline void __native_flush_tlb_global(void) {unsigned long flags; +if (static_cpu_has (X86_FEATURE_INVPCID )) { +/* +* Using INVPCID is considerably faster than a pair of writes +* to CR4 sandwiched inside an IRQ flag save/restore. +*/ +invpcid_flush_all (); +return ; + } +/* * Read-modify-write to CR4 - protect it from preemption and * from interrupts. (Use the raw variant because this code can
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sched/core: Add switch_mm_irqs_off() and use it in the scheduler
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f98db6013c557c216da5038d9c52045be55cd039 ]
By default, this is the same thing as switch_mm().
x86 will override it as an optimization.
--- include/linux/mmu_context.h | 7 +++++++ kernel/sched/core.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-)
include/linux/mmu_context.h +7 -0
@@ -1,9 +1,16 @@#ifndef _LINUX_MMU_CONTEXT_H#define _LINUX_MMU_CONTEXT_H +#include <asm/mmu_context.h> +struct mm_struct ;void use_mm (struct mm_struct *mm);void unuse_mm (struct mm_struct *mm); +/* Architectures that care about IRQ state in switch_mm can override this. */ +#ifndef switch_mm_irqs_off +# define switch_mm_irqs_off switch_mm +#endif +#endif
kernel/sched/core.c +3 -3
@@ -32,7 +32,7 @@#include <linux/init.h> #include <linux/uaccess.h> #include <linux/highmem.h> -#include <asm/mmu_context.h> +#include <linux/mmu_context.h> #include <linux/interrupt.h> #include <linux/capability.h> #include <linux/completion.h>
@@ -2339,7 +2339,7 @@ context_switch(struct rq *rq, struct task_struct *prev,atomic_inc (&oldmm->mm_count);enter_lazy_tlb (oldmm, next); }else -switch_mm (oldmm, mm, next); +switch_mm_irqs_off (oldmm, mm, next);if (!prev->mm) { prev->active_mm =NULL ;
@@ -4979,7 +4979,7 @@ void idle_task_exit(void)BUG_ON (cpu_online (smp_processor_id ()));if (mm != &init_mm) { -switch_mm (mm, &init_mm, current); +switch_mm_irqs_off (mm, &init_mm, current);finish_arch_post_lock_switch (); }mmdrop (mm);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] arm: kprobes: Align stack to 8-bytes in test code
In reply to Sasha LevinFrom: Jon Medhurst <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 974310d047f3c7788a51d10c8d255eebdb1fa857 ]
kprobes test cases need to have a stack that is aligned to an 8-byte boundary because they call other functions (and the ARM ABI mandates that alignment) and because test cases include 64-bit accesses to the stack. Unfortunately, GCC doesn't ensure this alignment for inline assembler and for the code in question seems to always misalign it by pushing just the LR register onto the stack. We therefore need to explicitly perform stack alignment at the start of each test case.
Without this fix, some test cases will generate alignment faults on systems where alignment is enforced. Even if the kernel is configured to handle these faults in software, triggering them is ugly. It also exposes limitations in the fault handling code which doesn't cope with writes to the stack. E.g. when handling this instruction
strd r6, [sp, #-64]!
the fault handling code will write to a stack location below the SP value at the point the fault occurred, which coincides with where the exception handler has pushed the saved register context. This results in corruption of those registers.
--- arch/arm/probes/kprobes/test-core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/arm/probes/kprobes/test-core.c +8 -3
@@ -976,7 +976,10 @@ static void coverage_end(void)void __naked __kprobes_test_case_start (void ) { __asm__ __volatile__ ( -"stmdb sp!, {r4-r11} \n\t" +"mov r2, sp \n\t" +"bic r3, r2, #7 \n\t" +"mov sp, r3 \n\t" +"stmdb sp!, {r2-r11} \n\t" "sub sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t""bic r0, lr, #1 @ r0 = inline data \n\t" "mov r1, sp \n\t"
@@ -996,7 +999,8 @@ void __naked __kprobes_test_case_end_32(void)"movne pc, r0 \n\t" "mov r0, r4 \n\t" "add sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" -"ldmia sp!, {r4-r11} \n\t" +"ldmia sp!, {r2-r11} \n\t" +"mov sp, r2 \n\t" "mov pc, r0 \n\t" ); }
@@ -1012,7 +1016,8 @@ void __naked __kprobes_test_case_end_16(void)"bxne r0 \n\t" "mov r0, r4 \n\t" "add sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" -"ldmia sp!, {r4-r11} \n\t" +"ldmia sp!, {r2-r11} \n\t" +"mov sp, r2 \n\t" "bx r0 \n\t" ); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] mm/mmu_context, sched/core: Fix mmu_context.h assumption
In reply to Sasha LevinFrom: Ingo Molnar <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8efd755ac2fe262d4c8d5c9bbe054bb67dae93da ]
Some architectures (such as Alpha) rely on include/linux/sched.h definitions in their mmu_context.h files.
So include sched.h before mmu_context.h.
--- mm/mmu_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mmu_context.c +1 -1
@@ -4,9 +4,9 @@*/ #include <linux/mm.h> +#include <linux/sched.h> #include <linux/mmu_context.h> #include <linux/export.h> -#include <linux/sched.h> #include <asm/mmu_context.h>
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Build arch/x86/mm/tlb.c even on !SMP
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e1074888c326038340a1ada9129d679e661f2ea6 ]
Currently all of the functions that live in tlb.c are inlined on !SMP builds. One can debate whether this is a good idea (in many respects the code in tlb.c is better than the inlined UP code).
Regardless, I want to add code that needs to be built on UP and SMP kernels and relates to tlb flushing, so arrange for tlb.c to be compiled unconditionally.
--- arch/x86/mm/Makefile | 3 +-- arch/x86/mm/tlb.c | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-)
arch/x86/mm/Makefile +1 -2
@@ -1,5 +1,5 @@ obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ - pat.o pgtable.o physaddr.o gup.o setup_nx.o + pat.o pgtable.o physaddr.o gup.o setup_nx.o tlb.o # Make sure __phys_addr has no stackprotector nostackp := $(call cc-option, -fno-stack-protector)
@@ -9,7 +9,6 @@ CFLAGS_setup_nx.o := $(nostackp) CFLAGS_fault.o := -I$(src)/../include/asm/trace obj-$(CONFIG_X86_PAT) += pat_rbtree.o -obj-$(CONFIG_SMP) += tlb.o obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o
arch/x86/mm/tlb.c +4 -0
@@ -28,6 +28,8 @@* Implement flush IPI by CALL_FUNCTION_VECTOR, Alex Shi */ +#ifdef CONFIG_SMP + struct flush_tlb_info { struct mm_struct *flush_mm; unsigned long flush_start;
@@ -346,3 +348,5 @@ static int __init create_tlb_single_page_flush_ceiling(void) return 0; }late_initcall (create_tlb_single_page_flush_ceiling); + +#endif /* CONFIG_SMP */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ARM: Hide finish_arch_post_lock_switch() from modules
In reply to Sasha LevinFrom: Steven Rostedt <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ef0491ea17f8019821c7e9c8e801184ecf17f85a ]
The introduction of switch_mm_irqs_off() brought back an old bug regarding the use of preempt_enable_no_resched:
As part of:
62b94a08da1b ("sched/preempt: Take away preempt_enable_no_resched() from modules")
the definition of preempt_enable_no_resched() is only available in built-in code, not in loadable modules, so we can't generally use it from header files.
However, the ARM version of finish_arch_post_lock_switch() calls preempt_enable_no_resched() and is defined as a static inline function in asm/mmu_context.h. This in turn means we cannot include asm/mmu_context.h from modules.
With today's tip tree, asm/mmu_context.h gets included from linux/mmu_context.h, which is normally the exact pattern one would expect, but unfortunately, linux/mmu_context.h can be included from the vhost driver that is a loadable module, now causing this compile time error with modular configs:
In file included from ../include/linux/mmu_context.h:4:0,
from ../drivers/vhost/vhost.c:18:
../arch/arm/include/asm/mmu_context.h: In function 'finish_arch_post_lock_switch':
../arch/arm/include/asm/mmu_context.h:88:3: error: implicit declaration of function 'preempt_enable_no_resched' [-Werror=implicit-function-declaration]
preempt_enable_no_resched();Andy already tried to fix the bug by including linux/preempt.h from asm/mmu_context.h, but that didn't help. Arnd suggested reordering the header files, which wasn't popular, so let's use this workaround instead:
The finish_arch_post_lock_switch() definition is now also hidden inside of #ifdef MODULE, so we don't see anything referencing preempt_enable_no_resched() from a header file. I've built a few hundred randconfig kernels with this, and did not see any new problems.
--- arch/arm/include/asm/mmu_context.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/include/asm/mmu_context.h +2 -0
@@ -61,6 +61,7 @@ static inline void check_and_switch_context(struct mm_struct *mm,cpu_switch_mm (mm->pgd, mm); } +#ifndef MODULE #define finish_arch_post_lock_switch \ finish_arch_post_lock_switchstatic inline void finish_arch_post_lock_switch (void )
@@ -82,6 +83,7 @@ static inline void finish_arch_post_lock_switch(void)preempt_enable_no_resched (); } } +#endif /* !MODULE */ #endif /* CONFIG_MMU */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] cpuidle: Validate cpu_dev in cpuidle_add_sysfs()
In reply to Sasha LevinFrom: Vaidyanathan Srinivasan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ad0a45fd9c14feebd000b6e84189d0edff265170 ]
If a given cpu is not in cpu_present and cpu hotplug is disabled, arch can skip setting up the cpu_dev.
Arch cpuidle driver should pass correct cpu mask for registration, but failing to do so by the driver causes error to propagate and crash like this:
[ 30.076045] Unable to handle kernel paging request for data at address 0x00000048
[ 30.076100] Faulting instruction address: 0xc0000000007b2f30
cpu 0x4d: Vector: 300 (Data Access) at [c000003feb18b670]
pc: c0000000007b2f30: kobject_get+0x20/0x70
lr: c0000000007b3c94: kobject_add_internal+0x54/0x3f0
sp: c000003feb18b8f0 msr: 9000000000009033
dar: 48
dsisr: 40000000
current = 0xc000003fd2ed8300
paca = 0xc00000000fbab500 softe: 0 irq_happened: 0x01
pid = 1, comm = swapper/0
Linux version 4.11.0-rc2-svaidy+ (sv@sagarika) (gcc version 6.2.0 20161005 (Ubuntu 6.2.0-5ubuntu12) ) #10 SMP Sun Mar 19 00:08:09 IST 2017 enter ? for help
[c000003feb18b960] c0000000007b3c94 kobject_add_internal+0x54/0x3f0 [c000003feb18b9f0] c0000000007b43a4 kobject_init_and_add+0x64/0xa0 [c000003feb18ba70] c000000000e284f4 cpuidle_add_sysfs+0xb4/0x130 [c000003feb18baf0] c000000000e26038 cpuidle_register_device+0x118/0x1c0 [c000003feb18bb30] c000000000e26c48 cpuidle_register+0x78/0x120 [c000003feb18bbc0] c00000000168fd9c powernv_processor_idle_init+0x110/0x1c4 [c000003feb18bc40] c00000000000cff8 do_one_initcall+0x68/0x1d0 [c000003feb18bd00] c0000000016242f4 kernel_init_freeable+0x280/0x360 [c000003feb18bdc0] c00000000000d864 kernel_init+0x24/0x160 [c000003feb18be30] c00000000000b4e8 ret_from_kernel_thread+0x5c/0x74
Validating cpu_dev fixes the crash and reports correct error message like:
[ 30.163506] Failed to register cpuidle device for cpu136 [ 30.173329] Registration of powernv driver failed.
--- drivers/cpuidle/sysfs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/cpuidle/sysfs.c +12 -0
@@ -613,6 +613,18 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)struct device *cpu_dev =get_cpu_device ((unsigned long )dev->cpu);int error; +/* +* Return if cpu_device is not setup for this CPU. +* +* This could happen if the arch did not set up cpu_device +* since this CPU is not in cpu_present mask and the +* driver did not send a correct CPU mask during registration. +* Without this check we would end up passing bogus +* value for &cpu_dev->kobj in kobject_init_and_add() +*/ +if (!cpu_dev) +return -ENODEV ; + kdev =kzalloc (sizeof (*kdev),GFP_KERNEL );if (!kdev)return -ENOMEM ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: gadget: f_uvc: Sanity check wMaxPacketSize for SuperSpeed
In reply to Sasha LevinFrom: Roger Quadros <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 16bb05d98c904a4f6c5ce7e2d992299f794acbf2 ]
As per USB3.0 Specification "Table 9-20. Standard Endpoint Descriptor", for interrupt and isochronous endpoints, wMaxPacketSize must be set to 1024 if the endpoint defines bMaxBurst to be greater than zero.
--- drivers/usb/gadget/function/f_uvc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/gadget/function/f_uvc.c +8 -0
@@ -611,6 +611,14 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) opts->streaming_maxpacket =clamp (opts->streaming_maxpacket,1U ,3072U ); opts->streaming_maxburst =min (opts->streaming_maxburst,15U ); +/* For SS, wMaxPacketSize has to be 1024 if bMaxBurst is not 0 */ +if (opts->streaming_maxburst && + (opts->streaming_maxpacket %1024 ) !=0 ) { + opts->streaming_maxpacket =roundup (opts->streaming_maxpacket,1024 ); +INFO (cdev,"overriding streaming_maxpacket to %d\n" , + opts->streaming_maxpacket); + } +/* Fill in the FS/HS/SS Video Streaming specific descriptors from the * module parameters. *
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sched/core: Idle_task_exit() shouldn't use switch_mm_irqs_off()
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 252d2a4117bc181b287eeddf848863788da733ae ]
idle_task_exit() can be called with IRQs on x86 on and therefore should use switch_mm(), not switch_mm_irqs_off().
This doesn't seem to cause any problems right now, but it will confuse my upcoming TLB flush changes. Nonetheless, I think it should be backported because it's trivial. There won't be any meaningful performance impact because idle_task_exit() is only used when offlining a CPU.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -4979,7 +4979,7 @@ void idle_task_exit(void)BUG_ON (cpu_online (smp_processor_id ()));if (mm != &init_mm) { -switch_mm_irqs_off (mm, &init_mm, current); +switch_mm (mm, &init_mm, current);finish_arch_post_lock_switch (); }mmdrop (mm);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/irq: Do not substract irq_tlb_count from irq_call_count
In reply to Sasha LevinFrom: Aaron Lu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 82ba4faca1bffad429f15c90c980ffd010366c25 ]
Since commit:
52aec3308db8 ("x86/tlb: replace INVALIDATE_TLB_VECTOR by CALL_FUNCTION_VECTOR")
the TLB remote shootdown is done through call function vector. That commit didn't take care of irq_tlb_count, which a later commit:
fd0f5869724f ("x86: Distinguish TLB shootdown interrupts from other functions call interrupts")
... tried to fix.
The fix assumes every increase of irq_tlb_count has a corresponding increase of irq_call_count. So the irq_call_count is always bigger than irq_tlb_count and we could substract irq_tlb_count from irq_call_count.
Unfortunately this is not true for the smp_call_function_single() case. The IPI is only sent if the target CPU's call_single_queue is empty when adding a csd into it in generic_exec_single. That means if two threads are both adding flush tlb csds to the same CPU's call_single_queue, only one IPI is sent. In other words, the irq_call_count is incremented by 1 but irq_tlb_count is incremented by 2. Over time, irq_tlb_count will be bigger than irq_call_count and the substract will produce a very large irq_call_count value due to overflow.
Considering that:
1) it's not worth to send more IPIs for the sake of accurate counting of
irq_call_count in generic_exec_single();
2) it's not easy to tell if the call function interrupt is for TLB shootdown in __smp_call_function_single_interrupt().
Not to exclude TLB shootdown from call function count seems to be the simplest fix and this patch just does that.
This bug was found by LKP's cyclic performance regression tracking recently with the vm-scalability test suite. I have bisected to commit:
3dec0ba0be6a ("mm/rmap: share the i_mmap_rwsem")
This commit didn't do anything wrong but revealed the irq_call_count problem. IIUC, the commit makes rwc->remap_one in rmap_walk_file concurrent with multiple threads. When remap_one is try_to_unmap_one(), then multiple threads could queue flush TLB to the same CPU but only one IPI will be sent.
Since the commit was added in Linux v3.19, the counting problem only shows up from v3.19 onwards.
--- arch/x86/include/asm/hardirq.h | 4 ---- arch/x86/kernel/irq.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-)
arch/x86/include/asm/hardirq.h +0 -4
@@ -21,10 +21,6 @@ typedef struct {#ifdef CONFIG_SMP unsigned int irq_resched_count;unsigned int irq_call_count; -/* -* irq_tlb_count is double-counted in irq_call_count, so it must be -* subtracted from irq_call_count when displaying irq_call_count -*/ unsigned int irq_tlb_count;#endif #ifdef CONFIG_X86_THERMAL_VECTOR
arch/x86/kernel/irq.c +1 -2
@@ -96,8 +96,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)seq_puts (p," Rescheduling interrupts\n" );seq_printf (p,"%*s: " , prec,"CAL" );for_each_online_cpu (j) -seq_printf (p,"%10u " ,irq_stats (j)->irq_call_count - -irq_stats (j)->irq_tlb_count); +seq_printf (p,"%10u " ,irq_stats (j)->irq_call_count);seq_puts (p," Function call interrupts\n" );seq_printf (p,"%*s: " , prec,"TLB" );for_each_online_cpu (j)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] r8152: fix the list rx_done may be used without initialization
In reply to Sasha LevinFrom: hayeswang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 98d068ab52b4b11d403995ed14154660797e7136 ]
The list rx_done would be initialized when the linking on occurs. Therefore, if a napi is scheduled without any linking on before, the following kernel panic would happen.
BUG: unable to handle kernel NULL pointer dereference at 000000000000008 IP: [<ffffffffc085efde>] r8152_poll+0xe1e/0x1210 [r8152] PGD 0 Oops: 0002 [#1] SMP
--- drivers/net/usb/r8152.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/r8152.c +1 -0
@@ -1263,6 +1263,7 @@ static int alloc_all_mem(struct r8152 *tp)spin_lock_init (&tp->rx_lock);spin_lock_init (&tp->tx_lock);INIT_LIST_HEAD (&tp->tx_free); +INIT_LIST_HEAD (&tp->rx_done);skb_queue_head_init (&tp->tx_queue);skb_queue_head_init (&tp->rx_queue);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: gadget: udc: remove pointer dereference after free
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1f459262b0e1649a1e5ad12fa4c66eb76c2220ce ]
Remove pointer dereference after free.
Addresses-Coverity-ID: 1091173
--- drivers/usb/gadget/udc/pch_udc.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/gadget/udc/pch_udc.c +0 -1
@@ -1534,7 +1534,6 @@ static void pch_udc_free_dma_chain(struct pch_udc_dev *dev, td =phys_to_virt (addr); addr2 = (dma_addr_t )td->next;pci_pool_free (dev->data_requests, td, addr); - td->next =0x00 ; addr = addr2; } req->chain_len =1 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] crypto: deadlock between crypto_alg_sem/rtnl_mutex/genl_mutex
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8a0f5ccfb33b0b8b51de65b7b3bf342ba10b4fb6 ]
Quoted 3 lines · Dmitry Vyukov
Yes, please.
Disregarding some reports is not a good way long term.
Please try this patch.
---8<---
Subject: netlink: Annotate nlk cb_mutex by protocol
Currently all occurences of nlk->cb_mutex are annotated by lockdep as a single class. This causes a false lcokdep cycle involving genl and crypto_user.
This patch fixes it by dividing cb_mutex into individual classes based on the netlink protocol. As genl and crypto_user do not use the same netlink protocol this breaks the false dependency loop.
--- net/netlink/af_netlink.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
net/netlink/af_netlink.c +41 -0
@@ -94,6 +94,44 @@ EXPORT_SYMBOL_GPL(nl_table);static DECLARE_WAIT_QUEUE_HEAD (nl_table_wait); +static struct lock_class_key nlk_cb_mutex_keys[MAX_LINKS ]; + +static const char *const nlk_cb_mutex_key_strings[MAX_LINKS +1 ] = { +"nlk_cb_mutex-ROUTE" , +"nlk_cb_mutex-1" , +"nlk_cb_mutex-USERSOCK" , +"nlk_cb_mutex-FIREWALL" , +"nlk_cb_mutex-SOCK_DIAG" , +"nlk_cb_mutex-NFLOG" , +"nlk_cb_mutex-XFRM" , +"nlk_cb_mutex-SELINUX" , +"nlk_cb_mutex-ISCSI" , +"nlk_cb_mutex-AUDIT" , +"nlk_cb_mutex-FIB_LOOKUP" , +"nlk_cb_mutex-CONNECTOR" , +"nlk_cb_mutex-NETFILTER" , +"nlk_cb_mutex-IP6_FW" , +"nlk_cb_mutex-DNRTMSG" , +"nlk_cb_mutex-KOBJECT_UEVENT" , +"nlk_cb_mutex-GENERIC" , +"nlk_cb_mutex-17" , +"nlk_cb_mutex-SCSITRANSPORT" , +"nlk_cb_mutex-ECRYPTFS" , +"nlk_cb_mutex-RDMA" , +"nlk_cb_mutex-CRYPTO" , +"nlk_cb_mutex-SMC" , +"nlk_cb_mutex-23" , +"nlk_cb_mutex-24" , +"nlk_cb_mutex-25" , +"nlk_cb_mutex-26" , +"nlk_cb_mutex-27" , +"nlk_cb_mutex-28" , +"nlk_cb_mutex-29" , +"nlk_cb_mutex-30" , +"nlk_cb_mutex-31" , +"nlk_cb_mutex-MAX_LINKS" +}; +static int netlink_dump (struct sock *sk);static void netlink_skb_destructor (struct sk_buff *skb);
@@ -1177,6 +1215,9 @@ static int __netlink_create(struct net *net, struct socket *sock, }else { nlk->cb_mutex = &nlk->cb_def_mutex;mutex_init (nlk->cb_mutex); +lockdep_set_class_and_name (nlk->cb_mutex, + nlk_cb_mutex_keys + protocol, + nlk_cb_mutex_key_strings[protocol]); }init_waitqueue_head (&nlk->wait);#ifdef CONFIG_NETLINK_MMAP
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: nfnl_cthelper: fix runtime expectation policy updates
In reply to Sasha LevinFrom: Pablo Neira Ayuso <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2c422257550f123049552b39f7af6e3428a60f43 ]
We only allow runtime updates of expectation policies for timeout and maximum number of expectations, otherwise reject the update.
--- net/netfilter/nfnetlink_cthelper.c | 86 +++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-)
net/netfilter/nfnetlink_cthelper.c +84 -2
@@ -255,6 +255,89 @@ nfnl_cthelper_create(const struct nlattr * const tb[],return ret; } +static int +nfnl_cthelper_update_policy_one (const struct nf_conntrack_expect_policy *policy, +struct nf_conntrack_expect_policy *new_policy, +const struct nlattr *attr) +{ +struct nlattr *tb[NFCTH_POLICY_MAX +1 ]; +int err; + + err =nla_parse_nested (tb,NFCTH_POLICY_MAX , attr, + nfnl_cthelper_expect_pol); +if (err <0 ) +return err; + +if (!tb[NFCTH_POLICY_NAME ] || + !tb[NFCTH_POLICY_EXPECT_MAX ] || + !tb[NFCTH_POLICY_EXPECT_TIMEOUT ]) +return -EINVAL ; + +if (nla_strcmp (tb[NFCTH_POLICY_NAME ], policy->name)) +return -EBUSY ; + + new_policy->max_expected = +ntohl (nla_get_be32 (tb[NFCTH_POLICY_EXPECT_MAX ])); + new_policy->timeout = +ntohl (nla_get_be32 (tb[NFCTH_POLICY_EXPECT_TIMEOUT ])); + +return 0 ; +} + +static int nfnl_cthelper_update_policy_all (struct nlattr *tb[], +struct nf_conntrack_helper *helper) +{ +struct nf_conntrack_expect_policy new_policy[helper->expect_class_max +1 ]; +struct nf_conntrack_expect_policy *policy; +int i, err; + +/* Check first that all policy attributes are well-formed, so we don't +* leave things in inconsistent state on errors. +*/ +for (i =0 ; i < helper->expect_class_max +1 ; i++) { + +if (!tb[NFCTH_POLICY_SET + i]) +return -EINVAL ; + + err =nfnl_cthelper_update_policy_one (&helper->expect_policy[i], + &new_policy[i], + tb[NFCTH_POLICY_SET + i]); +if (err <0 ) +return err; + } +/* Now we can safely update them. */ +for (i =0 ; i < helper->expect_class_max +1 ; i++) { + policy = (struct nf_conntrack_expect_policy *) + &helper->expect_policy[i]; + policy->max_expected = new_policy->max_expected; + policy->timeout = new_policy->timeout; + } + +return 0 ; +} + +static int nfnl_cthelper_update_policy (struct nf_conntrack_helper *helper, +const struct nlattr *attr) +{ +struct nlattr *tb[NFCTH_POLICY_SET_MAX +1 ]; +unsigned int class_max; +int err; + + err =nla_parse_nested (tb,NFCTH_POLICY_SET_MAX , attr, + nfnl_cthelper_expect_policy_set); +if (err <0 ) +return err; + +if (!tb[NFCTH_POLICY_SET_NUM ]) +return -EINVAL ; + + class_max =ntohl (nla_get_be32 (tb[NFCTH_POLICY_SET_NUM ])); +if (helper->expect_class_max +1 != class_max) +return -EBUSY ; + +return nfnl_cthelper_update_policy_all (tb, helper); +} +static int nfnl_cthelper_update (const struct nlattr *const tb[],struct nf_conntrack_helper *helper)
@@ -265,8 +348,7 @@ nfnl_cthelper_update(const struct nlattr * const tb[],return -EBUSY ;if (tb[NFCTH_POLICY ]) { - ret =nfnl_cthelper_parse_expect_policy (helper, - tb[NFCTH_POLICY ]); + ret =nfnl_cthelper_update_policy (helper, tb[NFCTH_POLICY ]);if (ret <0 )return ret; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] hwmon: (asus_atk0110) fix uninitialized data access
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a2125d02443e9a4e68bcfd9f8004fa23239e8329 ]
The latest gcc-7 snapshot adds a warning to point out that when atk_read_value_old or atk_read_value_new fails, we copy uninitialized data into sensor->cached_value:
drivers/hwmon/asus_atk0110.c: In function 'atk_input_show':drivers/hwmon/asus_atk0110.c:651:26: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Adding an error check avoids this. All versions of the driver are affected.
--- drivers/hwmon/asus_atk0110.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwmon/asus_atk0110.c +3 -0
@@ -646,6 +646,9 @@ static int atk_read_value(struct atk_sensor_data *sensor, u64 *value)else err =atk_read_value_new (sensor, value); +if (err) +return err; + sensor->is_valid = true; sensor->last_updated = jiffies; sensor->cached_value = *value;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: qmi_wwan: Add USB IDs for MDM6600 modem on Motorola Droid 4
In reply to Sasha LevinFrom: Tony Lindgren <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4071898bf0f4d79ff353db327af2a15123272548 ]
This gets qmicli working with the MDM6600 modem.
--- drivers/net/usb/qmi_wwan.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/usb/qmi_wwan.c +4 -0
@@ -464,6 +464,10 @@ static const struct usb_device_id products[] = { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69), .driver_info = (unsigned long)&qmi_wwan_info, }, + {/* Motorola Mapphone devices with MDM6600 */ + USB_VENDOR_AND_INTERFACE_INFO(0x22b8, USB_CLASS_VENDOR_SPEC, 0xfb, 0xff), + .driver_info = (unsigned long)&qmi_wwan_info, + },/* 2. Combined interface devices matching on class+protocol */ {/* Huawei E367 and possibly others in "Windows mode" */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] pinctrl: st: add irq_request/release_resources callbacks
In reply to Sasha LevinFrom: Patrice Chotard <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e855fa9a65c40788b5069abb0d094537daa22e05 ]
When using GPIO as IRQ source, the GPIO must be configured in INPUT. Callbacks dedicated for this was missing in pinctrl-st driver.
This fix the following kernel error when trying to lock a gpio as IRQ:
[ 7.521095] gpio gpiochip7: (PIO11): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ [ 7.526018] gpio gpiochip7: (PIO11): unable to lock HW IRQ 6 for IRQ [ 7.529405] genirq: Failed to request resources for 0-0053 (irq 81) on irqchip GPIO
--- drivers/pinctrl/pinctrl-st.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
drivers/pinctrl/pinctrl-st.c +24 -6
@@ -1348,6 +1348,22 @@ static void st_gpio_irq_unmask(struct irq_data *d)writel (BIT (d->hwirq), bank->base +REG_PIO_SET_PMASK ); } +static int st_gpio_irq_request_resources (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); + +st_gpio_direction_input (gc, d->hwirq); + +return gpiochip_lock_as_irq (gc, d->hwirq); +} + +static void st_gpio_irq_release_resources (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); + +gpiochip_unlock_as_irq (gc, d->hwirq); +} +static int st_gpio_irq_set_type (struct irq_data *d,unsigned type) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d);
@@ -1503,12 +1519,14 @@ static struct gpio_chip st_gpio_template = { };static struct irq_chip st_gpio_irqchip = { - .name ="GPIO" , - .irq_disable = st_gpio_irq_mask, - .irq_mask = st_gpio_irq_mask, - .irq_unmask = st_gpio_irq_unmask, - .irq_set_type = st_gpio_irq_set_type, - .flags =IRQCHIP_SKIP_SET_WAKE , + .name ="GPIO" , + .irq_request_resources = st_gpio_irq_request_resources, + .irq_release_resources = st_gpio_irq_release_resources, + .irq_disable = st_gpio_irq_mask, + .irq_mask = st_gpio_irq_mask, + .irq_unmask = st_gpio_irq_unmask, + .irq_set_type = st_gpio_irq_set_type, + .flags =IRQCHIP_SKIP_SET_WAKE , }; static int st_gpiolib_register_bank(struct st_pinctrl *info,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: x86: correct async page present tracepoint
In reply to Sasha LevinFrom: Wanpeng Li <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 24dccf83a121b8a4ad5c2ad383a8184ef6c266ee ]
After async pf setup successfully, there is a broadcast wakeup w/ special token 0xffffffff which tells vCPU that it should wake up all processes waiting for APFs though there is no real process waiting at the moment.
The async page present tracepoint print prematurely and fails to catch the special token setup. This patch fixes it by moving the async page present tracepoint after the special token setup.
Before patch:
qemu-system-x86-8499 [006] ...1 5973.473292: kvm_async_pf_ready: token 0x0 gva 0x0
After patch:
qemu-system-x86-8499 [006] ...1 5973.473292: kvm_async_pf_ready: token 0xffffffff gva 0x0
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -7954,11 +7954,11 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, {struct x86_exception fault; -trace_kvm_async_pf_ready (work->arch.token, work->gva);if (work->wakeup_all) work->arch.token = ~0 ;/* broadcast wakeup */ else kvm_del_async_pf_gfn (vcpu, work->arch.gfn); +trace_kvm_async_pf_ready (work->arch.token, work->gva);if ((vcpu->arch.apf.msr_val &KVM_ASYNC_PF_ENABLED ) && !apf_put_user (vcpu,KVM_PV_REASON_PAGE_READY )) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: nfnl_cthelper: Fix memory leak
In reply to Sasha LevinFrom: Jeffy Chen <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f83bf8da1135ca635aac8f062cad3f001fcf3a26 ]
We have memory leaks of nf_conntrack_helper & expect_policy.
--- net/netfilter/nfnetlink_cthelper.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/netfilter/nfnetlink_cthelper.c +9 -3
@@ -216,7 +216,7 @@ nfnl_cthelper_create(const struct nlattr * const tb[], ret =nfnl_cthelper_parse_expect_policy (helper, tb[NFCTH_POLICY ]);if (ret <0 ) - goto err; + goto err1;strncpy (helper->name,nla_data (tb[NFCTH_NAME ]),NF_CT_HELPER_NAME_LEN ); helper->data_len =ntohl (nla_get_be32 (tb[NFCTH_PRIV_DATA_LEN ]));
@@ -247,10 +247,12 @@ nfnl_cthelper_create(const struct nlattr * const tb[], ret =nf_conntrack_helper_register (helper);if (ret <0 ) - goto err; + goto err2;return 0 ; -err: +err2: +kfree (helper->expect_policy); +err1:kfree (helper);return ret; }
@@ -696,6 +698,8 @@ nfnl_cthelper_del(struct sock *nfnl, struct sk_buff *skb, found = true;nf_conntrack_helper_unregister (cur); +kfree (cur->expect_policy); +kfree (cur); } }/* Make sure we return success if we flush and there is no helpers */
@@ -759,6 +763,8 @@ static void __exit nfnl_cthelper_exit(void)continue ;nf_conntrack_helper_unregister (cur); +kfree (cur->expect_policy); +kfree (cur); } } }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ARM: dts: ti: fix PCI bus dtc warnings
In reply to Sasha LevinFrom: Rob Herring <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7d79f6098d82f8c09914d7799bc96891ad9c3baf ]
dtc recently added PCI bus checks. Fix these warnings.
--- arch/arm/boot/dts/dra7.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/dra7.dtsi +2 -0
@@ -216,6 +216,7 @@ device_type = "pci"; ranges = <0x81000000 0 0 0x03000 0 0x00010000 0x82000000 0 0x20013000 0x13000 0 0xffed000>; + bus-range = <0x00 0xff>; #interrupt-cells = <1>; num-lanes = <1>; ti,hwmods = "pcie1";
@@ -251,6 +252,7 @@ device_type = "pci"; ranges = <0x81000000 0 0 0x03000 0 0x00010000 0x82000000 0 0x30013000 0x13000 0 0xffed000>; + bus-range = <0x00 0xff>; #interrupt-cells = <1>; num-lanes = <1>; ti,hwmods = "pcie2";
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] scsi: lpfc: Fix PT2PT PRLI reject
In reply to Sasha LevinFrom: Dick Kennedy <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a71e3cdcfce4880a4578915e110e3eaed1659765 ]
lpfc cannot establish connection with targets that send PRLI in P2P configurations.
If lpfc rejects a PRLI that is sent from a target the target will not resend and will reject the PRLI send from the initiator.
[mkp: applied by hand]
--- drivers/scsi/lpfc/lpfc_els.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_els.c +2 -1
@@ -6891,7 +6891,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, did, vport->port_state, ndlp->nlp_flag); phba->fc_stat.elsRcvPRLI++; -if (vport->port_state <LPFC_DISC_AUTH ) { +if ((vport->port_state <LPFC_DISC_AUTH ) && + (vport->fc_flag &FC_FABRIC )) { rjt_err =LSRJT_UNABLE_TPC ; rjt_exp =LSEXP_NOTHING_MORE ;break ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] HID: xinmo: fix for out of range for THT 2P arcade controller.
In reply to Sasha LevinFrom: Peter Stein <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9257821c5a1dc57ef3a37f7cbcebaf548395c964 ]
There is a new clone of the XIN MO arcade controller which has same issue with out of range like the original. This fix will solve the issue where 2 directions on the joystick are not recognized by the new THT 2P arcade controller with device ID 0x75e1. In details the new device ID is added the hid-id list and the hid-xinmo source code.
--- drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-xinmo.c | 1 + 3 files changed, 3 insertions(+)
drivers/hid/hid-core.c +1 -0
@@ -2010,6 +2010,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) }, { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
drivers/hid/hid-ids.h +1 -0
@@ -1011,6 +1011,7 @@#define USB_VENDOR_ID_XIN_MO 0x16c0#define USB_DEVICE_ID_XIN_MO_DUAL_ARCADE 0x05e1 +#define USB_DEVICE_ID_THT_2P_ARCADE 0x75e1#define USB_VENDOR_ID_XIROKU 0x1477#define USB_DEVICE_ID_XIROKU_SPX 0x1006
drivers/hid/hid-xinmo.c +1 -0
@@ -46,6 +46,7 @@ static int xinmo_event(struct hid_device *hdev, struct hid_field *field,static const struct hid_device_id xinmo_devices[] = { {HID_USB_DEVICE (USB_VENDOR_ID_XIN_MO ,USB_DEVICE_ID_XIN_MO_DUAL_ARCADE ) }, + {HID_USB_DEVICE (USB_VENDOR_ID_XIN_MO ,USB_DEVICE_ID_THT_2P_ARCADE ) }, { } };
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] s390/qeth: no ETH header for outbound AF_IUCV
In reply to Sasha LevinFrom: Julian Wiedmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit acd9776b5c45ef02d1a210969a6fcc058afb76e3 ]
With AF_IUCV traffic, the skb passed to hard_start_xmit() has a 14 byte slot at skb->data, intended for an ETH header. qeth_l3_fill_af_iucv_hdr() fills this ETH header... and then immediately moves it to the skb's headroom, where it disappears and is never seen again.
But it's still possible for us to return NETDEV_TX_BUSY after the skb has been modified. Since we didn't get a private copy of the skb, the next time the skb is delivered to hard_start_xmit() it no longer has the expected layout (we moved the ETH header to the headroom, so skb->data now starts at the IUCV_TRANS header). So when qeth_l3_fill_af_iucv_hdr() does another round of rebuilding, the resulting qeth header ends up all wrong. On transmission, the buffer is then rejected by the HiperSockets device with SBALF15 = x'04'.
When this error is passed back to af_iucv as TX_NOTIFY_UNREACHABLE, it tears down the offending socket.
As the ETH header for AF_IUCV serves no purpose, just align the code to what we do for IP traffic on L3 HiperSockets: keep the ETH header at skb->data, and pass down data_offset = ETH_HLEN to qeth_fill_buffer(). When mapping the payload into the SBAL elements, the ETH header is then stripped off. This avoids the skb manipulations in qeth_l3_fill_af_iucv_hdr(), and any buffer re-entering hard_start_xmit() after NETDEV_TX_BUSY is now processed properly.
--- drivers/s390/net/qeth_l3_main.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/s390/net/qeth_l3_main.c +4 -11
@@ -2790,17 +2790,13 @@ static void qeth_l3_fill_af_iucv_hdr(struct qeth_card *card,char daddr[16 ];struct af_iucv_trans_hdr *iucv_hdr; -skb_pull (skb,14 ); - card->dev->header_ops->create (skb, card->dev,0 , - card->dev->dev_addr, card->dev->dev_addr, - card->dev->addr_len); -skb_pull (skb,14 ); - iucv_hdr = (struct af_iucv_trans_hdr *)skb->data;memset (hdr,0 ,sizeof (struct qeth_hdr )); hdr->hdr.l3.id =QETH_HEADER_TYPE_LAYER3 ; hdr->hdr.l3.ext_flags =0 ; - hdr->hdr.l3.length = skb->len; + hdr->hdr.l3.length = skb->len -ETH_HLEN ; hdr->hdr.l3.flags =QETH_HDR_IPV6 |QETH_CAST_UNICAST ; + + iucv_hdr = (struct af_iucv_trans_hdr *) (skb->data +ETH_HLEN );memset (daddr,0 ,sizeof (daddr)); daddr[0 ] =0xfe ; daddr[1 ] =0x80 ;
@@ -2983,10 +2979,7 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)if ((card->info.type ==QETH_CARD_TYPE_IQD ) && (!large_send) && (skb_shinfo (skb)->nr_frags ==0 )) { new_skb = skb; -if (new_skb->protocol ==ETH_P_AF_IUCV ) - data_offset =0 ; -else - data_offset =ETH_HLEN ; + data_offset =ETH_HLEN ; hdr =kmem_cache_alloc (qeth_core_header_cache,GFP_ATOMIC );if (!hdr) goto tx_drop;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] bna: avoid writing uninitialized data into hw registers
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a5af83925363eb85d467933e3d6ec5a87001eb7c ]
The latest gcc-7 snapshot warns about bfa_ioc_send_enable/bfa_ioc_send_disable writing undefined values into the hardware registers:
drivers/net/ethernet/brocade/bna/bfa_ioc.c: In function 'bfa_iocpf_sm_disabling_entry':arch/arm/include/asm/io.h:109:22: error: '*((void *)&disable_req+4)' is used uninitialized in this function [-Werror=uninitialized] arch/arm/include/asm/io.h:109:22: error: '*((void *)&disable_req+8)' is used uninitialized in this function [-Werror=uninitialized]
The two functions look like they should do the same thing, but only one of them initializes the time stamp and clscode field. The fact that we only get a warning for one of the two functions seems to be arbitrary, based on the inlining decisions in the compiler.
To address this, I'm making both functions do the same thing:
- set the clscode from the ioc structure in both
- set the time stamp from ktime_get_real_seconds (which also avoids the signed-integer overflow in 2038 and extends the well-defined behavior until 2106).
- zero-fill the reserved field
--- drivers/net/ethernet/brocade/bna/bfa_ioc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/brocade/bna/bfa_ioc.c +7 -3
@@ -1948,13 +1948,13 @@ static void bfa_ioc_send_enable(struct bfa_ioc *ioc) {struct bfi_ioc_ctrl_req enable_req; -struct timeval tv;bfi_h2i_set (enable_req.mh,BFI_MC_IOC ,BFI_IOC_H2I_ENABLE_REQ ,bfa_ioc_portid (ioc)); enable_req.clscode =htons (ioc->clscode); -do_gettimeofday (&tv); - enable_req.tv_sec =ntohl (tv.tv_sec); + enable_req.rsvd =htons (0 ); +/* overflow in 2106 */ + enable_req.tv_sec =ntohl (ktime_get_real_seconds ());bfa_ioc_mbox_send (ioc, &enable_req,sizeof (struct bfi_ioc_ctrl_req )); }
@@ -1965,6 +1965,10 @@ bfa_ioc_send_disable(struct bfa_ioc *ioc)bfi_h2i_set (disable_req.mh,BFI_MC_IOC ,BFI_IOC_H2I_DISABLE_REQ ,bfa_ioc_portid (ioc)); + disable_req.clscode =htons (ioc->clscode); + disable_req.rsvd =htons (0 ); +/* overflow in 2106 */ + disable_req.tv_sec =ntohl (ktime_get_real_seconds ());bfa_ioc_mbox_send (ioc, &disable_req,sizeof (struct bfi_ioc_ctrl_req )); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: Do not allow negative values for busy_read and busy_poll sysctl interfaces
In reply to Sasha LevinFrom: Alexander Duyck <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 95f255211396958c718aef8c45e3923b5211ea7b ]
This change basically codifies what I think was already the limitations on the busy_poll and busy_read sysctl interfaces. We weren't checking the lower bounds and as such could input negative values. The behavior when that was used was dependent on the architecture. In order to prevent any issues with that I am just disabling support for values less than 0 since this way we don't have to worry about any odd behaviors.
By limiting the sysctl values this way it also makes it consistent with how we handle the SO_BUSY_POLL socket option since the value appears to be reported as a signed integer value and negative values are rejected.
--- net/core/sysctl_net_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/sysctl_net_core.c +4 -2
@@ -360,14 +360,16 @@ static struct ctl_table net_core_table[] = { .data = &sysctl_net_busy_poll, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, }, { .procname = "busy_read", .data = &sysctl_net_busy_read, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, },#endif #ifdef CONFIG_NET_SCHED
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] i40e: Do not enable NAPI on q_vectors that have no rings
In reply to Sasha LevinFrom: Alexander Duyck <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 13a8cd191a2b470cfd435b3b57dbd21aa65ff78c ]
When testing the epoll w/ busy poll code I found that I could get into a state where the i40e driver had q_vectors w/ active NAPI that had no rings. This was resulting in a divide by zero error. To correct it I am updating the driver code so that we only support NAPI on q_vectors that have 1 or more rings allocated to them.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +12 -4
@@ -3894,8 +3894,12 @@ static void i40e_napi_enable_all(struct i40e_vsi *vsi)if (!vsi->netdev)return ; -for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) -napi_enable (&vsi->q_vectors[q_idx]->napi); +for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) { +struct i40e_q_vector *q_vector = vsi->q_vectors[q_idx]; + +if (q_vector->rx.ring || q_vector->tx.ring) +napi_enable (&q_vector->napi); + } }/**
@@ -3909,8 +3913,12 @@ static void i40e_napi_disable_all(struct i40e_vsi *vsi)if (!vsi->netdev)return ; -for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) -napi_disable (&vsi->q_vectors[q_idx]->napi); +for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) { +struct i40e_q_vector *q_vector = vsi->q_vectors[q_idx]; + +if (q_vector->rx.ring || q_vector->tx.ring) +napi_disable (&q_vector->napi); + } }/**
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] irda: vlsi_ir: fix check for DMA mapping errors
In reply to Sasha LevinFrom: Alexey Khoroshilov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6ac3b77a6ffff7513ff86b684aa256ea01c0e5b5 ]
vlsi_alloc_ring() checks for DMA mapping errors by comparing returned address with zero, while pci_dma_mapping_error() should be used.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/net/irda/vlsi_ir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/irda/vlsi_ir.c +4 -4
@@ -418,8 +418,9 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descrmemset (rd,0 ,sizeof (*rd)); rd->hw = hwmap + i; rd->buf =kmalloc (len,GFP_KERNEL |GFP_DMA ); -if (rd->buf ==NULL || - !(busaddr =pci_map_single (pdev, rd->buf, len, dir))) { +if (rd->buf) + busaddr =pci_map_single (pdev, rd->buf, len, dir); +if (rd->buf ==NULL ||pci_dma_mapping_error (pdev, busaddr)) {if (rd->buf) {net_err_ratelimited ("%s: failed to create PCI-MAP for %p\n" , __func__, rd->buf);
@@ -430,8 +431,7 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr rd = r->rd + j; busaddr =rd_get_addr (rd);rd_set_addr_status (rd,0 ,0 ); -if (busaddr) -pci_unmap_single (pdev, busaddr, len, dir); +pci_unmap_single (pdev, busaddr, len, dir);kfree (rd->buf); rd->buf =NULL ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: nfnl_cthelper: fix a race when walk the nf_ct_helper_hash table
In reply to Sasha LevinFrom: Liping Zhang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 83d90219a5df8d950855ce73229a97b63605c317 ]
The nf_ct_helper_hash table is protected by nf_ct_helper_mutex, while nfct_helper operation is protected by nfnl_lock(NFNL_SUBSYS_CTHELPER). So it's possible that one CPU is walking the nf_ct_helper_hash for cthelper add/get/del, another cpu is doing nf_conntrack_helpers_unregister at the same time. This is dangrous, and may cause use after free error.
Note, delete operation will flush all cthelpers added via nfnetlink, so using rcu to do protect is not easy.
Now introduce a dummy list to record all the cthelpers added via nfnetlink, then we can walk the dummy list instead of walking the nf_ct_helper_hash. Also, keep nfnl_cthelper_dump_table unchanged, it may be invoked without nfnl_lock(NFNL_SUBSYS_CTHELPER) held.
--- net/netfilter/nfnetlink_cthelper.c | 177 +++++++++++++++++-------------------- 1 file changed, 81 insertions(+), 96 deletions(-)
net/netfilter/nfnetlink_cthelper.c +81 -96
@@ -32,6 +32,13 @@ MODULE_LICENSE("GPL");MODULE_AUTHOR ("Pablo Neira Ayuso <[email protected]>" );MODULE_DESCRIPTION ("nfnl_cthelper: User-space connection tracking helpers" ); +struct nfnl_cthelper { +struct list_head list; +struct nf_conntrack_helper helper; +}; + +static LIST_HEAD (nfnl_cthelper_list); +static int nfnl_userspace_cthelper (struct sk_buff *skb,unsigned int protoff,struct nf_conn *ct,enum ip_conntrack_info ctinfo)
@@ -205,14 +212,16 @@ nfnl_cthelper_create(const struct nlattr * const tb[], struct nf_conntrack_tuple *tuple) {struct nf_conntrack_helper *helper; +struct nfnl_cthelper *nfcth;int ret;if (!tb[NFCTH_TUPLE ] || !tb[NFCTH_POLICY ] || !tb[NFCTH_PRIV_DATA_LEN ])return -EINVAL ; - helper =kzalloc (sizeof (struct nf_conntrack_helper ),GFP_KERNEL ); -if (helper ==NULL ) + nfcth =kzalloc (sizeof (*nfcth),GFP_KERNEL ); +if (nfcth ==NULL )return -ENOMEM ; + helper = &nfcth->helper; ret =nfnl_cthelper_parse_expect_policy (helper, tb[NFCTH_POLICY ]);if (ret <0 )
@@ -249,11 +258,12 @@ nfnl_cthelper_create(const struct nlattr * const tb[],if (ret <0 ) goto err2; +list_add_tail (&nfcth->list, &nfnl_cthelper_list);return 0 ; err2:kfree (helper->expect_policy); err1: -kfree (helper); +kfree (nfcth);return ret; }
@@ -379,7 +389,8 @@ nfnl_cthelper_new(struct sock *nfnl, struct sk_buff *skb,const char *helper_name;struct nf_conntrack_helper *cur, *helper =NULL ;struct nf_conntrack_tuple tuple; -int ret =0 , i; +struct nfnl_cthelper *nlcth; +int ret =0 ;if (!tb[NFCTH_NAME ] || !tb[NFCTH_TUPLE ])return -EINVAL ;
@@ -390,31 +401,22 @@ nfnl_cthelper_new(struct sock *nfnl, struct sk_buff *skb,if (ret <0 )return ret; -rcu_read_lock (); -for (i =0 ; i < nf_ct_helper_hsize && !helper; i++) { -hlist_for_each_entry_rcu (cur, &nf_ct_helper_hash[i], hnode) { +list_for_each_entry (nlcth, &nfnl_cthelper_list, list) { + cur = &nlcth->helper; -/* skip non-userspace conntrack helpers. */ -if (!(cur->flags &NF_CT_HELPER_F_USERSPACE )) -continue ; +if (strncmp (cur->name, helper_name,NF_CT_HELPER_NAME_LEN )) +continue ; -if (strncmp (cur->name, helper_name, -NF_CT_HELPER_NAME_LEN ) !=0 ) -continue ; +if ((tuple.src.l3num != cur->tuple.src.l3num || + tuple.dst.protonum != cur->tuple.dst.protonum)) +continue ; -if ((tuple.src.l3num != cur->tuple.src.l3num || - tuple.dst.protonum != cur->tuple.dst.protonum)) -continue ; +if (nlh->nlmsg_flags &NLM_F_EXCL ) +return -EEXIST ; -if (nlh->nlmsg_flags &NLM_F_EXCL ) { - ret = -EEXIST ; - goto err; - } - helper = cur; -break ; - } + helper = cur; +break ; } -rcu_read_unlock ();if (helper ==NULL ) ret =nfnl_cthelper_create (tb, &tuple);
@@ -422,9 +424,6 @@ nfnl_cthelper_new(struct sock *nfnl, struct sk_buff *skb, ret =nfnl_cthelper_update (tb, helper);return ret; -err: -rcu_read_unlock (); -return ret; } static int
@@ -588,11 +587,12 @@ static int nfnl_cthelper_get(struct sock *nfnl, struct sk_buff *skb, const struct nlmsghdr *nlh, const struct nlattr * const tb[]) { - int ret = -ENOENT, i; + int ret = -ENOENT;struct nf_conntrack_helper *cur;struct sk_buff *skb2;char *helper_name =NULL ;struct nf_conntrack_tuple tuple; +struct nfnl_cthelper *nlcth;bool tuple_set = false;if (nlh->nlmsg_flags &NLM_F_DUMP ) {
@@ -613,45 +613,39 @@ nfnl_cthelper_get(struct sock *nfnl, struct sk_buff *skb, tuple_set = true; } -for (i =0 ; i < nf_ct_helper_hsize; i++) { -hlist_for_each_entry_rcu (cur, &nf_ct_helper_hash[i], hnode) { +list_for_each_entry (nlcth, &nfnl_cthelper_list, list) { + cur = &nlcth->helper; +if (helper_name && +strncmp (cur->name, helper_name,NF_CT_HELPER_NAME_LEN )) +continue ; -/* skip non-userspace conntrack helpers. */ -if (!(cur->flags &NF_CT_HELPER_F_USERSPACE )) -continue ; +if (tuple_set && + (tuple.src.l3num != cur->tuple.src.l3num || + tuple.dst.protonum != cur->tuple.dst.protonum)) +continue ; -if (helper_name &&strncmp (cur->name, helper_name, -NF_CT_HELPER_NAME_LEN ) !=0 ) { -continue ; - } -if (tuple_set && - (tuple.src.l3num != cur->tuple.src.l3num || - tuple.dst.protonum != cur->tuple.dst.protonum)) -continue ; - - skb2 =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); -if (skb2 ==NULL ) { - ret = -ENOMEM ; -break ; - } + skb2 =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (skb2 ==NULL ) { + ret = -ENOMEM ; +break ; + } - ret =nfnl_cthelper_fill_info (skb2,NETLINK_CB (skb).portid, - nlh->nlmsg_seq, -NFNL_MSG_TYPE (nlh->nlmsg_type), -NFNL_MSG_CTHELPER_NEW , cur); -if (ret <=0 ) { -kfree_skb (skb2); -break ; - } + ret =nfnl_cthelper_fill_info (skb2,NETLINK_CB (skb).portid, + nlh->nlmsg_seq, +NFNL_MSG_TYPE (nlh->nlmsg_type), +NFNL_MSG_CTHELPER_NEW , cur); +if (ret <=0 ) { +kfree_skb (skb2); +break ; + } - ret =netlink_unicast (nfnl, skb2,NETLINK_CB (skb).portid, -MSG_DONTWAIT ); -if (ret >0 ) - ret =0 ; + ret =netlink_unicast (nfnl, skb2,NETLINK_CB (skb).portid, +MSG_DONTWAIT ); +if (ret >0 ) + ret =0 ; -/* this avoids a loop in nfnetlink. */ -return ret == -EAGAIN ? -ENOBUFS : ret; - } +/* this avoids a loop in nfnetlink. */ +return ret == -EAGAIN ? -ENOBUFS : ret; }return ret; }
@@ -662,10 +656,10 @@ nfnl_cthelper_del(struct sock *nfnl, struct sk_buff *skb, {char *helper_name =NULL ;struct nf_conntrack_helper *cur; -struct hlist_node *tmp;struct nf_conntrack_tuple tuple;bool tuple_set = false, found = false; -int i, j =0 , ret; +struct nfnl_cthelper *nlcth, *n; +int j =0 , ret;if (tb[NFCTH_NAME ]) helper_name =nla_data (tb[NFCTH_NAME ]);
@@ -678,30 +672,27 @@ nfnl_cthelper_del(struct sock *nfnl, struct sk_buff *skb, tuple_set = true; } -for (i =0 ; i < nf_ct_helper_hsize; i++) { -hlist_for_each_entry_safe (cur, tmp, &nf_ct_helper_hash[i], - hnode) { -/* skip non-userspace conntrack helpers. */ -if (!(cur->flags &NF_CT_HELPER_F_USERSPACE )) -continue ; +list_for_each_entry_safe (nlcth, n, &nfnl_cthelper_list, list) { + cur = &nlcth->helper; + j++; - j++; +if (helper_name && +strncmp (cur->name, helper_name,NF_CT_HELPER_NAME_LEN )) +continue ; -if (helper_name &&strncmp (cur->name, helper_name, -NF_CT_HELPER_NAME_LEN ) !=0 ) { -continue ; - } -if (tuple_set && - (tuple.src.l3num != cur->tuple.src.l3num || - tuple.dst.protonum != cur->tuple.dst.protonum)) -continue ; +if (tuple_set && + (tuple.src.l3num != cur->tuple.src.l3num || + tuple.dst.protonum != cur->tuple.dst.protonum)) +continue ; - found = true; -nf_conntrack_helper_unregister (cur); -kfree (cur->expect_policy); -kfree (cur); - } + found = true; +nf_conntrack_helper_unregister (cur); +kfree (cur->expect_policy); + +list_del (&nlcth->list); +kfree (nlcth); } +/* Make sure we return success if we flush and there is no helpers */ return (found || j ==0 ) ?0 : -ENOENT ; }
@@ -750,22 +741,16 @@ static int __init nfnl_cthelper_init(void) static void __exit nfnl_cthelper_exit(void) {struct nf_conntrack_helper *cur; -struct hlist_node *tmp; -int i; +struct nfnl_cthelper *nlcth, *n;nfnetlink_subsys_unregister (&nfnl_cthelper_subsys); -for (i=0 ; i<nf_ct_helper_hsize; i++) { -hlist_for_each_entry_safe (cur, tmp, &nf_ct_helper_hash[i], - hnode) { -/* skip non-userspace conntrack helpers. */ -if (!(cur->flags &NF_CT_HELPER_F_USERSPACE )) -continue ; +list_for_each_entry_safe (nlcth, n, &nfnl_cthelper_list, list) { + cur = &nlcth->helper; -nf_conntrack_helper_unregister (cur); -kfree (cur->expect_policy); -kfree (cur); - } +nf_conntrack_helper_unregister (cur); +kfree (cur->expect_policy); +kfree (nlcth); } }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: nf_nat_snmp: Fix panic when snmp_trap_helper fails to register
In reply to Sasha LevinFrom: Gao Feng <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 75c689dca98851d65ef5a27e5ce26b625b68751c ]
In the commit 93557f53e1fb ("netfilter: nf_conntrack: nf_conntrack snmp helper"), the snmp_helper is replaced by nf_nat_snmp_hook. So the snmp_helper is never registered. But it still tries to unregister the snmp_helper, it could cause the panic.
Now remove the useless snmp_helper and the unregister call in the error handler.
--- net/ipv4/netfilter/nf_nat_snmp_basic.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
net/ipv4/netfilter/nf_nat_snmp_basic.c +1 -18
@@ -1260,16 +1260,6 @@ static const struct nf_conntrack_expect_policy snmp_exp_policy = { .timeout = 180, }; -static struct nf_conntrack_helper snmp_helper__read_mostly = { - .me =THIS_MODULE , - .help = help, - .expect_policy = &snmp_exp_policy, - .name ="snmp" , - .tuple.src.l3num =AF_INET , - .tuple.src.u.udp.port =cpu_to_be16 (SNMP_PORT ), - .tuple.dst.protonum =IPPROTO_UDP , -}; -static struct nf_conntrack_helper snmp_trap_helper__read_mostly = { .me =THIS_MODULE , .help = help,
@@ -1288,17 +1278,10 @@ static struct nf_conntrack_helper snmp_trap_helper __read_mostly = {static int __init nf_nat_snmp_basic_init (void ) { -int ret =0 ; -BUG_ON (nf_nat_snmp_hook !=NULL );RCU_INIT_POINTER (nf_nat_snmp_hook, help); - ret =nf_conntrack_helper_register (&snmp_trap_helper); -if (ret <0 ) { -nf_conntrack_helper_unregister (&snmp_helper); -return ret; - } -return ret; +return nf_conntrack_helper_register (&snmp_trap_helper); } static void __exit nf_nat_snmp_basic_fini(void)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ARM: dts: am335x-evmsk: adjust mmc2 param to allow suspend
In reply to Sasha LevinFrom: "Reizer, Eyal" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9bcf53f34a2c1cebc45cc12e273dcd5f51fbc099 ]
mmc2 used for wl12xx was missing the keep-power-in suspend parameter. As a result the board couldn't reach suspend state.
--- arch/arm/boot/dts/am335x-evmsk.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/am335x-evmsk.dts +1 -0
@@ -646,6 +646,7 @@ ti,non-removable; bus-width = <4>; cap-power-off-card; + keep-power-in-suspend; pinctrl-names = "default"; pinctrl-0 = <&mmc2_pins>;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] isdn: kcapi: avoid uninitialized data
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit af109a2cf6a9a6271fa420ae2d64d72d86c92b7d ]
gcc-7 points out that the AVMB1_ADDCARD ioctl results in an unintialized value ending up in the cardnr parameter:
drivers/isdn/capi/kcapi.c: In function 'old_capi_manufacturer':drivers/isdn/capi/kcapi.c:1042:24: error: 'cdef.cardnr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
cparams.cardnr = cdef.cardnr;
This has been broken since before the start of the git history, so either the value is not used for anything important, or the ioctl command doesn't get called in practice.
Setting the cardnr to zero avoids the warning and makes sure we have consistent behavior.
--- drivers/isdn/capi/kcapi.c | 1 + 1 file changed, 1 insertion(+)
drivers/isdn/capi/kcapi.c +1 -0
@@ -1032,6 +1032,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) sizeof(avmb1_carddef))))return -EFAULT ; cdef.cardtype =AVM_CARDTYPE_B1 ; + cdef.cardnr =0 ; }else {if ((retval =copy_from_user (&cdef, data,sizeof (avmb1_extcarddef))))
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] xhci: plat: Register shutdown for xhci_plat
In reply to Sasha LevinFrom: Adam Wallis <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b07c12517f2aed0add8ce18146bb426b14099392 ]
Shutdown should be called for xhci_plat devices especially for situations where kexec might be used by stopping DMA transactions.
--- drivers/usb/host/xhci-plat.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/xhci-plat.c +1 -0
@@ -266,6 +266,7 @@ MODULE_DEVICE_TABLE(of, usb_xhci_of_match);static struct platform_driver usb_xhci_driver = { .probe = xhci_plat_probe, .remove = xhci_plat_remove, + .shutdown = usb_hcd_platform_shutdown, .driver = { .name ="xhci-hcd" , .pm =DEV_PM_OPS ,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] crypto: crypto4xx - increase context and scatter ring buffer elements
In reply to Sasha LevinFrom: Christian Lamparter <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 778f81d6cdb7d25360f082ac0384d5103f04eca5 ]
If crypto4xx is used in conjunction with dm-crypt, the available ring buffer elements are not enough to handle the load properly.
On an aes-cbc-essiv:sha256 encrypted swap partition the read performance is abyssal: (tested with hdparm -t)
/dev/mapper/swap_crypt:
Timing buffered disk reads: 14 MB in 3.68 seconds = 3.81 MB/sec
The patch increases both PPC4XX_NUM_SD and PPC4XX_NUM_PD to 256. This improves the performance considerably:
/dev/mapper/swap_crypt:
Timing buffered disk reads: 104 MB in 3.03 seconds = 34.31 MB/sec
Furthermore, PPC4XX_LAST_SD, PPC4XX_LAST_GD and PPC4XX_LAST_PD can be easily calculated from their respective PPC4XX_NUM_* constant.
--- drivers/crypto/amcc/crypto4xx_core.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/crypto/amcc/crypto4xx_core.h +5 -5
@@ -32,12 +32,12 @@#define PPC405EX_CE_RESET 0x00000008#define CRYPTO4XX_CRYPTO_PRIORITY 300 -#define PPC4XX_LAST_PD 63 -#define PPC4XX_NUM_PD 64 -#define PPC4XX_LAST_GD 1023 +#define PPC4XX_NUM_PD 256 +#define PPC4XX_LAST_PD (PPC4XX_NUM_PD - 1)#define PPC4XX_NUM_GD 1024 -#define PPC4XX_LAST_SD 63 -#define PPC4XX_NUM_SD 64 +#define PPC4XX_LAST_GD (PPC4XX_NUM_GD - 1) +#define PPC4XX_NUM_SD 256 +#define PPC4XX_LAST_SD (PPC4XX_NUM_SD - 1)#define PPC4XX_SD_BUFFER_SIZE 2048#define PD_ENTRY_INUSE 1
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: phy: at803x: Change error to EINVAL for invalid MAC
In reply to Sasha LevinFrom: Dan Murphy <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fc7556877d1748ac00958822a0a3bba1d4bd9e0d ]
Change the return error code to EINVAL if the MAC
address is not valid in the set_wol function.
--- drivers/net/phy/at803x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/at803x.c +1 -1
@@ -105,7 +105,7 @@ static int at803x_set_wol(struct phy_device *phydev, mac = (const u8 *) ndev->dev_addr;if (!is_valid_ether_addr (mac)) -return -EFAULT ; +return -EINVAL ;for (i =0 ; i <3 ; i++) { phy_write(phydev, AT803X_MMD_ACCESS_CONTROL,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] PCI: Avoid bus reset if bridge itself is broken
In reply to Sasha LevinFrom: David Daney <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 357027786f3523d26f42391aa4c075b8495e5d28 ]
When checking to see if a PCI bus can safely be reset, we previously checked to see if any of the children had their PCI_DEV_FLAGS_NO_BUS_RESET flag set. Children marked with that flag are known not to behave well after a bus reset.
Some PCIe root port bridges also do not behave well after a bus reset, sometimes causing the devices behind the bridge to become unusable.
Add a check for PCI_DEV_FLAGS_NO_BUS_RESET being set in the bridge device to allow these bridges to be flagged, and prevent their secondary buses from being reset.
--- drivers/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/pci.c +4 -0
@@ -3651,6 +3651,10 @@ static bool pci_bus_resetable(struct pci_bus *bus) {struct pci_dev *dev; + +if (bus->self && (bus->self->dev_flags &PCI_DEV_FLAGS_NO_BUS_RESET )) +return false; +list_for_each_entry (dev, &bus->devices, bus_list) {if (dev->dev_flags &PCI_DEV_FLAGS_NO_BUS_RESET || (dev->subordinate && !pci_bus_resetable (dev->subordinate)))
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ARM: dma-mapping: disallow dma_get_sgtable() for non-kernel managed memory
In reply to Sasha LevinFrom: Russell King <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 916a008b4b8ecc02fbd035cfb133773dba1ff3d7 ]
dma_get_sgtable() tries to create a scatterlist table containing valid struct page pointers for the coherent memory allocation passed in to it.
However, memory can be declared via dma_declare_coherent_memory(), or via other reservation schemes which means that coherent memory is not guaranteed to be backed by struct pages. In such cases, the resulting scatterlist table contains pointers to invalid pages, which causes kernel oops later.
This patch adds detection of such memory, and refuses to create a scatterlist table for such memory.
--- arch/arm/mm/dma-mapping.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +19 -1
@@ -764,13 +764,31 @@ static void arm_coherent_dma_free(struct device *dev, size_t size, void *cpu_add__arm_dma_free (dev, size, cpu_addr, handle, attrs, true); } +/* +* The whole dma_get_sgtable() idea is fundamentally unsafe - it seems +* that the intention is to allow exporting memory allocated via the +* coherent DMA APIs through the dma_buf API, which only accepts a +* scattertable. This presents a couple of problems: +* 1. Not all memory allocated via the coherent DMA APIs is backed by +* a struct page +* 2. Passing coherent DMA memory into the streaming APIs is not allowed +* as we will try to flush the memory through a different alias to that +* actually being used (and the flushes are redundant.) +*/ int arm_dma_get_sgtable (struct device *dev,struct sg_table *sgt,void *cpu_addr,dma_addr_t handle,size_t size,struct dma_attrs *attrs) { -struct page *page =pfn_to_page (dma_to_pfn (dev, handle)); +unsigned long pfn =dma_to_pfn (dev, handle); +struct page *page;int ret; +/* If the PFN is not valid, we do not have a struct page */ +if (!pfn_valid (pfn)) +return -ENXIO ; + + page =pfn_to_page (pfn); + ret =sg_alloc_table (sgt,1 ,GFP_KERNEL );if (unlikely (ret))return ret;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] cpuidle: powernv: Pass correct drv->cpumask for registration
In reply to Sasha LevinFrom: Vaidyanathan Srinivasan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 293d264f13cbde328d5477f49e3103edbc1dc191 ]
drv->cpumask defaults to cpu_possible_mask in __cpuidle_driver_init(). On PowerNV platform cpu_present could be less than cpu_possible in cases where firmware detects the cpu, but it is not available to the OS. When CONFIG_HOTPLUG_CPU=n, such cpus are not hotplugable at runtime and hence we skip creating cpu_device.
This breaks cpuidle on powernv where register_cpu() is not called for cpus in cpu_possible_mask that cannot be hot-added at runtime.
Trying cpuidle_register_device() on cpu without cpu_device will cause crash like this:
cpu 0xf: Vector: 380 (Data SLB Access) at [c000000ff1503490]
pc: c00000000022c8bc: string+0x34/0x60
lr: c00000000022ed78: vsnprintf+0x284/0x42c
sp: c000000ff1503710 msr: 9000000000009033
dar: 6000000060000000
current = 0xc000000ff1480000
paca = 0xc00000000fe82d00 softe: 0 irq_happened: 0x01
pid = 1, comm = swapper/8
Linux version 4.11.0-rc2 (sv@sagarika) (gcc version 4.9.4 (Buildroot 2017.02-00004-gc28573e) ) #15 SMP Fri Mar 17 19:32:02 IST 2017 enter ? for help
[link register ] c00000000022ed78 vsnprintf+0x284/0x42c
[c000000ff1503710] c00000000022ebb8 vsnprintf+0xc4/0x42c (unreliable) [c000000ff1503800] c00000000022ef40 vscnprintf+0x20/0x44 [c000000ff1503830] c0000000000ab61c vprintk_emit+0x94/0x2cc [c000000ff15038a0] c0000000000acc9c vprintk_func+0x60/0x74 [c000000ff15038c0] c000000000619694 printk+0x38/0x4c [c000000ff15038e0] c000000000224950 kobject_get+0x40/0x60 [c000000ff1503950] c00000000022507c kobject_add_internal+0x60/0x2c4 [c000000ff15039e0] c000000000225350 kobject_init_and_add+0x70/0x78 [c000000ff1503a60] c00000000053c288 cpuidle_add_sysfs+0x9c/0xe0 [c000000ff1503ae0] c00000000053aeac cpuidle_register_device+0xd4/0x12c [c000000ff1503b30] c00000000053b108 cpuidle_register+0x98/0xcc [c000000ff1503bc0] c00000000085eaf0 powernv_processor_idle_init+0x140/0x1e0 [c000000ff1503c60] c00000000000cd60 do_one_initcall+0xc0/0x15c [c000000ff1503d20] c000000000833e84 kernel_init_freeable+0x1a0/0x25c [c000000ff1503dc0] c00000000000d478 kernel_init+0x24/0x12c [c000000ff1503e30] c00000000000b564 ret_from_kernel_thread+0x5c/0x78
This patch fixes the bug by passing correct cpumask from powernv-cpuidle driver.
--- drivers/cpuidle/cpuidle-powernv.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/cpuidle/cpuidle-powernv.c +18 -0
@@ -153,6 +153,24 @@ static int powernv_cpuidle_driver_init(void) drv->state_count +=1 ; } +/* +* On the PowerNV platform cpu_present may be less than cpu_possible in +* cases when firmware detects the CPU, but it is not available to the +* OS. If CONFIG_HOTPLUG_CPU=n, then such CPUs are not hotplugable at +* run time and hence cpu_devices are not created for those CPUs by the +* generic topology_init(). +* +* drv->cpumask defaults to cpu_possible_mask in +* __cpuidle_driver_init(). This breaks cpuidle on PowerNV where +* cpu_devices are not created for CPUs in cpu_possible_mask that +* cannot be hot-added later at run time. +* +* Trying cpuidle_register_device() on a CPU without a cpu_device is +* incorrect, so pass a correct CPU mask to the generic cpuidle driver. +*/ + + drv->cpumask = (struct cpumask *)cpu_present_mask; +return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] scsi: cxgb4i: fix Tx skb leak
In reply to Sasha LevinFrom: Varun Prakash <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9b3a081fb62158b50bcc90522ca2423017544367 ]
In case of connection reset Tx skb queue can have some skbs which are not transmitted so purge Tx skb queue in release_offload_resources() to avoid skb leak.
--- drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +1 -0
@@ -1332,6 +1332,7 @@ static void release_offload_resources(struct cxgbi_sock *csk) csk, csk->state, csk->flags, csk->tid);cxgbi_sock_free_cpl_skbs (csk); +cxgbi_sock_purge_write_queue (csk);if (csk->wr_cred != csk->wr_max_cred) {cxgbi_sock_purge_wr_queue (csk);cxgbi_sock_reset_wr_list (csk);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] backlight: pwm_bl: Fix overflow condition
In reply to Sasha LevinFrom: Derek Basehore <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5d0c49acebc9488e37db95f1d4a55644e545ffe7 ]
This fixes an overflow condition that can happen with high max brightness and period values in compute_duty_cycle. This fixes it by using a 64 bit variable for computing the duty cycle.
--- drivers/video/backlight/pwm_bl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/video/backlight/pwm_bl.c +5 -2
@@ -79,14 +79,17 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)static int compute_duty_cycle (struct pwm_bl_data *pb,int brightness) {unsigned int lth = pb->lth_brightness; -int duty_cycle; +u64 duty_cycle;if (pb->levels) duty_cycle = pb->levels[brightness];else duty_cycle = brightness; -return (duty_cycle * (pb->period - lth) / pb->scale) + lth; + duty_cycle *= pb->period - lth; +do_div (duty_cycle, pb->scale); + +return duty_cycle + lth; }static int pwm_backlight_update_status (struct backlight_device *bl)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] PCI: Create SR-IOV virtfn/physfn links before attaching driver
In reply to Sasha LevinFrom: Stuart Hayes <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 27d6162944b9b34c32cd5841acd21786637ee743 ]
When creating virtual functions, create the "virtfn%u" and "physfn" links in sysfs *before* attaching the driver instead of after. When we attach the driver to the new virtual network interface first, there is a race when the driver attaches to the new sends out an "add" udev event, and the network interface naming software (biosdevname or systemd, for example) tries to look at these links.
--- drivers/pci/iov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/iov.c +2 -1
@@ -156,7 +156,6 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)pci_device_add (virtfn, virtfn->bus);mutex_unlock (&iov->dev->sriov->lock); -pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);if (rc)
@@ -167,6 +166,8 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)kobject_uevent (&virtfn->dev.kobj,KOBJ_CHANGE ); +pci_bus_add_device (virtfn); +return 0 ; failed2:
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] igb: check memory allocation failure
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 18eb86362a52f0af933cc0fd5e37027317eb2d1c ]
Check memory allocation failures and return -ENOMEM in such cases, as already done for other memory allocations in this function.
This avoids NULL pointers dereference.
--- drivers/net/ethernet/intel/igb/igb_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/igb/igb_main.c +2 -0
@@ -2998,6 +2998,8 @@ static int igb_sw_init(struct igb_adapter *adapter)/* Setup and initialize a copy of the hw vlan table array */ adapter->shadow_vfta =kcalloc (E1000_VLAN_FILTER_TBL_SIZE ,sizeof (u32),GFP_ATOMIC ); +if (!adapter->shadow_vfta) +return -ENOMEM ;/* This call may decrease the number of queues */ if (igb_init_interrupt_scheme (adapter, true)) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ixgbe: fix use of uninitialized padding
In reply to Sasha LevinFrom: Emil Tantilov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dcfd6b839c998bc9838e2a47f44f37afbdf3099c ]
This patch is resolving Coverity hits where padding in a structure could be used uninitialized.
- Initialize fwd_cmd.pad/2 before ixgbe_calculate_checksum()
- Initialize buffer.pad2/3 before ixgbe_hic_unlocked()
--- drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 4 ++-- drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +2 -2
@@ -3609,10 +3609,10 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, fw_cmd.ver_build = build; fw_cmd.ver_sub = sub; fw_cmd.hdr.checksum =0 ; - fw_cmd.hdr.checksum =ixgbe_calculate_checksum ((u8 *)&fw_cmd, - (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len)); fw_cmd.pad =0 ; fw_cmd.pad2 =0 ; + fw_cmd.hdr.checksum =ixgbe_calculate_checksum ((u8 *)&fw_cmd, + (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));for (i =0 ; i <=FW_CEM_MAX_RETRIES ; i++) { ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c +2 -0
@@ -224,6 +224,8 @@ static s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,/* convert offset from words to bytes */ buffer.address =cpu_to_be32 ((offset + current_word) *2 ); buffer.length =cpu_to_be16 (words_to_read *2 ); + buffer.pad2 =0 ; + buffer.pad3 =0 ; status = ixgbe_host_interface_command(hw, (u32 *)&buffer, sizeof(buffer),
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] PCI/AER: Report non-fatal errors only to the affected endpoint
In reply to Sasha LevinFrom: Gabriele Paoloni <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 86acc790717fb60fb51ea3095084e331d8711c74 ]
Previously, if an non-fatal error was reported by an endpoint, we called report_error_detected() for the endpoint, every sibling on the bus, and their descendents. If any of them did not implement the .error_detected() method, do_recovery() failed, leaving all these devices unrecovered.
For example, the system described in the bugzilla below has two devices:
0000:74:02.0 [19e5:a230] SAS controller, driver has .error_detected() 0000:74:03.0 [19e5:a235] SATA controller, driver lacks .error_detected()
When a device such as 74:02.0 reported a non-fatal error, do_recovery() failed because 74:03.0 lacked an .error_detected() method. But per PCIe r3.1, sec 6.2.2.2.2, such an error does not compromise the Link and does not affect 74:03.0:
Non-fatal errors are uncorrectable errors which cause a particular transaction to be unreliable but the Link is otherwise fully functional. Isolating Non-fatal from Fatal errors provides Requester/Receiver logic in a device or system management software the opportunity to recover from the error without resetting the components on the Link and disturbing other transactions in progress. Devices not associated with the transaction in error are not impacted by the error.
Report non-fatal errors only to the endpoint that reported them. We really want to check for AER_NONFATAL here, but the current code structure doesn't allow that. Looking for pci_channel_io_normal is the best we can do now.
--- drivers/pci/pcie/aer/aerdrv_core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/pci/pcie/aer/aerdrv_core.c +8 -1
@@ -360,7 +360,14 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev,* If the error is reported by an end point, we think this * error is related to the upstream link of the end point. */ -pci_walk_bus (dev->bus, cb, &result_data); +if (state == pci_channel_io_normal) +/* +* the error is non fatal so the bus is ok, just invoke +* the callback for the function that logged the error. +*/ +cb (dev, &result_data); +else +pci_walk_bus (dev->bus, cb, &result_data); }return result_data.result;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] scsi: lpfc: Fix secure firmware updates
In reply to Sasha LevinFrom: Dick Kennedy <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 184fc2b9a8bcbda9c14d0a1e7fbecfc028c7702e ]
Firmware update fails with: status x17 add_status x56 on the final write
If multiple DMA buffers are used for the download, some firmware revs have difficulty with signatures and crcs split across the dma buffer boundaries. Resolve by making all writes be a single 4k page in length.
--- drivers/scsi/lpfc/lpfc_hw4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_hw4.h +1 -1
@@ -2953,7 +2953,7 @@ struct lpfc_mbx_get_port_name {#define MB_CEQ_STATUS_QUEUE_FLUSHING 0x4#define MB_CQE_STATUS_DMA_FAILED 0x5 -#define LPFC_MBX_WR_CONFIG_MAX_BDE 8 +#define LPFC_MBX_WR_CONFIG_MAX_BDE 1struct lpfc_mbx_wr_object {struct mbox_header header;union {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] scsi: lpfc: PLOGI failures during NPIV testing
In reply to Sasha LevinFrom: Dick Kennedy <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e8bcf0ae4c0346fdc78ebefe0eefcaa6a6622d38 ]
Local Reject/Invalid RPI errors seen during discovery.
Temporary RPI cleanup was occurring regardless of SLI rev. It's only necessary on SLI-4.
Adjust the test for whether cleanup is necessary.
--- drivers/scsi/lpfc/lpfc_hbadisc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_hbadisc.c +2 -1
@@ -4767,7 +4767,8 @@ lpfc_nlp_remove(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)lpfc_cancel_retry_delay_tmo (vport, ndlp);if ((ndlp->nlp_flag &NLP_DEFER_RM ) && !(ndlp->nlp_flag &NLP_REG_LOGIN_SEND ) && - !(ndlp->nlp_flag &NLP_RPI_REGISTERED )) { + !(ndlp->nlp_flag &NLP_RPI_REGISTERED ) && + phba->sli_rev !=LPFC_SLI_REV4 ) {/* For this case we need to cleanup the default rpi * allocated by the firmware. */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] fm10k: ensure we process SM mbx when processing VF mbx
In reply to Sasha LevinFrom: Jacob Keller <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 17a91809942ca32c70026d2d5ba3348a2c4fdf8f ]
When we process VF mailboxes, the driver is likely going to also queue up messages to the switch manager. This process merely queues up the FIFO, but doesn't actually begin the transmission process. Because we hold the mailbox lock during this VF processing, the PF<->SM mailbox is not getting processed at this time. Ensure that we actually process the PF<->SM mailbox in between each PF<->VF mailbox.
This should ensure prompt transmission of the messages queued up after each VF message is received and handled.
--- drivers/net/ethernet/intel/fm10k/fm10k_iov.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/fm10k/fm10k_iov.c +3 -0
@@ -126,6 +126,9 @@ s32 fm10k_iov_mbx(struct fm10k_intfc *interface)struct fm10k_mbx_info *mbx = &vf_info->mbx;u16 glort = vf_info->glort; +/* process the SM mailbox first to drain outgoing messages */ + hw->mbx.ops.process (hw, &hw->mbx); +/* verify port mapping is valid, if not reset port */ if (vf_info->vf_flags && !fm10k_glort_valid_pf (hw, glort)) hw->iov.ops.reset_lport (hw, vf_info);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tcp: fix under-evaluated ssthresh in TCP Vegas
In reply to Sasha LevinFrom: Hoang Tran <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cf5d74b85ef40c202c76d90959db4d850f301b95 ]
With the commit 76174004a0f19785 (tcp: do not slow start when cwnd equals ssthresh), the comparison to the reduced cwnd in tcp_vegas_ssthresh() would under-evaluate the ssthresh.
--- net/ipv4/tcp_vegas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_vegas.c +1 -1
@@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(tcp_vegas_cwnd_event);static inline u32 tcp_vegas_ssthresh (struct tcp_sock *tp) { -return min (tp->snd_ssthresh, tp->snd_cwnd-1 ); +return min (tp->snd_ssthresh, tp->snd_cwnd); }static void tcp_vegas_cong_avoid (struct sock *sk,u32 ack,u32 acked)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] rtc: set the alarm to the next expiring timer
In reply to Sasha LevinFrom: Alexandre Belloni <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 74717b28cb32e1ad3c1042cafd76b264c8c0f68d ]
If there is any non expired timer in the queue, the RTC alarm is never set. This is an issue when adding a timer that expires before the next non expired timer.
Ensure the RTC alarm is set in that case.
--- drivers/rtc/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/interface.c +1 -1
@@ -809,7 +809,7 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) }timerqueue_add (&rtc->timerqueue, &timer->node); -if (!next) { +if (!next ||ktime_before (timer->node.expires, next->expires)) {struct rtc_wkalrm alarm;int err; alarm.time =rtc_ktime_to_tm (timer->node.expires);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] alpha: fix build failures
In reply to Sasha LevinFrom: Sudip Mukherjee <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8ee912dab95f1483156b6e994004bfcc3158d798 ]
The build of alpha allmodconfig is giving error:
arch/alpha/include/asm/mmu_context.h: In function 'ev5_switch_mm':
arch/alpha/include/asm/mmu_context.h:160:2: error:
implicit declaration of function 'task_thread_info'; did you mean 'init_thread_info'? [-Werror=implicit-function-declaration]
The file 'mmu_context.h' needed an extra header file.
--- arch/alpha/include/asm/mmu_context.h | 1 + 1 file changed, 1 insertion(+)
arch/alpha/include/asm/mmu_context.h +1 -0
@@ -7,6 +7,7 @@* Copyright (C) 1996, Linus Torvalds */ +#include <linux/sched.h> #include <asm/machvec.h> #include <asm/compiler.h> #include <asm-generic/mm_hooks.h>
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] crypto: mcryptd - protect the per-CPU queue with a lock
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9abffc6f2efe46c3564c04312e52e07622d40e51 ]
mcryptd_enqueue_request() grabs the per-CPU queue struct and protects access to it with disabled preemption. Then it schedules a worker on the same CPU. The worker in mcryptd_queue_worker() guards access to the same per-CPU variable with disabled preemption.
If we take CPU-hotplug into account then it is possible that between queue_work_on() and the actual invocation of the worker the CPU goes down and the worker will be scheduled on _another_ CPU. And here the preempt_disable() protection does not work anymore. The easiest thing is to add a spin_lock() to guard access to the list.
Another detail: mcryptd_queue_worker() is not processing more than MCRYPTD_BATCH invocation in a row. If there are still items left, then it will invoke queue_work() to proceed with more later. *I* would suggest to simply drop that check because it does not use a system workqueue and the workqueue is already marked as "CPU_INTENSIVE". And if preemption is required then the scheduler should do it. However if queue_work() is used then the work item is marked as CPU unbound. That means it will try to run on the local CPU but it may run on another CPU as well. Especially with CONFIG_DEBUG_WQ_FORCE_RR_CPU=y. Again, the preempt_disable() won't work here but lock which was introduced will help.
In order to keep work-item on the local CPU (and avoid RR) I changed it to queue_work_on().
--- crypto/mcryptd.c | 23 ++++++++++------------- include/crypto/mcryptd.h | 1 + 2 files changed, 11 insertions(+), 13 deletions(-)
crypto/mcryptd.c +10 -13
@@ -80,6 +80,7 @@ static int mcryptd_init_queue(struct mcryptd_queue *queue,pr_debug ("cpu_queue #%d %p\n" , cpu, queue->cpu_queue);crypto_init_queue (&cpu_queue->queue, max_cpu_qlen);INIT_WORK (&cpu_queue->work, mcryptd_queue_worker); +spin_lock_init (&cpu_queue->q_lock); }return 0 ; }
@@ -103,15 +104,16 @@ static int mcryptd_enqueue_request(struct mcryptd_queue *queue,int cpu, err;struct mcryptd_cpu_queue *cpu_queue; - cpu =get_cpu (); - cpu_queue =this_cpu_ptr (queue->cpu_queue); - rctx->tag.cpu = cpu; + cpu_queue =raw_cpu_ptr (queue->cpu_queue); +spin_lock (&cpu_queue->q_lock); + cpu =smp_processor_id (); + rctx->tag.cpu =smp_processor_id (); err =crypto_enqueue_request (&cpu_queue->queue, request);pr_debug ("enqueue request: cpu %d cpu_queue %p request %p\n" , cpu, cpu_queue, request); +spin_unlock (&cpu_queue->q_lock);queue_work_on (cpu, kcrypto_wq, &cpu_queue->work); -put_cpu ();return err; }
@@ -164,16 +166,11 @@ static void mcryptd_queue_worker(struct work_struct *work) cpu_queue = container_of(work, struct mcryptd_cpu_queue, work); i =0 ;while (i <MCRYPTD_BATCH ||single_task_running ()) { -/* -* preempt_disable/enable is used to prevent -* being preempted by mcryptd_enqueue_request() -*/ -local_bh_disable (); -preempt_disable (); + +spin_lock_bh (&cpu_queue->q_lock); backlog =crypto_get_backlog (&cpu_queue->queue); req =crypto_dequeue_request (&cpu_queue->queue); -preempt_enable (); -local_bh_enable (); +spin_unlock_bh (&cpu_queue->q_lock);if (!req) {mcryptd_opportunistic_flush ();
@@ -188,7 +185,7 @@ static void mcryptd_queue_worker(struct work_struct *work) ++i; }if (cpu_queue->queue.qlen) -queue_work (kcrypto_wq, &cpu_queue->work); +queue_work_on (smp_processor_id (), kcrypto_wq, &cpu_queue->work); }void mcryptd_flusher (struct work_struct *__work)
include/crypto/mcryptd.h +1 -0
@@ -26,6 +26,7 @@ static inline struct mcryptd_ahash *__mcryptd_ahash_cast(struct mcryptd_cpu_queue {struct crypto_queue queue; +spinlock_t q_lock;struct work_struct work; };
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ACPI: APEI / ERST: Fix missing error handling in erst_reader()
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bb82e0b4a7e96494f0c1004ce50cec3d7b5fb3d1 ]
The commit f6f828513290 ("pstore: pass allocated memory region back to caller") changed the check of the return value from erst_read() in erst_reader() in the following way:
if (len == -ENOENT)
goto skip;
- else if (len < 0) {
- rc = -1;
+ else if (len < sizeof(*rcd)) {
+ rc = -EIO;
goto out;This introduced another bug: since the comparison with sizeof() is cast to unsigned, a negative len value doesn't hit any longer. As a result, when an error is returned from erst_read(), the code falls through, and it may eventually lead to some weird thing like memory corruption.
This patch adds the negative error value check more explicitly for addressing the issue.
--- drivers/acpi/apei/erst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/erst.c +1 -1
@@ -1023,7 +1023,7 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,/* The record may be cleared by others, try read next record */ if (len == -ENOENT ) goto skip; -else if (len <sizeof (*rcd)) { +else if (len <0 || len <sizeof (*rcd)) { rc = -EIO ; goto out; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] mfd: twl4030-audio: Fix sibling-node lookup
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0a423772de2f3d7b00899987884f62f63ae00dcb ]
A helper purported to look up a child node based on its name was using the wrong of-helper and ended up prematurely freeing the parent of-node while leaking any matching node.
To make things worse, any matching node would not even necessarily be a child node as the whole device tree was searched depth-first starting at the parent.
--- drivers/mfd/twl4030-audio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mfd/twl4030-audio.c +7 -2
@@ -159,13 +159,18 @@ unsigned int twl4030_audio_get_mclk(void)EXPORT_SYMBOL_GPL (twl4030_audio_get_mclk);static bool twl4030_audio_has_codec (struct twl4030_audio_data *pdata, -struct device_node *node) +struct device_node *parent) { +struct device_node *node; +if (pdata && pdata->codec)return true; -if (of_find_node_by_name (node,"codec" )) + node =of_get_child_by_name (parent,"codec" ); +if (node) { +of_node_put (node);return true; + }return false; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] mfd: twl6040: Fix child-node lookup
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 85e9b13cbb130a3209f21bd7933933399c389ffe ]
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.
To make things worse, the parent node was prematurely freed, while the child node was leaked.
Note that the CONFIG_OF compile guard can be removed as of_get_child_by_name() provides a !CONFIG_OF implementation which always fails.
--- drivers/mfd/twl6040.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/mfd/twl6040.c +8 -4
@@ -97,12 +97,16 @@ static struct reg_default twl6040_patch[] = { }; -static bool twl6040_has_vibra (struct device_node *node) +static bool twl6040_has_vibra (struct device_node *parent) { -#ifdef CONFIG_OF -if (of_find_node_by_name (node,"vibra" )) +struct device_node *node; + + node =of_get_child_by_name (parent,"vibra" ); +if (node) { +of_node_put (node);return true; -#endif + } +return false; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: rawmidi: Avoid racy info ioctl via ctl device
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c1cfd9025cc394fd137a01159d74335c5ac978ce ]
The rawmidi also allows to obtaining the information via ioctl of ctl API. It means that user can issue an ioctl to the rawmidi device even when it's being removed as long as the control device is present. Although the code has some protection via the global register_mutex, its range is limited to the search of the corresponding rawmidi object, and the mutex is already unlocked at accessing the rawmidi object. This may lead to a use-after-free.
For avoiding it, this patch widens the application of register_mutex to the whole snd_rawmidi_info_select() function. We have another mutex per rawmidi object, but this operation isn't very hot path, so it shouldn't matter from the performance POV.
--- sound/core/rawmidi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
sound/core/rawmidi.c +12 -3
@@ -579,15 +579,14 @@ static int snd_rawmidi_info_user(struct snd_rawmidi_substream *substream,return 0 ; } -int snd_rawmidi_info_select (struct snd_card *card,struct snd_rawmidi_info *info) +static int __snd_rawmidi_info_select (struct snd_card *card, +struct snd_rawmidi_info *info) {struct snd_rawmidi *rmidi;struct snd_rawmidi_str *pstr;struct snd_rawmidi_substream *substream; -mutex_lock (®ister_mutex); rmidi =snd_rawmidi_search (card, info->device); -mutex_unlock (®ister_mutex);if (!rmidi)return -ENXIO ;if (info->stream <0 || info->stream >1 )
@@ -603,6 +602,16 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info }return -ENXIO ; } + +int snd_rawmidi_info_select (struct snd_card *card,struct snd_rawmidi_info *info) +{ +int ret; + +mutex_lock (®ister_mutex); + ret =__snd_rawmidi_info_select (card, info); +mutex_unlock (®ister_mutex); +return ret; +}EXPORT_SYMBOL (snd_rawmidi_info_select); static int snd_rawmidi_info_select_user(struct snd_card *card,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] PCI / PM: Force devices to D0 in pci_pm_thaw_noirq()
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5839ee7389e893a31e4e3c9cf17b50d14103c902 ]
It is incorrect to call pci_restore_state() for devices in low-power states (D1-D3), as that involves the restoration of MSI setup which requires MMIO to be operational and that is only the case in D0.
However, pci_pm_thaw_noirq() may do that if the driver's "freeze" callbacks put the device into a low-power state, so fix it by making it force devices into D0 via pci_set_power_state() instead of trying to "update" their power state which is pointless.
--- drivers/pci/pci-driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pci/pci-driver.c +6 -1
@@ -936,7 +936,12 @@ static int pci_pm_thaw_noirq(struct device *dev)if (pci_has_legacy_pm_support (pci_dev))return pci_legacy_resume_early (dev); -pci_update_current_state (pci_dev,PCI_D0 ); +/* +* pci_restore_state() requires the device to be in D0 (because of MSI +* restoration among other things), so force it into D0 in case the +* driver's "freeze" callbacks put it into a low-power state directly. +*/ +pci_set_power_state (pci_dev,PCI_D0 );pci_restore_state (pci_dev);if (drv && drv->pm && drv->pm->thaw_noirq)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: usb-audio: Fix the missing ctl name suffix at parsing SU
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5a15f289ee87eaf33f13f08a4909ec99d837ec5f ]
The commit 89b89d121ffc ("ALSA: usb-audio: Add check return value for usb_string()") added the check of the return value from snd_usb_copy_string_desc(), which is correct per se, but it introduced a regression. In the original code, either the "Clock Source", "Playback Source" or "Capture Source" suffix is added after the terminal string, while the commit changed it to add the suffix only when get_term_name() is failing. It ended up with an incorrect ctl name like "PCM" instead of "PCM Capture Source".
Also, even the original code has a similar bug: when the ctl name is generated from snd_usb_copy_string_desc() for the given iSelector, it also doesn't put the suffix.
This patch addresses these issues: the suffix is added always when no static mapping is found. Also the patch tries to put more comments and cleans up the if/else block for better readability in order to avoid the same pitfall again.
--- sound/usb/mixer.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
sound/usb/mixer.c +16 -11
@@ -2095,20 +2095,25 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, kctl->private_value = (unsigned long )namelist; kctl->private_free = usb_mixer_selector_elem_free; - nameid =uac_selector_unit_iSelector (desc); +/* check the static mapping table at first */ len =check_mapped_name (map, kctl->id.name,sizeof (kctl->id.name)); -if (len) - ; -else if (nameid) - len =snd_usb_copy_string_desc (state, nameid, kctl->id.name, -sizeof (kctl->id.name)); -else - len =get_term_name (state, &state->oterm, - kctl->id.name,sizeof (kctl->id.name),0 ); -if (!len) { -strlcpy (kctl->id.name,"USB" ,sizeof (kctl->id.name)); +/* no mapping ? */ +/* if iSelector is given, use it */ + nameid =uac_selector_unit_iSelector (desc); +if (nameid) + len =snd_usb_copy_string_desc (state, nameid, + kctl->id.name, +sizeof (kctl->id.name)); +/* ... or pick up the terminal name at next */ +if (!len) + len =get_term_name (state, &state->oterm, + kctl->id.name,sizeof (kctl->id.name),0 ); +/* ... or use the fixed string "USB" as the last resort */ +if (!len) +strlcpy (kctl->id.name,"USB" ,sizeof (kctl->id.name)); +/* and add the proper suffix */ if (desc->bDescriptorSubtype ==UAC2_CLOCK_SELECTOR )append_ctl_name (kctl," Clock Source" );else if ((state->oterm.type &0xff00 ) ==0x0100 )
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] parisc: Hide Diva-built-in serial aux and graphics card
In reply to Sasha LevinFrom: Helge Deller <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bcf3f1752a622f1372d3252d0fea8855d89812e7 ]
Diva GSP card has built-in serial AUX port and ATI graphic card which simply don't work and which both don't have external connectors. User Guides even mention that those devices shouldn't be used.
So, prevent that Linux drivers try to enable those devices.
--- drivers/parisc/lba_pci.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/parisc/lba_pci.c +33 -0
@@ -1654,3 +1654,36 @@ void lba_set_iregs(struct parisc_device *lba, u32 ibase, u32 imask)iounmap (base_addr); } + +/* +* The design of the Diva management card in rp34x0 machines (rp3410, rp3440) +* seems rushed, so that many built-in components simply don't work. +* The following quirks disable the serial AUX port and the built-in ATI RV100 +* Radeon 7000 graphics card which both don't have any external connectors and +* thus are useless, and even worse, e.g. the AUX port occupies ttyS0 and as +* such makes those machines the only PARISC machines on which we can't use +* ttyS0 as boot console. +*/ +static void quirk_diva_ati_card (struct pci_dev *dev) +{ +if (dev->subsystem_vendor !=PCI_VENDOR_ID_HP || + dev->subsystem_device !=0x1292 ) +return ; + +dev_info (&dev->dev,"Hiding Diva built-in ATI card" ); + dev->device =0 ; +} +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_ATI ,PCI_DEVICE_ID_ATI_RADEON_QY , + quirk_diva_ati_card); + +static void quirk_diva_aux_disable (struct pci_dev *dev) +{ +if (dev->subsystem_vendor !=PCI_VENDOR_ID_HP || + dev->subsystem_device !=0x1291 ) +return ; + +dev_info (&dev->dev,"Hiding Diva built-in AUX serial device" ); + dev->device =0 ; +} +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_HP ,PCI_DEVICE_ID_HP_DIVA_AUX , + quirk_diva_aux_disable);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: X86: Fix load RFLAGS w/o the fixed bit
In reply to Sasha LevinFrom: Wanpeng Li <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d73235d17ba63b53dc0e1051dbc10a1f1be91b71 ]
*** Guest State ***
CR0: actual=0x0000000000000030, shadow=0x0000000060000010, gh_mask=fffffffffffffff7
CR4: actual=0x0000000000002050, shadow=0x0000000000000000, gh_mask=ffffffffffffe871 CR3 = 0x00000000fffbc000
RSP = 0x0000000000000000 RIP = 0x0000000000000000
RFLAGS=0x00000000 DR7 = 0x0000000000000400
^^^^^^^^^^
The failed vmentry is triggered by the following testcase when ept=Y:
#include <unistd.h>
#include <sys/syscall.h>
#include <string.h>
#include <stdint.h>
#include <linux/kvm.h>
#include <fcntl.h>
#include <sys/ioctl.h>
long r[5];
int main()
{
r[2] = open("/dev/kvm", O_RDONLY);
r[3] = ioctl(r[2], KVM_CREATE_VM, 0);
r[4] = ioctl(r[3], KVM_CREATE_VCPU, 7);
struct kvm_regs regs = {
.rflags = 0,
};
ioctl(r[4], KVM_SET_REGS, ®s);
ioctl(r[4], KVM_RUN, 0);
}X86 RFLAGS bit 1 is fixed set, userspace can simply clearing bit 1 of RFLAGS with KVM_SET_REGS ioctl which results in vmentry fails. This patch fixes it by oring X86_EFLAGS_FIXED during ioctl.
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -6737,7 +6737,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)#endif kvm_rip_write (vcpu, regs->rip); -kvm_set_rflags (vcpu, regs->rflags); +kvm_set_rflags (vcpu, regs->rflags |X86_EFLAGS_FIXED ); vcpu->arch.exception.pending = false;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] powerpc/perf: Dereference BHRB entries safely
In reply to Sasha LevinFrom: Ravi Bangoria <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f41d84dddc66b164ac16acf3f584c276146f1c48 ]
It's theoretically possible that branch instructions recorded in BHRB (Branch History Rolling Buffer) entries have already been unmapped before they are processed by the kernel. Hence, trying to dereference such memory location will result in a crash. eg:
Unable to handle kernel paging request for data at address 0xd000000019c41764
Faulting instruction address: 0xc000000000084a14
NIP [c000000000084a14] branch_target+0x4/0x70
LR [c0000000000eb828] record_and_restart+0x568/0x5c0
Call Trace:
[c0000000000eb3b4] record_and_restart+0xf4/0x5c0 (unreliable)
[c0000000000ec378] perf_event_interrupt+0x298/0x460
[c000000000027964] performance_monitor_exception+0x54/0x70
[c000000000009ba4] performance_monitor_common+0x114/0x120Fix it by deferefencing the addresses safely.
--- arch/powerpc/perf/core-book3s.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/perf/core-book3s.c +6 -2
@@ -401,8 +401,12 @@ static __u64 power_pmu_bhrb_to(u64 addr)int ret;__u64 target; -if (is_kernel_addr (addr)) -return branch_target ((unsigned int *)addr); +if (is_kernel_addr (addr)) { +if (probe_kernel_read (&instr, (void *)addr,sizeof (instr))) +return 0 ; + +return branch_target (&instr); + }/* Userspace: need copy instruction here then translate it */ pagefault_disable ();
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: mvneta: clear interface link status on port disable
In reply to Sasha LevinFrom: Yelena Krivosheev <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4423c18e466afdfb02a36ee8b9f901d144b3c607 ]
When port connect to PHY in polling mode (with poll interval 1 sec), port and phy link status must be synchronize in order don't loss link change event.
--- drivers/net/ethernet/marvell/mvneta.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +4 -0
@@ -858,6 +858,10 @@ static void mvneta_port_disable(struct mvneta_port *pp) val &= ~MVNETA_GMAC0_PORT_ENABLE ;mvreg_write (pp,MVNETA_GMAC_CTRL_0 , val); + pp->link =0 ; + pp->duplex =-1 ; + pp->speed =0 ; +udelay (200 ); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tracing: Remove extra zeroing out of the ring buffer page
In reply to Sasha LevinFrom: "Steven Rostedt (VMware)" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6b7e633fe9c24682df550e5311f47fb524701586 ]
The ring_buffer_read_page() takes care of zeroing out any extra data in the page that it returns. There's no need to zero it out again from the consumer. It was removed from one consumer of this function, but read_buffers_splice_read() did not remove it, and worse, it contained a nasty bug because of it.
--- kernel/trace/trace.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
kernel/trace/trace.c +1 -9
@@ -5719,7 +5719,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos, .spd_release = buffer_spd_release, };struct buffer_ref *ref; -int entries, size, i; +int entries, i;ssize_t ret =0 ;#ifdef CONFIG_TRACER_MAX_TRACE
@@ -5770,14 +5770,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,break ; } -/* -* zero out any left over data, this is going to -* user land. -*/ - size =ring_buffer_page_len (ref->page); -if (size <PAGE_SIZE ) -memset (ref->page + size,0 ,PAGE_SIZE - size); - page =virt_to_page (ref->page); spd.pages[i] = page;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tracing: Fix possible double free on failure of allocating trace buffer
In reply to Sasha LevinFrom: "Steven Rostedt (VMware)" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4397f04575c44e1440ec2e49b6302785c95fd2f8 ]
Jing Xia and Chunyan Zhang reported that on failing to allocate part of the tracing buffer, memory is freed, but the pointers that point to them are not initialized back to NULL, and later paths may try to free the freed memory again. Jing and Chunyan fixed one of the locations that does this, but missed a spot.
--- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace.c +1 -0
@@ -6440,6 +6440,7 @@ allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size buf->data = alloc_percpu(struct trace_array_cpu);if (!buf->data) {ring_buffer_free (buf->buffer); + buf->buffer =NULL ;return -ENOMEM ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tracing: Fix crash when it fails to alloc ring buffer
In reply to Sasha LevinFrom: Jing Xia <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 24f2aaf952ee0b59f31c3a18b8b36c9e3d3c2cf5 ]
Double free of the ring buffer happens when it fails to alloc new ring buffer instance for max_buffer if TRACER_MAX_TRACE is configured. The root cause is that the pointer is not set to NULL after the buffer is freed in allocate_trace_buffers(), and the freeing of the ring buffer is invoked again later if the pointer is not equal to Null, as:
instance_mkdir()
|-allocate_trace_buffers()
|-allocate_trace_buffer(tr, &tr->trace_buffer...)
|-allocate_trace_buffer(tr, &tr->max_buffer...)
// allocate fail(-ENOMEM),first free
// and the buffer pointer is not set to null
|-ring_buffer_free(tr->trace_buffer.buffer)
// out_free_tr
|-free_trace_buffers()
|-free_trace_buffer(&tr->trace_buffer);
//if trace_buffer is not null, free again
|-ring_buffer_free(buf->buffer)
|-rb_free_cpu_buffer(buffer->buffers[cpu])
// ring_buffer_per_cpu is null, and
// crash in ring_buffer_per_cpu->pages--- kernel/trace/trace.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/trace/trace.c +2 -0
@@ -6464,7 +6464,9 @@ static int allocate_trace_buffers(struct trace_array *tr, int size) allocate_snapshot ? size : 1);if (WARN_ON (ret)) {ring_buffer_free (tr->trace_buffer.buffer); + tr->trace_buffer.buffer =NULL ;free_percpu (tr->trace_buffer.data); + tr->trace_buffer.data =NULL ;return -ENOMEM ; } tr->allocated_snapshot = allocate_snapshot;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ring-buffer: Mask out the info bits when returning buffer page length
In reply to Sasha LevinFrom: "Steven Rostedt (VMware)" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 45d8b80c2ac5d21cd1e2954431fb676bc2b1e099 ]
Two info bits were added to the "commit" part of the ring buffer data page when returned to be consumed. This was to inform the user space readers that events have been missed, and that the count may be stored at the end of the page.
What wasn't handled, was the splice code that actually called a function to return the length of the data in order to zero out the rest of the page before sending it up to user space. These data bits were returned with the length making the value negative, and that negative value was not checked. It was compared to PAGE_SIZE, and only used if the size was less than PAGE_SIZE. Luckily PAGE_SIZE is unsigned long which made the compare an unsigned compare, meaning the negative size value did not end up causing a large portion of memory to be randomly zeroed out.
--- kernel/trace/ring_buffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/trace/ring_buffer.c +5 -1
@@ -332,6 +332,8 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_data);/* Missed count stored at end */ #define RB_MISSED_STORED (1 << 30) +#define RB_MISSED_FLAGS (RB_MISSED_EVENTS|RB_MISSED_STORED) +struct buffer_data_page {u64 time_stamp;/* page time stamp */ local_t commit;/* write committed index */
@@ -383,7 +385,9 @@ static void rb_init_page(struct buffer_data_page *bpage)*/ size_t ring_buffer_page_len (void *page) { -return local_read (&((struct buffer_data_page *)page)->commit) +struct buffer_data_page *bpage = page; + +return (local_read (&bpage->commit) & ~RB_MISSED_FLAGS ) +BUF_PAGE_HDR_SIZE ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] iw_cxgb4: Only validate the MSN for successful completions
In reply to Sasha LevinFrom: Steve Wise <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f55688c45442bc863f40ad678c638785b26cdce6 ]
If the RECV CQE is in error, ignore the MSN check. This was causing recvs that were flushed into the sw cq to be completed with the wrong status (BAD_MSN instead of FLUSHED).
--- drivers/infiniband/hw/cxgb4/cq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/cxgb4/cq.c +3 -3
@@ -581,10 +581,10 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe, ret = -EAGAIN ; goto skip_cqe; } -if (unlikely ((CQE_WRID_MSN (hw_cqe) != (wq->rq.msn)))) { +if (unlikely (!CQE_STATUS (hw_cqe) && +CQE_WRID_MSN (hw_cqe) != wq->rq.msn)) {t4_set_wq_in_error (wq); - hw_cqe->header |=htonl (CQE_STATUS_V (T4_ERR_MSN )); - goto proc_cqe; + hw_cqe->header |=cpu_to_be32 (CQE_STATUS_V (T4_ERR_MSN )); } goto proc_cqe; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Disable PCID on 32-bit kernels
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cba4671af7550e008f7a7835f06df0763825bf3e ]
32-bit kernels on new hardware will see PCID in CPUID, but PCID can only be used in 64-bit mode. Rather than making all PCID code conditional, just disable the feature on 32-bit builds.
--- arch/x86/include/asm/disabled-features.h | 4 +++- arch/x86/kernel/cpu/bugs.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
arch/x86/include/asm/disabled-features.h +3 -1
@@ -21,11 +21,13 @@# define DISABLE_K6_MTRR (1<<(X86_FEATURE_K6_MTRR & 31))# define DISABLE_CYRIX_ARR (1<<(X86_FEATURE_CYRIX_ARR & 31))# define DISABLE_CENTAUR_MCR (1<<(X86_FEATURE_CENTAUR_MCR & 31)) +# define DISABLE_PCID 0#else # define DISABLE_VME 0# define DISABLE_K6_MTRR 0# define DISABLE_CYRIX_ARR 0# define DISABLE_CENTAUR_MCR 0 +# define DISABLE_PCID (1<<(X86_FEATURE_PCID & 31))#endif /* CONFIG_X86_64 */ /*
@@ -35,7 +37,7 @@#define DISABLED_MASK1 0#define DISABLED_MASK2 0#define DISABLED_MASK3 (DISABLE_CYRIX_ARR|DISABLE_CENTAUR_MCR|DISABLE_K6_MTRR) -#define DISABLED_MASK4 0 +#define DISABLED_MASK4 (DISABLE_PCID)#define DISABLED_MASK5 0#define DISABLED_MASK6 0#define DISABLED_MASK7 0
arch/x86/kernel/cpu/bugs.c +8 -0
@@ -65,6 +65,14 @@ static void __init check_fpu(void)void __init check_bugs (void ) { +#ifdef CONFIG_X86_32 +/* +* Regardless of whether PCID is enumerated, the SDM says +* that it can't be enabled in 32-bit mode. +*/ +setup_clear_cpu_cap (X86_FEATURE_PCID ); +#endif +identify_boot_cpu ();#ifndef CONFIG_SMP pr_info ("CPU: " );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ASoC: twl4030: fix child-node lookup
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 15f8c5f2415bfac73f33a14bcd83422bcbfb5298 ]
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.
To make things worse, the parent codec node was also prematurely freed, while the child node was leaked.
--- sound/soc/codecs/twl4030.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/twl4030.c +3 -1
@@ -232,7 +232,7 @@ static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec)struct twl4030_codec_data *pdata =dev_get_platdata (codec->dev);struct device_node *twl4030_codec_node =NULL ; - twl4030_codec_node =of_find_node_by_name (codec->dev->parent->of_node, + twl4030_codec_node =of_get_child_by_name (codec->dev->parent->of_node,"codec" );if (!pdata && twl4030_codec_node) {
@@ -241,9 +241,11 @@ static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec) GFP_KERNEL);if (!pdata) {dev_err (codec->dev,"Can not allocate memory\n" ); +of_node_put (twl4030_codec_node);return NULL ; }twl4030_setup_pdata_of (pdata, twl4030_codec_node); +of_node_put (twl4030_codec_node); }return pdata;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/vm86/32: Switch to flush_tlb_mm_range() in mark_screen_rdonly()
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9ccee2373f0658f234727700e619df097ba57023 ]
mark_screen_rdonly() is the last remaining caller of flush_tlb(). flush_tlb_mm_range() is potentially faster and isn't obsolete.
Compile-tested only because I don't know whether software that uses this mechanism even exists.
--- arch/x86/kernel/vm86_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/vm86_32.c +1 -1
@@ -194,7 +194,7 @@ static void mark_screen_rdonly(struct mm_struct *mm)pte_unmap_unlock (pte, ptl); out:up_write (&mm->mmap_sem); -flush_tlb (); +flush_tlb_mm_range (mm,0xA0000 ,0xA0000 +32 *PAGE_SIZE ,0UL ); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Add the 'nopcid' boot option to turn off PCID
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0790c9aad84901ca1bdc14746175549c8b5da215 ]
The parameter is only present on x86_64 systems to save a few bytes, as PCID is always disabled on x86_32.
--- Documentation/kernel-parameters.txt | 2 ++ arch/x86/kernel/cpu/common.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+)
Documentation/kernel-parameters.txt +2 -0
@@ -2471,6 +2471,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. nopat [X86] Disable PAT (page attribute table extension of pagetables) support. + nopcid [X86-64] Disable the PCID cpu feature. + norandmaps Don't use address space randomization. Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space
arch/x86/kernel/cpu/common.c +18 -0
@@ -172,6 +172,24 @@ static int __init x86_xsaves_setup(char *s) }__setup ("noxsaves" , x86_xsaves_setup); +#ifdef CONFIG_X86_64 +static int __init x86_pcid_setup (char *s) +{ +/* require an exact match without trailing characters */ +if (strlen (s)) +return 0 ; + +/* do not emit a message if the feature is not present */ +if (!boot_cpu_has (X86_FEATURE_PCID )) +return 1 ; + +setup_clear_cpu_cap (X86_FEATURE_PCID ); +pr_info ("nopcid: PCID feature disabled\n" ); +return 1 ; +} +__setup ("nopcid" , x86_pcid_setup); +#endif +static int __init x86_noinvpcid_setup (char *s) {/* noinvpcid doesn't accept parameters */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Enable CR4.PCIDE on supported systems
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 660da7c9228f685b2ebe664f9fd69aaddcc420b5 ]
We can use PCID if the CPU has PCID and PGE and we're not on Xen.
By itself, this has no effect. A followup patch will start using PCID.
--- arch/x86/include/asm/tlbflush.h | 8 ++++++++ arch/x86/kernel/cpu/common.c | 22 ++++++++++++++++++++++ arch/x86/xen/enlighten.c | 6 ++++++ 3 files changed, 36 insertions(+)
arch/x86/include/asm/tlbflush.h +8 -0
@@ -184,6 +184,14 @@ static inline void __flush_tlb_all(void)__flush_tlb_global (); else__flush_tlb (); + +/* +* Note: if we somehow had PCID but not PGE, then this wouldn't work -- +* we'd end up flushing kernel translations for the current ASID but +* we might fail to flush kernel translations for other cached ASIDs. +* +* To avoid this issue, we force PCID off if PGE is off. +*/ }static inline void __flush_tlb_one (unsigned long addr)
arch/x86/kernel/cpu/common.c +22 -0
@@ -339,6 +339,25 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c) } } +static void setup_pcid (struct cpuinfo_x86 *c) +{ +if (cpu_has (c,X86_FEATURE_PCID )) { +if (cpu_has (c,X86_FEATURE_PGE )) { +cr4_set_bits (X86_CR4_PCIDE ); + }else { +/* +* flush_tlb_all(), as currently implemented, won't +* work if PCID is on but PGE is not. Since that +* combination doesn't exist on real hardware, there's +* no reason to try to fully support it, but it's +* polite to avoid corrupting data if we're on +* an improperly configured VM. +*/ +clear_cpu_cap (c,X86_FEATURE_PCID ); + } + } +} +/* * Some CPU features depend on higher CPUID levels, which may not always * be available due to CPUID level capping or broken virtualization
@@ -968,6 +987,9 @@ static void identify_cpu(struct cpuinfo_x86 *c)setup_smep (c);setup_smap (c); +/* Set up PCID */ +setup_pcid (c); +/* * The vendor-specific functions might have changed features. * Now we do "generic changes."
arch/x86/xen/enlighten.c +6 -0
@@ -432,6 +432,12 @@ static void __init xen_init_cpuid_mask(void) ~((1 <<X86_FEATURE_MTRR ) |/* disable MTRR */ (1 <<X86_FEATURE_ACC ));/* thermal monitoring */ +/* +* Xen PV would need some work to support PCID: CR3 handling as well +* as xen_flush_tlb_others() would need updating. +*/ + cpuid_leaf1_ecx_mask &= ~(1 << (X86_FEATURE_PCID %32 ));/* disable PCID */ +if (!xen_initial_domain ()) cpuid_leaf1_edx_mask &= ~((1 <<X86_FEATURE_ACPI ));/* disable ACPI */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ipv4: igmp: guard against silly MTU values
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b5476022bbada3764609368f03329ca287528dc8 ]
IPv4 stack reacts to changes to small MTU, by disabling itself under RTNL.
But there is a window where threads not using RTNL can see a wrong device mtu. This can lead to surprises, in igmp code where it is assumed the mtu is suitable.
Fix this by reading device mtu once and checking IPv4 minimal MTU.
This patch adds missing IPV4_MIN_MTU define, to not abuse ETH_MIN_MTU anymore.
--- include/net/ip.h | 2 ++ net/ipv4/devinet.c | 2 +- net/ipv4/igmp.c | 24 +++++++++++++++--------- net/ipv4/ip_tunnel.c | 4 ++-- 4 files changed, 20 insertions(+), 12 deletions(-)
include/net/ip.h +2 -0
@@ -33,6 +33,8 @@#include <net/flow.h> #include <net/flow_keys.h> +#define IPV4_MIN_MTU 68/* RFC 791 */ +struct sock ;struct inet_skb_parm {
net/ipv4/devinet.c +1 -1
@@ -1359,7 +1359,7 @@ static void inetdev_changename(struct net_device *dev, struct in_device *in_dev)static bool inetdev_valid_mtu (unsigned int mtu) { -return mtu >=68 ; +return mtu >=IPV4_MIN_MTU ; } static void inetdev_send_gratuitous_arp(struct net_device *dev,
net/ipv4/igmp.c +15 -9
@@ -402,16 +402,17 @@ static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel) }static struct sk_buff *add_grhead (struct sk_buff *skb,struct ip_mc_list *pmc, -int type,struct igmpv3_grec **ppgr) +int type,struct igmpv3_grec **ppgr,unsigned int mtu) {struct net_device *dev = pmc->interface->dev;struct igmpv3_report *pih;struct igmpv3_grec *pgr; -if (!skb) - skb =igmpv3_newpack (dev, dev->mtu); -if (!skb) -return NULL ; +if (!skb) { + skb =igmpv3_newpack (dev, mtu); +if (!skb) +return NULL ; + } pgr = (struct igmpv3_grec *)skb_put (skb,sizeof (struct igmpv3_grec )); pgr->grec_type = type; pgr->grec_auxwords =0 ;
@@ -433,10 +434,15 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,struct igmpv3_grec *pgr =NULL ;struct ip_sf_list *psf, *psf_next, *psf_prev, **psf_list;int scount, stotal, first, isquery, truncate; +unsigned int mtu;if (pmc->multiaddr ==IGMP_ALL_HOSTS )return skb; + mtu =READ_ONCE (dev->mtu); +if (mtu <IPV4_MIN_MTU ) +return skb; + isquery = type ==IGMPV3_MODE_IS_INCLUDE || type ==IGMPV3_MODE_IS_EXCLUDE ; truncate = type == IGMPV3_MODE_IS_EXCLUDE ||
@@ -457,7 +463,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, AVAILABLE(skb) < grec_size(pmc, type, gdeleted, sdeleted)) {if (skb)igmpv3_sendpack (skb); - skb =igmpv3_newpack (dev, dev->mtu); + skb =igmpv3_newpack (dev, mtu); } } first =1 ;
@@ -484,12 +490,12 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, pgr->grec_nsrcs =htons (scount);if (skb)igmpv3_sendpack (skb); - skb =igmpv3_newpack (dev, dev->mtu); + skb =igmpv3_newpack (dev, mtu); first =1 ; scount =0 ; }if (first) { - skb =add_grhead (skb, pmc, type, &pgr); + skb =add_grhead (skb, pmc, type, &pgr, mtu); first =0 ; }if (!skb)
@@ -523,7 +529,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,igmpv3_sendpack (skb); skb =NULL ;/* add_grhead will get a new one */ } - skb =add_grhead (skb, pmc, type, &pgr); + skb =add_grhead (skb, pmc, type, &pgr, mtu); } }if (pgr)
net/ipv4/ip_tunnel.c +2 -2
@@ -393,8 +393,8 @@ static int ip_tunnel_bind_dev(struct net_device *dev) dev->needed_headroom = t_hlen + hlen; mtu -= (dev->hard_header_len + t_hlen); -if (mtu <68 ) - mtu =68 ; +if (mtu <IPV4_MIN_MTU ) + mtu =IPV4_MIN_MTU ;return mtu; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Remove flush_tlb() and flush_tlb_current_task()
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 29961b59a51f8c6838a26a45e871a7ed6771809b ]
I was trying to figure out what how flush_tlb_current_task() would possibly work correctly if current->mm != current->active_mm, but I realized I could spare myself the effort: it has no callers except the unused flush_tlb() macro.
--- arch/x86/include/asm/tlbflush.h | 9 --------- arch/x86/mm/tlb.c | 17 ----------------- 2 files changed, 26 deletions(-)
arch/x86/include/asm/tlbflush.h +0 -9
@@ -197,7 +197,6 @@ static inline void __flush_tlb_one(unsigned long addr)/* * TLB flushing: * -* - flush_tlb() flushes the current mm struct TLBs * - flush_tlb_all() flushes all processes TLBs * - flush_tlb_mm(mm) flushes the specified mm context TLB's * - flush_tlb_page(vma, vmaddr) flushes one page
@@ -229,11 +228,6 @@ static inline void flush_tlb_all(void)__flush_tlb_all (); } -static inline void flush_tlb (void ) -{ -__flush_tlb_up (); -} -static inline void local_flush_tlb (void ) {__flush_tlb_up ();
@@ -295,14 +289,11 @@ static inline void flush_tlb_kernel_range(unsigned long start, flush_tlb_mm_range(vma->vm_mm, start, end, vma->vm_flags)extern void flush_tlb_all (void ); -extern void flush_tlb_current_task (void );extern void flush_tlb_page (struct vm_area_struct *,unsigned long );extern void flush_tlb_mm_range (struct mm_struct *mm,unsigned long start,unsigned long end,unsigned long vmflag);extern void flush_tlb_kernel_range (unsigned long start,unsigned long end); -#define flush_tlb () flush_tlb_current_task() -void native_flush_tlb_others (const struct cpumask *cpumask,struct mm_struct *mm,unsigned long start,unsigned long end);
arch/x86/mm/tlb.c +0 -17
@@ -155,23 +155,6 @@ void native_flush_tlb_others(const struct cpumask *cpumask,smp_call_function_many (cpumask, flush_tlb_func, &info,1 ); } -void flush_tlb_current_task (void ) -{ -struct mm_struct *mm = current->mm; - -preempt_disable (); - -count_vm_tlb_event (NR_TLB_LOCAL_FLUSH_ALL ); - -/* This is an implicit full barrier that synchronizes with switch_mm. */ -local_flush_tlb (); - -trace_tlb_flush (TLB_LOCAL_SHOOTDOWN ,TLB_FLUSH_ALL ); -if (cpumask_any_but (mm_cpumask (mm),smp_processor_id ()) < nr_cpu_ids) -flush_tlb_others (mm_cpumask (mm), mm,0UL ,TLB_FLUSH_ALL ); -preempt_enable (); -} -/* * See Documentation/x86/tlb.txt for details. We choose 33 * because it is large enough to cover the vast majority (at
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ipv6: mcast: better catch silly mtu values
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b9b312a7a451e9c098921856e7cfbc201120e1a7 ]
syzkaller reported crashes in IPv6 stack [1]
Xin Long found that lo MTU was set to silly values.
IPv6 stack reacts to changes to small MTU, by disabling itself under RTNL.
But there is a window where threads not using RTNL can see a wrong device mtu. This can lead to surprises, in mld code where it is assumed the mtu is suitable.
Fix this by reading device mtu once and checking IPv6 minimal MTU.
[1]
skbuff: skb_over_panic: text:0000000010b86b8d len:196 put:20 head:000000003b477e60 data:000000000e85441e tail:0xd4 end:0xc0 dev:lo
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:104!
invalid opcode: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.15.0-rc2-mm1+ #39
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
RIP: 0010:skb_panic+0x15c/0x1f0 net/core/skbuff.c:100
RSP: 0018:ffff8801db307508 EFLAGS: 00010286
RAX: 0000000000000082 RBX: ffff8801c517e840 RCX: 0000000000000000
RDX: 0000000000000082 RSI: 1ffff1003b660e61 RDI: ffffed003b660e95
RBP: ffff8801db307570 R08: 1ffff1003b660e23 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff85bd4020
R13: ffffffff84754ed2 R14: 0000000000000014 R15: ffff8801c4e26540
FS: 0000000000000000(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000463610 CR3: 00000001c6698000 CR4: 00000000001406e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<IRQ>
skb_over_panic net/core/skbuff.c:109 [inline]
skb_put+0x181/0x1c0 net/core/skbuff.c:1694
add_grhead.isra.24+0x42/0x3b0 net/ipv6/mcast.c:1695
add_grec+0xa55/0x1060 net/ipv6/mcast.c:1817
mld_send_cr net/ipv6/mcast.c:1903 [inline]
mld_ifc_timer_expire+0x4d2/0x770 net/ipv6/mcast.c:2448
call_timer_fn+0x23b/0x840 kernel/time/timer.c:1320
expire_timers kernel/time/timer.c:1357 [inline]
__run_timers+0x7e1/0xb60 kernel/time/timer.c:1660
run_timer_softirq+0x4c/0xb0 kernel/time/timer.c:1686
__do_softirq+0x29d/0xbb2 kernel/softirq.c:285
invoke_softirq kernel/softirq.c:365 [inline]
irq_exit+0x1d3/0x210 kernel/softirq.c:405
exiting_irq arch/x86/include/asm/apic.h:540 [inline]
smp_apic_timer_interrupt+0x16b/0x700 arch/x86/kernel/apic/apic.c:1052
apic_timer_interrupt+0xa9/0xb0 arch/x86/entry/entry_64.S:920--- net/ipv6/mcast.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
net/ipv6/mcast.c +15 -10
@@ -1668,16 +1668,16 @@ static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel) }static struct sk_buff *add_grhead (struct sk_buff *skb,struct ifmcaddr6 *pmc, -int type,struct mld2_grec **ppgr) +int type,struct mld2_grec **ppgr,unsigned int mtu) { -struct net_device *dev = pmc->idev->dev;struct mld2_report *pmr;struct mld2_grec *pgr; -if (!skb) - skb =mld_newpack (pmc->idev, dev->mtu); -if (!skb) -return NULL ; +if (!skb) { + skb =mld_newpack (pmc->idev, mtu); +if (!skb) +return NULL ; + } pgr = (struct mld2_grec *)skb_put (skb,sizeof (struct mld2_grec )); pgr->grec_type = type; pgr->grec_auxwords =0 ;
@@ -1700,10 +1700,15 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,struct mld2_grec *pgr =NULL ;struct ip6_sf_list *psf, *psf_next, *psf_prev, **psf_list;int scount, stotal, first, isquery, truncate; +unsigned int mtu;if (pmc->mca_flags &MAF_NOREPORT )return skb; + mtu =READ_ONCE (dev->mtu); +if (mtu <IPV6_MIN_MTU ) +return skb; + isquery = type ==MLD2_MODE_IS_INCLUDE || type ==MLD2_MODE_IS_EXCLUDE ; truncate = type == MLD2_MODE_IS_EXCLUDE ||
@@ -1724,7 +1729,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc, AVAILABLE(skb) < grec_size(pmc, type, gdeleted, sdeleted)) {if (skb)mld_sendpack (skb); - skb =mld_newpack (idev, dev->mtu); + skb =mld_newpack (idev, mtu); } } first =1 ;
@@ -1751,12 +1756,12 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc, pgr->grec_nsrcs =htons (scount);if (skb)mld_sendpack (skb); - skb =mld_newpack (idev, dev->mtu); + skb =mld_newpack (idev, mtu); first =1 ; scount =0 ; }if (first) { - skb =add_grhead (skb, pmc, type, &pgr); + skb =add_grhead (skb, pmc, type, &pgr, mtu); first =0 ; }if (!skb)
@@ -1790,7 +1795,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,mld_sendpack (skb); skb =NULL ;/* add_grhead will get a new one */ } - skb =add_grhead (skb, pmc, type, &pgr); + skb =add_grhead (skb, pmc, type, &pgr, mtu); } }if (pgr)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm/64: Fix reboot interaction with CR4.PCIDE
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 924c6b900cfdf376b07bccfd80e62b21914f8a5a ]
Trying to reboot via real mode fails with PCID on: long mode cannot be exited while CR4.PCIDE is set. (No, I have no idea why, but the SDM and actual CPUs are in agreement here.) The result is a GPF and a hang instead of a reboot.
I didn't catch this in testing because neither my computer nor my VM reboots this way. I can trigger it with reboot=bios, though.
--- arch/x86/kernel/reboot.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kernel/reboot.c +4 -0
@@ -93,6 +93,10 @@ void __noreturn machine_real_restart(unsigned int type)load_cr3 (initial_page_table);#else write_cr3 (real_mode_header->trampoline_pgd); + +/* Exiting long mode will fail if CR4.PCIDE is set. */ +if (static_cpu_has (X86_FEATURE_PCID )) +cr4_clear_bits (X86_CR4_PCIDE );#endif /* Jump to the identity-mapped low memory code */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/mm: Make flush_tlb_mm_range() more predictable
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ce27374fabf553153c3f53efcaa9bfab9216bd8c ]
I'm about to rewrite the function almost completely, but first I want to get a functional change out of the way. Currently, if flush_tlb_mm_range() does not flush the local TLB at all, it will never do individual page flushes on remote CPUs. This seems to be an accident, and preserving it will be awkward. Let's change it first so that any regressions in the rewrite will be easier to bisect and so that the rewrite can attempt to change no visible behavior at all.
The fix is simple: we can simply avoid short-circuiting the calculation of base_pages_to_flush.
As a side effect, this also eliminates a potential corner case: if tlb_single_page_flush_ceiling == TLB_FLUSH_ALL, flush_tlb_mm_range() could have ended up flushing the entire address space one page at a time.
--- arch/x86/mm/tlb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/x86/mm/tlb.c +7 -5
@@ -175,6 +175,12 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,unsigned long base_pages_to_flush =TLB_FLUSH_ALL ;preempt_disable (); + +if ((end !=TLB_FLUSH_ALL ) && !(vmflag &VM_HUGETLB )) + base_pages_to_flush = (end - start) >>PAGE_SHIFT ; +if (base_pages_to_flush > tlb_single_page_flush_ceiling) + base_pages_to_flush =TLB_FLUSH_ALL ; +if (current->active_mm != mm) {/* Synchronize with switch_mm. */ smp_mb ();
@@ -191,15 +197,11 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, goto out; } -if ((end !=TLB_FLUSH_ALL ) && !(vmflag &VM_HUGETLB )) - base_pages_to_flush = (end - start) >>PAGE_SHIFT ; -/* * Both branches below are implicit full barriers (MOV to CR or * INVLPG) that synchronize with switch_mm. */ -if (base_pages_to_flush > tlb_single_page_flush_ceiling) { - base_pages_to_flush =TLB_FLUSH_ALL ; +if (base_pages_to_flush ==TLB_FLUSH_ALL ) {count_vm_tlb_event (NR_TLB_LOCAL_FLUSH_ALL );local_flush_tlb (); }else {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: igmp: Use correct source address on IGMPv3 reports
In reply to Sasha LevinFrom: Kevin Cernekee <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a46182b00290839fa3fa159d54fd3237bd8669f0 ]
Closing a multicast socket after the final IPv4 address is deleted from an interface can generate a membership report that uses the source IP from a different interface. The following test script, run from an isolated netns, reproduces the issue:
#!/bin/bash
ip link add dummy0 type dummy
ip link add dummy1 type dummy
ip link set dummy0 up
ip link set dummy1 up
ip addr add 10.1.1.1/24 dev dummy0
ip addr add 192.168.99.99/24 dev dummy1
tcpdump -U -i dummy0 &
socat EXEC:"sleep 2" \
UDP4-DATAGRAM:239.101.1.68:8889,ip-add-membership=239.0.1.68:10.1.1.1 &
sleep 1
ip addr del 10.1.1.1/24 dev dummy0
sleep 5
kill %tcpdumpRFC 3376 specifies that the report must be sent with a valid IP source address from the destination subnet, or from address 0.0.0.0. Add an extra check to make sure this is the case.
--- net/ipv4/igmp.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
net/ipv4/igmp.c +19 -1
@@ -89,6 +89,7 @@#include <linux/rtnetlink.h> #include <linux/times.h> #include <linux/pkt_sched.h> +#include <linux/byteorder/generic.h> #include <net/net_namespace.h> #include <net/arp.h>
@@ -319,6 +320,23 @@ igmp_scount(struct ip_mc_list *pmc, int type, int gdeleted, int sdeleted)return scount; } +/* source address selection per RFC 3376 section 4.2.13 */ +static __be32 igmpv3_get_srcaddr (struct net_device *dev, +const struct flowi4 *fl4) +{ +struct in_device *in_dev =__in_dev_get_rcu (dev); + +if (!in_dev) +return htonl (INADDR_ANY ); + +for_ifa (in_dev) { +if (inet_ifa_match (fl4->saddr, ifa)) +return fl4->saddr; + }endfor_ifa (in_dev); + +return htonl (INADDR_ANY ); +} +static struct sk_buff *igmpv3_newpack (struct net_device *dev,unsigned int mtu) {struct sk_buff *skb;
@@ -366,7 +384,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu) pip->frag_off =htons (IP_DF ); pip->ttl =1 ; pip->daddr = fl4.daddr; - pip->saddr = fl4.saddr; + pip->saddr =igmpv3_get_srcaddr (dev, &fl4); pip->protocol =IPPROTO_IGMP ; pip->tot_len =0 ;/* filled in later */ ip_select_ident (net, skb,NULL );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kbuild: add '-fno-stack-check' to kernel build options
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3ce120b16cc548472f80cf8644f90eda958cf1b6 ]
It appears that hardened gentoo enables "-fstack-check" by default for gcc.
That doesn't work _at_all_ for the kernel, because the kernel stack doesn't act like a user stack at all: it's much smaller, and it doesn't auto-expand on use. So the extra "probe one page below the stack" code generated by -fstack-check just breaks the kernel in horrible ways, causing infinite double faults etc.
[ I have to say, that the particular code gcc generates looks very
stupid even for user space where it works, but that's a separate issue. ]
--- Makefile | 3 +++ 1 file changed, 3 insertions(+)
Makefile +3 -0
@@ -772,6 +772,9 @@ KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) +# Make sure -fstack-check isn't enabled (like gentoo apparently did) +KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,) + # conserve stack if available KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netlink: Add netns check on taps
In reply to Sasha LevinFrom: Kevin Cernekee <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 93c647643b48f0131f02e45da3bd367d80443291 ]
Currently, a nlmon link inside a child namespace can observe systemwide netlink activity. Filter the traffic so that nlmon can only sniff netlink messages from its own netns.
Test case:
vpnns -- bash -c "ip link add nlmon0 type nlmon; \
ip link set nlmon0 up; \
tcpdump -i nlmon0 -q -w /tmp/nlmon.pcap -U" &
sudo ip xfrm state add src 10.1.1.1 dst 10.1.1.2 proto esp \
spi 0x1 mode transport \
auth sha1 0x6162633132330000000000000000000000000000 \
enc aes 0x00000000000000000000000000000000
grep --binary abc123 /tmp/nlmon.pcap--- net/netlink/af_netlink.c | 3 +++ 1 file changed, 3 insertions(+)
net/netlink/af_netlink.c +3 -0
@@ -259,6 +259,9 @@ static int __netlink_deliver_tap_skb(struct sk_buff *skb,struct sock *sk = skb->sk;int ret = -ENOMEM ; +if (!net_eq (dev_net (dev),sock_net (sk))) +return 0 ; +dev_hold (dev);if (netlink_skb_is_mmaped (skb) ||is_vmalloc_addr (skb->head))
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tg3: Fix rx hang on MTU change with 5717/5719
In reply to Sasha LevinFrom: Brian King <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 748a240c589824e9121befb1cba5341c319885bc ]
This fixes a hang issue seen when changing the MTU size from 1500 MTU to 9000 MTU on both 5717 and 5719 chips. In discussion with Broadcom, they've indicated that these chipsets have the same phy as the 57766 chipset, so the same workarounds apply. This has been tested by IBM on both Power 8 and Power 9 systems as well as by Broadcom on x86 hardware and has been confirmed to resolve the hang issue.
--- drivers/net/ethernet/broadcom/tg3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +3 -1
@@ -14228,7 +14228,9 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu)/* Reset PHY, otherwise the read DMA engine will be in a mode that * breaks all requests to 256 bytes. */ -if (tg3_asic_rev (tp) ==ASIC_REV_57766 ) +if (tg3_asic_rev (tp) ==ASIC_REV_57766 || +tg3_asic_rev (tp) ==ASIC_REV_5717 || +tg3_asic_rev (tp) ==ASIC_REV_5719 ) reset_phy = true; err =tg3_restart_hw (tp, reset_phy);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: qmi_wwan: add Sierra EM7565 1199:9091
In reply to Sasha LevinFrom: Sebastian Sjoholm <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit aceef61ee56898cfa7b6960fb60b9326c3860441 ]
Sierra Wireless EM7565 is an Qualcomm MDM9x50 based M.2 modem. The USB id is added to qmi_wwan.c to allow QMI communication with the EM7565.
--- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/qmi_wwan.c +1 -0
@@ -779,6 +779,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x1199, 0x9079, 10)}, /* Sierra Wireless EM74xx */ {QMI_FIXED_INTF(0x1199, 0x907b, 8)}, /* Sierra Wireless EM74xx */ {QMI_FIXED_INTF(0x1199, 0x907b, 10)}, /* Sierra Wireless EM74xx */ + {QMI_FIXED_INTF(0x1199, 0x9091, 8)}, /* Sierra Wireless EM7565 */ {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] tcp md5sig: Use skb's saddr when replying to an incoming segment
In reply to Sasha LevinFrom: Christoph Paasch <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 30791ac41927ebd3e75486f9504b6d2280463bf0 ]
The MD5-key that belongs to a connection is identified by the peer's IP-address. When we are in tcp_v4(6)_reqsk_send_ack(), we are replying to an incoming segment from tcp_check_req() that failed the seq-number checks.
Thus, to find the correct key, we need to use the skb's saddr and not the daddr.
This bug seems to have been there since quite a while, but probably got unnoticed because the consequences are not catastrophic. We will call tcp_v4_reqsk_send_ack only to send a challenge-ACK back to the peer, thus the connection doesn't really fail.
--- net/ipv4/tcp_ipv4.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_ipv4.c +1 -1
@@ -814,7 +814,7 @@ static void tcp_v4_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, tcp_time_stamp, req->ts_recent,0 , -tcp_md5_do_lookup (sk, (union tcp_md5_addr *)&ip_hdr (skb)->daddr, +tcp_md5_do_lookup (sk, (union tcp_md5_addr *)&ip_hdr (skb)->saddr,AF_INET ),inet_rsk (req)->no_srccheck ?IP_REPLY_ARG_NOSRCCHECK :0 , ip_hdr(skb)->tos);
net/ipv6/tcp_ipv6.c +1 -1
@@ -940,7 +940,7 @@ static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt,tcp_rsk (req)->rcv_nxt, req->rcv_wnd, tcp_time_stamp, req->ts_recent, sk->sk_bound_dev_if, -tcp_v6_md5_do_lookup (sk, &ipv6_hdr (skb)->daddr), +tcp_v6_md5_do_lookup (sk, &ipv6_hdr (skb)->saddr), 0, 0); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: mvmdio: disable/unprepare clocks in EPROBE_DEFER case
In reply to Sasha LevinFrom: Tobias Jordan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 589bf32f09852041fbd3b7ce1a9e703f95c230ba ]
add appropriate calls to clk_disable_unprepare() by jumping to out_mdio in case orion_mdio_probe() returns -EPROBE_DEFER.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/net/ethernet/marvell/mvmdio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvmdio.c +2 -1
@@ -241,7 +241,8 @@ static int orion_mdio_probe(struct platform_device *pdev) dev->regs + MVMDIO_ERR_INT_MASK); }else if (dev->err_interrupt == -EPROBE_DEFER ) { -return -EPROBE_DEFER ; + ret = -EPROBE_DEFER ; + goto out_mdio; }mutex_init (&dev->lock);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sctp: Replace use of sockets_allocated with specified macro.
In reply to Sasha LevinFrom: Tonghao Zhang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8cb38a602478e9f806571f6920b0a3298aabf042 ]
The patch(180d8cd942ce) replaces all uses of struct sock fields' memory_pressure, memory_allocated, sockets_allocated, and sysctl_mem to accessor macros. But the sockets_allocated field of sctp sock is not replaced at all. Then replace it now for unifying the code.
--- net/sctp/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sctp/socket.c +2 -2
@@ -4163,7 +4163,7 @@ static int sctp_init_sock(struct sock *sk)SCTP_DBG_OBJCNT_INC (sock);local_bh_disable (); -percpu_counter_inc (&sctp_sockets_allocated); +sk_sockets_allocated_inc (sk);sock_prot_inuse_add (net, sk->sk_prot,1 );/* Nothing can fail after this block, otherwise
@@ -4207,7 +4207,7 @@ static void sctp_destroy_sock(struct sock *sk) }sctp_endpoint_free (sp->ep);local_bh_disable (); -percpu_counter_dec (&sctp_sockets_allocated); +sk_sockets_allocated_dec (sk);sock_prot_inuse_add (sock_net (sk), sk->sk_prot,-1 );local_bh_enable (); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ipv4: Fix use-after-free when flushing FIB tables
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b4681c2829e24943aadd1a7bb3a30d41d0a20050 ]
Since commit 0ddcf43d5d4a ("ipv4: FIB Local/MAIN table collapse") the local table uses the same trie allocated for the main table when custom rules are not in use.
When a net namespace is dismantled, the main table is flushed and freed (via an RCU callback) before the local table. In case the callback is invoked before the local table is iterated, a use-after-free can occur.
Fix this by iterating over the FIB tables in reverse order, so that the main table is always freed after the local table.
v3: Reworded comment according to Alex's suggestion.
v2: Add a comment to make the fix more explicit per Dave's and Alex's feedback.
--- net/ipv4/fib_frontend.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/ipv4/fib_frontend.c +7 -2
@@ -1181,7 +1181,7 @@ static int __net_init ip_fib_net_init(struct net *net)static void ip_fib_net_exit (struct net *net) { -unsigned int i; +int i;rtnl_lock ();#ifdef CONFIG_IP_MULTIPLE_TABLES
@@ -1189,7 +1189,12 @@ static void ip_fib_net_exit(struct net *net)RCU_INIT_POINTER (net->ipv4.fib_main,NULL );RCU_INIT_POINTER (net->ipv4.fib_default,NULL );#endif -for (i =0 ; i <FIB_TABLE_HASHSZ ; i++) { +/* Destroy the tables in reverse order to guarantee that the +* local table, ID 255, is destroyed before the main table, ID +* 254. This is necessary as the local table may contain +* references to data contained in the main table. +*/ +for (i =FIB_TABLE_HASHSZ -1 ; i >=0 ; i--) {struct hlist_head *head = &net->ipv4.fib_table_hash[i];struct hlist_node *tmp;struct fib_table *tb;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sock: free skb in skb_complete_tx_timestamp on error
In reply to Sasha LevinFrom: Willem de Bruijn <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 35b99dffc3f710cafceee6c8c6ac6a98eb2cb4bf ]
skb_complete_tx_timestamp must ingest the skb it is passed. Call kfree_skb if the skb cannot be enqueued.
--- net/core/skbuff.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/core/skbuff.c +5 -1
@@ -3694,7 +3694,7 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,struct sock *sk = skb->sk;if (!skb_may_tx_timestamp (sk, false)) -return ; + goto err;/* Take a reference to prevent skb_orphan() from freeing the socket, * but only if the socket refcount is not zero.
@@ -3703,7 +3703,11 @@ void skb_complete_tx_timestamp(struct sk_buff *skb, *skb_hwtstamps (skb) = *hwtstamps;__skb_complete_tx_timestamp (skb, sk,SCM_TSTAMP_SND );sock_put (sk); +return ; } + +err: +kfree_skb (skb); }EXPORT_SYMBOL_GPL (skb_complete_tx_timestamp);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: fix usbip bind writing random string after command in match_busid
In reply to Sasha LevinFrom: Juan Zea <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 544c4605acc5ae4afe7dd5914147947db182f2fb ]
usbip bind writes commands followed by random string when writing to match_busid attribute in sysfs, caused by using full variable size instead of string length.
--- tools/usb/usbip/src/utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/usb/usbip/src/utils.c +6 -3
@@ -30,6 +30,7 @@ int modify_match_busid(char *busid, int add)char command[SYSFS_BUS_ID_SIZE +4 ];char match_busid_attr_path[SYSFS_PATH_MAX ];int rc; +int cmd_size; snprintf(match_busid_attr_path, sizeof(match_busid_attr_path), "%s/%s/%s/%s/%s/%s", SYSFS_MNT_PATH, SYSFS_BUS_NAME,
@@ -37,12 +38,14 @@ int modify_match_busid(char *busid, int add) attr_name);if (add) -snprintf (command,SYSFS_BUS_ID_SIZE +4 ,"add %s" , busid); + cmd_size =snprintf (command,SYSFS_BUS_ID_SIZE +4 ,"add %s" , + busid);else -snprintf (command,SYSFS_BUS_ID_SIZE +4 ,"del %s" , busid); + cmd_size =snprintf (command,SYSFS_BUS_ID_SIZE +4 ,"del %s" , + busid); rc =write_sysfs_attribute (match_busid_attr_path, command, -sizeof (command)); + cmd_size);if (rc <0 ) {dbg ("failed to write match_busid: %s" ,strerror (errno));return -1 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: stub: stop printing kernel pointer addresses in messages
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 248a22044366f588d46754c54dfe29ffe4f8b4df ]
Remove and/or change debug, info. and error messages to not print kernel pointer addresses.
--- drivers/usb/usbip/stub_main.c | 5 +++-- drivers/usb/usbip/stub_rx.c | 7 ++----- drivers/usb/usbip/stub_tx.c | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-)
drivers/usb/usbip/stub_main.c +3 -2
@@ -252,11 +252,12 @@ void stub_device_cleanup_urbs(struct stub_device *sdev)struct stub_priv *priv;struct urb *urb; -dev_dbg (&sdev->udev->dev,"free sdev %p\n" , sdev); +dev_dbg (&sdev->udev->dev,"Stub device cleaning up urbs\n" );while ((priv =stub_priv_pop (sdev))) { urb = priv->urb; -dev_dbg (&sdev->udev->dev,"free urb %p\n" , urb); +dev_dbg (&sdev->udev->dev,"free urb seqnum %lu\n" , + priv->seqnum);usb_kill_urb (urb);kmem_cache_free (stub_priv_cache, priv);
drivers/usb/usbip/stub_rx.c +2 -5
@@ -230,9 +230,6 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev,if (priv->seqnum != pdu->u.cmd_unlink.seqnum)continue ; -dev_info (&priv->urb->dev->dev,"unlink urb %p\n" , - priv->urb); -/* * This matched urb is not completed yet (i.e., be in * flight in usb hcd hardware/driver). Now we are
@@ -271,8 +268,8 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev, ret =usb_unlink_urb (priv->urb);if (ret != -EINPROGRESS )dev_err (&priv->urb->dev->dev, -"failed to unlink a urb %p, ret %d\n" , - priv->urb, ret); +"failed to unlink a urb # %lu, ret %d\n" , + priv->seqnum, ret);return 0 ; }
drivers/usb/usbip/stub_tx.c +2 -2
@@ -201,8 +201,8 @@ static int stub_send_ret_submit(struct stub_device *sdev)/* 1. setup usbip_header */ setup_ret_submit_pdu (&pdu_header, urb); -usbip_dbg_stub_tx ("setup txdata seqnum: %d urb: %p\n" , - pdu_header.base.seqnum, urb); +usbip_dbg_stub_tx ("setup txdata seqnum: %d\n" , + pdu_header.base.seqnum);usbip_header_correct_endian (&pdu_header,1 ); iov[iovnum].iov_base = &pdu_header;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usbip: vhci: stop printing kernel pointer addresses in messages
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8272d099d05f7ab2776cf56a2ab9f9443be18907 ]
Remove and/or change debug, info. and error messages to not print kernel pointer addresses.
--- drivers/usb/usbip/vhci_hcd.c | 10 ---------- drivers/usb/usbip/vhci_rx.c | 23 +++++++++++------------ drivers/usb/usbip/vhci_tx.c | 3 ++- 3 files changed, 13 insertions(+), 23 deletions(-)
drivers/usb/usbip/vhci_hcd.c +0 -10
@@ -462,9 +462,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,int ret =0 ;struct vhci_device *vdev; -usbip_dbg_vhci_hc ("enter, usb_hcd %p urb %p mem_flags %d\n" , - hcd, urb, mem_flags); -/* patch to usb_sg_init() is in 2.5.60 */ BUG_ON (!urb->transfer_buffer && urb->transfer_buffer_length);
@@ -620,8 +617,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)struct vhci_priv *priv;struct vhci_device *vdev; -pr_info ("dequeue a urb %p\n" , urb); -spin_lock (&the_controller->lock); priv = urb->hcpriv;
@@ -649,7 +644,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)/* tcp connection is closed */ spin_lock (&vdev->priv_lock); -pr_info ("device %p seems to be disconnected\n" , vdev);list_del (&priv->list);kfree (priv); urb->hcpriv =NULL ;
@@ -661,8 +655,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)* vhci_rx will receive RET_UNLINK and give back the URB. * Otherwise, we give back it here. */ -pr_info ("gives back urb %p\n" , urb); -usb_hcd_unlink_urb_from_ep (hcd, urb);spin_unlock (&the_controller->lock);
@@ -691,8 +683,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) unlink->unlink_seqnum = priv->seqnum; -pr_info ("device %p seems to be still connected\n" , vdev); -/* send cmd_unlink and try to cancel the pending URB in the * peer */ list_add_tail (&unlink->list, &vdev->unlink_tx);
drivers/usb/usbip/vhci_rx.c +11 -12
@@ -37,24 +37,23 @@ struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum) urb = priv->urb; status = urb->status; -usbip_dbg_vhci_rx ("find urb %p vurb %p seqnum %u\n" , - urb, priv, seqnum); +usbip_dbg_vhci_rx ("find urb seqnum %u\n" , seqnum);switch (status) {case -ENOENT :/* fall through */ case -ECONNRESET : -dev_info (&urb->dev->dev, -"urb %p was unlinked %ssynchronuously.\n" , urb, - status == -ENOENT ?"" :"a" ); +dev_dbg (&urb->dev->dev, +"urb seq# %u was unlinked %ssynchronuously\n" , + seqnum, status == -ENOENT ?"" :"a" );break ;case -EINPROGRESS :/* no info output */ break ;default : -dev_info (&urb->dev->dev, -"urb %p may be in a error, status %d\n" , urb, - status); +dev_dbg (&urb->dev->dev, +"urb seq# %u may be in a error, status %d\n" , + seqnum, status); }list_del (&priv->list);
@@ -78,8 +77,8 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,spin_unlock (&vdev->priv_lock);if (!urb) { -pr_err ("cannot find a urb of seqnum %u\n" , pdu->base.seqnum); -pr_info ("max seqnum %d\n" , +pr_err ("cannot find a urb of seqnum %u max seqnum %d\n" , + pdu->base.seqnum,atomic_read (&the_controller->seqnum));usbip_event_add (ud,VDEV_EVENT_ERROR_TCP );return ;
@@ -102,7 +101,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,if (usbip_dbg_flag_vhci_rx)usbip_dump_urb (urb); -usbip_dbg_vhci_rx ("now giveback urb %p\n" , urb); +usbip_dbg_vhci_rx ("now giveback urb %u\n" , pdu->base.seqnum);spin_lock (&the_controller->lock);usb_hcd_unlink_urb_from_ep (vhci_to_hcd (the_controller), urb);
@@ -165,7 +164,7 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,pr_info ("the urb (seqnum %d) was already given back\n" , pdu->base.seqnum); }else { -usbip_dbg_vhci_rx ("now giveback urb %p\n" , urb); +usbip_dbg_vhci_rx ("now giveback urb %d\n" , pdu->base.seqnum);/* If unlink is successful, status is -ECONNRESET */ urb->status = pdu->u.ret_unlink.status;
drivers/usb/usbip/vhci_tx.c +2 -1
@@ -82,7 +82,8 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)memset (&msg,0 ,sizeof (msg));memset (&iov,0 ,sizeof (iov)); -usbip_dbg_vhci_tx ("setup txdata urb %p\n" , urb); +usbip_dbg_vhci_tx ("setup txdata urb seqnum %lu\n" , + priv->seqnum);/* 1. setup usbip_header */ setup_cmd_submit_pdu (&pdu_header, urb);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: Add device quirk for Logitech HD Pro Webcam C925e
In reply to Sasha LevinFrom: Dmitry Fleytman Dmitry Fleytman <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7f038d256c723dd390d2fca942919573995f4cfd ]
Commit e0429362ab15
("usb: Add device quirk for Logitech HD Pro Webcams C920 and C930e") introduced quirk to workaround an issue with some Logitech webcams.
There is one more model that has the same issue - C925e, so applying the same quirk as well.
See aforementioned commit message for detailed explanation of the problem.
--- drivers/usb/core/quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/core/quirks.c +2 -1
@@ -57,10 +57,11 @@ static const struct usb_device_id usb_quirk_list[] = {/* Microsoft LifeCam-VX700 v2.0 */ { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME }, - /* Logitech HD Pro Webcams C920, C920-C and C930e */ + /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */ { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT }, { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT }, { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT }, /* Logitech ConferenceCam CC3000e */ { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] USB: serial: option: add support for Telit ME910 PID 0x1101
In reply to Sasha LevinFrom: Daniele Palmas <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 08933099e6404f588f81c2050bfec7313e06eeaf ]
This patch adds support for PID 0x1101 of Telit ME910.
--- drivers/usb/serial/option.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/serial/option.c +8 -0
@@ -277,6 +277,7 @@ static void option_instat_callback(struct urb *urb);#define TELIT_PRODUCT_LE922_USBCFG3 0x1043#define TELIT_PRODUCT_LE922_USBCFG5 0x1045#define TELIT_PRODUCT_ME910 0x1100 +#define TELIT_PRODUCT_ME910_DUAL_MODEM 0x1101#define TELIT_PRODUCT_LE920 0x1200#define TELIT_PRODUCT_LE910 0x1201#define TELIT_PRODUCT_LE910_USBCFG4 0x1206
@@ -642,6 +643,11 @@ static const struct option_blacklist_info telit_me910_blacklist = { .reserved = BIT(1) | BIT(3), }; +static const struct option_blacklist_info telit_me910_dual_modem_blacklist = { + .sendsetup =BIT (0 ), + .reserved =BIT (3 ), +}; +static const struct option_blacklist_info telit_le910_blacklist = { .sendsetup =BIT (0 ), .reserved =BIT (1 ) |BIT (2 ),
@@ -1241,6 +1247,8 @@ static const struct usb_device_id option_ids[] = { .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), .driver_info = (kernel_ulong_t)&telit_me910_blacklist }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), + .driver_info = (kernel_ulong_t)&telit_me910_dual_modem_blacklist }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: add RESET_RESUME for ELSA MicroLink 56K
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b9096d9f15c142574ebebe8fbb137012bb9d99c2 ]
This modem needs this quirk to operate. It produces timeouts when resumed without reset.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -155,6 +155,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */ { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM }, + /* ELSA MicroLink 56K */ + { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME }, + /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */ { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: xhci: Add XHCI_TRUST_TX_LENGTH for Renesas uPD720201
In reply to Sasha LevinFrom: Daniel Thompson <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit da99706689481717998d1d48edd389f339eea979 ]
When plugging in a USB webcam I see the following message:xhci_hcd 0000:04:00.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?handle_tx_event: 913 callbacks suppressed
All is quiet again with this patch (and I've done a fair but of soak testing with the camera since).
--- drivers/usb/host/xhci-pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-pci.c +3 -0
@@ -181,6 +181,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) xhci->quirks |=XHCI_TRUST_TX_LENGTH ; xhci->quirks |=XHCI_BROKEN_STREAMS ; } +if (pdev->vendor ==PCI_VENDOR_ID_RENESAS && + pdev->device ==0x0014 ) + xhci->quirks |=XHCI_TRUST_TX_LENGTH ;if (pdev->vendor ==PCI_VENDOR_ID_RENESAS && pdev->device ==0x0015 ) xhci->quirks |=XHCI_RESET_ON_RESUME ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/smpboot: Remove stale TLB flush invocations
In reply to Sasha LevinFrom: Thomas Gleixner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 322f8b8b340c824aef891342b0f5795d15e11562 ]
smpboot_setup_warm_reset_vector() and smpboot_restore_warm_reset_vector() invoke local_flush_tlb() for no obvious reason.
Digging in history revealed that the original code in the 2.1 era added those because the code manipulated a swapper_pg_dir pagetable entry. The pagetable manipulation was removed long ago in the 2.3 timeframe, but the TLB flush invocations stayed around forever.
Remove them along with the pointless pr_debug()s which come from the same 2.1 change.
--- arch/x86/kernel/smpboot.c | 9 --------- 1 file changed, 9 deletions(-)
arch/x86/kernel/smpboot.c +0 -9
@@ -107,25 +107,16 @@ static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)spin_lock_irqsave (&rtc_lock, flags);CMOS_WRITE (0xa ,0xf );spin_unlock_irqrestore (&rtc_lock, flags); -local_flush_tlb (); -pr_debug ("1.\n" ); *((volatile unsigned short *)phys_to_virt (TRAMPOLINE_PHYS_HIGH )) = start_eip >>4 ; -pr_debug ("2.\n" ); *((volatile unsigned short *)phys_to_virt (TRAMPOLINE_PHYS_LOW )) = start_eip &0xf ; -pr_debug ("3.\n" ); }static inline void smpboot_restore_warm_reset_vector (void ) {unsigned long flags; -/* -* Install writable page 0 entry to set BIOS data area. -*/ -local_flush_tlb (); -/* * Paranoid: Set warm reset code and vector here back * to default values.
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] n_tty: fix EXTPROC vs ICANON interaction with TIOCINQ (aka FIONREAD)
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 966031f340185eddd05affcf72b740549f056348 ]
We added support for EXTPROC back in 2010 in commit 26df6d13406d ("tty:
Add EXTPROC support for LINEMODE") and the intent was to allow it to override some (all?) ICANON behavior. Quoting from that original commit message:
There is a new bit in the termios local flag word, EXTPROC. When this bit is set, several aspects of the terminal driver are disabled. Input line editing, character echo, and mapping of signals are all disabled. This allows the telnetd to turn off these functions when in linemode, but still keep track of what state the user wants the terminal to be in.
but the problem turns out that "several aspects of the terminal driver are disabled" is a bit ambiguous, and you can really confuse the n_tty layer by setting EXTPROC and then causing some of the ICANON invariants to no longer be maintained.
This fixes at least one such case (TIOCINQ) becoming unhappy because of the confusion over whether ICANON really means ICANON when EXTPROC is set.
This basically makes TIOCINQ match the case of read: if EXTPROC is set, we ignore ICANON. Also, make sure to reset the ICANON state ie EXTPROC changes, not just if ICANON changes.
--- drivers/tty/n_tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/n_tty.c +2 -2
@@ -1808,7 +1808,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) {struct n_tty_data *ldata = tty->disc_data; -if (!old || (old->c_lflag ^ tty->termios.c_lflag) &ICANON ) { +if (!old || (old->c_lflag ^ tty->termios.c_lflag) & (ICANON |EXTPROC )) {bitmap_zero (ldata->read_flags,N_TTY_BUF_SIZE ); ldata->line_start = ldata->read_tail;if (!L_ICANON (tty) || !read_cnt (ldata)) {
@@ -2517,7 +2517,7 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file,return put_user (tty_chars_in_buffer (tty), (int __user *) arg);case TIOCINQ :down_write (&tty->termios_rwsem); -if (L_ICANON (tty)) +if (L_ICANON (tty) && !L_EXTPROC (tty)) retval =inq_canon (ldata);else retval =read_cnt (ldata);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/boot: Add early cmdline parsing for options with arguments
In reply to Sasha LevinFrom: Tom Lendacky <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e505371dd83963caae1a37ead9524e8d997341be ]
Add a cmdline_find_option() function to look for cmdline options that take arguments. The argument is returned in a supplied buffer and the argument length (regardless of whether it fits in the supplied buffer) is returned, with -1 indicating not found.
--- arch/x86/include/asm/cmdline.h | 2 + arch/x86/lib/cmdline.c | 105 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+)
arch/x86/include/asm/cmdline.h +2 -0
@@ -2,5 +2,7 @@#define _ASM_X86_CMDLINE_Hint cmdline_find_option_bool (const char *cmdline_ptr,const char *option); +int cmdline_find_option (const char *cmdline_ptr,const char *option, +char *buffer,int bufsize);#endif /* _ASM_X86_CMDLINE_H */
arch/x86/lib/cmdline.c +105 -0
108 lines not on this page · raw message
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/paravirt: Dont patch flush_tlb_single
In reply to Sasha LevinFrom: Thomas Gleixner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a035795499ca1c2bd1928808d1a156eda1420383 ]
native_flush_tlb_single() will be changed with the upcoming PAGE_TABLE_ISOLATION feature. This requires to have more code in there than INVLPG.
Remove the paravirt patching for it.
--- arch/x86/kernel/paravirt_patch_64.c | 2 -- 1 file changed, 2 deletions(-)
arch/x86/kernel/paravirt_patch_64.c +0 -2
@@ -9,7 +9,6 @@ DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");DEF_NATIVE (pv_mmu_ops, read_cr2,"movq %cr2, %rax" );DEF_NATIVE (pv_mmu_ops, read_cr3,"movq %cr3, %rax" );DEF_NATIVE (pv_mmu_ops, write_cr3,"movq %rdi, %cr3" ); -DEF_NATIVE (pv_mmu_ops, flush_tlb_single,"invlpg (%rdi)" );DEF_NATIVE (pv_cpu_ops, clts,"clts" );DEF_NATIVE (pv_cpu_ops, wbinvd,"wbinvd" );
@@ -57,7 +56,6 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,PATCH_SITE (pv_mmu_ops, read_cr3);PATCH_SITE (pv_mmu_ops, write_cr3);PATCH_SITE (pv_cpu_ops, clts); -PATCH_SITE (pv_mmu_ops, flush_tlb_single);PATCH_SITE (pv_cpu_ops, wbinvd); patch_site:
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kernel/acct.c: fix the acct->needcheck check in check_free_space()
In reply to Sasha LevinFrom: Oleg Nesterov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4d9570158b6260f449e317a5f9ed030c2504a615 ]
As Tsukada explains, the time_is_before_jiffies(acct->needcheck) check is very wrong, we need time_is_after_jiffies() to make sys_acct() work.
Ignoring the overflows, the code should "goto out" if needcheck > jiffies, while currently it checks "needcheck < jiffies" and thus in the likely case check_free_space() does nothing until jiffies overflow.
In particular this means that sys_acct() is simply broken, acct_on() sets acct->needcheck = jiffies and expects that check_free_space() should set acct->active = 1 after the free-space check, but this won't happen if jiffies increments in between.
This was broken by commit 32dc73086015 ("get rid of timer in kern/acct.c") in 2011, then another (correct) commit 795a2f22a8ea ("acct() should honour the limits from the very beginning") made the problem more visible.
--- kernel/acct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/acct.c +1 -1
@@ -99,7 +99,7 @@ static int check_free_space(struct bsd_acct_struct *acct) {struct kstatfs sbuf; -if (time_is_before_jiffies (acct->needcheck)) +if (time_is_after_jiffies (acct->needcheck)) goto out;/* May block */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] crypto: n2 - cure use after free
In reply to Sasha LevinFrom: Jan Engelhardt <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 203f45003a3d03eea8fa28d74cfc74c354416fdb ]
queue_cache_init is first called for the Control Word Queue (n2_crypto_probe). At that time, queue_cache[0] is NULL and a new kmem_cache will be allocated. If the subsequent n2_register_algs call fails, the kmem_cache will be released in queue_cache_destroy, but queue_cache_init[0] is not set back to NULL.
So when the Module Arithmetic Unit gets probed next (n2_mau_probe), queue_cache_init will not allocate a kmem_cache again, but leave it as its bogus value, causing a BUG() to trigger when queue_cache[0] is eventually passed to kmem_cache_zalloc:
n2_crypto: Found N2CP at /virtual-devices@100/n2cp@7
n2_crypto: Registered NCS HVAPI version 2.0
called queue_cache_init
n2_crypto: md5 alg registration failed
n2cp f028687c: /virtual-devices@100/n2cp@7: Unable to register algorithms.
called queue_cache_destroy
n2cp: probe of f028687c failed with error -22
n2_crypto: Found NCP at /virtual-devices@100/ncp@6
n2_crypto: Registered NCS HVAPI version 2.0
called queue_cache_init
kernel BUG at mm/slab.c:2993!
Call Trace:
[0000000000604488] kmem_cache_alloc+0x1a8/0x1e0
(inlined) kmem_cache_zalloc
(inlined) new_queue
(inlined) spu_queue_setup
(inlined) handle_exec_unit
[0000000010c61eb4] spu_mdesc_scan+0x1f4/0x460 [n2_crypto]
[0000000010c62b80] n2_mau_probe+0x100/0x220 [n2_crypto]
[000000000084b174] platform_drv_probe+0x34/0xc0--- drivers/crypto/n2_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/n2_core.c +3 -0
@@ -1641,6 +1641,7 @@ static int queue_cache_init(void) CWQ_ENTRY_SIZE, 0, NULL);if (!queue_cache[HV_NCS_QTYPE_CWQ -1 ]) {kmem_cache_destroy (queue_cache[HV_NCS_QTYPE_MAU -1 ]); + queue_cache[HV_NCS_QTYPE_MAU -1 ] =NULL ;return -ENOMEM ; }return 0 ;
@@ -1650,6 +1651,8 @@ static void queue_cache_destroy(void) {kmem_cache_destroy (queue_cache[HV_NCS_QTYPE_MAU -1 ]);kmem_cache_destroy (queue_cache[HV_NCS_QTYPE_CWQ -1 ]); + queue_cache[HV_NCS_QTYPE_MAU -1 ] =NULL ; + queue_cache[HV_NCS_QTYPE_CWQ -1 ] =NULL ; }static int spu_queue_register (struct spu_queue *p,unsigned long q_type)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] fscache: Fix the default for fscache_maybe_release_page()
In reply to Sasha LevinFrom: David Howells <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 98801506552593c9b8ac11021b0cdad12cab4f6b ]
Fix the default for fscache_maybe_release_page() for when the cookie isn't valid or the page isn't cached. It mustn't return false as that indicates the page cannot yet be freed.
The problem with the default is that if, say, there's no cache, but a network filesystem's pages are using up almost all the available memory, a system can OOM because the filesystem ->releasepage() op will not allow them to be released as fscache_maybe_release_page() incorrectly prevents it.
This can be tested by writing a sequence of 512MiB files to an AFS mount. It does not affect NFS or CIFS because both of those wrap the call in a check of PG_fscache and it shouldn't bother Ceph as that only has PG_private set whilst writeback is in progress. This might be an issue for 9P, however.
Note that the pages aren't entirely stuck. Removing a file or unmounting will clear things because that uses ->invalidatepage() instead.
--- include/linux/fscache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/fscache.h +1 -1
@@ -764,7 +764,7 @@ bool fscache_maybe_release_page(struct fscache_cookie *cookie, {if (fscache_cookie_valid (cookie) &&PageFsCache (page))return __fscache_maybe_release_page (cookie, page, gfp); -return false; +return true; }/**
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kernel: make groups_sort calling a responsibility group_info allocators
In reply to Sasha LevinFrom: Thiago Rafael Becker <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bdcf0a423ea1c40bbb40e7ee483b50fc8aa3d758 ]
In testing, we found that nfsd threads may call set_groups in parallel for the same entry cached in auth.unix.gid, racing in the call of groups_sort, corrupting the groups for that entry and leading to permission denials for the client.
This patch:
- Make groups_sort globally visible.
- Move the call to groups_sort to the modifiers of group_info
- Remove the call to groups_sort from set_groups
--- arch/s390/kernel/compat_linux.c | 1 + fs/nfsd/auth.c | 3 +++ include/linux/cred.h | 1 + kernel/groups.c | 5 +++-- kernel/uid16.c | 1 + net/sunrpc/auth_gss/gss_rpc_xdr.c | 1 + net/sunrpc/auth_gss/svcauth_gss.c | 1 + net/sunrpc/svcauth_unix.c | 2 ++ 8 files changed, 13 insertions(+), 2 deletions(-)
arch/s390/kernel/compat_linux.c +1 -0
@@ -263,6 +263,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setgroups16, int, gidsetsize, u16 __user *, grouplisreturn retval; } +groups_sort (group_info); retval =set_current_groups (group_info);put_group_info (group_info);
fs/nfsd/auth.c +3 -0
@@ -59,6 +59,9 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)GROUP_AT (gi, i) = exp->ex_anon_gid; elseGROUP_AT (gi ,i ) =GROUP_AT (rqgi, i); + +/* Each thread allocates its own gi, no race */ +groups_sort (gi); } }else { gi =get_group_info (rqgi);
include/linux/cred.h +1 -0
@@ -87,6 +87,7 @@ extern int set_current_groups(struct group_info *);extern void set_groups (struct cred *,struct group_info *);extern int groups_search (const struct group_info *,kgid_t );extern bool may_setgroups (void ); +extern void groups_sort (struct group_info *);/* access the groups "array" with this macro */ #define GROUP_AT (gi, i) \
kernel/groups.c +3 -2
@@ -101,7 +101,7 @@ static int groups_from_user(struct group_info *group_info, }/* a simple Shell sort */ -static void groups_sort (struct group_info *group_info) +void groups_sort (struct group_info *group_info) {int base, max, stride;int gidsetsize = group_info->ngroups;
@@ -128,6 +128,7 @@ static void groups_sort(struct group_info *group_info) stride /=3 ; } } +EXPORT_SYMBOL (groups_sort);/* a simple bsearch */ int groups_search (const struct group_info *group_info,kgid_t grp)
@@ -159,7 +160,6 @@ int groups_search(const struct group_info *group_info, kgid_t grp)void set_groups (struct cred *new,struct group_info *group_info) {put_group_info (new->group_info); -groups_sort (group_info);get_group_info (group_info); new->group_info = group_info; }
@@ -243,6 +243,7 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist)return retval; } +groups_sort (group_info); retval =set_current_groups (group_info);put_group_info (group_info);
kernel/uid16.c +1 -0
@@ -190,6 +190,7 @@ SYSCALL_DEFINE2(setgroups16, int, gidsetsize, old_gid_t __user *, grouplist)return retval; } +groups_sort (group_info); retval =set_current_groups (group_info);put_group_info (group_info);
net/sunrpc/auth_gss/gss_rpc_xdr.c +1 -0
@@ -231,6 +231,7 @@ static int gssx_dec_linux_creds(struct xdr_stream *xdr, goto out_free_groups;GROUP_AT (creds->cr_group_info, i) = kgid; } +groups_sort (creds->cr_group_info);return 0 ; out_free_groups:
net/sunrpc/auth_gss/svcauth_gss.c +1 -0
@@ -481,6 +481,7 @@ static int rsc_parse(struct cache_detail *cd, goto out;GROUP_AT (rsci.cred.cr_group_info, i) = kgid; } +groups_sort (rsci.cred.cr_group_info);/* mech name */ len =qword_get (&mesg, buf, mlen);
net/sunrpc/svcauth_unix.c +2 -0
@@ -520,6 +520,7 @@ static int unix_gid_parse(struct cache_detail *cd,GROUP_AT (ug.gi, i) = kgid; } +groups_sort (ug.gi); ugp =unix_gid_lookup (cd, uid);if (ugp) {struct cache_head *ch;
@@ -827,6 +828,7 @@ svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp)kgid_t kgid =make_kgid (&init_user_ns,svc_getnl (argv));GROUP_AT (cred->cr_group_info, i) = kgid; } +groups_sort (cred->cr_group_info);if (svc_getu32 (argv) !=htonl (RPC_AUTH_NULL ) ||svc_getu32 (argv) !=0 ) { *authp = rpc_autherr_badverf;return SVC_DENIED ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kernel/signal.c: protect the traced SIGNAL_UNKILLABLE tasks from SIGKILL
In reply to Sasha LevinFrom: Oleg Nesterov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 628c1bcba204052d19b686b5bac149a644cdb72e ]
The comment in sig_ignored() says "Tracers may want to know about even ignored signals" but SIGKILL can not be reported to debugger and it is just wrong to return 0 in this case: SIGKILL should only kill the SIGNAL_UNKILLABLE task if it comes from the parent ns.
Change sig_ignored() to ignore ->ptrace if sig == SIGKILL and rely on sig_task_ignored().
SISGTOP coming from within the namespace is not really right too but at least debugger can intercept it, and we can't drop it here because this will break "gdb -p 1": ptrace_attach() won't work. Perhaps we will add another ->ptrace check later, we will see.
--- kernel/signal.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
kernel/signal.c +7 -5
@@ -88,13 +88,15 @@ static int sig_ignored(struct task_struct *t, int sig, bool force)if (sigismember (&t->blocked, sig) ||sigismember (&t->real_blocked, sig))return 0 ; -if (!sig_task_ignored (t, sig, force)) -return 0 ; -/* -* Tracers may want to know about even ignored signals. +* Tracers may want to know about even ignored signal unless it +* is SIGKILL which can't be reported anyway but can be ignored +* by SIGNAL_UNKILLABLE task. */ -return !t->ptrace; +if (t->ptrace && sig !=SIGKILL ) +return 0 ; + +return sig_task_ignored (t, sig, force); }/*
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kernel/signal.c: protect the SIGNAL_UNKILLABLE tasks from !sig_kernel_only() signals
In reply to Sasha LevinFrom: Oleg Nesterov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ac25385089f673560867eb5179228a44ade0cfc1 ]
Change sig_task_ignored() to drop the SIG_DFL && !sig_kernel_only() signals even if force == T. This simplifies the next change and this matches the same check in get_signal() which will drop these signals anyway.
--- kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/signal.c +1 -1
@@ -72,7 +72,7 @@ static int sig_task_ignored(struct task_struct *t, int sig, bool force) handler =sig_handler (t, sig);if (unlikely (t->signal->flags &SIGNAL_UNKILLABLE ) && - handler ==SIG_DFL && !force) + handler ==SIG_DFL && !(force &&sig_kernel_only (sig)))return 1 ;return sig_handler_ignored (handler, sig);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Input: elantech - add new icbody type 15
In reply to Sasha LevinFrom: Aaron Ma <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 10d900303f1c3a821eb0bef4e7b7ece16768fba4 ]
The touchpad of Lenovo Thinkpad L480 reports it's version as 15.
--- drivers/input/mouse/elantech.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/elantech.c +1 -1
@@ -1550,7 +1550,7 @@ static int elantech_set_properties(struct elantech_data *etd)case 5 : etd->hw_version =3 ;break ; - case 6 ... 14: + case 6 ... 15: etd->hw_version =4 ;break ;default :
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kernel/signal.c: remove the no longer needed SIGNAL_UNKILLABLE check in complete_signal()
In reply to Sasha LevinFrom: Oleg Nesterov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 426915796ccaf9c2bd9bb06dc5702225957bc2e5 ]
complete_signal() checks SIGNAL_UNKILLABLE before it starts to destroy the thread group, today this is wrong in many ways.
If nothing else, fatal_signal_pending() should always imply that the whole thread group (except ->group_exit_task if it is not NULL) is killed, this check breaks the rule.
After the previous changes we can rely on sig_task_ignored(); sig_fatal(sig) && SIGNAL_UNKILLABLE can only be true if we actually want to kill this task and sig == SIGKILL OR it is traced and debugger can intercept the signal.
This should hopefully fix the problem reported by Dmitry. This test-case
static int init(void *arg)
{
for (;;)
pause();
}
int main(void)
{
char stack[16 * 1024];
for (;;) {
int pid = clone(init, stack + sizeof(stack)/2,
CLONE_NEWPID | SIGCHLD, NULL);
assert(pid > 0);
assert(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
assert(waitpid(-1, NULL, WSTOPPED) == pid);
assert(ptrace(PTRACE_DETACH, pid, 0, SIGSTOP) == 0);
assert(syscall(__NR_tkill, pid, SIGKILL) == 0);
assert(pid == wait(NULL));
}
}triggers the WARN_ON_ONCE(!(task->jobctl & JOBCTL_STOP_PENDING)) in task_participate_group_stop(). do_signal_stop()->signal_group_exit() checks SIGNAL_GROUP_EXIT and return false, but task_set_jobctl_pending() checks fatal_signal_pending() and does not set JOBCTL_STOP_PENDING.
And his should fix the minor security problem reported by Kyle, SECCOMP_RET_TRACE can miss fatal_signal_pending() the same way if the task is the root of a pid namespace.
--- kernel/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/signal.c +2 -2
@@ -962,9 +962,9 @@ static void complete_signal(int sig, struct task_struct *p, int group)* then start taking the whole group down immediately. */ if (sig_fatal (p, sig) && - !(signal->flags & (SIGNAL_UNKILLABLE |SIGNAL_GROUP_EXIT )) && + !(signal->flags &SIGNAL_GROUP_EXIT ) && !sigismember (&t->real_blocked, sig) && - (sig ==SIGKILL || !t->ptrace)) { + (sig ==SIGKILL || !p->ptrace)) {/* * This signal will be fatal to the whole group. */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] genksyms: Handle string literals with spaces in reference files
In reply to Sasha LevinFrom: Michal Marek <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a78f70e8d65e88b9f631d073f68cb26dcd746298 ]
The reference files use spaces to separate tokens, however, we must preserve spaces inside string literals. Currently the only case in the tree is struct edac_raw_error_desc in <linux/edac.h>:
$ KBUILD_SYMTYPES=1 make -s drivers/edac/amd64_edac.symtypes
$ mv drivers/edac/amd64_edac.{symtypes,symref}
$ KBUILD_SYMTYPES=1 make -s drivers/edac/amd64_edac.symtypes
drivers/edac/amd64_edac.c:527: warning: amd64_get_dram_hole_info: modversion changed because of changes in struct edac_raw_error_desc--- scripts/genksyms/genksyms.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/genksyms/genksyms.c +4 -2
@@ -423,13 +423,15 @@ static struct string_list *read_node(FILE *f)struct string_list node = { .string = buffer, .tag =SYM_NORMAL }; -int c; +int c, in_string =0 ;while ((c =fgetc (f)) !=EOF ) { -if (c ==' ' ) { +if (!in_string && c ==' ' ) {if (node.string == buffer)continue ;break ; + }else if (c =='"' ) { + in_string = !in_string; }else if (c =='\n' ) {if (node.string == buffer)return NULL ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] module: keep percpu symbols in module's symtab
In reply to Sasha LevinFrom: Miroslav Benes <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e0224418516b4d8a6c2160574bac18447c354ef0 ]
Currently, percpu symbols from .data..percpu ELF section of a module are not copied over and stored in final symtab array of struct module. Consequently such symbol cannot be returned via kallsyms API (for example kallsyms_lookup_name). This can be especially confusing when the percpu symbol is exported. Only its __ksymtab et al. are present in its symtab.
The culprit is in layout_and_allocate() function where SHF_ALLOC flag is dropped for .data..percpu section. There is in fact no need to copy the section to final struct module, because kernel module loader allocates extra percpu section by itself. Unfortunately only symbols from SHF_ALLOC sections are copied due to a check in is_core_symbol().
The patch changes is_core_symbol() function to copy over also percpu symbols (their st_shndx points to .data..percpu ELF section). We do it only if CONFIG_KALLSYMS_ALL is set to be consistent with the rest of the function (ELF section is SHF_ALLOC but !SHF_EXECINSTR). Finally elf_type() returns type 'a' for a percpu symbol because its address is absolute.
--- kernel/module.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
kernel/module.c +11 -4
@@ -2233,7 +2233,7 @@ static char elf_type(const Elf_Sym *sym, const struct load_info *info) }if (sym->st_shndx ==SHN_UNDEF )return 'U' ; -if (sym->st_shndx ==SHN_ABS ) +if (sym->st_shndx ==SHN_ABS || sym->st_shndx == info->index.pcpu)return 'a' ;if (sym->st_shndx >=SHN_LORESERVE )return '?' ;
@@ -2262,7 +2262,7 @@ static char elf_type(const Elf_Sym *sym, const struct load_info *info) }static bool is_core_symbol (const Elf_Sym *src,const Elf_Shdr *sechdrs, -unsigned int shnum) +unsigned int shnum,unsigned int pcpundx) {const Elf_Shdr *sec;
@@ -2271,6 +2271,11 @@ static bool is_core_symbol(const Elf_Sym *src, const Elf_Shdr *sechdrs, || !src->st_name)return false; +#ifdef CONFIG_KALLSYMS_ALL +if (src->st_shndx == pcpundx) +return true; +#endif + sec = sechdrs + src->st_shndx; if (!(sec->sh_flags & SHF_ALLOC)#ifndef CONFIG_KALLSYMS_ALL
@@ -2308,7 +2313,8 @@ static void layout_symtab(struct module *mod, struct load_info *info)/* Compute total space required for the core symbols' strtab. */ for (ndst = i =0 ; i < nsrc; i++) {if (i ==0 || -is_core_symbol (src+i, info->sechdrs, info->hdr->e_shnum)) { +is_core_symbol (src+i, info->sechdrs, info->hdr->e_shnum, + info->index.pcpu)) { strtab_size +=strlen (&info->strtab[src[i].st_name])+1 ; ndst++; }
@@ -2366,7 +2372,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info) src = mod->kallsyms->symtab;for (ndst = i =0 ; i < mod->kallsyms->num_symtab; i++) {if (i ==0 || -is_core_symbol (src+i, info->sechdrs, info->hdr->e_shnum)) { +is_core_symbol (src+i, info->sechdrs, info->hdr->e_shnum, + info->index.pcpu)) { dst[ndst] = src[i]; dst[ndst++].st_name = s - mod->core_kallsyms.strtab; s += strlcpy(s, &mod->kallsyms->strtab[src[i].st_name],
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/microcode/AMD: Add support for fam17h microcode loading
In reply to Sasha LevinFrom: Tom Lendacky <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f4e9b7af0cd58dd039a0fb2cd67d57cea4889abf ]
The size for the Microcode Patch Block (MPB) for an AMD family 17h processor is 3200 bytes. Add a #define for fam17h so that it does not default to 2048 bytes and fail a microcode load/update.
--- arch/x86/kernel/cpu/microcode/amd.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kernel/cpu/microcode/amd.c +4 -0
@@ -153,6 +153,7 @@ static unsigned int verify_patch_size(u8 family, u32 patch_size,#define F14H_MPB_MAX_SIZE 1824#define F15H_MPB_MAX_SIZE 4096#define F16H_MPB_MAX_SIZE 3458 +#define F17H_MPB_MAX_SIZE 3200switch (family) {case 0x14 :
@@ -164,6 +165,9 @@ static unsigned int verify_patch_size(u8 family, u32 patch_size,case 0x16 : max_size =F16H_MPB_MAX_SIZE ;break ; +case 0x17 : + max_size =F17H_MPB_MAX_SIZE ; +break ;default : max_size =F1XH_MPB_MAX_SIZE ;break ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/tlb: Drop the _GPL from the cpu_tlbstate export
In reply to Sasha LevinFrom: Thomas Gleixner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1e5476815fd7f98b888e01a0f9522b63085f96c9 ]
The recent changes for PTI touch cpu_tlbstate from various tlb_flush inlines. cpu_tlbstate is exported as GPL symbol, so this causes a regression when building out of tree drivers for certain graphics cards.
Aside of that the export was wrong since it was introduced as it should have been EXPORT_PER_CPU_SYMBOL_GPL().
Use the correct PER_CPU export and drop the _GPL to restore the previous state which allows users to utilize the cards they payed for.
As always I'm really thrilled to make this kind of change to support the #friends (or however the hot hashtag of today is spelled) from that closet sauce graphics corp.
--- arch/x86/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/init.c +1 -1
@@ -758,7 +758,7 @@ DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = {#endif .cr4 = ~0UL, /* fail hard if we screw up cr4 shadow initialization */ }; -EXPORT_SYMBOL_GPL (cpu_tlbstate); +EXPORT_PER_CPU_SYMBOL (cpu_tlbstate);void update_cache_mode_entry (unsigned entry,enum page_cache_mode cache) {
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] module: Issue warnings when tainting kernel
In reply to Sasha LevinFrom: Libor Pechacek <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3205c36cf7d96024626f92d65f560035df1abcb2 ]
While most of the locations where a kernel taint bit is set are accompanied with a warning message, there are two which set their bits silently. If the tainting module gets unloaded later on, it is almost impossible to tell what was the reason for setting the flag.
--- kernel/module.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
kernel/module.c +10 -1
@@ -2733,8 +2733,12 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)return -ENOEXEC ; } -if (!get_modinfo (info,"intree" )) +if (!get_modinfo (info,"intree" )) { +if (!test_taint (TAINT_OOT_MODULE )) +pr_warn ("%s: loading out-of-tree module taints kernel.\n" , + mod->name);add_taint_module (mod,TAINT_OOT_MODULE ,LOCKDEP_STILL_OK ); + }if (get_modinfo (info,"staging" )) {add_taint_module (mod,TAINT_CRAP ,LOCKDEP_STILL_OK );
@@ -2899,6 +2903,8 @@ static int move_module(struct module *mod, struct load_info *info)static int check_module_license_and_versions (struct module *mod) { +int prev_taint =test_taint (TAINT_PROPRIETARY_MODULE ); +/* * ndiswrapper is under GPL by itself, but loads proprietary modules. * Don't use add_taint_module(), as it would prevent ndiswrapper from
@@ -2917,6 +2923,9 @@ static int check_module_license_and_versions(struct module *mod)add_taint_module (mod,TAINT_PROPRIETARY_MODULE ,LOCKDEP_NOW_UNRELIABLE ); +if (!prev_taint &&test_taint (TAINT_PROPRIETARY_MODULE )) +pr_warn ("%s: module license taints kernel.\n" , mod->name); +#ifdef CONFIG_MODVERSIONS if ((mod->num_syms && !mod->crcs) || (mod->num_gpl_syms && !mod->gpl_crcs)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] parisc: Fix alignment of pa_tlb_lock in assembly on 32-bit SMP kernel
In reply to Sasha LevinFrom: Helge Deller <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 88776c0e70be0290f8357019d844aae15edaa967 ]
Qemu for PARISC reported on a 32bit SMP parisc kernel strange failures about "Not-handled unaligned insn 0x0e8011d6 and 0x0c2011c9."
Those opcodes evaluate to the ldcw() assembly instruction which requires (on 32bit) an alignment of 16 bytes to ensure atomicity.
As it turns out, qemu is correct and in our assembly code in entry.S and pacache.S we don't pay attention to the required alignment.
This patch fixes the problem by aligning the lock offset in assembly code in the same manner as we do in our C-code.
--- arch/parisc/include/asm/ldcw.h | 2 ++ arch/parisc/kernel/entry.S | 13 +++++++++++-- arch/parisc/kernel/pacache.S | 9 +++++++-- 3 files changed, 20 insertions(+), 4 deletions(-)
arch/parisc/include/asm/ldcw.h +2 -0
@@ -11,6 +11,7 @@for the semaphore. */ #define __PA_LDCW_ALIGNMENT 16 +#define __PA_LDCW_ALIGN_ORDER 4#define __ldcw_align (a) ({ \ unsigned long __ret = (unsigned long) &(a)->lock[0]; \ __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) \
@@ -28,6 +29,7 @@ldcd). */ #define __PA_LDCW_ALIGNMENT 4 +#define __PA_LDCW_ALIGN_ORDER 2#define __ldcw_align (a) (&(a)->slock)#define __LDCW "ldcw,co"
arch/parisc/kernel/entry.S +11 -2
@@ -35,6 +35,7 @@ #include <asm/pgtable.h> #include <asm/signal.h> #include <asm/unistd.h> +#include <asm/ldcw.h> #include <asm/thread_info.h> #include <linux/linkage.h>
@@ -46,6 +47,14 @@ #endif .import pa_tlb_lock,data + .macro load_pa_tlb_lock reg +#if __PA_LDCW_ALIGNMENT > 4 + load32 PA(pa_tlb_lock) + __PA_LDCW_ALIGNMENT-1, \reg + depi 0,31,__PA_LDCW_ALIGN_ORDER, \reg +#else + load32 PA(pa_tlb_lock), \reg +#endif + .endm /* space_to_prot macro creates a prot id from a space id */
@@ -457,7 +466,7 @@ .macro tlb_lock spc,ptp,pte,tmp,tmp1,fault #ifdef CONFIG_SMP cmpib,COND(=),n 0,\spc,2f - load32 PA(pa_tlb_lock),\tmp + load_pa_tlb_lock \tmp 1: LDCW 0(\tmp),\tmp1 cmpib,COND(=) 0,\tmp1,1b nop
@@ -480,7 +489,7 @@ /* Release pa_tlb_lock lock. */ .macro tlb_unlock1 spc,tmp #ifdef CONFIG_SMP - load32 PA(pa_tlb_lock),\tmp + load_pa_tlb_lock \tmp tlb_unlock0 \spc,\tmp #endif .endm
arch/parisc/kernel/pacache.S +7 -2
@@ -36,6 +36,7 @@ #include <asm/assembly.h> #include <asm/pgtable.h> #include <asm/cache.h> +#include <asm/ldcw.h> #include <linux/linkage.h> .text
@@ -333,8 +334,12 @@ ENDPROC(flush_data_cache_local) .macro tlb_lock la,flags,tmp #ifdef CONFIG_SMP - ldil L%pa_tlb_lock,%r1 - ldo R%pa_tlb_lock(%r1),\la +#if __PA_LDCW_ALIGNMENT > 4 + load32 pa_tlb_lock + __PA_LDCW_ALIGNMENT-1, \la + depi 0,31,__PA_LDCW_ALIGN_ORDER, \la +#else + load32 pa_tlb_lock, \la +#endif rsm PSW_SM_I,\flags 1: LDCW 0(\la),\tmp cmpib,<>,n 0,\tmp,3f
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] proc: much faster /proc/vmstat
In reply to Sasha LevinFrom: Alexey Dobriyan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 68ba0326b4e14988f9e0c24a6e12a85cf2acd1ca ]
Every current KDE system has process named ksysguardd polling files below once in several seconds:
$ strace -e trace=open -p $(pidof ksysguardd)
Process 1812 attached
open("/etc/mtab", O_RDONLY|O_CLOEXEC) = 8
open("/etc/mtab", O_RDONLY|O_CLOEXEC) = 8
open("/proc/net/dev", O_RDONLY) = 8
open("/proc/net/wireless", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/proc/stat", O_RDONLY) = 8
open("/proc/vmstat", O_RDONLY) = 8Hell knows what it is doing but speed up reading /proc/vmstat by 33%!
Benchmark is open+read+close 1.000.000 times.
BEFORE
$ perf stat -r 10 taskset -c 3 ./proc-vmstat
Performance counter stats for 'taskset -c 3 ./proc-vmstat' (10 runs):
13146.768464 task-clock (msec) # 0.960 CPUs utilized ( +- 0.60% )
15 context-switches # 0.001 K/sec ( +- 1.41% )
1 cpu-migrations # 0.000 K/sec ( +- 11.11% )
104 page-faults # 0.008 K/sec ( +- 0.57% )
45,489,799,349 cycles # 3.460 GHz ( +- 0.03% )
9,970,175,743 stalled-cycles-frontend # 21.92% frontend cycles idle ( +- 0.10% )
2,800,298,015 stalled-cycles-backend # 6.16% backend cycles idle ( +- 0.32% )
79,241,190,850 instructions # 1.74 insn per cycle
# 0.13 stalled cycles per insn ( +- 0.00% )
17,616,096,146 branches # 1339.956 M/sec ( +- 0.00% )
176,106,232 branch-misses # 1.00% of all branches ( +- 0.18% ) 13.691078109 seconds time elapsed ( +- 0.03% )
^^^^^^^^^^^^
AFTER
$ perf stat -r 10 taskset -c 3 ./proc-vmstat
Performance counter stats for 'taskset -c 3 ./proc-vmstat' (10 runs):
8688.353749 task-clock (msec) # 0.950 CPUs utilized ( +- 1.25% )
10 context-switches # 0.001 K/sec ( +- 2.13% )
1 cpu-migrations # 0.000 K/sec
104 page-faults # 0.012 K/sec ( +- 0.56% )
30,384,010,730 cycles # 3.497 GHz ( +- 0.07% )
12,296,259,407 stalled-cycles-frontend # 40.47% frontend cycles idle ( +- 0.13% )
3,370,668,651 stalled-cycles-backend # 11.09% backend cycles idle ( +- 0.69% )
28,969,052,879 instructions # 0.95 insn per cycle
# 0.42 stalled cycles per insn ( +- 0.01% )
6,308,245,891 branches # 726.058 M/sec ( +- 0.00% )
214,685,502 branch-misses # 3.40% of all branches ( +- 0.26% ) 9.146081052 seconds time elapsed ( +- 0.07% )
^^^^^^^^^^^
vsnprintf() is slow because:
1. format_decode() is busy looking for format specifier: 2 branches per character (not in this case, but in others)
2. approximately million branches while parsing format mini language and everywhere
3. just look at what string() does /proc/vmstat is good case because most of its content are strings
--- mm/vmstat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/vmstat.c +3 -1
@@ -1326,7 +1326,9 @@ static int vmstat_show(struct seq_file *m, void *arg)unsigned long *l = arg;unsigned long off = l - (unsigned long *)m->private; -seq_printf (m,"%s %lu\n" , vmstat_text[off], *l); +seq_puts (m, vmstat_text[off]); +seq_put_decimal_ull (m,' ' , *l); +seq_putc (m,'\n' );return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] dm bufio: fix shrinker scans when (nr_to_scan < retain_target)
In reply to Sasha LevinFrom: Suren Baghdasaryan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fbc7c07ec23c040179384a1f16b62b6030eb6bdd ]
When system is under memory pressure it is observed that dm bufio shrinker often reclaims only one buffer per scan. This change fixes the following two issues in dm bufio shrinker that cause this behavior:
1. ((nr_to_scan - freed) <= retain_target) condition is used to terminate slab scan process. This assumes that nr_to_scan is equal to the LRU size, which might not be correct because do_shrink_slab() in vmscan.c calculates nr_to_scan using multiple inputs.
As a result when nr_to_scan is less than retain_target (64) the scan will terminate after the first iteration, effectively reclaiming one buffer per scan and making scans very inefficient. This hurts vmscan performance especially because mutex is acquired/released every time dm_bufio_shrink_scan() is called.
New implementation uses ((LRU size - freed) <= retain_target) condition for scan termination. LRU size can be safely determined inside __scan() because this function is called after dm_bufio_lock().
2. do_shrink_slab() uses value returned by dm_bufio_shrink_count() to determine number of freeable objects in the slab. However dm_bufio always retains retain_target buffers in its LRU and will terminate a scan when this mark is reached. Therefore returning the entire LRU size from dm_bufio_shrink_count() is misleading because that does not represent the number of freeable objects that slab will reclaim during a scan. Returning (LRU size - retain_target) better represents the number of freeable objects in the slab. This way do_shrink_slab() returns 0 when (LRU size < retain_target) and vmscan will not try to scan this shrinker avoiding scans that will not reclaim any memory.
Test: tested using Android device running <AOSP>/system/extras/alloc-stress that generates memory pressure and causes intensive shrinker scans
--- drivers/md/dm-bufio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/md/dm-bufio.c +5 -2
@@ -1521,7 +1521,8 @@ static unsigned long __scan(struct dm_bufio_client *c, unsigned long nr_to_scan,int l;struct dm_buffer *b, *tmp;unsigned long freed =0 ; -unsigned long count = nr_to_scan; +unsigned long count = c->n_buffers[LIST_CLEAN ] + + c->n_buffers[LIST_DIRTY ];unsigned long retain_target =get_retain_buffers (c);for (l =0 ; l <LIST_SIZE ; l++) {
@@ -1558,6 +1559,7 @@ dm_bufio_shrink_count(struct shrinker *shrink, struct shrink_control *sc) {struct dm_bufio_client *c;unsigned long count; +unsigned long retain_target; c = container_of(shrink, struct dm_bufio_client, shrinker);if (sc->gfp_mask & __GFP_FS)
@@ -1566,8 +1568,9 @@ dm_bufio_shrink_count(struct shrinker *shrink, struct shrink_control *sc)return 0 ; count = c->n_buffers[LIST_CLEAN ] + c->n_buffers[LIST_DIRTY ]; + retain_target =get_retain_buffers (c);dm_bufio_unlock (c); -return count; +return (count < retain_target) ?0 : (count - retain_target); }/*
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: Fix stack-out-of-bounds read in write_mmio
In reply to Sasha LevinFrom: Wanpeng Li <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e39d200fa5bf5b94a0948db0dae44c1b73b84a56 ]
Reported by syzkaller:
BUG: KASAN: stack-out-of-bounds in write_mmio+0x11e/0x270 [kvm] Read of size 8 at addr ffff8803259df7f8 by task syz-executor/32298 CPU: 6 PID: 32298 Comm: syz-executor Tainted: G OE 4.15.0-rc2+ #18 Hardware name: LENOVO ThinkCentre M8500t-N000/SHARKBAY, BIOS FBKTC1AUS 02/16/2016 Call Trace: dump_stack+0xab/0xe1 print_address_description+0x6b/0x290 kasan_report+0x28a/0x370 write_mmio+0x11e/0x270 [kvm] emulator_read_write_onepage+0x311/0x600 [kvm] emulator_read_write+0xef/0x240 [kvm] emulator_fix_hypercall+0x105/0x150 [kvm] em_hypercall+0x2b/0x80 [kvm] x86_emulate_insn+0x2b1/0x1640 [kvm] x86_emulate_instruction+0x39a/0xb90 [kvm] handle_exception+0x1b4/0x4d0 [kvm_intel] vcpu_enter_guest+0x15a0/0x2640 [kvm] kvm_arch_vcpu_ioctl_run+0x549/0x7d0 [kvm] kvm_vcpu_ioctl+0x479/0x880 [kvm] do_vfs_ioctl+0x142/0x9a0 SyS_ioctl+0x74/0x80 entry_SYSCALL_64_fastpath+0x23/0x9a
The path of patched vmmcall will patch 3 bytes opcode 0F 01 C1(vmcall) to the guest memory, however, write_mmio tracepoint always prints 8 bytes through *(u64 *)val since kvm splits the mmio access into 8 bytes. This leaks 5 bytes from the kernel stack (CVE-2017-17741). This patch fixes it by just accessing the bytes which we operate on.
Before patch:
syz-executor-5567 [007] .... 51370.561696: kvm_mmio: mmio write len 3 gpa 0x10 val 0x1ffff10077c1010f
After patch:
syz-executor-13416 [002] .... 51302.299573: kvm_mmio: mmio write len 3 gpa 0x10 val 0xc1010f
--- arch/arm/kvm/mmio.c | 6 +++--- arch/x86/kvm/x86.c | 8 ++++---- include/trace/events/kvm.h | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-)
arch/arm/kvm/mmio.c +3 -3
@@ -113,7 +113,7 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) }trace_kvm_mmio (KVM_TRACE_MMIO_READ , len, run->mmio.phys_addr, - data); + &data); data =vcpu_data_host_to_guest (vcpu, data, len); *vcpu_reg (vcpu, vcpu->arch.mmio_decode.rt) = data; }
@@ -188,14 +188,14 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,if (is_write) { data =vcpu_data_guest_to_host (vcpu, *vcpu_reg (vcpu, rt), len); -trace_kvm_mmio (KVM_TRACE_MMIO_WRITE , len, fault_ipa, data); +trace_kvm_mmio (KVM_TRACE_MMIO_WRITE , len, fault_ipa, &data);mmio_write_buf (data_buf, len, data); ret =kvm_io_bus_write (vcpu,KVM_MMIO_BUS , fault_ipa, len, data_buf); }else {trace_kvm_mmio (KVM_TRACE_MMIO_READ_UNSATISFIED , len, - fault_ipa,0 ); + fault_ipa,NULL ); ret =kvm_io_bus_read (vcpu,KVM_MMIO_BUS , fault_ipa, len, data_buf);
arch/x86/kvm/x86.c +4 -4
@@ -4188,7 +4188,7 @@ static int vcpu_mmio_read(struct kvm_vcpu *vcpu, gpa_t addr, int len, void *v) addr, n, v)) && kvm_io_bus_read(vcpu, KVM_MMIO_BUS, addr, n, v))break ; -trace_kvm_mmio (KVM_TRACE_MMIO_READ , n, addr, *(u64 *)v); +trace_kvm_mmio (KVM_TRACE_MMIO_READ , n, addr, v); handled += n; addr += n; len -= n;
@@ -4427,7 +4427,7 @@ static int read_prepare(struct kvm_vcpu *vcpu, void *val, int bytes) {if (vcpu->mmio_read_completed) {trace_kvm_mmio (KVM_TRACE_MMIO_READ , bytes, - vcpu->mmio_fragments[0 ].gpa, *(u64 *)val); + vcpu->mmio_fragments[0 ].gpa, val); vcpu->mmio_read_completed =0 ;return 1 ; }
@@ -4449,14 +4449,14 @@ static int write_emulate(struct kvm_vcpu *vcpu, gpa_t gpa,static int write_mmio (struct kvm_vcpu *vcpu,gpa_t gpa,int bytes,void *val) { -trace_kvm_mmio (KVM_TRACE_MMIO_WRITE , bytes, gpa, *(u64 *)val); +trace_kvm_mmio (KVM_TRACE_MMIO_WRITE , bytes, gpa, val);return vcpu_mmio_write (vcpu, gpa, bytes, val); }static int read_exit_mmio (struct kvm_vcpu *vcpu,gpa_t gpa,void *val,int bytes) { -trace_kvm_mmio (KVM_TRACE_MMIO_READ_UNSATISFIED , bytes, gpa,0 ); +trace_kvm_mmio (KVM_TRACE_MMIO_READ_UNSATISFIED , bytes, gpa,NULL );return X86EMUL_IO_NEEDED ; }
include/trace/events/kvm.h +5 -2
@@ -204,7 +204,7 @@ TRACE_EVENT(kvm_ack_irq, { KVM_TRACE_MMIO_WRITE, "write" } TRACE_EVENT(kvm_mmio, - TP_PROTO(int type, int len, u64 gpa, u64 val), + TP_PROTO(int type, int len, u64 gpa, void *val), TP_ARGS(type, len, gpa, val), TP_STRUCT__entry(
@@ -218,7 +218,10 @@ TRACE_EVENT(kvm_mmio, __entry->type = type; __entry->len = len; __entry->gpa = gpa; - __entry->val = val; + __entry->val =0 ; +if (val) +memcpy (&__entry->val, val, +min_t (u32,sizeof (__entry->val), len)); ), TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] can: gs_usb: fix return value of the "set_bittiming" callback
In reply to Sasha LevinFrom: Wolfgang Grandegger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d5b42e6607661b198d8b26a0c30969605b1bf5c7 ]
The "set_bittiming" callback treats a positive return value as error! For that reason "can_changelink()" will quit silently after setting the bittiming values without processing ctrlmode, restart-ms, etc.
--- drivers/net/can/usb/gs_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/gs_usb.c +1 -1
@@ -430,7 +430,7 @@ static int gs_usb_set_bittiming(struct net_device *netdev)dev_err (netdev->dev.parent,"Couldn't set bittimings (err=%d)" , rc); -return rc; +return (rc >0 ) ?0 : rc; }static void gs_usb_xmit_callback (struct urb *urb)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] IB/srpt: Disable RDMA access by the initiator
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bec40c26041de61162f7be9d2ce548c756ce0f65 ]
With the SRP protocol all RDMA operations are initiated by the target. Since no RDMA operations are initiated by the initiator, do not grant the initiator permission to submit RDMA reads or writes to the target.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -2
@@ -958,8 +958,7 @@ static int srpt_init_ch_qp(struct srpt_rdma_ch *ch, struct ib_qp *qp)return -ENOMEM ; attr->qp_state =IB_QPS_INIT ; - attr->qp_access_flags =IB_ACCESS_LOCAL_WRITE |IB_ACCESS_REMOTE_READ | -IB_ACCESS_REMOTE_WRITE ; + attr->qp_access_flags =IB_ACCESS_LOCAL_WRITE ; attr->port_num = ch->sport->port; attr->pkey_index =0 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] MIPS: Validate PR_SET_FP_MODE prctl(2) requests against the ABI of the task
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b67336eee3fcb8ecedc6c13e2bf88aacfa3151e2 ]
Fix an API loophole introduced with commit 9791554b45a2 ("MIPS,prctl:
add PR_[GS]ET_FP_MODE prctl options for MIPS"), where the caller of prctl(2) is incorrectly allowed to make a change to CP0.Status.FR or CP0.Config5.FRE register bits even if CONFIG_MIPS_O32_FP64_SUPPORT has not been enabled, despite that an executable requesting the mode requested via ELF file annotation would not be allowed to run in the first place, or for n64 and n64 ABI tasks which do not have non-default modes defined at all. Add suitable checks to `mips_set_process_fp_mode' and bail out if an invalid mode change has been requested for the ABI in effect, even if the FPU hardware or emulation would otherwise allow it.
Always succeed however without taking any further action if the mode requested is the same as one already in effect, regardless of whether any mode change, should it be requested, would actually be allowed for the task concerned.
Patchwork: https://patchwork.linux-mips.org/patch/17800/
--- arch/mips/kernel/process.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/mips/kernel/process.c +12 -0
@@ -631,6 +631,18 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)unsigned long switch_count;struct task_struct *t; +/* If nothing to change, return right away, successfully. */ +if (value ==mips_get_process_fp_mode (task)) +return 0 ; + +/* Only accept a mode change if 64-bit FP enabled for o32. */ +if (!IS_ENABLED (CONFIG_MIPS_O32_FP64_SUPPORT )) +return -EOPNOTSUPP ; + +/* And only for o32 tasks. */ +if (IS_ENABLED (CONFIG_64BIT ) && !test_thread_flag (TIF_32BIT_REGS )) +return -EOPNOTSUPP ; +/* Check the value is valid */ if (value & ~known_bits)return -EOPNOTSUPP ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: pcm: Add missing error checks in OSS emulation plugin builder
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6708913750344a900f2e73bfe4a4d6dbbce4fe8d ]
In the OSS emulation plugin builder where the frame size is parsed in the plugin chain, some places miss the possible errors returned from the plugin src_ or dst_frames callback.
This patch papers over such places.
--- sound/core/oss/pcm_plugin.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/core/oss/pcm_plugin.c +11 -3
@@ -591,18 +591,26 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, stsnd_pcm_sframes_t frames = size; plugin =snd_pcm_plug_first (plug); -while (plugin && frames >0 ) { +while (plugin) { +if (frames <=0 ) +return frames;if ((next = plugin->next) !=NULL ) {snd_pcm_sframes_t frames1 = frames; -if (plugin->dst_frames) +if (plugin->dst_frames) { frames1 = plugin->dst_frames (plugin, frames); +if (frames1 <=0 ) +return frames1; + }if ((err = next->client_channels (next, frames1, &dst_channels)) <0 ) {return err; }if (err != frames1) { frames = err; -if (plugin->src_frames) +if (plugin->src_frames) { frames = plugin->src_frames (plugin, frames1); +if (frames <=0 ) +return frames; + } } }else dst_channels =NULL ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] MIPS: Factor out NT_PRFPREG regset access helpers
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a03fe72572c12e98f4173f8a535f32468e48b6ec ]
In preparation to fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset") FCSR access regression factor out NT_PRFPREG regset access helpers for the non-MSA and the MSA variants respectively, to avoid having to deal with excessive indentation in the actual fix.
No functional change, however use target->thread.fpu.fpr[0]' rather than target->thread.fpu.fpr[i]' for FGR holding type size determination as there's no i' variable to refer to anymore, and for the factored out i' variable declaration use unsigned int' rather than unsigned' as its type, following the common style.
Patchwork: https://patchwork.linux-mips.org/patch/17925/
--- arch/mips/kernel/ptrace.c | 108 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 25 deletions(-)
arch/mips/kernel/ptrace.c +83 -25
@@ -438,25 +438,36 @@ static int gpr64_set(struct task_struct *target,#endif /* CONFIG_64BIT */ -static int fpr_get (struct task_struct *target, -const struct user_regset *regset, -unsigned int pos,unsigned int count, -void *kbuf,void __user *ubuf) +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer, +* !CONFIG_CPU_HAS_MSA variant. FP context's general register slots +* correspond 1:1 to buffer slots. +*/ +static int fpr_get_fpa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +void **kbuf,void __user **ubuf) { -unsigned i; -int err; -u64 fpr_val; - -/* XXX fcr31 */ +return user_regset_copyout (pos, count, kbuf, ubuf, + &target->thread.fpu, +0 ,sizeof (elf_fpregset_t)); +} -if (sizeof (target->thread.fpu.fpr[i]) ==sizeof (elf_fpreg_t)) -return user_regset_copyout (&pos, &count, &kbuf, &ubuf, - &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer, +* CONFIG_CPU_HAS_MSA variant. Only lower 64 bits of FP context's +* general register slots are copied to buffer slots. +*/ +static int fpr_get_msa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +void **kbuf,void __user **ubuf) +{ +unsigned int i; +u64 fpr_val; +int err;for (i =0 ; i <NUM_FPU_REGS ; i++) { fpr_val =get_fpr64 (&target->thread.fpu.fpr[i],0 ); - err =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + err =user_regset_copyout (pos, count, kbuf, ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));if (err)
@@ -466,27 +477,54 @@ static int fpr_get(struct task_struct *target,return 0 ; } -static int fpr_set (struct task_struct *target, +/* Copy the floating-point context to the supplied NT_PRFPREG buffer. */ +static int fpr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count, -const void *kbuf,const void __user *ubuf) +void *kbuf,void __user *ubuf) { -unsigned i;int err; -u64 fpr_val;/* XXX fcr31 */ -init_fp_ctx (target); +if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) + err =fpr_get_fpa (target, &pos, &count, &kbuf, &ubuf); +else + err =fpr_get_msa (target, &pos, &count, &kbuf, &ubuf); + +return err; +} -if (sizeof (target->thread.fpu.fpr[i]) ==sizeof (elf_fpreg_t)) -return user_regset_copyin (&pos, &count, &kbuf, &ubuf, - &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context, +* !CONFIG_CPU_HAS_MSA variant. Buffer slots correspond 1:1 to FP +* context's general register slots. +*/ +static int fpr_set_fpa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +const void **kbuf,const void __user **ubuf) +{ +return user_regset_copyin (pos, count, kbuf, ubuf, + &target->thread.fpu, +0 ,sizeof (elf_fpregset_t)); +} + +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context, +* CONFIG_CPU_HAS_MSA variant. Buffer slots are copied to lower 64 +* bits only of FP context's general register slots. +*/ +static int fpr_set_msa (struct task_struct *target, +unsigned int *pos,unsigned int *count, +const void **kbuf,const void __user **ubuf) +{ +unsigned int i; +u64 fpr_val; +int err;BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t)); -for (i =0 ; i <NUM_FPU_REGS && count >=sizeof (elf_fpreg_t); i++) { - err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, +for (i =0 ; i <NUM_FPU_REGS && *count >=sizeof (elf_fpreg_t); i++) { + err =user_regset_copyin (pos, count, kbuf, ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));if (err)
@@ -497,6 +535,26 @@ static int fpr_set(struct task_struct *target,return 0 ; } +/* Copy the supplied NT_PRFPREG buffer to the floating-point context. */ +static int fpr_set (struct task_struct *target, +const struct user_regset *regset, +unsigned int pos,unsigned int count, +const void *kbuf,const void __user *ubuf) +{ +int err; + +/* XXX fcr31 */ + +init_fp_ctx (target); + +if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) + err =fpr_set_fpa (target, &pos, &count, &kbuf, &ubuf); +else + err =fpr_set_msa (target, &pos, &count, &kbuf, &ubuf); + +return err; +} +enum mips_regset {REGSET_GPR ,REGSET_FPR ,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: pcm: Abort properly at pending signal in OSS read/write loops
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 29159a4ed7044c52e3e2cf1a9fb55cec4745c60b ]
The loops for read and write in PCM OSS emulation have no proper check of pending signals, and they keep processing even after user tries to break. This results in a very long delay, often seen as RCU stall when a huge unprocessed bytes remain queued. The bug could be easily triggered by syzkaller.
As a simple workaround, this patch adds the proper check of pending signals and aborts the loop appropriately.
--- sound/core/oss/pcm_oss.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/core/oss/pcm_oss.c +8 -0
@@ -1416,6 +1416,10 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha tmp != runtime->oss.period_bytes)break ; } +if (signal_pending (current)) { + tmp = -ERESTARTSYS ; + goto err; + } }mutex_unlock (&runtime->oss.params_lock);return xfer;
@@ -1501,6 +1505,10 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use bytes -= tmp; xfer += tmp; } +if (signal_pending (current)) { + tmp = -ERESTARTSYS ; + goto err; + } }mutex_unlock (&runtime->oss.params_lock);return xfer;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] MIPS: Guard against any partial write attempt with PTRACE_SETREGSET
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dc24d0edf33c3e15099688b6bbdf7bdc24bf6e91 ]
Complement commit d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset write") and ensure that no partial register write attempt is made with PTRACE_SETREGSET, as we do not preinitialize any temporaries used to hold incoming register data and consequently random data could be written.
It is the responsibility of the caller, such as `ptrace_regset', to arrange for writes to span whole registers only, so here we only assert that it has indeed happened.
Patchwork: https://patchwork.linux-mips.org/patch/17926/
--- arch/mips/kernel/ptrace.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +11 -1
@@ -535,7 +535,15 @@ static int fpr_set_msa(struct task_struct *target,return 0 ; } -/* Copy the supplied NT_PRFPREG buffer to the floating-point context. */ +/* +* Copy the supplied NT_PRFPREG buffer to the floating-point context. +* +* We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', +* which is supposed to have been guaranteed by the kernel before +* calling us, e.g. in `ptrace_regset'. We enforce that requirement, +* so that we can safely avoid preinitializing temporaries for +* partial register writes. +*/ static int fpr_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count,
@@ -543,6 +551,8 @@ static int fpr_set(struct task_struct *target, {int err; +BUG_ON (count %sizeof (elf_fpreg_t)); +/* XXX fcr31 */ init_fp_ctx (target);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] MIPS: Consistently handle buffer counter with PTRACE_SETREGSET
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 80b3ffce0196ea50068885d085ff981e4b8396f4 ]
Update commit d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset write") bug and consistently consume all data supplied to `fpr_set_msa' with the ptrace(2) PTRACE_SETREGSET request, such that a zero data buffer counter is returned where insufficient data has been given to fill a whole number of FP general registers.
In reality this is not going to happen, as the caller is supposed to only supply data covering a whole number of registers and it is verified in ptrace_regset' and again asserted in fpr_set', however structuring code such that the presence of trailing partial FP general register data causes `fpr_set_msa' to return with a non-zero data buffer counter makes it appear that this trailing data will be used if there are subsequent writes made to FP registers, which is going to be the case with the FCSR once the missing write to that register has been fixed.
Patchwork: https://patchwork.linux-mips.org/patch/17927/
--- arch/mips/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +1 -1
@@ -523,7 +523,7 @@ static int fpr_set_msa(struct task_struct *target,int err;BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t)); -for (i =0 ; i <NUM_FPU_REGS && *count >=sizeof (elf_fpreg_t); i++) { +for (i =0 ; i <NUM_FPU_REGS && *count >0 ; i++) { err =user_regset_copyin (pos, count, kbuf, ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: pcm: Allow aborting mutex lock at OSS read/write loops
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 900498a34a3ac9c611e9b425094c8106bdd7dc1c ]
PCM OSS read/write loops keep taking the mutex lock for the whole read/write, and this might take very long when the exceptionally high amount of data is given. Also, since it invokes with mutex_lock(), the concurrent read/write becomes unbreakable.
This patch tries to address these issues by replacing mutex_lock() with mutex_lock_interruptible(), and also splits / re-takes the lock at each read/write period chunk, so that it can switch the context more finely if requested.
--- sound/core/oss/pcm_oss.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)
sound/core/oss/pcm_oss.c +21 -15
@@ -1369,8 +1369,11 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const chaif ((tmp =snd_pcm_oss_make_ready (substream)) <0 )return tmp; -mutex_lock (&runtime->oss.params_lock);while (bytes >0 ) { +if (mutex_lock_interruptible (&runtime->oss.params_lock)) { + tmp = -ERESTARTSYS ; +break ; + }if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used >0 ) { tmp = bytes;if (tmp + runtime->oss.buffer_used > runtime->oss.period_bytes)
@@ -1414,18 +1417,18 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha xfer += tmp;if ((substream->f_flags &O_NONBLOCK ) !=0 && tmp != runtime->oss.period_bytes) -break ; + tmp = -EAGAIN ; } + err: +mutex_unlock (&runtime->oss.params_lock); +if (tmp <0 ) +break ;if (signal_pending (current)) { tmp = -ERESTARTSYS ; - goto err; +break ; } + tmp =0 ; } -mutex_unlock (&runtime->oss.params_lock); -return xfer; - - err: -mutex_unlock (&runtime->oss.params_lock);return xfer >0 ? (snd_pcm_sframes_t )xfer : tmp; }
@@ -1473,8 +1476,11 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __useif ((tmp =snd_pcm_oss_make_ready (substream)) <0 )return tmp; -mutex_lock (&runtime->oss.params_lock);while (bytes >0 ) { +if (mutex_lock_interruptible (&runtime->oss.params_lock)) { + tmp = -ERESTARTSYS ; +break ; + }if (bytes < runtime->oss.period_bytes || runtime->oss.buffer_used >0 ) {if (runtime->oss.buffer_used ==0 ) { tmp =snd_pcm_oss_read2 (substream, runtime->oss.buffer, runtime->oss.period_bytes,1 );
@@ -1505,16 +1511,16 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use bytes -= tmp; xfer += tmp; } + err: +mutex_unlock (&runtime->oss.params_lock); +if (tmp <0 ) +break ;if (signal_pending (current)) { tmp = -ERESTARTSYS ; - goto err; +break ; } + tmp =0 ; } -mutex_unlock (&runtime->oss.params_lock); -return xfer; - - err: -mutex_unlock (&runtime->oss.params_lock);return xfer >0 ? (snd_pcm_sframes_t )xfer : tmp; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit be07a6a1188372b6d19a3307ec33211fc9c9439d ]
Fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset") public API regression, then activated by commit 1db1af84d6df ("MIPS: Basic MSA context switching support"), that caused the FCSR register not to be read or written for CONFIG_CPU_HAS_MSA kernel configurations (regardless of actual presence or absence of the MSA feature in a given processor) with ptrace(2) PTRACE_GETREGSET and PTRACE_SETREGSET requests nor recorded in core dumps.
This is because with !CONFIG_CPU_HAS_MSA configurations the whole of `elf_fpregset_t' array is bulk-copied as it is, which includes the FCSR in one half of the last, 33rd slot, whereas with CONFIG_CPU_HAS_MSA configurations array elements are copied individually, and then only the leading 32 FGR slots while the remaining slot is ignored.
Correct the code then such that only FGR slots are copied in the respective !MSA and MSA helpers an then the FCSR slot is handled separately in common code. Use `ptrace_setfcr31' to update the FCSR too, so that the read-only mask is respected.
Retrieving a correct value of FCSR is important in debugging not only for the human to be able to get the right interpretation of the situation, but for correct operation of GDB as well. This is because the condition code bits in FSCR are used by GDB to determine the location to place a breakpoint at when single-stepping through an FPU branch instruction. If such a breakpoint is placed incorrectly (i.e. with the condition reversed), then it will be missed, likely causing the debuggee to run away from the control of GDB and consequently breaking the process of investigation.
Fortunately GDB continues using the older PTRACE_GETFPREGS ptrace(2) request which is unaffected, so the regression only really hits with post-mortem debug sessions using a core dump file, in which case execution, and consequently single-stepping through branches is not possible. Of course core files created by buggy kernels out there will have the value of FCSR recorded clobbered, but such core files cannot be corrected and the person using them simply will have to be aware that the value of FCSR retrieved is not reliable.
Which also means we can likely get away without defining a replacement API which would ensure a correct value of FSCR to be retrieved, or none at all.
This is based on previous work by Alex Smith, extensively rewritten.
Patchwork: https://patchwork.linux-mips.org/patch/17928/
--- arch/mips/kernel/ptrace.c | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)
arch/mips/kernel/ptrace.c +36 -11
@@ -441,7 +441,7 @@ static int gpr64_set(struct task_struct *target,/* * Copy the floating-point context to the supplied NT_PRFPREG buffer, * !CONFIG_CPU_HAS_MSA variant. FP context's general register slots -* correspond 1:1 to buffer slots. +* correspond 1:1 to buffer slots. Only general registers are copied. */ static int fpr_get_fpa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -449,13 +449,14 @@ static int fpr_get_fpa(struct task_struct *target, {return user_regset_copyout (pos, count, kbuf, ubuf, &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +0 ,NUM_FPU_REGS *sizeof (elf_fpreg_t)); }/* * Copy the floating-point context to the supplied NT_PRFPREG buffer, * CONFIG_CPU_HAS_MSA variant. Only lower 64 bits of FP context's -* general register slots are copied to buffer slots. +* general register slots are copied to buffer slots. Only general +* registers are copied. */ static int fpr_get_msa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -477,20 +478,29 @@ static int fpr_get_msa(struct task_struct *target,return 0 ; } -/* Copy the floating-point context to the supplied NT_PRFPREG buffer. */ +/* +* Copy the floating-point context to the supplied NT_PRFPREG buffer. +* Choose the appropriate helper for general registers, and then copy +* the FCSR register separately. +*/ static int fpr_get (struct task_struct *target,const struct user_regset *regset,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf) { +const int fcr31_pos =NUM_FPU_REGS *sizeof (elf_fpreg_t);int err; -/* XXX fcr31 */ -if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) err =fpr_get_fpa (target, &pos, &count, &kbuf, &ubuf);else err =fpr_get_msa (target, &pos, &count, &kbuf, &ubuf); +if (err) +return err; + + err =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &target->thread.fpu.fcr31, + fcr31_pos, fcr31_pos +sizeof (u32));return err; }
@@ -498,7 +508,7 @@ static int fpr_get(struct task_struct *target,/* * Copy the supplied NT_PRFPREG buffer to the floating-point context, * !CONFIG_CPU_HAS_MSA variant. Buffer slots correspond 1:1 to FP -* context's general register slots. +* context's general register slots. Only general registers are copied. */ static int fpr_set_fpa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -506,13 +516,14 @@ static int fpr_set_fpa(struct task_struct *target, {return user_regset_copyin (pos, count, kbuf, ubuf, &target->thread.fpu, -0 ,sizeof (elf_fpregset_t)); +0 ,NUM_FPU_REGS *sizeof (elf_fpreg_t)); }/* * Copy the supplied NT_PRFPREG buffer to the floating-point context, * CONFIG_CPU_HAS_MSA variant. Buffer slots are copied to lower 64 -* bits only of FP context's general register slots. +* bits only of FP context's general register slots. Only general +* registers are copied. */ static int fpr_set_msa(struct task_struct *target, unsigned int *pos, unsigned int *count,
@@ -537,6 +548,8 @@ static int fpr_set_msa(struct task_struct *target,/* * Copy the supplied NT_PRFPREG buffer to the floating-point context. +* Choose the appropriate helper for general registers, and then copy +* the FCSR register separately. * * We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', * which is supposed to have been guaranteed by the kernel before
@@ -549,18 +562,30 @@ static int fpr_set(struct task_struct *target, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { + const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t); +u32 fcr31;int err;BUG_ON (count %sizeof (elf_fpreg_t)); -/* XXX fcr31 */ -init_fp_ctx (target);if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t)) err =fpr_set_fpa (target, &pos, &count, &kbuf, &ubuf);else err =fpr_set_msa (target, &pos, &count, &kbuf, &ubuf); +if (err) +return err; + +if (count >0 ) { + err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, + &fcr31, + fcr31_pos, fcr31_pos +sizeof (u32)); +if (err) +return err; + +ptrace_setfcr31 (target, fcr31); + }return err; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: aloop: Release cable upon open error path
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9685347aa0a5c2869058ca6ab79fd8e93084a67f ]
The aloop runtime object and its assignment in the cable are left even when opening a substream fails. This doesn't mean any memory leak, but it still keeps the invalid pointer that may be referred by the another side of the cable spontaneously, which is a potential Oops cause.
Clean up the cable assignment and the empty cable upon the error path properly.
--- sound/drivers/aloop.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-)
sound/drivers/aloop.c +25 -13
@@ -658,12 +658,31 @@ static int rule_channels(struct snd_pcm_hw_params *params,return snd_interval_refine (hw_param_interval (params, rule->var), &t); } +static void free_cable (struct snd_pcm_substream *substream) +{ +struct loopback *loopback = substream->private_data; +int dev =get_cable_index (substream); +struct loopback_cable *cable; + + cable = loopback->cables[substream->number][dev]; +if (!cable) +return ; +if (cable->streams[!substream->stream]) { +/* other stream is still alive */ + cable->streams[substream->stream] =NULL ; + }else { +/* free the cable */ + loopback->cables[substream->number][dev] =NULL ; +kfree (cable); + } +} +static int loopback_open (struct snd_pcm_substream *substream) {struct snd_pcm_runtime *runtime = substream->runtime;struct loopback *loopback = substream->private_data;struct loopback_pcm *dpcm; -struct loopback_cable *cable; +struct loopback_cable *cable =NULL ;int err =0 ;int dev =get_cable_index (substream);
@@ -682,7 +701,6 @@ static int loopback_open(struct snd_pcm_substream *substream)if (!cable) { cable =kzalloc (sizeof (*cable),GFP_KERNEL );if (!cable) { -kfree (dpcm); err = -ENOMEM ; goto unlock; }
@@ -724,6 +742,10 @@ static int loopback_open(struct snd_pcm_substream *substream)else runtime->hw = cable->hw; unlock: +if (err <0 ) { +free_cable (substream); +kfree (dpcm); + }mutex_unlock (&loopback->cable_lock);return err; }
@@ -732,20 +754,10 @@ static int loopback_close(struct snd_pcm_substream *substream) {struct loopback *loopback = substream->private_data;struct loopback_pcm *dpcm = substream->runtime->private_data; -struct loopback_cable *cable; -int dev =get_cable_index (substream);loopback_timer_stop (dpcm);mutex_lock (&loopback->cable_lock); - cable = loopback->cables[substream->number][dev]; -if (cable->streams[!substream->stream]) { -/* other stream is still alive */ - cable->streams[substream->stream] =NULL ; - }else { -/* free the cable */ - loopback->cables[substream->number][dev] =NULL ; -kfree (cable); - } +free_cable (substream);mutex_unlock (&loopback->cable_lock);return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] MIPS: Also verify sizeof `elf_fpreg_t' with PTRACE_SETREGSET
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 006501e039eec411842bb3150c41358867d320c2 ]
Complement commit d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset write") and like with the PTRACE_GETREGSET ptrace(2) request also apply a BUILD_BUG_ON check for the size of the `elf_fpreg_t' type in the PTRACE_SETREGSET request handler.
Patchwork: https://patchwork.linux-mips.org/patch/17929/
--- arch/mips/kernel/ptrace.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/ptrace.c +1 -0
@@ -466,6 +466,7 @@ static int fpr_get_msa(struct task_struct *target,u64 fpr_val;int err; +BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t));for (i =0 ; i <NUM_FPU_REGS ; i++) { fpr_val =get_fpr64 (&target->thread.fpu.fpr[i],0 ); err = user_regset_copyout(pos, count, kbuf, ubuf,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c8c5a3a24d395b14447a9a89d61586a913840a3b ]
Complement commit c23b3d1a5311 ("MIPS: ptrace: Change GP regset to use correct core dump register layout") and also reject outsized PTRACE_SETREGSET requests to the NT_PRFPREG regset, like with the NT_PRSTATUS regset.
Patchwork: https://patchwork.linux-mips.org/patch/17930/
--- arch/mips/kernel/ptrace.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/kernel/ptrace.c +3 -0
@@ -569,6 +569,9 @@ static int fpr_set(struct task_struct *target,BUG_ON (count %sizeof (elf_fpreg_t)); +if (pos + count >sizeof (elf_fpregset_t)) +return -EIO ; +init_fp_ctx (target);if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t))
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: aloop: Fix inconsistent format due to incomplete rule
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b088b53e20c7d09b5ab84c5688e609f478e5c417 ]
The extra hw constraint rule for the formats the aloop driver introduced has a slight flaw, where it doesn't return a positive value when the mask got changed. It came from the fact that it's basically a copy&paste from snd_hw_constraint_mask64(). The original code is supposed to be a single-shot and it modifies the mask bits only once and never after, while what we need for aloop is the dynamic hw rule that limits the mask bits.
This difference results in the inconsistent state, as the hw_refine doesn't apply the dependencies fully. The worse and surprisingly result is that it causes a crash in OSS emulation when multiple full-duplex reads/writes are performed concurrently (I leave why it triggers Oops to readers as a homework).
For fixing this, replace a few open-codes with the standard snd_mask_*() macros.
--- sound/drivers/aloop.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
sound/drivers/aloop.c +6 -7
@@ -39,6 +39,7 @@#include <sound/core.h> #include <sound/control.h> #include <sound/pcm.h> +#include <sound/pcm_params.h> #include <sound/info.h> #include <sound/initval.h>
@@ -622,14 +623,12 @@ static int rule_format(struct snd_pcm_hw_params *params, {struct snd_pcm_hardware *hw = rule->private; -struct snd_mask *maskp =hw_param_mask (params, rule->var); +struct snd_mask m; - maskp->bits[0 ] &= (u_int32_t )hw->formats; - maskp->bits[1 ] &= (u_int32_t)(hw->formats >>32 ); -memset (maskp->bits +2 ,0 , (SNDRV_MASK_MAX -64 ) /8 );/* clear rest */ -if (! maskp->bits[0 ] && ! maskp->bits[1 ]) -return -EINVAL ; -return 0 ; +snd_mask_none (&m); + m.bits[0 ] = (u_int32_t )hw->formats; + m.bits[1 ] = (u_int32_t)(hw->formats >>32 ); +return snd_mask_refine (hw_param_mask (params, rule->var), &m); } static int rule_rate(struct snd_pcm_hw_params *params,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] kvm: vmx: Scrub hardware GPRs at VM-exit
In reply to Sasha LevinFrom: Jim Mattson <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0cb5b30698fdc8f6b4646012e3acb4ddce430788 ]
Guest GPR values are live in the hardware GPRs at VM-exit. Do not leave any guest values in hardware GPRs after the guest GPR values are saved to the vcpu_vmx structure.
This is a partial mitigation for CVE 2017-5715 and CVE 2017-5753. Specifically, it defeats the Project Zero PoC for CVE 2017-5715.
--- arch/x86/kvm/svm.c | 19 +++++++++++++++++++ arch/x86/kvm/vmx.c | 14 +++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-)
arch/x86/kvm/svm.c +19 -0
@@ -3947,6 +3947,25 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)"mov %%r13, %c[r13](%[svm]) \n\t" "mov %%r14, %c[r14](%[svm]) \n\t" "mov %%r15, %c[r15](%[svm]) \n\t" +#endif +/* +* Clear host registers marked as clobbered to prevent +* speculative use. +*/ +"xor %%" _ASM_BX", %%" _ASM_BX" \n\t" +"xor %%" _ASM_CX", %%" _ASM_CX" \n\t" +"xor %%" _ASM_DX", %%" _ASM_DX" \n\t" +"xor %%" _ASM_SI", %%" _ASM_SI" \n\t" +"xor %%" _ASM_DI", %%" _ASM_DI" \n\t" +#ifdef CONFIG_X86_64 +"xor %%r8, %%r8 \n\t" +"xor %%r9, %%r9 \n\t" +"xor %%r10, %%r10 \n\t" +"xor %%r11, %%r11 \n\t" +"xor %%r12, %%r12 \n\t" +"xor %%r13, %%r13 \n\t" +"xor %%r14, %%r14 \n\t" +"xor %%r15, %%r15 \n\t" #endif "pop %%" _ASM_BP :
arch/x86/kvm/vmx.c +13 -1
@@ -8252,6 +8252,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)/* Save guest registers, load host registers, keep flags */ "mov %0, %c[wordsize](%%" _ASM_SP") \n\t" "pop %0 \n\t" +"setbe %c[fail](%0)\n\t" "mov %%" _ASM_AX", %c[rax](%0) \n\t" "mov %%" _ASM_BX", %c[rbx](%0) \n\t" __ASM_SIZE(pop) " %c[rcx](%0) \n\t"
@@ -8268,12 +8269,23 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)"mov %%r13, %c[r13](%0) \n\t" "mov %%r14, %c[r14](%0) \n\t" "mov %%r15, %c[r15](%0) \n\t" +"xor %%r8d, %%r8d \n\t" +"xor %%r9d, %%r9d \n\t" +"xor %%r10d, %%r10d \n\t" +"xor %%r11d, %%r11d \n\t" +"xor %%r12d, %%r12d \n\t" +"xor %%r13d, %%r13d \n\t" +"xor %%r14d, %%r14d \n\t" + "xor %%r15d, %%r15d \n\t"#endif "mov %%cr2, %%" _ASM_AX" \n\t" "mov %%" _ASM_AX", %c[cr2](%0) \n\t" +"xor %%eax, %%eax \n\t" +"xor %%ebx, %%ebx \n\t" +"xor %%esi, %%esi \n\t" +"xor %%edi, %%edi \n\t" "pop %%" _ASM_BP"; pop %%" _ASM_DX" \n\t" -"setbe %c[fail](%0) \n\t" ".pushsection .rodata \n\t" ".global vmx_return \n\t" "vmx_return: " _ASM_PTR" 2b \n\t"
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: pcm: Remove incorrect snd_BUG_ON() usages
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fe08f34d066f4404934a509b6806db1a4f700c86 ]
syzkaller triggered kernel warnings through PCM OSS emulation at closing a stream:
WARNING: CPU: 0 PID: 3502 at sound/core/pcm_lib.c:1635 snd_pcm_hw_param_first+0x289/0x690 sound/core/pcm_lib.c:1635 Call Trace: .... snd_pcm_hw_param_near.constprop.27+0x78d/0x9a0 sound/core/oss/pcm_oss.c:457 snd_pcm_oss_change_params+0x17d3/0x3720 sound/core/oss/pcm_oss.c:969 snd_pcm_oss_make_ready+0xaa/0x130 sound/core/oss/pcm_oss.c:1128 snd_pcm_oss_sync+0x257/0x830 sound/core/oss/pcm_oss.c:1638 snd_pcm_oss_release+0x20b/0x280 sound/core/oss/pcm_oss.c:2431 __fput+0x327/0x7e0 fs/file_table.c:210 ....
This happens while it tries to open and set up the aloop device concurrently. The warning above (invoked from snd_BUG_ON() macro) is to detect the unexpected logical error where snd_pcm_hw_refine() call shouldn't fail. The theory is true for the case where the hw_params config rules are static. But for an aloop device, the hw_params rule condition does vary dynamically depending on the connected target; when another device is opened and changes the parameters, the device connected in another side is also affected, and it caused the error from snd_pcm_hw_refine().
That is, the simplest "solution" for this is to remove the incorrect assumption of static rules, and treat such an error as a normal error path. As there are a couple of other places using snd_BUG_ON() incorrectly, this patch removes these spurious snd_BUG_ON() calls.
--- sound/core/oss/pcm_oss.c | 1 - sound/core/pcm_lib.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
sound/core/oss/pcm_oss.c +0 -1
@@ -465,7 +465,6 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm, v =snd_pcm_hw_param_last (pcm, params, var, dir); else v =snd_pcm_hw_param_first (pcm, params, var, dir); -snd_BUG_ON (v <0 );return v; }
sound/core/pcm_lib.c +2 -2
@@ -1663,7 +1663,7 @@ int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm,return changed;if (params->rmask) {int err =snd_pcm_hw_refine (pcm, params); -if (snd_BUG_ON (err <0 )) +if (err <0 )return err; }return snd_pcm_hw_param_value (params, var, dir);
@@ -1710,7 +1710,7 @@ int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm,return changed;if (params->rmask) {int err =snd_pcm_hw_refine (pcm, params); -if (snd_BUG_ON (err <0 )) +if (err <0 )return err; }return snd_pcm_hw_param_value (params, var, dir);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ALSA: aloop: Fix racy hw constraints adjustment
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 898dfe4687f460ba337a01c11549f87269a13fa2 ]
The aloop driver tries to update the hw constraints of the connected target on the cable of the opened PCM substream. This is done by adding the extra hw constraints rules referring to the substream runtime->hw fields, while the other substream may update the runtime hw of another side on the fly.
This is, however, racy and may result in the inconsistent values when both PCM streams perform the prepare concurrently. One of the reason is that it overwrites the other's runtime->hw field; which is not only racy but also broken when it's called before the open of another side finishes. And, since the reference to runtime->hw isn't protected, the concurrent write may give the partial value update and become inconsistent.
This patch is an attempt to fix and clean up:
- The prepare doesn't change the runtime->hw of other side any longer, but only update the cable->hw that is referred commonly.
- The extra rules refer to the loopback_pcm object instead of the runtime->hw. The actual hw is deduced from cable->hw.
- The extra rules take the cable_lock to protect against the race.
--- sound/drivers/aloop.c | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-)
sound/drivers/aloop.c +21 -30
@@ -306,19 +306,6 @@ static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)return 0 ; } -static void params_change_substream (struct loopback_pcm *dpcm, -struct snd_pcm_runtime *runtime) -{ -struct snd_pcm_runtime *dst_runtime; - -if (dpcm ==NULL || dpcm->substream ==NULL ) -return ; - dst_runtime = dpcm->substream->runtime; -if (dst_runtime ==NULL ) -return ; - dst_runtime->hw = dpcm->cable->hw; -} -static void params_change (struct snd_pcm_substream *substream) {struct snd_pcm_runtime *runtime = substream->runtime;
@@ -330,10 +317,6 @@ static void params_change(struct snd_pcm_substream *substream) cable->hw.rate_max = runtime->rate; cable->hw.channels_min = runtime->channels; cable->hw.channels_max = runtime->channels; -params_change_substream (cable->streams[SNDRV_PCM_STREAM_PLAYBACK ], - runtime); -params_change_substream (cable->streams[SNDRV_PCM_STREAM_CAPTURE ], - runtime); }static int loopback_prepare (struct snd_pcm_substream *substream)
@@ -621,24 +604,29 @@ static unsigned int get_cable_index(struct snd_pcm_substream *substream)static int rule_format (struct snd_pcm_hw_params *params,struct snd_pcm_hw_rule *rule) { - -struct snd_pcm_hardware *hw = rule->private; +struct loopback_pcm *dpcm = rule->private; +struct loopback_cable *cable = dpcm->cable;struct snd_mask m;snd_mask_none (&m); - m.bits[0 ] = (u_int32_t )hw->formats; - m.bits[1 ] = (u_int32_t)(hw->formats >>32 ); +mutex_lock (&dpcm->loopback->cable_lock); + m.bits[0 ] = (u_int32_t )cable->hw.formats; + m.bits[1 ] = (u_int32_t)(cable->hw.formats >>32 ); +mutex_unlock (&dpcm->loopback->cable_lock);return snd_mask_refine (hw_param_mask (params, rule->var), &m); }static int rule_rate (struct snd_pcm_hw_params *params,struct snd_pcm_hw_rule *rule) { -struct snd_pcm_hardware *hw = rule->private; +struct loopback_pcm *dpcm = rule->private; +struct loopback_cable *cable = dpcm->cable;struct snd_interval t; - t.min = hw->rate_min; - t.max = hw->rate_max; +mutex_lock (&dpcm->loopback->cable_lock); + t.min = cable->hw.rate_min; + t.max = cable->hw.rate_max; +mutex_unlock (&dpcm->loopback->cable_lock); t.openmin = t.openmax =0 ; t.integer =0 ;return snd_interval_refine (hw_param_interval (params, rule->var), &t);
@@ -647,11 +635,14 @@ static int rule_rate(struct snd_pcm_hw_params *params,static int rule_channels (struct snd_pcm_hw_params *params,struct snd_pcm_hw_rule *rule) { -struct snd_pcm_hardware *hw = rule->private; +struct loopback_pcm *dpcm = rule->private; +struct loopback_cable *cable = dpcm->cable;struct snd_interval t; - t.min = hw->channels_min; - t.max = hw->channels_max; +mutex_lock (&dpcm->loopback->cable_lock); + t.min = cable->hw.channels_min; + t.max = cable->hw.channels_max; +mutex_unlock (&dpcm->loopback->cable_lock); t.openmin = t.openmax =0 ; t.integer =0 ;return snd_interval_refine (hw_param_interval (params, rule->var), &t);
@@ -717,19 +708,19 @@ static int loopback_open(struct snd_pcm_substream *substream)/* are cached -> they do not reflect the actual state */ err =snd_pcm_hw_rule_add (runtime,0 ,SNDRV_PCM_HW_PARAM_FORMAT , - rule_format, &runtime->hw, + rule_format, dpcm,SNDRV_PCM_HW_PARAM_FORMAT ,-1 );if (err <0 ) goto unlock; err =snd_pcm_hw_rule_add (runtime,0 ,SNDRV_PCM_HW_PARAM_RATE , - rule_rate, &runtime->hw, + rule_rate, dpcm,SNDRV_PCM_HW_PARAM_RATE ,-1 );if (err <0 ) goto unlock; err =snd_pcm_hw_rule_add (runtime,0 ,SNDRV_PCM_HW_PARAM_CHANNELS , - rule_channels, &runtime->hw, + rule_channels, dpcm,SNDRV_PCM_HW_PARAM_CHANNELS ,-1 );if (err <0 ) goto unlock;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] mm/page-writeback: fix dirty_ratelimit calculation
In reply to Sasha LevinFrom: Andrey Ryabinin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d59b1087a98e402ed9a7cc577f4da435f9a555f5 ]
Calculation of dirty_ratelimit sometimes is not correct. E.g. initial values of dirty_ratelimit == INIT_BW and step == 0, lead to the following result:
UBSAN: Undefined behaviour in ../mm/page-writeback.c:1286:7 shift exponent 25600 is too large for 64-bit type 'long unsigned int'
The fix is straightforward - make step 0 if the shift exponent is too big.
--- mm/page-writeback.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
mm/page-writeback.c +6 -5
@@ -967,6 +967,7 @@ static void bdi_update_dirty_ratelimit(struct backing_dev_info *bdi,unsigned long pos_ratio;unsigned long step;unsigned long x; +unsigned long shift;/* * The dirty rate will match the writeout rate in long term, except
@@ -1094,11 +1095,11 @@ static void bdi_update_dirty_ratelimit(struct backing_dev_info *bdi,* rate itself is constantly fluctuating. So decrease the track speed * when it gets close to the target. Helps eliminate pointless tremors. */ - step >>= dirty_ratelimit / (2 * step +1 ); -/* -* Limit the tracking speed to avoid overshooting. -*/ - step = (step +7 ) /8 ; + shift = dirty_ratelimit / (2 * step +1 ); +if (shift <BITS_PER_LONG ) + step =DIV_ROUND_UP (step >> shift,8 ); +else + step =0 ;if (dirty_ratelimit < balanced_dirty_ratelimit) dirty_ratelimit += step;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] locks: don't check for race with close when setting OFD lock
In reply to Sasha LevinFrom: Jeff Layton <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0752ba807b04ccd69cb4bc8bbf829a80ee208a3c ]
We don't clean out OFD locks on close(), so there's no need to check for a race with them here. They'll get cleaned out at the same time that flock locks are.
--- fs/locks.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
fs/locks.c +10 -6
@@ -2192,10 +2192,12 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, error =do_lock_file_wait (filp, cmd, file_lock);/* -* Attempt to detect a close/fcntl race and recover by -* releasing the lock that was just acquired. +* Attempt to detect a close/fcntl race and recover by releasing the +* lock that was just acquired. There is no need to do that when we're +* unlocking though, or for OFD locks. */ -if (!error && file_lock->fl_type !=F_UNLCK ) { +if (!error && file_lock->fl_type !=F_UNLCK && + !(file_lock->fl_flags &FL_OFDLCK )) {/* * We need that spin_lock here - it prevents reordering between * update of i_flctx->flc_posix and check for it done in
@@ -2334,10 +2336,12 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, error =do_lock_file_wait (filp, cmd, file_lock);/* -* Attempt to detect a close/fcntl race and recover by -* releasing the lock that was just acquired. +* Attempt to detect a close/fcntl race and recover by releasing the +* lock that was just acquired. There is no need to do that when we're +* unlocking though, or for OFD locks. */ -if (!error && file_lock->fl_type !=F_UNLCK ) { +if (!error && file_lock->fl_type !=F_UNLCK && + !(file_lock->fl_flags &FL_OFDLCK )) {/* * We need that spin_lock here - it prevents reordering between * update of i_flctx->flc_posix and check for it done in
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] [media] usbvision fix overflow of interfaces array
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 588afcc1c0e45358159090d95bf7b246fb67565f ]
This fixes the crash reported in:
http://seclists.org/bugtraq/2015/Oct/35
The interface number needs a sanity check.
--- drivers/media/usb/usbvision/usbvision-video.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/usb/usbvision/usbvision-video.c +7 -0
@@ -1522,6 +1522,13 @@ static int usbvision_probe(struct usb_interface *intf,printk (KERN_INFO "%s: %s found\n" , __func__, usbvision_device_data[model].model_string); +/* +* this is a security check. +* an exploit using an incorrect bInterfaceNumber is known +*/ +if (ifnum >=USB_MAXINTERFACES || !dev->actconfig->interface[ifnum]) +return -ENODEV ; +if (usbvision_device_data[model].interface >=0 ) interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0 ];else if (ifnum < dev->actconfig->desc.bNumInterfaces)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] futex: Replace barrier() in unqueue_me() with READ_ONCE()
In reply to Sasha LevinFrom: Jianyu Zhan <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 29b75eb2d56a714190a93d7be4525e617591077a ]
Commit e91467ecd1ef ("bug in futex unqueue_me") introduced a barrier() in unqueue_me() to prevent the compiler from rereading the lock pointer which might change after a check for NULL.
Replace the barrier() with a READ_ONCE() for the following reasons:
1) READ_ONCE() is a weaker form of barrier() that affects only the specific load operation, while barrier() is a general compiler level memory barrier. READ_ONCE() was not available at the time when the barrier was added.
2) Aside of that READ_ONCE() is descriptive and self explainatory while a barrier without comment is not clear to the casual reader.
No functional change.
[ tglx: Massaged changelog ]
--- kernel/futex.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/futex.c +6 -2
@@ -1831,8 +1831,12 @@ static int unqueue_me(struct futex_q *q)/* In the common case we don't take the spinlock, which is nice. */ retry: - lock_ptr = q->lock_ptr; -barrier (); +/* +* q->lock_ptr can change between this read and the following spin_lock. +* Use READ_ONCE to forbid the compiler from reloading q->lock_ptr and +* optimizing lock_ptr out of the logic below. +*/ + lock_ptr =READ_ONCE (q->lock_ptr);if (lock_ptr !=NULL ) {spin_lock (lock_ptr);/*
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] r8152: use test_and_clear_bit
In reply to Sasha LevinFrom: hayeswang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 216a8349d3a0dd1bc2afbcc821e374c8f929bd62 ]
Replace test_bit() followed by clear_bit() with test_and_clear_bit().
--- drivers/net/usb/r8152.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/net/usb/r8152.c +6 -14
@@ -1929,7 +1929,6 @@ static void _rtl8152_set_rx_mode(struct net_device *netdev)__le32 tmp[2 ];u32 ocp_data; -clear_bit (RTL8152_SET_RX_MODE , &tp->flags);netif_stop_queue (netdev); ocp_data =ocp_read_dword (tp,MCU_TYPE_PLA ,PLA_RCR ); ocp_data &= ~RCR_ACPT_ALL ;
@@ -2364,8 +2363,6 @@ static void rtl_phy_reset(struct r8152 *tp)u16 data;int i; -clear_bit (PHY_RESET , &tp->flags); - data =r8152_mdio_read (tp,MII_BMCR );/* don't reset again before the previous one complete */
@@ -2860,10 +2857,9 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex)r8152_mdio_write (tp,MII_ADVERTISE , anar);r8152_mdio_write (tp,MII_BMCR , bmcr); -if (test_bit (PHY_RESET , &tp->flags)) { +if (test_and_clear_bit (PHY_RESET , &tp->flags)) {int i; -clear_bit (PHY_RESET , &tp->flags);for (i =0 ; i <50 ; i++) {msleep (20 );if ((r8152_mdio_read (tp,MII_BMCR ) &BMCR_RESET ) ==0 )
@@ -2872,7 +2868,6 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) } out: -return ret; }
@@ -2928,7 +2923,6 @@ static void set_carrier(struct r8152 *tp)struct net_device *netdev = tp->netdev;u8 speed; -clear_bit (RTL8152_LINK_CHG , &tp->flags); speed =rtl8152_get_speed (tp);if (speed &LINK_STATUS ) {
@@ -2969,20 +2963,18 @@ static void rtl_work_func_t(struct work_struct *work) goto out1; } -if (test_bit (RTL8152_LINK_CHG , &tp->flags)) +if (test_and_clear_bit (RTL8152_LINK_CHG , &tp->flags))set_carrier (tp); -if (test_bit (RTL8152_SET_RX_MODE , &tp->flags)) +if (test_and_clear_bit (RTL8152_SET_RX_MODE , &tp->flags))_rtl8152_set_rx_mode (tp->netdev);/* don't schedule napi before linking */ -if (test_bit (SCHEDULE_NAPI , &tp->flags) && -netif_carrier_ok (tp->netdev)) { -clear_bit (SCHEDULE_NAPI , &tp->flags); +if (test_and_clear_bit (SCHEDULE_NAPI , &tp->flags) && +netif_carrier_ok (tp->netdev))napi_schedule (&tp->napi); - } -if (test_bit (PHY_RESET , &tp->flags)) +if (test_and_clear_bit (PHY_RESET , &tp->flags))rtl_phy_reset (tp);mutex_unlock (&tp->control);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sr9700: use skb_cow_head() to deal with cloned skbs
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d532c1082f68176363ed766d09bf187616e282fe ]
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/sr9700.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/usb/sr9700.c +2 -7
@@ -456,14 +456,9 @@ static struct sk_buff *sr9700_tx_fixup(struct usbnet *dev, struct sk_buff *skb, len = skb->len; -if (skb_headroom (skb) <SR_TX_OVERHEAD ) { -struct sk_buff *skb2; - - skb2 =skb_copy_expand (skb,SR_TX_OVERHEAD ,0 , flags); +if (skb_cow_head (skb,SR_TX_OVERHEAD )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; }__skb_push (skb,SR_TX_OVERHEAD );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] smsc75xx: use skb_cow_head() to deal with cloned skbs
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b7c6d2675899cfff0180412c63fc9cbd5bacdb4d ]
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/smsc75xx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/usb/smsc75xx.c +2 -6
@@ -2198,13 +2198,9 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev, {u32 tx_cmd_a, tx_cmd_b; -if (skb_headroom (skb) <SMSC75XX_TX_OVERHEAD ) { -struct sk_buff *skb2 = -skb_copy_expand (skb,SMSC75XX_TX_OVERHEAD ,0 , flags); +if (skb_cow_head (skb,SMSC75XX_TX_OVERHEAD )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; } tx_cmd_a = (u32)(skb->len &TX_CMD_A_LEN ) |TX_CMD_A_FCS ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] cx82310_eth: use skb_cow_head() to deal with cloned skbs
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a9e840a2081ed28c2b7caa6a9a0041c950b3c37d ]
We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers.
skb_cow_head() is the proper helper to deal with this.
--- drivers/net/usb/cx82310_eth.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/usb/cx82310_eth.c +2 -5
@@ -293,12 +293,9 @@ static struct sk_buff *cx82310_tx_fixup(struct usbnet *dev, struct sk_buff *skb, {int len = skb->len; -if (skb_headroom (skb) <2 ) { -struct sk_buff *skb2 =skb_copy_expand (skb,2 ,0 , flags); +if (skb_cow_head (skb,2 )) {dev_kfree_skb_any (skb); - skb = skb2; -if (!skb) -return NULL ; +return NULL ; }skb_push (skb,2 );
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] hwrng: core - sleep interruptible in read
In reply to Sasha LevinFrom: Jiri Slaby <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1ab87298cb59b649d8d648d25dc15b36ab865f5a ]
hwrng kthread can be waiting via hwrng_fillfn for some data from a rng like virtio-rng:
hwrng D ffff880093e17798 0 382 2 0x00000000
...
Call Trace: [<ffffffff817339c6>] wait_for_completion_killable+0x96/0x210 [<ffffffffa00aa1b7>] virtio_read+0x57/0xf0 [virtio_rng] [<ffffffff814f4a35>] hwrng_fillfn+0x75/0x130 [<ffffffff810aa243>] kthread+0xf3/0x110
And when some user program tries to read the /dev node in this state, we get:
rngd D ffff880093e17798 0 762 1 0x00000004
...
Call Trace: [<ffffffff817351ac>] mutex_lock_nested+0x15c/0x3e0 [<ffffffff814f478e>] rng_dev_read+0x6e/0x240 [<ffffffff81231958>] __vfs_read+0x28/0xe0 [<ffffffff81232393>] vfs_read+0x83/0x130
And this is indeed unkillable. So use mutex_lock_interruptible instead of mutex_lock in rng_dev_read and exit immediatelly when interrupted. And possibly return already read data, if any (as POSIX allows).
v2: use ERESTARTSYS instead of EINTR
--- drivers/char/hw_random/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/hw_random/core.c +5 -1
@@ -238,7 +238,10 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf, goto out; } -mutex_lock (&reading_mutex); +if (mutex_lock_interruptible (&reading_mutex)) { + err = -ERESTARTSYS ; + goto out_put; + }if (!data_avail) { bytes_read = rng_get_data(rng, rng_buffer, rng_buffer_size(),
@@ -288,6 +291,7 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf, out_unlock_reading:mutex_unlock (&reading_mutex); +out_put:put_rng (rng); goto out; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sysrq: Fix warning in sysrq generated crash.
In reply to Sasha LevinFrom: Ani Sinha <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 984cf355aeaa8f2eda3861b50d0e8d3e3f77e83b ]
Commit 984d74a72076a1 ("sysrq: rcu-ify __handle_sysrq") replaced spin_lock_irqsave() calls with rcu_read_lock() calls in sysrq. Since rcu_read_lock() does not disable preemption, faulthandler_disabled() in __do_page_fault() in x86/fault.c returns false. When the code later calls might_sleep() in the pagefault handler, we get the following warning:
BUG: sleeping function called from invalid context at ../arch/x86/mm/fault.c:1187
in_atomic(): 0, irqs_disabled(): 0, pid: 4706, name: bash Preemption disabled at:[<ffffffff81484339>] printk+0x48/0x4a
To fix this, we release the RCU read lock before we crash.
Tested this patch on linux 3.18 by booting off one of our boards.
--- drivers/tty/sysrq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tty/sysrq.c +6 -0
@@ -133,6 +133,12 @@ static void sysrq_handle_crash(int key) {char *killer =NULL ; +/* we need to release the RCU read lock here, +* otherwise we get an annoying +* 'BUG: sleeping function called from invalid context' +* complaint from the kernel before the panic. +*/ +rcu_read_unlock (); panic_on_oops =1 ;/* force panic */ wmb (); *killer =1 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] 8021q: fix a memory leak for VLAN 0 device
In reply to Sasha LevinFrom: Cong Wang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 78bbb15f2239bc8e663aa20bbe1987c91a0b75f6 ]
A vlan device with vid 0 is allow to creat by not able to be fully cleaned up by unregister_vlan_dev() which checks for vlan_id!=0.
Also, VLAN 0 is probably not a valid number and it is kinda "reserved" for HW accelerating devices, but it is probably too late to reject it from creation even if makes sense. Instead, just remove the check in unregister_vlan_dev().
--- net/8021q/vlan.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
net/8021q/vlan.c +1 -6
@@ -111,12 +111,7 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)vlan_gvrp_uninit_applicant (real_dev); } -/* Take it out of our own structures, but be sure to interlock with -* HW accelerating devices or SW vlan input packet processing if -* VLAN is not 0 (leave it there for 802.1p). -*/ -if (vlan_id) -vlan_vid_del (real_dev, vlan->vlan_proto, vlan_id); +vlan_vid_del (real_dev, vlan->vlan_proto, vlan_id);/* Get rid of the vlan's reference to real_dev */ dev_put (real_dev);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] RDS: null pointer dereference in rds_atomic_free_op
In reply to Sasha LevinFrom: Mohamed Ghannam <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7d11f77f84b27cef452cee332f4e469503084737 ]
set rm->atomic.op_active to 0 when rds_pin_pages() fails or the user supplied address is invalid,
this prevents a NULL pointer usage in rds_atomic_free_op()
--- net/rds/rdma.c | 1 + 1 file changed, 1 insertion(+)
net/rds/rdma.c +1 -0
@@ -866,6 +866,7 @@ int rds_cmsg_atomic(struct rds_sock *rs, struct rds_message *rm, err:if (page)put_page (page); + rm->atomic.op_active =0 ;kfree (rm->atomic.op_notifier);return ret;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sh_eth: fix TSU resource handling
In reply to Sasha LevinFrom: Sergei Shtylyov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dfe8266b8dd10e12a731c985b725fcf7f0e537f0 ]
When switching the driver to the managed device API, I managed to break the case of a dual Ether devices sharing a single TSU: the 2nd Ether port wouldn't probe. Iwamatsu-san has tried to fix this but his patch was buggy and he then dropped the ball...
The solution is to limit calling devm_request_mem_region() to the first of the two ports sharing the same TSU, so devm_ioremap_resource() can't be used anymore for the TSU resource...
--- drivers/net/ethernet/renesas/sh_eth.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +22 -3
@@ -3171,10 +3171,29 @@ static int sh_eth_drv_probe(struct platform_device *pdev)/* ioremap the TSU registers */ if (mdp->cd->tsu) {struct resource *rtsu; + rtsu =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); - mdp->tsu_addr =devm_ioremap_resource (&pdev->dev, rtsu); -if (IS_ERR (mdp->tsu_addr)) { - ret =PTR_ERR (mdp->tsu_addr); +if (!rtsu) { +dev_err (&pdev->dev,"no TSU resource\n" ); + ret = -ENODEV ; + goto out_release; + } +/* We can only request the TSU region for the first port +* of the two sharing this TSU for the probe to succeed... +*/ +if (devno %2 ==0 && + !devm_request_mem_region (&pdev->dev, rtsu->start, +resource_size (rtsu), +dev_name (&pdev->dev))) { +dev_err (&pdev->dev,"can't request TSU resource.\n" ); + ret = -EBUSY ; + goto out_release; + } + mdp->tsu_addr =devm_ioremap (&pdev->dev, rtsu->start, +resource_size (rtsu)); +if (!mdp->tsu_addr) { +dev_err (&pdev->dev,"TSU region ioremap() failed.\n" ); + ret = -ENOMEM ; goto out_release; } mdp->port = devno %2 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] RDS: Heap OOB write in rds_message_alloc_sgs()
In reply to Sasha LevinFrom: Mohamed Ghannam <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c095508770aebf1b9218e77026e48345d719b17c ]
When args->nr_local is 0, nr_pages gets also 0 due some size calculation via rds_rm_size(), which is later used to allocate pages for DMA, this bug produces a heap Out-Of-Bound write access to a specific memory region.
--- net/rds/rdma.c | 3 +++ 1 file changed, 3 insertions(+)
net/rds/rdma.c +3 -0
@@ -516,6 +516,9 @@ int rds_rdma_extra_size(struct rds_rdma_args *args) local_vec = (struct rds_iovec __user *)(unsigned long ) args->local_vec_addr; +if (args->nr_local ==0 ) +return -EINVAL ; +/* figure out the number of pages in the vector */ for (i =0 ; i < args->nr_local; i++) { if (copy_from_user(&vec, &local_vec[i],
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] sh_eth: fix SH7757 GEther initialization
In reply to Sasha LevinFrom: Sergei Shtylyov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5133550296d43236439494aa955bfb765a89f615 ]
Renesas SH7757 has 2 Fast and 2 Gigabit Ether controllers, while the 'sh_eth' driver can only reset and initialize TSU of the first controller pair. Shimoda-san tried to solve that adding the 'needs_init' member to the 'struct sh_eth_plat_data', however the platform code still never sets this flag. I think that we can infer this information from the 'devno' variable (set to 'platform_device::id') and reset/init the Ether controller pair only for an even 'devno'; therefore 'sh_eth_plat_data::needs_init' can be removed...
--- drivers/net/ethernet/renesas/sh_eth.c | 4 ++-- include/linux/sh_eth.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +2 -2
@@ -3200,8 +3200,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ndev->features =NETIF_F_HW_VLAN_CTAG_FILTER ; } -/* initialize first or needed device */ -if (!devno || pd->needs_init) { +/* Need to init only the first port of the two sharing a TSU */ +if (devno %2 ==0 ) {if (mdp->cd->chip_reset) mdp->cd->chip_reset (ndev);
include/linux/sh_eth.h +0 -1
@@ -16,7 +16,6 @@ struct sh_eth_plat_data {unsigned char mac_addr[ETH_ALEN ]; unsigned no_ether_link:1; unsigned ether_link_active_low:1; - unsigned needs_init:1; };#endif
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ipv6: fix possible mem leaks in ipv6_make_skb()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 862c03ee1deb7e19e0f9931682e0294ecd1fcaf9 ]
ip6_setup_cork() might return an error, while memory allocations have been done and must be rolled back.
--- net/ipv6/ip6_output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv6/ip6_output.c +3 -1
@@ -1759,8 +1759,10 @@ struct sk_buff *ip6_make_skb(struct sock *sk, cork.base.opt =NULL ; v6_cork.opt =NULL ; err =ip6_setup_cork (sk, &cork, &v6_cork, hlimit, tclass, opt, rt, fl6); -if (err) +if (err) { +ip6_cork_release (&cork, &v6_cork);return ERR_PTR (err); + }if (dontfrag <0 ) dontfrag =inet6_sk (sk)->dontfrag;
Signature · 1 line
2.14.1