scsi: sun_esp: fix device reference leaks
Subsystems (4)
PATCH 51/101 scsi: sun_esp: fix device reference leaks
From: Johan Hovold <[email protected]>
[ Upstream commit f62f9ffdb5ef683ef8cffb43932fa72cc3713e94 ]
Make sure to drop the reference to the dma device taken by of_find_device_by_node() on probe errors and on driver unbind.
--- drivers/scsi/sun_esp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/sun_esp.c +8 -1
@@ -566,6 +566,7 @@ static int esp_sbus_probe(struct platform_device *op)struct device_node *dp = op->dev.of_node;struct platform_device *dma_of =NULL ;int hme =0 ; +int ret; if (dp->parent && (!strcmp(dp->parent->name, "espdma") ||
@@ -580,7 +581,11 @@ static int esp_sbus_probe(struct platform_device *op)if (!dma_of)return -ENODEV ; -return esp_sbus_probe_one (op, dma_of, hme); + ret =esp_sbus_probe_one (op, dma_of, hme); +if (ret) +put_device (&dma_of->dev); + +return ret; }static int esp_sbus_remove (struct platform_device *op)
@@ -613,6 +618,8 @@ static int esp_sbus_remove(struct platform_device *op)dev_set_drvdata (&op->dev,NULL ); +put_device (&dma_of->dev); +return 0 ; }
Signature · 1 line
2.15.1
PATCH 52/101 powerpc/fadump: avoid duplicates in crash memory ranges
From: Hari Bathini <[email protected]>
[ Upstream commit a77af552ccc9d4d54459a39f9e5f7ad307aeb4f9 ]
fadump sets up crash memory ranges to be used for creating PT_LOAD program headers in elfcore header. Memory chunk RMA_START through boot memory area size is added as the first memory range because firmware, at the time of crash, moves this memory chunk to different location specified during fadump registration making it necessary to create a separate program header for it with the correct offset. This memory chunk is skipped while setting up the remaining memory ranges. But currently, there is possibility that some of this memory may have duplicate entries like when it is hot-removed and added again. Ensure that no two memory ranges represent the same memory.
When 5 lmbs are hot-removed and then hot-plugged before registering fadump, here is how the program headers in /proc/vmcore exported by fadump look like
without this change:
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
NOTE 0x0000000000010000 0x0000000000000000 0x0000000000000000
0x0000000000001894 0x0000000000001894 0
LOAD 0x0000000000021020 0xc000000000000000 0x0000000000000000
0x0000000040000000 0x0000000040000000 RWE 0
LOAD 0x0000000040031020 0xc000000000000000 0x0000000000000000
0x0000000010000000 0x0000000010000000 RWE 0
LOAD 0x0000000050040000 0xc000000010000000 0x0000000010000000
0x0000000050000000 0x0000000050000000 RWE 0
LOAD 0x00000000a0040000 0xc000000060000000 0x0000000060000000
0x000000019ffe0000 0x000000019ffe0000 RWE 0and with this change:
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
NOTE 0x0000000000010000 0x0000000000000000 0x0000000000000000
0x0000000000001894 0x0000000000001894 0
LOAD 0x0000000000021020 0xc000000000000000 0x0000000000000000
0x0000000040000000 0x0000000040000000 RWE 0
LOAD 0x0000000040030000 0xc000000040000000 0x0000000040000000
0x0000000020000000 0x0000000020000000 RWE 0
LOAD 0x0000000060030000 0xc000000060000000 0x0000000060000000
0x000000019ffe0000 0x000000019ffe0000 RWE 0--- arch/powerpc/kernel/fadump.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
arch/powerpc/kernel/fadump.c +13 -2
@@ -812,8 +812,19 @@ static void fadump_setup_crash_memory_ranges(void)for_each_memblock (memory, reg) { start = (unsigned long long )reg->base; end = start + (unsigned long long )reg->size; -if (start ==RMA_START && end >= fw_dump.boot_memory_size) - start = fw_dump.boot_memory_size; + +/* +* skip the first memory chunk that is already added (RMA_START +* through boot_memory_size). This logic needs a relook if and +* when RMA_START changes to a non-zero value. +*/ +BUILD_BUG_ON (RMA_START !=0 ); +if (start < fw_dump.boot_memory_size) { +if (end > fw_dump.boot_memory_size) + start = fw_dump.boot_memory_size; +else +continue ; + }/* add this range excluding the reserved dump area. */ fadump_exclude_reserved_area (start, end);
Signature · 1 line
2.15.1
PATCH 53/101 libertas: Fix lbs_prb_rsp_limit_set()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 69551f5f370cc20342fab17ca54716b6ec7e332d ]
The kstrtoul() test was reversed so this always returned -ENOTSUPP.
--- drivers/net/wireless/libertas/mesh.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/libertas/mesh.c +3 -2
@@ -239,8 +239,9 @@ static ssize_t lbs_prb_rsp_limit_set(struct device *dev,memset (&mesh_access,0 ,sizeof (mesh_access)); mesh_access.data[0 ] =cpu_to_le32 (CMD_ACT_SET ); -if (!kstrtoul (buf,10 , &retry_limit)) -return -ENOTSUPP ; + ret =kstrtoul (buf,10 , &retry_limit); +if (ret) +return ret;if (retry_limit >15 )return -ENOTSUPP ;
Signature · 1 line
2.15.1
PATCH 54/101 PCI: Enable ECRC only if device supports it
In reply to Sasha LevinFrom: Bjorn Helgaas <[email protected]>
[ Upstream commit 675734baa361cf044033bb60594dea33d8d8da36 ]
John reported that an Intel QuickAssist crypto accelerator didn't work in a Dell PowerEdge R730. The problem seems to be that we enabled ECRC when the device doesn't support it:
85:00.0 Co-processor [0b40]: Intel Corporation DH895XCC Series QAT [8086:0435]
Capabilities: [100 v1] Advanced Error Reporting
AERCap: First Error Pointer: 00, GenCap- CGenEn+ ChkCap- ChkEn+
1302fcf0d03e ("PCI: Configure *all* devices, not just hot-added ones") exposed the problem because it applies settings from the _HPX method to all devices, not just hot-added ones. The R730 supplies an _HPX method that allows the kernel to enable ECRC.
Only enable ECRC if the device advertises support for it.
--- drivers/pci/probe.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/probe.c +5 -0
@@ -1400,6 +1400,11 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)/* Initialize Advanced Error Capabilities and Control Register */ pci_read_config_dword (dev, pos +PCI_ERR_CAP , ®32); reg32 = (reg32 & hpp->adv_err_cap_and) | hpp->adv_err_cap_or; +/* Don't enable ECRC generation or checking if unsupported */ +if (!(reg32 &PCI_ERR_CAP_ECRC_GENC )) + reg32 &= ~PCI_ERR_CAP_ECRC_GENE ; +if (!(reg32 &PCI_ERR_CAP_ECRC_CHKC )) + reg32 &= ~PCI_ERR_CAP_ECRC_CHKE ;pci_write_config_dword (dev, pos +PCI_ERR_CAP , reg32);/*
Signature · 1 line
2.15.1
PATCH 55/101 MIPS: CPS: Prevent multi-core with dcache aliasing
In reply to Sasha LevinFrom: Paul Burton <[email protected]>
[ Upstream commit 5570ba2ee920de4e7760a2802b842771845b2c32 ]
Systems using the MIPS Coherence Manager (CM) cannot support multi-core SMP with dcache aliasing. This is because CPU caches are VIPT, but interventions in CM-based systems provide only the physical address to remote caches. This means that interventions may behave incorrectly in the presence of an aliasing dcache, since the physical address used when handling an intervention may lead to operation on an aliased cache line rather than the correct line.
Prevent us from running into this issue by refusing to boot secondary cores in systems where dcache aliasing may occur.
Patchwork: https://patchwork.linux-mips.org/patch/16196/
--- arch/mips/kernel/smp-cps.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/mips/kernel/smp-cps.c +5 -3
@@ -120,9 +120,11 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)/* Warn the user if the CCA prevents multi-core */ ncores =mips_cm_numcores (); -if (cca_unsuitable && ncores >1 ) { -pr_warn ("Using only one core due to unsuitable CCA 0x%x\n" , - cca); +if ((cca_unsuitable || cpu_has_dc_aliases) && ncores >1 ) { +pr_warn ("Using only one core due to %s%s%s\n" , + cca_unsuitable ?"unsuitable CCA" :"" , + (cca_unsuitable && cpu_has_dc_aliases) ?" & " :"" , + cpu_has_dc_aliases ?"dcache aliasing" :"" );for_each_present_cpu (c) {if (cpu_data[c].core)
Signature · 1 line
2.15.1
PATCH 56/101 MIPS: Handle tlbex-tlbp race condition
In reply to Sasha LevinFrom: Paul Burton <[email protected]>
[ Upstream commit f39878cc5b09c75d35eaf52131e920b872e3feb4 ]
In systems where there are multiple actors updating the TLB, the potential exists for a race condition wherein a CPU hits a TLB exception but by the time it reaches a TLBP instruction the affected TLB entry may have been replaced. This can happen if, for example, a CPU shares the TLB between hardware threads (VPs) within a core and one of them replaces the entry that another has just taken a TLB exception for.
We handle this race in the case of the Hardware Table Walker (HTW) being the other actor already, but didn't take into account the potential for multiple threads racing. Include the code for aborting TLB exception handling in affected multi-threaded systems, those being the I6400 & I6500 CPUs which share TLB entries between VPs.
In the case of using RiXi without dedicated exceptions we have never handled this race even for HTW. This patch adds WARN()s to these cases which ought never to be hit because all CPUs with either HTW or shared FTLB RAMs also include dedicated RiXi exceptions, but the WARN()s will ensure this is always the case.
Patchwork: https://patchwork.linux-mips.org/patch/16203/
--- arch/mips/mm/tlbex.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
arch/mips/mm/tlbex.c +37 -1
@@ -1838,6 +1838,26 @@ static void build_r3000_tlb_modify_handler(void) }#endif /* CONFIG_MIPS_PGD_C0_CONTEXT */ +static bool cpu_has_tlbex_tlbp_race (void ) +{ +/* +* When a Hardware Table Walker is running it can replace TLB entries +* at any time, leading to a race between it & the CPU. +*/ +if (cpu_has_htw) +return true; + +/* +* If the CPU shares FTLB RAM with its siblings then our entry may be +* replaced at any time by a sibling performing a write to the FTLB. +*/ +if (cpu_has_shared_ftlb_ram) +return true; + +/* In all other cases there ought to be no race condition to handle */ +return false; +} +/* * R4000 style TLB load/store/modify handlers. */
@@ -1874,7 +1894,7 @@ build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,iPTE_LW (p, wr.r1, wr.r2);/* get even pte */ if (!m4kc_tlbp_war ()) {build_tlb_probe_entry (p); -if (cpu_has_htw) { +if (cpu_has_tlbex_tlbp_race ()) {/* race condition happens, leaving */ uasm_i_ehb (p);uasm_i_mfc0 (p, wr.r3,C0_INDEX );
@@ -1948,6 +1968,14 @@ static void build_r4000_tlb_load_handler(void) }uasm_i_nop (&p); +/* +* Warn if something may race with us & replace the TLB entry +* before we read it here. Everything with such races should +* also have dedicated RiXi exception handlers, so this +* shouldn't be hit. +*/ +WARN (cpu_has_tlbex_tlbp_race (),"Unhandled race in RiXi path" ); +uasm_i_tlbr (&p);switch (current_cpu_type ()) {
@@ -2015,6 +2043,14 @@ static void build_r4000_tlb_load_handler(void) }uasm_i_nop (&p); +/* +* Warn if something may race with us & replace the TLB entry +* before we read it here. Everything with such races should +* also have dedicated RiXi exception handlers, so this +* shouldn't be hit. +*/ +WARN (cpu_has_tlbex_tlbp_race (),"Unhandled race in RiXi path" ); +uasm_i_tlbr (&p);switch (current_cpu_type ()) {
Signature · 1 line
2.15.1
PATCH 57/101 arm64: ptrace: Avoid setting compat FP[SC]R to garbage if get_user fails
In reply to Sasha LevinFrom: Dave Martin <[email protected]>
[ Upstream commit 53b1a742ed251780267a57415bc955bd50f40c3d ]
If get_user() fails when reading the new FPSCR value from userspace in compat_vfp_get(), then garbage* will be written to the task's FPSR and FPCR registers.
This patch prevents this by checking the return from get_user() first.
[*] Actually, zero, due to the behaviour of get_user() on error, but that's still not what userspace expects.
--- arch/arm64/kernel/ptrace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm64/kernel/ptrace.c +4 -2
@@ -785,8 +785,10 @@ static int compat_vfp_set(struct task_struct *target,if (count && !ret) { ret =get_user (fpscr, (compat_ulong_t *)ubuf); - uregs->fpsr = fpscr &VFP_FPSCR_STAT_MASK ; - uregs->fpcr = fpscr &VFP_FPSCR_CTRL_MASK ; +if (!ret) { + uregs->fpsr = fpscr &VFP_FPSCR_STAT_MASK ; + uregs->fpcr = fpscr &VFP_FPSCR_CTRL_MASK ; + } }fpsimd_flush_task_state (target);
Signature · 1 line
2.15.1
PATCH 58/101 arm64: ptrace: Fix incorrect get_user() use in compat_vfp_set()
In reply to Sasha LevinFrom: Dave Martin <[email protected]>
[ Upstream commit 5fbd5fc49fc39ac8433da62d16682a1d0217ea4f ]
Now that compat_vfp_get() uses the regset API to copy the FPSCR value out to userspace, compat_vfp_set() looks inconsistent. In particular, compat_vfp_set() will fail if called with kbuf != NULL && ubuf == NULL (which is valid usage according to the regset API).
This patch fixes compat_vfp_set() to use user_regset_copyin(), similarly to compat_vfp_get().
This also squashes a sparse warning triggered by the cast that drops __user when calling get_user().
--- arch/arm64/kernel/ptrace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/arm64/kernel/ptrace.c +5 -3
@@ -773,18 +773,20 @@ static int compat_vfp_set(struct task_struct *target, {struct user_fpsimd_state *uregs;compat_ulong_t fpscr; -int ret; +int ret, vregs_end_pos;if (pos + count >VFP_STATE_SIZE )return -EIO ; uregs = &target->thread.fpsimd_state.user_fpsimd; + vregs_end_pos =VFP_STATE_SIZE -sizeof (compat_ulong_t); ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, uregs,0 , -VFP_STATE_SIZE -sizeof (compat_ulong_t)); + vregs_end_pos);if (count && !ret) { - ret =get_user (fpscr, (compat_ulong_t *)ubuf); + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &fpscr, + vregs_end_pos,VFP_STATE_SIZE );if (!ret) { uregs->fpsr = fpscr &VFP_FPSCR_STAT_MASK ; uregs->fpcr = fpscr &VFP_FPSCR_CTRL_MASK ;
Signature · 1 line
2.15.1
PATCH 59/101 x86/um: thin archives build fix
In reply to Sasha LevinFrom: Nicholas Piggin <[email protected]>
[ Upstream commit 827880ec260ba048f95fe646b96a205c394fa0f0 ]
The linker does not like vdso-syms.lds in input archive files. Make it an extra-y instead.
--- arch/x86/um/vdso/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/um/vdso/Makefile +1 -1
@@ -50,7 +50,7 @@ CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage targets += vdso-syms.lds -obj-$(VDSO64-y) += vdso-syms.lds +extra-$(VDSO64-y) += vdso-syms.lds # # Match symbols in the DSO that look like VDSO*; produce a file of constants.
Signature · 1 line
2.15.1
Re: [PATCH AUTOSEL for 3.18 059/101] x86/um: thin archives build fix
Quoted 6 lines · On Mon, 9 Apr 2018 00:41:22 +0000 Sasha Levin <[email protected]>…
From: Nicholas Piggin <[email protected]>
[ Upstream commit
827880ec260ba048f95fe646b96a205c394fa0f0]The linker does not like
vdso-syms.ldsin input archive files. Make it an extra-y instead.
I wouldn't say these should be needed on kernels without thin archives build.
It shouldn't hurt, but no point risking stable breakage.
Thanks,
Nick
Re: [PATCH AUTOSEL for 3.18 059/101] x86/um: thin archives build fix
Quoted 10 lines · Nicholas Piggin
Quoted 6 lines · On Mon, 9 Apr 2018 00:41:22 +0000 Sasha Levin <[email protected]>…
From: Nicholas Piggin <[email protected]>
[ Upstream commit
827880ec260ba048f95fe646b96a205c394fa0f0]The linker does not like
vdso-syms.ldsin input archive files. Make it an extra-y instead.
Quoted 7 lines
I wouldn't say these should be needed on kernels without thin archives build.
It shouldn't hurt, but no point risking stable breakage.
Thanks,
Nick
Now dropped, thanks Nick!
PATCH 60/101 fs: warn in case userspace lied about modprobe return
In reply to Sasha LevinFrom: "Luis R. Rodriguez" <[email protected]>
[ Upstream commit 41124db869b7e00e12052555f8987867ac01d70c ]
kmod <= v19 was broken -- it could return 0 to modprobe calls, incorrectly assuming that a kernel module was built-in, whereas in reality the module was just forming in the kernel. The reason for this is an incorrect userspace heuristics. A userspace kmod fix is available for it [0], however should userspace break again we could go on with an failed get_fs_type() which is hard to debug as the request_module() is detected as returning 0. The first suspect would be that there is something worth with the kernel's module loader and obviously in this case that is not the issue.
Since these issues are painful to debug complain when we know userspace has outright lied to us.
--- fs/filesystems.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/filesystems.c +3 -1
@@ -275,8 +275,10 @@ struct file_system_type *get_fs_type(const char *name)int len = dot ? dot - name :strlen (name); fs =__get_fs_type (name, len); -if (!fs && (request_module ("fs-%.*s" , len, name) ==0 )) +if (!fs && (request_module ("fs-%.*s" , len, name) ==0 )) { fs =__get_fs_type (name, len); +WARN_ONCE (!fs,"request_module fs-%.*s succeeded, but still no fs?\n" , len, name); + }if (dot && fs && !(fs->fs_flags &FS_HAS_SUBTYPE )) {put_filesystem (fs);
Signature · 1 line
2.15.1
PATCH 61/101 ext4: change fast symlink test to not rely on i_blocks
In reply to Sasha LevinFrom: Tahsin Erdogan <[email protected]>
[ Upstream commit 407cd7fb83c0ebabb490190e673d8c71ee7df97e ]
ext4_inode_info->i_data is the storage area for 4 types of data:
a) Extents data
b) Inline data
c) Block map
d) Fast symlink data (symlink length < 60)
Extents data case is positively identified by EXT4_INODE_EXTENTS flag. Inline data case is also obvious because of EXT4_INODE_INLINE_DATA flag.
Distinguishing c) and d) however requires additional logic. This currently relies on i_blocks count. After subtracting external xattr block from i_blocks, if it is greater than 0 then we know that some data blocks exist, so there must be a block map.
This logic got broken after ea_inode feature was added. That feature charges the data blocks of external xattr inodes to the referencing inode and so adds them to the i_blocks. To fix this, we could subtract ea_inode blocks by iterating through all xattr entries and then check whether remaining i_blocks count is zero. Besides being complicated, this won't change the fact that the current way of distinguishing between c) and d) is fragile.
The alternative solution is to test whether i_size is less than 60 to determine fast symlink case. ext4_symlink() uses the same test to decide whether to store the symlink in i_data. There is one caveat to address before this can work though.
If an inode's i_nlink is zero during eviction, its i_size is set to zero and its data is truncated. If system crashes before inode is removed from the orphan list, next boot orphan cleanup may find the inode with zero i_size. So, a symlink that had its data stored in a block may now appear to be a fast symlink. The solution used in this patch is to treat i_size = 0 as a non-fast symlink case. A zero sized symlink is not legal so the only time this can happen is the mentioned scenario. This is also logically correct because a i_size = 0 symlink has no data stored in i_data.
--- fs/ext4/inode.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
fs/ext4/inode.c +13 -7
@@ -140,16 +140,12 @@ static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,/* * Test whether an inode is a fast symlink. +* A fast symlink has its symlink data stored in ext4_inode_info->i_data. */ static int ext4_inode_is_fast_symlink (struct inode *inode) { -int ea_blocks =EXT4_I (inode)->i_file_acl ? -EXT4_CLUSTER_SIZE (inode->i_sb) >>9 :0 ; - -if (ext4_has_inline_data (inode)) -return 0 ; - -return (S_ISLNK (inode->i_mode) && inode->i_blocks - ea_blocks ==0 ); +return S_ISLNK (inode->i_mode) && inode->i_size && + (inode->i_size <EXT4_N_BLOCKS *4 ); }/*
@@ -253,6 +249,16 @@ void ext4_evict_inode(struct inode *inode)if (IS_SYNC (inode))ext4_handle_sync (handle); + +/* +* Set inode->i_size to 0 before calling ext4_truncate(). We need +* special handling of symlinks here because i_size is used to +* determine whether ext4_inode_info->i_data contains symlink data or +* block mappings. Setting i_size to 0 will remove its fast symlink +* status. Erase i_data so that it becomes a valid empty block map. +*/ +if (ext4_inode_is_fast_symlink (inode)) +memset (EXT4_I (inode)->i_data,0 ,sizeof (EXT4_I (inode)->i_data)); inode->i_size =0 ; err =ext4_mark_inode_dirty (handle, inode);if (err) {
Signature · 1 line
2.15.1
PATCH 62/101 irqchip/gic-v3: Honor forced affinity setting
In reply to Sasha LevinFrom: Suzuki K Poulose <[email protected]>
[ Upstream commit 65a30f8b300107266f316d550f060ccc186201a3 ]
Honor the 'force' flag for set_affinity, by selecting a CPU from the given mask (which may not be reported "online" by the cpu_online_mask). Some drivers, like ARM PMU, rely on it.
--- drivers/irqchip/irq-gic-v3.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +6 -1
@@ -526,11 +526,16 @@ static void gic_smp_init(void)static int gic_set_affinity (struct irq_data *d,const struct cpumask *mask_val,bool force) { -unsigned int cpu =cpumask_any_and (mask_val, cpu_online_mask); +unsigned int cpu;void __iomem *reg;int enabled;u64 val; +if (force) + cpu =cpumask_first (mask_val); +else + cpu =cpumask_any_and (mask_val, cpu_online_mask); +if (cpu >= nr_cpu_ids)return -EINVAL ;
Signature · 1 line
2.15.1
PATCH 63/101 vmlfb: Fix error handling in cr_pll_init()
In reply to Sasha LevinFrom: Alexey Khoroshilov <[email protected]>
[ Upstream commit 6af574e826740bf17663b48ba3f8fadb81d2113f ]
There is an error path, where iomemory is left mapped.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/video/fbdev/vermilion/cr_pll.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/vermilion/cr_pll.c +1 -0
@@ -185,6 +185,7 @@ static int __init cr_pll_init(void)if (err) {printk (KERN_ERR "Carillo Ranch failed to initialize vml_sys.\n" ); +iounmap (mch_regs_base);pci_dev_put (mch_dev);return err; }
Signature · 1 line
2.15.1
PATCH 64/101 firewire-ohci: work around oversized DMA reads on JMicron controllers
In reply to Sasha LevinFrom: Hector Martin <[email protected]>
[ Upstream commit 188775181bc05f29372b305ef96485840e351fde ]
At least some JMicron controllers issue buggy oversized DMA reads when fetching context descriptors, always fetching 0x20 bytes at once for descriptors which are only 0x10 bytes long. This is often harmless, but can cause page faults on modern systems with IOMMUs:
DMAR: [DMA Read] Request device [05:00.0] fault addr fff56000 [fault reason 06] PTE Read access is not set firewire_ohci 0000:05:00.0: DMA context IT0 has stopped, error code: evt_descriptor_read
This works around the problem by always leaving 0x10 padding bytes at the end of descriptor buffer pages, which should be harmless to do unconditionally for controllers in case others have the same behavior.
--- drivers/firewire/ohci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/firewire/ohci.c +7 -1
@@ -1137,7 +1137,13 @@ static int context_add_buffer(struct context *ctx)return -ENOMEM ; offset = (void *)&desc->buffer - (void *)desc; - desc->buffer_size =PAGE_SIZE - offset; +/* +* Some controllers, like JMicron ones, always issue 0x20-byte DMA reads +* for descriptors, even 0x10-byte ones. This can cause page faults when +* an IOMMU is in use and the oversized read crosses a page boundary. +* Work around this by always leaving at least 0x10 bytes of padding. +*/ + desc->buffer_size =PAGE_SIZE - offset -0x10 ; desc->buffer_bus = bus_addr + offset; desc->used =0 ;
Signature · 1 line
2.15.1
PATCH 65/101 ASoC: au1x: Fix timeout tests in au1xac97c_ac97_read()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 123af9043e93cb6f235207d260d50f832cdb5439 ]
The loop timeout doesn't work because it's a post op and ends with "tmo" set to -1. I changed it from a post-op to a pre-op and I changed the initial the starting value from 5 to 6 so we still iterate 5 times. I left the other as it was because it's a large number.
--- sound/soc/au1x/ac97c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/au1x/ac97c.c +3 -3
@@ -91,8 +91,8 @@ static unsigned short au1xac97c_ac97_read(struct snd_ac97 *ac97, do { mutex_lock(&ctx->lock); - tmo = 5; - while ((RD(ctx, AC97_STATUS) & STAT_CP) && tmo--) + tmo = 6; + while ((RD(ctx, AC97_STATUS) & STAT_CP) && --tmo) udelay(21); /* wait an ac97 frame time */ if (!tmo) { pr_debug("ac97rd timeout #1\n");
@@ -105,7 +105,7 @@ static unsigned short au1xac97c_ac97_read(struct snd_ac97 *ac97,* poll, Forrest, poll... */ tmo =0x10000 ; -while ((RD (ctx,AC97_STATUS ) &STAT_CP ) && tmo--) +while ((RD (ctx,AC97_STATUS ) &STAT_CP ) && --tmo) asmvolatile ("nop" ); data =RD (ctx,AC97_CMDRESP );
Signature · 1 line
2.15.1
PATCH 66/101 kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl
In reply to Sasha LevinFrom: Paolo Bonzini <[email protected]>
[ Upstream commit 51776043afa415435c7e4636204fbe4f7edc4501 ]
This ioctl is obsolete (it was used by Xenner as far as I know) but still let's not break it gratuitously... Its handler is copying directly into struct kvm. Go through a bounce buffer instead, with the added benefit that we can actually do something useful with the flags argument---the previous code was exiting with -EINVAL but still doing the copy.
This technically is a userspace ABI breakage, but since no one should be using the ioctl, it's a good occasion to see if someone actually complains.
--- arch/x86/kvm/x86.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/kvm/x86.c +4 -3
@@ -4025,13 +4025,14 @@ long kvm_arch_vm_ioctl(struct file *filp,break ; }case KVM_XEN_HVM_CONFIG : { +struct kvm_xen_hvm_config xhc; r = -EFAULT ; -if (copy_from_user (&kvm->arch.xen_hvm_config, argp, -sizeof (struct kvm_xen_hvm_config ))) +if (copy_from_user (&xhc, argp,sizeof (xhc))) goto out; r = -EINVAL ; -if (kvm->arch.xen_hvm_config.flags) +if (xhc.flags) goto out; +memcpy (&kvm->arch.xen_hvm_config, &xhc,sizeof (xhc)); r =0 ;break ; }
Signature · 1 line
2.15.1
PATCH 67/101 tracing/hrtimer: Fix tracing bugs by taking all clock bases and modes into account
In reply to Sasha LevinFrom: Anna-Maria Gleixner <[email protected]>
[ Upstream commit 91633eed73a3ac37aaece5c8c1f93a18bae616a9 ]
So far only CLOCK_MONOTONIC and CLOCK_REALTIME were taken into account as well as HRTIMER_MODE_ABS/REL in the hrtimer_init tracepoint. The query for detecting the ABS or REL timer modes is not valid anymore, it got broken by the introduction of HRTIMER_MODE_PINNED.
HRTIMER_MODE_PINNED is not evaluated in the hrtimer_init() call, but for the sake of completeness print all given modes.
--- include/trace/events/timer.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
include/trace/events/timer.h +16 -4
@@ -121,6 +121,20 @@ DEFINE_EVENT(timer_class, timer_cancel,TP_ARGS (timer) ); +#define decode_clockid (type) \ + __print_symbolic(type, \ + { CLOCK_REALTIME, "CLOCK_REALTIME" }, \ + { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" }, \ + { CLOCK_BOOTTIME, "CLOCK_BOOTTIME" }, \ + { CLOCK_TAI, "CLOCK_TAI" }) + +#define decode_hrtimer_mode (mode) \ + __print_symbolic(mode, \ + { HRTIMER_MODE_ABS, "ABS" }, \ + { HRTIMER_MODE_REL, "REL" }, \ + { HRTIMER_MODE_ABS_PINNED, "ABS|PINNED" }, \ + { HRTIMER_MODE_REL_PINNED, "REL|PINNED" }) +/** * hrtimer_init - called when the hrtimer is initialized * @hrtimer: pointer to struct hrtimer
@@ -147,10 +161,8 @@ TRACE_EVENT(hrtimer_init, ),TP_printk ("hrtimer=%p clockid=%s mode=%s" , __entry->hrtimer, - __entry->clockid ==CLOCK_REALTIME ? -"CLOCK_REALTIME" :"CLOCK_MONOTONIC" , - __entry->mode ==HRTIMER_MODE_ABS ? -"HRTIMER_MODE_ABS" :"HRTIMER_MODE_REL" ) +decode_clockid (__entry->clockid), +decode_hrtimer_mode (__entry->mode)) );/**
Signature · 1 line
2.15.1
PATCH 68/101 PCI: Add function 1 DMA alias quirk for Marvell 9128
In reply to Sasha LevinFrom: Alex Williamson <[email protected]>
[ Upstream commit aa008206634363ef800fbd5f0262016c9ff81dea ]
The Marvell 9128 is the original device generating bug 42679, from which many other Marvell DMA alias quirks have been sourced, but we didn't have positive confirmation of the fix on 9128 until now.
--- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/quirks.c +2 -0
@@ -3559,6 +3559,8 @@ static void quirk_dma_func1_alias(struct pci_dev *dev)*/ DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MARVELL_EXT ,0x9123 , quirk_dma_func1_alias); +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MARVELL_EXT ,0x9128 , + quirk_dma_func1_alias);/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */ DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MARVELL_EXT ,0x9130 , quirk_dma_func1_alias);
Signature · 1 line
2.15.1
PATCH 69/101 tools lib traceevent: Fix get_field_str() for dynamic strings
In reply to Sasha LevinFrom: "Steven Rostedt (VMware)" <[email protected]>
[ Upstream commit d777f8de99b05d399c0e4e51cdce016f26bd971b ]
If a field is a dynamic string, get_field_str() returned just the offset/size value and not the string. Have it parse the offset/size correctly to return the actual string. Otherwise filtering fails when trying to filter fields that are dynamic strings.
--- tools/lib/traceevent/parse-filter.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tools/lib/traceevent/parse-filter.c +9 -1
@@ -1867,17 +1867,25 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *rstruct pevent *pevent;unsigned long long addr;const char *val =NULL ; +unsigned int size;char hex[64 ];/* If the field is not a string convert it */ if (arg->str.field->flags &FIELD_IS_STRING ) { val = record->data + arg->str.field->offset; + size = arg->str.field->size; + +if (arg->str.field->flags &FIELD_IS_DYNAMIC ) { + addr = *(unsigned int *)val; + val = record->data + (addr &0xffff ); + size = addr >>16 ; + }/* * We need to copy the data since we can't be sure the field * is null terminated. */ -if (*(val + arg->str.field->size -1 )) { +if (*(val + size -1 )) {/* copy it */ memcpy (arg->str.buffer, val, arg->str.field->size);/* the buffer is already NULL terminated */
Signature · 1 line
2.15.1
PATCH 70/101 dm thin: fix documentation relative to low water mark threshold
In reply to Sasha LevinFrom: mulhern <[email protected]>
[ Upstream commit 9b28a1102efc75d81298198166ead87d643a29ce ]
Fixes:
1. The use of "exceeds" when the opposite of exceeds, falls below, was meant.
2. Properly speaking, a table can not exceed a threshold.
It emphasizes the important point, which is that it is the userspace daemon's responsibility to check for low free space when a device is resumed, since it won't get a special event indicating low free space in that situation.
--- Documentation/device-mapper/thin-provisioning.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Documentation/device-mapper/thin-provisioning.txt +5 -3
@@ -112,9 +112,11 @@ $low_water_mark is expressed in blocks of size $data_block_size. If free space on the data device drops below this level then a dm event will be triggered which a userspace daemon should catch allowing it to extend the pool device. Only one such event will be sent. -Resuming a device with a new table itself triggers an event so the -userspace daemon can use this to detect a situation where a new table -already exceeds the threshold. + +No special event is triggered if a just resumed device's free space is below +the low water mark. However, resuming a device always triggers an +event; a userspace daemon should verify that free space exceeds the low +water mark when handling this event. A low water mark for the metadata device is maintained in the kernel and will trigger a dm event if free space on the metadata device drops below
Signature · 1 line
2.15.1
PATCH 71/101 nfs: Do not convert nfs_idmap_cache_timeout to jiffies
In reply to Sasha LevinFrom: Jan Chochol <[email protected]>
[ Upstream commit cbebc6ef4fc830f4040d4140bf53484812d5d5d9 ]
Since commit 57e62324e469 ("NFS: Store the legacy idmapper result in the keyring") nfs_idmap_cache_timeout changed units from jiffies to seconds. Unfortunately sysctl interface was not updated accordingly.
As a effect updating /proc/sys/fs/nfs/idmap_cache_timeout with some value will incorrectly multiply this value by HZ.
Also reading /proc/sys/fs/nfs/idmap_cache_timeout will show real value divided by HZ.
--- fs/nfs/nfs4sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4sysctl.c +1 -1
@@ -31,7 +31,7 @@ static struct ctl_table nfs4_cb_sysctls[] = { .data = &nfs_idmap_cache_timeout, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_jiffies, + .proc_handler = proc_dointvec, }, { } };
Signature · 1 line
2.15.1
PATCH 72/101 watchdog: sp5100_tco: Fix watchdog disable bit
In reply to Sasha LevinFrom: Guenter Roeck <[email protected]>
[ Upstream commit f541c09ebfc61697b586b38c9ebaf4b70defb278 ]
According to all published information, the watchdog disable bit for SB800 compatible controllers is bit 1 of PM register 0x48, not bit 2. For the most part that doesn't matter in practice, since the bit has to be cleared to enable watchdog address decoding, which is the default setting, but it still needs to be fixed.
--- drivers/watchdog/sp5100_tco.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/sp5100_tco.h +1 -1
@@ -54,7 +54,7 @@#define SB800_PM_WATCHDOG_CONFIG 0x4C#define SB800_PCI_WATCHDOG_DECODE_EN (1 << 0) -#define SB800_PM_WATCHDOG_DISABLE (1 << 2) +#define SB800_PM_WATCHDOG_DISABLE (1 << 1)#define SB800_PM_WATCHDOG_SECOND_RES (3 << 0)#define SB800_ACPI_MMIO_DECODE_EN (1 << 0)#define SB800_ACPI_MMIO_SEL (1 << 1)
Signature · 1 line
2.15.1
PATCH 73/101 kconfig: Don't leak main menus during parsing
In reply to Sasha LevinFrom: Ulf Magnusson <[email protected]>
[ Upstream commit 0724a7c32a54e3e50d28e19e30c59014f61d4e2c ]
If a 'mainmenu' entry appeared in the Kconfig files, two things would leak:
- The 'struct property' allocated for the default "Linux Kernel Configuration" prompt.
- The string for the T_WORD/T_WORD_QUOTE prompt after the T_MAINMENU token, allocated on the heap in zconf.l.
To fix it, introduce a new 'no_mainmenu_stmt' nonterminal that matches if there's no 'mainmenu' and adds the default prompt. That means the prompt only gets allocated once regardless of whether there's a 'mainmenu' statement or not, and managing it becomes simple.
Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:
LEAK SUMMARY: definitely lost: 344,568 bytes in 14,352 blocks ...
Summary after the fix:
LEAK SUMMARY: definitely lost: 344,440 bytes in 14,350 blocks ...
--- scripts/kconfig/zconf.y | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
scripts/kconfig/zconf.y +24 -9
@@ -102,7 +102,27 @@ static struct menu *current_menu, *current_entry; %% input: nl start | start; -start: mainmenu_stmt stmt_list | stmt_list; +start: mainmenu_stmt stmt_list | no_mainmenu_stmt stmt_list; + +/* mainmenu entry */ + +mainmenu_stmt: T_MAINMENU prompt nl +{ + menu_add_prompt(P_MENU, $2, NULL); +}; + +/* Default main menu, if there's no mainmenu entry */ + +no_mainmenu_stmt: /* empty */ +{ + /* + * Hack: Keep the main menu title on the heap so we can safely free it + * later regardless of whether it comes from the 'prompt' in + * mainmenu_stmt or here + */ + menu_add_prompt(P_MENU, strdup("Linux Kernel Configuration"), NULL); +}; + stmt_list: /* empty */
@@ -339,13 +359,6 @@ if_block: | if_block choice_stmt ; -/* mainmenu entry */ - -mainmenu_stmt: T_MAINMENU prompt nl -{ - menu_add_prompt(P_MENU, $2, NULL); -}; - /* menu entry */ menu: T_MENU prompt T_EOL
@@ -486,6 +499,7 @@ word_opt: /* empty */ { $$ = NULL; } void conf_parse(const char *name) { + const char *tmp; struct symbol *sym; int i;
@@ -493,7 +507,6 @@ void conf_parse(const char *name) sym_init(); _menu_init(); - rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); if (getenv("ZCONF_DEBUG")) zconfdebug = 1;
@@ -503,8 +516,10 @@ void conf_parse(const char *name) if (!modules_sym) modules_sym = sym_find( "n" ); + tmp = rootmenu.prompt->text; rootmenu.prompt->text = _(rootmenu.prompt->text); rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + free((char*)tmp); menu_finalize(&rootmenu); for_all_symbols(i, sym) {
Signature · 1 line
2.15.1
PATCH 74/101 kconfig: Fix automatic menu creation mem leak
In reply to Sasha LevinFrom: Ulf Magnusson <[email protected]>
[ Upstream commit ae7440ef0c8013d68c00dad6900e7cce5311bb1c ]
expr_trans_compare() always allocates and returns a new expression, giving the following leak outline:
...
*Allocate*
basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
...
for (menu = parent->next; menu; menu = menu->next) {
...
*Copy*
dep2 = expr_copy(basedep);
...
*Free copy*
expr_free(dep2);
}
*basedep lost!*Fix by freeing 'basedep' after the loop.
Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:
LEAK SUMMARY: definitely lost: 344,376 bytes in 14,349 blocks ...
Summary after the fix:
LEAK SUMMARY: definitely lost: 44,448 bytes in 1,852 blocks ...
--- scripts/kconfig/menu.c | 1 + 1 file changed, 1 insertion(+)
scripts/kconfig/menu.c +1 -0
@@ -364,6 +364,7 @@ void menu_finalize(struct menu *parent) menu->parent = parent; last_menu = menu; } +expr_free (basedep);if (last_menu) { parent->list = parent->next; parent->next = last_menu->next;
Signature · 1 line
2.15.1
PATCH 75/101 kconfig: Fix expr_free() E_NOT leak
In reply to Sasha LevinFrom: Ulf Magnusson <[email protected]>
[ Upstream commit 5b1374b3b3c2fc4f63a398adfa446fb8eff791a4 ]
Only the E_NOT operand and not the E_NOT node itself was freed, due to accidentally returning too early in expr_free(). Outline of leak:
switch (e->type) {
...
case E_NOT:
expr_free(e->left.expr);
return;
...
}
*Never reached, 'e' leaked*
free(e);Fix by changing the 'return' to a 'break'.
Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:
LEAK SUMMARY: definitely lost: 44,448 bytes in 1,852 blocks ...
Summary after the fix:
LEAK SUMMARY: definitely lost: 1,608 bytes in 67 blocks ...
--- scripts/kconfig/expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/expr.c +1 -1
@@ -106,7 +106,7 @@ void expr_free(struct expr *e)break ;case E_NOT :expr_free (e->left.expr); -return ; +break ;case E_EQUAL :case E_UNEQUAL :break ;
Signature · 1 line
2.15.1
PATCH 76/101 btrfs: Fix out of bounds access in btrfs_search_slot
In reply to Sasha LevinFrom: Nikolay Borisov <[email protected]>
[ Upstream commit 9ea2c7c9da13c9073e371c046cbbc45481ecb459 ]
When modifying a tree where the root is at BTRFS_MAX_LEVEL - 1 then the level variable is going to be 7 (this is the max height of the tree). On the other hand btrfs_cow_block is always called with "level + 1" as an index into the nodes and slots arrays. This leads to an out of bounds access. Admittdely this will be benign since an OOB access of the nodes array will likely read the 0th element from the slots array, which in this case is going to be 0 (since we start CoW at the top of the tree). The OOB access into the slots array in turn will read the 0th and 1st values of the locks array, which would both be 0 at the time. However, this benign behavior relies on the fact that the path being passed hasn't been initialised, if it has already been used to query a btree then it could potentially have populated the nodes/slots arrays.
Fix it by explicitly checking if we are at level 7 (the maximum allowed index in nodes/slots arrays) and explicitly call the CoW routine with NULL for parent's node/slot.
Fixes-coverity-id: 711515
--- fs/btrfs/ctree.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/ctree.c +9 -3
@@ -2758,6 +2758,8 @@ again:* contention with the cow code */ if (cow) { +bool last_level = (level == (BTRFS_MAX_LEVEL -1 )); +/* * if we don't really need to cow this block * then we don't want to set the path blocking,
@@ -2782,9 +2784,13 @@ again: }btrfs_set_path_blocking (p); - err =btrfs_cow_block (trans, root, b, - p->nodes[level +1 ], - p->slots[level +1 ], &b); +if (last_level) + err =btrfs_cow_block (trans, root, b,NULL ,0 , + &b); +else + err =btrfs_cow_block (trans, root, b, + p->nodes[level +1 ], + p->slots[level +1 ], &b);if (err) { ret = err; goto done;
Signature · 1 line
2.15.1
PATCH 77/101 scsi: devinfo: fix format of the device list
In reply to Sasha LevinFrom: Xose Vazquez Perez <[email protected]>
[ Upstream commit 3f884a0a8bdf28cfd1e9987d54d83350096cdd46 ]
Replace "" with NULL for product revision level, and merge TEXEL duplicate entries.
--- drivers/scsi/scsi_devinfo.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/scsi_devinfo.c +3 -4
@@ -108,8 +108,8 @@ static struct {* seagate controller, which causes SCSI code to reset bus. */ {"HP", "C1750A", "3226", BLIST_NOLUN}, /* scanjet iic */ - {"HP", "C1790A", "", BLIST_NOLUN}, /* scanjet iip */ - {"HP", "C2500A", "", BLIST_NOLUN}, /* scanjet iicx */ + {"HP", "C1790A", NULL, BLIST_NOLUN}, /* scanjet iip */ + {"HP", "C2500A", NULL, BLIST_NOLUN}, /* scanjet iicx */ {"MEDIAVIS", "CDR-H93MV", "1.31", BLIST_NOLUN}, /* locks up */ {"MICROTEK", "ScanMaker II", "5.61", BLIST_NOLUN}, /* responds to all lun */ {"MITSUMI", "CD-R CR-2201CS", "6119", BLIST_NOLUN}, /* locks up */
@@ -119,7 +119,7 @@ static struct { {"QUANTUM", "FIREBALL ST4.3S", "0F0C", BLIST_NOLUN}, /* locks up */ {"RELISYS", "Scorpio", NULL, BLIST_NOLUN}, /* responds to all lun */ {"SANKYO", "CP525", "6.64", BLIST_NOLUN}, /* causes failed REQ SENSE, extra reset */ - {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN}, + {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN | BLIST_BORKEN}, {"transtec", "T5008", "0001", BLIST_NOREPORTLUN }, {"YAMAHA", "CDR100", "1.00", BLIST_NOLUN}, /* locks up */ {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN}, /* locks up */
@@ -248,7 +248,6 @@ static struct { {"ST650211", "CF", NULL, BLIST_RETRY_HWERROR}, {"SUN", "T300", "*", BLIST_SPARSELUN}, {"SUN", "T4", "*", BLIST_SPARSELUN}, - {"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN}, {"Tornado-", "F4", "*", BLIST_NOREPORTLUN}, {"TOSHIBA", "CDROM", NULL, BLIST_ISROM}, {"TOSHIBA", "CD-ROM", NULL, BLIST_ISROM},
Signature · 1 line
2.15.1
PATCH 78/101 scsi: fas216: fix sense buffer initialization
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 96d5eaa9bb74d299508d811d865c2c41b38b0301 ]
While testing with the ARM specific memset() macro removed, I ran into a compiler warning that shows an old bug:
drivers/scsi/arm/fas216.c: In function 'fas216_rq_sns_done':drivers/scsi/arm/fas216.c:2014:40: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
It turns out that the definition of the scsi_cmd structure changed back in linux-2.6.25, so now we clear only four bytes (sizeof(pointer)) instead of 96 (SCSI_SENSE_BUFFERSIZE). I did not check whether we actually need to initialize the buffer here, but it's clear that if we do it, we should use the correct size.
--- drivers/scsi/arm/fas216.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/arm/fas216.c +1 -1
@@ -2010,7 +2010,7 @@ static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,* have valid data in the sense buffer that could * confuse the higher levels. */ -memset (SCpnt->sense_buffer,0 ,sizeof (SCpnt->sense_buffer)); +memset (SCpnt->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE );//printk("scsi%d.%c: sense buffer: ", info->host->host_no, '0' + SCpnt->device->id); //{ int i; for (i = 0; i < 32; i++) printk("%02x ", SCpnt->sense_buffer[i]); printk("\n"); } /*
Signature · 1 line
2.15.1
PATCH 79/101 HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 7ad81482cad67cbe1ec808490d1ddfc420c42008 ]
We get the "new_profile_index" value from the mouse device when we're handling raw events. Smatch taints it as untrusted data and complains that we need a bounds check. This seems like a reasonable warning otherwise there is a small read beyond the end of the array.
--- drivers/hid/hid-roccat-kovaplus.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-roccat-kovaplus.c +2 -0
@@ -37,6 +37,8 @@ static uint kovaplus_convert_event_cpi(uint value)static void kovaplus_profile_activated (struct kovaplus_device *kovaplus,uint new_profile_index) { +if (new_profile_index >=ARRAY_SIZE (kovaplus->profile_settings)) +return ; kovaplus->actual_profile = new_profile_index; kovaplus->actual_cpi = kovaplus->profile_settings[new_profile_index].cpi_startup_level; kovaplus->actual_x_sensitivity = kovaplus->profile_settings[new_profile_index].sensitivity_x;
Signature · 1 line
2.15.1
PATCH 80/101 jffs2: Fix use-after-free bug in jffs2_iget()'s error handling path
In reply to Sasha LevinFrom: Jake Daryll Obina <[email protected]>
[ Upstream commit 5bdd0c6f89fba430e18d636493398389dadc3b17 ]
If jffs2_iget() fails for a newly-allocated inode, jffs2_do_clear_inode() can get called twice in the error handling path, the first call in jffs2_iget() itself and the second through iget_failed(). This can result to a use-after-free error in the second jffs2_do_clear_inode() call, such as shown by the oops below wherein the second jffs2_do_clear_inode() call was trying to free node fragments that were already freed in the first jffs2_do_clear_inode() call.
[ 78.178860] jffs2: error: (1904) jffs2_do_read_inode_internal: CRC failed for read_inode of inode 24 at physical location 0x1fc00c [ 78.178914] Unable to handle kernel paging request at virtual address 6b6b6b6b6b6b6b7b [ 78.185871] pgd = ffffffc03a567000 [ 78.188794] [6b6b6b6b6b6b6b7b] *pgd=0000000000000000, *pud=0000000000000000 [ 78.194968] Internal error: Oops: 96000004 [#1] PREEMPT SMP ... [ 78.513147] PC is at rb_first_postorder+0xc/0x28 [ 78.516503] LR is at jffs2_kill_fragtree+0x28/0x90 [jffs2] [ 78.520672] pc : [<ffffff8008323d28>] lr : [<ffffff8000eb1cc8>] pstate: 60000105 [ 78.526757] sp : ffffff800cea38f0 [ 78.528753] x29: ffffff800cea38f0 x28: ffffffc01f3f8e80 [ 78.532754] x27: 0000000000000000 x26: ffffff800cea3c70 [ 78.536756] x25: 00000000dc67c8ae x24: ffffffc033d6945d [ 78.540759] x23: ffffffc036811740 x22: ffffff800891a5b8 [ 78.544760] x21: 0000000000000000 x20: 0000000000000000 [ 78.548762] x19: ffffffc037d48910 x18: ffffff800891a588 [ 78.552764] x17: 0000000000000800 x16: 0000000000000c00 [ 78.556766] x15: 0000000000000010 x14: 6f2065646f6e695f [ 78.560767] x13: 6461657220726f66 x12: 2064656c69616620 [ 78.564769] x11: 435243203a6c616e x10: 7265746e695f6564 [ 78.568771] x9 : 6f6e695f64616572 x8 : ffffffc037974038 [ 78.572774] x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000008 [ 78.576775] x5 : 002f91d85bd44a2f x4 : 0000000000000000 [ 78.580777] x3 : 0000000000000000 x2 : 000000403755e000 [ 78.584779] x1 : 6b6b6b6b6b6b6b6b x0 : 6b6b6b6b6b6b6b6b ... [ 79.038551] [<ffffff8008323d28>] rb_first_postorder+0xc/0x28 [ 79.042962] [<ffffff8000eb5578>] jffs2_do_clear_inode+0x88/0x100 [jffs2] [ 79.048395] [<ffffff8000eb9ddc>] jffs2_evict_inode+0x3c/0x48 [jffs2] [ 79.053443] [<ffffff8008201ca8>] evict+0xb0/0x168 [ 79.056835] [<ffffff8008202650>] iput+0x1c0/0x200 [ 79.060228] [<ffffff800820408c>] iget_failed+0x30/0x3c [ 79.064097] [<ffffff8000eba0c0>] jffs2_iget+0x2d8/0x360 [jffs2] [ 79.068740] [<ffffff8000eb0a60>] jffs2_lookup+0xe8/0x130 [jffs2] [ 79.073434] [<ffffff80081f1a28>] lookup_slow+0x118/0x190 [ 79.077435] [<ffffff80081f4708>] walk_component+0xfc/0x28c [ 79.081610] [<ffffff80081f4dd0>] path_lookupat+0x84/0x108 [ 79.085699] [<ffffff80081f5578>] filename_lookup+0x88/0x100 [ 79.089960] [<ffffff80081f572c>] user_path_at_empty+0x58/0x6c [ 79.094396] [<ffffff80081ebe14>] vfs_statx+0xa4/0x114 [ 79.098138] [<ffffff80081ec44c>] SyS_newfstatat+0x58/0x98 [ 79.102227] [<ffffff800808354c>] __sys_trace_return+0x0/0x4 [ 79.106489] Code: d65f03c0 f9400001 b40000e1 aa0103e0 (f9400821)
The jffs2_do_clear_inode() call in jffs2_iget() is unnecessary since iget_failed() will eventually call jffs2_do_clear_inode() if needed, so just remove it.
--- fs/jffs2/fs.c | 1 - 1 file changed, 1 deletion(-)
fs/jffs2/fs.c +0 -1
@@ -363,7 +363,6 @@ error_io: ret = -EIO ; error:mutex_unlock (&f->sem); -jffs2_do_clear_inode (c, f);iget_failed (inode);return ERR_PTR (ret); }
Signature · 1 line
2.15.1
PATCH 81/101 RDMA/mlx5: Avoid memory leak in case of XRCD dealloc failure
In reply to Sasha LevinFrom: Leon Romanovsky <[email protected]>
[ Upstream commit b081808a66345ba725b77ecd8d759bee874cd937 ]
Failure in XRCD FW deallocation command leaves memory leaked and returns error to the user which he can't do anything about it.
This patch changes behavior to always free memory and always return success to the user.
--- drivers/infiniband/hw/mlx5/qp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +1 -4
@@ -3028,12 +3028,9 @@ int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd)int err; err =mlx5_core_xrcd_dealloc (dev->mdev, xrcdn); -if (err) { +if (err)mlx5_ib_warn (dev,"failed to dealloc xrcdn 0x%x\n" , xrcdn); -return err; - }kfree (xrcd); -return 0 ; }
Signature · 1 line
2.15.1
PATCH 82/101 ocfs2: return -EROFS to mount.ocfs2 if inode block is invalid
In reply to Sasha LevinFrom: piaojun <[email protected]>
[ Upstream commit 025bcbde3634b2c9b316f227fed13ad6ad6817fb ]
If metadata is corrupted such as 'invalid inode block', we will get failed by calling 'mount()' and then set filesystem readonly as below:
ocfs2_mount
ocfs2_initialize_super
ocfs2_init_global_system_inodes
ocfs2_iget
ocfs2_read_locked_inode
ocfs2_validate_inode_block
ocfs2_error
ocfs2_handle_error
ocfs2_set_ro_flag(osb, 0); // set readonlyIn this situation we need return -EROFS to 'mount.ocfs2', so that user can fix it by fsck. And then mount again. In addition, 'mount.ocfs2' should be updated correspondingly as it only return 1 for all errno. And I will post a patch for 'mount.ocfs2' too.
--- fs/ocfs2/super.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/ocfs2/super.c +2 -3
@@ -467,9 +467,8 @@ static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) new =ocfs2_get_system_file_inode (osb, i, osb->slot_num);if (!new) {ocfs2_release_system_inodes (osb); - status = -EINVAL ; + status =ocfs2_is_soft_readonly (osb) ? -EROFS : -EINVAL ;mlog_errno (status); -/* FIXME: Should ERROR_RO_FS */ mlog (ML_ERROR ,"Unable to load system inode %d, " "possibly corrupt fs?" , i); goto bail;
@@ -498,7 +497,7 @@ static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb) new =ocfs2_get_system_file_inode (osb, i, osb->slot_num);if (!new) {ocfs2_release_system_inodes (osb); - status = -EINVAL ; + status =ocfs2_is_soft_readonly (osb) ? -EROFS : -EINVAL ;mlog (ML_ERROR ,"status=%d, sysfile=%d, slot=%d\n" , status, i, osb->slot_num); goto bail;
Signature · 1 line
2.15.1
PATCH 83/101 ocfs2/acl: use 'ip_xattr_sem' to protect getting extended attribute
In reply to Sasha LevinFrom: piaojun <[email protected]>
[ Upstream commit 16c8d569f5704a84164f30ff01b29879f3438065 ]
The race between *set_acl and *get_acl will cause getting incomplete xattr data as below:
processA processB
ocfs2_set_acl
ocfs2_xattr_set
__ocfs2_xattr_set_handle
ocfs2_get_acl_nolock
ocfs2_xattr_get_nolock:
processB may get incomplete xattr data if processA hasn't set_acl done.
So we should use 'ip_xattr_sem' to protect getting extended attribute in ocfs2_get_acl_nolock(), as other processes could be changing it concurrently.
--- fs/ocfs2/acl.c | 6 ++++++ fs/ocfs2/xattr.c | 2 ++ 2 files changed, 8 insertions(+)
fs/ocfs2/acl.c +6 -0
@@ -300,7 +300,9 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)if (ret <0 )return ERR_PTR (ret); +down_read (&OCFS2_I (inode)->ip_xattr_sem); acl =ocfs2_get_acl_nolock (inode, type, di_bh); +up_read (&OCFS2_I (inode)->ip_xattr_sem);brelse (di_bh);
@@ -319,7 +321,9 @@ int ocfs2_acl_chmod(struct inode *inode, struct buffer_head *bh)if (!(osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ))return 0 ; +down_read (&OCFS2_I (inode)->ip_xattr_sem); acl =ocfs2_get_acl_nolock (inode,ACL_TYPE_ACCESS , bh); +up_read (&OCFS2_I (inode)->ip_xattr_sem);if (IS_ERR (acl) || !acl)return PTR_ERR (acl); ret =__posix_acl_chmod (&acl,GFP_KERNEL , inode->i_mode);
@@ -350,8 +354,10 @@ int ocfs2_init_acl(handle_t *handle,if (!S_ISLNK (inode->i_mode)) {if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { +down_read (&OCFS2_I (dir)->ip_xattr_sem); acl =ocfs2_get_acl_nolock (dir,ACL_TYPE_DEFAULT , dir_bh); +up_read (&OCFS2_I (dir)->ip_xattr_sem);if (IS_ERR (acl))return PTR_ERR (acl); }
fs/ocfs2/xattr.c +2 -0
@@ -645,9 +645,11 @@ int ocfs2_calc_xattr_init(struct inode *dir, si->value_len);if (osb->s_mount_opt &OCFS2_MOUNT_POSIX_ACL ) { +down_read (&OCFS2_I (dir)->ip_xattr_sem); acl_len =ocfs2_xattr_get_nolock (dir, dir_bh,OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT ,"" ,NULL ,0 ); +up_read (&OCFS2_I (dir)->ip_xattr_sem);if (acl_len >0 ) { a_size =ocfs2_xattr_entry_real_size (0 , acl_len);if (S_ISDIR (mode))
Signature · 1 line
2.15.1
PATCH 84/101 mm/mempolicy: fix the check of nodemask from user
In reply to Sasha LevinFrom: Yisheng Xie <[email protected]>
[ Upstream commit 56521e7a02b7b84a5e72691a1fb15570e6055545 ]
As Xiaojun reported the ltp of migrate_pages01 will fail on arm64 system which has 4 nodes[0...3], all have memory and CONFIG_NODES_SHIFT=2:
migrate_pages01 0 TINFO : test_invalid_nodes migrate_pages01 14 TFAIL : migrate_pages_common.c:45: unexpected failure - returned value = 0, expected: -1 migrate_pages01 15 TFAIL : migrate_pages_common.c:55: call succeeded unexpectedly
In this case the test_invalid_nodes of migrate_pages01 will call:SYSC_migrate_pages as:
migrate_pages(0, , {0x0000000000000001}, 64, , {0x0000000000000010}, 64) = 0
The new nodes specifies one or more node IDs that are greater than the maximum supported node ID, however, the errno is not set to EINVAL as expected.
As man pages of set_mempolicy[1], mbind[2], and migrate_pages[3] mentioned, when nodemask specifies one or more node IDs that are greater than the maximum supported node ID, the errno should set to EINVAL. However, get_nodes only check whether the part of bits [BITS_PER_LONG*BITS_TO_LONGS(MAX_NUMNODES), maxnode) is zero or not, and remain [MAX_NUMNODES, BITS_PER_LONG*BITS_TO_LONGS(MAX_NUMNODES) unchecked.
This patch is to check the bits of [MAX_NUMNODES, maxnode) in get_nodes to let migrate_pages set the errno to EINVAL when nodemask specifies one or more node IDs that are greater than the maximum supported node ID, which follows the manpage's guide.
[1] http://man7.org/linux/man-pages/man2/set_mempolicy.2.html
[2] http://man7.org/linux/man-pages/man2/mbind.2.html
[3] http://man7.org/linux/man-pages/man2/migrate_pages.2.html
--- mm/mempolicy.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
mm/mempolicy.c +20 -3
@@ -1286,6 +1286,7 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask, unsigned long maxnode) {unsigned long k; +unsigned long t;unsigned long nlongs;unsigned long endmask;
@@ -1302,13 +1303,19 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask,else endmask = (1UL << (maxnode %BITS_PER_LONG )) -1 ; -/* When the user specified more nodes than supported just check -if the non supported part is all zero. */ +/* +* When the user specified more nodes than supported just check +* if the non supported part is all zero. +* +* If maxnode have more longs than MAX_NUMNODES, check +* the bits in that area first. And then go through to +* check the rest bits which equal or bigger than MAX_NUMNODES. +* Otherwise, just check bits [MAX_NUMNODES, maxnode). +*/ if (nlongs >BITS_TO_LONGS (MAX_NUMNODES )) {if (nlongs >PAGE_SIZE /sizeof (long ))return -EINVAL ;for (k =BITS_TO_LONGS (MAX_NUMNODES ); k < nlongs; k++) { -unsigned long t;if (get_user (t, nmask + k))return -EFAULT ;if (k == nlongs -1 ) {
@@ -1321,6 +1328,16 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask, endmask = ~0UL ; } +if (maxnode >MAX_NUMNODES &&MAX_NUMNODES %BITS_PER_LONG !=0 ) { +unsigned long valid_mask = endmask; + + valid_mask &= ~((1UL << (MAX_NUMNODES %BITS_PER_LONG )) -1 ); +if (get_user (t, nmask + nlongs -1 )) +return -EFAULT ; +if (t & valid_mask) +return -EINVAL ; + } +if (copy_from_user (nodes_addr (*nodes), nmask, nlongs*sizeof (unsigned long )))return -EFAULT ;nodes_addr (*nodes)[nlongs-1 ] &= endmask;
Signature · 1 line
2.15.1
PATCH 85/101 mm/mempolicy: add nodes_empty check in SYSC_migrate_pages
In reply to Sasha LevinFrom: Yisheng Xie <[email protected]>
[ Upstream commit 0486a38bcc4749808edbc848f1bcf232042770fc ]
As in manpage of migrate_pages, the errno should be set to EINVAL when none of the node IDs specified by new_nodes are on-line and allowed by the process's current cpuset context, or none of the specified nodes contain memory. However, when test by following case:
new_nodes = 0; old_nodes = 0xf; ret = migrate_pages(pid, old_nodes, new_nodes, MAX);
The ret will be 0 and no errno is set. As the new_nodes is empty, we should expect EINVAL as documented.
To fix the case like above, this patch check whether target nodes AND current task_nodes is empty, and then check whether AND node_states[N_MEMORY] is empty.
--- mm/mempolicy.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
mm/mempolicy.c +7 -3
@@ -1464,10 +1464,14 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode, goto out_put; } -if (!nodes_subset (*new, node_states[N_MEMORY ])) { - err = -EINVAL ; + task_nodes =cpuset_mems_allowed (current); +nodes_and (*new, *new, task_nodes); +if (nodes_empty (*new)) + goto out_put; + +nodes_and (*new, *new, node_states[N_MEMORY ]); +if (nodes_empty (*new)) goto out_put; - } err =security_task_movememory (task);if (err)
Signature · 1 line
2.15.1
PATCH 86/101 asm-generic: provide generic_pmdp_establish()
In reply to Sasha LevinFrom: "Kirill A. Shutemov" <[email protected]>
[ Upstream commit c58f0bb77ed8bf93dfdde762b01cb67eebbdfc29 ]
Patch series "Do not lose dirty bit on THP pages", v4.
Vlastimil noted that pmdp_invalidate() is not atomic and we can lose dirty and access bits if CPU sets them after pmdp dereference, but before set_pmd_at().
The bug can lead to data loss, but the race window is tiny and I haven't seen any reports that suggested that it happens in reality. So I don't think it worth sending it to stable.
Unfortunately, there's no way to address the issue in a generic way. We need to fix all architectures that support THP one-by-one.
All architectures that have THP supported have to provide atomic pmdp_invalidate() that returns previous value.
If generic implementation of pmdp_invalidate() is used, architecture needs to provide atomic pmdp_estabish().
pmdp_estabish() is not used out-side generic implementation of pmdp_invalidate() so far, but I think this can change in the future.
This patch (of 12):
This is an implementation of pmdp_establish() that is only suitable for an architecture that doesn't have hardware dirty/accessed bits. In this case we can't race with CPU which sets these bits and non-atomic approach is fine.
--- include/asm-generic/pgtable.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/asm-generic/pgtable.h +15 -0
@@ -181,6 +181,21 @@ extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,extern pgtable_t pgtable_trans_huge_withdraw (struct mm_struct *mm,pmd_t *pmdp);#endif +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* +* This is an implementation of pmdp_establish() that is only suitable for an +* architecture that doesn't have hardware dirty/accessed bits. In this case we +* can't race with CPU which sets these bits and non-atomic aproach is fine. +*/ +static inline pmd_t generic_pmdp_establish (struct vm_area_struct *vma, +unsigned long address,pmd_t *pmdp,pmd_t pmd) +{ +pmd_t old_pmd = *pmdp; +set_pmd_at (vma->vm_mm, address, pmdp, pmd); +return old_pmd; +} +#endif +#ifndef __HAVE_ARCH_PMDP_INVALIDATEextern void pmdp_invalidate (struct vm_area_struct *vma,unsigned long address,pmd_t *pmdp);
Signature · 1 line
2.15.1
PATCH 87/101 mm: pin address_space before dereferencing it while isolating an LRU page
In reply to Sasha LevinFrom: Mel Gorman <[email protected]>
[ Upstream commit 69d763fc6d3aee787a3e8c8c35092b4f4960fa5d ]
Minchan Kim asked the following question -- what locks protects address_space destroying when race happens between inode trauncation and __isolate_lru_page? Jan Kara clarified by describing the race as follows
CPU1 CPU2
truncate(inode) __isolate_lru_page()
...
truncate_inode_page(mapping, page);
delete_from_page_cache(page)
spin_lock_irqsave(&mapping->tree_lock, flags);
__delete_from_page_cache(page, NULL)
page_cache_tree_delete(..)
... mapping = page_mapping(page);
page->mapping = NULL;
...
spin_unlock_irqrestore(&mapping->tree_lock, flags);
page_cache_free_page(mapping, page)
put_page(page)
if (put_page_testzero(page)) -> false- inode now has no pages and can be freed including embedded address_space
if (mapping && !mapping->a_ops->migratepage)
- we've dereferenced mapping which is potentially already free.
The race is theoretically possible but unlikely. Before the delete_from_page_cache, truncate_cleanup_page is called so the page is likely to be !PageDirty or PageWriteback which gets skipped by the only caller that checks the mappping in __isolate_lru_page. Even if the race occurs, a substantial amount of work has to happen during a tiny window with no preemption but it could potentially be done using a virtual machine to artifically slow one CPU or halt it during the critical window.
This patch should eliminate the race with truncation by try-locking the page before derefencing mapping and aborting if the lock was not acquired. There was a suggestion from Huang Ying to use RCU as a side-effect to prevent mapping being freed. However, I do not like the solution as it's an unconventional means of preserving a mapping and it's not a context where rcu_read_lock is obviously protecting rcu data.
--- mm/vmscan.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
mm/vmscan.c +12 -2
@@ -1215,6 +1215,7 @@ int __isolate_lru_page(struct page *page, isolate_mode_t mode)if (PageDirty (page)) {struct address_space *mapping; +bool migrate_dirty;/* ISOLATE_CLEAN means only clean pages */ if (mode &ISOLATE_CLEAN )
@@ -1223,10 +1224,19 @@ int __isolate_lru_page(struct page *page, isolate_mode_t mode)/* * Only pages without mappings or that have a * ->migratepage callback are possible to migrate -* without blocking +* without blocking. However, we can be racing with +* truncation so it's necessary to lock the page +* to stabilise the mapping as truncation holds +* the page lock until after the page is removed +* from the page cache. */ +if (!trylock_page (page)) +return ret; + mapping =page_mapping (page); -if (mapping && !mapping->a_ops->migratepage) + migrate_dirty = mapping && mapping->a_ops->migratepage; +unlock_page (page); +if (!migrate_dirty)return ret; } }
Signature · 1 line
2.15.1
PATCH 88/101 IB/ipoib: Fix for potential no-carrier state
In reply to Sasha LevinFrom: Alex Estrin <[email protected]>
[ Upstream commit 1029361084d18cc270f64dfd39529fafa10cfe01 ]
On reboot SM can program port pkey table before ipoib registered its event handler, which could result in missing pkey event and leave root interface with initial pkey value from index 0.
Since OPA port starts with invalid pkey in index 0, root interface will fail to initialize and stay down with no-carrier flag.
For IB ipoib interface may end up with pkey different from value opensm put in pkey table idx 0, resulting in connectivity issues (different mcast groups, for example).
Close the window by calling event handler after registration to make sure ipoib pkey is in sync with port pkey table.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +3 -0
@@ -1644,6 +1644,9 @@ static struct net_device *ipoib_add_port(const char *format, goto event_failed; } +/* call event handler to ensure pkey in sync */ +queue_work (ipoib_workqueue, &priv->flush_heavy); + result =register_netdev (priv->dev);if (result) { printk(KERN_WARNING "%s: couldn't register ipoib port %d; error %d\n",
Signature · 1 line
2.15.1
PATCH 89/101 x86/power: Fix swsusp_arch_resume prototype
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 328008a72d38b5bde6491e463405c34a81a65d3e ]
The declaration for swsusp_arch_resume marks it as 'asmlinkage', but the definition in x86-32 does not, and it fails to include the header with the declaration. This leads to a warning when building with link-time-optimizations:
kernel/power/power.h:108:23: error: type of 'swsusp_arch_resume' does not match original declaration [-Werror=lto-type-mismatch]
extern asmlinkage int swsusp_arch_resume(void);
^arch/x86/power/hibernate_32.c:148:0: note: 'swsusp_arch_resume' was previously declared here
int swsusp_arch_resume(void)
This moves the declaration into a globally visible header file and fixes up both x86 definitions to match it.
--- arch/x86/power/hibernate_32.c | 2 +- arch/x86/power/hibernate_64.c | 2 +- include/linux/suspend.h | 2 ++ kernel/power/power.h | 3 --- 4 files changed, 4 insertions(+), 5 deletions(-)
arch/x86/power/hibernate_32.c +1 -1
@@ -142,7 +142,7 @@ static inline void resume_init_first_level_page_table(pgd_t *pg_dir)#endif } -int swsusp_arch_resume (void ) +asmlinkage int swsusp_arch_resume(void) {int error;
arch/x86/power/hibernate_64.c +1 -1
@@ -78,7 +78,7 @@ static int set_up_temporary_mappings(void)return 0 ; } -int swsusp_arch_resume (void ) +asmlinkage int swsusp_arch_resume(void) {int error;
include/linux/suspend.h +2 -0
@@ -325,6 +325,8 @@ extern int swsusp_page_is_forbidden(struct page *);extern void swsusp_set_page_free (struct page *);extern void swsusp_unset_page_free (struct page *);extern unsigned long get_safe_page (gfp_t gfp_mask); +extern asmlinkage int swsusp_arch_suspend(void); +extern asmlinkage int swsusp_arch_resume(void);extern void hibernation_set_ops (const struct platform_hibernation_ops *ops);extern int hibernate (void );
kernel/power/power.h +0 -3
@@ -85,9 +85,6 @@ extern int in_suspend;extern dev_t swsusp_resume_device;extern sector_t swsusp_resume_block; -extern asmlinkage int swsusp_arch_suspend(void); -extern asmlinkage int swsusp_arch_resume(void); -extern int create_basic_memory_bitmaps (void );extern void free_basic_memory_bitmaps (void );extern int hibernate_preallocate_memory (void );
Signature · 1 line
2.15.1
PATCH 90/101 firmware: dmi_scan: Fix handling of empty DMI strings
In reply to Sasha LevinFrom: Jean Delvare <[email protected]>
[ Upstream commit a7770ae194569e96a93c48aceb304edded9cc648 ]
The handling of empty DMI strings looks quite broken to me:
* Strings from 1 to 7 spaces are not considered empty.
* True empty DMI strings (string index set to 0) are not considered empty, and result in allocating a 0-char string.
* Strings with invalid index also result in allocating a 0-char string.
* Strings starting with 8 spaces are all considered empty, even if non-space characters follow (sounds like a weird thing to do, but I have actually seen occurrences of this in DMI tables before.)
* Strings which are considered empty are reported as 8 spaces, instead of being actually empty.
Some of these issues are the result of an off-by-one error in memcmp, the rest is incorrect by design.
So let's get it square: missing strings and strings made of only spaces, regardless of their length, should be treated as empty and no memory should be allocated for them. All other strings are non-empty and should be allocated.
--- drivers/firmware/dmi_scan.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/firmware/dmi_scan.c +9 -13
@@ -15,7 +15,7 @@* of and an antecedent to, SMBIOS, which stands for System * Management BIOS. See further: http://www.dmtf.org/standards */ -static const char dmi_empty_string[] =" " ; +static const char dmi_empty_string[] ="" ;static u16 __initdata dmi_ver;/*
@@ -36,25 +36,21 @@ static int dmi_memdev_nr;static const char *__init dmi_string_nosave (const struct dmi_header *dm,u8 s) {const u8 *bp = ((u8 *) dm) + dm->length; +const u8 *nsp;if (s) { - s--; -while (s >0 && *bp) { +while (--s >0 && *bp) bp +=strlen (bp) +1 ; - s--; - } - -if (*bp !=0 ) { -size_t len =strlen (bp)+1 ; -size_t cmp_len = len >8 ?8 : len; -if (!memcmp (bp, dmi_empty_string, cmp_len)) -return dmi_empty_string; +/* Strings containing only spaces are considered empty */ + nsp = bp; +while (*nsp ==' ' ) + nsp++; +if (*nsp !='\0' )return bp; - } } -return "" ; +return dmi_empty_string; }static const char *__init dmi_string (const struct dmi_header *dm,u8 s)
Signature · 1 line
2.15.1
PATCH 91/101 ACPI: processor_perflib: Do not send _PPC change notification if not ready
In reply to Sasha LevinFrom: Chen Yu <[email protected]>
[ Upstream commit ba1edb9a5125a617d612f98eead14b9b84e75c3a ]
The following warning was triggered after resumed from S3 - if all the nonboot CPUs were put offline before suspend:
[ 1840.329515] unchecked MSR access error: RDMSR from 0x771 at rIP: 0xffffffff86061e3a (native_read_msr+0xa/0x30) [ 1840.329516] Call Trace: [ 1840.329521] __rdmsr_on_cpu+0x33/0x50 [ 1840.329525] generic_exec_single+0x81/0xb0 [ 1840.329527] smp_call_function_single+0xd2/0x100 [ 1840.329530] ? acpi_ds_result_pop+0xdd/0xf2 [ 1840.329532] ? acpi_ds_create_operand+0x215/0x23c [ 1840.329534] rdmsrl_on_cpu+0x57/0x80 [ 1840.329536] ? cpumask_next+0x1b/0x20 [ 1840.329538] ? rdmsrl_on_cpu+0x57/0x80 [ 1840.329541] intel_pstate_update_perf_limits+0xf3/0x220 [ 1840.329544] ? notifier_call_chain+0x4a/0x70 [ 1840.329546] intel_pstate_set_policy+0x4e/0x150 [ 1840.329548] cpufreq_set_policy+0xcd/0x2f0 [ 1840.329550] cpufreq_update_policy+0xb2/0x130 [ 1840.329552] ? cpufreq_update_policy+0x130/0x130 [ 1840.329556] acpi_processor_ppc_has_changed+0x65/0x80 [ 1840.329558] acpi_processor_notify+0x80/0x100 [ 1840.329561] acpi_ev_notify_dispatch+0x44/0x5c [ 1840.329563] acpi_os_execute_deferred+0x14/0x20 [ 1840.329565] process_one_work+0x193/0x3c0 [ 1840.329567] worker_thread+0x35/0x3b0 [ 1840.329569] kthread+0x125/0x140 [ 1840.329571] ? process_one_work+0x3c0/0x3c0 [ 1840.329572] ? kthread_park+0x60/0x60 [ 1840.329575] ? do_syscall_64+0x67/0x180 [ 1840.329577] ret_from_fork+0x25/0x30 [ 1840.329585] unchecked MSR access error: WRMSR to 0x774 (tried to write 0x0000000000000000) at rIP: 0xffffffff86061f78 (native_write_msr+0x8/0x30) [ 1840.329586] Call Trace: [ 1840.329587] __wrmsr_on_cpu+0x37/0x40 [ 1840.329589] generic_exec_single+0x81/0xb0 [ 1840.329592] smp_call_function_single+0xd2/0x100 [ 1840.329594] ? acpi_ds_create_operand+0x215/0x23c [ 1840.329595] ? cpumask_next+0x1b/0x20 [ 1840.329597] wrmsrl_on_cpu+0x57/0x70 [ 1840.329598] ? rdmsrl_on_cpu+0x57/0x80 [ 1840.329599] ? wrmsrl_on_cpu+0x57/0x70 [ 1840.329602] intel_pstate_hwp_set+0xd3/0x150 [ 1840.329604] intel_pstate_set_policy+0x119/0x150 [ 1840.329606] cpufreq_set_policy+0xcd/0x2f0 [ 1840.329607] cpufreq_update_policy+0xb2/0x130 [ 1840.329610] ? cpufreq_update_policy+0x130/0x130 [ 1840.329613] acpi_processor_ppc_has_changed+0x65/0x80 [ 1840.329615] acpi_processor_notify+0x80/0x100 [ 1840.329617] acpi_ev_notify_dispatch+0x44/0x5c [ 1840.329619] acpi_os_execute_deferred+0x14/0x20 [ 1840.329620] process_one_work+0x193/0x3c0 [ 1840.329622] worker_thread+0x35/0x3b0 [ 1840.329624] kthread+0x125/0x140 [ 1840.329625] ? process_one_work+0x3c0/0x3c0 [ 1840.329626] ? kthread_park+0x60/0x60 [ 1840.329628] ? do_syscall_64+0x67/0x180 [ 1840.329631] ret_from_fork+0x25/0x30
This is because if there's only one online CPU, the MSR_PM_ENABLE (package wide)can not be enabled after resumed, due to intel_pstate_hwp_enable() will only be invoked on AP's online process after resumed - if there's no AP online, the HWP remains disabled after resumed (BIOS has disabled it in S3). Then if there comes a _PPC change notification which touches HWP register during this stage, the warning is triggered.
Since we don't call acpi_processor_register_performance() when HWP is enabled, the pr->performance will be NULL. When this is NULL we don't need to do _PPC change notification.
--- drivers/acpi/processor_perflib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/processor_perflib.c +1 -1
@@ -165,7 +165,7 @@ int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag) {int ret; -if (ignore_ppc) { +if (ignore_ppc || !pr->performance) {/* * Only when it is notification event, the _OST object * will be evaluated. Otherwise it is skipped.
Signature · 1 line
2.15.1
PATCH 92/101 MIPS: TXx9: use IS_BUILTIN() for CONFIG_LEDS_CLASS
In reply to Sasha LevinFrom: Matt Redfearn <[email protected]>
[ Upstream commit 0cde5b44a30f1daaef1c34e08191239dc63271c4 ]
When commit b27311e1cace ("MIPS: TXx9: Add RBTX4939 board support") added board support for the RBTX4939, it added a call to led_classdev_register even if the LED class is built as a module. Built-in arch code cannot call module code directly like this. Commit b33b44073734 ("MIPS: TXX9: use IS_ENABLED() macro") subsequently changed the inclusion of this code to a single check that CONFIG_LEDS_CLASS is either builtin or a module, but the same issue remains.
This leads to MIPS allmodconfig builds failing when CONFIG_MACH_TX49XX=y is set:
arch/mips/txx9/rbtx4939/setup.o: In function `rbtx4939_led_probe':
setup.c:(.init.text+0xc0): undefined reference to `of_led_classdev_register'
make: *** [Makefile:999: vmlinux] Error 1
Fix this by using the IS_BUILTIN() macro instead.
Patchwork: https://patchwork.linux-mips.org/patch/18544/
--- arch/mips/txx9/rbtx4939/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/txx9/rbtx4939/setup.c +2 -2
@@ -186,7 +186,7 @@ static void __init rbtx4939_update_ioc_pen(void)#define RBTX4939_MAX_7SEGLEDS 8 -#if IS_ENABLED(CONFIG_LEDS_CLASS) +#if IS_BUILTIN(CONFIG_LEDS_CLASS) static u8 led_val[RBTX4939_MAX_7SEGLEDS]; struct rbtx4939_led_data { struct led_classdev cdev;
@@ -262,7 +262,7 @@ static inline void rbtx4939_led_setup(void)static void __rbtx4939_7segled_putc (unsigned int pos,unsigned char val) { -#if IS_ENABLED (CONFIG_LEDS_CLASS ) +#if IS_BUILTIN (CONFIG_LEDS_CLASS )unsigned long flags;local_irq_save (flags);/* bit7: reserved for LED class */
Signature · 1 line
2.15.1
PATCH 93/101 xen/grant-table: Use put_page instead of free_page
In reply to Sasha LevinFrom: Ross Lagerwall <[email protected]>
[ Upstream commit 3ac7292a25db1c607a50752055a18aba32ac2176 ]
The page given to gnttab_end_foreign_access() to free could be a compound page so use put_page() instead of free_page() since it can handle both compound and single pages correctly.
This bug was discovered when migrating a Xen VM with several VIFs and CONFIG_DEBUG_VM enabled. It hits a BUG usually after fewer than 10 iterations. All netfront devices disconnect from the backend during a suspend/resume and this will call gnttab_end_foreign_access() if a netfront queue has an outstanding skb. The mismatch between calling get_page() and free_page() on a compound page causes a reference counting error which is detected when DEBUG_VM is enabled.
--- drivers/xen/grant-table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/grant-table.c +2 -2
@@ -322,7 +322,7 @@ static void gnttab_handle_deferred(unsigned long unused)if (entry->page) {pr_debug ("freeing g.e. %#x (pfn %#lx)\n" , entry->ref,page_to_pfn (entry->page)); -__free_page (entry->page); +put_page (entry->page); }else pr_info ("freeing g.e. %#x\n" , entry->ref);kfree (entry);
@@ -378,7 +378,7 @@ void gnttab_end_foreign_access(grant_ref_t ref, int readonly,if (gnttab_end_foreign_access_ref (ref, readonly)) {put_free_entry (ref);if (page !=0 ) -free_page (page); +put_page (virt_to_page (page)); }else gnttab_add_deferred (ref, readonly, page ?virt_to_page (page) :NULL );
Signature · 1 line
2.15.1
PATCH 94/101 proc: fix /proc/*/map_files lookup
In reply to Sasha LevinFrom: Alexey Dobriyan <[email protected]>
[ Upstream commit ac7f1061c2c11bb8936b1b6a94cdb48de732f7a4 ]
Current code does:
if (sscanf(dentry->d_name.name, "%lx-%lx", start, end) != 2)
However sscanf() is broken garbage.
It silently accepts whitespace between format specifiers (did you know that?).
It silently accepts valid strings which result in integer overflow.
Do not use sscanf() for any even remotely reliable parsing code.
OK # readlink '/proc/1/map_files/55a23af39000-55a23b05b000' /lib/systemd/systemd broken # readlink '/proc/1/map_files/ 55a23af39000-55a23b05b000' /lib/systemd/systemd broken # readlink '/proc/1/map_files/55a23af39000-55a23b05b000 ' /lib/systemd/systemd very broken # readlink '/proc/1/map_files/1000000000000000055a23af39000-55a23b05b000' /lib/systemd/systemd
Andrei said:
: This patch breaks criu. It was a bug in criu. And this bug is on a minor : path, which works when memfd_create() isn't available. It is a reason why : I ask to not backport this patch to stable kernels.
:
: In CRIU this bug can be triggered, only if this patch will be backported : to a kernel which version is lower than v3.16.
--- fs/proc/base.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
fs/proc/base.c +28 -1
@@ -94,6 +94,8 @@#include "internal.h" #include "fd.h" +#include "../../lib/kstrtox.h" +/* NOTE: * Implementing inode permission operations in /proc is almost * certainly an error. Permission checks need to happen during
@@ -1642,8 +1644,33 @@ end_instantiate:static int dname_to_vma_addr (struct dentry *dentry,unsigned long *start,unsigned long *end) { -if (sscanf (dentry->d_name.name,"%lx-%lx" , start, end) !=2 ) +const char *str = dentry->d_name.name; +unsigned long long sval, eval; +unsigned int len; + + len =_parse_integer (str,16 , &sval); +if (len &KSTRTOX_OVERFLOW ) +return -EINVAL ; +if (sval != (unsigned long )sval)return -EINVAL ; + str += len; + +if (*str !='-' ) +return -EINVAL ; + str++; + + len =_parse_integer (str,16 , &eval); +if (len &KSTRTOX_OVERFLOW ) +return -EINVAL ; +if (eval != (unsigned long )eval) +return -EINVAL ; + str += len; + +if (*str !='\0' ) +return -EINVAL ; + + *start = sval; + *end = eval;return 0 ; }
Signature · 1 line
2.15.1
PATCH 95/101 cifs: silence compiler warnings showing up with gcc-8.0.0
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit ade7db991b47ab3016a414468164f4966bd08202 ]
This bug was fixed before, but came up again with the latest compiler in another function:
fs/cifs/cifssmb.c: In function 'CIFSSMBSetEA':fs/cifs/cifssmb.c:6362:3: error: 'strncpy' offset 8 is out of the bounds [0, 4] [-Werror=array-bounds]
strncpy(parm_data->list[0].name, ea_name, name_len);
Let's apply the same fix that was used for the other instances.
--- fs/cifs/cifssmb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/cifs/cifssmb.c +1 -3
@@ -6413,9 +6413,7 @@ SetEARetry: pSMB->InformationLevel =cpu_to_le16 (SMB_SET_FILE_EA ); - parm_data = - (struct fealist *) (((char *) &pSMB->hdr.Protocol) + - offset); + parm_data = (void *)pSMB + offsetof(struct smb_hdr , Protocol) + offset; pSMB->ParameterOffset =cpu_to_le16 (param_offset); pSMB->DataOffset =cpu_to_le16 (offset); pSMB->SetupCount =1 ;
Signature · 1 line
2.15.1
PATCH 96/101 bcache: properly set task state in bch_writeback_thread()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 99361bbf26337186f02561109c17a4c4b1a7536a ]
Kernel thread routine bch_writeback_thread() has the following code block,
447 down_write(&dc->writeback_lock);
448~450 if (check conditions) {
451 up_write(&dc->writeback_lock);
452 set_current_state(TASK_INTERRUPTIBLE);
453
454 if (kthread_should_stop())
455 return 0;
456
457 schedule();
458 continue;
459 }
If condition check is true, its task state is set to TASK_INTERRUPTIBLE and call schedule() to wait for others to wake up it.
There are 2 issues in current code,
1, Task state is set to TASK_INTERRUPTIBLE after the condition checks, if
another process changes the condition and call wake_up_process(dc-> writeback_thread), then at line 452 task state is set back to TASK_INTERRUPTIBLE, the writeback kernel thread will lose a chance to be waken up.
2, At line 454 if kthread_should_stop() is true, writeback kernel thread
will return to kernel/kthread.c:kthread() with TASK_INTERRUPTIBLE and call do_exit(). It is not good to enter do_exit() with task state TASK_INTERRUPTIBLE, in following code path might_sleep() is called and a warning message is reported by __might_sleep(): "WARNING: do not call blocking ops when !TASK_RUNNING; state=1 set at [xxxx]".
For the first issue, task state should be set before condition checks. Ineed because dc->writeback_lock is required when modifying all the conditions, calling set_current_state() inside code block where dc-> writeback_lock is hold is safe. But this is quite implicit, so I still move set_current_state() before all the condition checks.
For the second issue, frankley speaking it does not hurt when kernel thread exits with TASK_INTERRUPTIBLE state, but this warning message scares users, makes them feel there might be something risky with bcache and hurt their data. Setting task state to TASK_RUNNING before returning fixes this problem.
In alloc.c:allocator_wait(), there is also a similar issue, and is also fixed in this patch.
Changelog:
v3: merge two similar fixes into one patch
v2: fix the race issue in v1 patch.
v1: initial buggy fix.
--- drivers/md/bcache/alloc.c | 4 +++- drivers/md/bcache/writeback.c | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/md/bcache/alloc.c +3 -1
@@ -285,8 +285,10 @@ do { \break ; \ \mutex_unlock (&(ca)->set->bucket_lock); \ -if (kthread_should_stop ()) \ +if (kthread_should_stop ()) { \ +set_current_state (TASK_RUNNING ); \return 0 ; \ + } \ \try_to_freeze (); \schedule (); \
drivers/md/bcache/writeback.c +5 -2
@@ -425,19 +425,22 @@ static int bch_writeback_thread(void *arg)while (!kthread_should_stop ()) {down_write (&dc->writeback_lock); +set_current_state (TASK_INTERRUPTIBLE );if (!atomic_read (&dc->has_dirty) || (!test_bit (BCACHE_DEV_DETACHING , &dc->disk.flags) && !dc->writeback_running)) {up_write (&dc->writeback_lock); -set_current_state (TASK_INTERRUPTIBLE ); -if (kthread_should_stop ()) +if (kthread_should_stop ()) { +set_current_state (TASK_RUNNING );return 0 ; + }try_to_freeze ();schedule ();continue ; } +set_current_state (TASK_RUNNING ); searched_full_index =refill_dirty (dc);
Signature · 1 line
2.15.1
PATCH 97/101 bcache: fix for allocator and register thread race
In reply to Sasha LevinFrom: Tang Junhui <[email protected]>
[ Upstream commit 682811b3ce1a5a4e20d700939a9042f01dbc66c4 ]
After long time running of random small IO writing, I reboot the machine, and after the machine power on, I found bcache got stuck, the stack is:
[root@ceph153 ~]# cat /proc/2510/task/*/stack
[<ffffffffa06b2455>] closure_sync+0x25/0x90 [bcache] [<ffffffffa06b6be8>] bch_journal+0x118/0x2b0 [bcache] [<ffffffffa06b6dc7>] bch_journal_meta+0x47/0x70 [bcache] [<ffffffffa06be8f7>] bch_prio_write+0x237/0x340 [bcache] [<ffffffffa06a8018>] bch_allocator_thread+0x3c8/0x3d0 [bcache] [<ffffffff810a631f>] kthread+0xcf/0xe0 [<ffffffff8164c318>] ret_from_fork+0x58/0x90 [<ffffffffffffffff>] 0xffffffffffffffff [root@ceph153 ~]# cat /proc/2038/task/*/stack [<ffffffffa06b1abd>] __bch_btree_map_nodes+0x12d/0x150 [bcache] [<ffffffffa06b1bd1>] bch_btree_insert+0xf1/0x170 [bcache] [<ffffffffa06b637f>] bch_journal_replay+0x13f/0x230 [bcache] [<ffffffffa06c75fe>] run_cache_set+0x79a/0x7c2 [bcache] [<ffffffffa06c0cf8>] register_bcache+0xd48/0x1310 [bcache] [<ffffffff812f702f>] kobj_attr_store+0xf/0x20 [<ffffffff8125b216>] sysfs_write_file+0xc6/0x140 [<ffffffff811dfbfd>] vfs_write+0xbd/0x1e0 [<ffffffff811e069f>] SyS_write+0x7f/0xe0 [<ffffffff8164c3c9>] system_call_fastpath+0x16/0x1
The stack shows the register thread and allocator thread were getting stuck when registering cache device.
I reboot the machine several times, the issue always exsit in this machine.
I debug the code, and found the call trace as bellow:register_bcache()
==>run_cache_set()
==>bch_journal_replay()
==>bch_btree_insert()
==>__bch_btree_map_nodes()
==>btree_insert_fn()
==>btree_split() //node need split
==>btree_check_reserve()In btree_check_reserve(), It will check if there is enough buckets of RESERVE_BTREE type, since allocator thread did not work yet, so no buckets of RESERVE_BTREE type allocated, so the register thread waits on c->btree_cache_wait, and goes to sleep.
Then the allocator thread initialized, the call trace is bellow:bch_allocator_thread()
==>bch_prio_write()
==>bch_journal_meta()
==>bch_journal()
==>journal_wait_for_write()In journal_wait_for_write(), It will check if journal is full by journal_full(), but the long time random small IO writing causes the exhaustion of journal buckets(journal.blocks_free=0), In order to release the journal buckets,
the allocator calls btree_flush_write() to flush keys to btree nodes, and waits on c->journal.wait until btree nodes writing over or there has already some journal buckets space, then the allocator thread goes to sleep. but in btree_flush_write(), since bch_journal_replay() is not finished, so no btree nodes have journal (condition "if (btree_current_write(b)->journal)" never satisfied), so we got no btree node to flush, no journal bucket released, and allocator sleep all the times.
Through the above analysis, we can see that:
1) Register thread wait for allocator thread to allocate buckets of RESERVE_BTREE type;
2) Alloctor thread wait for register thread to replay journal, so it can flush btree nodes and get journal bucket.
then they are all got stuck by waiting for each other.
Hua Rui provided a patch for me, by allocating some buckets of RESERVE_BTREE type in advance, so the register thread can get bucket when btree node splitting and no need to waiting for the allocator thread. I tested it, it has effect, and register thread run a step forward, but finally are still got stuck, the reason is only 8 bucket of RESERVE_BTREE type were allocated, and in bch_journal_replay(), after 2 btree nodes splitting, only 4 bucket of RESERVE_BTREE type left, then btree_check_reserve() is not satisfied anymore, so it goes to sleep again, and in the same time, alloctor thread did not flush enough btree nodes to release a journal bucket, so they all got stuck again.
So we need to allocate more buckets of RESERVE_BTREE type in advance, but how much is enough? By experience and test, I think it should be as much as journal buckets. Then I modify the code as this patch, and test in the machine, and it works.
This patch modified base on Hua Rui’s patch, and allocate more buckets of RESERVE_BTREE type in advance to avoid register thread and allocate thread going to wait for each other.
[patch v2] ca->sb.njournal_buckets would be 0 in the first time after cache creation, and no journal exists, so just 8 btree buckets is OK.
--- drivers/md/bcache/btree.c | 9 ++++++--- drivers/md/bcache/super.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/md/bcache/btree.c +6 -3
@@ -1869,14 +1869,17 @@ void bch_initial_gc_finish(struct cache_set *c)*/ for_each_cache (ca, c, i) {for_each_bucket (b, ca) { -if (fifo_full (&ca->free[RESERVE_PRIO ])) +if (fifo_full (&ca->free[RESERVE_PRIO ]) && +fifo_full (&ca->free[RESERVE_BTREE ]))break ;if (bch_can_invalidate_bucket (ca, b) && !GC_MARK (b)) {__bch_invalidate_one_bucket (ca, b); -fifo_push (&ca->free[RESERVE_PRIO ], - b - ca->buckets); +if (!fifo_push (&ca->free[RESERVE_PRIO ], + b - ca->buckets)) +fifo_push (&ca->free[RESERVE_BTREE ], + b - ca->buckets); } } }
drivers/md/bcache/super.c +12 -1
@@ -1842,6 +1842,7 @@ void bch_cache_release(struct kobject *kobj)static int cache_alloc (struct cache_sb *sb,struct cache *ca) {size_t free; +size_t btree_buckets;struct bucket *b;__module_get (THIS_MODULE );
@@ -1851,9 +1852,19 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca) ca->journal.bio.bi_max_vecs =8 ; ca->journal.bio.bi_io_vec = ca->journal.bio.bi_inline_vecs; +/* +* when ca->sb.njournal_buckets is not zero, journal exists, +* and in bch_journal_replay(), tree node may split, +* so bucket of RESERVE_BTREE type is needed, +* the worst situation is all journal buckets are valid journal, +* and all the keys need to replay, +* so the number of RESERVE_BTREE type buckets should be as much +* as journal buckets +*/ + btree_buckets = ca->sb.njournal_buckets ?:8 ; free =roundup_pow_of_two (ca->sb.nbuckets) >>10 ; - if (!init_fifo(&ca->free[RESERVE_BTREE], 8, GFP_KERNEL) || + if (!init_fifo(&ca->free[RESERVE_BTREE], btree_buckets, GFP_KERNEL) || !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) ||
Signature · 1 line
2.15.1
PATCH 98/101 bcache: fix for data collapse after re-attaching an attached device
In reply to Sasha LevinFrom: Tang Junhui <[email protected]>
[ Upstream commit 73ac105be390c1de42a2f21643c9778a5e002930 ]
back-end device sdm has already attached a cache_set with ID f67ebe1f-f8bc-4d73-bfe5-9dc88607f119, then try to attach with another cache set, and it returns with an error:
[root]# cd /sys/block/sdm/bcache
[root]# echo 5ccd0a63-148e-48b8-afa2-aca9cbd6279f > attach -bash: echo: write error: Invalid argument
After that, execute a command to modify the label of bcache device:
[root]# echo data_disk1 > label
Then we reboot the system, when the system power on, the back-end device can not attach to cache_set, a messages show in the log:
Feb 5 12:05:52 ceph152 kernel: [922385.508498] bcache:
bch_cached_dev_attach() couldn't find uuid for sdm in set
In sysfs_attach(), dc->sb.set_uuid was assigned to the value which input through sysfs, no matter whether it is success or not in bch_cached_dev_attach(). For example, If the back-end device has already attached to an cache set, bch_cached_dev_attach() would fail, but dc->sb.set_uuid was changed. Then modify the label of bcache device, it will call bch_write_bdev_super(), which would write the dc->sb.set_uuid to the super block, so we record a wrong cache set ID in the super block, after the system reboot, the cache set couldn't find the uuid of the back-end device, so the bcache device couldn't exist and use any more.
In this patch, we don't assigned cache set ID to dc->sb.set_uuid in sysfs_attach() directly, but input it into bch_cached_dev_attach(), and assigned dc->sb.set_uuid to the cache set ID after the back-end device attached to the cache set successful.
--- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/super.c | 10 ++++++---- drivers/md/bcache/sysfs.c | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-)
drivers/md/bcache/bcache.h +1 -1
@@ -922,7 +922,7 @@ void bcache_write_super(struct cache_set *);int bch_flash_dev_create (struct cache_set *c,uint64_t size); -int bch_cached_dev_attach (struct cached_dev *,struct cache_set *); +int bch_cached_dev_attach (struct cached_dev *,struct cache_set *,uint8_t *);void bch_cached_dev_detach (struct cached_dev *);void bch_cached_dev_run (struct cached_dev *);void bcache_device_stop (struct bcache_device *);
drivers/md/bcache/super.c +6 -4
@@ -961,7 +961,8 @@ void bch_cached_dev_detach(struct cached_dev *dc)cached_dev_put (dc); } -int bch_cached_dev_attach (struct cached_dev *dc,struct cache_set *c) +int bch_cached_dev_attach (struct cached_dev *dc,struct cache_set *c, +uint8_t *set_uuid) {uint32_t rtime =cpu_to_le32 (get_seconds ());struct uuid_entry *u;
@@ -969,7 +970,8 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)bdevname (dc->bdev, buf); -if (memcmp (dc->sb.set_uuid, c->sb.set_uuid,16 )) +if ((set_uuid &&memcmp (set_uuid, c->sb.set_uuid,16 )) || + (!set_uuid &&memcmp (dc->sb.set_uuid, c->sb.set_uuid,16 )))return -ENOENT ;if (dc->disk.c) {
@@ -1203,7 +1205,7 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,list_add (&dc->list, &uncached_devices);list_for_each_entry (c, &bch_cache_sets, list) -bch_cached_dev_attach (dc, c); +bch_cached_dev_attach (dc, c,NULL );if (BDEV_STATE (&dc->sb) ==BDEV_STATE_NONE ||BDEV_STATE (&dc->sb) ==BDEV_STATE_STALE )
@@ -1723,7 +1725,7 @@ static void run_cache_set(struct cache_set *c)bcache_write_super (c);list_for_each_entry_safe (dc, t, &uncached_devices, list) -bch_cached_dev_attach (dc, c); +bch_cached_dev_attach (dc, c,NULL );flash_devs_run (c);
drivers/md/bcache/sysfs.c +4 -2
@@ -263,11 +263,13 @@ STORE(__cached_dev) }if (attr == &sysfs_attach) { -if (bch_parse_uuid (buf, dc->sb.set_uuid) <16 ) +uint8_t set_uuid[16 ]; + +if (bch_parse_uuid (buf, set_uuid) <16 )return -EINVAL ;list_for_each_entry (c, &bch_cache_sets, list) { - v =bch_cached_dev_attach (dc, c); + v =bch_cached_dev_attach (dc, c, set_uuid);if (!v)return size; }
Signature · 1 line
2.15.1
PATCH 99/101 bcache: return attach error when no cache set exist
In reply to Sasha LevinFrom: Tang Junhui <[email protected]>
[ Upstream commit 7f4fc93d4713394ee8f1cd44c238e046e11b4f15 ]
I attach a back-end device to a cache set, and the cache set is not registered yet, this back-end device did not attach successfully, and no error returned:
[root]# echo 87859280-fec6-4bcc-20df7ca8f86b > /sys/block/sde/bcache/attach [root]#
In sysfs_attach(), the return value "v" is initialized to "size" in the beginning, and if no cache set exist in bch_cache_sets, the "v" value would not change any more, and return to sysfs, sysfs regard it as success since the "size" is a positive number.
This patch fixes this issue by assigning "v" with "-ENOENT" in the initialization.
--- drivers/md/bcache/sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/bcache/sysfs.c +3 -2
@@ -191,7 +191,7 @@ STORE(__cached_dev) { struct cached_dev *dc = container_of(kobj, struct cached_dev, disk.kobj); -ssize_t v = size; +ssize_t v;struct cache_set *c;struct kobj_uevent_env *env;
@@ -268,6 +268,7 @@ STORE(__cached_dev)if (bch_parse_uuid (buf, set_uuid) <16 )return -EINVAL ; + v = -ENOENT ;list_for_each_entry (c, &bch_cache_sets, list) { v =bch_cached_dev_attach (dc, c, set_uuid);if (!v)
@@ -275,7 +276,7 @@ STORE(__cached_dev) }pr_err ("Can't attach %s: cache set not found" , buf); - size = v; +return v; }if (attr == &sysfs_detach && dc->disk.c)
Signature · 1 line
2.15.1
PATCH 100/101 nfsd: return RESOURCE not GARBAGE_ARGS on too many ops
In reply to Sasha LevinFrom: "J. Bruce Fields" <[email protected]>
[ Upstream commit 0078117c6d9160031b866cfa1853514d4f6865d2 ]
A client that sends more than a hundred ops in a single compound currently gets an rpc-level GARBAGE_ARGS error.
It would be more helpful to return NFS4ERR_RESOURCE, since that gives the client a better idea how to recover (for example by splitting up the compound into smaller compounds).
This is all a bit academic since we've never actually seen a reason for clients to send such long compounds, but we may as well fix it.
While we're there, just use NFSD4_MAX_OPS_PER_COMPOUND == 16, the constant we already use in the 4.1 case, instead of hard-coding 100. Chances anyone actually uses even 16 ops per compound are small enough that I think there's a neglible risk or any regression.
This fixes pynfs test COMP6.
--- fs/nfsd/nfs4proc.c | 3 +++ fs/nfsd/nfs4xdr.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -0
@@ -1342,6 +1342,9 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, status = nfserr_minor_vers_mismatch;if (nfsd_minorversion (args->minorversion,NFSD_TEST ) <=0 ) goto out; + status = nfserr_resource; +if (args->opcnt >NFSD_MAX_OPS_PER_COMPOUND ) + goto out; status =nfs41_check_op_ordering (args);if (status) {
fs/nfsd/nfs4xdr.c +7 -2
@@ -1655,8 +1655,13 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)if (argp->taglen >NFSD4_MAX_TAGLEN ) goto xdr_error; -if (argp->opcnt >100 ) - goto xdr_error; +/* +* NFS4ERR_RESOURCE is a more helpful error than GARBAGE_ARGS +* here, so we return success at the xdr level so that +* nfsd4_proc can handle this is an NFS-level error. +*/ +if (argp->opcnt >NFSD_MAX_OPS_PER_COMPOUND ) +return 0 ;if (argp->opcnt >ARRAY_SIZE (argp->iops)) { argp->ops =kzalloc (argp->opcnt *sizeof (*argp->ops),GFP_KERNEL );
Signature · 1 line
2.15.1
PATCH 101/101 irqchip/gic-v3: Change pr_debug message to pr_devel
In reply to Sasha LevinFrom: Mark Salter <[email protected]>
[ Upstream commit b6dd4d83dc2f78cebc9a7e6e7e4bc2be4d29b94d ]
The pr_debug() in gic-v3 gic_send_sgi() can trigger a circular locking warning:
GICv3: CPU10: ICC_SGI1R_EL1 5000400
======================================================
WARNING: possible circular locking dependency detected
4.15.0+ #1 Tainted: G W
------------------------------------------------------
dynamic_debug01/1873 is trying to acquire lock:
((console_sem).lock){-...}, at: [<0000000099c891ec>] down_trylock+0x20/0x4c
but task is already holding lock:
(&rq->lock){-.-.}, at: [<00000000842e1587>] __task_rq_lock+0x54/0xdc
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&rq->lock){-.-.}:
__lock_acquire+0x3b4/0x6e0
lock_acquire+0xf4/0x2a8
_raw_spin_lock+0x4c/0x60
task_fork_fair+0x3c/0x148
sched_fork+0x10c/0x214
copy_process.isra.32.part.33+0x4e8/0x14f0
_do_fork+0xe8/0x78c
kernel_thread+0x48/0x54
rest_init+0x34/0x2a4
start_kernel+0x45c/0x488-> #1 (&p->pi_lock){-.-.}:
__lock_acquire+0x3b4/0x6e0
lock_acquire+0xf4/0x2a8
_raw_spin_lock_irqsave+0x58/0x70
try_to_wake_up+0x48/0x600
wake_up_process+0x28/0x34
__up.isra.0+0x60/0x6c
up+0x60/0x68
__up_console_sem+0x4c/0x7c
console_unlock+0x328/0x634
vprintk_emit+0x25c/0x390
dev_vprintk_emit+0xc4/0x1fc
dev_printk_emit+0x88/0xa8
__dev_printk+0x58/0x9c
_dev_info+0x84/0xa8
usb_new_device+0x100/0x474
hub_port_connect+0x280/0x92c
hub_event+0x740/0xa84
process_one_work+0x240/0x70c
worker_thread+0x60/0x400
kthread+0x110/0x13c
ret_from_fork+0x10/0x18-> #0 ((console_sem).lock){-...}:
validate_chain.isra.34+0x6e4/0xa20
__lock_acquire+0x3b4/0x6e0
lock_acquire+0xf4/0x2a8
_raw_spin_lock_irqsave+0x58/0x70
down_trylock+0x20/0x4c
__down_trylock_console_sem+0x3c/0x9c
console_trylock+0x20/0xb0
vprintk_emit+0x254/0x390
vprintk_default+0x58/0x90
vprintk_func+0xbc/0x164
printk+0x80/0xa0
__dynamic_pr_debug+0x84/0xac
gic_raise_softirq+0x184/0x18c
smp_cross_call+0xac/0x218
smp_send_reschedule+0x3c/0x48
resched_curr+0x60/0x9c
check_preempt_curr+0x70/0xdc
wake_up_new_task+0x310/0x470
_do_fork+0x188/0x78c
SyS_clone+0x44/0x50
__sys_trace_return+0x0/0x4other info that might help us debug this:
Chain exists of: (console_sem).lock --> &p->pi_lock --> &rq->lock Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&rq->lock);
lock(&p->pi_lock);
lock(&rq->lock);lock((console_sem).lock);
*** DEADLOCK ***
2 locks held by dynamic_debug01/1873:
#0: (&p->pi_lock){-.-.}, at: [<000000001366df53>] wake_up_new_task+0x40/0x470 #1: (&rq->lock){-.-.}, at: [<00000000842e1587>] __task_rq_lock+0x54/0xdc
stack backtrace: CPU: 10 PID: 1873 Comm: dynamic_debug01 Tainted: G W 4.15.0+ #1 Hardware name: GIGABYTE R120-T34-00/MT30-GS2-00, BIOS T48 10/02/2017 Call trace: dump_backtrace+0x0/0x188 show_stack+0x24/0x2c dump_stack+0xa4/0xe0 print_circular_bug.isra.31+0x29c/0x2b8 check_prev_add.constprop.39+0x6c8/0x6dc validate_chain.isra.34+0x6e4/0xa20 __lock_acquire+0x3b4/0x6e0 lock_acquire+0xf4/0x2a8 _raw_spin_lock_irqsave+0x58/0x70 down_trylock+0x20/0x4c __down_trylock_console_sem+0x3c/0x9c console_trylock+0x20/0xb0 vprintk_emit+0x254/0x390 vprintk_default+0x58/0x90 vprintk_func+0xbc/0x164 printk+0x80/0xa0 __dynamic_pr_debug+0x84/0xac gic_raise_softirq+0x184/0x18c smp_cross_call+0xac/0x218 smp_send_reschedule+0x3c/0x48 resched_curr+0x60/0x9c check_preempt_curr+0x70/0xdc wake_up_new_task+0x310/0x470 _do_fork+0x188/0x78c SyS_clone+0x44/0x50 __sys_trace_return+0x0/0x4 GICv3: CPU0: ICC_SGI1R_EL1 12000
This could be fixed with printk_deferred() but that might lessen its usefulness for debugging. So change it to pr_devel to keep it out of production kernels. Developers working on gic-v3 can enable it as needed in their kernels.
--- drivers/irqchip/irq-gic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +1 -1
@@ -488,7 +488,7 @@ static void gic_send_sgi(u64 cluster_id, u16 tlist, unsigned int irq)MPIDR_TO_SGI_AFFINITY (cluster_id,1 ) | tlist << ICC_SGI1R_TARGET_LIST_SHIFT); -pr_debug ("CPU%d: ICC_SGI1R_EL1 %llx\n" ,smp_processor_id (), val); +pr_devel ("CPU%d: ICC_SGI1R_EL1 %llx\n" ,smp_processor_id (), val);gic_write_sgi1r (val); }
Signature · 1 line
2.15.1