4.16.13-stable review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 7/272 KVM: Fix spelling mistake: "cop_unsuable" -> "cop_unusable"
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit ba3696e94d9d590d9a7e55f68e81c25dba515191 upstream.
Trivial fix to spelling mistake in debugfs_entries text.
--- arch/mips/kvm/mips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kvm/mips.c +1 -1
@@ -45,7 +45,7 @@ struct kvm_stats_debugfs_item debugfs_en { "cache", VCPU_STAT(cache_exits), KVM_STAT_VCPU }, { "signal", VCPU_STAT(signal_exits), KVM_STAT_VCPU }, { "interrupt", VCPU_STAT(int_exits), KVM_STAT_VCPU }, - { "cop_unsuable", VCPU_STAT(cop_unusable_exits), KVM_STAT_VCPU }, + { "cop_unusable", VCPU_STAT(cop_unusable_exits), KVM_STAT_VCPU }, { "tlbmod", VCPU_STAT(tlbmod_exits), KVM_STAT_VCPU }, { "tlbmiss_ld", VCPU_STAT(tlbmiss_ld_exits), KVM_STAT_VCPU }, { "tlbmiss_st", VCPU_STAT(tlbmiss_st_exits), KVM_STAT_VCPU },
Greg Kroah-Hartman
maintainerPATCH 8/272 affs_lookup(): close a race with affs_remove_link()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 30da870ce4a4e007c901858a96e9e394a1daa74a upstream.
we unlock the directory hash too early - if we are looking at secondary link and primary (in another directory) gets removed just as we unlock, we could have the old primary moved in place of the secondary, leaving us to look into freed entry (and leaving our dentry with ->d_fsdata pointing to a freed entry).
--- fs/affs/namei.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/affs/namei.c +7 -3
@@ -206,9 +206,10 @@ affs_lookup(struct inode *dir, struct deaffs_lock_dir (dir); bh =affs_find_entry (dir, dentry); -affs_unlock_dir (dir); -if (IS_ERR (bh)) +if (IS_ERR (bh)) { +affs_unlock_dir (dir);return ERR_CAST (bh); + }if (bh) {u32 ino = bh->b_blocknr;
@@ -222,10 +223,13 @@ affs_lookup(struct inode *dir, struct de }affs_brelse (bh); inode =affs_iget (sb, ino); -if (IS_ERR (inode)) +if (IS_ERR (inode)) { +affs_unlock_dir (dir);return ERR_CAST (inode); + } }d_add (dentry, inode); +affs_unlock_dir (dir);return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 9/272 fix breakage caused by d_find_alias() semantics change
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit b127125d9db23e4856156a7c909a3c8e18b69f99 upstream.
"VFS: don't keep disconnected dentries on d_anon" had a non-trivial side-effect - d_unhashed() now returns true for those dentries, making d_find_alias() skip them altogether. For most of its callers that's fine - we really want a connected alias there. However, there is a codepath where we relied upon picking such aliases if nothing else could be found - selinux delayed initialization of contexts for inodes on already mounted filesystems used to rely upon that.
--- security/selinux/hooks.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
security/selinux/hooks.c +16 -4
@@ -1532,8 +1532,15 @@ static int inode_doinit_with_dentry(stru/* Called from d_instantiate or d_splice_alias. */ dentry =dget (opt_dentry); }else { -/* Called from selinux_complete_init, try to find a dentry. */ +/* +* Called from selinux_complete_init, try to find a dentry. +* Some filesystems really want a connected one, so try +* that first. We could split SECURITY_FS_USE_XATTR in +* two, depending upon that... +*/ dentry =d_find_alias (inode); +if (!dentry) + dentry =d_find_any_alias (inode); }if (!dentry) {/*
@@ -1636,14 +1643,19 @@ static int inode_doinit_with_dentry(struif ((sbsec->flags &SE_SBGENFS ) && !S_ISLNK (inode->i_mode)) {/* We must have a dentry to determine the label on * procfs inodes */ -if (opt_dentry) +if (opt_dentry) {/* Called from d_instantiate or * d_splice_alias. */ dentry =dget (opt_dentry); -else + }else {/* Called from selinux_complete_init, try to -* find a dentry. */ +* find a dentry. Some filesystems really want +* a connected one, so try that first. +*/ dentry =d_find_alias (inode); +if (!dentry) + dentry =d_find_any_alias (inode); + }/* * This can be hit on boot when a file is accessed * before the policy is loaded. When we load policy we
Greg Kroah-Hartman
maintainerPATCH 19/272 ahci: Add PCI ID for Cannon Lake PCH-LP AHCI
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
commit 4544e403eb25552aed7f0ee181a7a506b8800403 upstream.
This one should be using the default LPM policy for mobile chipsets so add the PCI ID to the driver list of supported revices.
--- drivers/ata/ahci.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/ahci.c +1 -0
@@ -334,6 +334,7 @@ static const struct pci_device_id ahci_p { PCI_VDEVICE(INTEL, 0x9c07), board_ahci_mobile }, /* Lynx LP RAID */ { PCI_VDEVICE(INTEL, 0x9c0e), board_ahci_mobile }, /* Lynx LP RAID */ { PCI_VDEVICE(INTEL, 0x9c0f), board_ahci_mobile }, /* Lynx LP RAID */ + { PCI_VDEVICE(INTEL, 0x9dd3), board_ahci_mobile }, /* Cannon Lake PCH-LP AHCI */ { PCI_VDEVICE(INTEL, 0x1f22), board_ahci }, /* Avoton AHCI */ { PCI_VDEVICE(INTEL, 0x1f23), board_ahci }, /* Avoton AHCI */ { PCI_VDEVICE(INTEL, 0x1f24), board_ahci }, /* Avoton RAID */
Greg Kroah-Hartman
maintainerPATCH 21/272 libata: blacklist Micron 500IT SSD with MU01 firmware
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudip Mukherjee <[email protected]>
commit 136d769e0b3475d71350aa3648a116a6ee7a8f6c upstream.
While whitelisting Micron M500DC drives, the tweaked blacklist entry enabled queued TRIM from M500IT variants also. But these do not support queued TRIM. And while using those SSDs with the latest kernel we have seen errors and even the partition table getting corrupted.
Some part from the dmesg:
[ 6.727384] ata1.00: ATA-9: Micron_M500IT_MTFDDAK060MBD, MU01, max UDMA/133 [ 6.727390] ata1.00: 117231408 sectors, multi 16: LBA48 NCQ (depth 31/32), AA [ 6.741026] ata1.00: supports DRM functions and may not be fully accessible [ 6.759887] ata1.00: configured for UDMA/133 [ 6.762256] scsi 0:0:0:0: Direct-Access ATA Micron_M500IT_MT MU01 PQ: 0 ANSI: 5
and then for the error:
[ 120.860334] ata1.00: exception Emask 0x1 SAct 0x7ffc0007 SErr 0x0 action 0x6 frozen
[ 120.860338] ata1.00: irq_stat 0x40000008
[ 120.860342] ata1.00: failed command: SEND FPDMA QUEUED
[ 120.860351] ata1.00: cmd 64/01:00:00:00:00/00:00:00:00:00/a0 tag 0 ncq dma 512 out
res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x5 (timeout)
[ 120.860353] ata1.00: status: { DRDY }
[ 120.860543] ata1: hard resetting link
[ 121.166128] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[ 121.166376] ata1.00: supports DRM functions and may not be fully accessible
[ 121.186238] ata1.00: supports DRM functions and may not be fully accessible
[ 121.204445] ata1.00: configured for UDMA/133
[ 121.204454] ata1.00: device reported invalid CHS sector 0
[ 121.204541] sd 0:0:0:0: [sda] tag#18 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[ 121.204546] sd 0:0:0:0: [sda] tag#18 Sense Key : 0x5 [current]
[ 121.204550] sd 0:0:0:0: [sda] tag#18 ASC=0x21 ASCQ=0x4
[ 121.204555] sd 0:0:0:0: [sda] tag#18 CDB: opcode=0x93 93 08 00 00 00 00 00 04 28 80 00 00 00 30 00 00
[ 121.204559] print_req_error: I/O error, dev sda, sector 272512After few reboots with these errors, and the SSD is corrupted. After blacklisting it, the errors are not seen and the SSD does not get corrupted any more.
--- drivers/ata/libata-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ata/libata-core.c +2 -0
@@ -4557,6 +4557,8 @@ static const struct ata_blacklist_entry { "SanDisk SD7UB3Q*G1001", NULL, ATA_HORKAGE_NOLPM, }, /* devices that don't properly handle queued TRIM commands */ + { "Micron_M500IT_*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM, }, { "Micron_M500_*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM, }, { "Crucial_CT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
Greg Kroah-Hartman
maintainerPATCH 37/272 kernel/sys.c: fix potential Spectre v1 issue
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit 23d6aef74da86a33fa6bb75f79565e0a16ee97c2 upstream.
`resource' can be controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability.
This issue was detected with the help of Smatch:
kernel/sys.c:1474 __do_compat_sys_old_getrlimit() warn: potential spectre issue 'get_current()->signal->rlim' (local cap) kernel/sys.c:1455 __do_sys_old_getrlimit() warn: potential spectre issue 'get_current()->signal->rlim' (local cap)
Fix this by sanitizing *resource* before using it to index current->signal->rlim
Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1].
[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
--- kernel/sys.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/sys.c +2 -0
@@ -1401,6 +1401,7 @@ SYSCALL_DEFINE2(old_getrlimit, unsignedif (resource >=RLIM_NLIMITS )return -EINVAL ; + resource =array_index_nospec (resource,RLIM_NLIMITS );task_lock (current->group_leader); x = current->signal->rlim[resource];task_unlock (current->group_leader);
@@ -1420,6 +1421,7 @@ COMPAT_SYSCALL_DEFINE2(old_getrlimit, unif (resource >=RLIM_NLIMITS )return -EINVAL ; + resource =array_index_nospec (resource,RLIM_NLIMITS );task_lock (current->group_leader); r = current->signal->rlim[resource];task_unlock (current->group_leader);
Greg Kroah-Hartman
maintainerPATCH 49/272 Btrfs: fix loss of prealloc extents past i_size after fsync log replay
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 471d557afed155b85da237ec46c549f443eeb5de ]
Currently if we allocate extents beyond an inode's i_size (through the fallocate system call) and then fsync the file, we log the extents but after a power failure we replay them and then immediately drop them. This behaviour happens since about 2009, commit c71bf099abdd ("Btrfs:
Avoid orphan inodes cleanup while replaying log"), because it marks the inode as an orphan instead of dropping any extents beyond i_size before replaying logged extents, so after the log replay, and while the mount operation is still ongoing, we find the inode marked as an orphan and then perform a truncation (drop extents beyond the inode's i_size). Because the processing of orphan inodes is still done right after replaying the log and before the mount operation finishes, the intention of that commit does not make any sense (at least as of today). However reverting that behaviour is not enough, because we can not simply discard all extents beyond i_size and then replay logged extents, because we risk dropping extents beyond i_size created in past transactions, for example:
add prealloc extent beyond i_size
fsync - clears the flag BTRFS_INODE_NEEDS_FULL_SYNC from the inode transaction commit
add another prealloc extent beyond i_size
fsync - triggers the fast fsync path
power failure
In that scenario, we would drop the first extent and then replay the second one. To fix this just make sure that all prealloc extents beyond i_size are logged, and if we find too many (which is far from a common case), fallback to a full transaction commit (like we do when logging regular extents in the fast fsync path).
Trivial reproducer:
$ mkfs.btrfs -f /dev/sdb $ mount /dev/sdb /mnt $ xfs_io -f -c "pwrite -S 0xab 0 256K" /mnt/foo $ sync $ xfs_io -c "falloc -k 256K 1M" /mnt/foo $ xfs_io -c "fsync" /mnt/foo <power failure>
# mount to replay log $ mount /dev/sdb /mnt # at this point the file only has one extent, at offset 0, size 256K
A test case for fstests follows soon, covering multiple scenarios that involve adding prealloc extents with previous shrinking truncates and without such truncates.
--- fs/btrfs/tree-log.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 5 deletions(-)
fs/btrfs/tree-log.c +58 -5
@@ -2461,13 +2461,41 @@ static int replay_one_buffer(struct btrfif (ret)break ; -/* for regular files, make sure corresponding -* orphan item exist. extents past the new EOF -* will be truncated later by orphan cleanup. +/* +* Before replaying extents, truncate the inode to its +* size. We need to do it now and not after log replay +* because before an fsync we can have prealloc extents +* added beyond the inode's i_size. If we did it after, +* through orphan cleanup for example, we would drop +* those prealloc extents just after replaying them. */ if (S_ISREG (mode)) { - ret =insert_orphan_item (wc->trans, root, - key.objectid); +struct inode *inode; +u64 from; + + inode =read_one_inode (root, key.objectid); +if (!inode) { + ret = -EIO ; +break ; + } + from =ALIGN (i_size_read (inode), + root->fs_info->sectorsize); + ret =btrfs_drop_extents (wc->trans, root, inode, + from, (u64)-1 ,1 ); +/* +* If the nlink count is zero here, the iput +* will free the inode. We bump it to make +* sure it doesn't get freed until the link +* count fixup is done. +*/ +if (!ret) { +if (inode->i_nlink ==0 ) +inc_nlink (inode); +/* Update link count and nbytes. */ + ret =btrfs_update_inode (wc->trans, + root, inode); + } +iput (inode);if (ret)break ; }
@@ -4321,6 +4349,31 @@ static int btrfs_log_changed_extents(str num++; } +/* +* Add all prealloc extents beyond the inode's i_size to make sure we +* don't lose them after doing a fast fsync and replaying the log. +*/ +if (inode->flags &BTRFS_INODE_PREALLOC ) { +struct rb_node *node; + +for (node =rb_last (&tree->map); node; node =rb_prev (node)) { + em = rb_entry(node, struct extent_map, rb_node); +if (em->start <i_size_read (&inode->vfs_inode)) +break ; +if (!list_empty (&em->list)) +continue ; +/* Same as above loop. */ +if (++num >32768 ) { +list_del_init (&tree->modified_extents); + ret = -EFBIG ; + goto process; + } +refcount_inc (&em->refs); +set_bit (EXTENT_FLAG_LOGGING , &em->flags); +list_add_tail (&em->list, &extents); + } + } +list_sort (NULL , &extents, extent_cmp);btrfs_get_logged_extents (inode, logged_list, logged_start, logged_end);/*
Greg Kroah-Hartman
maintainerPATCH 50/272 x86/pgtable: Dont set huge PUD/PMD on non-leaf entries
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joerg Roedel <[email protected]>
[ Upstream commit e3e288121408c3abeed5af60b87b95c847143845 ]
The pmd_set_huge() and pud_set_huge() functions are used from the generic ioremap() code to establish large mappings where this is possible.
But the generic ioremap() code does not check whether the PMD/PUD entries are already populated with a non-leaf entry, so that any page-table pages these entries point to will be lost.
Further, on x86-32 with SHARED_KERNEL_PMD=0, this causes a BUG_ON() in vmalloc_sync_one() when PMD entries are synced from swapper_pg_dir to the current page-table. This happens because the PMD entry from swapper_pg_dir was promoted to a huge-page entry while the current PGD still contains the non-leaf entry. Because both entries are present and point to a different page, the BUG_ON() triggers.
This was actually triggered with pti-x32 enabled in a KVM virtual machine by the graphics driver.
A real and better fix for that would be to improve the page-table handling in the generic ioremap() code. But that is out-of-scope for this patch-set and left for later work.
--- arch/x86/mm/pgtable.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/mm/pgtable.c +9 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/mm.h> #include <linux/gfp.h> +#include <linux/hugetlb.h> #include <asm/pgalloc.h> #include <asm/pgtable.h> #include <asm/tlb.h>
@@ -636,6 +637,10 @@ int pud_set_huge(pud_t *pud, phys_addr_t (mtrr != MTRR_TYPE_WRBACK))return 0 ; +/* Bail out if we are we on a populated non-leaf entry: */ +if (pud_present (*pud) && !pud_huge (*pud)) +return 0 ; + prot =pgprot_4k_2_large (prot); set_pte((pte_t *)pud, pfn_pte(
@@ -664,6 +669,10 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_treturn 0 ; } +/* Bail out if we are we on a populated non-leaf entry: */ +if (pmd_present (*pmd) && !pmd_huge (*pmd)) +return 0 ; + prot =pgprot_4k_2_large (prot); set_pte((pte_t *)pmd, pfn_pte(
Greg Kroah-Hartman
maintainerPATCH 51/272 x86/mm: Do not forbid _PAGE_RW before init for __ro_after_init
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
[ Upstream commit 639d6aafe437a7464399d2a77d006049053df06f ]
__ro_after_init data gets stuck in the .rodata section. That's normally fine because the kernel itself manages the R/W properties.
But, if we run __change_page_attr() on an area which is __ro_after_init, the .rodata checks will trigger and force the area to be immediately read-only, even if it is early-ish in boot. This caused problems when trying to clear the _PAGE_GLOBAL bit for these area in the PTI code:
it cleared _PAGE_GLOBAL like I asked, but also took it up on itself to clear _PAGE_RW. The kernel then oopses the next time it wrote to a __ro_after_init data structure.
To fix this, add the kernel_set_to_readonly check, just like we have for kernel text, just a few lines below in this function.
--- arch/x86/mm/pageattr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/mm/pageattr.c +4 -2
@@ -298,9 +298,11 @@ static inline pgprot_t static_protection/* * The .rodata section needs to be read-only. Using the pfn -* catches all aliases. +* catches all aliases. This also includes __ro_after_init, +* so do not enforce until kernel_set_to_readonly is true. */ -if (within (pfn,__pa_symbol (__start_rodata) >>PAGE_SHIFT , +if (kernel_set_to_readonly && +within (pfn,__pa_symbol (__start_rodata) >>PAGE_SHIFT ,__pa_symbol (__end_rodata) >>PAGE_SHIFT ))pgprot_val (forbidden) |= _PAGE_RW;
Greg Kroah-Hartman
maintainerPATCH 63/272 perf tools: Fix perf builds with clang support
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit c2fb54a183cfe77c6fdc9d71e2d5299c1c302a6e ]
For libclang, some distro packages provide static libraries (.a) while some provide shared libraries (.so). Currently, perf code can only be linked with static libraries. This makes perf build possible for both cases.
--- tools/perf/Makefile.perf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/Makefile.perf +2 -1
@@ -364,7 +364,8 @@ LIBS = -Wl,--whole-archive $(PERFLIBS) $ ifeq ($(USE_CLANG), 1) CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization - LIBCLANG = $(foreach l,$(CLANGLIBS_LIST),$(wildcard $(shell $(LLVM_CONFIG) --libdir)/libclang$(l).a)) + CLANGLIBS_NOEXT_LIST = $(foreach l,$(CLANGLIBS_LIST),$(shell $(LLVM_CONFIG) --libdir)/libclang$(l)) + LIBCLANG = $(foreach l,$(CLANGLIBS_NOEXT_LIST),$(wildcard $(l).a $(l).so)) LIBS += -Wl,--start-group $(LIBCLANG) -Wl,--end-group endif
Greg Kroah-Hartman
maintainerPATCH 73/272 btrfs: Fix possible softlock on single core machines
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Borisov <[email protected]>
[ Upstream commit 1e1c50a929bc9e49bc3f9935b92450d9e69f8158 ]
do_chunk_alloc implements a loop checking whether there is a pending chunk allocation and if so causes the caller do loop. Generally this loop is executed only once, however testing with btrfs/072 on a single core vm machines uncovered an extreme case where the system could loop indefinitely. This is due to a missing cond_resched when loop which doesn't give a chance to the previous chunk allocator finish its job.
The fix is to simply add the missing cond_resched.
--- fs/btrfs/extent-tree.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/extent-tree.c +1 -0
@@ -4657,6 +4657,7 @@ again:if (wait_for_alloc) {mutex_unlock (&fs_info->chunk_mutex); wait_for_alloc =0 ; +cond_resched (); goto again; }
Greg Kroah-Hartman
maintainerPATCH 74/272 IB/rxe: Fix for oops in rxe_register_device on ppc64le arch
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Malygin <[email protected]>
[ Upstream commit efc365e7290d040fbd43f60b0e97653489a739d4 ]
On ppc64le arch rxe_add command causes oops in kernel log:
[ 92.495140] Oops: Kernel access of bad area, sig: 11 [#1] [ 92.499710] SMP NR_CPUS=2048 NUMA pSeries [ 92.499792] Modules linked in: ipt_MASQUERADE(E) nf_nat_masquerade_ipv4(E) nf_conntrack_netlink(E) nfnetlink(E) xfrm_user(E) iptable
_nat(E) nf_conntrack_ipv4(E) nf_defrag_ipv4(E) nf_nat_ipv4(E) xt_addrtype(E) iptable_filter(E) ip_tables(E) xt_conntrack(E) x_tables(E)
nf_nat(E) nf_conntrack(E) br_netfilter(E) bridge(E) stp(E) llc(E) overlay(E) af_packet(E) rpcrdma(E) ib_isert(E) iscsi_target_mod(E) ib_iser(E) libiscsi(E) ib_srpt(E) target_core_mod(E) ib_srp(E) ib_ipoib(E) rdma_ucm(E) ib_ucm(E) ib_uverbs(E) ib_umad(E) bochs_drm(E) tt m(E) drm_kms_helper(E) syscopyarea(E) sysfillrect(E) sysimgblt(E) fb_sys_fops(E) drm(E) agpgart(E) virtio_rng(E) virtio_console(E) rtc_ generic(E) dm_ec(OEN) ttln_rdma(OEN) rdma_cm(E) configfs(E) iw_cm(E) ib_cm(E) rdma_rxe(E) ip6_udp_tunnel(E) udp_tunnel(E) ib_core(E) ql a2xxx(E)
[ 92.499832] scsi_transport_fc(E) nvme_fc(E) nvme_fabrics(E) nvme_core(E) ipmi_watchdog(E) ipmi_ssif(E) ipmi_poweroff(E) ipmi_powernv(EX) ipmi_devintf(E) ipmi_msghandler(E) dummy(E) ext4(E) crc16(E) jbd2(E) mbcache(E) dm_service_time(E) scsi_transport_iscsi(E) sd_mod(E) sr_mod(E) cdrom(E) hid_generic(E) usbhid(E) virtio_blk(E) virtio_scsi(E) virtio_net(E) ibmvscsi(EX) scsi_transport_srp(E) xhci_pci(E) xhci_hcd(E) usbcore(E) usb_common(E) virtio_pci(E) virtio_ring(E) virtio(E) sunrpc(E) dm_mirror(E) dm_region_hash(E) dm_log(E) sg(E) dm_multipath(E) dm_mod(E) scsi_dh_rdac(E) scsi_dh_emc(E) scsi_dh_alua(E) scsi_mod(E) autofs4(E)
[ 92.499834] Supported: No, Unsupported modules are loaded
[ 92.499839] CPU: 3 PID: 5576 Comm: sh Tainted: G OE NX 4.4.120-ttln.17-default #1
[ 92.499841] task: c0000000afe8a490 ti: c0000000beba8000 task.ti: c0000000beba8000
[ 92.499842] NIP: c00000000008ba3c LR: c000000000027644 CTR: c00000000008ba10
[ 92.499844] REGS: c0000000bebab750 TRAP: 0300 Tainted: G OE NX (4.4.120-ttln.17-default)
[ 92.499850] MSR: 8000000000009033 <SF,EE,ME,IR,DR,RI,LE> CR: 28424428 XER: 20000000
[ 92.499871] CFAR: 0000000000002424 DAR: 0000000000000208 DSISR: 40000000 SOFTE: 1
GPR00: c000000000027644 c0000000bebab9d0 c000000000f09700 0000000000000000
GPR04: d0000000043d7192 0000000000000002 000000000000001a fffffffffffffffe
GPR08: 000000000000009c c00000000008ba10 d0000000043e5848 d0000000043d3828
GPR12: c00000000008ba10 c000000007a02400 0000000010062e38 0000010020388860
GPR16: 0000000000000000 0000000000000000 00000100203885f0 00000000100f6c98
GPR20: c0000000b3f1fcc0 c0000000b3f1fc48 c0000000b3f1fbd0 c0000000b3f1fb58
GPR24: c0000000b3f1fae0 c0000000b3f1fa68 00000000000005dc c0000000b3f1f9f0
GPR28: d0000000043e5848 c0000000b3f1f900 c0000000b3f1f320 c0000000b3f1f000
[ 92.499881] NIP [c00000000008ba3c] dma_get_required_mask_pSeriesLP+0x2c/0x1a0
[ 92.499885] LR [c000000000027644] dma_get_required_mask+0x44/0xac
[ 92.499886] Call Trace:
[ 92.499891] [c0000000bebab9d0] [c0000000bebaba30] 0xc0000000bebaba30 (unreliable)
[ 92.499894] [c0000000bebaba10] [c000000000027644] dma_get_required_mask+0x44/0xac
[ 92.499904] [c0000000bebaba30] [d0000000043cb4b4] rxe_register_device+0xc4/0x430 [rdma_rxe]
[ 92.499910] [c0000000bebabab0] [d0000000043c06c8] rxe_add+0x448/0x4e0 [rdma_rxe]
[ 92.499915] [c0000000bebabb30] [d0000000043d28dc] rxe_net_add+0x4c/0xf0 [rdma_rxe]
[ 92.499921] [c0000000bebabb60] [d0000000043d305c] rxe_param_set_add+0x6c/0x1ac [rdma_rxe]
[ 92.499924] [c0000000bebabbf0] [c0000000000e78c0] param_attr_store+0xa0/0x180
[ 92.499927] [c0000000bebabc70] [c0000000000e6448] module_attr_store+0x48/0x70
[ 92.499932] [c0000000bebabc90] [c000000000391f60] sysfs_kf_write+0x70/0xb0
[ 92.499935] [c0000000bebabcb0] [c000000000390f1c] kernfs_fop_write+0x18c/0x1e0
[ 92.499939] [c0000000bebabd00] [c0000000002e22ac] __vfs_write+0x4c/0x1d0
[ 92.499942] [c0000000bebabd90] [c0000000002e2f94] vfs_write+0xc4/0x200
[ 92.499945] [c0000000bebabde0] [c0000000002e488c] SyS_write+0x6c/0x110
[ 92.499948] [c0000000bebabe30] [c000000000009384] system_call+0x38/0xe4
[ 92.499949] Instruction dump:
[ 92.499954] 4e800020 3c4c00e8 3842dcf0 7c0802a6 f8010010 60000000 7c0802a6 fba1ffe8
[ 92.499958] fbc1fff0 fbe1fff8 f8010010 f821ffc1 <e9230208> 7c7e1b78 2fa90000 419e0078
[ 92.499962] ---[ end trace bed077e15eb420cf ]---It fails in dma_get_required_mask, that has ppc-specific implementation, and fail if provided device argument is NULL
--- drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_verbs.c +1 -1
@@ -1206,7 +1206,7 @@ int rxe_register_device(struct rxe_dev * rxe->ndev->dev_addr); dev->dev.dma_ops = &dma_virt_ops;dma_coerce_mask_and_coherent (&dev->dev, -dma_get_required_mask (dev->dev.parent)); +dma_get_required_mask (&dev->dev)); dev->uverbs_abi_ver =RXE_UVERBS_ABI_VERSION ; dev->uverbs_cmd_mask =BIT_ULL (IB_USER_VERBS_CMD_GET_CONTEXT )
Greg Kroah-Hartman
maintainerPATCH 75/272 ocfs2/dlm: dont handle migrate lockres if already in shutdown
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Piao <[email protected]>
[ Upstream commit bb34f24c7d2c98d0c81838a7700e6068325b17a0 ]
We should not handle migrate lockres if we are already in 'DLM_CTXT_IN_SHUTDOWN', as that will cause lockres remains after leaving dlm domain. At last other nodes will get stuck into infinite loop when requsting lock from us.
The problem is caused by concurrency umount between nodes. Before receiveing N1's DLM_BEGIN_EXIT_DOMAIN_MSG, N2 has picked up N1 as the migrate target. So N2 will continue sending lockres to N1 even though N1 has left domain.
N1 N2 (owner)
touch file
access the file,
and get pr lock
begin leave domain and pick up N1 as new owner
begin leave domain and
migrate all lockres done
begin migrate lockres to N1
end leave domain, but
the lockres left
unexpectedly, because
migrate task has passed
--- fs/ocfs2/dlm/dlmdomain.c | 14 -------------- fs/ocfs2/dlm/dlmdomain.h | 25 ++++++++++++++++++++++++- fs/ocfs2/dlm/dlmrecovery.c | 9 +++++++++ 3 files changed, 33 insertions(+), 15 deletions(-)
fs/ocfs2/dlm/dlmdomain.c +0 -14
@@ -675,20 +675,6 @@ static void dlm_leave_domain(struct dlm_spin_unlock (&dlm->spinlock); } -int dlm_shutting_down (struct dlm_ctxt *dlm) -{ -int ret =0 ; - -spin_lock (&dlm_domain_lock); - -if (dlm->dlm_state ==DLM_CTXT_IN_SHUTDOWN ) - ret =1 ; - -spin_unlock (&dlm_domain_lock); - -return ret; -} -void dlm_unregister_domain (struct dlm_ctxt *dlm) {int leave =0 ;
fs/ocfs2/dlm/dlmdomain.h +24 -1
@@ -28,7 +28,30 @@extern spinlock_t dlm_domain_lock;extern struct list_head dlm_domains; -int dlm_shutting_down (struct dlm_ctxt *dlm); +static inline int dlm_joined (struct dlm_ctxt *dlm) +{ +int ret =0 ; + +spin_lock (&dlm_domain_lock); +if (dlm->dlm_state ==DLM_CTXT_JOINED ) + ret =1 ; +spin_unlock (&dlm_domain_lock); + +return ret; +} + +static inline int dlm_shutting_down (struct dlm_ctxt *dlm) +{ +int ret =0 ; + +spin_lock (&dlm_domain_lock); +if (dlm->dlm_state ==DLM_CTXT_IN_SHUTDOWN ) + ret =1 ; +spin_unlock (&dlm_domain_lock); + +return ret; +} +void dlm_fire_domain_eviction_callbacks (struct dlm_ctxt *dlm,int node_num);
fs/ocfs2/dlm/dlmrecovery.c +9 -0
@@ -1378,6 +1378,15 @@ int dlm_mig_lockres_handler(struct o2netif (!dlm_grab (dlm))return -EINVAL ; +if (!dlm_joined (dlm)) { +mlog (ML_ERROR ,"Domain %s not joined! " +"lockres %.*s, master %u\n" , + dlm->name, mres->lockname_len, + mres->lockname, mres->master); +dlm_put (dlm); +return -EINVAL ; + } +BUG_ON (!(mres->flags & (DLM_MRES_RECOVERY |DLM_MRES_MIGRATION ))); real_master = mres->master;
Greg Kroah-Hartman
maintainerPATCH 76/272 powerpc/64s/idle: Fix restore of AMOR on POWER9 after deep sleep
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
[ Upstream commit c1b25a17d24925b0961c319cfc3fd7e1dc778914 ]
POWER8 restores AMOR when waking from deep sleep, but POWER9 does not, because it does not go through the subcore restore.
Have POWER9 restore it in core restore.
--- arch/powerpc/kernel/idle_book3s.S | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/kernel/idle_book3s.S +2 -0
@@ -834,6 +834,8 @@ BEGIN_FTR_SECTION mtspr SPRN_PTCR,r4 ld r4,_RPR(r1) mtspr SPRN_RPR,r4 + ld r4,_AMOR(r1) + mtspr SPRN_AMOR,r4 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300) ld r4,_TSCR(r1)
Greg Kroah-Hartman
maintainerPATCH 77/272 sched/rt: Fix rq->clock_update_flags < RQCF_ACT_SKIP warning
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
[ Upstream commit d29a20645d5e929aa7e8616f28e5d8e1c49263ec ]
While running rt-tests' pi_stress program I got the following splat:
rq->clock_update_flags < RQCF_ACT_SKIP
WARNING: CPU: 27 PID: 0 at kernel/sched/sched.h:960 assert_clock_updated.isra.38.part.39+0x13/0x20
[...]
<IRQ> enqueue_top_rt_rq+0xf4/0x150 ? cpufreq_dbs_governor_start+0x170/0x170 sched_rt_rq_enqueue+0x65/0x80 sched_rt_period_timer+0x156/0x360 ? sched_rt_rq_enqueue+0x80/0x80 __hrtimer_run_queues+0xfa/0x260 hrtimer_interrupt+0xcb/0x220 smp_apic_timer_interrupt+0x62/0x120 apic_timer_interrupt+0xf/0x20 </IRQ>
[...]
do_idle+0x183/0x1e0 cpu_startup_entry+0x5f/0x70 start_secondary+0x192/0x1d0 secondary_startup_64+0xa5/0xb0
We can get rid of it be the "traditional" means of adding an update_rq_clock() call after acquiring the rq->lock in do_sched_rt_period_timer().
The case for the RT task throttling (which this workload also hits) can be ignored in that the skip_update call is actually bogus and quite the contrary (the request bits are removed/reverted).
By setting RQCF_UPDATED we really don't care if the skip is happening or not and will therefore make the assert_clock_updated() check happy.
--- kernel/sched/rt.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/sched/rt.c +2 -0
@@ -843,6 +843,8 @@ static int do_sched_rt_period_timer(strucontinue ;raw_spin_lock (&rq->lock); +update_rq_clock (rq); +if (rt_rq->rt_time) {u64 runtime;
Greg Kroah-Hartman
maintainerPATCH 78/272 x86/mm: Fix bogus warning during EFI bootup, use boot_cpu_has() instead of this_cpu_has() in build_cr3_noflush()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sai Praneeth <[email protected]>
[ Upstream commit 162ee5a8ab49be40d253f90e94aef712470a3a24 ]
Linus reported the following boot warning:
WARNING: CPU: 0 PID: 0 at arch/x86/include/asm/tlbflush.h:134 load_new_mm_cr3+0x114/0x170 [...] Call Trace: switch_mm_irqs_off+0x267/0x590 switch_mm+0xe/0x20 efi_switch_mm+0x3e/0x50 efi_enter_virtual_mode+0x43f/0x4da start_kernel+0x3bf/0x458 secondary_startup_64+0xa5/0xb0
... after merging:
03781e40890c: x86/efi: Use efi_switch_mm() rather than manually twiddling with %cr3
When the platform supports PCID and if CONFIG_DEBUG_VM=y is enabled, build_cr3_noflush() (called via switch_mm()) does a sanity check to see if X86_FEATURE_PCID is set.
Presently, build_cr3_noflush() uses "this_cpu_has(X86_FEATURE_PCID)" to perform the check but this_cpu_has() works only after SMP is initialized (i.e. per cpu cpu_info's should be populated) and this happens to be very late in the boot process (during rest_init()).
As efi_runtime_services() are called during (early) kernel boot time and run time, modify build_cr3_noflush() to use boot_cpu_has() all the time. As suggested by Dave Hansen, this should be OK because all CPU's have same capabilities on x86.
With this change the warning is fixed.
( Dave also suggested that we put a warning in this_cpu_has() if it's used
early in the boot process. This is still work in progress as it affects MCE. )
--- arch/x86/include/asm/tlbflush.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/include/asm/tlbflush.h +6 -1
@@ -131,7 +131,12 @@ static inline unsigned long build_cr3(pgstatic inline unsigned long build_cr3_noflush (pgd_t *pgd,u16 asid) {VM_WARN_ON_ONCE (asid >MAX_ASID_AVAILABLE ); -VM_WARN_ON_ONCE (!this_cpu_has (X86_FEATURE_PCID )); +/* +* Use boot_cpu_has() instead of this_cpu_has() as this function +* might be called during early boot. This should work even after +* boot because all CPU's the have same capabilities: +*/ +VM_WARN_ON_ONCE (!boot_cpu_has (X86_FEATURE_PCID ));return __sme_pa (pgd) |kern_pcid (asid) |CR3_NOFLUSH ; }
Greg Kroah-Hartman
maintainerPATCH 84/272 riscv/spinlock: Strengthen implementations with fences
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
[ Upstream commit 0123f4d76ca63b7b895f40089be0ce4809e392d8 ]
Current implementations map locking operations using .rl and .aq annotations. However, this mapping is unsound w.r.t. the kernel memory consistency model (LKMM) [1]:
Referring to the "unlock-lock-read-ordering" test reported below, Daniel wrote:
"I think an RCpc interpretation of .aq and .rl would in fact
allow the two normal loads in P1 to be reordered [...]
The intuition would be that the amoswap.w.aq can forward from the amoswap.w.rl while that's still in the store buffer, and then the lw x3,0(x4) can also perform while the amoswap.w.rl is still in the store buffer, all before the l1 x1,0(x2) executes. That's not forbidden unless the amoswaps are RCsc, unless I'm missing something.
Likewise even if the unlock()/lock() is between two stores. A control dependency might originate from the load part of the amoswap.w.aq, but there still would have to be something to ensure that this load part in fact performs after the store part of the amoswap.w.rl performs globally, and that's not automatic under RCpc."
Simulation of the RISC-V memory consistency model confirmed this expectation.
In order to "synchronize" LKMM and RISC-V's implementation, this commit strengthens the implementations of the locking operations by replacing .rl and .aq with the use of ("lightweigth") fences, resp., "fence rw, w" and "fence r , rw".
C unlock-lock-read-ordering
{}
/* s initially owned by P1 */
P0(int *x, int *y)
{
WRITE_ONCE(*x, 1);
smp_wmb();
WRITE_ONCE(*y, 1);
}P1(int *x, int *y, spinlock_t *s)
{
int r0;
int r1;
r0 = READ_ONCE(*y);
spin_unlock(s);
spin_lock(s);
r1 = READ_ONCE(*x);
}exists (1:r0=1 /\ 1:r1=0)
[1] https://marc.info/?l=linux-kernel&m=151930201102853&w=2
https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/hKywNHBkAXM https://marc.info/?l=linux-kernel&m=151633436614259&w=2
--- arch/riscv/include/asm/fence.h | 12 ++++++++++++ arch/riscv/include/asm/spinlock.h | 29 +++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 arch/riscv/include/asm/fence.h
arch/riscv/include/asm/fence.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef _ASM_RISCV_FENCE_H +#define _ASM_RISCV_FENCE_H + +#ifdef CONFIG_SMP +#define RISCV_ACQUIRE_BARRIER "\tfence r , rw\n" +#define RISCV_RELEASE_BARRIER "\tfence rw, w\n" +#else +#define RISCV_ACQUIRE_BARRIER +#define RISCV_RELEASE_BARRIER +#endif + +#endif /* _ASM_RISCV_FENCE_H */
arch/riscv/include/asm/spinlock.h +15 -14
@@ -17,6 +17,7 @@#include <linux/kernel.h> #include <asm/current.h> +#include <asm/fence.h> /* * Simple spin lock operations. These provide no fairness guarantees.
@@ -28,10 +29,7 @@static inline void arch_spin_unlock (arch_spinlock_t *lock) { - __asm__ __volatile__ ( -"amoswap.w.rl x0, x0, %0" - :"=A" (lock->lock) - ::"memory" ); +smp_store_release (&lock->lock,0 ); }static inline int arch_spin_trylock (arch_spinlock_t *lock)
@@ -39,7 +37,8 @@ static inline int arch_spin_trylock(archint tmp =1 , busy; __asm__ __volatile__ ( -"amoswap.w.aq %0, %2, %1" +" amoswap.w %0, %2, %1\n" +RISCV_ACQUIRE_BARRIER :"=r" (busy),"+A" (lock->lock) :"r" (tmp) :"memory" );
@@ -68,8 +67,9 @@ static inline void arch_read_lock(arch_r"1: lr.w %1, %0\n" " bltz %1, 1b\n" " addi %1, %1, 1\n" -" sc.w.aq %1, %1, %0\n" +" sc.w %1, %1, %0\n" " bnez %1, 1b\n" +RISCV_ACQUIRE_BARRIER : "+A" (lock->lock), "=&r" (tmp) :: "memory"); }
@@ -82,8 +82,9 @@ static inline void arch_write_lock(arch_"1: lr.w %1, %0\n" " bnez %1, 1b\n" " li %1, -1\n" -" sc.w.aq %1, %1, %0\n" +" sc.w %1, %1, %0\n" " bnez %1, 1b\n" +RISCV_ACQUIRE_BARRIER : "+A" (lock->lock), "=&r" (tmp) :: "memory"); }
@@ -96,8 +97,9 @@ static inline int arch_read_trylock(arch"1: lr.w %1, %0\n" " bltz %1, 1f\n" " addi %1, %1, 1\n" -" sc.w.aq %1, %1, %0\n" +" sc.w %1, %1, %0\n" " bnez %1, 1b\n" +RISCV_ACQUIRE_BARRIER "1:\n" : "+A" (lock->lock), "=&r" (busy) :: "memory");
@@ -113,8 +115,9 @@ static inline int arch_write_trylock(arc"1: lr.w %1, %0\n" " bnez %1, 1f\n" " li %1, -1\n" -" sc.w.aq %1, %1, %0\n" +" sc.w %1, %1, %0\n" " bnez %1, 1b\n" +RISCV_ACQUIRE_BARRIER "1:\n" : "+A" (lock->lock), "=&r" (busy) :: "memory");
@@ -125,7 +128,8 @@ static inline int arch_write_trylock(arcstatic inline void arch_read_unlock (arch_rwlock_t *lock) { __asm__ __volatile__( -"amoadd.w.rl x0, %1, %0" +RISCV_RELEASE_BARRIER +" amoadd.w x0, %1, %0\n" :"+A" (lock->lock) :"r" (-1 ) :"memory" );
@@ -133,10 +137,7 @@ static inline void arch_read_unlock(archstatic inline void arch_write_unlock (arch_rwlock_t *lock) { - __asm__ __volatile__ ( -"amoswap.w.rl x0, x0, %0" - :"=A" (lock->lock) - ::"memory" ); +smp_store_release (&lock->lock,0 ); }#endif /* _ASM_RISCV_SPINLOCK_H */
Greg Kroah-Hartman
maintainerPATCH 85/272 platform/x86: dell-smbios: Fix memory leaks in build_tokens_sysfs()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 0e5b09b165510e2ea5c526e962c4edadd849ef4c ]
We're freeing "value_name" which is NULL, so that's a no-op, but we intended to free "location_name" instead. And then we don't free the names in token_location_attrs[0] and token_value_attrs[0].
--- drivers/platform/x86/dell-smbios-base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/dell-smbios-base.c +2 -2
@@ -514,7 +514,7 @@ static int build_tokens_sysfs(struct placontinue ; loop_fail_create_value: -kfree (value_name); +kfree (location_name); goto out_unwind_strings; } smbios_attribute_group.attrs = token_attrs;
@@ -525,7 +525,7 @@ loop_fail_create_value:return 0 ; out_unwind_strings: -for (i = i-1 ; i >0 ; i--) { +while (i--) {kfree (token_location_attrs[i].attr.name);kfree (token_value_attrs[i].attr.name); }
Greg Kroah-Hartman
maintainerPATCH 86/272 net: bgmac: Fix endian access in bgmac_dma_tx_ring_free()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 60d6e6f0b9e422dd01aeda39257ee0428e5e2a3f ]
bgmac_dma_tx_ring_free() assigns the ctl1 word which is a litle endian 32-bit word without using proper accessors, fix this, and because a length cannot be negative, use unsigned int while at it.
--- drivers/net/ethernet/broadcom/bgmac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bgmac.c +2 -1
@@ -533,7 +533,8 @@ static void bgmac_dma_tx_ring_free(strucint i;for (i =0 ; i <BGMAC_TX_RING_SLOTS ; i++) { -int len = dma_desc[i].ctl1 &BGMAC_DESC_CTL1_LEN ; +u32 ctl1 =le32_to_cpu (dma_desc[i].ctl1); +unsigned int len = ctl1 &BGMAC_DESC_CTL1_LEN ; slot = &ring->slots[i];dev_kfree_skb (slot->skb);
Greg Kroah-Hartman
maintainerPATCH 98/272 drivers: macintosh: rack-meter: really fix bogus memsets
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaro Koskinen <[email protected]>
[ Upstream commit e283655b5abe26462d53d5196f186c5e8863af3b ]
We should zero an array using sizeof instead of number of elements.
Fixes the following compiler (GCC 7.3.0) warnings:
drivers/macintosh/rack-meter.c: In function 'rackmeter_do_pause':drivers/macintosh/rack-meter.c:157:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size] drivers/macintosh/rack-meter.c:158:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
--- drivers/macintosh/rack-meter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/macintosh/rack-meter.c +2 -2
@@ -154,8 +154,8 @@ static void rackmeter_do_pause(struct raDBDMA_DO_STOP (rm->dma_regs);return ; } -memset (rdma->buf1,0 ,ARRAY_SIZE (rdma->buf1)); -memset (rdma->buf2,0 ,ARRAY_SIZE (rdma->buf2)); +memset (rdma->buf1,0 ,sizeof (rdma->buf1)); +memset (rdma->buf2,0 ,sizeof (rdma->buf2)); rm->dma_buf_v->mark =0 ;
Greg Kroah-Hartman
maintainerPATCH 99/272 ACPI: acpi_pad: Fix memory leak in power saving threads
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lenny Szubowicz <[email protected]>
[ Upstream commit 8b29d29abc484d638213dd79a18a95ae7e5bb402 ]
Fix once per second (round_robin_time) memory leak of about 1 KB in each acpi_pad kernel idling thread that is activated.
Found by testing with kmemleak.
--- drivers/acpi/acpi_pad.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/acpi_pad.c +3 -0
@@ -110,6 +110,7 @@ static void round_robin_cpu(unsigned intcpumask_andnot (tmp, cpu_online_mask, pad_busy_cpus);if (cpumask_empty (tmp)) {mutex_unlock (&round_robin_lock); +free_cpumask_var (tmp);return ; }for_each_cpu (cpu, tmp) {
@@ -127,6 +128,8 @@ static void round_robin_cpu(unsigned intmutex_unlock (&round_robin_lock);set_cpus_allowed_ptr (current,cpumask_of (preferred_cpu)); + +free_cpumask_var (tmp); }static void exit_round_robin (unsigned int tsk_index)
Greg Kroah-Hartman
maintainerPATCH 101/272 ieee802154: ca8210: fix uninitialised data read
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Morris <[email protected]>
[ Upstream commit 86674a97f5055f4c7f406563408096e8cf9364ff ]
In ca8210_test_int_user_write() a user can request the transfer of a frame with a length field (command.length) that is longer than the actual buffer provided (len). In this scenario the driver will copy the buffer contents into the uninitialised command[] buffer, then transfer <data.length> bytes over the SPI even though only <len> bytes had been populated, potentially leaking sensitive kernel memory.
Also the first 6 bytes of the command buffer must be initialised in case a malformed, short packet is written and the uninitialised bytes are read in ca8210_test_check_upstream.
--- drivers/net/ieee802154/ca8210.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/net/ieee802154/ca8210.c +11 -3
@@ -2493,13 +2493,14 @@ static ssize_t ca8210_test_int_user_writstruct ca8210_priv *priv = filp->private_data;u8 command[CA8210_SPI_BUF_SIZE ]; -if (len >CA8210_SPI_BUF_SIZE ) { +memset (command,SPI_IDLE ,6 ); +if (len >CA8210_SPI_BUF_SIZE || len <2 ) {dev_warn ( &priv->spi->dev, -"userspace requested erroneously long write (%zu)\n" , +"userspace requested erroneous write length (%zu)\n" , len ); -return -EMSGSIZE ; +return -EBADE ; } ret =copy_from_user (command, in_buf, len);
@@ -2511,6 +2512,13 @@ static ssize_t ca8210_test_int_user_writ );return -EIO ; } +if (len != command[1 ] +2 ) { +dev_err ( + &priv->spi->dev, +"write len does not match packet length field\n" + ); +return -EBADE ; + } ret =ca8210_test_check_upstream (command, priv->spi);if (ret ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 103/272 iommu/amd: Take into account that alloc_dev_data() may return NULL
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 39ffe39545cd5cb5b8cee9f0469165cf24dc62c2 ]
find_dev_data() does not check whether the return value alloc_dev_data() is NULL. This was okay once because the pointer was returned once as-is. Since commit df3f7a6e8e85 ("iommu/amd: Use is_attach_deferred call-back") the pointer may be used within find_dev_data() so a NULL check is required.
--- drivers/iommu/amd_iommu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iommu/amd_iommu.c +2 -0
@@ -310,6 +310,8 @@ static struct iommu_dev_data *find_dev_dif (dev_data ==NULL ) { dev_data =alloc_dev_data (devid); +if (!dev_data) +return NULL ;if (translation_pre_enabled (iommu)) dev_data->defer_attach = true;
Greg Kroah-Hartman
maintainerPATCH 116/272 rsi: fix kernel panic observed on 64bit machine
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amitkumar Karwar <[email protected]>
[ Upstream commit 864db4d5085349fcfa1f260b5bcd2adde3d7f2ed ]
Following kernel panic is observed on 64bit machine while loading the driver. It is fixed if we pass dynamically allocated memory to SDIO for DMA.
BUG: unable to handle kernel paging request at ffffeb04000172e0 IP: sg_miter_stop+0x56/0x70 PGD 0 P4D 0 Oops: 0000 [#1] SMP PTI Modules linked in: rsi_sdio(OE+) rsi_91x(OE) btrsi(OE) rfcomm bluetooth ecdh_generic mac80211 mmc_block fuse xt_CHECKSUM iptable_mangle drm_kms_helper mmc_core serio_raw drm firewire_ohci tg3 CPU: 0 PID: 4003 Comm: insmod Tainted: G OE 4.16.0-rc1+ #27 Hardware name: Dell Inc. Latitude E5500 /0DW634, BIOS A19 06/13/2013 RIP: 0010:sg_miter_stop+0x56/0x70 RSP: 0018:ffff88007d003e78 EFLAGS: 00010002 RAX: 0000000000000003 RBX: 0000000000000004 RCX: 0000000000000000 RDX: ffffeb04000172c0 RSI: ffff88002f58002c RDI: ffff88007d003e80 RBP: 0000000000000004 R08: ffff88007d003e80 R09: 0000000000000008 R10: 0000000000000003 R11: 0000000000000001 R12: 0000000000000004 R13: ffff88002f580028 R14: 0000000000000000 R15: 0000000000000004 FS: 00007f35c29db700(0000) GS:ffff88007d000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffeb04000172e0 CR3: 000000007038e000 CR4: 00000000000406f0 Call Trace: <IRQ> sg_copy_buffer+0xc6/0xf0 sdhci_tasklet_finish+0x170/0x260 [sdhci] tasklet_action+0xf4/0x100 __do_softirq+0xef/0x26e irq_exit+0xbe/0xd0 do_IRQ+0x4a/0xc0 common_interrupt+0xa2/0xa2 </IRQ>
--- drivers/net/wireless/rsi/rsi_91x_sdio.c | 32 +++++++++++++++++++++----------- drivers/net/wireless/rsi/rsi_sdio.h | 2 ++ 2 files changed, 23 insertions(+), 11 deletions(-)
drivers/net/wireless/rsi/rsi_91x_sdio.c +21 -11
@@ -636,11 +636,14 @@ static int rsi_sdio_master_reg_read(stru u32 *read_buf, u16 size) {u32 addr_on_bus, *data; -u32 align[2 ] = {};u16 ms_addr;int status; - data =PTR_ALIGN (&align[0 ],8 ); + data =kzalloc (RSI_MASTER_REG_BUF_SIZE ,GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + data =PTR_ALIGN (data,8 ); ms_addr = (addr >>16 ); status =rsi_sdio_master_access_msword (adapter, ms_addr);
@@ -648,7 +651,7 @@ static int rsi_sdio_master_reg_read(strursi_dbg (ERR_ZONE ,"%s: Unable to set ms word to common reg\n" , __func__); -return status; + goto err; } addr &=0xFFFF ;
@@ -666,7 +669,7 @@ static int rsi_sdio_master_reg_read(stru (u8 *)data, 4);if (status <0 ) {rsi_dbg (ERR_ZONE ,"%s: AHB register read failed\n" , __func__); -return status; + goto err; }if (size ==2 ) {if ((addr &0x3 ) ==0 )
@@ -688,17 +691,23 @@ static int rsi_sdio_master_reg_read(stru *read_buf = *data; } -return 0 ; +err: +kfree (data); +return status; }static int rsi_sdio_master_reg_write (struct rsi_hw *adapter,unsigned long addr,unsigned long data,u16 size) { -unsigned long data1[2 ], *data_aligned; +unsigned long *data_aligned;int status; - data_aligned =PTR_ALIGN (&data1[0 ],8 ); + data_aligned =kzalloc (RSI_MASTER_REG_BUF_SIZE ,GFP_KERNEL ); +if (!data_aligned) +return -ENOMEM ; + + data_aligned =PTR_ALIGN (data_aligned,8 );if (size ==2 ) { *data_aligned = ((data <<16 ) | (data &0xFFFF ));
@@ -717,6 +726,7 @@ static int rsi_sdio_master_reg_write(strrsi_dbg (ERR_ZONE ,"%s: Unable to set ms word to common reg\n" , __func__); +kfree (data_aligned);return -EIO ; } addr = addr &0xFFFF ;
@@ -726,12 +736,12 @@ static int rsi_sdio_master_reg_write(str (adapter, (addr |RSI_SD_REQUEST_MASTER ), (u8 *)data_aligned, size); -if (status <0 ) { +if (status <0 )rsi_dbg (ERR_ZONE ,"%s: Unable to do AHB reg write\n" , __func__); -return status; - } -return 0 ; + +kfree (data_aligned); +return status; }/**
drivers/net/wireless/rsi/rsi_sdio.h +2 -0
@@ -46,6 +46,8 @@ enum sdio_interrupt_type {#define PKT_BUFF_AVAILABLE 1#define FW_ASSERT_IND 2 +#define RSI_MASTER_REG_BUF_SIZE 12 +#define RSI_DEVICE_BUFFER_STATUS_REGISTER 0xf3#define RSI_FN1_INT_REGISTER 0xf9#define RSI_INT_ENABLE_REGISTER 0x04
Greg Kroah-Hartman
maintainerPATCH 119/272 i40e: hold the RTNL lock while changing interrupt schemes
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Keller <[email protected]>
[ Upstream commit f0ee70a042e267a517e943220e18ae62d3c1995a ]
When we suspend and resume, we need to clear and re-enable the interrupt scheme. This was previously not done while holding the RTNL lock, which could be problematic, because we are actually destroying and re-creating queues.
Hold the RTNL lock for the entire sequence of preparing for reset, and when resuming. This additionally protects the flags related to interrupt scheme under RTNL lock so that their modification is properly threaded.
This is part of a larger effort to remove the need for cmpxchg64 in i40e_set_priv_flags().
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +17 -2
@@ -14216,7 +14216,13 @@ static int __maybe_unused i40e_suspend(sif (pf->wol_en && (pf->hw_features &I40E_HW_WOL_MC_MAGIC_PKT_WAKE ))i40e_enable_mc_magic_wake (pf); -i40e_prep_for_reset (pf, false); +/* Since we're going to destroy queues during the +* i40e_clear_interrupt_scheme() we should hold the RTNL lock for this +* whole section +*/ +rtnl_lock (); + +i40e_prep_for_reset (pf, true);wr32 (hw,I40E_PFPM_APM , (pf->wol_en ?I40E_PFPM_APM_APME_MASK :0 ));wr32 (hw,I40E_PFPM_WUFC , (pf->wol_en ?I40E_PFPM_WUFC_MAG_MASK :0 ));
@@ -14228,6 +14234,8 @@ static int __maybe_unused i40e_suspend(s*/ i40e_clear_interrupt_scheme (pf); +rtnl_unlock (); +return 0 ; }
@@ -14245,6 +14253,11 @@ static int __maybe_unused i40e_resume(stif (!test_bit (__I40E_SUSPENDED, pf->state))return 0 ; +/* We need to hold the RTNL lock prior to restoring interrupt schemes, +* since we're going to be restoring queues +*/ +rtnl_lock (); +/* We cleared the interrupt scheme when we suspended, so we need to * restore it now to resume device functionality. */
@@ -14255,7 +14268,9 @@ static int __maybe_unused i40e_resume(st }clear_bit (__I40E_DOWN, pf->state); -i40e_reset_and_rebuild (pf, false, false); +i40e_reset_and_rebuild (pf, false, true); + +rtnl_unlock ();/* Clear suspended state last after everything is recovered */ clear_bit (__I40E_SUSPENDED, pf->state);
Greg Kroah-Hartman
maintainerPATCH 126/272 ath10k: Fix kernel panic while using worker (ath10k_sta_rc_update_wk)
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karthikeyan Periyasamy <[email protected]>
[ Upstream commit 8b2d93dd22615cb7f3046a5a2083a6f8bb8052ed ]
When attempt to run worker (ath10k_sta_rc_update_wk) after the station object (ieee80211_sta) delete will trigger the kernel panic.
This problem arise in AP + Mesh configuration, Where the current node AP VAP and neighbor node mesh VAP MAC address are same. When the current mesh node try to establish the mesh link with neighbor node, driver peer creation for the neighbor mesh node fails due to duplication MAC address. Already the AP VAP created with same MAC address.
It is caused by the following scenario steps.
Steps:
1. In above condition, ath10k driver sta_state callback (ath10k_sta_state) fails to do the state change for a station from IEEE80211_STA_NOTEXIST to IEEE80211_STA_NONE due to peer creation fails. Sta_state callback is called from ieee80211_add_station() to handle the new station (neighbor mesh node) request from the wpa_supplicant.
2. Concurrently ath10k receive the sta_rc_update callback notification from the mesh_neighbour_update() to handle the beacon frames of the above neighbor mesh node. since its atomic callback, ath10k driver queue the work (ath10k_sta_rc_update_wk) to handle rc update.
3. Due to driver sta_state callback fails (step 1), mac80211 free the station object.
4. When the worker (ath10k_sta_rc_update_wk) scheduled to run, it will access the station object which is already deleted. so it will trigger kernel panic.
Added the peer exist check in sta_rc_update callback before queue the work.
Kernel Panic log:
Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0204000 [00000000] *pgd=00000000 Internal error: Oops: 17 [#1] PREEMPT SMP ARM CPU: 1 PID: 1833 Comm: kworker/u4:2 Not tainted 3.14.77 #1 task: dcef0000 ti: d72b6000 task.ti: d72b6000 PC is at pwq_activate_delayed_work+0x10/0x40 LR is at pwq_activate_delayed_work+0xc/0x40 pc : [<c023f988>] lr : [<c023f984>] psr: 40000193
sp : d72b7f18 ip : 0000007a fp : d72b6000
r10: 00000000 r9 : dd404414 r8 : d8c31998
r7 : d72b6038 r6 : 00000004 r5 : d4907ec8 r4 : dcee1300 r3 : ffffffe0 r2 : 00000000 r1 : 00000001 r0 : 00000000
Flags: nZcv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 10c5787d Table: 595bc06a DAC: 00000015
...
Process kworker/u4:2 (pid: 1833, stack limit = 0xd72b6238)
Stack: (0xd72b7f18 to 0xd72b8000)
7f00: 00000001 dcee1300
7f20: 00000001 c02410dc d8c31980 dd404400 dd404400 c0242790 d8c31980 00000089 7f40: 00000000 d93e1340 00000000 d8c31980 c0242568 00000000 00000000 00000000 7f60: 00000000 c02474dc 00000000 00000000 000000f8 d8c31980 00000000 00000000 7f80: d72b7f80 d72b7f80 00000000 00000000 d72b7f90 d72b7f90 d72b7fac d93e1340 7fa0: c0247404 00000000 00000000 c0208d20 00000000 00000000 00000000 00000000 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [<c023f988>] (pwq_activate_delayed_work) from [<c02410dc>] (pwq_dec_nr_in_flight+0x58/0xc4) [<c02410dc>] (pwq_dec_nr_in_flight) from [<c0242790>] (worker_thread+0x228/0x360) [<c0242790>] (worker_thread) from [<c02474dc>] (kthread+0xd8/0xec) [<c02474dc>] (kthread) from [<c0208d20>] (ret_from_fork+0x14/0x34)
Code: e92d4038 e1a05000 ebffffbc[69210.619376] SMP: failed to stop secondary CPUs
Rebooting in 3 seconds..
--- drivers/net/wireless/ath/ath10k/mac.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/ath/ath10k/mac.c +10 -0
@@ -7084,10 +7084,20 @@ static void ath10k_sta_rc_update(struct {struct ath10k *ar = hw->priv;struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; +struct ath10k_vif *arvif = (void *)vif->drv_priv; +struct ath10k_peer *peer;u32 bw, smps;spin_lock_bh (&ar->data_lock); + peer =ath10k_peer_find (ar, arvif->vdev_id, sta->addr); +if (!peer) { +spin_unlock_bh (&ar->data_lock); +ath10k_warn (ar,"mac sta rc update failed to find peer %pM on vdev %i\n" , + sta->addr, arvif->vdev_id); +return ; + } + ath10k_dbg(ar, ATH10K_DBG_MAC, "mac sta rc update for %pM changed %08x bw %d nss %d smps %d\n", sta->addr, changed, sta->bandwidth, sta->rx_nss,
Greg Kroah-Hartman
maintainerPATCH 129/272 ath9k: fix crash in spectral scan
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Gottschall <[email protected]>
[ Upstream commit 221b6ec69ed9c56b6cd9a124a387a9472f14284e ]
Fixes crash seen on arm smp systems (gateworks ventana imx6):
Unable to handle kernel NULL pointer dereference at virtual address 00000014 pgd = 80004000 [00000014] *pgd=00000000 Internal error: Oops - BUG: 17 [#1] PREEMPT SMP ARM Modules linked in: ip6table_filter nf_conntrack_ipv6 ip6_tables nf_log_ipv6 nf_defrag_ipv6 shortcut_fe ipcomp6 xfrm_ipcomp xfrm6_tunnel xfrm6_mode_tunnel xfrm6_mode_transport xfrm6_mode_ro xfrm6_mode_beet ip6_tunnel tunnel6 mip6 ah6 esp6 xfrm_algo sit ip_tunnel tunnel4 ipv6 ath10k_pci ath10k_core ath9k ath mac80211 cfg80211 compat ath_pci ath_hal(P) caamalg authencesn authenc caamrng caamhash caam_jr caam cdc_ncm usbnet usbcore sky2 imx2_wdt CPU: 0 PID: 3 Comm: ksoftirqd/0 Tainted: P 4.9.85 #19 Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) task: bf064980 task.stack: bf07c000 PC is at relay_buf_full+0xc/0x30 LR is at _674+0x740/0xf10 [ath9k] pc : [<8018bce0>] lr : [<7f1aa604>] psr: 80000013
sp : bf07dbf0 ip : bf07dc00 fp : bf07dbfc
r10: 0000003f r9 : bf130e00 r8 : 809044b0
r7 : 00000000 r6 : be67a9f0 r5 : 00000000 r4 : 809043e4 r3 : c0864c24 r2 : 00000000 r1 : 00000004 r0 : 00000000
Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 10c5387d Table: 4e6a004a DAC: 00000055 Process ksoftirqd/0 (pid: 3, stack limit = 0xbf07c210)
Stack: (0xbf07dbf0 to 0xbf07e000)
dbe0: bf07dd04 bf07dc00 7f1aa604 8018bce0
dc00: 00004014 be59e010 bf07dc34 bf07dc18 7f1a7084 7f19c07c be59c010 be6470a0
dc20: 0000096c be648954 bf07dc6c bf07dc38 7f1c286c bf07dd90 bf07dc5c bf07dc48
dc40: 8029ea4c 0000003c 00000001 be59c010 00000094 00000000 00000000 00000000
dc60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
dc80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
dca0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
dcc0: 00000000 00000000 00000000 00000000 00000000 00000000 8010ef24 00000030
dce0: be94f5e8 be6485a0 bddf0200 be59c010 be6465a0 be6415a0 bf07ddf4 bf07dd08
dd00: 7f1cf800 7f1aa55c 1fc38c4c 00000000 bf07dd58 cccccccd 66666667 be640bc0
dd20: bf07dd54 be6415a0 1fc38c4c 00000000 00000000 be59c038 be67a9c0 be59e010
dd40: be67a9f0 be647170 8090c904 be59c010 00000000 00000001 1fc38e84 00000000
dd60: be640bc0 bddf0200 00000200 00000010 0000003f 00000002 20000013 be59c010
dd80: 8092d940 bf7ca2c0 bf07ddb4 bf07dd98 1fc38c4c 2602003f 0100ff1b 80ff1b00
dda0: 00808080 00000000 00000000 80808080 80808080 80808080 80808080 00008080
ddc0: 00000000 00000000 7f1b62b8 00000002 be6470ec be6470f0 00000000 bf07de98
dde0: 8092d940 be6415a0 bf07de94 bf07ddf8 7f1d1ed8 7f1cf1fc 00000000 00000000
de00: bf7cc4c0 00000400 be6470f0 bf07de18 8015165c be59c010 8090453c 8090453c
de20: bf07dec4 be6465a0 8014f614 80148884 0000619a 00000001 bf07c000 00000100
de40: bf07de78 00000001 7f327850 00000002 afb50401 bf064980 bf07de9c bf07de68
de60: bf064a00 803cc668 bf064a00 be6470b4 be6470b8 80844180 00000000 bf07de98
de80: 8092d940 bf07c000 bf07dec4 bf07de98 80124d18 7f1d1c44 80124c94 00000000
dea0: 00000006 80902098 80902080 40000006 00000100 bf07c000 bf07df24 bf07dec8
dec0: 8012501c 80124ca0 bf7cc4c0 bf064980 be95e1c0 04208040 80902d00 000061c7
dee0: 0000000a 80600b54 8092d940 808441f8 80902080 bf07dec8 bf03b200 bf07c000
df00: bf03b200 8090fe54 00000000 00000000 00000000 00000000 bf07df34 bf07df28
df20: 80125148 80124f28 bf07df5c bf07df38 8013deb4 8012511c 00000000 bf03b240
df40: bf03b200 8013dc90 00000000 00000000 bf07dfac bf07df60 8013ad40 8013dc9c
df60: 70448040 00000001 00000000 bf03b200 00000000 00030003 bf07df78 bf07df78
df80: 00000000 00000000 bf07df88 bf07df88 bf03b240 8013ac48 00000000 00000000
dfa0: 00000000 bf07dfb0 80107760 8013ac54 00000000 00000000 00000000 00000000
dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 8c120004 1190ad04
Backtrace: [<8018bcd4>] (relay_buf_full) from [<7f1aa604>] (_674+0x740/0xf10 [ath9k]) [<7f1aa550>] (_674 [ath9k]) from [<7f1cf800>] (_582+0x14b4/0x3708 [ath9k]) r10:be6415a0 r9:be6465a0 r8:be59c010 r7:bddf0200 r6:be6485a0 r5:be94f5e8 r4:00000030 [<7f1cf1f0>] (_582 [ath9k]) from [<7f1d1ed8>] (_735+0x2a0/0xec4 [ath9k]) r10:be6415a0 r9:8092d940 r8:bf07de98 r7:00000000 r6:be6470f0 r5:be6470ec r4:00000002 [<7f1d1c38>] (_735 [ath9k]) from [<80124d18>] (tasklet_action+0x84/0xf8) r10:bf07c000 r9:8092d940 r8:bf07de98 r7:00000000 r6:80844180 r5:be6470b8 r4:be6470b4 [<80124c94>] (tasklet_action) from [<8012501c>] (__do_softirq+0x100/0x1f4) r10:bf07c000 r9:00000100 r8:40000006 r7:80902080 r6:80902098 r5:00000006 r4:00000000 r3:80124c94 [<80124f1c>] (__do_softirq) from [<80125148>] (run_ksoftirqd+0x38/0x4c) r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:8090fe54 r5:bf03b200 r4:bf07c000 [<80125110>] (run_ksoftirqd) from [<8013deb4>] (smpboot_thread_fn+0x224/0x260) [<8013dc90>] (smpboot_thread_fn) from [<8013ad40>] (kthread+0xf8/0x100) r9:00000000 r8:00000000 r7:8013dc90 r6:bf03b200 r5:bf03b240 r4:00000000 [<8013ac48>] (kthread) from [<80107760>] (ret_from_fork+0x14/0x34) r7:00000000 r6:00000000 r5:8013ac48 r4:bf03b240 Code: e89da800 e1a0c00d e92dd800 e24cb004 (e5901014) ---[ end trace dddf11ac9111b272 ]--- Kernel panic - not syncing: Fatal exception in interrupt CPU1: stopping CPU: 1 PID: 0 Comm: swapper/1 Tainted: P D 4.9.85 #19 Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) Backtrace: [<8010a708>] (dump_backtrace) from [<8010a99c>] (show_stack+0x18/0x1c) r7:bf093f58 r6:20000193 r5:809168e8 r4:00000000 [<8010a984>] (show_stack) from [<802a09c4>] (dump_stack+0x94/0xa8) [<802a0930>] (dump_stack) from [<8010d184>] (handle_IPI+0xe8/0x180) r7:bf093f58 r6:00000000 r5:00000001 r4:808478c4 [<8010d09c>] (handle_IPI) from [<801013e8>] (gic_handle_irq+0x78/0x7c) r7:f4000100 r6:bf093f58 r5:f400010c r4:8090467c [<80101370>] (gic_handle_irq) from [<8010b378>] (__irq_svc+0x58/0x8c) Exception stack(0xbf093f58 to 0xbf093fa0)
3f40: bf7d62a0 00000000
3f60: 0010a5f4 80113460 bf092000 809043e4 00000002 80904434 bf092008 412fc09a 3f80: 00000000 bf093fb4 bf093fb8 bf093fa8 8010804c 80108050 60000013 ffffffff
r9:bf092000 r8:bf092008 r7:bf093f8c r6:ffffffff r5:60000013 r4:80108050
[<80108014>] (arch_cpu_idle) from [<80553c2c>] (default_idle_call+0x30/0x34) [<80553bfc>] (default_idle_call) from [<80158394>] (cpu_startup_entry+0xc4/0xfc) [<801582d0>] (cpu_startup_entry) from [<8010ce40>] (secondary_start_kernel+0x168/0x174)
r7:8092d2f8 r4:80913568
[<8010ccd8>] (secondary_start_kernel) from [<10101488>] (0x10101488)
r5:00000055 r4:4f07806a
Rebooting in 10 seconds..
Reboot failed -- System halted
--- drivers/net/wireless/ath/ath9k/common-spectral.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/common-spectral.c +7 -5
@@ -479,14 +479,16 @@ ath_cmn_is_fft_buf_full(struct ath_spec_ {int i =0 ;int ret =0 ; +struct rchan_buf *buf;struct rchan *rc = spec_priv->rfs_chan_spec_scan; -for_each_online_cpu (i) - ret +=relay_buf_full (*per_cpu_ptr (rc->buf, i)); +for_each_possible_cpu (i) { +if ((buf = *per_cpu_ptr (rc->buf, i))) { + ret +=relay_buf_full (buf); + } + } - i =num_online_cpus (); - -if (ret == i) +if (ret)return 1 ;else return 0 ;
Greg Kroah-Hartman
maintainerPATCH 159/272 perf stat: Fix core dump when flag T is used
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richter <[email protected]>
[ Upstream commit fca32340a5e8b896f57d41fd94b8b1701df25eb1 ]
Executing command 'perf stat -T -- ls' dumps core on x86 and s390.
Here is the call back chain (done on x86):
# gdb ./perf
....
(gdb) r stat -T -- ls
...
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff56d1963 in vasprintf () from /lib64/libc.so.6
(gdb) where
#0 0x00007ffff56d1963 in vasprintf () from /lib64/libc.so.6
#1 0x00007ffff56ae484 in asprintf () from /lib64/libc.so.6
#2 0x00000000004f1982 in __parse_events_add_pmu (parse_state=0x7fffffffd580,
list=0xbfb970, name=0xbf3ef0 "cpu",
head_config=0xbfb930, auto_merge_stats=false) at util/parse-events.c:1233
#3 0x00000000004f1c8e in parse_events_add_pmu (parse_state=0x7fffffffd580,
list=0xbfb970, name=0xbf3ef0 "cpu",
head_config=0xbfb930) at util/parse-events.c:1288
#4 0x0000000000537ce3 in parse_events_parse (_parse_state=0x7fffffffd580,
scanner=0xbf4210) at util/parse-events.y:234
#5 0x00000000004f2c7a in parse_events__scanner (str=0x6b66c0
"task-clock,{instructions,cycles,cpu/cycles-t/,cpu/tx-start/}",
parse_state=0x7fffffffd580, start_token=258) at util/parse-events.c:1673
#6 0x00000000004f2e23 in parse_events (evlist=0xbe9990, str=0x6b66c0
"task-clock,{instructions,cycles,cpu/cycles-t/,cpu/tx-start/}", err=0x0)
at util/parse-events.c:1713
#7 0x000000000044e137 in add_default_attributes () at builtin-stat.c:2281
#8 0x000000000044f7b5 in cmd_stat (argc=1, argv=0x7fffffffe3b0) at
builtin-stat.c:2828
#9 0x00000000004c8b0f in run_builtin (p=0xab01a0 <commands+288>, argc=4,
argv=0x7fffffffe3b0) at perf.c:297
#10 0x00000000004c8d7c in handle_internal_command (argc=4,
argv=0x7fffffffe3b0) at perf.c:349
#11 0x00000000004c8ece in run_argv (argcp=0x7fffffffe20c,
argv=0x7fffffffe200) at perf.c:393
#12 0x00000000004c929c in main (argc=4, argv=0x7fffffffe3b0) at perf.c:537
(gdb)It turns out that a NULL pointer is referenced. Here are the function calls:
...
cmd_stat()
+---> add_default_attributes() +---> parse_events(evsel_list, transaction_attrs, NULL);
3rd parameter set to NULL
Function parse_events(xx, xx, struct parse_events_error *err) dives into a bison generated scanner and creates
parser state information for it first:
struct parse_events_state parse_state = {
.list = LIST_HEAD_INIT(parse_state.list),
.idx = evlist->nr_entries,
.error = err, <--- NULL POINTER !!!
.evlist = evlist,
};Now various functions inside the bison scanner are called to end up in __parse_events_add_pmu(struct parse_events_state *parse_state, ..) with first parameter being a pointer to above structure definition.
Now the PMU event name is not found (because being executed in a VM) and this function tries to create an error message with
asprintf(&parse_state->error.str, ....)
which references a NULL pointer and dumps core.
Fix this by providing a pointer to the necessary error information instead of NULL. Technically only the else part is needed to avoid the core dump, just lets be safe...
--- tools/perf/builtin-stat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/builtin-stat.c +7 -2
@@ -2274,11 +2274,16 @@ static int add_default_attributes(void)return 0 ;if (transaction_run) { +struct parse_events_error errinfo; +if (pmu_have_event ("cpu" ,"cycles-ct" ) &&pmu_have_event ("cpu" ,"el-start" )) - err =parse_events (evsel_list, transaction_attrs,NULL ); + err =parse_events (evsel_list, transaction_attrs, + &errinfo);else - err =parse_events (evsel_list, transaction_limited_attrs,NULL ); + err =parse_events (evsel_list, + transaction_limited_attrs, + &errinfo);if (err) {fprintf (stderr,"Cannot set up transaction events\n" );return -1 ;
Greg Kroah-Hartman
maintainerPATCH 164/272 regulator: gpio: Fix some error handling paths in gpio_regulator_probe()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Jaillet <[email protected]>
[ Upstream commit ed8cffda27dea6fd3dafb3ee881c5a786edac9ca ]
Re-order error handling code and gotos to avoid leaks in error handling paths.
--- drivers/regulator/gpio-regulator.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/regulator/gpio-regulator.c +7 -9
@@ -271,8 +271,7 @@ static int gpio_regulator_probe(struct p drvdata->desc.name =kstrdup (config->supply_name,GFP_KERNEL );if (drvdata->desc.name ==NULL ) {dev_err (&pdev->dev,"Failed to allocate supply name\n" ); - ret = -ENOMEM ; - goto err; +return -ENOMEM ; }if (config->nr_gpios !=0 ) {
@@ -292,7 +291,7 @@ static int gpio_regulator_probe(struct pdev_err (&pdev->dev,"Could not obtain regulator setting GPIOs: %d\n" , ret); - goto err_memstate; + goto err_memgpio; } }
@@ -303,7 +302,7 @@ static int gpio_regulator_probe(struct pif (drvdata->states ==NULL ) {dev_err (&pdev->dev,"Failed to allocate state data\n" ); ret = -ENOMEM ; - goto err_memgpio; + goto err_stategpio; } drvdata->nr_states = config->nr_states;
@@ -324,7 +323,7 @@ static int gpio_regulator_probe(struct pdefault :dev_err (&pdev->dev,"No regulator type set\n" ); ret = -EINVAL ; - goto err_memgpio; + goto err_memstate; }/* build initial state from gpio init data. */
@@ -361,22 +360,21 @@ static int gpio_regulator_probe(struct pif (IS_ERR (drvdata->dev)) { ret =PTR_ERR (drvdata->dev);dev_err (&pdev->dev,"Failed to register regulator: %d\n" , ret); - goto err_stategpio; + goto err_memstate; }platform_set_drvdata (pdev, drvdata);return 0 ; -err_stategpio: -gpio_free_array (drvdata->gpios, drvdata->nr_gpios); err_memstate:kfree (drvdata->states); +err_stategpio: +gpio_free_array (drvdata->gpios, drvdata->nr_gpios); err_memgpio:kfree (drvdata->gpios); err_name:kfree (drvdata->desc.name); -err:return ret; }
Greg Kroah-Hartman
maintainerPATCH 167/272 MIPS: ath79: Fix AR724X_PLL_REG_PCIE_CONFIG offset
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Kresin <[email protected]>
[ Upstream commit 05454c1bde91fb013c0431801001da82947e6b5a ]
According to the QCA u-boot source the "PCIE Phase Lock Loop Configuration (PCIE_PLL_CONFIG)" register is for all SoCs except the QCA955X and QCA956X at offset 0x10.
Since the PCIE PLL config register is only defined for the AR724x fix only this value. The value is wrong since the day it was added and isn't used by any driver yet.
Patchwork: https://patchwork.linux-mips.org/patch/16048/
--- arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/mach-ath79/ar71xx_regs.h +1 -1
@@ -167,7 +167,7 @@#define AR71XX_AHB_DIV_MASK 0x7#define AR724X_PLL_REG_CPU_CONFIG 0x00 -#define AR724X_PLL_REG_PCIE_CONFIG 0x18 +#define AR724X_PLL_REG_PCIE_CONFIG 0x10#define AR724X_PLL_FB_SHIFT 0#define AR724X_PLL_FB_MASK 0x3ff
Greg Kroah-Hartman
maintainerPATCH 172/272 watchdog: aspeed: Fix translation of reset mode to ctrl register
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Milton Miller <[email protected]>
[ Upstream commit d2fc8db691bf3197d43b2afb553311a9bf257bff ]
Assert RESET_SYSTEM bit for any reset and set MODE field from reset type.
The watchdog control register has a RESET_SYSTEM bit that is really closer to activate a reset, and RESET_SYSTEM_MODE field that chooses how much to reset.
Before this patch, a node without these optional property would do a SOC reset, but a node with properties requesting a cpu or SOC reset would do nothing and a node requesting a system reset would do a SOC reset.
--- drivers/watchdog/aspeed_wdt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/watchdog/aspeed_wdt.c +6 -3
@@ -234,11 +234,14 @@ static int aspeed_wdt_probe(struct platf wdt->ctrl |=WDT_CTRL_RESET_MODE_SOC |WDT_CTRL_RESET_SYSTEM ; }else {if (!strcmp (reset_type,"cpu" )) - wdt->ctrl |=WDT_CTRL_RESET_MODE_ARM_CPU ; + wdt->ctrl |=WDT_CTRL_RESET_MODE_ARM_CPU | +WDT_CTRL_RESET_SYSTEM ;else if (!strcmp (reset_type,"soc" )) - wdt->ctrl |=WDT_CTRL_RESET_MODE_SOC ; + wdt->ctrl |=WDT_CTRL_RESET_MODE_SOC | +WDT_CTRL_RESET_SYSTEM ;else if (!strcmp (reset_type,"system" )) - wdt->ctrl |=WDT_CTRL_RESET_SYSTEM ; + wdt->ctrl |=WDT_CTRL_RESET_MODE_FULL_CHIP | +WDT_CTRL_RESET_SYSTEM ;else if (strcmp (reset_type,"none" ))return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 177/272 powerpc/powernv/npu: Fix deadlock in mmio_invalidate()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alistair Popple <[email protected]>
[ Upstream commit 2b74e2a9b39df40a2b489af2d24079617c61ee0e ]
When sending TLB invalidates to the NPU we need to send extra flushes due to a hardware issue. The original implementation would lock the all the ATSD MMIO registers sequentially before unlocking and relocking each of them sequentially to do the extra flush.
This introduced a deadlock as it is possible for one thread to hold one ATSD register whilst waiting for another register to be freed while the other thread is holding that register waiting for the one in the first thread to be freed.
For example if there are two threads and two ATSD registers:
Thread A Thread B
----------------------
Acquire 1
Acquire 2
Release 1 Acquire 1
Wait 1 Wait 2
Both threads will be stuck waiting to acquire a register resulting in an RCU stall warning or soft lockup.
This patch solves the deadlock by refactoring the code to ensure registers are not released between flushes and to ensure all registers are either acquired or released together and in order.
--- arch/powerpc/platforms/powernv/npu-dma.c | 227 +++++++++++++++++++------------ 1 file changed, 140 insertions(+), 87 deletions(-)
arch/powerpc/platforms/powernv/npu-dma.c +140 -87
@@ -417,6 +417,11 @@ struct npu_context {void *priv; }; +struct mmio_atsd_reg { +struct npu *npu; +int reg; +}; +/* * Find a free MMIO ATSD register and mark it in use. Return -ENOSPC * if none are available.
@@ -426,7 +431,7 @@ static int get_mmio_atsd_reg(struct npuint i;for (i =0 ; i < npu->mmio_atsd_count; i++) { -if (!test_and_set_bit (i, &npu->mmio_atsd_usage)) +if (!test_and_set_bit_lock (i, &npu->mmio_atsd_usage))return i; }
@@ -435,86 +440,90 @@ static int get_mmio_atsd_reg(struct npustatic void put_mmio_atsd_reg (struct npu *npu,int reg) { -clear_bit (reg, &npu->mmio_atsd_usage); +clear_bit_unlock (reg, &npu->mmio_atsd_usage); }/* MMIO ATSD register offsets */ #define XTS_ATSD_AVA 1#define XTS_ATSD_STAT 2 -static int mmio_launch_invalidate (struct npu *npu,unsigned long launch, -unsigned long va) +static void mmio_launch_invalidate (struct mmio_atsd_reg *mmio_atsd_reg, +unsigned long launch,unsigned long va) { -int mmio_atsd_reg; - -do { - mmio_atsd_reg =get_mmio_atsd_reg (npu); -cpu_relax (); - }while (mmio_atsd_reg <0 ); +struct npu *npu = mmio_atsd_reg->npu; +int reg = mmio_atsd_reg->reg;__raw_writeq (cpu_to_be64 (va), - npu->mmio_atsd_regs[mmio_atsd_reg] +XTS_ATSD_AVA ); + npu->mmio_atsd_regs[reg] +XTS_ATSD_AVA );eieio (); -__raw_writeq (cpu_to_be64 (launch), npu->mmio_atsd_regs[mmio_atsd_reg]); - -return mmio_atsd_reg; +__raw_writeq (cpu_to_be64 (launch), npu->mmio_atsd_regs[reg]); } -static int mmio_invalidate_pid (struct npu *npu,unsigned long pid,bool flush) +static void mmio_invalidate_pid (struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS ], +unsigned long pid,bool flush) { +int i;unsigned long launch; -/* IS set to invalidate matching PID */ - launch =PPC_BIT (12 ); +for (i =0 ; i <= max_npu2_index; i++) { +if (mmio_atsd_reg[i].reg <0 ) +continue ; + +/* IS set to invalidate matching PID */ + launch =PPC_BIT (12 ); -/* PRS set to process-scoped */ - launch |=PPC_BIT (13 ); +/* PRS set to process-scoped */ + launch |=PPC_BIT (13 ); -/* AP */ - launch |= (u64 )mmu_get_ap (mmu_virtual_psize) <<PPC_BITLSHIFT (17 ); +/* AP */ + launch |= (u64 ) +mmu_get_ap (mmu_virtual_psize) <<PPC_BITLSHIFT (17 ); -/* PID */ - launch |= pid <<PPC_BITLSHIFT (38 ); +/* PID */ + launch |= pid <<PPC_BITLSHIFT (38 ); -/* No flush */ - launch |= !flush <<PPC_BITLSHIFT (39 ); +/* No flush */ + launch |= !flush <<PPC_BITLSHIFT (39 ); -/* Invalidating the entire process doesn't use a va */ -return mmio_launch_invalidate (npu, launch,0 ); +/* Invalidating the entire process doesn't use a va */ +mmio_launch_invalidate (&mmio_atsd_reg[i], launch,0 ); + } } -static int mmio_invalidate_va (struct npu *npu,unsigned long va, -unsigned long pid,bool flush) +static void mmio_invalidate_va (struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS ], +unsigned long va,unsigned long pid,bool flush) { +int i;unsigned long launch; -/* IS set to invalidate target VA */ - launch =0 ; +for (i =0 ; i <= max_npu2_index; i++) { +if (mmio_atsd_reg[i].reg <0 ) +continue ; -/* PRS set to process scoped */ - launch |=PPC_BIT (13 ); +/* IS set to invalidate target VA */ + launch =0 ; -/* AP */ - launch |= (u64 )mmu_get_ap (mmu_virtual_psize) <<PPC_BITLSHIFT (17 ); +/* PRS set to process scoped */ + launch |=PPC_BIT (13 ); -/* PID */ - launch |= pid <<PPC_BITLSHIFT (38 ); +/* AP */ + launch |= (u64 ) +mmu_get_ap (mmu_virtual_psize) <<PPC_BITLSHIFT (17 ); -/* No flush */ - launch |= !flush <<PPC_BITLSHIFT (39 ); +/* PID */ + launch |= pid <<PPC_BITLSHIFT (38 ); -return mmio_launch_invalidate (npu, launch, va); +/* No flush */ + launch |= !flush <<PPC_BITLSHIFT (39 ); + +mmio_launch_invalidate (&mmio_atsd_reg[i], launch, va); + } }#define mn_to_npu_context (x) container_of(x, struct npu_context, mn) -struct mmio_atsd_reg { -struct npu *npu; -int reg; -}; -static void mmio_invalidate_wait ( -struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS ],bool flush) +struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS ]) {struct npu *npu;int i, reg;
@@ -529,16 +538,67 @@ static void mmio_invalidate_wait( reg = mmio_atsd_reg[i].reg;while (__raw_readq (npu->mmio_atsd_regs[reg] +XTS_ATSD_STAT ))cpu_relax (); + } +} + +/* +* Acquires all the address translation shootdown (ATSD) registers required to +* launch an ATSD on all links this npu_context is active on. +*/ +static void acquire_atsd_reg (struct npu_context *npu_context, +struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS ]) +{ +int i, j; +struct npu *npu; +struct pci_dev *npdev; +struct pnv_phb *nphb; + +for (i =0 ; i <= max_npu2_index; i++) { + mmio_atsd_reg[i].reg =-1 ; +for (j =0 ; j <NV_MAX_LINKS ; j++) { +/* +* There are no ordering requirements with respect to +* the setup of struct npu_context, but to ensure +* consistent behaviour we need to ensure npdev[][] is +* only read once. +*/ + npdev =READ_ONCE (npu_context->npdev[i][j]); +if (!npdev) +continue ; + + nphb =pci_bus_to_host (npdev->bus)->private_data; + npu = &nphb->npu; + mmio_atsd_reg[i].npu = npu; + mmio_atsd_reg[i].reg =get_mmio_atsd_reg (npu); +while (mmio_atsd_reg[i].reg <0 ) { + mmio_atsd_reg[i].reg =get_mmio_atsd_reg (npu); +cpu_relax (); + } +break ; + } + } +} -put_mmio_atsd_reg (npu, reg); +/* +* Release previously acquired ATSD registers. To avoid deadlocks the registers +* must be released in the same order they were acquired above in +* acquire_atsd_reg. +*/ +static void release_atsd_reg (struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS ]) +{ +int i; +for (i =0 ; i <= max_npu2_index; i++) {/* -* The GPU requires two flush ATSDs to ensure all entries have -* been flushed. We use PID 0 as it will never be used for a -* process on the GPU. +* We can't rely on npu_context->npdev[][] being the same here +* as when acquire_atsd_reg() was called, hence we use the +* values stored in mmio_atsd_reg during the acquire phase +* rather than re-reading npdev[][]. */ -if (flush) -mmio_invalidate_pid (npu,0 , true); +if (mmio_atsd_reg[i].reg <0 ) +continue ; + +put_mmio_atsd_reg (mmio_atsd_reg[i].npu, mmio_atsd_reg[i].reg); } }
@@ -549,10 +609,6 @@ static void mmio_invalidate_wait(static void mmio_invalidate (struct npu_context *npu_context,int va,unsigned long address,bool flush) { -int i, j; -struct npu *npu; -struct pnv_phb *nphb; -struct pci_dev *npdev;struct mmio_atsd_reg mmio_atsd_reg[NV_MAX_NPUS ];unsigned long pid = npu_context->mm->context.id;
@@ -568,37 +624,25 @@ static void mmio_invalidate(struct npu_c* Loop over all the NPUs this process is active on and launch * an invalidate. */ -for (i =0 ; i <= max_npu2_index; i++) { - mmio_atsd_reg[i].reg =-1 ; -for (j =0 ; j <NV_MAX_LINKS ; j++) { - npdev = npu_context->npdev[i][j]; -if (!npdev) -continue ; +acquire_atsd_reg (npu_context, mmio_atsd_reg); +if (va) +mmio_invalidate_va (mmio_atsd_reg, address, pid, flush); +else +mmio_invalidate_pid (mmio_atsd_reg, pid, flush); - nphb =pci_bus_to_host (npdev->bus)->private_data; - npu = &nphb->npu; - mmio_atsd_reg[i].npu = npu; - -if (va) - mmio_atsd_reg[i].reg = -mmio_invalidate_va (npu, address, pid, - flush); -else - mmio_atsd_reg[i].reg = -mmio_invalidate_pid (npu, pid, flush); - -/* -* The NPU hardware forwards the shootdown to all GPUs -* so we only have to launch one shootdown per NPU. -*/ -break ; - } +mmio_invalidate_wait (mmio_atsd_reg); +if (flush) { +/* +* The GPU requires two flush ATSDs to ensure all entries have +* been flushed. We use PID 0 as it will never be used for a +* process on the GPU. +*/ +mmio_invalidate_pid (mmio_atsd_reg,0 , true); +mmio_invalidate_wait (mmio_atsd_reg); +mmio_invalidate_pid (mmio_atsd_reg,0 , true); +mmio_invalidate_wait (mmio_atsd_reg); } - -mmio_invalidate_wait (mmio_atsd_reg, flush); -if (flush) -/* Wait for the flush to complete */ -mmio_invalidate_wait (mmio_atsd_reg, false); +release_atsd_reg (mmio_atsd_reg); } static void pnv_npu2_mn_release(struct mmu_notifier *mn,
@@ -741,7 +785,16 @@ struct npu_context *pnv_npu2_init_contexif (WARN_ON (of_property_read_u32 (nvlink_dn,"ibm,npu-link-index" , &nvlink_index)))return ERR_PTR (-ENODEV ); - npu_context->npdev[npu->index][nvlink_index] = npdev; + +/* +* npdev is a pci_dev pointer setup by the PCI code. We assign it to +* npdev[][] to indicate to the mmu notifiers that an invalidation +* should also be sent over this nvlink. The notifiers don't use any +* other fields in npu_context, so we just need to ensure that when they +* deference npu_context->npdev[][] it is either a valid pointer or +* NULL. +*/ +WRITE_ONCE (npu_context->npdev[npu->index][nvlink_index], npdev);if (!nphb->npu.nmmu_flush) {/*
@@ -793,7 +846,7 @@ void pnv_npu2_destroy_context(struct npuif (WARN_ON (of_property_read_u32 (nvlink_dn,"ibm,npu-link-index" , &nvlink_index)))return ; - npu_context->npdev[npu->index][nvlink_index] =NULL ; +WRITE_ONCE (npu_context->npdev[npu->index][nvlink_index],NULL );opal_npu_destroy_context (nphb->opal_id, npu_context->mm->context.id,PCI_DEVID (gpdev->bus->number, gpdev->devfn));kref_put (&npu_context->kref, pnv_npu2_release_context);
Greg Kroah-Hartman
maintainerPATCH 191/272 efi/arm*: Only register page tables when they exist
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
[ Upstream commit 6b31a2fa1e8f7bc6c2a474b4a12dad7a145cf83d ]
Currently the arm/arm64 runtime code registers the runtime servies pagetables with ptdump regardless of whether runtime services page tables have been created.
As efi_mm.pgd is NULL in these cases, attempting to dump the efi page tables results in a NULL pointer dereference in the ptdump code:
/sys/kernel/debug# cat efi_page_tables
[ 479.522600] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 479.522715] Mem abort info: [ 479.522764] ESR = 0x96000006 [ 479.522850] Exception class = DABT (current EL), IL = 32 bits [ 479.522899] SET = 0, FnV = 0 [ 479.522937] EA = 0, S1PTW = 0 [ 479.528200] Data abort info: [ 479.528230] ISV = 0, ISS = 0x00000006 [ 479.528317] CM = 0, WnR = 0 [ 479.528317] user pgtable: 4k pages, 48-bit VAs, pgd = 0000000064ab0cb0 [ 479.528449] [0000000000000000] *pgd=00000000fbbe4003, *pud=00000000fb66e003, *pmd=0000000000000000 [ 479.528600] Internal error: Oops: 96000006 [#1] PREEMPT SMP [ 479.528664] Modules linked in: [ 479.528699] CPU: 0 PID: 2457 Comm: cat Not tainted 4.15.0-rc3-00065-g2ad2ee7ecb5c-dirty #7 [ 479.528799] Hardware name: FVP Base (DT) [ 479.528899] pstate: 00400009 (nzcv daif +PAN -UAO) [ 479.528941] pc : walk_pgd.isra.1+0x20/0x1d0 [ 479.529011] lr : ptdump_walk_pgd+0x30/0x50 [ 479.529105] sp : ffff00000bf4bc20 [ 479.529185] x29: ffff00000bf4bc20 x28: 0000ffff9d22e000 [ 479.529271] x27: 0000000000020000 x26: ffff80007b4c63c0 [ 479.529358] x25: 00000000014000c0 x24: ffff80007c098900 [ 479.529445] x23: ffff00000bf4beb8 x22: 0000000000000000 [ 479.529532] x21: ffff00000bf4bd70 x20: 0000000000000001 [ 479.529618] x19: ffff00000bf4bcb0 x18: 0000000000000000 [ 479.529760] x17: 000000000041a1c8 x16: ffff0000082139d8 [ 479.529800] x15: 0000ffff9d3c6030 x14: 0000ffff9d2527f4 [ 479.529924] x13: 00000000000003f3 x12: 0000000000000038 [ 479.530000] x11: 0000000000000003 x10: 0101010101010101 [ 479.530099] x9 : 0000000017e94050 x8 : 000000000000003f [ 479.530226] x7 : 0000000000000000 x6 : 0000000000000000 [ 479.530313] x5 : 0000000000000001 x4 : 0000000000000000 [ 479.530416] x3 : ffff000009069fd8 x2 : 0000000000000000 [ 479.530500] x1 : 0000000000000000 x0 : 0000000000000000 [ 479.530599] Process cat (pid: 2457, stack limit = 0x000000005d1b0e6f) [ 479.530660] Call trace: [ 479.530746] walk_pgd.isra.1+0x20/0x1d0 [ 479.530833] ptdump_walk_pgd+0x30/0x50 [ 479.530907] ptdump_show+0x10/0x20 [ 479.530920] seq_read+0xc8/0x470 [ 479.531023] full_proxy_read+0x60/0x90 [ 479.531100] __vfs_read+0x18/0x100 [ 479.531180] vfs_read+0x88/0x160 [ 479.531267] SyS_read+0x48/0xb0 [ 479.531299] el0_svc_naked+0x20/0x24 [ 479.531400] Code: 91400420 f90033a0 a90707a2 f9403fa0 (f9400000) [ 479.531499] ---[ end trace bfe8e28d8acb2b67 ]---
Segmentation fault
Let's avoid this problem by only registering the tables after their successful creation, which is also less confusing when EFI runtime services are not in use.
--- drivers/firmware/efi/arm-runtime.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/firmware/efi/arm-runtime.c +3 -0
@@ -54,6 +54,9 @@ static struct ptdump_info efi_ptdump_infstatic int __init ptdump_init (void ) { +if (!efi_enabled (EFI_RUNTIME_SERVICES )) +return 0 ; +return ptdump_debugfs_register (&efi_ptdump_info,"efi_page_tables" ); }device_initcall (ptdump_init);
Greg Kroah-Hartman
maintainerPATCH 194/272 arm64: dts: qcom: Fix SPI5 config on MSM8996
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilia Lin <[email protected]>
[ Upstream commit e723795c702b52cfceb3bb3faa63059eb4658313 ]
Set correct clocks and interrupt values. Fixes the incorrect SPI master configuration. This is mandatory to make the SPI5 interface functional.
--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/msm8996.dtsi +2 -2
@@ -497,8 +497,8 @@ blsp2_spi5: spi@75ba000{ compatible = "qcom,spi-qup-v2.2.1"; reg = <0x075ba000 0x600>; - interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&gcc GCC_BLSP2_QUP5_SPI_APPS_CLK>, + interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&gcc GCC_BLSP2_QUP6_SPI_APPS_CLK>, <&gcc GCC_BLSP2_AHB_CLK>; clock-names = "core", "iface"; pinctrl-names = "default", "sleep";
Greg Kroah-Hartman
maintainerPATCH 208/272 powerpc/mm/slice: Remove intermediate bitmap copy
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit 326691ad4f179e6edc7eb1271e618dd673e4736d upstream.
bitmap_or() and bitmap_andnot() can work properly with dst identical to src1 or src2. There is no need of an intermediate result bitmap that is copied back to dst in a second step.
--- arch/powerpc/mm/slice.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/powerpc/mm/slice.c +4 -8
@@ -388,21 +388,17 @@ static unsigned long slice_find_area(strstatic inline void slice_or_mask (struct slice_mask *dst,struct slice_mask *src) { -DECLARE_BITMAP (result,SLICE_NUM_HIGH ); - dst->low_slices |= src->low_slices; -bitmap_or (result, dst->high_slices, src->high_slices,SLICE_NUM_HIGH ); -bitmap_copy (dst->high_slices, result,SLICE_NUM_HIGH ); +bitmap_or (dst->high_slices, dst->high_slices, src->high_slices, +SLICE_NUM_HIGH ); }static inline void slice_andnot_mask (struct slice_mask *dst,struct slice_mask *src) { -DECLARE_BITMAP (result,SLICE_NUM_HIGH ); - dst->low_slices &= ~src->low_slices; -bitmap_andnot (result, dst->high_slices, src->high_slices,SLICE_NUM_HIGH ); -bitmap_copy (dst->high_slices, result,SLICE_NUM_HIGH ); +bitmap_andnot (dst->high_slices, dst->high_slices, src->high_slices, +SLICE_NUM_HIGH ); }#ifdef CONFIG_PPC_64K_PAGES
Greg Kroah-Hartman
maintainerPATCH 210/272 powerpc/mm/slice: Enhance for supporting PPC32
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit db3a528db41caaa6dfd4c64e9f5efb1c81a80467 upstream.
In preparation for the following patch which will fix an issue on the 8xx by re-using the 'slices', this patch enhances the 'slices' implementation to support 32 bits CPUs.
On PPC32, the address space is limited to 4Gbytes, hence only the low slices will be used.
The high slices use bitmaps. As bitmap functions are not prepared to handle bitmaps of size 0, this patch ensures that bitmap functions are called only when SLICE_NUM_HIGH is not nul.
--- arch/powerpc/include/asm/nohash/32/slice.h | 18 ++++++++++++++ arch/powerpc/include/asm/slice.h | 4 ++- arch/powerpc/mm/slice.c | 37 ++++++++++++++++++++++------- 3 files changed, 50 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/nohash/32/slice.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_POWERPC_NOHASH_32_SLICE_H +#define _ASM_POWERPC_NOHASH_32_SLICE_H + +#ifdef CONFIG_PPC_MM_SLICES + +#define SLICE_LOW_SHIFT 28 +#define SLICE_LOW_TOP (0x100000000ull) +#define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) +#define GET_LOW_SLICE_INDEX (addr) ((addr) >> SLICE_LOW_SHIFT) + +#define SLICE_HIGH_SHIFT 0 +#define SLICE_NUM_HIGH 0ul +#define GET_HIGH_SLICE_INDEX (addr) (addr & 0) + +#endif /* CONFIG_PPC_MM_SLICES */ + +#endif /* _ASM_POWERPC_NOHASH_32_SLICE_H */
arch/powerpc/include/asm/slice.h +3 -1
@@ -4,8 +4,10 @@#ifdef CONFIG_PPC_BOOK3S_64 #include <asm/book3s/64/slice.h> -#else +#elif defined(CONFIG_PPC64 )#include <asm/nohash/64/slice.h> +#elif defined(CONFIG_PPC_MMU_NOHASH ) +#include <asm/nohash/32/slice.h> #endif #ifdef CONFIG_PPC_MM_SLICES
arch/powerpc/mm/slice.c +29 -8
@@ -73,10 +73,12 @@ static void slice_range_to_mask(unsignedunsigned long end = start + len -1 ; ret->low_slices =0 ; -bitmap_zero (ret->high_slices,SLICE_NUM_HIGH ); +if (SLICE_NUM_HIGH ) +bitmap_zero (ret->high_slices,SLICE_NUM_HIGH );if (start <SLICE_LOW_TOP ) { -unsigned long mend =min (end, (SLICE_LOW_TOP -1 )); +unsigned long mend =min (end, + (unsigned long )(SLICE_LOW_TOP -1 )); ret->low_slices = (1u << (GET_LOW_SLICE_INDEX (mend) +1 )) - (1u <<GET_LOW_SLICE_INDEX (start));
@@ -113,11 +115,13 @@ static int slice_high_has_vma(struct mm_unsigned long start = slice <<SLICE_HIGH_SHIFT ;unsigned long end = start + (1ul <<SLICE_HIGH_SHIFT ); +#ifdef CONFIG_PPC64 /* Hack, so that each addresses is controlled by exactly one * of the high or low area bitmaps, the first high area starts * at 4GB, not 0 */ if (start ==0 ) start =SLICE_LOW_TOP ; +#endif return !slice_area_is_free (mm, start, end - start); }
@@ -128,7 +132,8 @@ static void slice_mask_for_free(struct munsigned long i; ret->low_slices =0 ; -bitmap_zero (ret->high_slices,SLICE_NUM_HIGH ); +if (SLICE_NUM_HIGH ) +bitmap_zero (ret->high_slices,SLICE_NUM_HIGH );for (i =0 ; i <SLICE_NUM_LOW ; i++)if (!slice_low_has_vma (mm, i))
@@ -151,7 +156,8 @@ static void slice_mask_for_size(struct mu64 lpsizes; ret->low_slices =0 ; -bitmap_zero (ret->high_slices,SLICE_NUM_HIGH ); +if (SLICE_NUM_HIGH ) +bitmap_zero (ret->high_slices,SLICE_NUM_HIGH ); lpsizes = mm->context.low_slices_psize;for (i =0 ; i <SLICE_NUM_LOW ; i++)
@@ -180,6 +186,10 @@ static int slice_check_fit(struct mm_str*/ unsigned long slice_count =GET_HIGH_SLICE_INDEX (mm->context.slb_addr_limit); +if (!SLICE_NUM_HIGH ) +return (mask.low_slices & available.low_slices) == + mask.low_slices; +bitmap_and (result, mask.high_slices, available.high_slices, slice_count);
@@ -189,6 +199,7 @@ static int slice_check_fit(struct mm_strstatic void slice_flush_segments (void *parm) { +#ifdef CONFIG_PPC64 struct mm_struct *mm = parm;unsigned long flags;
@@ -200,6 +211,7 @@ static void slice_flush_segments(void *plocal_irq_save (flags);slb_flush_and_rebolt ();local_irq_restore (flags); +#endif }static void slice_convert (struct mm_struct *mm,struct slice_mask mask,int psize)
@@ -389,6 +401,8 @@ static unsigned long slice_find_area(strstatic inline void slice_or_mask (struct slice_mask *dst,struct slice_mask *src) { dst->low_slices |= src->low_slices; +if (!SLICE_NUM_HIGH ) +return ;bitmap_or (dst->high_slices, dst->high_slices, src->high_slices,SLICE_NUM_HIGH ); }
@@ -397,6 +411,8 @@ static inline void slice_andnot_mask(str { dst->low_slices &= ~src->low_slices; +if (!SLICE_NUM_HIGH ) +return ;bitmap_andnot (dst->high_slices, dst->high_slices, src->high_slices,SLICE_NUM_HIGH ); }
@@ -446,14 +462,17 @@ unsigned long slice_get_unmapped_area(un* init different masks */ mask.low_slices =0 ; -bitmap_zero (mask.high_slices,SLICE_NUM_HIGH );/* silence stupid warning */ ; potential_mask.low_slices =0 ; -bitmap_zero (potential_mask.high_slices,SLICE_NUM_HIGH ); compat_mask.low_slices =0 ; -bitmap_zero (compat_mask.high_slices,SLICE_NUM_HIGH ); + +if (SLICE_NUM_HIGH ) { +bitmap_zero (mask.high_slices,SLICE_NUM_HIGH ); +bitmap_zero (potential_mask.high_slices,SLICE_NUM_HIGH ); +bitmap_zero (compat_mask.high_slices,SLICE_NUM_HIGH ); + }/* Sanity checks */ BUG_ON (mm->task_size ==0 );
@@ -591,7 +610,9 @@ unsigned long slice_get_unmapped_area(un convert:slice_andnot_mask (&mask, &good_mask);slice_andnot_mask (&mask, &compat_mask); -if (mask.low_slices || !bitmap_empty (mask.high_slices,SLICE_NUM_HIGH )) { +if (mask.low_slices || + (SLICE_NUM_HIGH && + !bitmap_empty (mask.high_slices,SLICE_NUM_HIGH ))) {slice_convert (mm, mask, psize);if (psize >MMU_PAGE_BASE )on_each_cpu (slice_flush_segments, mm,1 );
Greg Kroah-Hartman
maintainerPATCH 226/272 net: stmmac: ensure that the MSS desc is the last desc to set the own bit
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 15d2ee42a3087089e73ad52fd8c1b37ab496b87c ]
A dma_wmb() is used to guarantee the ordering, with respect to other writes, to cache coherent DMA memory.
There is a dma_wmb() in prepare_tx_desc()/prepare_tso_tx_desc() which ensures that TDES0/1/2 is written before TDES3 (which contains the own bit), for First Desc.
However, in the rare case that MSS changes, there will be a MSS context descriptor in front of the regular DMA descriptors:
<MSS desc> <- DMA Next Descriptor
<First Desc>
<desc n>
<Last Desc>
Thus, for this special case, we need a dma_wmb()
after prepare_tso_tx_desc()/before writing the own bit to the MSS desc, so that we flush the write to TDES3 for First Desc,
in order to ensure that the MSS descriptor is the last descriptor to set the own bit.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +8 -1
@@ -2985,8 +2985,15 @@ static netdev_tx_t stmmac_tso_xmit(struc tcp_hdrlen(skb) / 4, (skb->len - proto_hdr_len));/* If context desc is used to change MSS */ -if (mss_desc) +if (mss_desc) { +/* Make sure that first descriptor has been completely +* written, including its own bit. This is because MSS is +* actually before first descriptor, so we need to make +* sure that MSS's own bit is the last thing written. +*/ +dma_wmb (); priv->hw->desc->set_tx_owner (mss_desc); + }/* The own bit must be the latest setting done when prepare the * descriptor and then barrier is needed to make sure that
Greg Kroah-Hartman
maintainerPATCH 235/272 ARM: dts: bcm283x: Fix probing of bcm2835-i2s
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit 79c81facdc0b43b1cef37b8d5689a8c8b78f8be0 ]
Since 517e7a1537a ("ASoC: bcm2835: move to use the clock framework") the bcm2835-i2s requires a clock as DT property. Unfortunately the necessary DT change has never been applied. While we are at it also fix the first PCM register range to cover the PCM_GRAY register.
--- arch/arm/boot/dts/bcm283x.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/bcm283x.dtsi +2 -2
@@ -397,8 +397,8 @@ i2s: i2s@7e203000 { compatible = "brcm,bcm2835-i2s"; - reg = <0x7e203000 0x20>, - <0x7e101098 0x02>; + reg = <0x7e203000 0x24>; + clocks = <&clocks BCM2835_CLOCK_PCM>; dmas = <&dma 2>, <&dma 3>;
Greg Kroah-Hartman
maintainerPATCH 242/272 pinctrl: sh-pfc: r8a7796: Fix MOD_SEL register pin assignment for SSI pins group
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takeshi Kihara <[email protected]>
[ Upstream commit b418c4609d5052d174668ad6d13efe023c45c595 ]
This patch fixes MOD_SEL1 bit20 and MOD_SEL2 bit20, bit21 pin assignment for SSI pins group.
This is a correction to the incorrect implementation of MOD_SEL register pin assignment for R8A7796 SoC specification of R-Car Gen3 Hardware User's Manual Rev.0.51E or later.
--- drivers/pinctrl/sh-pfc/pfc-r8a7796.c | 40 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/pinctrl/sh-pfc/pfc-r8a7796.c +20 -20
@@ -1,7 +1,7 @@/* * R8A7796 processor support - PFC hardware block. * -* Copyright (C) 2016 Renesas Electronics Corp. +* Copyright (C) 2016-2017 Renesas Electronics Corp. * * This file is based on the drivers/pinctrl/sh-pfc/pfc-r8a7795.c *
@@ -477,7 +477,7 @@ FM(IP16_31_28) IP16_31_28 FM(IP17_31_28)#define MOD_SEL1_26 FM(SEL_TIMER_TMU_0) FM(SEL_TIMER_TMU_1)#define MOD_SEL1_25_24 FM(SEL_SSP1_1_0) FM(SEL_SSP1_1_1) FM(SEL_SSP1_1_2) FM(SEL_SSP1_1_3)#define MOD_SEL1_23_22_21 FM(SEL_SSP1_0_0) FM(SEL_SSP1_0_1) FM(SEL_SSP1_0_2) FM(SEL_SSP1_0_3) FM(SEL_SSP1_0_4) F_(0, 0) F_(0, 0) F_(0, 0) -#define MOD_SEL1_20 FM(SEL_SSI_0) FM(SEL_SSI_1) +#define MOD_SEL1_20 FM(SEL_SSI1_0) FM(SEL_SSI1_1)#define MOD_SEL1_19 FM(SEL_SPEED_PULSE_0) FM(SEL_SPEED_PULSE_1)#define MOD_SEL1_18_17 FM(SEL_SIMCARD_0) FM(SEL_SIMCARD_1) FM(SEL_SIMCARD_2) FM(SEL_SIMCARD_3)#define MOD_SEL1_16 FM(SEL_SDHI2_0) FM(SEL_SDHI2_1)
@@ -1218,7 +1218,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP13_11_8 ,HSCK0 ),PINMUX_IPSR_MSEL (IP13_11_8 ,MSIOF1_SCK_D ,SEL_MSIOF1_3 ),PINMUX_IPSR_MSEL (IP13_11_8 ,AUDIO_CLKB_A ,SEL_ADG_B_0 ), -PINMUX_IPSR_MSEL (IP13_11_8 ,SSI_SDATA1_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP13_11_8 ,SSI_SDATA1_B ,SEL_SSI1_1 ),PINMUX_IPSR_MSEL (IP13_11_8 ,TS_SCK0_D ,SEL_TSIF0_3 ),PINMUX_IPSR_MSEL (IP13_11_8 ,STP_ISCLK_0_D ,SEL_SSP1_0_3 ), PINMUX_IPSR_MSEL(IP13_11_8, RIF0_CLK_C, SEL_DRIF0_2),
@@ -1226,14 +1226,14 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP13_15_12 ,HRX0 ),PINMUX_IPSR_MSEL (IP13_15_12 ,MSIOF1_RXD_D ,SEL_MSIOF1_3 ), -PINMUX_IPSR_MSEL (IP13_15_12 ,SSI_SDATA2_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP13_15_12 ,SSI_SDATA2_B ,SEL_SSI2_1 ),PINMUX_IPSR_MSEL (IP13_15_12 ,TS_SDEN0_D ,SEL_TSIF0_3 ),PINMUX_IPSR_MSEL (IP13_15_12 ,STP_ISEN_0_D ,SEL_SSP1_0_3 ),PINMUX_IPSR_MSEL (IP13_15_12 ,RIF0_D0_C ,SEL_DRIF0_2 ),PINMUX_IPSR_GPSR (IP13_19_16 ,HTX0 ),PINMUX_IPSR_MSEL (IP13_19_16 ,MSIOF1_TXD_D ,SEL_MSIOF1_3 ), -PINMUX_IPSR_MSEL (IP13_19_16 ,SSI_SDATA9_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP13_19_16 ,SSI_SDATA9_B ,SEL_SSI9_1 ),PINMUX_IPSR_MSEL (IP13_19_16 ,TS_SDAT0_D ,SEL_TSIF0_3 ),PINMUX_IPSR_MSEL (IP13_19_16 ,STP_ISD_0_D ,SEL_SSP1_0_3 ), PINMUX_IPSR_MSEL(IP13_19_16, RIF0_D1_C, SEL_DRIF0_2),
@@ -1241,7 +1241,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP13_23_20 ,HCTS0_N ),PINMUX_IPSR_MSEL (IP13_23_20 ,RX2_B ,SEL_SCIF2_1 ),PINMUX_IPSR_MSEL (IP13_23_20 ,MSIOF1_SYNC_D ,SEL_MSIOF1_3 ), -PINMUX_IPSR_MSEL (IP13_23_20 ,SSI_SCK9_A ,SEL_SSI_0 ), +PINMUX_IPSR_MSEL (IP13_23_20 ,SSI_SCK9_A ,SEL_SSI9_0 ),PINMUX_IPSR_MSEL (IP13_23_20 ,TS_SPSYNC0_D ,SEL_TSIF0_3 ),PINMUX_IPSR_MSEL (IP13_23_20 ,STP_ISSYNC_0_D ,SEL_SSP1_0_3 ), PINMUX_IPSR_MSEL(IP13_23_20, RIF0_SYNC_C, SEL_DRIF0_2),
@@ -1250,7 +1250,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP13_27_24 ,HRTS0_N ),PINMUX_IPSR_MSEL (IP13_27_24 ,TX2_B ,SEL_SCIF2_1 ),PINMUX_IPSR_MSEL (IP13_27_24 ,MSIOF1_SS1_D ,SEL_MSIOF1_3 ), -PINMUX_IPSR_MSEL (IP13_27_24 ,SSI_WS9_A ,SEL_SSI_0 ), +PINMUX_IPSR_MSEL (IP13_27_24 ,SSI_WS9_A ,SEL_SSI9_0 ),PINMUX_IPSR_MSEL (IP13_27_24 ,STP_IVCXO27_0_D ,SEL_SSP1_0_3 ),PINMUX_IPSR_MSEL (IP13_27_24 ,BPFCLK_A ,SEL_FM_0 ), PINMUX_IPSR_GPSR(IP13_27_24, AUDIO_CLKOUT2_A),
@@ -1265,7 +1265,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_MSEL (IP14_3_0 ,RX5_A ,SEL_SCIF5_0 ),PINMUX_IPSR_MSEL (IP14_3_0 ,NFWP_N_A ,SEL_NDF_0 ),PINMUX_IPSR_MSEL (IP14_3_0 ,AUDIO_CLKA_C ,SEL_ADG_A_2 ), -PINMUX_IPSR_MSEL (IP14_3_0 ,SSI_SCK2_A ,SEL_SSI_0 ), +PINMUX_IPSR_MSEL (IP14_3_0 ,SSI_SCK2_A ,SEL_SSI2_0 ),PINMUX_IPSR_MSEL (IP14_3_0 ,STP_IVCXO27_0_C ,SEL_SSP1_0_2 ),PINMUX_IPSR_GPSR (IP14_3_0 ,AUDIO_CLKOUT3_A ), PINMUX_IPSR_MSEL(IP14_3_0, TCLK1_B, SEL_TIMER_TMU_1),
@@ -1274,7 +1274,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_MSEL (IP14_7_4 ,TX5_A ,SEL_SCIF5_0 ),PINMUX_IPSR_MSEL (IP14_7_4 ,MSIOF1_SS2_D ,SEL_MSIOF1_3 ),PINMUX_IPSR_MSEL (IP14_7_4 ,AUDIO_CLKC_A ,SEL_ADG_C_0 ), -PINMUX_IPSR_MSEL (IP14_7_4 ,SSI_WS2_A ,SEL_SSI_0 ), +PINMUX_IPSR_MSEL (IP14_7_4 ,SSI_WS2_A ,SEL_SSI2_0 ),PINMUX_IPSR_MSEL (IP14_7_4 ,STP_OPWM_0_D ,SEL_SSP1_0_3 ),PINMUX_IPSR_GPSR (IP14_7_4 ,AUDIO_CLKOUT_D ), PINMUX_IPSR_MSEL(IP14_7_4, SPEEDIN_B, SEL_SPEED_PULSE_1),
@@ -1302,10 +1302,10 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_MSEL (IP14_31_28 ,MSIOF1_SS2_F ,SEL_MSIOF1_5 ),/* IPSR15 */ -PINMUX_IPSR_MSEL (IP15_3_0 ,SSI_SDATA1_A ,SEL_SSI_0 ), +PINMUX_IPSR_MSEL (IP15_3_0 ,SSI_SDATA1_A ,SEL_SSI1_0 ), -PINMUX_IPSR_MSEL (IP15_7_4 ,SSI_SDATA2_A ,SEL_SSI_0 ), -PINMUX_IPSR_MSEL (IP15_7_4 ,SSI_SCK1_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP15_7_4 ,SSI_SDATA2_A ,SEL_SSI2_0 ), +PINMUX_IPSR_MSEL (IP15_7_4 ,SSI_SCK1_B ,SEL_SSI1_1 ),PINMUX_IPSR_GPSR (IP15_11_8 ,SSI_SCK349 ), PINMUX_IPSR_MSEL(IP15_11_8, MSIOF1_SS1_A, SEL_MSIOF1_0),
@@ -1391,11 +1391,11 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_MSEL (IP16_27_24 ,RIF1_D1_A ,SEL_DRIF1_0 ),PINMUX_IPSR_MSEL (IP16_27_24 ,RIF3_D1_A ,SEL_DRIF3_0 ), -PINMUX_IPSR_MSEL (IP16_31_28 ,SSI_SDATA9_A ,SEL_SSI_0 ), +PINMUX_IPSR_MSEL (IP16_31_28 ,SSI_SDATA9_A ,SEL_SSI9_0 ),PINMUX_IPSR_MSEL (IP16_31_28 ,HSCK2_B ,SEL_HSCIF2_1 ),PINMUX_IPSR_MSEL (IP16_31_28 ,MSIOF1_SS1_C ,SEL_MSIOF1_2 ),PINMUX_IPSR_MSEL (IP16_31_28 ,HSCK1_A ,SEL_HSCIF1_0 ), -PINMUX_IPSR_MSEL (IP16_31_28 ,SSI_WS1_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP16_31_28 ,SSI_WS1_B ,SEL_SSI1_1 ),PINMUX_IPSR_GPSR (IP16_31_28 ,SCK1 ),PINMUX_IPSR_MSEL (IP16_31_28 ,STP_IVCXO27_1_A ,SEL_SSP1_1_0 ), PINMUX_IPSR_MSEL(IP16_31_28, SCK5_A, SEL_SCIF5_0),
@@ -1427,7 +1427,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP17_19_16 ,USB1_PWEN ),PINMUX_IPSR_MSEL (IP17_19_16 ,SIM0_CLK_C ,SEL_SIMCARD_2 ), -PINMUX_IPSR_MSEL (IP17_19_16 ,SSI_SCK1_A ,SEL_SSI_0 ), +PINMUX_IPSR_MSEL (IP17_19_16 ,SSI_SCK1_A ,SEL_SSI1_0 ),PINMUX_IPSR_MSEL (IP17_19_16 ,TS_SCK0_E ,SEL_TSIF0_4 ),PINMUX_IPSR_MSEL (IP17_19_16 ,STP_ISCLK_0_E ,SEL_SSP1_0_4 ), PINMUX_IPSR_MSEL(IP17_19_16, FMCLK_B, SEL_FM_1),
@@ -1437,7 +1437,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP17_23_20 ,USB1_OVC ),PINMUX_IPSR_MSEL (IP17_23_20 ,MSIOF1_SS2_C ,SEL_MSIOF1_2 ), -PINMUX_IPSR_MSEL (IP17_23_20 ,SSI_WS1_A ,SEL_SSI_0 ), +PINMUX_IPSR_MSEL (IP17_23_20 ,SSI_WS1_A ,SEL_SSI1_0 ),PINMUX_IPSR_MSEL (IP17_23_20 ,TS_SDAT0_E ,SEL_TSIF0_4 ),PINMUX_IPSR_MSEL (IP17_23_20 ,STP_ISD_0_E ,SEL_SSP1_0_4 ), PINMUX_IPSR_MSEL(IP17_23_20, FMIN_B, SEL_FM_1),
@@ -1447,7 +1447,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP17_27_24 ,USB30_PWEN ),PINMUX_IPSR_GPSR (IP17_27_24 ,AUDIO_CLKOUT_B ), -PINMUX_IPSR_MSEL (IP17_27_24 ,SSI_SCK2_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP17_27_24 ,SSI_SCK2_B ,SEL_SSI2_1 ),PINMUX_IPSR_MSEL (IP17_27_24 ,TS_SDEN1_D ,SEL_TSIF1_3 ),PINMUX_IPSR_MSEL (IP17_27_24 ,STP_ISEN_1_D ,SEL_SSP1_1_3 ), PINMUX_IPSR_MSEL(IP17_27_24, STP_OPWM_0_E, SEL_SSP1_0_4),
@@ -1459,7 +1459,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP17_31_28 ,USB30_OVC ),PINMUX_IPSR_GPSR (IP17_31_28 ,AUDIO_CLKOUT1_B ), -PINMUX_IPSR_MSEL (IP17_31_28 ,SSI_WS2_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP17_31_28 ,SSI_WS2_B ,SEL_SSI2_1 ),PINMUX_IPSR_MSEL (IP17_31_28 ,TS_SPSYNC1_D ,SEL_TSIF1_3 ),PINMUX_IPSR_MSEL (IP17_31_28 ,STP_ISSYNC_1_D ,SEL_SSP1_1_3 ), PINMUX_IPSR_MSEL(IP17_31_28, STP_IVCXO27_0_E, SEL_SSP1_0_4),
@@ -1470,7 +1470,7 @@ static const u16 pinmux_data[] = {/* IPSR18 */ PINMUX_IPSR_GPSR (IP18_3_0 ,GP6_30 ),PINMUX_IPSR_GPSR (IP18_3_0 ,AUDIO_CLKOUT2_B ), -PINMUX_IPSR_MSEL (IP18_3_0 ,SSI_SCK9_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP18_3_0 ,SSI_SCK9_B ,SEL_SSI9_1 ),PINMUX_IPSR_MSEL (IP18_3_0 ,TS_SDEN0_E ,SEL_TSIF0_4 ),PINMUX_IPSR_MSEL (IP18_3_0 ,STP_ISEN_0_E ,SEL_SSP1_0_4 ), PINMUX_IPSR_MSEL(IP18_3_0, RIF2_D0_B, SEL_DRIF2_1),
@@ -1480,7 +1480,7 @@ static const u16 pinmux_data[] = {PINMUX_IPSR_GPSR (IP18_7_4 ,GP6_31 ),PINMUX_IPSR_GPSR (IP18_7_4 ,AUDIO_CLKOUT3_B ), -PINMUX_IPSR_MSEL (IP18_7_4 ,SSI_WS9_B ,SEL_SSI_1 ), +PINMUX_IPSR_MSEL (IP18_7_4 ,SSI_WS9_B ,SEL_SSI9_1 ),PINMUX_IPSR_MSEL (IP18_7_4 ,TS_SPSYNC0_E ,SEL_TSIF0_4 ),PINMUX_IPSR_MSEL (IP18_7_4 ,STP_ISSYNC_0_E ,SEL_SSP1_0_4 ), PINMUX_IPSR_MSEL(IP18_7_4, RIF2_D1_B, SEL_DRIF2_1),
Greg Kroah-Hartman
maintainerPATCH 243/272 dt-bindings: display: msm/dsi: Fix the PHY regulator supply props
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Archit Taneja <[email protected]>
[ Upstream commit 8c4905fd4939c59e0f7993ba34883e328eef4b59 ]
The PHY regulator supply names vary across different PHY versions. Mention explicitly which PHYs require which supplies.
--- Documentation/devicetree/bindings/display/msm/dsi.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/display/msm/dsi.txt +4 -0
@@ -102,7 +102,11 @@ Required properties: - clocks: Phandles to device clocks. See [1] for details on clock bindings. - clock-names: the following clocks are required: * "iface" + For 28nm HPM/LP, 28nm 8960 PHYs: - vddio-supply: phandle to vdd-io regulator device node + For 20nm PHY: +- vddio-supply: phandle to vdd-io regulator device node +- vcca-supply: phandle to vcca regulator device node Optional properties: - qcom,dsi-phy-regulator-ldo-mode: Boolean value indicating if the LDO mode PHY
Greg Kroah-Hartman
maintainerPATCH 244/272 drm/amd/display: Set vsc pack revision when DPCD revision is >= 1.2
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao <[email protected]>
[ Upstream commit 3b94a4007dcfd4ac5780cd3d8a2d99979c966073 ]
Brightness couldn't change when booting up in DC mode.
It was because "psr_enabled" flag was not set to true before setting vsc packet revision, causing packet rev setup was skipped. Now instead of checking the psr flag, it checks if the DPCD_REV >= 1.2 and set the vsc packet revision.
--- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +3 -1
@@ -35,6 +35,7 @@#include "core_types.h" #include "set_mode_types.h" #include "virtual/virtual_stream_encoder.h" +#include "dpcd_defs.h" #include "dce80/dce80_resource.h" #include "dce100/dce100_resource.h"
@@ -2428,7 +2429,8 @@ static void set_vsc_info_packet(unsigned int vscPacketRevision =0 ;unsigned int i; -if (stream->sink->link->psr_enabled) { +/*VSC packet set to 2 when DP revision >= 1.2*/ +if (stream->sink->link->dpcd_caps.dpcd_rev.raw >=DPCD_REV_12 ) { vscPacketRevision =2 ; }
Greg Kroah-Hartman
maintainerPATCH 258/272 drm: rcar-du: lvds: Fix LVDS startup on R-Car Gen3
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit 796ceb9269626afaed3b4955c40d2c3d7a8c5d01 ]
According to the latest revisions of the R-Car Gen3 manual, the LVDS mode must be set before the LVDS I/O pins are enabled, not after -- fix the Gen3 LVDS startup sequence accordingly.
--- drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c +5 -2
@@ -95,7 +95,7 @@ static void rcar_du_lvdsenc_start_gen3(su32 lvdcr0;u32 pllcr; -/* PLL clock configuration */ +/* Set the PLL clock configuration and LVDS mode. */ if (freq <42000 ) pllcr =LVDPLLCR_PLLDIVCNT_42M ;else if (freq <85000 )
@@ -107,6 +107,9 @@ static void rcar_du_lvdsenc_start_gen3(srcar_lvds_write (lvds,LVDPLLCR , pllcr); + lvdcr0 = lvds->mode <<LVDCR0_LVMD_SHIFT ; +rcar_lvds_write (lvds,LVDCR0 , lvdcr0); +/* Turn all the channels on. */ rcar_lvds_write(lvds, LVDCR1, LVDCR1_CHSTBY_GEN3(3) | LVDCR1_CHSTBY_GEN3(2) |
@@ -117,7 +120,7 @@ static void rcar_du_lvdsenc_start_gen3(s* Turn the PLL on, set it to LVDS normal mode, wait for the startup * delay and turn the output on. */ - lvdcr0 = (lvds->mode <<LVDCR0_LVMD_SHIFT ) |LVDCR0_PLLON ; + lvdcr0 |=LVDCR0_PLLON ;rcar_lvds_write (lvds,LVDCR0 , lvdcr0); lvdcr0 |=LVDCR0_PWD ;
Greg Kroah-Hartman
maintainerPATCH 260/272 selftests: Add FIB onlink tests
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Ahern <[email protected]>
[ Upstream commit 153e1b84f477f716bc3f81e6cfae1a3d941fc7ec ]
Add test cases verifying FIB onlink commands work as expected in various conditions - IPv4, IPv6, main table, and VRF.
--- tools/testing/selftests/net/fib-onlink-tests.sh | 375 ++++++++++++++++++++++++ 1 file changed, 375 insertions(+) create mode 100644 tools/testing/selftests/net/fib-onlink-tests.sh
tools/testing/selftests/net/fib-onlink-tests.sh new file +375 -0
@@ -0,0 +1,375 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# IPv4 and IPv6 onlink tests + +PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no} + +# Network interfaces +# - odd in current namespace; even in peer ns +declare -A NETIFS +# default VRF +NETIFS[p1]=veth1 +NETIFS[p2]=veth2 +NETIFS[p3]=veth3 +NETIFS[p4]=veth4 +# VRF +NETIFS[p5]=veth5 +NETIFS[p6]=veth6 +NETIFS[p7]=veth7 +NETIFS[p8]=veth8 + +# /24 network +declare -A V4ADDRS +V4ADDRS[p1]=169.254.1.1 +V4ADDRS[p2]=169.254.1.2 +V4ADDRS[p3]=169.254.3.1 +V4ADDRS[p4]=169.254.3.2 +V4ADDRS[p5]=169.254.5.1 +V4ADDRS[p6]=169.254.5.2 +V4ADDRS[p7]=169.254.7.1 +V4ADDRS[p8]=169.254.7.2 + +# /64 network +declare -A V6ADDRS +V6ADDRS[p1]=2001:db8:101::1 +V6ADDRS[p2]=2001:db8:101::2 +V6ADDRS[p3]=2001:db8:301::1 +V6ADDRS[p4]=2001:db8:301::2 +V6ADDRS[p5]=2001:db8:501::1 +V6ADDRS[p6]=2001:db8:501::2 +V6ADDRS[p7]=2001:db8:701::1 +V6ADDRS[p8]=2001:db8:701::2 + +# Test networks: +# [1] = default table +# [2] = VRF +# +# /32 host routes +declare -A TEST_NET4 +TEST_NET4[1]=169.254.101 +TEST_NET4[2]=169.254.102 +# /128 host routes +declare -A TEST_NET6 +TEST_NET6[1]=2001:db8:101 +TEST_NET6[2]=2001:db8:102 + +# connected gateway +CONGW[1]=169.254.1.254 +CONGW[2]=169.254.5.254 + +# recursive gateway +RECGW4[1]=169.254.11.254 +RECGW4[2]=169.254.12.254 +RECGW6[1]=2001:db8:11::64 +RECGW6[2]=2001:db8:12::64 + +# for v4 mapped to v6 +declare -A TEST_NET4IN6IN6 +TEST_NET4IN6[1]=10.1.1.254 +TEST_NET4IN6[2]=10.2.1.254 + +# mcast address +MCAST6=ff02::1 + + +PEER_NS=bart +PEER_CMD="ip netns exec ${PEER_NS}" +VRF=lisa +VRF_TABLE=1101 +PBR_TABLE=101 + +################################################################################ +# utilities + +log_test() +{ + local rc=$1 + local expected=$2 + local msg="$3" + + if [ ${rc} -eq ${expected} ]; then + nsuccess=$((nsuccess+1)) + printf "\n TEST: %-50s [ OK ]\n" "${msg}" + else + nfail=$((nfail+1)) + printf "\n TEST: %-50s [FAIL]\n" "${msg}" + if [ "${PAUSE_ON_FAIL}" = "yes" ]; then + echo + echo "hit enter to continue, 'q' to quit" + read a + [ "$a" = "q" ] && exit 1 + fi + fi +} + +log_section() +{ + echo + echo "######################################################################" + echo "TEST SECTION: $*" + echo "######################################################################" +} + +log_subsection() +{ + echo + echo "#########################################" + echo "TEST SUBSECTION: $*" +} + +run_cmd() +{ + echo + echo "COMMAND: $*" + eval $* +} + +get_linklocal() +{ + local dev=$1 + local pfx + local addr + + addr=$(${pfx} ip -6 -br addr show dev ${dev} | \ + awk '{ + for (i = 3; i <= NF; ++i) { + if ($i ~ /^fe80/) + print $i + } + }' + ) + addr=${addr/\/*} + + [ -z "$addr" ] && return 1 + + echo $addr + + return 0 +} + +################################################################################ +# + +setup() +{ + echo + echo "########################################" + echo "Configuring interfaces" + + set -e + + # create namespace + ip netns add ${PEER_NS} + ip -netns ${PEER_NS} li set lo up + + # add vrf table + ip li add ${VRF} type vrf table ${VRF_TABLE} + ip li set ${VRF} up + ip ro add table ${VRF_TABLE} unreachable default + ip -6 ro add table ${VRF_TABLE} unreachable default + + # create test interfaces + ip li add ${NETIFS[p1]} type veth peer name ${NETIFS[p2]} + ip li add ${NETIFS[p3]} type veth peer name ${NETIFS[p4]} + ip li add ${NETIFS[p5]} type veth peer name ${NETIFS[p6]} + ip li add ${NETIFS[p7]} type veth peer name ${NETIFS[p8]} + + # enslave vrf interfaces + for n in 5 7; do + ip li set ${NETIFS[p${n}]} vrf ${VRF} + done + + # add addresses + for n in 1 3 5 7; do + ip li set ${NETIFS[p${n}]} up + ip addr add ${V4ADDRS[p${n}]}/24 dev ${NETIFS[p${n}]} + ip addr add ${V6ADDRS[p${n}]}/64 dev ${NETIFS[p${n}]} + done + + # move peer interfaces to namespace and add addresses + for n in 2 4 6 8; do + ip li set ${NETIFS[p${n}]} netns ${PEER_NS} up + ip -netns ${PEER_NS} addr add ${V4ADDRS[p${n}]}/24 dev ${NETIFS[p${n}]} + ip -netns ${PEER_NS} addr add ${V6ADDRS[p${n}]}/64 dev ${NETIFS[p${n}]} + done + + set +e + + # let DAD complete - assume default of 1 probe + sleep 1 +} + +cleanup() +{ + # make sure we start from a clean slate + ip netns del ${PEER_NS} 2>/dev/null + for n in 1 3 5 7; do + ip link del ${NETIFS[p${n}]} 2>/dev/null + done + ip link del ${VRF} 2>/dev/null + ip ro flush table ${VRF_TABLE} + ip -6 ro flush table ${VRF_TABLE} +} + +################################################################################ +# IPv4 tests +# + +run_ip() +{ + local table="$1" + local prefix="$2" + local gw="$3" + local dev="$4" + local exp_rc="$5" + local desc="$6" + + # dev arg may be empty + [ -n "${dev}" ] && dev="dev ${dev}" + + run_cmd ip ro add table "${table}" "${prefix}"/32 via "${gw}" "${dev}" onlink + log_test $? ${exp_rc} "${desc}" +} + +valid_onlink_ipv4() +{ + # - unicast connected, unicast recursive + # + log_subsection "default VRF - main table" + + run_ip 254 ${TEST_NET4[1]}.1 ${CONGW[1]} ${NETIFS[p1]} 0 "unicast connected" + run_ip 254 ${TEST_NET4[1]}.2 ${RECGW4[1]} ${NETIFS[p1]} 0 "unicast recursive" + + log_subsection "VRF ${VRF}" + + run_ip ${VRF_TABLE} ${TEST_NET4[2]}.1 ${CONGW[2]} ${NETIFS[p5]} 0 "unicast connected" + run_ip ${VRF_TABLE} ${TEST_NET4[2]}.2 ${RECGW4[2]} ${NETIFS[p5]} 0 "unicast recursive" + + log_subsection "VRF device, PBR table" + + run_ip ${PBR_TABLE} ${TEST_NET4[2]}.3 ${CONGW[2]} ${NETIFS[p5]} 0 "unicast connected" + run_ip ${PBR_TABLE} ${TEST_NET4[2]}.4 ${RECGW4[2]} ${NETIFS[p5]} 0 "unicast recursive" +} + +invalid_onlink_ipv4() +{ + run_ip 254 ${TEST_NET4[1]}.11 ${V4ADDRS[p1]} ${NETIFS[p1]} 2 \ + "Invalid gw - local unicast address" + + run_ip ${VRF_TABLE} ${TEST_NET4[2]}.11 ${V4ADDRS[p5]} ${NETIFS[p5]} 2 \ + "Invalid gw - local unicast address, VRF" + + run_ip 254 ${TEST_NET4[1]}.101 ${V4ADDRS[p1]} "" 2 "No nexthop device given" + + run_ip 254 ${TEST_NET4[1]}.102 ${V4ADDRS[p3]} ${NETIFS[p1]} 2 \ + "Gateway resolves to wrong nexthop device" + + run_ip ${VRF_TABLE} ${TEST_NET4[2]}.103 ${V4ADDRS[p7]} ${NETIFS[p5]} 2 \ + "Gateway resolves to wrong nexthop device - VRF" +} + +################################################################################ +# IPv6 tests +# + +run_ip6() +{ + local table="$1" + local prefix="$2" + local gw="$3" + local dev="$4" + local exp_rc="$5" + local desc="$6" + + # dev arg may be empty + [ -n "${dev}" ] && dev="dev ${dev}" + + run_cmd ip -6 ro add table "${table}" "${prefix}"/128 via "${gw}" "${dev}" onlink + log_test $? ${exp_rc} "${desc}" +} + +valid_onlink_ipv6() +{ + # - unicast connected, unicast recursive, v4-mapped + # + log_subsection "default VRF - main table" + + run_ip6 254 ${TEST_NET6[1]}::1 ${V6ADDRS[p1]/::*}::64 ${NETIFS[p1]} 0 "unicast connected" + run_ip6 254 ${TEST_NET6[1]}::2 ${RECGW6[1]} ${NETIFS[p1]} 0 "unicast recursive" + run_ip6 254 ${TEST_NET6[1]}::3 ::ffff:${TEST_NET4IN6[1]} ${NETIFS[p1]} 0 "v4-mapped" + + log_subsection "VRF ${VRF}" + + run_ip6 ${VRF_TABLE} ${TEST_NET6[2]}::1 ${V6ADDRS[p5]/::*}::64 ${NETIFS[p5]} 0 "unicast connected" + run_ip6 ${VRF_TABLE} ${TEST_NET6[2]}::2 ${RECGW6[2]} ${NETIFS[p5]} 0 "unicast recursive" + run_ip6 ${VRF_TABLE} ${TEST_NET6[2]}::3 ::ffff:${TEST_NET4IN6[2]} ${NETIFS[p5]} 0 "v4-mapped" + + log_subsection "VRF device, PBR table" + + run_ip6 ${PBR_TABLE} ${TEST_NET6[2]}::4 ${V6ADDRS[p5]/::*}::64 ${NETIFS[p5]} 0 "unicast connected" + run_ip6 ${PBR_TABLE} ${TEST_NET6[2]}::5 ${RECGW6[2]} ${NETIFS[p5]} 0 "unicast recursive" + run_ip6 ${PBR_TABLE} ${TEST_NET6[2]}::6 ::ffff:${TEST_NET4IN6[2]} ${NETIFS[p5]} 0 "v4-mapped" +} + +invalid_onlink_ipv6() +{ + local lladdr + + lladdr=$(get_linklocal ${NETIFS[p1]}) || return 1 + + run_ip6 254 ${TEST_NET6[1]}::11 ${V6ADDRS[p1]} ${NETIFS[p1]} 2 \ + "Invalid gw - local unicast address" + run_ip6 254 ${TEST_NET6[1]}::12 ${lladdr} ${NETIFS[p1]} 2 \ + "Invalid gw - local linklocal address" + run_ip6 254 ${TEST_NET6[1]}::12 ${MCAST6} ${NETIFS[p1]} 2 \ + "Invalid gw - multicast address" + + lladdr=$(get_linklocal ${NETIFS[p5]}) || return 1 + run_ip6 ${VRF_TABLE} ${TEST_NET6[2]}::11 ${V6ADDRS[p5]} ${NETIFS[p5]} 2 \ + "Invalid gw - local unicast address, VRF" + run_ip6 ${VRF_TABLE} ${TEST_NET6[2]}::12 ${lladdr} ${NETIFS[p5]} 2 \ + "Invalid gw - local linklocal address, VRF" + run_ip6 ${VRF_TABLE} ${TEST_NET6[2]}::12 ${MCAST6} ${NETIFS[p5]} 2 \ + "Invalid gw - multicast address, VRF" + + run_ip6 254 ${TEST_NET6[1]}::101 ${V6ADDRS[p1]} "" 2 \ + "No nexthop device given" + + # default VRF validation is done against LOCAL table + # run_ip6 254 ${TEST_NET6[1]}::102 ${V6ADDRS[p3]/::[0-9]/::64} ${NETIFS[p1]} 2 \ + # "Gateway resolves to wrong nexthop device" + + run_ip6 ${VRF_TABLE} ${TEST_NET6[2]}::103 ${V6ADDRS[p7]/::[0-9]/::64} ${NETIFS[p5]} 2 \ + "Gateway resolves to wrong nexthop device - VRF" +} + +run_onlink_tests() +{ + log_section "IPv4 onlink" + log_subsection "Valid onlink commands" + valid_onlink_ipv4 + log_subsection "Invalid onlink commands" + invalid_onlink_ipv4 + + log_section "IPv6 onlink" + log_subsection "Valid onlink commands" + valid_onlink_ipv6 + invalid_onlink_ipv6 +} + +################################################################################ +# main + +nsuccess=0 +nfail=0 + +cleanup +setup +run_onlink_tests +cleanup + +if [ "$TESTS" != "none" ]; then + printf "\nTests passed: %3d\n" ${nsuccess} + printf "Tests failed: %3d\n" ${nfail} +fi
Greg Kroah-Hartman
maintainerPATCH 264/272 soc: amlogic: meson-gx-pwrc-vpu: fix error on shutdown when domain is powered off
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
[ Upstream commit 87f88732d25e6175cb4faa8070658f604660d720 ]
When operating the system headless headless, the domain is never powered on, leaving the clocks disabled. The shutdown function then tries to disable the already disabled clocks, resulting in errors. Therefore call meson_gx_pwrc_vpu_power_off() only if domain is powered on.
This patch fixes the described issue on my system (Odorid-C2).
--- drivers/soc/amlogic/meson-gx-pwrc-vpu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/soc/amlogic/meson-gx-pwrc-vpu.c +5 -1
@@ -224,7 +224,11 @@ static int meson_gx_pwrc_vpu_probe(strucstatic void meson_gx_pwrc_vpu_shutdown (struct platform_device *pdev) { -meson_gx_pwrc_vpu_power_off (&vpu_hdmi_pd.genpd); +bool powered_off; + + powered_off =meson_gx_pwrc_vpu_get_power (&vpu_hdmi_pd); +if (!powered_off) +meson_gx_pwrc_vpu_power_off (&vpu_hdmi_pd.genpd); }static const struct of_device_id meson_gx_pwrc_vpu_match_table[] = {
Greg Kroah-Hartman
maintainerPATCH 1/272 MIPS: xilfpga: Stop generating useless dtb.o
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Belloni <[email protected]>
commit a5a92abbce56c41ff121db41a33b9c0a0ff39365 upstream.
A dtb.o is generated from nexys4ddr.dts but this is never used since it has been moved to mips/generic with commit b35565bb16a5 ("MIPS: generic:
Add support for MIPSfpga").
Patchwork: https://patchwork.linux-mips.org/patch/19244/
--- arch/mips/boot/dts/xilfpga/Makefile | 2 -- 1 file changed, 2 deletions(-)
arch/mips/boot/dts/xilfpga/Makefile +0 -2
@@ -1,4 +1,2 @@ # SPDX-License-Identifier: GPL-2.0 dtb-$(CONFIG_FIT_IMAGE_FDT_XILFPGA) += nexys4ddr.dtb - -obj-y += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
Greg Kroah-Hartman
maintainerPATCH 2/272 MIPS: xilfpga: Actually include FDT in fitImage
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Belloni <[email protected]>
commit 947bc875116042d5375446aa29bc1073c2d38977 upstream.
Commit b35565bb16a5 ("MIPS: generic: Add support for MIPSfpga") added and its.S file for xilfpga but forgot to add it to arch/mips/generic/Platform so it is never used.
Patchwork: https://patchwork.linux-mips.org/patch/19245/
--- arch/mips/generic/Platform | 1 + 1 file changed, 1 insertion(+)
arch/mips/generic/Platform +1 -0
@@ -16,3 +16,4 @@ all-$(CONFIG_MIPS_GENERIC) := vmlinux.gz its-y := vmlinux.its.S its-$(CONFIG_FIT_IMAGE_FDT_BOSTON) += board-boston.its.S its-$(CONFIG_FIT_IMAGE_FDT_NI169445) += board-ni169445.its.S +its-$(CONFIG_FIT_IMAGE_FDT_XILFPGA) += board-xilfpga.its.S
Greg Kroah-Hartman
maintainerPATCH 3/272 MIPS: c-r4k: Fix data corruption related to cache coherence
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 55a2aa08b3af519a9693f99cdf7fa6d8b62d9f65 upstream.
When DMA will be performed to a MIPS32 1004K CPS, the L1-cache for the range needs to be flushed and invalidated first.
The code currently takes one of two approaches.
1/ If the range is less than the size of the dcache, then HIT type
requests flush/invalidate cache lines for the particular addresses. HIT-type requests a globalised by the CPS so this is safe on SMP.
2/ If the range is larger than the size of dcache, then INDEX type
requests flush/invalidate the whole cache. INDEX type requests affect the local cache only. CPS does not propagate them in any way. So this invalidation is not safe on SMP CPS systems.
Data corruption due to '2' can quite easily be demonstrated by repeatedly "echo 3 > /proc/sys/vm/drop_caches" and then sha1sum a file that is several times the size of available memory. Dropping caches means that large contiguous extents (large than dcache) are more likely.
This was not a problem before Linux-4.8 because option 2 was never used if CONFIG_MIPS_CPS was defined. The commit which removed that apparently didn't appreciate the full consequence of the change.
We could, in theory, globalize the INDEX based flush by sending an IPI to other cores. These cache invalidation routines can be called with interrupts disabled and synchronous IPI require interrupts to be enabled. Asynchronous IPI may not trigger writeback soon enough. So we cannot use IPI in practice.
We can already test if IPI would be needed for an INDEX operation with r4k_op_needs_ipi(R4K_INDEX). If this is true then we mustn't try the INDEX approach as we cannot use IPI. If this is false (e.g. when there is only one core and hence one L1 cache) then it is safe to use the INDEX approach without IPI.
This patch avoids options 2 if r4k_op_needs_ipi(R4K_INDEX), and so eliminates the corruption.
Patchwork: https://patchwork.linux-mips.org/patch/19259/
--- arch/mips/mm/c-r4k.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/mips/mm/c-r4k.c +6 -3
@@ -851,9 +851,12 @@ static void r4k_dma_cache_wback_inv(unsi/* * Either no secondary cache or the available caches don't have the * subset property so we have to flush the primary caches -* explicitly +* explicitly. +* If we would need IPI to perform an INDEX-type operation, then +* we have to use the HIT-type alternative as IPI cannot be used +* here due to interrupts possibly being disabled. */ -if (size >= dcache_size) { +if (!r4k_op_needs_ipi (R4K_INDEX ) && size >= dcache_size) {r4k_blast_dcache (); }else {R4600_HIT_CACHEOP_WAR_IMPL ;
@@ -890,7 +893,7 @@ static void r4k_dma_cache_inv(unsigned lreturn ; } -if (size >= dcache_size) { +if (!r4k_op_needs_ipi (R4K_INDEX ) && size >= dcache_size) {r4k_blast_dcache (); }else {R4600_HIT_CACHEOP_WAR_IMPL ;
Greg Kroah-Hartman
maintainerPATCH 4/272 MIPS: Fix build with DEBUG_ZBOOT and MACH_JZ4770
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Cercueil <[email protected]>
commit c60128ce97674fd05adb8b5ae79eb6745a03192e upstream.
The debug definitions were missing for MACH_JZ4770, resulting in a build failure when DEBUG_ZBOOT was set.
Since the UART addresses are the same across all Ingenic SoCs, we just use a #ifdef CONFIG_MACH_INGENIC instead of checking for individual Ingenic SoCs.
Additionally, I added a #define for the UART0 address in-code and dropped the <asm/mach-jz4740/base.h> include, for the reason that this include file is slowly being phased out as the whole platform is being moved to devicetree.
Patchwork: https://patchwork.linux-mips.org/patch/18957/
--- arch/mips/boot/compressed/uart-16550.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/boot/compressed/uart-16550.c +3 -3
@@ -18,9 +18,9 @@#define PORT (offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))#endif -#if defined(CONFIG_MACH_JZ4740 ) || defined(CONFIG_MACH_JZ4780 ) -#include <asm/mach-jz4740/base.h> -#define PORT (offset) (CKSEG1ADDR(JZ4740_UART0_BASE_ADDR) + (4 * offset)) +#ifdef CONFIG_MACH_INGENIC +#define INGENIC_UART0_BASE_ADDR 0x10030000 +#define PORT (offset) (CKSEG1ADDR(INGENIC_UART0_BASE_ADDR) + (4 * offset))#endif #ifdef CONFIG_CPU_XLR
Greg Kroah-Hartman
maintainerPATCH 5/272 MIPS: ptrace: Expose FIR register through FP regset
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 71e909c0cdad28a1df1fa14442929e68615dee45 upstream.
Correct commit 7aeb753b5353 ("MIPS: Implement task_user_regset_view.") and expose the FIR register using the unused 4 bytes at the end of the NT_PRFPREG regset. Without that register included clients cannot use the PTRACE_GETREGSET request to retrieve the complete FPU register set and have to resort to one of the older interfaces, either PTRACE_PEEKUSR or PTRACE_GETFPREGS, to retrieve the missing piece of data. Also the register is irreversibly missing from core dumps.
This register is architecturally hardwired and read-only so the write path does not matter. Ignore data supplied on writes then.
Patchwork: https://patchwork.linux-mips.org/patch/19273/
--- arch/mips/kernel/ptrace.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
arch/mips/kernel/ptrace.c +16 -2
@@ -463,7 +463,7 @@ static int fpr_get_msa(struct task_struc/* * Copy the floating-point context to the supplied NT_PRFPREG buffer. * Choose the appropriate helper for general registers, and then copy -* the FCSR register separately. +* the FCSR and FIR registers separately. */ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
@@ -471,6 +471,7 @@ static int fpr_get(struct task_struct *t void *kbuf, void __user *ubuf) {const int fcr31_pos =NUM_FPU_REGS *sizeof (elf_fpreg_t); +const int fir_pos = fcr31_pos +sizeof (u32);int err;if (sizeof (target->thread.fpu.fpr[0 ]) ==sizeof (elf_fpreg_t))
@@ -483,6 +484,12 @@ static int fpr_get(struct task_struct *t err =user_regset_copyout (&pos, &count, &kbuf, &ubuf, &target->thread.fpu.fcr31, fcr31_pos, fcr31_pos +sizeof (u32)); +if (err) +return err; + + err =user_regset_copyout (&pos, &count, &kbuf, &ubuf, + &boot_cpu_data.fpu_id, + fir_pos, fir_pos +sizeof (u32));return err; }
@@ -531,7 +538,8 @@ static int fpr_set_msa(struct task_struc/* * Copy the supplied NT_PRFPREG buffer to the floating-point context. * Choose the appropriate helper for general registers, and then copy -* the FCSR register separately. +* the FCSR register separately. Ignore the incoming FIR register +* contents though, as the register is read-only. * * We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', * which is supposed to have been guaranteed by the kernel before
@@ -545,6 +553,7 @@ static int fpr_set(struct task_struct *t const void *kbuf, const void __user *ubuf) { const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t); +const int fir_pos = fcr31_pos +sizeof (u32);u32 fcr31;int err;
@@ -572,6 +581,11 @@ static int fpr_set(struct task_struct *tptrace_setfcr31 (target, fcr31); } +if (count >0 ) + err =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, + fir_pos, + fir_pos +sizeof (u32)); +return err; }
Greg Kroah-Hartman
maintainerPATCH 6/272 MIPS: Fix ptrace(2) PTRACE_PEEKUSR and PTRACE_POKEUSR accesses to o32 FGRs
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 9a3a92ccfe3620743d4ae57c987dc8e9c5f88996 upstream.
Check the TIF_32BIT_FPREGS task setting of the tracee rather than the tracer in determining the layout of floating-point general registers in the floating-point context, correcting access to odd-numbered registers for o32 tracees where the setting disagrees between the two processes.
--- arch/mips/kernel/ptrace.c | 4 ++-- arch/mips/kernel/ptrace32.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/mips/kernel/ptrace.c +2 -2
@@ -807,7 +807,7 @@ long arch_ptrace(struct task_struct *chi fregs =get_fpu_regs (child);#ifdef CONFIG_32BIT -if (test_thread_flag (TIF_32BIT_FPREGS )) { +if (test_tsk_thread_flag (child,TIF_32BIT_FPREGS )) {/* * The odd registers are actually the high * order bits of the values stored in the even
@@ -902,7 +902,7 @@ long arch_ptrace(struct task_struct *chiinit_fp_ctx (child);#ifdef CONFIG_32BIT -if (test_thread_flag (TIF_32BIT_FPREGS )) { +if (test_tsk_thread_flag (child,TIF_32BIT_FPREGS )) {/* * The odd registers are actually the high * order bits of the values stored in the even
arch/mips/kernel/ptrace32.c +2 -2
@@ -99,7 +99,7 @@ long compat_arch_ptrace(struct task_strubreak ; } fregs =get_fpu_regs (child); -if (test_thread_flag (TIF_32BIT_FPREGS )) { +if (test_tsk_thread_flag (child,TIF_32BIT_FPREGS )) {/* * The odd registers are actually the high * order bits of the values stored in the even
@@ -212,7 +212,7 @@ long compat_arch_ptrace(struct task_stru sizeof(child->thread.fpu)); child->thread.fpu.fcr31 =0 ; } -if (test_thread_flag (TIF_32BIT_FPREGS )) { +if (test_tsk_thread_flag (child,TIF_32BIT_FPREGS )) {/* * The odd registers are actually the high * order bits of the values stored in the even
Greg Kroah-Hartman
maintainercover 4.16.13-stable review
This is the start of the stable review cycle for the 4.16.13 release. There are 272 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed May 30 10:01:02 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.16.13-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.16.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.16.13-rc1
Deepak Rawat <[email protected]>
drm/vmwgfx: Set dmabuf_size when vmw_dmabuf_init is successful
Randy Dunlap <[email protected]>
kdb: make "mdr" command repeat
Jan Kundrát <[email protected]>
pinctrl: mcp23s08: spi: Fix regmap debugfs entries
Bjorn Andersson <[email protected]>
pinctrl: msm: Use dynamic GPIO numbering
Christophe JAILLET <[email protected]>
regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'
Laurent Pinchart <[email protected]>
ARM: dts: porter: Fix HDMI output routing
Aapo Vienamo <[email protected]>
ARM: dts: imx7d: cl-som-imx7: fix pinctrl_enet
Filip Sadowski <[email protected]>
i40e: Add delay after EMP reset for firmware to recover
Heiner Kallweit <[email protected]>
soc: amlogic: meson-gx-pwrc-vpu: fix error on shutdown when domain is powered off
Charles Keepax <[email protected]>
regmap: Correct comparison in regmap_cached
Peter Rosin <[email protected]>
ARM: dts: at91: tse850: use the correct compatible for the eeprom
Peter Rosin <[email protected]>
ARM: dts: at91: nattis: use the correct compatible for the eeprom
David Ahern <[email protected]>
selftests: Add FIB onlink tests
Sergei Shtylyov <[email protected]>
drm: rcar-du: lvds: Fix LVDS startup on R-Car Gen2
Sergei Shtylyov <[email protected]>
drm: rcar-du: lvds: Fix LVDS startup on R-Car Gen3
Richard Haines <[email protected]>
netlabel: If PF_INET6, check sk_buff ip header version
Dhinakaran Pandiyan <[email protected]>
drm/vblank: Data type fixes for 64-bit vblank sequences.
Prashant Bhole <[email protected]>
selftests/net: fixes psock_fanout eBPF test case
Jiri Olsa <[email protected]>
perf tests: Fix dwarf unwind for stripped binaries
Jiri Olsa <[email protected]>
perf report: Fix memory corruption in --branch-history mode --branch-history
Jiri Olsa <[email protected]>
perf tests: Use arch__compare_symbol_names to compare symbols
Jin Yao <[email protected]>
perf report: Fix wrong jump arrow
Thomas Richter <[email protected]>
perf test: Fix test case inet_pton to accept inlines.
Baoquan He <[email protected]>
x86/apic: Set up through-local-APIC mode on the boot CPU if 'noapic' specified
Ørjan Eide <[email protected]>
drm/rockchip: Respect page offset for PRIME mmap calls
Sergei Shtylyov <[email protected]>
soc: renesas: r8a77970-sysc: fix power area parents
Joe Perches <[email protected]>
MIPS: Octeon: Fix logging messages with spurious periods after newlines
Jake Moroni <[email protected]>
dpaa_eth: fix pause capability advertisement logic
Tao <[email protected]>
drm/amd/display: Set vsc pack revision when DPCD revision is >= 1.2
Archit Taneja <[email protected]>
dt-bindings: display: msm/dsi: Fix the PHY regulator supply props
Takeshi Kihara <[email protected]>
pinctrl: sh-pfc: r8a7796: Fix MOD_SEL register pin assignment for SSI pins group
Tejun Heo <[email protected]>
rcu: Call touch_nmi_watchdog() while printing stall warnings
Niklas Cassel <[email protected]>
net: stmmac: call correct function in stmmac_mac_config_rx_queues_routing()
Richard Guy Briggs <[email protected]>
audit: return on memory error to avoid null pointer dereference
Stefan Wahren <[email protected]>
hwrng: bcm2835 - Handle deferred clock properly
Rafael J. Wysocki <[email protected]>
PCMCIA / PM: Avoid noirq suspend aborts during suspend-to-idle
Henry Zhang <[email protected]>
ARM: dts: bcm283x: Fix pin function of JTAG pins
Stefan Wahren <[email protected]>
ARM: dts: bcm283x: Fix probing of bcm2835-i2s
Ladislav Michl <[email protected]>
power: supply: ltc2941-battery-gauge: Fix temperature units
Sergei Shtylyov <[email protected]>
sh_eth: fix TSU init on SH7734/R8A7740
Jacob Keller <[email protected]>
ixgbe: prevent ptp_rx_hang from running when in FILTER_ALL mode
Jan Kara <[email protected]>
fanotify: Avoid lost events due to ENOMEM for unlimited queues
Jan Kara <[email protected]>
udf: Provide saner default for invalid uid / gid
Thomas Vincent-Cross <[email protected]>
PCI: Add function 1 DMA alias quirk for Marvell 88SE9220
Madalin Bucur <[email protected]>
dpaa_eth: fix SG mapping
Viresh Kumar <[email protected]>
cpufreq: Reorder cpufreq_online() error code path
Niklas Cassel <[email protected]>
net: stmmac: ensure that the MSS desc is the last desc to set the own bit
Niklas Cassel <[email protected]>
net: stmmac: ensure that the device has released ownership before reading data
Thomas Falcon <[email protected]>
ibmvnic: Allocate statistics buffers during probe
Monk Liu <[email protected]>
drm/amdgpu: adjust timeout for ib_ring_tests(v2)
Monk Liu <[email protected]>
drm/amdgpu: disable GFX ring and disable PQ wptr in hw_fini
Ravikumar Kattekola <[email protected]>
ARM: dts: dra71-evm: Correct evm_sd regulator max voltage
Laurent Pinchart <[email protected]>
drm: omapdrm: dss: Move initialization code from component bind to probe
Srinivas Kandagatla <[email protected]>
dmaengine: qcom: bam_dma: get num-channels and num-ees from dt
Cornelia Huck <[email protected]>
vfio-ccw: fence off transport mode
Niklas Cassel <[email protected]>
pinctrl: artpec6: dt: add missing pin group uart5nocts
Richard Fitzgerald <[email protected]>
pinctrl: devicetree: Fix dt_to_map_one_config handling of hogs
[email protected] <[email protected]>
hwrng: stm32 - add reset during probe
Alexey Khoroshilov <[email protected]>
watchdog: asm9260_wdt: fix error handling in asm9260_wdt_probe()
Govindarajulu Varadarajan <[email protected]>
enic: enable rq before updating rq descriptors
Yoshihiro Shimoda <[email protected]>
dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
Christophe Leroy <[email protected]>
powerpc/mm/slice: Fix hugepage allocation at hint address on 8xx
Christophe Leroy <[email protected]>
powerpc/mm/slice: Enhance for supporting PPC32
Christophe Leroy <[email protected]>
powerpc/mm/slice: create header files dedicated to slices
Christophe Leroy <[email protected]>
powerpc/mm/slice: Remove intermediate bitmap copy
Suman Anna <[email protected]>
ARM: dts: keystone-k2e-clocks: Fix missing unit address separator
Qi Hou <[email protected]>
dmaengine: pl330: fix a race condition in case of threaded irqs
Ming Lei <[email protected]>
block: null_blk: fix 'Invalid parameters' when loading module
Dexuan Cui <[email protected]>
tools: hv: fix compiler warnings about major/target_fname
Emily Deng <[email protected]>
drm/amdgpu: Clean sdma wptr register when only enable wptr polling
Linus Walleij <[email protected]>
drm/bridge: sii902x: Retry status read after DDI I2C
Vivek Gautam <[email protected]>
phy: qcom-qmp: Fix phy pipe clock gating
Takashi Iwai <[email protected]>
ALSA: vmaster: Propagate slave error
Shawn Lin <[email protected]>
phy: rockchip-emmc: retry calpad busy trimming
Ivan Gorinov <[email protected]>
x86/devicetree: Fix device IRQ settings in DT
Ivan Gorinov <[email protected]>
x86/devicetree: Initialize device tree before using it
Andreas Gruenbacher <[email protected]>
gfs2: Fix fallocate chunk size
Bjorn Andersson <[email protected]>
soc: qcom: wcnss_ctrl: Fix increment in NV upload
Ilia Lin <[email protected]>
arm64: dts: qcom: Fix SPI5 config on MSM8996
Kan Liang <[email protected]>
perf/x86/intel: Fix event update for auto-reload
Kan Liang <[email protected]>
perf/x86/intel: Fix large period handling on Broadwell CPUs
Mark Rutland <[email protected]>
efi/arm*: Only register page tables when they exist
Maurizio Lombardi <[email protected]>
cdrom: do not call check_disk_change() inside cdrom_open()
Kan Liang <[email protected]>
perf/x86/intel: Properly save/restore the PMU state in the NMI handler
Guenter Roeck <[email protected]>
hwmon: (pmbus/adm1275) Accept negative page register values
Guenter Roeck <[email protected]>
hwmon: (pmbus/max8688) Accept negative page register values
Eric Anholt <[email protected]>
drm/panel: simple: Fix the bus format for the Ontat panel
Peter Zijlstra <[email protected]>
perf/core: Fix perf_output_read_group()
Pierre Bourdon <[email protected]>
max17042: propagate of_node to power supply device
leilei.lin <[email protected]>
perf/core: Fix installing cgroup events on CPU
Chao Yu <[email protected]>
f2fs: fix to check extent cache in f2fs_drop_extent_tree
Chao Yu <[email protected]>
f2fs: fix to clear CP_TRIMMED_FLAG
Chao Yu <[email protected]>
f2fs: fix to set KEEP_SIZE bit in f2fs_zero_range
Vaibhav Jain <[email protected]>
cxl: Check if PSL data-cache is available before issue flush request
Gao Xiang <[email protected]>
f2fs: flush cp pack except cp pack 2 page at first
Alistair Popple <[email protected]>
powerpc/powernv/npu: Fix deadlock in mmio_invalidate()
Mathieu Malaterre <[email protected]>
powerpc: Add missing prototype for arch_irq_work_raise()
Christophe JAILLET <[email protected]>
drm/meson: Fix an un-handled error path in 'meson_drv_bind_master()'
Christophe JAILLET <[email protected]>
drm/meson: Fix some error handling paths in 'meson_drv_bind_master()'
Kamlakant Patel <[email protected]>
ipmi_ssif: Fix kernel panic at msg_done_handler
Milton Miller <[email protected]>
watchdog: aspeed: Fix translation of reset mode to ctrl register
Brian Norris <[email protected]>
watchdog: dw: RMW the control register
Alexey Khoroshilov <[email protected]>
watchdog: sprd_wdt: Fix error handling in sprd_wdt_enable()
Rafael J. Wysocki <[email protected]>
PCI: Restore config space on runtime resume despite being unbound
Sukadev Bhattiprolu <[email protected]>
powerpc/vas: Fix cleanup when VAS is not configured
Mathias Kresin <[email protected]>
MIPS: ath79: Fix AR724X_PLL_REG_PCIE_CONFIG offset
Ursula Braun <[email protected]>
net/smc: pay attention to MAX_ORDER for CQ entries
Christophe Jaillet <[email protected]>
spi: bcm-qspi: fIX some error handling paths
Christophe Jaillet <[email protected]>
regulator: gpio: Fix some error handling paths in 'gpio_regulator_probe()'
John Allen <[email protected]>
ibmvnic: Fix reset return from closed state
Leo Yan <[email protected]>
coresight: Use %px to print pcsr instead of %p
Oded Gabbay <[email protected]>
drm/amdkfd: add missing include of mm.h
Parav Pandit <[email protected]>
IB/core: Honor port_num while resolving GID for IB link layer
Thomas Richter <[email protected]>
perf stat: Fix core dump when flag T is used
Yisheng Xie <[email protected]>
perf top: Fix top.call-graph config option reading
Vitaly Kuznetsov <[email protected]>
KVM: lapic: stop advertising DIRECTED_EOI when in-kernel IOAPIC is in use
Gregory CLEMENT <[email protected]>
i2c: mv64xxx: Apply errata delay only in standard mode
Arjun Vynipadath <[email protected]>
cxgb4: Fix queue free path of ULD drivers
Seunghun Han <[email protected]>
ACPICA: acpi: acpica: fix acpi operand cache leak in nseval.c
Coly Li <[email protected]>
bcache: stop dc->writeback_rate_update properly
Bob Moore <[email protected]>
ACPICA: Fix memory leak on unusual memory leak
Erik Schmauss <[email protected]>
ACPICA: Events: add a return on failure from acpi_hw_register_read
Coly Li <[email protected]>
bcache: fix cached_dev->count usage for bch_cache_set_error()
Icenowy Zheng <[email protected]>
dt-bindings: add device tree binding for Allwinner H6 main CCU
Christophe JAILLET <[email protected]>
remoteproc: imx_rproc: Fix an error handling path in 'imx_rproc_probe()'
Coly Li <[email protected]>
bcache: quit dc->writeback_thread when BCACHE_DEV_DETACHING is set
Michael Schmitz <[email protected]>
zorro: Set up z->dev.dma_mask for the DMA API
Honggang Li <[email protected]>
IB/mlx5: Set the default active rate and width to QDR and 4X
Luis R. Rodriguez <[email protected]>
firmware: fix checking for return values for fw_add_devm_name()
Chunyu Hu <[email protected]>
cpufreq: cppc_cpufreq: Fix cppc_cpufreq_init() failure path
Yong Wu <[email protected]>
iommu/mediatek: Fix protect memory setting
Thomas Hellstrom <[email protected]>
drm/vmwgfx: Unpin the screen object backup buffer when not used
Eric Sandeen <[email protected]>
ext4: don't complain about incorrect features when probing
Mimi Zohar <[email protected]>
ima: clear IMA_HASH
Philipp Puschmann <[email protected]>
arm: dts: socfpga: fix GIC PPI warning
Jay Vosburgh <[email protected]>
virtio-net: Fix operstate for virtio when no VIRTIO_NET_F_STATUS
Andreas Gruenbacher <[email protected]>
gfs2: Check for the end of metadata in punch_hole
Milton Miller <[email protected]>
watchdog: aspeed: Allow configuring for alternate boot
Petr Vorel <[email protected]>
ima: Fallback to the builtin hash algorithm
Jiandi An <[email protected]>
ima: Fix Kconfig to select TPM 2.0 CRB interface
Haiyang Zhang <[email protected]>
hv_netvsc: Fix the return status in RX path
Arjun Vynipadath <[email protected]>
cxgb4: Setup FW queues before registering netdev
Anand Jain <[email protected]>
btrfs: fix null pointer deref when target device is missing
Sebastian Gottschall <[email protected]>
ath9k: fix crash in spectral scan
Jarosław Janik <[email protected]>
nvme-pci: disable APST for Samsung NVMe SSD 960 EVO + ASUS PRIME Z370-A
James Smart <[email protected]>
nvme_fc: fix abort race on teardown with lld reject
Karthikeyan Periyasamy <[email protected]>
ath10k: Fix kernel panic while using worker (ath10k_sta_rc_update_wk)
Colin Ian King <[email protected]>
net: qualcomm: rmnet: check for null ep to avoid null pointer dereference
Fuyun Liang <[email protected]>
net: hns3: fix for returning wrong value problem in hns3_get_rss_key_size
Fuyun Liang <[email protected]>
net: hns3: fix for returning wrong value problem in hns3_get_rss_indir_size
Fuyun Liang <[email protected]>
net: hns3: fix for the wrong shift problem in hns3_set_txbd_baseinfo
Alexey Khoroshilov <[email protected]>
watchdog: davinci_wdt: fix error handling in davinci_wdt_probe()
Leon Romanovsky <[email protected]>
net/mlx5: Protect from command bit overflow
Jacob Keller <[email protected]>
i40e: hold the RTNL lock while changing interrupt schemes
Michael Ellerman <[email protected]>
selftests: Print the test we're running to /dev/kmsg
Frank Asseg <[email protected]>
tools/thermal: tmon: fix for segfault
Amitkumar Karwar <[email protected]>
rsi: fix kernel panic observed on 64bit machine
Michael Ellerman <[email protected]>
powerpc/perf: Fix kernel address leak via sampling registers
Madhavan Srinivasan <[email protected]>
powerpc/perf: Prevent kernel address leak to userspace via BHRB buffer
Lorenzo Bianconi <[email protected]>
mt76x2: fix warning in ieee80211_get_key_rx_seq()
Lorenzo Bianconi <[email protected]>
mt76x2: fix possible NULL pointer dereferencing in mt76x2_tx()
Guenter Roeck <[email protected]>
hwmon: (nct6775) Fix writing pwmX_mode
Kan Liang <[email protected]>
perf mmap: Fix accessing unmapped mmap in perf_mmap__read_done()
Helge Deller <[email protected]>
parisc/pci: Switch LBA PCI bus from Hard Fail to Soft Fail mode
Eran Ben Elisha <[email protected]>
net/mlx5e: Move all TX timeout logic to be under state lock
Sara Sharon <[email protected]>
iwlwifi: mvm: take RCU lock before dereferencing
Luca Coelho <[email protected]>
iwlwifi: mvm: check if mac80211_queue is valid in iwl_mvm_disable_txq
Greg Ungerer <[email protected]>
m68k: set dma and coherent masks for platform FEC ethernets
Alexander Shishkin <[email protected]>
intel_th: Use correct method of finding hub
Sebastian Andrzej Siewior <[email protected]>
iommu/amd: Take into account that alloc_dev_data() may return NULL
Anilkumar Kolli <[email protected]>
ath10k: advertize beacon_int_min_gcd
Harry Morris <[email protected]>
ieee802154: ca8210: fix uninitialised data read
Michael Ellerman <[email protected]>
powerpc/mpic: Check if cpu_possible() in mpic_physmask()
Lenny Szubowicz <[email protected]>
ACPI: acpi_pad: Fix memory leak in power saving threads
Aaro Koskinen <[email protected]>
drivers: macintosh: rack-meter: really fix bogus memsets
Dan Carpenter <[email protected]>
xen/acpi: off by one in read_acpi_id()
David Howells <[email protected]>
rxrpc: Don't treat call aborts as conn aborts
David Howells <[email protected]>
rxrpc: Fix Tx ring annotation after initial Tx failure
Marc Dionne <[email protected]>
rxrpc: Fix resend event time calculation
Qu Wenruo <[email protected]>
btrfs: qgroup: Fix root item corruption when multiple same source snapshots are created with quota enabled
Jeff Mahoney <[email protected]>
btrfs: fix lockdep splat in btrfs_alloc_subvolume_writers
Filipe Manana <[email protected]>
Btrfs: fix copy_items() return value when logging an inode
Qu Wenruo <[email protected]>
btrfs: tests/qgroup: Fix wrong tree backref level
Nicholas Piggin <[email protected]>
powerpc/64s: sreset panic if there is no debugger or crash dump handlers
Scott Branden <[email protected]>
bnxt_en: fix clear flags in ethtool reset handling
Florian Fainelli <[email protected]>
net: bgmac: Correctly annotate register space
Florian Fainelli <[email protected]>
net: bgmac: Fix endian access in bgmac_dma_tx_ring_free()
Dan Carpenter <[email protected]>
platform/x86: dell-smbios: Fix memory leaks in build_tokens_sysfs()
Andrea Parri <[email protected]>
riscv/spinlock: Strengthen implementations with fences
David S. Miller <[email protected]>
sparc64: Make atomic_xchg() an inline function rather than a macro.
Geert Uytterhoeven <[email protected]>
dmaengine: rcar-dmac: Fix too early/late system suspend/resume callbacks
David Howells <[email protected]>
fscache: Fix hanging wait on page discarded by writeback
Alexander Graf <[email protected]>
lan78xx: Connect phy early
Sean Christopherson <[email protected]>
KVM: VMX: raise internal error for exception during invalid protected mode state
Sai Praneeth <[email protected]>
x86/mm: Fix bogus warning during EFI bootup, use boot_cpu_has() instead of this_cpu_has() in build_cr3_noflush()
Davidlohr Bueso <[email protected]>
sched/rt: Fix rq->clock_update_flags < RQCF_ACT_SKIP warning
Nicholas Piggin <[email protected]>
powerpc/64s/idle: Fix restore of AMOR on POWER9 after deep sleep
Jun Piao <[email protected]>
ocfs2/dlm: don't handle migrate lockres if already in shutdown
Mikhail Malygin <[email protected]>
IB/rxe: Fix for oops in rxe_register_device on ppc64le arch
Nikolay Borisov <[email protected]>
btrfs: Fix possible softlock on single core machines
Liu Bo <[email protected]>
Btrfs: fix NULL pointer dereference in log_dir_items
Liu Bo <[email protected]>
Btrfs: bail out on error during replay_dir_deletes
Yang Shi <[email protected]>
mm: thp: fix potential clearing to referenced flag in page_idle_clear_pte_refs_one()
Huang Ying <[email protected]>
mm: fix races between address_space dereference and free in page_evicatable
Claudio Imbrenda <[email protected]>
mm/ksm: fix interaction with THP
Thomas Gleixner <[email protected]>
genirq/affinity: Don't return with empty affinity masks on error
Thomas Falcon <[email protected]>
ibmvnic: Zero used TX descriptor counter on reset
Esben Haabendal <[email protected]>
dp83640: Ensure against premature access to PHY registers after reset
Sandipan Das <[email protected]>
perf clang: Add support for recent clang versions
Sandipan Das <[email protected]>
perf tools: Fix perf builds with clang support
Anshuman Khandual <[email protected]>
powerpc/fscr: Enable interrupts earlier before calling get_user()
Shunyong Yang <[email protected]>
cpufreq: CPPC: Initialize shared perf capabilities of CPUs
Carlos Maiolino <[email protected]>
Force log to disk before reading the AGF during a fstrim
Jens Axboe <[email protected]>
sr: get/drop reference to device in revalidate and check_events
Xidong Wang <[email protected]>
z3fold: fix memory leak
Tom Abraham <[email protected]>
swap: divide-by-zero when zero length swap file on ssd
Andrey Konovalov <[email protected]>
kasan, slub: fix handling of kasan_slab_free hook
Andrey Konovalov <[email protected]>
kasan: fix invalid-free test crashing the kernel
Danilo Krummrich <[email protected]>
fs/proc/proc_sysctl.c: fix potential page fault while unregistering sysctl table
James Smart <[email protected]>
nvme: expand nvmf_check_if_ready checks
Sriharsha Basavapatna <[email protected]>
bnxt_en: Ignore src port field in decap filter nodes
Dave Hansen <[email protected]>
x86/mm: Do not forbid _PAGE_RW before init for __ro_after_init
Joerg Roedel <[email protected]>
x86/pgtable: Don't set huge PUD/PMD on non-leaf entries
Filipe Manana <[email protected]>
Btrfs: fix loss of prealloc extents past i_size after fsync log replay
Liu Bo <[email protected]>
Btrfs: clean up resources during umount after trans is aborted
Johannes Thumshirn <[email protected]>
nvme: don't send keep-alives to the discovery controller
Jean Delvare <[email protected]>
firmware: dmi_scan: Fix UUID length safety check
Rich Felker <[email protected]>
sh: fix debug trap failure to process signals before return to user
Pascal Roeleven <[email protected]>
ARM: dts: sun4i: Fix incorrect clocks for displays
David Vrabel <[email protected]>
x86/kvm: fix LAPIC timer drift when guest uses periodic mode
Jim Mattson <[email protected]>
kvm: x86: IA32_ARCH_CAPABILITIES is always supported
Wei Huang <[email protected]>
KVM: x86: Update cpuid properly when CR4.OSXAVE or CR4.PKE is changed
David Hildenbrand <[email protected]>
KVM: s390: vsie: fix < 8k check for the itdba
Konrad Rzeszutek Wilk <[email protected]>
KVM/VMX: Expose SSBD properly to guests
Rafael J. Wysocki <[email protected]>
PM / core: Fix direct_complete handling for devices with no callbacks
Gustavo A. R. Silva <[email protected]>
kernel/sys.c: fix potential Spectre v1 issue
David Hildenbrand <[email protected]>
kasan: fix memory hotplug during boot
David Hildenbrand <[email protected]>
kasan: free allocated shadow memory on MEM_CANCEL_ONLINE
Andrey Ryabinin <[email protected]>
mm/kasan: don't vfree() nonexistent vm_area
Davidlohr Bueso <[email protected]>
ipc/shm: fix shmat() nil address after round-down when remapping
Davidlohr Bueso <[email protected]>
Revert "ipc/shm: Fix shmat mmap nil-page protection"
Matthew Wilcox <[email protected]>
idr: fix invalid ptr dereference on item delete
Rafał Miłecki <[email protected]>
bcma: fix buffer size caused crash in bcma_core_mips_print_irq()
Jens Axboe <[email protected]>
sr: pass down correctly sized SCSI sense buffer
Lidong Chen <[email protected]>
IB/umem: Use the correct mm during ib_umem_release
Michael J. Ruhl <[email protected]>
IB/hfi1: Use after free race condition in send context error path
Michael Neuling <[email protected]>
powerpc/64s: Clear PCR on boot
Jason A. Donenfeld <[email protected]>
arm64: export tishift functions to modules
Will Deacon <[email protected]>
arm64: lse: Add early clobbers to some input/output asm operands
Thomas Hellstrom <[email protected]>
drm/vmwgfx: Fix 32-bit VMW_PORT_HB_[IN|OUT] macros
Joe Jin <[email protected]>
xen-swiotlb: fix the check condition for xen_swiotlb_free_coherent
Sudip Mukherjee <[email protected]>
libata: blacklist Micron 500IT SSD with MU01 firmware
Tejun Heo <[email protected]>
libata: Blacklist some Sandisk SSDs for NCQ
Mika Westerberg <[email protected]>
ahci: Add PCI ID for Cannon Lake PCH-LP AHCI
Corneliu Doban <[email protected]>
mmc: sdhci-iproc: add SDHCI_QUIRK2_HOST_OFF_CARD_ON for cygnus
Corneliu Doban <[email protected]>
mmc: sdhci-iproc: fix 32bit writes for TRANSFER_MODE register
Srinath Mannam <[email protected]>
mmc: sdhci-iproc: remove hard coded mmc cap 1.8v
Mathieu Malaterre <[email protected]>
mmc: block: propagate correct returned value in mmc_rpmb_ioctl
Al Viro <[email protected]>
do d_instantiate/unlock_new_inode combinations safely
Ben Hutchings <[email protected]>
ALSA: timer: Fix pause event notification
Omar Sandoval <[email protected]>
Btrfs: fix error handling in btrfs_truncate()
Al Viro <[email protected]>
aio: fix io_destroy(2) vs. lookup_ioctx() race
Dave Chinner <[email protected]>
fs: don't scan the inode cache before SB_BORN is set
Al Viro <[email protected]>
fix breakage caused by d_find_alias() semantics change
Al Viro <[email protected]>
affs_lookup(): close a race with affs_remove_link()
Colin Ian King <[email protected]>
KVM: Fix spelling mistake: "cop_unsuable" -> "cop_unusable"
Maciej W. Rozycki <[email protected]>
MIPS: Fix ptrace(2) PTRACE_PEEKUSR and PTRACE_POKEUSR accesses to o32 FGRs
Maciej W. Rozycki <[email protected]>
MIPS: ptrace: Expose FIR register through FP regset
Paul Cercueil <[email protected]>
MIPS: Fix build with DEBUG_ZBOOT and MACH_JZ4770
NeilBrown <[email protected]>
MIPS: c-r4k: Fix data corruption related to cache coherence
Alexandre Belloni <[email protected]>
MIPS: xilfpga: Actually include FDT in fitImage
Alexandre Belloni <[email protected]>
MIPS: xilfpga: Stop generating useless dtb.o
-------------
Diffstat:
.../devicetree/bindings/clock/sunxi-ccu.txt | 4 + .../devicetree/bindings/display/msm/dsi.txt | 4 + .../bindings/pinctrl/axis,artpec6-pinctrl.txt | 5 +- Makefile | 4 +- arch/arm/boot/dts/at91-nattis-2-natte-2.dts | 2 +- arch/arm/boot/dts/at91-tse850-3.dts | 2 +- arch/arm/boot/dts/bcm283x.dtsi | 6 +- arch/arm/boot/dts/dra71-evm.dts | 4 +- arch/arm/boot/dts/imx7d-cl-som-imx7.dts | 52 +-- arch/arm/boot/dts/keystone-k2e-clocks.dtsi | 2 +- arch/arm/boot/dts/r8a7791-porter.dts | 2 +- arch/arm/boot/dts/socfpga.dtsi | 2 +- arch/arm/boot/dts/sun4i-a10.dtsi | 6 +- arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 +- arch/arm64/include/asm/atomic_lse.h | 24 +- arch/arm64/kernel/arm64ksyms.c | 8 + arch/arm64/lib/tishift.S | 15 +- arch/m68k/coldfire/device.c | 12 +- arch/mips/boot/compressed/uart-16550.c | 6 +- arch/mips/boot/dts/xilfpga/Makefile | 2 - arch/mips/cavium-octeon/octeon-irq.c | 10 +- arch/mips/generic/Platform | 1 + arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 2 +- arch/mips/kernel/ptrace.c | 22 +- arch/mips/kernel/ptrace32.c | 4 +- arch/mips/kvm/mips.c | 2 +- arch/mips/mm/c-r4k.c | 9 +- arch/powerpc/include/asm/book3s/64/slice.h | 27 ++ arch/powerpc/include/asm/irq_work.h | 1 + arch/powerpc/include/asm/mmu-8xx.h | 6 + arch/powerpc/include/asm/nohash/32/slice.h | 18 + arch/powerpc/include/asm/nohash/64/slice.h | 12 + arch/powerpc/include/asm/page.h | 1 + arch/powerpc/include/asm/page_64.h | 59 ---- arch/powerpc/include/asm/slice.h | 42 +++ arch/powerpc/kernel/cpu_setup_power.S | 6 + arch/powerpc/kernel/dt_cpu_ftrs.c | 1 + arch/powerpc/kernel/idle_book3s.S | 2 + arch/powerpc/kernel/setup-common.c | 2 + arch/powerpc/kernel/traps.c | 47 ++- arch/powerpc/mm/8xx_mmu.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 + arch/powerpc/mm/mmu_context_nohash.c | 18 +- arch/powerpc/mm/slice.c | 49 ++- arch/powerpc/perf/core-book3s.c | 25 ++ arch/powerpc/platforms/Kconfig.cputype | 1 + arch/powerpc/platforms/powernv/npu-dma.c | 229 ++++++++----- arch/powerpc/platforms/powernv/vas-debug.c | 11 + arch/powerpc/platforms/powernv/vas.c | 6 +- arch/powerpc/sysdev/mpic.c | 2 +- arch/riscv/include/asm/fence.h | 12 + arch/riscv/include/asm/spinlock.h | 29 +- arch/s390/kvm/vsie.c | 2 +- arch/sh/kernel/entry-common.S | 2 +- arch/sparc/include/asm/atomic_64.h | 6 +- arch/x86/events/core.c | 15 +- arch/x86/events/intel/core.c | 12 +- arch/x86/events/intel/ds.c | 92 ++++- arch/x86/events/perf_event.h | 2 +- arch/x86/include/asm/tlbflush.h | 7 +- arch/x86/kernel/apic/apic.c | 2 +- arch/x86/kernel/devicetree.c | 21 +- arch/x86/kvm/cpuid.c | 9 +- arch/x86/kvm/lapic.c | 26 +- arch/x86/kvm/vmx.c | 20 +- arch/x86/kvm/x86.c | 5 +- arch/x86/mm/pageattr.c | 6 +- arch/x86/mm/pgtable.c | 9 + drivers/acpi/acpi_pad.c | 3 + drivers/acpi/acpica/evevent.c | 9 +- drivers/acpi/acpica/nseval.c | 8 + drivers/acpi/acpica/psargs.c | 4 + drivers/ata/ahci.c | 1 + drivers/ata/libata-core.c | 6 + drivers/base/firmware_class.c | 12 +- drivers/base/power/main.c | 7 +- drivers/base/regmap/regmap.c | 2 +- drivers/bcma/driver_mips.c | 2 +- drivers/block/null_blk.c | 46 +-- drivers/block/paride/pcd.c | 2 + drivers/cdrom/cdrom.c | 3 - drivers/cdrom/gdrom.c | 3 + drivers/char/hw_random/bcm2835-rng.c | 2 + drivers/char/hw_random/stm32-rng.c | 9 + drivers/char/ipmi/ipmi_ssif.c | 4 +- drivers/cpufreq/cppc_cpufreq.c | 23 +- drivers/cpufreq/cpufreq.c | 6 +- drivers/dma/pl330.c | 6 +- drivers/dma/qcom/bam_dma.c | 27 +- drivers/dma/sh/rcar-dmac.c | 13 +- drivers/firmware/dmi_scan.c | 2 +- drivers/firmware/efi/arm-runtime.c | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 33 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 8 +- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 7 +- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 4 +- drivers/gpu/drm/bridge/sii902x.c | 20 +- drivers/gpu/drm/drm_vblank.c | 8 +- drivers/gpu/drm/meson/meson_drv.c | 29 +- drivers/gpu/drm/omapdrm/dss/dss.c | 193 ++++++----- drivers/gpu/drm/panel/panel-simple.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 18 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 7 +- drivers/gpu/drm/vmwgfx/vmwgfx_msg.h | 25 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 31 +- drivers/hwmon/nct6775.c | 10 +- drivers/hwmon/pmbus/adm1275.c | 4 +- drivers/hwmon/pmbus/max8688.c | 2 +- drivers/hwtracing/coresight/coresight-cpu-debug.c | 2 +- drivers/hwtracing/intel_th/core.c | 2 +- drivers/i2c/busses/i2c-mv64xxx.c | 8 +- drivers/ide/ide-cd.c | 2 + drivers/infiniband/core/multicast.c | 26 +- drivers/infiniband/core/umem.c | 7 +- drivers/infiniband/hw/hfi1/chip.c | 4 + drivers/infiniband/hw/mlx5/main.c | 3 + drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +- drivers/iommu/amd_iommu.c | 2 + drivers/iommu/mtk_iommu.c | 15 +- drivers/iommu/mtk_iommu.h | 1 + drivers/macintosh/rack-meter.c | 4 +- drivers/md/bcache/bcache.h | 9 +- drivers/md/bcache/super.c | 39 ++- drivers/md/bcache/sysfs.c | 3 +- drivers/md/bcache/writeback.c | 60 +++- drivers/md/bcache/writeback.h | 2 - drivers/misc/cxl/cxl.h | 4 + drivers/misc/cxl/native.c | 11 +- drivers/misc/cxl/pci.c | 19 +- drivers/mmc/core/block.c | 2 +- drivers/mmc/host/sdhci-iproc.c | 33 +- drivers/net/ethernet/broadcom/bgmac.c | 3 +- drivers/net/ethernet/broadcom/bgmac.h | 6 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 8 +- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 4 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 11 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 1 + drivers/net/ethernet/cisco/enic/enic_main.c | 10 +- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 23 +- drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 4 +- drivers/net/ethernet/ibm/ibmvnic.c | 30 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 30 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 61 ++-- drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 2 + drivers/net/ethernet/renesas/sh_eth.c | 6 +- drivers/net/ethernet/renesas/sh_eth.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +- drivers/net/hyperv/netvsc.c | 8 +- drivers/net/hyperv/netvsc_drv.c | 2 +- drivers/net/hyperv/rndis_filter.c | 4 +- drivers/net/ieee802154/ca8210.c | 14 +- drivers/net/phy/dp83640.c | 18 + drivers/net/usb/lan78xx.c | 34 +- drivers/net/virtio_net.c | 2 +- drivers/net/wireless/ath/ath10k/mac.c | 12 + drivers/net/wireless/ath/ath9k/common-spectral.c | 12 +- drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c | 6 +- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 11 +- drivers/net/wireless/mediatek/mt76/mt76x2_main.c | 11 + drivers/net/wireless/mediatek/mt76/mt76x2_tx.c | 5 +- drivers/net/wireless/rsi/rsi_91x_sdio.c | 32 +- drivers/net/wireless/rsi/rsi_sdio.h | 2 + drivers/nvme/host/core.c | 17 +- drivers/nvme/host/fabrics.c | 83 ++++- drivers/nvme/host/fabrics.h | 33 +- drivers/nvme/host/fc.c | 17 +- drivers/nvme/host/nvme.h | 1 + drivers/nvme/host/pci.c | 7 +- drivers/nvme/host/rdma.c | 14 +- drivers/nvme/target/loop.c | 11 +- drivers/parisc/lba_pci.c | 20 +- drivers/pci/pci-driver.c | 17 +- drivers/pci/quirks.c | 3 + drivers/pcmcia/cs.c | 10 +- drivers/pcmcia/cs_internal.h | 1 + drivers/phy/qualcomm/phy-qcom-qmp.c | 4 +- drivers/phy/rockchip/phy-rockchip-emmc.c | 27 +- drivers/pinctrl/devicetree.c | 6 +- drivers/pinctrl/pinctrl-mcp23s08.c | 37 +- drivers/pinctrl/qcom/pinctrl-msm.c | 2 +- drivers/pinctrl/sh-pfc/pfc-r8a7796.c | 40 +-- drivers/platform/x86/dell-smbios-base.c | 4 +- drivers/power/supply/ltc2941-battery-gauge.c | 8 +- drivers/power/supply/max17042_battery.c | 1 + drivers/regulator/gpio-regulator.c | 16 +- drivers/regulator/of_regulator.c | 1 + drivers/remoteproc/imx_rproc.c | 6 +- drivers/s390/cio/vfio_ccw_fsm.c | 5 + drivers/scsi/sr.c | 21 +- drivers/scsi/sr_ioctl.c | 10 +- drivers/soc/amlogic/meson-gx-pwrc-vpu.c | 6 +- drivers/soc/qcom/wcnss_ctrl.c | 2 +- drivers/soc/renesas/r8a77970-sysc.c | 12 +- drivers/spi/spi-bcm-qspi.c | 4 +- drivers/watchdog/asm9260_wdt.c | 8 +- drivers/watchdog/aspeed_wdt.c | 13 +- drivers/watchdog/davinci_wdt.c | 15 +- drivers/watchdog/dw_wdt.c | 23 +- drivers/watchdog/sprd_wdt.c | 4 +- drivers/xen/swiotlb-xen.c | 2 +- drivers/xen/xen-acpi-processor.c | 6 +- drivers/zorro/zorro.c | 12 + fs/affs/namei.c | 10 +- fs/aio.c | 4 +- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/disk-io.c | 5 +- fs/btrfs/extent-tree.c | 1 + fs/btrfs/inode.c | 19 +- fs/btrfs/tests/qgroup-tests.c | 2 +- fs/btrfs/transaction.c | 10 +- fs/btrfs/tree-log.c | 75 ++++- fs/dcache.c | 22 ++ fs/ecryptfs/inode.c | 3 +- fs/ext2/namei.c | 6 +- fs/ext4/namei.c | 6 +- fs/ext4/super.c | 12 + fs/f2fs/checkpoint.c | 71 ++-- fs/f2fs/extent_cache.c | 3 + fs/f2fs/file.c | 8 +- fs/f2fs/namei.c | 12 +- fs/fscache/page.c | 13 +- fs/gfs2/bmap.c | 10 +- fs/gfs2/file.c | 5 +- fs/gfs2/quota.h | 2 + fs/jffs2/dir.c | 12 +- fs/jfs/namei.c | 12 +- fs/nilfs2/namei.c | 6 +- fs/notify/fanotify/fanotify.c | 19 +- fs/notify/fanotify/fanotify.h | 3 +- fs/notify/fanotify/fanotify_user.c | 2 +- fs/ocfs2/dlm/dlmdomain.c | 14 - fs/ocfs2/dlm/dlmdomain.h | 25 +- fs/ocfs2/dlm/dlmrecovery.c | 9 + fs/orangefs/namei.c | 9 +- fs/proc/proc_sysctl.c | 3 + fs/reiserfs/namei.c | 12 +- fs/super.c | 30 +- fs/udf/namei.c | 6 +- fs/udf/super.c | 5 +- fs/ufs/namei.c | 6 +- fs/xfs/xfs_discard.c | 14 +- include/drm/drm_vblank.h | 2 +- include/linux/dcache.h | 1 + include/rdma/ib_umem.h | 1 - ipc/shm.c | 19 +- kernel/audit.c | 2 + kernel/debug/kdb/kdb_main.c | 27 +- kernel/events/core.c | 49 ++- kernel/irq/affinity.c | 15 +- kernel/rcu/tree_plugin.h | 14 +- kernel/sched/rt.c | 2 + kernel/sys.c | 2 + lib/radix-tree.c | 4 +- lib/test_kasan.c | 8 + mm/kasan/kasan.c | 66 +++- mm/ksm.c | 28 ++ mm/page_idle.c | 12 +- mm/slub.c | 57 ++-- mm/swapfile.c | 4 + mm/vmscan.c | 8 +- mm/z3fold.c | 9 +- net/netlabel/netlabel_unlabeled.c | 10 + net/rxrpc/call_event.c | 2 +- net/rxrpc/input.c | 15 +- net/rxrpc/sendmsg.c | 4 +- net/smc/smc_ib.c | 10 +- net/smc/smc_wr.h | 1 - security/integrity/ima/Kconfig | 1 + security/integrity/ima/ima_crypto.c | 2 + security/integrity/ima/ima_main.c | 13 + security/integrity/ima/ima_policy.c | 2 +- security/selinux/hooks.c | 20 +- sound/core/timer.c | 4 +- sound/core/vmaster.c | 5 +- tools/hv/hv_fcopy_daemon.c | 3 +- tools/hv/hv_vss_daemon.c | 1 + tools/perf/Makefile.perf | 3 +- tools/perf/builtin-stat.c | 9 +- tools/perf/builtin-top.c | 6 +- tools/perf/tests/dwarf-unwind.c | 46 ++- .../perf/tests/shell/trace+probe_libc_inet_pton.sh | 6 +- tools/perf/tests/vmlinux-kallsyms.c | 2 +- tools/perf/ui/browsers/annotate.c | 9 +- tools/perf/util/c++/clang.cpp | 11 +- tools/perf/util/hist.c | 4 +- tools/perf/util/hist.h | 1 - tools/perf/util/mmap.c | 6 + tools/testing/radix-tree/idr-test.c | 7 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/net/fib-onlink-tests.sh | 375 +++++++++++++++++++++ tools/testing/selftests/net/psock_fanout.c | 3 +- tools/thermal/tmon/sysfs.c | 12 +- tools/thermal/tmon/tmon.c | 1 - 298 files changed, 3076 insertions(+), 1191 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 20/272 libata: Blacklist some Sandisk SSDs for NCQ
4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 322579dcc865b94b47345ad1b6002ad167f85405 upstream.
Sandisk SSDs SD7SN6S256G and SD8SN8U256G are regularly locking up regularly under sustained moderate load with NCQ enabled. Blacklist for now.
--- drivers/ata/libata-core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/ata/libata-core.c +4 -0
@@ -4493,6 +4493,10 @@ static const struct ata_blacklist_entry/* https://bugzilla.kernel.org/show_bug.cgi?id=15573 */ { "C300-CTFDDAC128MAG", "0001", ATA_HORKAGE_NONCQ, }, + /* Some Sandisk SSDs lock up hard with NCQ enabled. Reported on + SD7SN6S256G and SD8SN8U256G */ + { "SanDisk SD[78]SN*G", NULL, ATA_HORKAGE_NONCQ, }, + /* devices which puke on READ_NATIVE_MAX */ { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, { "WDC WD3200JD-00KLB0", "WD-WCAMR1130137", ATA_HORKAGE_BROKEN_HPA },
Greg Kroah-Hartman
maintainerPATCH 22/272 xen-swiotlb: fix the check condition for xen_swiotlb_free_coherent
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Jin <[email protected]>
commit 4855c92dbb7b3b85c23e88ab7ca04f99b9677b41 upstream.
When run raidconfig from Dom0 we found that the Xen DMA heap is reduced, but Dom Heap is increased by the same size. Tracing raidconfig we found that the related ioctl() in megaraid_sas will call dma_alloc_coherent() to apply memory. If the memory allocated by Dom0 is not in the DMA area, it will exchange memory with Xen to meet the requiment. Later drivers call dma_free_coherent() to free the memory, on xen_swiotlb_free_coherent() the check condition (dev_addr + size - 1 <= dma_mask) is always false, it prevents calling xen_destroy_contiguous_region() to return the memory to the Xen DMA heap.
This issue introduced by commit 6810df88dcfc2 "xen-swiotlb: When doing coherent alloc/dealloc check before swizzling the MFNs.".
--- drivers/xen/swiotlb-xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/swiotlb-xen.c +1 -1
@@ -365,7 +365,7 @@ xen_swiotlb_free_coherent(struct device* physical address */ phys =xen_bus_to_phys (dev_addr); -if (((dev_addr + size -1 > dma_mask)) || +if (((dev_addr + size -1 <= dma_mask)) ||range_straddles_page_boundary (phys, size))xen_destroy_contiguous_region (phys, order);
Greg Kroah-Hartman
maintainerPATCH 23/272 drm/vmwgfx: Fix 32-bit VMW_PORT_HB_[IN|OUT] macros
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
commit 938ae7259c908ad031da35d551da297640bb640c upstream.
Depending on whether the kernel is compiled with frame-pointer or not, the temporary memory location used for the bp parameter in these macros is referenced relative to the stack pointer or the frame pointer. Hence we can never reference that parameter when we've modified either the stack pointer or the frame pointer, because then the compiler would generate an incorrect stack reference.
Fix this by pushing the temporary memory parameter on a known location on the stack before modifying the stack- and frame pointers.
--- drivers/gpu/drm/vmwgfx/vmwgfx_msg.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_msg.h +17 -8
@@ -135,17 +135,24 @@#else -/* In the 32-bit version of this macro, we use "m" because there is no -* more register left for bp +/* +* In the 32-bit version of this macro, we store bp in a memory location +* because we've ran out of registers. +* Now we can't reference that memory location while we've modified +* %esp or %ebp, so we first push it on the stack, just before we push +* %ebp, and then when we need it we read it from the stack where we +* just pushed it. */ #define VMW_PORT_HB_OUT (cmd, in_ecx, in_si, in_di, \ port_num, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ - asm volatile ("push %%ebp;" \ - "mov %12, %%ebp;" \ + asm volatile ("push %12;" \ + "push %%ebp;" \ + "mov 0x04(%%esp), %%ebp;" \ "rep outsb;" \ - "pop %%ebp;" : \ + "pop %%ebp;" \ + "add $0x04, %%esp;" : \ "=a"(eax), \ "=b"(ebx), \ "=c"(ecx), \
@@ -167,10 +174,12 @@ port_num, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ - asm volatile ("push %%ebp;" \ - "mov %12, %%ebp;" \ + asm volatile ("push %12;" \ + "push %%ebp;" \ + "mov 0x04(%%esp), %%ebp;" \ "rep insb;" \ - "pop %%ebp" : \ + "pop %%ebp;" \ + "add $0x04, %%esp;" : \ "=a"(eax), \ "=b"(ebx), \ "=c"(ecx), \
Greg Kroah-Hartman
maintainerPATCH 24/272 arm64: lse: Add early clobbers to some input/output asm operands
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit 32c3fa7cdf0c4a3eb8405fc3e13398de019e828b upstream.
For LSE atomics that read and write a register operand, we need to ensure that these operands are annotated as "early clobber" if the register is written before all of the input operands have been consumed. Failure to do so can result in the compiler allocating the same register to both operands, leading to splats such as:
Unable to handle kernel paging request at virtual address 11111122222221 [...] x1 : 1111111122222222 x0 : 1111111122222221 Process swapper/0 (pid: 1, stack limit = 0x000000008209f908) Call trace: test_atomic64+0x1360/0x155c
where x0 has been allocated as both the value to be stored and also the atomic_t pointer.
This patch adds the missing clobbers.
--- arch/arm64/include/asm/atomic_lse.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
arch/arm64/include/asm/atomic_lse.h +12 -12
@@ -117,7 +117,7 @@ static inline void atomic_and(int i, ato/* LSE atomics */ " mvn %w[i], %w[i]\n" " stclr %w[i], %[v]") - : [i] "+r" (w0), [v] "+Q" (v->counter) + : [i] "+&r" (w0), [v] "+Q" (v->counter) : "r" (x1) : __LL_SC_CLOBBERS); }
@@ -135,7 +135,7 @@ static inline int atomic_fetch_and##name/* LSE atomics */ \" mvn %w[i], %w[i]\n" \ " ldclr" #mb " %w[i], %w[i], %[v]") \ - : [i] "+r" (w0), [v] "+Q" (v->counter) \ + : [i] "+&r" (w0), [v] "+Q" (v->counter) \ : "r" (x1) \ : __LL_SC_CLOBBERS, ##cl); \ \
@@ -161,7 +161,7 @@ static inline void atomic_sub(int i, ato/* LSE atomics */ " neg %w[i], %w[i]\n" " stadd %w[i], %[v]") - : [i] "+r" (w0), [v] "+Q" (v->counter) + : [i] "+&r" (w0), [v] "+Q" (v->counter) : "r" (x1) : __LL_SC_CLOBBERS); }
@@ -180,7 +180,7 @@ static inline int atomic_sub_return##nam" neg %w[i], %w[i]\n" \ " ldadd" #mb " %w[i], w30, %[v]\n" \ " add %w[i], %w[i], w30") \ - : [i] "+r" (w0), [v] "+Q" (v->counter) \ + : [i] "+&r" (w0), [v] "+Q" (v->counter) \ : "r" (x1) \ : __LL_SC_CLOBBERS , ##cl); \ \
@@ -207,7 +207,7 @@ static inline int atomic_fetch_sub##name/* LSE atomics */ \" neg %w[i], %w[i]\n" \ " ldadd" #mb " %w[i], %w[i], %[v]") \ - : [i] "+r" (w0), [v] "+Q" (v->counter) \ + : [i] "+&r" (w0), [v] "+Q" (v->counter) \ : "r" (x1) \ : __LL_SC_CLOBBERS, ##cl); \ \
@@ -314,7 +314,7 @@ static inline void atomic64_and(long i,/* LSE atomics */ " mvn %[i], %[i]\n" " stclr %[i], %[v]") - : [i] "+r" (x0), [v] "+Q" (v->counter) + : [i] "+&r" (x0), [v] "+Q" (v->counter) : "r" (x1) : __LL_SC_CLOBBERS); }
@@ -332,7 +332,7 @@ static inline long atomic64_fetch_and##n/* LSE atomics */ \" mvn %[i], %[i]\n" \ " ldclr" #mb " %[i], %[i], %[v]") \ - : [i] "+r" (x0), [v] "+Q" (v->counter) \ + : [i] "+&r" (x0), [v] "+Q" (v->counter) \ : "r" (x1) \ : __LL_SC_CLOBBERS, ##cl); \ \
@@ -358,7 +358,7 @@ static inline void atomic64_sub(long i,/* LSE atomics */ " neg %[i], %[i]\n" " stadd %[i], %[v]") - : [i] "+r" (x0), [v] "+Q" (v->counter) + : [i] "+&r" (x0), [v] "+Q" (v->counter) : "r" (x1) : __LL_SC_CLOBBERS); }
@@ -377,7 +377,7 @@ static inline long atomic64_sub_return##" neg %[i], %[i]\n" \ " ldadd" #mb " %[i], x30, %[v]\n" \ " add %[i], %[i], x30") \ - : [i] "+r" (x0), [v] "+Q" (v->counter) \ + : [i] "+&r" (x0), [v] "+Q" (v->counter) \ : "r" (x1) \ : __LL_SC_CLOBBERS, ##cl); \ \
@@ -404,7 +404,7 @@ static inline long atomic64_fetch_sub##n/* LSE atomics */ \" neg %[i], %[i]\n" \ " ldadd" #mb " %[i], %[i], %[v]") \ - : [i] "+r" (x0), [v] "+Q" (v->counter) \ + : [i] "+&r" (x0), [v] "+Q" (v->counter) \ : "r" (x1) \ : __LL_SC_CLOBBERS, ##cl); \ \
@@ -435,7 +435,7 @@ static inline long atomic64_dec_if_posit" sub x30, x30, %[ret]\n" " cbnz x30, 1b\n" "2:") - : [ret] "+r" (x0), [v] "+Q" (v->counter) + : [ret] "+&r" (x0), [v] "+Q" (v->counter) : : __LL_SC_CLOBBERS, "cc", "memory");
@@ -516,7 +516,7 @@ static inline long __cmpxchg_double##nam" eor %[old1], %[old1], %[oldval1]\n" \" eor %[old2], %[old2], %[oldval2]\n" \ " orr %[old1], %[old1], %[old2]") \ - : [old1] "+r" (x0), [old2] "+r" (x1), \ + : [old1] "+&r" (x0), [old2] "+&r" (x1), \[v] " +Q " (*(unsigned long *)ptr) \ : [new1] " r" (x2), [new2] " r" (x3), [ptr] " r" (x4), \ [oldval1] " r" (oldval1), [oldval2] " r" (oldval2) \
Greg Kroah-Hartman
maintainerPATCH 25/272 arm64: export tishift functions to modules
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
commit 255845fc43a3aaf806852a1d3bc89bff1411ebe3 upstream.
Otherwise modules that use these arithmetic operations will fail to link. We accomplish this with the usual EXPORT_SYMBOL, which on most architectures goes in the .S file but the ARM64 maintainers prefer that insead it goes into arm64ksyms.
While we're at it, we also fix this up to use SPDX, and I personally choose to relicense this as GPL2||BSD so that these symbols don't need to be export_symbol_gpl, so all modules can use the routines, since these are important general purpose compiler-generated function calls.
--- arch/arm64/kernel/arm64ksyms.c | 8 ++++++++ arch/arm64/lib/tishift.S | 15 ++------------- 2 files changed, 10 insertions(+), 13 deletions(-)
arch/arm64/kernel/arm64ksyms.c +8 -0
@@ -75,3 +75,11 @@ NOKPROBE_SYMBOL(_mcount);/* arm-smccc */ EXPORT_SYMBOL (__arm_smccc_smc);EXPORT_SYMBOL (__arm_smccc_hvc); + +/* tishift.S */ +extern long long __ashlti3 (long long a,int b); +EXPORT_SYMBOL (__ashlti3); +extern long long __ashrti3 (long long a,int b); +EXPORT_SYMBOL (__ashrti3); +extern long long __lshrti3 (long long a,int b); +EXPORT_SYMBOL (__lshrti3);
arch/arm64/lib/tishift.S +2 -13
@@ -1,17 +1,6 @@ -/* - * Copyright (C) 2017 Jason A. Donenfeld <[email protected]>. All Rights Reserved. +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. + * Copyright (C) 2017-2018 Jason A. Donenfeld <[email protected]>. All Rights Reserved. */ #include <linux/linkage.h>
Greg Kroah-Hartman
maintainerPATCH 26/272 powerpc/64s: Clear PCR on boot
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Neuling <[email protected]>
commit faf37c44a105f3608115785f17cbbf3500f8bc71 upstream.
Clear the PCR (Processor Compatibility Register) on boot to ensure we are not running in a compatibility mode.
We've seen this cause problems when a crash (and kdump) occurs while running compat mode guests. The kdump kernel then runs with the PCR set and causes problems. The symptom in the kdump kernel (also seen in petitboot after fast-reboot) is early userspace programs taking sigills on newer instructions (seen in libc).
--- arch/powerpc/kernel/cpu_setup_power.S | 6 ++++++ arch/powerpc/kernel/dt_cpu_ftrs.c | 1 + 2 files changed, 7 insertions(+)
arch/powerpc/kernel/cpu_setup_power.S +6 -0
@@ -28,6 +28,7 @@ _GLOBAL(__setup_cpu_power7) beqlr li r0,0 mtspr SPRN_LPID,r0 + mtspr SPRN_PCR,r0 mfspr r3,SPRN_LPCR li r4,(LPCR_LPES1 >> LPCR_LPES_SH) bl __init_LPCR_ISA206
@@ -41,6 +42,7 @@ _GLOBAL(__restore_cpu_power7) beqlr li r0,0 mtspr SPRN_LPID,r0 + mtspr SPRN_PCR,r0 mfspr r3,SPRN_LPCR li r4,(LPCR_LPES1 >> LPCR_LPES_SH) bl __init_LPCR_ISA206
@@ -57,6 +59,7 @@ _GLOBAL(__setup_cpu_power8) beqlr li r0,0 mtspr SPRN_LPID,r0 + mtspr SPRN_PCR,r0 mfspr r3,SPRN_LPCR ori r3, r3, LPCR_PECEDH li r4,0 /* LPES = 0 */
@@ -78,6 +81,7 @@ _GLOBAL(__restore_cpu_power8) beqlr li r0,0 mtspr SPRN_LPID,r0 + mtspr SPRN_PCR,r0 mfspr r3,SPRN_LPCR ori r3, r3, LPCR_PECEDH li r4,0 /* LPES = 0 */
@@ -99,6 +103,7 @@ _GLOBAL(__setup_cpu_power9) mtspr SPRN_PSSCR,r0 mtspr SPRN_LPID,r0 mtspr SPRN_PID,r0 + mtspr SPRN_PCR,r0 mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC) or r3, r3, r4
@@ -123,6 +128,7 @@ _GLOBAL(__restore_cpu_power9) mtspr SPRN_PSSCR,r0 mtspr SPRN_LPID,r0 mtspr SPRN_PID,r0 + mtspr SPRN_PCR,r0 mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC) or r3, r3, r4
arch/powerpc/kernel/dt_cpu_ftrs.c +1 -0
@@ -114,6 +114,7 @@ static void __restore_cpu_cpufeatures(voif (hv_mode) {mtspr (SPRN_LPID ,0 );mtspr (SPRN_HFSCR , system_registers.hfscr); +mtspr (SPRN_PCR ,0 ); }mtspr (SPRN_FSCR , system_registers.fscr);
Greg Kroah-Hartman
maintainerPATCH 27/272 IB/hfi1: Use after free race condition in send context error path
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael J. Ruhl <[email protected]>
commit f9e76ca3771bf23d2142a81a88ddd8f31f5c4c03 upstream.
A pio send egress error can occur when the PSM library attempts to to send a bad packet. That issue is still being investigated.
The pio error interrupt handler then attempts to progress the recovery of the errored pio send context.
Code inspection reveals that the handling lacks the necessary locking if that recovery interleaves with a PSM close of the "context" object contains the pio send context.
The lack of the locking can cause the recovery to access the already freed pio send context object and incorrectly deduce that the pio send context is actually a kernel pio send context as shown by the NULL deref stack below:
[<ffffffff8143d78c>] _dev_info+0x6c/0x90 [<ffffffffc0613230>] sc_restart+0x70/0x1f0 [hfi1] [<ffffffff816ab124>] ? __schedule+0x424/0x9b0 [<ffffffffc06133c5>] sc_halted+0x15/0x20 [hfi1] [<ffffffff810aa3ba>] process_one_work+0x17a/0x440 [<ffffffff810ab086>] worker_thread+0x126/0x3c0 [<ffffffff810aaf60>] ? manage_workers.isra.24+0x2a0/0x2a0 [<ffffffff810b252f>] kthread+0xcf/0xe0 [<ffffffff810b2460>] ? insert_kthread_work+0x40/0x40 [<ffffffff816b8798>] ret_from_fork+0x58/0x90 [<ffffffff810b2460>] ? insert_kthread_work+0x40/0x40
This is the best case scenario and other scenarios can corrupt the already freed memory.
Fix by adding the necessary locking in the pio send context error handler.
--- drivers/infiniband/hw/hfi1/chip.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/infiniband/hw/hfi1/chip.c +4 -0
@@ -5944,6 +5944,7 @@ static void is_sendctxt_err_int(struct hu64 status;u32 sw_index;int i =0 ; +unsigned long irq_flags; sw_index = dd->hw_to_sw[hw_context];if (sw_index >= dd->num_send_contexts) {
@@ -5953,10 +5954,12 @@ static void is_sendctxt_err_int(struct hreturn ; } sci = &dd->send_contexts[sw_index]; +spin_lock_irqsave (&dd->sc_lock, irq_flags); sc = sci->sc;if (!sc) {dd_dev_err (dd,"%s: context %u(%u): no sc?\n" , __func__, sw_index, hw_context); +spin_unlock_irqrestore (&dd->sc_lock, irq_flags);return ; }
@@ -5978,6 +5981,7 @@ static void is_sendctxt_err_int(struct h*/ if (sc->type !=SC_USER )queue_work (dd->pport->hfi1_wq, &sc->halt_work); +spin_unlock_irqrestore (&dd->sc_lock, irq_flags);/* * Update the counters for the corresponding status bits.
Greg Kroah-Hartman
maintainerPATCH 28/272 IB/umem: Use the correct mm during ib_umem_release
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lidong Chen <[email protected]>
commit 8e907ed4882714fd13cfe670681fc6cb5284c780 upstream.
User-space may invoke ibv_reg_mr and ibv_dereg_mr in different threads.
If ibv_dereg_mr is called after the thread which invoked ibv_reg_mr has exited, get_pid_task will return NULL and ib_umem_release will not decrease mm->pinned_vm.
Instead of using threads to locate the mm, use the overall tgid from the ib_ucontext struct instead. This matches the behavior of ODP and disassociate in handling the mm of the process that called ibv_reg_mr.
--- drivers/infiniband/core/umem.c | 7 +------ include/rdma/ib_umem.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/infiniband/core/umem.c +1 -6
@@ -119,7 +119,6 @@ struct ib_umem *ib_umem_get(struct ib_uc umem->length = size; umem->address = addr; umem->page_shift =PAGE_SHIFT ; - umem->pid =get_task_pid (current,PIDTYPE_PID );/* * We ask for writable memory if any of the following * access flags are set. "Local write" and "remote write"
@@ -132,7 +131,6 @@ struct ib_umem *ib_umem_get(struct ib_uc IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND));if (access &IB_ACCESS_ON_DEMAND ) { -put_pid (umem->pid); ret =ib_umem_odp_get (context, umem, access);if (ret) {kfree (umem);
@@ -148,7 +146,6 @@ struct ib_umem *ib_umem_get(struct ib_uc page_list = (struct page **)__get_free_page (GFP_KERNEL );if (!page_list) { -put_pid (umem->pid);kfree (umem);return ERR_PTR (-ENOMEM ); }
@@ -231,7 +228,6 @@ out:if (ret <0 ) {if (need_release)__ib_umem_release (context->device, umem,0 ); -put_pid (umem->pid);kfree (umem); }else current->mm->pinned_vm = locked;
@@ -274,8 +270,7 @@ void ib_umem_release(struct ib_umem *ume__ib_umem_release (umem->context->device, umem,1 ); - task =get_pid_task (umem->pid,PIDTYPE_PID ); -put_pid (umem->pid); + task =get_pid_task (umem->context->tgid,PIDTYPE_PID );if (!task) goto out; mm =get_task_mm (task);
include/rdma/ib_umem.h +0 -1
@@ -48,7 +48,6 @@ struct ib_umem {int writable;int hugetlb;struct work_struct work; -struct pid *pid;struct mm_struct *mm;unsigned long diff;struct ib_umem_odp *odp_data;
Greg Kroah-Hartman
maintainerPATCH 29/272 sr: pass down correctly sized SCSI sense buffer
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit f7068114d45ec55996b9040e98111afa56e010fe upstream.
We're casting the CDROM layer request_sense to the SCSI sense buffer, but the former is 64 bytes and the latter is 96 bytes. As we generally allocate these on the stack, we end up blowing up the stack.
Fix this by wrapping the scsi_execute() call with a properly sized sense buffer, and copying back the bits for the CDROM layer.
--- drivers/scsi/sr_ioctl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/scsi/sr_ioctl.c +8 -2
@@ -188,9 +188,13 @@ int sr_do_ioctl(Scsi_CD *cd, struct packstruct scsi_device *SDev;struct scsi_sense_hdr sshdr;int result, err =0 , retries =0 ; +unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE ], *senseptr =NULL ; SDev = cd->device; +if (cgc->sense) + senseptr = sense_buffer; + retry:if (!scsi_block_when_processing_errors (SDev)) { err = -ENODEV ;
@@ -198,10 +202,12 @@ int sr_do_ioctl(Scsi_CD *cd, struct pack } result =scsi_execute (SDev, cgc->cmd, cgc->data_direction, - cgc->buffer, cgc->buflen, - (unsigned char *)cgc->sense, &sshdr, + cgc->buffer, cgc->buflen, senseptr, &sshdr, cgc->timeout,IOCTL_RETRIES ,0 ,0 ,NULL ); +if (cgc->sense) +memcpy (cgc->sense, sense_buffer,sizeof (*cgc->sense)); +/* Minimal error checking. Ignore cases we know about, and report the rest. */ if (driver_byte (result) !=0 ) {switch (sshdr.sense_key) {
Greg Kroah-Hartman
maintainerPATCH 12/272 Btrfs: fix error handling in btrfs_truncate()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Omar Sandoval <[email protected]>
commit d50147381aa0c9725d63a677c138c47f55d6d3bc upstream.
Jun Wu at Facebook reported that an internal service was seeing a return value of 1 from ftruncate() on Btrfs in some cases. This is coming from the NEED_TRUNCATE_BLOCK return value from btrfs_truncate_inode_items().
btrfs_truncate() uses two variables for error handling, ret and err. When btrfs_truncate_inode_items() returns non-zero, we set err to the return value. However, NEED_TRUNCATE_BLOCK is not an error. Make sure we only set err if ret is an error (i.e., negative).
To reproduce the issue: mount a filesystem with -o compress-force=zstd and the following program will encounter return value of 1 from ftruncate:
int main(void) {
char buf[256] = { 0 };
int ret;
int fd;
fd = open("test", O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (fd == -1) {
perror("open");
return EXIT_FAILURE;
}
if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
perror("write");
close(fd);
return EXIT_FAILURE;
}
if (fsync(fd) == -1) {
perror("fsync");
close(fd);
return EXIT_FAILURE;
}
ret = ftruncate(fd, 128);
if (ret) {
printf("ftruncate() returned %d\n", ret);
close(fd);
return EXIT_FAILURE;
}
close(fd);
return EXIT_SUCCESS;
}--- fs/btrfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +2 -1
@@ -9238,7 +9238,8 @@ static int btrfs_truncate(struct inode * BTRFS_EXTENT_DATA_KEY); trans->block_rsv = &fs_info->trans_block_rsv;if (ret != -ENOSPC && ret != -EAGAIN ) { - err = ret; +if (ret <0 ) + err = ret;break ; }
Greg Kroah-Hartman
maintainerPATCH 31/272 idr: fix invalid ptr dereference on item delete
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox <[email protected]>
commit 7a4deea1aa8bddfed4ef1b35fc2b6732563d8ad5 upstream.
If the radix tree underlying the IDR happens to be full and we attempt to remove an id which is larger than any id in the IDR, we will call __radix_tree_delete() with an uninitialised 'slot' pointer, at which point anything could happen. This was easiest to hit with a single entry at id 0 and attempting to remove a non-0 id, but it could have happened with 64 entries and attempting to remove an id >= 64.
Roman said:
The syzcaller test boils down to opening /dev/kvm, creating an eventfd, and calling a couple of KVM ioctls. None of this requires superuser. And the result is dereferencing an uninitialized pointer which is likely a crash. The specific path caught by syzbot is via KVM_HYPERV_EVENTD ioctl which is new in 4.17. But I guess there are other user-triggerable paths, so cc:stable is probably justified.
Matthew added:
We have around 250 calls to idr_remove() in the kernel today. Many of them pass an ID which is embedded in the object they're removing, so they're safe. Picking a few likely candidates:
drivers/firewire/core-cdev.c looks unsafe; the ID comes from an ioctl. drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c is similar drivers/atm/nicstar.c could be taken down by a handcrafted packet
--- lib/radix-tree.c | 4 +++- tools/testing/radix-tree/idr-test.c | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
lib/radix-tree.c +3 -1
@@ -2034,10 +2034,12 @@ void *radix_tree_delete_item(struct radi unsigned long index, void *item) { struct radix_tree_node *node = NULL; -void __rcu **slot; +void __rcu **slot =NULL ;void *entry; entry =__radix_tree_lookup (root, index, &node, &slot); +if (!slot) +return NULL ;if (!entry && (!is_idr (root) ||node_tag_get (root, node,IDR_FREE ,get_slot_offset (node, slot))))return NULL ;
tools/testing/radix-tree/idr-test.c +7 -0
@@ -252,6 +252,13 @@ void idr_checks(void)idr_remove (&idr,3 );idr_remove (&idr,0 ); +assert (idr_alloc (&idr,DUMMY_PTR ,0 ,0 ,GFP_KERNEL ) ==0 ); +idr_remove (&idr,1 ); +for (i =1 ; i <RADIX_TREE_MAP_SIZE ; i++) +assert (idr_alloc (&idr,DUMMY_PTR ,0 ,0 ,GFP_KERNEL ) == i); +idr_remove (&idr,1 <<30 ); +idr_destroy (&idr); +for (i =INT_MAX -3UL ; i <INT_MAX +1UL ; i++) {struct item *item =item_create (i,0 );assert (idr_alloc (&idr, item, i, i +10 ,GFP_KERNEL ) == i);
Greg Kroah-Hartman
maintainerPATCH 32/272 Revert "ipc/shm: Fix shmat mmap nil-page protection"
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit a73ab244f0dad8fffb3291b905f73e2d3eaa7c00 upstream.
Patch series "ipc/shm: shmat() fixes around nil-page".
These patches fix two issues reported[1] a while back by Joe and Andrea around how shmat(2) behaves with nil-page.
The first reverts a commit that it was incorrectly thought that mapping nil-page (address=0) was a no no with MAP_FIXED. This is not the case, with the exception of SHM_REMAP; which is address in the second patch.
I chose two patches because it is easier to backport and it explicitly reverts bogus behaviour. Both patches ought to be in -stable and ltp testcases need updated (the added testcase around the cve can be modified to just test for SHM_RND|SHM_REMAP).
[1] lkml.kernel.org/r/20180430172152.nfa564pvgpk3ut7p@linux-n805
This patch (of 2):
Commit 95e91b831f87 ("ipc/shm: Fix shmat mmap nil-page protection") worked on the idea that we should not be mapping as root addr=0 and MAP_FIXED. However, it was reported that this scenario is in fact valid, thus making the patch both bogus and breaks userspace as well.
For example X11's libint10.so relies on shmat(1, SHM_RND) for lowmem initialization[1].
[1] https://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/os-support/linux/int10/linux.c#n347
--- ipc/shm.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
ipc/shm.c +2 -7
@@ -1320,13 +1320,8 @@ long do_shmat(int shmid, char __user *shif (addr) {if (addr & (shmlba -1 )) { -/* -* Round down to the nearest multiple of shmlba. -* For sane do_mmap_pgoff() parameters, avoid -* round downs that trigger nil-page and MAP_FIXED. -*/ -if ((shmflg &SHM_RND ) && addr >= shmlba) - addr &= ~(shmlba -1 ); +if (shmflg &SHM_RND ) + addr &= ~(shmlba -1 );/* round down */ else#ifndef __ARCH_FORCE_SHMLBAif (addr & ~PAGE_MASK )
Greg Kroah-Hartman
maintainerPATCH 33/272 ipc/shm: fix shmat() nil address after round-down when remapping
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 8f89c007b6dec16a1793cb88de88fcc02117bbbc upstream.
shmat()'s SHM_REMAP option forbids passing a nil address for; this is in fact the very first thing we check for. Andrea reported that for SHM_RND|SHM_REMAP cases we can end up bypassing the initial addr check, but we need to check again if the address was rounded down to nil. As of this patch, such cases will return -EINVAL.
--- ipc/shm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
ipc/shm.c +10 -2
@@ -1320,9 +1320,17 @@ long do_shmat(int shmid, char __user *shif (addr) {if (addr & (shmlba -1 )) { -if (shmflg &SHM_RND ) +if (shmflg &SHM_RND ) { addr &= ~(shmlba -1 );/* round down */ - else + +/* +* Ensure that the round-down is non-nil +* when remapping. This can happen for +* cases when addr < shmlba. +*/ +if (!addr && (shmflg &SHM_REMAP )) + goto out; + } else#ifndef __ARCH_FORCE_SHMLBA if (addr & ~PAGE_MASK)#endif
Greg Kroah-Hartman
maintainerPATCH 34/272 mm/kasan: dont vfree() nonexistent vm_area
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ryabinin <[email protected]>
commit 0f901dcbc31f88ae41a2aaa365f7802b5d520a28 upstream.
KASAN uses different routines to map shadow for hot added memory and memory obtained in boot process. Attempt to offline memory onlined by normal boot process leads to this:
Trying to vfree() nonexistent vm area (000000005d3b34b9)
WARNING: CPU: 2 PID: 13215 at mm/vmalloc.c:1525 __vunmap+0x147/0x190
Call Trace:
kasan_mem_notifier+0xad/0xb9
notifier_call_chain+0x166/0x260
__blocking_notifier_call_chain+0xdb/0x140
__offline_pages+0x96a/0xb10
memory_subsys_offline+0x76/0xc0
device_offline+0xb8/0x120
store_mem_state+0xfa/0x120
kernfs_fop_write+0x1d5/0x320
__vfs_write+0xd4/0x530
vfs_write+0x105/0x340
SyS_write+0xb0/0x140Obviously we can't call vfree() to free memory that wasn't allocated via vmalloc(). Use find_vm_area() to see if we can call vfree().
Unfortunately it's a bit tricky to properly unmap and free shadow allocated during boot, so we'll have to keep it. If memory will come online again that shadow will be reused.
Matthew asked: how can you call vfree() on something that isn't a vmalloc address?
vfree() is able to free any address returned by __vmalloc_node_range(). And __vmalloc_node_range() gives you any address you ask. It doesn't have to be an address in [VMALLOC_START, VMALLOC_END] range.
That's also how the module_alloc()/module_memfree() works on architectures that have designated area for modules.
--- mm/kasan/kasan.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-)
mm/kasan/kasan.c +61 -2
@@ -791,6 +791,40 @@ DEFINE_ASAN_SET_SHADOW(f5);DEFINE_ASAN_SET_SHADOW (f8);#ifdef CONFIG_MEMORY_HOTPLUG +static bool shadow_mapped (unsigned long addr) +{ +pgd_t *pgd =pgd_offset_k (addr); +p4d_t *p4d; +pud_t *pud; +pmd_t *pmd; +pte_t *pte; + +if (pgd_none (*pgd)) +return false; + p4d =p4d_offset (pgd, addr); +if (p4d_none (*p4d)) +return false; + pud =pud_offset (p4d, addr); +if (pud_none (*pud)) +return false; + +/* +* We can't use pud_large() or pud_huge(), the first one is +* arch-specific, the last one depends on HUGETLB_PAGE. So let's abuse +* pud_bad(), if pud is bad then it's bad because it's huge. +*/ +if (pud_bad (*pud)) +return true; + pmd =pmd_offset (pud, addr); +if (pmd_none (*pmd)) +return false; + +if (pmd_bad (*pmd)) +return true; + pte =pte_offset_kernel (pmd, addr); +return !pte_none (*pte); +} +static int __meminit kasan_mem_notifier (struct notifier_block *nb,unsigned long action,void *data) {
@@ -812,6 +846,14 @@ static int __meminit kasan_mem_notifier(case MEM_GOING_ONLINE : {void *ret; +/* +* If shadow is mapped already than it must have been mapped +* during the boot. This could happen if we onlining previously +* offlined memory. +*/ +if (shadow_mapped (shadow_start)) +return NOTIFY_OK ; + ret = __vmalloc_node_range(shadow_size, PAGE_SIZE, shadow_start, shadow_end, GFP_KERNEL, PAGE_KERNEL, VM_NO_GUARD,
@@ -823,8 +865,25 @@ static int __meminit kasan_mem_notifier(kmemleak_ignore (ret);return NOTIFY_OK ; } -case MEM_OFFLINE : -vfree ((void *)shadow_start); +case MEM_OFFLINE : { +struct vm_struct *vm; + +/* +* shadow_start was either mapped during boot by kasan_init() +* or during memory online by __vmalloc_node_range(). +* In the latter case we can use vfree() to free shadow. +* Non-NULL result of the find_vm_area() will tell us if +* that was the second case. +* +* Currently it's not possible to free shadow mapped +* during boot by kasan_init(). It's because the code +* to do that hasn't been written yet. So we'll just +* leak the memory. +*/ + vm =find_vm_area ((void *)shadow_start); +if (vm) +vfree ((void *)shadow_start); + } }return NOTIFY_OK ;
Greg Kroah-Hartman
maintainerPATCH 35/272 kasan: free allocated shadow memory on MEM_CANCEL_ONLINE
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
commit ed1596f9ab958dd156a66c9ff1029d3761c1786a upstream.
We have to free memory again when we cancel onlining, otherwise a later onlining attempt will fail.
--- mm/kasan/kasan.c | 1 + 1 file changed, 1 insertion(+)
mm/kasan/kasan.c +1 -0
@@ -865,6 +865,7 @@ static int __meminit kasan_mem_notifier(kmemleak_ignore (ret);return NOTIFY_OK ; } +case MEM_CANCEL_ONLINE :case MEM_OFFLINE : {struct vm_struct *vm;
Greg Kroah-Hartman
maintainerPATCH 36/272 kasan: fix memory hotplug during boot
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
commit 3f1959721558a976aaf9c2024d5bc884e6411bf7 upstream.
Using module_init() is wrong. E.g. ACPI adds and onlines memory before our memory notifier gets registered.
This makes sure that ACPI memory detected during boot up will not result in a kernel crash.
Easily reproducible with QEMU, just specify a DIMM when starting up.
--- mm/kasan/kasan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kasan/kasan.c +1 -1
@@ -897,5 +897,5 @@ static int __init kasan_memhotplug_init( return 0; } -module_init (kasan_memhotplug_init); +core_initcall (kasan_memhotplug_init);#endif
Greg Kroah-Hartman
maintainerPATCH 38/272 PM / core: Fix direct_complete handling for devices with no callbacks
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit c62ec4610c40bcc44f2d3d5ed1c312737279e2f3 upstream.
Commit 08810a4119aa (PM / core: Add NEVER_SKIP and SMART_PREPARE driver flags) inadvertently prevented the power.direct_complete flag from being set for devices without PM callbacks and with disabled runtime PM which also prevents power.direct_complete from being set for their parents. That led to problems including a resume crash on HP ZBook 14u.
Restore the previous behavior by causing power.direct_complete to be set for those devices again, but do that in a more direct way to avoid overlooking that case in the future.
--- drivers/base/power/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/base/power/main.c +3 -4
@@ -1923,10 +1923,8 @@ static int device_prepare(struct device dev->power.wakeup_path = false; -if (dev->power.no_pm_callbacks) { - ret =1 ;/* Let device go direct_complete */ +if (dev->power.no_pm_callbacks) goto unlock; - }if (dev->pm_domain) callback = dev->pm_domain->ops.prepare;
@@ -1960,7 +1958,8 @@ unlock:*/ spin_lock_irq (&dev->power.lock); dev->power.direct_complete = state.event ==PM_EVENT_SUSPEND && -pm_runtime_suspended (dev) && ret >0 && + ((pm_runtime_suspended (dev) && ret >0 ) || + dev->power.no_pm_callbacks) && !dev_pm_test_driver_flags (dev,DPM_FLAG_NEVER_SKIP );spin_unlock_irq (&dev->power.lock);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 13/272 ALSA: timer: Fix pause event notification
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
commit 3ae180972564846e6d794e3615e1ab0a1e6c4ef9 upstream.
Commit f65e0d299807 ("ALSA: timer: Call notifier in the same spinlock") combined the start/continue and stop/pause functions, and in doing so changed the event code for the pause case to SNDRV_TIMER_EVENT_CONTINUE. Change it back to SNDRV_TIMER_EVENT_PAUSE.
--- sound/core/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/timer.c +2 -2
@@ -592,7 +592,7 @@ static int snd_timer_stop1(struct snd_tielse timeri->flags |=SNDRV_TIMER_IFLG_PAUSED ;snd_timer_notify1 (timeri, stop ?SNDRV_TIMER_EVENT_STOP : -SNDRV_TIMER_EVENT_CONTINUE ); +SNDRV_TIMER_EVENT_PAUSE ); unlock:spin_unlock_irqrestore (&timer->lock, flags);return result;
@@ -614,7 +614,7 @@ static int snd_timer_stop_slave(struct slist_del_init (&timeri->ack_list);list_del_init (&timeri->active_list);snd_timer_notify1 (timeri, stop ?SNDRV_TIMER_EVENT_STOP : -SNDRV_TIMER_EVENT_CONTINUE ); +SNDRV_TIMER_EVENT_PAUSE );spin_unlock (&timeri->timer->lock); }spin_unlock_irqrestore (&slave_active_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 40/272 KVM: s390: vsie: fix < 8k check for the itdba
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
commit f4a551b72358facbbe5714248dff78404272feee upstream.
By missing an "L", we might detect some addresses to be <8k, although they are not.
e.g. for itdba = 100001fff
!(gpa & ~0x1fffU) -> 1
!(gpa & ~0x1fffUL) -> 0
So we would report a SIE validity intercept although everything is fine.
--- arch/s390/kvm/vsie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/vsie.c +1 -1
@@ -578,7 +578,7 @@ static int pin_blocks(struct kvm_vcpu *v gpa =READ_ONCE (scb_o->itdba) & ~0xffUL ;if (gpa && (scb_s->ecb &ECB_TE )) { -if (!(gpa & ~0x1fffU )) { +if (!(gpa & ~0x1fffUL )) { rc =set_validity_icpt (scb_s,0x0080U ); goto unpin; }
Greg Kroah-Hartman
maintainerPATCH 44/272 ARM: dts: sun4i: Fix incorrect clocks for displays
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pascal Roeleven <[email protected]>
commit 590b0c0cfc6162aeebbf43eaafb9753b56df1532 upstream.
Some displays on sun4i devices wouldn't properly stay on unless 'clk_ignore_unused' is used.
Change the duplicate clocks to the probably intended ones.
--- arch/arm/boot/dts/sun4i-a10.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/sun4i-a10.dtsi +3 -3
@@ -76,7 +76,7 @@ allwinner,pipeline = "de_fe0-de_be0-lcd0-hdmi"; clocks = <&ccu CLK_AHB_LCD0>, <&ccu CLK_AHB_HDMI0>, <&ccu CLK_AHB_DE_BE0>, <&ccu CLK_AHB_DE_FE0>, - <&ccu CLK_DE_BE0>, <&ccu CLK_AHB_DE_FE0>, + <&ccu CLK_DE_BE0>, <&ccu CLK_DE_FE0>, <&ccu CLK_TCON0_CH1>, <&ccu CLK_HDMI>, <&ccu CLK_DRAM_DE_FE0>, <&ccu CLK_DRAM_DE_BE0>; status = "disabled";
@@ -88,7 +88,7 @@ allwinner,pipeline = "de_fe0-de_be0-lcd0"; clocks = <&ccu CLK_AHB_LCD0>, <&ccu CLK_AHB_DE_BE0>, <&ccu CLK_AHB_DE_FE0>, <&ccu CLK_DE_BE0>, - <&ccu CLK_AHB_DE_FE0>, <&ccu CLK_TCON0_CH0>, + <&ccu CLK_DE_FE0>, <&ccu CLK_TCON0_CH0>, <&ccu CLK_DRAM_DE_FE0>, <&ccu CLK_DRAM_DE_BE0>; status = "disabled"; };
@@ -99,7 +99,7 @@ allwinner,pipeline = "de_fe0-de_be0-lcd0-tve0"; clocks = <&ccu CLK_AHB_TVE0>, <&ccu CLK_AHB_LCD0>, <&ccu CLK_AHB_DE_BE0>, <&ccu CLK_AHB_DE_FE0>, - <&ccu CLK_DE_BE0>, <&ccu CLK_AHB_DE_FE0>, + <&ccu CLK_DE_BE0>, <&ccu CLK_DE_FE0>, <&ccu CLK_TCON0_CH1>, <&ccu CLK_DRAM_TVE0>, <&ccu CLK_DRAM_DE_FE0>, <&ccu CLK_DRAM_DE_BE0>; status = "disabled";
Greg Kroah-Hartman
maintainerPATCH 16/272 mmc: sdhci-iproc: remove hard coded mmc cap 1.8v
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinath Mannam <[email protected]>
commit 4c94238f37af87a2165c3fb491b4a8b50e90649c upstream.
Remove hard coded mmc cap 1.8v from platform data as it is board specific. The 1.8v DDR mmc caps can be enabled using DTS property for those boards that support it.
--- drivers/mmc/host/sdhci-iproc.c | 1 - 1 file changed, 1 deletion(-)
drivers/mmc/host/sdhci-iproc.c +0 -1
@@ -206,7 +206,6 @@ static const struct sdhci_iproc_data ipr .caps1 = SDHCI_DRIVER_TYPE_C | SDHCI_DRIVER_TYPE_D | SDHCI_SUPPORT_DDR50, - .mmc_caps = MMC_CAP_1_8V_DDR, };static const struct sdhci_pltfm_data sdhci_bcm2835_pltfm_data = {
Greg Kroah-Hartman
maintainerPATCH 17/272 mmc: sdhci-iproc: fix 32bit writes for TRANSFER_MODE register
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corneliu Doban <[email protected]>
commit 5f651b870485ee60f5abbbd85195a6852978894a upstream.
When the host controller accepts only 32bit writes, the value of the 16bit TRANSFER_MODE register, that has the same 32bit address as the 16bit COMMAND register, needs to be saved and it will be written in a 32bit write together with the command as this will trigger the host to send the command on the SD interface.
When sending the tuning command, TRANSFER_MODE is written and then sdhci_set_transfer_mode reads it back to clear AUTO_CMD12 bit and write it again resulting in wrong value to be written because the initial write value was saved in a shadow and the read-back returned a wrong value, from the register.
Fix sdhci_iproc_readw to return the saved value of TRANSFER_MODE when a saved value exist.
Same fix for read of BLOCK_SIZE and BLOCK_COUNT registers, that are saved for a different reason, although a scenario that will cause the mentioned problem on this registers is not probable.
--- drivers/mmc/host/sdhci-iproc.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
drivers/mmc/host/sdhci-iproc.c +25 -5
@@ -33,6 +33,8 @@ struct sdhci_iproc_host {const struct sdhci_iproc_data *data;u32 shadow_cmd;u32 shadow_blk; +bool is_cmd_shadowed; +bool is_blk_shadowed; };#define REG_OFFSET_IN_BITS (reg) ((reg) << 3 & 0x18)
@@ -48,8 +50,22 @@ static inline u32 sdhci_iproc_readl(strustatic u16 sdhci_iproc_readw (struct sdhci_host *host,int reg) { -u32 val =sdhci_iproc_readl (host, (reg & ~3 )); -u16 word = val >>REG_OFFSET_IN_BITS (reg) &0xffff ; +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_iproc_host *iproc_host =sdhci_pltfm_priv (pltfm_host); +u32 val; +u16 word; + +if ((reg ==SDHCI_TRANSFER_MODE ) && iproc_host->is_cmd_shadowed) { +/* Get the saved transfer mode */ + val = iproc_host->shadow_cmd; + }else if ((reg ==SDHCI_BLOCK_SIZE || reg ==SDHCI_BLOCK_COUNT ) && + iproc_host->is_blk_shadowed) { +/* Get the saved block info */ + val = iproc_host->shadow_blk; + }else { + val =sdhci_iproc_readl (host, (reg & ~3 )); + } + word = val >>REG_OFFSET_IN_BITS (reg) &0xffff ;return word; }
@@ -105,13 +121,15 @@ static void sdhci_iproc_writew(struct sdif (reg ==SDHCI_COMMAND ) {/* Write the block now as we are issuing a command */ -if (iproc_host->shadow_blk !=0 ) { +if (iproc_host->is_blk_shadowed) {sdhci_iproc_writel (host, iproc_host->shadow_blk,SDHCI_BLOCK_SIZE ); - iproc_host->shadow_blk =0 ; + iproc_host->is_blk_shadowed = false; } oldval = iproc_host->shadow_cmd; - }else if (reg ==SDHCI_BLOCK_SIZE || reg ==SDHCI_BLOCK_COUNT ) { + iproc_host->is_cmd_shadowed = false; + }else if ((reg ==SDHCI_BLOCK_SIZE || reg ==SDHCI_BLOCK_COUNT ) && + iproc_host->is_blk_shadowed) {/* Block size and count are stored in shadow reg */ oldval = iproc_host->shadow_blk; }else {
@@ -123,9 +141,11 @@ static void sdhci_iproc_writew(struct sdif (reg ==SDHCI_TRANSFER_MODE ) {/* Save the transfer mode until the command is issued */ iproc_host->shadow_cmd = newval; + iproc_host->is_cmd_shadowed = true; }else if (reg ==SDHCI_BLOCK_SIZE || reg ==SDHCI_BLOCK_COUNT ) {/* Save the block info until the command is issued */ iproc_host->shadow_blk = newval; + iproc_host->is_blk_shadowed = true; }else {/* Command or other regular 32-bit write */ sdhci_iproc_writel (host, newval, reg & ~3 );
Greg Kroah-Hartman
maintainerPATCH 18/272 mmc: sdhci-iproc: add SDHCI_QUIRK2_HOST_OFF_CARD_ON for cygnus
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corneliu Doban <[email protected]>
commit 3de06d5a1f05c11c94cbb68af14dbfa7fb81d78b upstream.
The SDHCI_QUIRK2_HOST_OFF_CARD_ON is needed for the driver to properly reset the host controller (reset all) on initialization after exiting deep sleep.
--- drivers/mmc/host/sdhci-iproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-iproc.c +1 -1
@@ -186,7 +186,7 @@ static const struct sdhci_ops sdhci_iprostatic const struct sdhci_pltfm_data sdhci_iproc_cygnus_pltfm_data = { .quirks =SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK , - .quirks2 =SDHCI_QUIRK2_ACMD23_BROKEN , + .quirks2 =SDHCI_QUIRK2_ACMD23_BROKEN |SDHCI_QUIRK2_HOST_OFF_CARD_ON , .ops = &sdhci_iproc_32only_ops, };
Greg Kroah-Hartman
maintainerPATCH 46/272 firmware: dmi_scan: Fix UUID length safety check
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean Delvare <[email protected]>
[ Upstream commit 90fe6f8ff00a07641ca893d64f75ca22ce77cca2 ]
The test which ensures that the DMI type 1 structure is long enough to hold the UUID is off by one. It would fail if the structure is exactly 24 bytes long, while that's sufficient to hold the UUID.
I don't expect this bug to cause problem in practice because all implementations I have seen had length 8, 25 or 27 bytes, in line with the SMBIOS specifications. But let's fix it still.
--- drivers/firmware/dmi_scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/dmi_scan.c +1 -1
@@ -186,7 +186,7 @@ static void __init dmi_save_uuid(const schar *s;int is_ff =1 , is_00 =1 , i; -if (dmi_ident[slot] || dm->length <= index +16 ) +if (dmi_ident[slot] || dm->length < index +16 )return ; d = (u8 *) dm + index;
Greg Kroah-Hartman
maintainerPATCH 55/272 kasan: fix invalid-free test crashing the kernel
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Konovalov <[email protected]>
[ Upstream commit 91c93ed07f04f5b32a30321d522d8ca9504745bf ]
When an invalid-free is triggered by one of the KASAN tests, the object doesn't actually get freed. This later leads to a BUG failure in kmem_cache_destroy that checks that there are no allocated objects in the cache that is being destroyed.
Fix this by calling kmem_cache_free with the proper object address after the call that triggers invalid-free.
--- lib/test_kasan.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/test_kasan.c +8 -0
@@ -567,7 +567,15 @@ static noinline void __init kmem_cache_ireturn ; } +/* Trigger invalid free, the object doesn't get freed */ kmem_cache_free (cache, p +1 ); + +/* +* Properly free the object to prevent the "Objects remaining in +* test_cache on __kmem_cache_shutdown" BUG failure. +*/ +kmem_cache_free (cache, p); +kmem_cache_destroy (cache); }
Greg Kroah-Hartman
maintainerPATCH 56/272 kasan, slub: fix handling of kasan_slab_free hook
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Konovalov <[email protected]>
[ Upstream commit c3895391df385c6628638f014c87e16f5e2efd45 ]
The kasan_slab_free hook's return value denotes whether the reuse of a slab object must be delayed (e.g. when the object is put into memory qurantine).
The current way SLUB handles this hook is by ignoring its return value and hardcoding checks similar (but not exactly the same) to the ones performed in kasan_slab_free, which is prone to making mistakes.
The main difference between the hardcoded checks and the ones in kasan_slab_free is whether we want to perform a free in case when an invalid-free or a double-free was detected (we don't).
This patch changes the way SLUB handles this by:
1. taking into account the return value of kasan_slab_free for each of the objects, that are being freed;
2. reconstructing the freelist of objects to exclude the ones, whose reuse must be delayed.
--- mm/slub.c | 57 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 23 deletions(-)
mm/slub.c +34 -23
@@ -1362,10 +1362,8 @@ static __always_inline void kfree_hook(vkasan_kfree_large (x, _RET_IP_); } -static __always_inline void *slab_free_hook(struct kmem_cache *s, void *x) +static __always_inline bool slab_free_hook(struct kmem_cache *s, void *x) { -void *freeptr; -kmemleak_free_recursive (x, s->flags);/*
@@ -1385,17 +1383,12 @@ static __always_inline void *slab_free_hif (!(s->flags &SLAB_DEBUG_OBJECTS ))debug_check_no_obj_freed (x, s->object_size); - freeptr =get_freepointer (s, x); -/* -* kasan_slab_free() may put x into memory quarantine, delaying its -* reuse. In this case the object's freelist pointer is changed. -*/ -kasan_slab_free (s, x, _RET_IP_); -return freeptr; +/* KASAN might put x into memory quarantine, delaying its reuse */ +return kasan_slab_free (s, x, _RET_IP_); } -static inline void slab_free_freelist_hook (struct kmem_cache *s, -void *head,void *tail) +static inline bool slab_free_freelist_hook (struct kmem_cache *s, +void **head,void **tail) {/* * Compiler cannot detect this function can be removed if slab_free_hook()
@@ -1406,13 +1399,33 @@ static inline void slab_free_freelist_hodefined (CONFIG_DEBUG_OBJECTS_FREE ) || \defined (CONFIG_KASAN ) - void *object = head; -void *tail_obj = tail ? : head; -void *freeptr; + void *object; +void *next = *head; +void *old_tail = *tail ? *tail : *head; + +/* Head and tail of the reconstructed freelist */ + *head =NULL ; + *tail =NULL ;do { - freeptr =slab_free_hook (s, object); - }while ((object != tail_obj) && (object = freeptr)); + object = next; + next =get_freepointer (s, object); +/* If object's reuse doesn't have to be delayed */ +if (!slab_free_hook (s, object)) { +/* Move object to the new freelist */ +set_freepointer (s, object, *head); + *head = object; +if (!*tail) + *tail = object; + } + }while (object != old_tail); + +if (*head == *tail) + *tail =NULL ; + +return *head !=NULL ; +#else +return true;#endif }
@@ -2965,14 +2978,12 @@ static __always_inline void slab_free(st void *head, void *tail, int cnt, unsigned long addr) { -slab_free_freelist_hook (s ,head ,tail ); /* -* slab_free_freelist_hook() could have put the items into quarantine. -* If so, no need to free them. + * With KASAN enabled slab_free_freelist_hook modifies the freelist + * to remove objects, whose reuse must be delayed. */ -if (s->flags &SLAB_KASAN && !(s->flags &SLAB_TYPESAFE_BY_RCU )) -return ; -do_slab_free (s, page, head, tail, cnt, addr); + if (slab_free_freelist_hook(s, &head, &tail)) + do_slab_free(s, page, head, tail, cnt, addr); }#ifdef CONFIG_KASAN
Greg Kroah-Hartman
maintainerPATCH 57/272 swap: divide-by-zero when zero length swap file on ssd
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Abraham <[email protected]>
[ Upstream commit a06ad633a37c64a0cd4c229fc605cee8725d376e ]
Calling swapon() on a zero length swap file on SSD can lead to a divide-by-zero.
Although creating such files isn't possible with mkswap and they woud be considered invalid, it would be better for the swapon code to be more robust and handle this condition gracefully (return -EINVAL). Especially since the fix is small and straightforward.
To help with wear leveling on SSD, the swapon syscall calculates a random position in the swap file using modulo p->highest_bit, which is set to maxpages - 1 in read_swap_header.
If the swap file is zero length, read_swap_header sets maxpages=1 and last_page=0, resulting in p->highest_bit=0 and we divide-by-zero when we modulo p->highest_bit in swapon syscall.
This can be prevented by having read_swap_header return zero if last_page is zero.
--- mm/swapfile.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/swapfile.c +4 -0
@@ -2961,6 +2961,10 @@ static unsigned long read_swap_header(st maxpages =swp_offset (pte_to_swp_entry (swp_entry_to_pte (swp_entry (0 , ~0UL )))) +1 ; last_page = swap_header->info.last_page; +if (!last_page) { +pr_warn ("Empty swap-file\n" ); +return 0 ; + }if (last_page > maxpages) { pr_warn("Truncating oversized swap area, only using %luk out of %luk\n", maxpages << (PAGE_SHIFT - 10),
Greg Kroah-Hartman
maintainerPATCH 58/272 z3fold: fix memory leak
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xidong Wang <[email protected]>
[ Upstream commit 1ec6995d1290bfb87cc3a51f0836c889e857cef9 ]
In z3fold_create_pool(), the memory allocated by __alloc_percpu() is not released on the error path that pool->compact_wq , which holds the return value of create_singlethread_workqueue(), is NULL. This will result in a memory leak bug.
--- mm/z3fold.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
mm/z3fold.c +7 -2
@@ -469,6 +469,8 @@ static struct z3fold_pool *z3fold_createspin_lock_init (&pool->lock);spin_lock_init (&pool->stale_lock); pool->unbuddied =__alloc_percpu (sizeof (struct list_head )*NCHUNKS ,2 ); +if (!pool->unbuddied) + goto out_pool;for_each_possible_cpu (cpu) {struct list_head *unbuddied =per_cpu_ptr (pool->unbuddied, cpu);
@@ -481,7 +483,7 @@ static struct z3fold_pool *z3fold_create pool->name = name; pool->compact_wq =create_singlethread_workqueue (pool->name);if (!pool->compact_wq) - goto out; + goto out_unbuddied; pool->release_wq =create_singlethread_workqueue (pool->name);if (!pool->release_wq) goto out_wq;
@@ -491,8 +493,11 @@ static struct z3fold_pool *z3fold_create out_wq:destroy_workqueue (pool->compact_wq); -out: +out_unbuddied: +free_percpu (pool->unbuddied); +out_pool:kfree (pool); +out:return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 59/272 sr: get/drop reference to device in revalidate and check_events
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit 2d097c50212e137e7b53ffe3b37561153eeba87d ]
We can't just use scsi_cd() to get the scsi_cd structure, we have to grab a live reference to the device. For both callbacks, we're not inside an open where we already hold a reference to the device.
This fixes device removal/addition under concurrent device access, which otherwise could result in the below oops.
NULL pointer dereference at 0000000000000010
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP Modules linked in:
sr 12:0:0:0: [sr2] scsi-1 drive
scsi_debug crc_t10dif crct10dif_generic crct10dif_common nvme nvme_core sb_edac xl
sr 12:0:0:0: Attached scsi CD-ROM sr2
sr_mod cdrom btrfs xor zstd_decompress zstd_compress xxhash lzo_compress zlib_defc
sr 12:0:0:0: Attached scsi generic sg7 type 5
igb ahci libahci i2c_algo_bit libata dca [last unloaded: crc_t10dif]
CPU: 43 PID: 4629 Comm: systemd-udevd Not tainted 4.16.0+ #650 Hardware name: Dell Inc. PowerEdge T630/0NT78X, BIOS 2.3.4 11/09/2016 RIP: 0010:sr_block_revalidate_disk+0x23/0x190 [sr_mod] RSP: 0018:ffff883ff357bb58 EFLAGS: 00010292 RAX: ffffffffa00b07d0 RBX: ffff883ff3058000 RCX: ffff883ff357bb66 RDX: 0000000000000003 RSI: 0000000000007530 RDI: ffff881fea631000 RBP: 0000000000000000 R08: ffff881fe4d38400 R09: 0000000000000000 R10: 0000000000000000 R11: 00000000000001b6 R12: 000000000800005d R13: 000000000800005d R14: ffff883ffd9b3790 R15: 0000000000000000 FS: 00007f7dc8e6d8c0(0000) GS:ffff883fff340000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000010 CR3: 0000003ffda98005 CR4: 00000000003606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? __invalidate_device+0x48/0x60 check_disk_change+0x4c/0x60 sr_block_open+0x16/0xd0 [sr_mod] __blkdev_get+0xb9/0x450 ? iget5_locked+0x1c0/0x1e0 blkdev_get+0x11e/0x320 ? bdget+0x11d/0x150 ? _raw_spin_unlock+0xa/0x20 ? bd_acquire+0xc0/0xc0 do_dentry_open+0x1b0/0x320 ? inode_permission+0x24/0xc0 path_openat+0x4e6/0x1420 ? cpumask_any_but+0x1f/0x40 ? flush_tlb_mm_range+0xa0/0x120 do_filp_open+0x8c/0xf0 ? __seccomp_filter+0x28/0x230 ? _raw_spin_unlock+0xa/0x20 ? __handle_mm_fault+0x7d6/0x9b0 ? list_lru_add+0xa8/0xc0 ? _raw_spin_unlock+0xa/0x20 ? __alloc_fd+0xaf/0x160 ? do_sys_open+0x1a6/0x230 do_sys_open+0x1a6/0x230 do_syscall_64+0x5a/0x100 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
--- drivers/scsi/sr.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/scsi/sr.c +15 -4
@@ -585,18 +585,28 @@ out:static unsigned int sr_block_check_events (struct gendisk *disk,unsigned int clearing) { -struct scsi_cd *cd =scsi_cd (disk); +unsigned int ret =0 ; +struct scsi_cd *cd; -if (atomic_read (&cd->device->disk_events_disable_depth)) + cd =scsi_cd_get (disk); +if (!cd)return 0 ; -return cdrom_check_events (&cd->cdi, clearing); +if (!atomic_read (&cd->device->disk_events_disable_depth)) + ret =cdrom_check_events (&cd->cdi, clearing); + +scsi_cd_put (cd); +return ret; }static int sr_block_revalidate_disk (struct gendisk *disk) { -struct scsi_cd *cd =scsi_cd (disk);struct scsi_sense_hdr sshdr; +struct scsi_cd *cd; + + cd =scsi_cd_get (disk); +if (!cd) +return -ENXIO ;/* if the unit is not ready, nothing more to do */ if (scsi_test_unit_ready (cd->device,SR_TIMEOUT ,MAX_RETRIES , &sshdr))
@@ -605,6 +615,7 @@ static int sr_block_revalidate_disk(strusr_cd_check (&cd->cdi);get_sectorsize (cd); out: +scsi_cd_put (cd);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 60/272 Force log to disk before reading the AGF during a fstrim
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Maiolino <[email protected]>
[ Upstream commit 8c81dd46ef3c416b3b95e3020fb90dbd44e6140b ]
Forcing the log to disk after reading the agf is wrong, we might be calling xfs_log_force with XFS_LOG_SYNC with a metadata lock held.
This can cause a deadlock when racing a fstrim with a filesystem shutdown.
The deadlock has been identified due a miscalculation bug in device-mapper dm-thin, which returns lack of space to its users earlier than the device itself really runs out of space, changing the device-mapper volume into an error state.
The problem happened while filling the filesystem with a single file, triggering the bug in device-mapper, consequently causing an IO error and shutting down the filesystem.
If such file is removed, and fstrim executed before the XFS finishes the shut down process, the fstrim process will end up holding the buffer lock, and going to sleep on the cil wait queue.
At this point, the shut down process will try to wake up all the threads waiting on the cil wait queue, but for this, it will try to hold the same buffer log already held my the fstrim, locking up the filesystem.
--- fs/xfs/xfs_discard.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/xfs/xfs_discard.c +7 -7
@@ -50,19 +50,19 @@ xfs_trim_extents( pag =xfs_perag_get (mp, agno); - error =xfs_alloc_read_agf (mp,NULL , agno,0 , &agbp); -if (error || !agbp) - goto out_put_perag; - - cur =xfs_allocbt_init_cursor (mp,NULL , agbp, agno,XFS_BTNUM_CNT ); -/* * Force out the log. This means any transactions that might have freed -* space before we took the AGF buffer lock are now on disk, and the +* space before we take the AGF buffer lock are now on disk, and the * volatile disk cache is flushed. */ xfs_log_force (mp,XFS_LOG_SYNC ); + error =xfs_alloc_read_agf (mp,NULL , agno,0 , &agbp); +if (error || !agbp) + goto out_put_perag; + + cur =xfs_allocbt_init_cursor (mp,NULL , agbp, agno,XFS_BTNUM_CNT ); +/* * Look up the longest btree in the AGF and start with it. */
Greg Kroah-Hartman
maintainerPATCH 61/272 cpufreq: CPPC: Initialize shared perf capabilities of CPUs
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shunyong Yang <[email protected]>
[ Upstream commit 8913315e9459b146e5888ab5138e10daa061b885 ]
When multiple CPUs are related in one cpufreq policy, the first online CPU will be chosen by default to handle cpufreq operations. Let's take cpu0 and cpu1 as an example.
When cpu0 is offline, policy->cpu will be shifted to cpu1. cpu1's perf capabilities should be initialized. Otherwise, perf capabilities are 0s and speed change can not take effect.
This patch copies perf capabilities of the first online CPU to other shared CPUs when policy shared type is CPUFREQ_SHARED_TYPE_ANY.
--- drivers/cpufreq/cppc_cpufreq.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +12 -2
@@ -167,9 +167,19 @@ static int cppc_cpufreq_cpu_init(structNSEC_PER_USEC ; policy->shared_type = cpu->shared_type; -if (policy->shared_type ==CPUFREQ_SHARED_TYPE_ANY ) +if (policy->shared_type ==CPUFREQ_SHARED_TYPE_ANY ) { +int i; +cpumask_copy (policy->cpus, cpu->shared_cpu_map); -else if (policy->shared_type ==CPUFREQ_SHARED_TYPE_ALL ) { + +for_each_cpu (i, policy->cpus) { +if (unlikely (i == policy->cpu)) +continue ; + +memcpy (&all_cpu_data[i]->perf_caps, &cpu->perf_caps, +sizeof (cpu->perf_caps)); + } + }else if (policy->shared_type ==CPUFREQ_SHARED_TYPE_ALL ) {/* Support only SW_ANY for now. */ pr_debug ("Unsupported CPU co-ord type\n" );return -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 62/272 powerpc/fscr: Enable interrupts earlier before calling get_user()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshuman Khandual <[email protected]>
[ Upstream commit 709b973c844c0b4d115ac3a227a2e5a68722c912 ]
The function get_user() can sleep while trying to fetch instruction from user address space and causes the following warning from the scheduler.
BUG: sleeping function called from invalid context
Though interrupts get enabled back but it happens bit later after get_user() is called. This change moves enabling these interrupts earlier covering the function get_user(). While at this, lets check for kernel mode and crash as this interrupt should not have been triggered from the kernel context.
--- arch/powerpc/kernel/traps.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
arch/powerpc/kernel/traps.c +17 -15
@@ -1612,6 +1612,22 @@ void facility_unavailable_exception(stru value =mfspr (SPRN_FSCR ); status = value >>56 ; +if ((hv || status >=2 ) && + (status <ARRAY_SIZE (facility_strings)) && + facility_strings[status]) + facility = facility_strings[status]; + +/* We should not have taken this interrupt in kernel */ +if (!user_mode (regs)) { +pr_emerg ("Facility '%s' unavailable (%d) exception in kernel mode at %lx\n" , + facility, status, regs->nip); +die ("Unexpected facility unavailable exception" , regs,SIGABRT ); + } + +/* We restore the interrupt state now */ +if (!arch_irq_disabled_regs (regs)) +local_irq_enable (); +if (status ==FSCR_DSCR_LG ) {/* * User is accessing the DSCR register using the problem
@@ -1678,25 +1694,11 @@ void facility_unavailable_exception(stru return; } -if ((hv || status >=2 ) && - (status <ARRAY_SIZE (facility_strings)) && - facility_strings[status]) - facility = facility_strings[status]; - -/* We restore the interrupt state now */ -if (!arch_irq_disabled_regs (regs)) -local_irq_enable (); -pr_err_ratelimited ("%sFacility '%s' unavailable (%d), exception at 0x%lx, MSR=%lx\n" , hv ?"Hypervisor " :"" , facility, status, regs->nip, regs->msr); out: -if (user_mode (regs)) { -_exception (SIGILL , regs,ILL_ILLOPC , regs->nip); -return ; - } - -die ("Unexpected facility unavailable exception" , regs,SIGABRT ); +_exception (SIGILL , regs,ILL_ILLOPC , regs->nip); }#endif
Greg Kroah-Hartman
maintainerPATCH 65/272 dp83640: Ensure against premature access to PHY registers after reset
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esben Haabendal <[email protected]>
[ Upstream commit 76327a35caabd1a932e83d6a42b967aa08584e5d ]
The datasheet specifies a 3uS pause after performing a software reset. The default implementation of genphy_soft_reset() does not provide this, so implement soft_reset with the needed pause.
--- drivers/net/phy/dp83640.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/phy/dp83640.c +18 -0
@@ -1207,6 +1207,23 @@ static void dp83640_remove(struct phy_dekfree (dp83640); } +static int dp83640_soft_reset (struct phy_device *phydev) +{ +int ret; + + ret =genphy_soft_reset (phydev); +if (ret <0 ) +return ret; + +/* From DP83640 datasheet: "Software driver code must wait 3 us +* following a software reset before allowing further serial MII +* operations with the DP83640." +*/ +udelay (10 );/* Taking udelay inaccuracy into account */ + +return 0 ; +} +static int dp83640_config_init (struct phy_device *phydev) {struct dp83640_private *dp83640 = phydev->priv;
@@ -1501,6 +1518,7 @@ static struct phy_driver dp83640_driver .flags = PHY_HAS_INTERRUPT, .probe = dp83640_probe, .remove = dp83640_remove, + .soft_reset = dp83640_soft_reset, .config_init = dp83640_config_init, .ack_interrupt = dp83640_ack_interrupt, .config_intr = dp83640_config_intr,
Greg Kroah-Hartman
maintainerPATCH 66/272 ibmvnic: Zero used TX descriptor counter on reset
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Falcon <[email protected]>
[ Upstream commit 41f714672f93608751dbd2fa2291d476a8ff0150 ]
The counter that tracks used TX descriptors pending completion needs to be zeroed as part of a device reset. This change fixes a bug causing transmit queues to be stopped unnecessarily and in some cases a transmit queue stall and timeout reset. If the counter is not reset, the remaining descriptors will not be "removed", effectively reducing queue capacity. If the queue is over half full, it will cause the queue to stall if stopped.
--- drivers/net/ethernet/ibm/ibmvnic.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/ibm/ibmvnic.c +1 -0
@@ -2266,6 +2266,7 @@ static int reset_one_sub_crq_queue(struc }memset (scrq->msgs,0 ,4 *PAGE_SIZE ); +atomic_set (&scrq->used,0 ); scrq->cur =0 ; rc = h_reg_sub_crq(adapter->vdev->unit_address, scrq->msg_token,
Greg Kroah-Hartman
maintainerPATCH 67/272 genirq/affinity: Dont return with empty affinity masks on error
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
[ Upstream commit 0211e12dd0a5385ecffd3557bc570dbad7fcf245 ]
When the allocation of node_to_possible_cpumask fails, then irq_create_affinity_masks() returns with a pointer to the empty affinity masks array, which will cause malfunction.
Reorder the allocations so the masks array allocation comes last and every failure path returns NULL.
--- kernel/irq/affinity.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
kernel/irq/affinity.c +8 -7
@@ -108,7 +108,7 @@ irq_create_affinity_masks(int nvecs, conint affv = nvecs - affd->pre_vectors - affd->post_vectors;int last_affv = affv + affd->pre_vectors;nodemask_t nodemsk =NODE_MASK_NONE ; -struct cpumask *masks; +struct cpumask *masks =NULL ;cpumask_var_t nmsk, *node_to_possible_cpumask;/*
@@ -121,13 +121,13 @@ irq_create_affinity_masks(int nvecs, conif (!zalloc_cpumask_var (&nmsk,GFP_KERNEL ))return NULL ; - masks =kcalloc (nvecs,sizeof (*masks),GFP_KERNEL ); -if (!masks) - goto out; - node_to_possible_cpumask =alloc_node_to_possible_cpumask ();if (!node_to_possible_cpumask) - goto out; + goto outcpumsk; + + masks =kcalloc (nvecs,sizeof (*masks),GFP_KERNEL ); +if (!masks) + goto outnodemsk;/* Fill out vectors at the beginning that don't need affinity */ for (curvec =0 ; curvec < affd->pre_vectors; curvec++)
@@ -192,8 +192,9 @@ done:/* Fill out vectors at the end that don't need affinity */ for (; curvec < nvecs; curvec++)cpumask_copy (masks + curvec, irq_default_affinity); +outnodemsk:free_node_to_possible_cpumask (node_to_possible_cpumask); -out: +outcpumsk:free_cpumask_var (nmsk);return masks; }
Greg Kroah-Hartman
maintainerPATCH 68/272 mm/ksm: fix interaction with THP
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudio Imbrenda <[email protected]>
[ Upstream commit 77da2ba0648a4fd52e5ff97b8b2b8dd312aec4b0 ]
This patch fixes a corner case for KSM. When two pages belong or belonged to the same transparent hugepage, and they should be merged, KSM fails to split the page, and therefore no merging happens.
This bug can be reproduced by:
* making sure ksm is running (in case disabling ksmtuned)
* enabling transparent hugepages
* allocating a THP-aligned 1-THP-sized buffer e.g. on amd64: posix_memalign(&p, 1<<21, 1<<21)
* filling it with the same values
e.g. memset(p, 42, 1<<21)
* performing madvise to make it mergeable
e.g. madvise(p, 1<<21, MADV_MERGEABLE)
* waiting for KSM to perform a few scans
The expected outcome is that the all the pages get merged (1 shared and the rest sharing); the actual outcome is that no pages get merged (1 unshared and the rest volatile)
The reason of this behaviour is that we increase the reference count once for both pages we want to merge, but if they belong to the same hugepage (or compound page), the reference counter used in both cases is the one of the head of the compound page. This means that split_huge_page will find a value of the reference counter too high and will fail.
This patch solves this problem by testing if the two pages to merge belong to the same hugepage when attempting to merge them. If so, the hugepage is split safely. This means that the hugepage is not split if not necessary.
--- mm/ksm.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
mm/ksm.c +28 -0
@@ -2089,8 +2089,22 @@ static void cmp_and_merge_page(struct pa tree_rmap_item =unstable_tree_search_insert (rmap_item, page, &tree_page);if (tree_rmap_item) { +bool split; + kpage =try_to_merge_two_pages (rmap_item, page, tree_rmap_item, tree_page); +/* +* If both pages we tried to merge belong to the same compound +* page, then we actually ended up increasing the reference +* count of the same compound page twice, and split_huge_page +* failed. +* Here we set a flag if that happened, and we use it later to +* try split_huge_page again. Since we call put_page right +* afterwards, the reference count will be correct and +* split_huge_page should succeed. +*/ + split =PageTransCompound (page) + &&compound_head (page) ==compound_head (tree_page);put_page (tree_page);if (kpage) {/*
@@ -2117,6 +2131,20 @@ static void cmp_and_merge_page(struct pabreak_cow (tree_rmap_item);break_cow (rmap_item); } + }else if (split) { +/* +* We are here if we tried to merge two pages and +* failed because they both belonged to the same +* compound page. We will split the page now, but no +* merging will take place. +* We do not want to add the cost of a full lock; if +* the page is locked, it is better to skip it and +* perhaps try again later. +*/ +if (!trylock_page (page)) +return ; +split_huge_page (page); +unlock_page (page); } } }
Greg Kroah-Hartman
maintainerPATCH 69/272 mm: fix races between address_space dereference and free in page_evicatable
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huang Ying <[email protected]>
[ Upstream commit e92bb4dd9673945179b1fc738c9817dd91bfb629 ]
When page_mapping() is called and the mapping is dereferenced in page_evicatable() through shrink_active_list(), it is possible for the inode to be truncated and the embedded address space to be freed at the same time. This may lead to the following race.
CPU1 CPU2
truncate(inode) shrink_active_list()
... page_evictable(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
mapping_unevictable(mapping) test_bit(AS_UNEVICTABLE, &mapping->flags);
- we've dereferenced mapping which is potentially already free.
Similar race exists between swap cache freeing and page_evicatable() too.
The address_space in inode and swap cache will be freed after a RCU grace period. So the races are fixed via enclosing the page_mapping() and address_space usage in rcu_read_lock/unlock(). Some comments are added in code to make it clear what is protected by the RCU read lock.
--- mm/vmscan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
mm/vmscan.c +7 -1
@@ -3896,7 +3896,13 @@ int node_reclaim(struct pglist_data *pgd*/ int page_evictable (struct page *page) { -return !mapping_unevictable (page_mapping (page)) && !PageMlocked (page); +int ret; + +/* Prevent address_space of inode and swap cache from being freed */ +rcu_read_lock (); + ret = !mapping_unevictable (page_mapping (page)) && !PageMlocked (page); +rcu_read_unlock (); +return ret; }#ifdef CONFIG_SHMEM
Greg Kroah-Hartman
maintainerPATCH 70/272 mm: thp: fix potential clearing to referenced flag in page_idle_clear_pte_refs_one()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Shi <[email protected]>
[ Upstream commit f0849ac0b8e072073ec5fcc7fadd05a77434364e ]
For PTE-mapped THP, the compound THP has not been split to normal 4K pages yet, the whole THP is considered referenced if any one of sub page is referenced.
When walking PTE-mapped THP by pvmw, all relevant PTEs will be checked to retrieve referenced bit. But, the current code just returns the result of the last PTE. If the last PTE has not referenced, the referenced flag will be cleared.
Just set referenced when ptep{pmdp}_clear_young_notify() returns true.
--- mm/page_idle.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
mm/page_idle.c +8 -4
@@ -65,11 +65,15 @@ static bool page_idle_clear_pte_refs_onewhile (page_vma_mapped_walk (&pvmw)) { addr = pvmw.address;if (pvmw.pte) { - referenced =ptep_clear_young_notify (vma, addr, - pvmw.pte); +/* +* For PTE-mapped THP, one sub page is referenced, +* the whole THP is referenced. +*/ +if (ptep_clear_young_notify (vma, addr, pvmw.pte)) + referenced = true; }else if (IS_ENABLED (CONFIG_TRANSPARENT_HUGEPAGE )) { - referenced =pmdp_clear_young_notify (vma, addr, - pvmw.pmd); +if (pmdp_clear_young_notify (vma, addr, pvmw.pmd)) + referenced = true; }else {/* unexpected pmd-mapped page? */ WARN_ON_ONCE (1 );
Greg Kroah-Hartman
maintainerPATCH 71/272 Btrfs: bail out on error during replay_dir_deletes
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Bo <[email protected]>
[ Upstream commit b98def7ca6e152ee55e36863dddf6f41f12d1dc6 ]
If errors were returned by btrfs_next_leaf(), replay_dir_deletes needs to bail out, otherwise @ret would be forced to be 0 after 'break;' and the caller won't be aware of it.
--- fs/btrfs/tree-log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/tree-log.c +3 -1
@@ -2356,8 +2356,10 @@ again: nritems =btrfs_header_nritems (path->nodes[0 ]);if (path->slots[0 ] >= nritems) { ret =btrfs_next_leaf (root, path); -if (ret) +if (ret ==1 )break ; +else if (ret <0 ) + goto out; }btrfs_item_key_to_cpu (path->nodes[0 ], &found_key, path->slots[0 ]);
Greg Kroah-Hartman
maintainerPATCH 72/272 Btrfs: fix NULL pointer dereference in log_dir_items
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Bo <[email protected]>
[ Upstream commit 80c0b4210a963e31529e15bf90519708ec947596 ]
0, 1 and <0 can be returned by btrfs_next_leaf(), and when <0 is returned, path->nodes[0] could be NULL, log_dir_items lacks such a check for <0 and we may run into a null pointer dereference panic.
--- fs/btrfs/tree-log.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/tree-log.c +5 -2
@@ -3548,8 +3548,11 @@ static noinline int log_dir_items(struct* from this directory and from this transaction */ ret =btrfs_next_leaf (root, path); -if (ret ==1 ) { - last_offset = (u64)-1 ; +if (ret) { +if (ret ==1 ) + last_offset = (u64)-1 ; +else + err = ret; goto done; }btrfs_item_key_to_cpu (path->nodes[0 ], &tmp, path->slots[0 ]);
Greg Kroah-Hartman
maintainerPATCH 48/272 Btrfs: clean up resources during umount after trans is aborted
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Bo <[email protected]>
[ Upstream commit af7227338135d2f1b1552bf9a6d43e02dcba10b9 ]
Currently if some fatal errors occur, like all IO get -EIO, resources would be cleaned up when
a) transaction is being committed or
b) BTRFS_FS_STATE_ERROR is set
However, in some rare cases, resources may be left alone after transaction gets aborted and umount may run into some ASSERT(), e.g. ASSERT(list_empty(&block_group->dirty_list));
For case a), in btrfs_commit_transaciton(), there're several places at the beginning where we just call btrfs_end_transaction() without cleaning up resources. For case b), it is possible that the trans handle doesn't have any dirty stuff, then only trans hanlde is marked as aborted while BTRFS_FS_STATE_ERROR is not set, so resources remain in memory.
This makes btrfs also check BTRFS_FS_STATE_TRANS_ABORTED to make sure that all resources won't stay in memory after umount.
--- fs/btrfs/disk-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/disk-io.c +2 -1
@@ -3735,7 +3735,8 @@ void close_ctree(struct btrfs_fs_info *fbtrfs_err (fs_info,"commit super ret %d" , ret); } -if (test_bit (BTRFS_FS_STATE_ERROR , &fs_info->fs_state)) +if (test_bit (BTRFS_FS_STATE_ERROR , &fs_info->fs_state) || +test_bit (BTRFS_FS_STATE_TRANS_ABORTED , &fs_info->fs_state))btrfs_error_commit_super (fs_info);kthread_stop (fs_info->transaction_kthread);
Greg Kroah-Hartman
maintainerPATCH 52/272 bnxt_en: Ignore src port field in decap filter nodes
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sriharsha Basavapatna <[email protected]>
[ Upstream commit 479ca3bf91da971fcefc003cf5773e8d7db24794 ]
The driver currently uses src port field (along with other fields) in the decap tunnel key, while looking up and adding tunnel nodes. This leads to redundant cfa_decap_filter_alloc() requests to the FW and flow-miss in the flow engine. Fix this by ignoring the src port field in decap tunnel nodes.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +3 -1
@@ -992,8 +992,10 @@ static int bnxt_tc_get_decap_handle(stru/* Check if there's another flow using the same tunnel decap. * If not, add this tunnel to the table and resolve the other -* tunnel header fileds +* tunnel header fileds. Ignore src_port in the tunnel_key, +* since it is not required for decap filters. */ + decap_key->tp_src =0 ; decap_node =bnxt_tc_get_tunnel_node (bp, &tc_info->decap_table, &tc_info->decap_ht_params, decap_key);
Greg Kroah-Hartman
maintainerPATCH 53/272 nvme: expand nvmf_check_if_ready checks
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Smart <[email protected]>
[ Upstream commit bb06ec31452fb2da1594f88035c2ecea4e0652f4 ]
The nvmf_check_if_ready() checks that were added are very simplistic. As such, the routine allows a lot of cases to fail ios during windows of reset or re-connection. In cases where there are not multi-path options present, the error goes back to the callee - the filesystem or application. Not good.
The common routine was rewritten and calling syntax slightly expanded so that per-transport is_ready routines don't need to be present. The transports now call the routine directly. The routine is now a fabrics routine rather than an inline function.
The routine now looks at controller state to decide the action to take. Some states mandate io failure. Others define the condition where a command can be accepted. When the decision is unclear, a generic queue-or-reject check is made to look for failfast or multipath ios and only fails the io if it is so marked. Otherwise, the io will be queued and wait for the controller state to resolve.
Admin commands issued via ioctl share a live admin queue with commands from the transport for controller init. The ioctls could be intermixed with the initialization commands. It's possible for the ioctl cmd to be issued prior to the controller being enabled. To block this, the ioctl admin commands need to be distinguished from admin commands used for controller init. Added a USERCMD nvme_req(req)->rq_flags bit to reflect this division and set it on ioctls requests. As the nvmf_check_if_ready() routine is called prior to nvme_setup_cmd(), ensure that commands allocated by the ioctl path (actually anything in core.c) preps the nvme_req(req) before starting the io. This will preserve the USERCMD flag during execution and/or retry.
--- drivers/nvme/host/core.c | 17 ++++++--- drivers/nvme/host/fabrics.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/fabrics.h | 33 +----------------- drivers/nvme/host/fc.c | 12 +----- drivers/nvme/host/nvme.h | 1 drivers/nvme/host/rdma.c | 14 +------ drivers/nvme/target/loop.c | 11 +----- 7 files changed, 101 insertions(+), 66 deletions(-)
drivers/nvme/host/core.c +12 -5
@@ -379,6 +379,15 @@ static void nvme_put_ns(struct nvme_ns *kref_put (&ns->kref, nvme_free_ns); } +static inline void nvme_clear_nvme_request (struct request *req) +{ +if (!(req->rq_flags &RQF_DONTPREP )) { +nvme_req (req)->retries =0 ; +nvme_req (req)->flags =0 ; + req->rq_flags |=RQF_DONTPREP ; + } +} +struct request *nvme_alloc_request (struct request_queue *q,struct nvme_command *cmd,blk_mq_req_flags_t flags,int qid) {
@@ -395,6 +404,7 @@ struct request *nvme_alloc_request(strucreturn req; req->cmd_flags |=REQ_FAILFAST_DRIVER ; +nvme_clear_nvme_request (req);nvme_req (req)->cmd = cmd;return req;
@@ -611,11 +621,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ {blk_status_t ret =BLK_STS_OK ; -if (!(req->rq_flags &RQF_DONTPREP )) { -nvme_req (req)->retries =0 ; -nvme_req (req)->flags =0 ; - req->rq_flags |=RQF_DONTPREP ; - } +nvme_clear_nvme_request (req);switch (req_op (req)) {case REQ_OP_DRV_IN :
@@ -745,6 +751,7 @@ static int nvme_submit_user_cmd(struct rreturn PTR_ERR (req); req->timeout = timeout ? timeout :ADMIN_TIMEOUT ; +nvme_req (req)->flags |=NVME_REQ_USERCMD ;if (ubuffer && bufflen) { ret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen,
drivers/nvme/host/fabrics.c +79 -0
85 lines not on this page · raw message
drivers/nvme/host/fabrics.h +2 -31
@@ -157,36 +157,7 @@ void nvmf_unregister_transport(struct nvvoid nvmf_free_options (struct nvmf_ctrl_options *opts);int nvmf_get_address (struct nvme_ctrl *ctrl,char *buf,int size);bool nvmf_should_reconnect (struct nvme_ctrl *ctrl); - -static inline blk_status_t nvmf_check_init_req (struct nvme_ctrl *ctrl, -struct request *rq) -{ -struct nvme_command *cmd =nvme_req (rq)->cmd; - -/* -* We cannot accept any other command until the connect command has -* completed, so only allow connect to pass. -*/ -if (!blk_rq_is_passthrough (rq) || - cmd->common.opcode != nvme_fabrics_command || - cmd->fabrics.fctype != nvme_fabrics_type_connect) { -/* -* Connecting state means transport disruption or initial -* establishment, which can take a long time and even might -* fail permanently, fail fast to give upper layers a chance -* to failover. -* Deleting state means that the ctrl will never accept commands -* again, fail it permanently. -*/ -if (ctrl->state ==NVME_CTRL_CONNECTING || - ctrl->state ==NVME_CTRL_DELETING ) { -nvme_req (rq)->status =NVME_SC_ABORT_REQ ; -return BLK_STS_IOERR ; - } -return BLK_STS_RESOURCE ;/* try again later */ - } - -return BLK_STS_OK ; -} +blk_status_t nvmf_check_if_ready (struct nvme_ctrl *ctrl, +struct request *rq,bool queue_live,bool is_connected);#endif /* _NVME_FABRICS_H */
drivers/nvme/host/fc.c +3 -9
@@ -2284,14 +2284,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrlreturn BLK_STS_OK ; } -static inline blk_status_t nvme_fc_is_ready (struct nvme_fc_queue *queue, -struct request *rq) -{ -if (unlikely (!test_bit (NVME_FC_Q_LIVE , &queue->flags))) -return nvmf_check_init_req (&queue->ctrl->ctrl, rq); -return BLK_STS_OK ; -} -static blk_status_t nvme_fc_queue_rq (struct blk_mq_hw_ctx *hctx,const struct blk_mq_queue_data *bd)
@@ -2307,7 +2299,9 @@ nvme_fc_queue_rq(struct blk_mq_hw_ctx *hu32 data_len;blk_status_t ret; - ret =nvme_fc_is_ready (queue, rq); + ret =nvmf_check_if_ready (&queue->ctrl->ctrl, rq, +test_bit (NVME_FC_Q_LIVE , &queue->flags), + ctrl->rport->remoteport.port_state ==FC_OBJSTATE_ONLINE );if (unlikely (ret))return ret;
drivers/nvme/host/nvme.h +1 -0
@@ -109,6 +109,7 @@ struct nvme_request {enum {NVME_REQ_CANCELLED = (1 <<0 ), +NVME_REQ_USERCMD = (1 <<1 ), };static inline struct nvme_request *nvme_req (struct request *req)
drivers/nvme/host/rdma.c +2 -12
@@ -1594,17 +1594,6 @@ nvme_rdma_timeout(struct request *rq, boreturn BLK_EH_HANDLED ; } -/* -* We cannot accept any other command until the Connect command has completed. -*/ -static inline blk_status_t -nvme_rdma_is_ready (struct nvme_rdma_queue *queue,struct request *rq) -{ -if (unlikely (!test_bit (NVME_RDMA_Q_LIVE , &queue->flags))) -return nvmf_check_init_req (&queue->ctrl->ctrl, rq); -return BLK_STS_OK ; -} -static blk_status_t nvme_rdma_queue_rq (struct blk_mq_hw_ctx *hctx,const struct blk_mq_queue_data *bd) {
@@ -1620,7 +1609,8 @@ static blk_status_t nvme_rdma_queue_rq(sWARN_ON_ONCE (rq->tag <0 ); - ret =nvme_rdma_is_ready (queue, rq); + ret =nvmf_check_if_ready (&queue->ctrl->ctrl, rq, +test_bit (NVME_RDMA_Q_LIVE , &queue->flags), true);if (unlikely (ret))return ret;
drivers/nvme/target/loop.c +2 -9
@@ -149,14 +149,6 @@ nvme_loop_timeout(struct request *rq, boreturn BLK_EH_HANDLED ; } -static inline blk_status_t nvme_loop_is_ready (struct nvme_loop_queue *queue, -struct request *rq) -{ -if (unlikely (!test_bit (NVME_LOOP_Q_LIVE , &queue->flags))) -return nvmf_check_init_req (&queue->ctrl->ctrl, rq); -return BLK_STS_OK ; -} -static blk_status_t nvme_loop_queue_rq (struct blk_mq_hw_ctx *hctx,const struct blk_mq_queue_data *bd) {
@@ -166,7 +158,8 @@ static blk_status_t nvme_loop_queue_rq(sstruct nvme_loop_iod *iod =blk_mq_rq_to_pdu (req);blk_status_t ret; - ret =nvme_loop_is_ready (queue, req); + ret =nvmf_check_if_ready (&queue->ctrl->ctrl, req, +test_bit (NVME_LOOP_Q_LIVE , &queue->flags), true);if (unlikely (ret))return ret;
Greg Kroah-Hartman
maintainerPATCH 54/272 fs/proc/proc_sysctl.c: fix potential page fault while unregistering sysctl table
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danilo Krummrich <[email protected]>
[ Upstream commit a0b0d1c345d0317efe594df268feb5ccc99f651e ]
proc_sys_link_fill_cache() does not take currently unregistering sysctl tables into account, which might result into a page fault in sysctl_follow_link() - add a check to fix it.
This bug has been present since v3.4.
--- fs/proc/proc_sysctl.c | 3 +++ 1 file changed, 3 insertions(+)
fs/proc/proc_sysctl.c +3 -0
@@ -707,7 +707,10 @@ static bool proc_sys_link_fill_cache(str struct ctl_table *table) {bool ret = true; + head =sysctl_head_grab (head); +if (IS_ERR (head)) +return false;if (S_ISLNK (table->mode)) {/* It is not an error if we can not follow the link ignore it */
Greg Kroah-Hartman
maintainerPATCH 45/272 sh: fix debug trap failure to process signals before return to user
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rich Felker <[email protected]>
[ Upstream commit 96a598996f6ac518ac79839ecbb17c91af91f4f7 ]
When responding to a debug trap (breakpoint) in userspace, the kernel's trap handler raised SIGTRAP but returned from the trap via a code path that ignored pending signals, resulting in an infinite loop re-executing the trapping instruction.
--- arch/sh/kernel/entry-common.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/entry-common.S +1 -1
@@ -255,7 +255,7 @@ debug_trap: mov.l @r8, r8 jsr @r8 nop - bra __restore_all + bra ret_from_exception nop CFI_ENDPROC
Greg Kroah-Hartman
maintainerPATCH 81/272 fscache: Fix hanging wait on page discarded by writeback
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 2c98425720233ae3e135add0c7e869b32913502f ]
If the fscache asynchronous write operation elects to discard a page that's pending storage to the cache because the page would be over the store limit then it needs to wake the page as someone may be waiting on completion of the write.
The problem is that the store limit may be updated by a different asynchronous operation - and so may miss the write - and that the store limit may not even get updated until later by the netfs.
Fix the kernel hang by making fscache_write_op() mark as written any pages that are over the limit.
--- fs/fscache/page.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
fs/fscache/page.c +9 -4
@@ -776,6 +776,7 @@ static void fscache_write_op(struct fsca_enter ("{OP%x,%d}" , op->op.debug_id,atomic_read (&op->op.usage)); +again:spin_lock (&object->lock); cookie = object->cookie;
@@ -816,10 +817,6 @@ static void fscache_write_op(struct fsca goto superseded; page = results[0 ];_debug ("gang %d [%lx]" , n, page->index); -if (page->index >= op->store_limit) { -fscache_stat (&fscache_n_store_pages_over_limit); - goto superseded; - }radix_tree_tag_set (&cookie->stores, page->index,FSCACHE_COOKIE_STORING_TAG );
@@ -829,6 +826,9 @@ static void fscache_write_op(struct fscaspin_unlock (&cookie->stores_lock);spin_unlock (&object->lock); +if (page->index >= op->store_limit) + goto discard_page; +fscache_stat (&fscache_n_store_pages);fscache_stat (&fscache_n_cop_write_page); ret = object->cache->ops->write_page (op, page);
@@ -844,6 +844,11 @@ static void fscache_write_op(struct fsca_leave ("" );return ; +discard_page: +fscache_stat (&fscache_n_store_pages_over_limit); +fscache_end_page_write (object, page); + goto again; + superseded:/* this writer is going away and there aren't any more things to * write */
Greg Kroah-Hartman
maintainerPATCH 90/272 btrfs: tests/qgroup: Fix wrong tree backref level
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 3c0efdf03b2d127f0e40e30db4e7aa0429b1b79a ]
The extent tree of the test fs is like the following:
BTRFS info (device (null)): leaf 16327509003777336587 total ptrs 1 free space 3919
item 0 key (4096 168 4096) itemoff 3944 itemsize 51
extent refs 1 gen 1 flags 2
tree block key (68719476736 0 0) level 1
^^^^^^^
ref#0: tree block backref root 5
And it's using an empty tree for fs tree, so there is no way that its level can be 1.
For REAL (created by mkfs) fs tree backref with no skinny metadata, the result should look like:
item 3 key (30408704 EXTENT_ITEM 4096) itemoff 3845 itemsize 51
refs 1 gen 4 flags TREE_BLOCK
tree block key (256 INODE_ITEM 0) level 0
^^^^^^^
tree block backref root 5
Fix the level to 0, so it won't break later tree level checker.
--- fs/btrfs/tests/qgroup-tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tests/qgroup-tests.c +1 -1
@@ -63,7 +63,7 @@ static int insert_normal_tree_ref(structbtrfs_set_extent_generation (leaf, item,1 );btrfs_set_extent_flags (leaf, item,BTRFS_EXTENT_FLAG_TREE_BLOCK ); block_info = (struct btrfs_tree_block_info *)(item +1 ); -btrfs_set_tree_block_level (leaf, block_info,1 ); +btrfs_set_tree_block_level (leaf, block_info,0 ); iref = (struct btrfs_extent_inline_ref *)(block_info +1 );if (parent >0 ) { btrfs_set_extent_inline_ref_type(leaf, iref,
Greg Kroah-Hartman
maintainerPATCH 91/272 Btrfs: fix copy_items() return value when logging an inode
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 8434ec46c6e3232cebc25a910363b29f5c617820 ]
When logging an inode, at tree-log.c:copy_items(), if we call btrfs_next_leaf() at the loop which checks for the need to log holes, we need to make sure copy_items() returns the value 1 to its caller and not 0 (on success). This is because the path the caller passed was released and is now different from what is was before, and the caller expects a return value of 0 to mean both success and that the path has not changed, while a return value of 1 means both success and signals the caller that it can not reuse the path, it has to perform another tree search.
Even though this is a case that should not be triggered on normal circumstances or very rare at least, its consequences can be very unpredictable (especially when replaying a log tree).
--- fs/btrfs/tree-log.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/tree-log.c +1 -0
@@ -4005,6 +4005,7 @@ fill_holes:ASSERT (ret ==0 ); src = src_path->nodes[0 ]; i =0 ; + need_find_last_extent = true; }btrfs_item_key_to_cpu (src, &key, i);
Greg Kroah-Hartman
maintainerPATCH 92/272 btrfs: fix lockdep splat in btrfs_alloc_subvolume_writers
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Mahoney <[email protected]>
[ Upstream commit 8a5a916d9a35e13576d79cc16e24611821b13e34 ]
While running btrfs/011, I hit the following lockdep splat.
This is the important bit:
pcpu_alloc+0x1ac/0x5e0 __percpu_counter_init+0x4e/0xb0 btrfs_init_fs_root+0x99/0x1c0 [btrfs] btrfs_get_fs_root.part.54+0x5b/0x150 [btrfs] resolve_indirect_refs+0x130/0x830 [btrfs] find_parent_nodes+0x69e/0xff0 [btrfs] btrfs_find_all_roots_safe+0xa0/0x110 [btrfs] btrfs_find_all_roots+0x50/0x70 [btrfs] btrfs_qgroup_prepare_account_extents+0x53/0x90 [btrfs] btrfs_commit_transaction+0x3ce/0x9b0 [btrfs]
The percpu_counter_init call in btrfs_alloc_subvolume_writers uses GFP_KERNEL, which we can't do during transaction commit.
This switches it to GFP_NOFS.
========================================================
WARNING: possible irq lock inversion dependency detected
4.12.14-kvmsmall #8 Tainted: G W
--------------------------------------------------------
kswapd0/50 just changed the state of lock:
(&delayed_node->mutex){+.+.-.}, at: [<ffffffffc06994fa>] __btrfs_release_delayed_node+0x3a/0x1f0 [btrfs]
but this lock took another, RECLAIM_FS-unsafe lock in the past:
(pcpu_alloc_mutex){+.+.+.}
and interrupts could create inverse lock ordering between them.
other info that might help us debug this:
Chain exists of: &delayed_node->mutex --> &found->groups_sem --> pcpu_alloc_mutex
Possible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(pcpu_alloc_mutex);
local_irq_disable();
lock(&delayed_node->mutex);
lock(&found->groups_sem);
<Interrupt>
lock(&delayed_node->mutex);*** DEADLOCK ***
2 locks held by kswapd0/50:
#0: (shrinker_rwsem){++++..}, at: [<ffffffff811dc11f>] shrink_slab+0x7f/0x5b0 #1: (&type->s_umount_key#30){+++++.}, at: [<ffffffff8126dec6>] trylock_super+0x16/0x50
the shortest dependencies between 2nd lock and 1st lock:
-> (pcpu_alloc_mutex){+.+.+.} ops: 4904 {
HARDIRQ-ON-W at:
__mutex_lock+0x4e/0x8c0
pcpu_alloc+0x1ac/0x5e0
alloc_kmem_cache_cpus.isra.70+0x25/0xa0
__do_tune_cpucache+0x2c/0x220
do_tune_cpucache+0x26/0xc0
enable_cpucache+0x6d/0xf0
kmem_cache_init_late+0x42/0x75
start_kernel+0x343/0x4cb
x86_64_start_kernel+0x127/0x134
secondary_startup_64+0xa5/0xb0
SOFTIRQ-ON-W at:
__mutex_lock+0x4e/0x8c0
pcpu_alloc+0x1ac/0x5e0
alloc_kmem_cache_cpus.isra.70+0x25/0xa0
__do_tune_cpucache+0x2c/0x220
do_tune_cpucache+0x26/0xc0
enable_cpucache+0x6d/0xf0
kmem_cache_init_late+0x42/0x75
start_kernel+0x343/0x4cb
x86_64_start_kernel+0x127/0x134
secondary_startup_64+0xa5/0xb0
RECLAIM_FS-ON-W at:
__kmalloc+0x47/0x310
pcpu_extend_area_map+0x2b/0xc0
pcpu_alloc+0x3ec/0x5e0
alloc_kmem_cache_cpus.isra.70+0x25/0xa0
__do_tune_cpucache+0x2c/0x220
do_tune_cpucache+0x26/0xc0
enable_cpucache+0x6d/0xf0
__kmem_cache_create+0x1bf/0x390
create_cache+0xba/0x1b0
kmem_cache_create+0x1f8/0x2b0
ksm_init+0x6f/0x19d
do_one_initcall+0x50/0x1b0
kernel_init_freeable+0x201/0x289
kernel_init+0xa/0x100
ret_from_fork+0x3a/0x50
INITIAL USE at:
__mutex_lock+0x4e/0x8c0
pcpu_alloc+0x1ac/0x5e0
alloc_kmem_cache_cpus.isra.70+0x25/0xa0
setup_cpu_cache+0x2f/0x1f0
__kmem_cache_create+0x1bf/0x390
create_boot_cache+0x8b/0xb1
kmem_cache_init+0xa1/0x19e
start_kernel+0x270/0x4cb
x86_64_start_kernel+0x127/0x134
secondary_startup_64+0xa5/0xb0
}
... key at: [<ffffffff821d8e70>] pcpu_alloc_mutex+0x70/0xa0
... acquired at:
pcpu_alloc+0x1ac/0x5e0
__percpu_counter_init+0x4e/0xb0
btrfs_init_fs_root+0x99/0x1c0 [btrfs]
btrfs_get_fs_root.part.54+0x5b/0x150 [btrfs]
resolve_indirect_refs+0x130/0x830 [btrfs]
find_parent_nodes+0x69e/0xff0 [btrfs]
btrfs_find_all_roots_safe+0xa0/0x110 [btrfs]
btrfs_find_all_roots+0x50/0x70 [btrfs]
btrfs_qgroup_prepare_account_extents+0x53/0x90 [btrfs]
btrfs_commit_transaction+0x3ce/0x9b0 [btrfs]
transaction_kthread+0x176/0x1b0 [btrfs]
kthread+0x102/0x140
ret_from_fork+0x3a/0x50 -> (&fs_info->commit_root_sem){++++..} ops: 1566382 {
HARDIRQ-ON-W at:
down_write+0x3e/0xa0
cache_block_group+0x287/0x420 [btrfs]
find_free_extent+0x106c/0x12d0 [btrfs]
btrfs_reserve_extent+0xd8/0x170 [btrfs]
cow_file_range.isra.66+0x133/0x470 [btrfs]
run_delalloc_range+0x121/0x410 [btrfs]
writepage_delalloc.isra.50+0xfe/0x180 [btrfs]
__extent_writepage+0x19a/0x360 [btrfs]
extent_write_cache_pages.constprop.56+0x249/0x3e0 [btrfs]
extent_writepages+0x4d/0x60 [btrfs]
do_writepages+0x1a/0x70
__filemap_fdatawrite_range+0xa7/0xe0
btrfs_rename+0x5ee/0xdb0 [btrfs]
vfs_rename+0x52a/0x7e0
SyS_rename+0x351/0x3b0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
HARDIRQ-ON-R at:
down_read+0x35/0x90
caching_thread+0x57/0x560 [btrfs]
normal_work_helper+0x1c0/0x5e0 [btrfs]
process_one_work+0x1e0/0x5c0
worker_thread+0x44/0x390
kthread+0x102/0x140
ret_from_fork+0x3a/0x50
SOFTIRQ-ON-W at:
down_write+0x3e/0xa0
cache_block_group+0x287/0x420 [btrfs]
find_free_extent+0x106c/0x12d0 [btrfs]
btrfs_reserve_extent+0xd8/0x170 [btrfs]
cow_file_range.isra.66+0x133/0x470 [btrfs]
run_delalloc_range+0x121/0x410 [btrfs]
writepage_delalloc.isra.50+0xfe/0x180 [btrfs]
__extent_writepage+0x19a/0x360 [btrfs]
extent_write_cache_pages.constprop.56+0x249/0x3e0 [btrfs]
extent_writepages+0x4d/0x60 [btrfs]
do_writepages+0x1a/0x70
__filemap_fdatawrite_range+0xa7/0xe0
btrfs_rename+0x5ee/0xdb0 [btrfs]
vfs_rename+0x52a/0x7e0
SyS_rename+0x351/0x3b0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
SOFTIRQ-ON-R at:
down_read+0x35/0x90
caching_thread+0x57/0x560 [btrfs]
normal_work_helper+0x1c0/0x5e0 [btrfs]
process_one_work+0x1e0/0x5c0
worker_thread+0x44/0x390
kthread+0x102/0x140
ret_from_fork+0x3a/0x50
INITIAL USE at:
down_write+0x3e/0xa0
cache_block_group+0x287/0x420 [btrfs]
find_free_extent+0x106c/0x12d0 [btrfs]
btrfs_reserve_extent+0xd8/0x170 [btrfs]
cow_file_range.isra.66+0x133/0x470 [btrfs]
run_delalloc_range+0x121/0x410 [btrfs]
writepage_delalloc.isra.50+0xfe/0x180 [btrfs]
__extent_writepage+0x19a/0x360 [btrfs]
extent_write_cache_pages.constprop.56+0x249/0x3e0 [btrfs]
extent_writepages+0x4d/0x60 [btrfs]
do_writepages+0x1a/0x70
__filemap_fdatawrite_range+0xa7/0xe0
btrfs_rename+0x5ee/0xdb0 [btrfs]
vfs_rename+0x52a/0x7e0
SyS_rename+0x351/0x3b0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
}
... key at: [<ffffffffc0729578>] __key.61970+0x0/0xfffffffffff9aa88 [btrfs]
... acquired at:
cache_block_group+0x287/0x420 [btrfs]
find_free_extent+0x106c/0x12d0 [btrfs]
btrfs_reserve_extent+0xd8/0x170 [btrfs]
btrfs_alloc_tree_block+0x12f/0x4c0 [btrfs]
btrfs_create_tree+0xbb/0x2a0 [btrfs]
btrfs_create_uuid_tree+0x37/0x140 [btrfs]
open_ctree+0x23c0/0x2660 [btrfs]
btrfs_mount+0xd36/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
btrfs_mount+0x18c/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
do_mount+0x1c1/0xcc0
SyS_mount+0x7e/0xd0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7 -> (&found->groups_sem){++++..} ops: 2134587 {
HARDIRQ-ON-W at:
down_write+0x3e/0xa0
__link_block_group+0x34/0x130 [btrfs]
btrfs_read_block_groups+0x33d/0x7b0 [btrfs]
open_ctree+0x2054/0x2660 [btrfs]
btrfs_mount+0xd36/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
btrfs_mount+0x18c/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
do_mount+0x1c1/0xcc0
SyS_mount+0x7e/0xd0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
HARDIRQ-ON-R at:
down_read+0x35/0x90
btrfs_calc_num_tolerated_disk_barrier_failures+0x113/0x1f0 [btrfs]
open_ctree+0x207b/0x2660 [btrfs]
btrfs_mount+0xd36/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
btrfs_mount+0x18c/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
do_mount+0x1c1/0xcc0
SyS_mount+0x7e/0xd0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
SOFTIRQ-ON-W at:
down_write+0x3e/0xa0
__link_block_group+0x34/0x130 [btrfs]
btrfs_read_block_groups+0x33d/0x7b0 [btrfs]
open_ctree+0x2054/0x2660 [btrfs]
btrfs_mount+0xd36/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
btrfs_mount+0x18c/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
do_mount+0x1c1/0xcc0
SyS_mount+0x7e/0xd0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
SOFTIRQ-ON-R at:
down_read+0x35/0x90
btrfs_calc_num_tolerated_disk_barrier_failures+0x113/0x1f0 [btrfs]
open_ctree+0x207b/0x2660 [btrfs]
btrfs_mount+0xd36/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
btrfs_mount+0x18c/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
do_mount+0x1c1/0xcc0
SyS_mount+0x7e/0xd0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
INITIAL USE at:
down_write+0x3e/0xa0
__link_block_group+0x34/0x130 [btrfs]
btrfs_read_block_groups+0x33d/0x7b0 [btrfs]
open_ctree+0x2054/0x2660 [btrfs]
btrfs_mount+0xd36/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
btrfs_mount+0x18c/0xf90 [btrfs]
mount_fs+0x3a/0x160
vfs_kern_mount+0x66/0x150
do_mount+0x1c1/0xcc0
SyS_mount+0x7e/0xd0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
}
... key at: [<ffffffffc0729488>] __key.59101+0x0/0xfffffffffff9ab78 [btrfs]
... acquired at:
find_free_extent+0xcb4/0x12d0 [btrfs]
btrfs_reserve_extent+0xd8/0x170 [btrfs]
btrfs_alloc_tree_block+0x12f/0x4c0 [btrfs]
__btrfs_cow_block+0x110/0x5b0 [btrfs]
btrfs_cow_block+0xd7/0x290 [btrfs]
btrfs_search_slot+0x1f6/0x960 [btrfs]
btrfs_lookup_inode+0x2a/0x90 [btrfs]
__btrfs_update_delayed_inode+0x65/0x210 [btrfs]
btrfs_commit_inode_delayed_inode+0x121/0x130 [btrfs]
btrfs_evict_inode+0x3fe/0x6a0 [btrfs]
evict+0xc4/0x190
__dentry_kill+0xbf/0x170
dput+0x2ae/0x2f0
SyS_rename+0x2a6/0x3b0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7-> (&delayed_node->mutex){+.+.-.} ops: 5580204 {
HARDIRQ-ON-W at:
__mutex_lock+0x4e/0x8c0
btrfs_delayed_update_inode+0x46/0x6e0 [btrfs]
btrfs_update_inode+0x83/0x110 [btrfs]
btrfs_dirty_inode+0x62/0xe0 [btrfs]
touch_atime+0x8c/0xb0
do_generic_file_read+0x818/0xb10
__vfs_read+0xdc/0x150
vfs_read+0x8a/0x130
SyS_read+0x45/0xa0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
SOFTIRQ-ON-W at:
__mutex_lock+0x4e/0x8c0
btrfs_delayed_update_inode+0x46/0x6e0 [btrfs]
btrfs_update_inode+0x83/0x110 [btrfs]
btrfs_dirty_inode+0x62/0xe0 [btrfs]
touch_atime+0x8c/0xb0
do_generic_file_read+0x818/0xb10
__vfs_read+0xdc/0x150
vfs_read+0x8a/0x130
SyS_read+0x45/0xa0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
IN-RECLAIM_FS-W at:
__mutex_lock+0x4e/0x8c0
__btrfs_release_delayed_node+0x3a/0x1f0 [btrfs]
btrfs_evict_inode+0x22c/0x6a0 [btrfs]
evict+0xc4/0x190
dispose_list+0x35/0x50
prune_icache_sb+0x42/0x50
super_cache_scan+0x139/0x190
shrink_slab+0x262/0x5b0
shrink_node+0x2eb/0x2f0
kswapd+0x2eb/0x890
kthread+0x102/0x140
ret_from_fork+0x3a/0x50
INITIAL USE at:
__mutex_lock+0x4e/0x8c0
btrfs_delayed_update_inode+0x46/0x6e0 [btrfs]
btrfs_update_inode+0x83/0x110 [btrfs]
btrfs_dirty_inode+0x62/0xe0 [btrfs]
touch_atime+0x8c/0xb0
do_generic_file_read+0x818/0xb10
__vfs_read+0xdc/0x150
vfs_read+0x8a/0x130
SyS_read+0x45/0xa0
do_syscall_64+0x79/0x1e0
entry_SYSCALL_64_after_hwframe+0x42/0xb7
}
... key at: [<ffffffffc072d488>] __key.56935+0x0/0xfffffffffff96b78 [btrfs]
... acquired at:
__lock_acquire+0x264/0x11c0
lock_acquire+0xbd/0x1e0
__mutex_lock+0x4e/0x8c0
__btrfs_release_delayed_node+0x3a/0x1f0 [btrfs]
btrfs_evict_inode+0x22c/0x6a0 [btrfs]
evict+0xc4/0x190
dispose_list+0x35/0x50
prune_icache_sb+0x42/0x50
super_cache_scan+0x139/0x190
shrink_slab+0x262/0x5b0
shrink_node+0x2eb/0x2f0
kswapd+0x2eb/0x890
kthread+0x102/0x140
ret_from_fork+0x3a/0x50
stack backtrace:
CPU: 1 PID: 50 Comm: kswapd0 Tainted: G W 4.12.14-kvmsmall #8 SLE15 (unreleased)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
Call Trace:
dump_stack+0x78/0xb7
print_irq_inversion_bug.part.38+0x19f/0x1aa
check_usage_forwards+0x102/0x120
? ret_from_fork+0x3a/0x50
? check_usage_backwards+0x110/0x110
mark_lock+0x16c/0x270
__lock_acquire+0x264/0x11c0
? pagevec_lookup_entries+0x1a/0x30
? truncate_inode_pages_range+0x2b3/0x7f0
lock_acquire+0xbd/0x1e0
? __btrfs_release_delayed_node+0x3a/0x1f0 [btrfs]
__mutex_lock+0x4e/0x8c0
? __btrfs_release_delayed_node+0x3a/0x1f0 [btrfs]
? __btrfs_release_delayed_node+0x3a/0x1f0 [btrfs]
? btrfs_evict_inode+0x1f6/0x6a0 [btrfs]
__btrfs_release_delayed_node+0x3a/0x1f0 [btrfs]
btrfs_evict_inode+0x22c/0x6a0 [btrfs]
evict+0xc4/0x190
dispose_list+0x35/0x50
prune_icache_sb+0x42/0x50
super_cache_scan+0x139/0x190
shrink_slab+0x262/0x5b0
shrink_node+0x2eb/0x2f0
kswapd+0x2eb/0x890
kthread+0x102/0x140
? mem_cgroup_shrink_node+0x2c0/0x2c0
? kthread_create_on_node+0x40/0x40
ret_from_fork+0x3a/0x50--- fs/btrfs/disk-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/disk-io.c +1 -1
@@ -1108,7 +1108,7 @@ static struct btrfs_subvolume_writers *bif (!writers)return ERR_PTR (-ENOMEM ); - ret =percpu_counter_init (&writers->counter,0 ,GFP_KERNEL ); + ret =percpu_counter_init (&writers->counter,0 ,GFP_NOFS );if (ret <0 ) {kfree (writers);return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 93/272 btrfs: qgroup: Fix root item corruption when multiple same source snapshots are created with quota enabled
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 4d31778aa2fa342f5f92ca4025b293a1729161d1 ]
When multiple pending snapshots referring to the same source subvolume are executed, enabled quota will cause root item corruption, where root items are using old bytenr (no backref in extent tree).
This can be triggered by fstests btrfs/152.
The cause is when source subvolume is still dirty, extra commit (simplied transaction commit) of qgroup_account_snapshot() can skip dirty roots not recorded in current transaction, making root item of source subvolume not updated.
Fix it by forcing recording source subvolume in current transaction before qgroup sub-transaction commit.
--- fs/btrfs/transaction.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/btrfs/transaction.c +9 -1
@@ -319,7 +319,7 @@ static int record_root_in_trans(struct bif ((test_bit (BTRFS_ROOT_REF_COWS , &root->state) && root->last_trans < trans->transid) || force) {WARN_ON (root == fs_info->extent_root); -WARN_ON (root->commit_root != root->node); +WARN_ON (!force && root->commit_root != root->node);/* * see below for IN_TRANS_SETUP usage rules
@@ -1366,6 +1366,14 @@ static int qgroup_account_snapshot(strucreturn 0 ;/* +* Ensure dirty @src will be commited. Or, after comming +* commit_fs_roots() and switch_commit_roots(), any dirty but not +* recorded root will never be updated again, causing an outdated root +* item. +*/ +record_root_in_trans (trans, src,1 ); + +/* * We are going to commit transaction, see btrfs_commit_transaction() * comment for reason locking tree_log_mutex */
Greg Kroah-Hartman
maintainerPATCH 94/272 rxrpc: Fix resend event time calculation
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Dionne <[email protected]>
[ Upstream commit 59299aa1028fce051adbd25aaff7c387b865cd6d ]
Commit a158bdd3 ("rxrpc: Fix call timeouts") reworked the time calculation for the next resend event. For this calculation, "oldest" will be before "now", so ktime_sub(oldest, now) will yield a negative value. When passed to nsecs_to_jiffies which expects an unsigned value, the end result will be a very large value, and a resend event scheduled far into the future. This could cause calls to stall if some packets were lost.
Fix by ordering the arguments to ktime_sub correctly.
--- net/rxrpc/call_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/call_event.c +1 -1
@@ -225,7 +225,7 @@ static void rxrpc_resend(struct rxrpc_ca ktime_to_ns(ktime_sub(skb->tstamp, max_age))); } - resend_at =nsecs_to_jiffies (ktime_to_ns (ktime_sub (oldest, now))); + resend_at =nsecs_to_jiffies (ktime_to_ns (ktime_sub (now, oldest))); resend_at += jiffies + rxrpc_resend_timeout;WRITE_ONCE (call->resend_at, resend_at);
Greg Kroah-Hartman
maintainerPATCH 95/272 rxrpc: Fix Tx ring annotation after initial Tx failure
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 03877bf6a30cca7d4bc3ffabd3c3e9464a7a1a19 ]
rxrpc calls have a ring of packets that are awaiting ACK or retransmission and a parallel ring of annotations that tracks the state of those packets. If the initial transmission of a packet on the underlying UDP socket fails then the packet annotation is marked for resend - but the setting of this mark accidentally erases the last-packet mark also stored in the same annotation slot. If this happens, a call won't switch out of the Tx phase when all the packets have been transmitted.
Fix this by retaining the last-packet mark and only altering the packet state.
--- net/rxrpc/sendmsg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/rxrpc/sendmsg.c +3 -1
@@ -130,7 +130,9 @@ static inline void rxrpc_instant_resend(spin_lock_bh (&call->lock);if (call->state <RXRPC_CALL_COMPLETE ) { - call->rxtx_annotations[ix] =RXRPC_TX_ANNO_RETRANS ; + call->rxtx_annotations[ix] = + (call->rxtx_annotations[ix] &RXRPC_TX_ANNO_LAST ) | +RXRPC_TX_ANNO_RETRANS ;if (!test_and_set_bit (RXRPC_CALL_EV_RESEND , &call->events))rxrpc_queue_call (call); }
Greg Kroah-Hartman
maintainerPATCH 96/272 rxrpc: Dont treat call aborts as conn aborts
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 57b0c9d49b94bbeb53649b7fbd264603c1ebd585 ]
If a call-level abort is received for the previous call to complete on a connection channel, then that abort is queued for the connection processor to handle. Unfortunately, the connection processor then assumes without checking that the abort is connection-level (ie. callNumber is 0) and distributes it over all active calls on that connection, thereby incorrectly aborting them.
Fix this by discarding aborts aimed at a completed call.
Further, discard all packets aimed at a call that's complete if there's currently an active call on a channel, since the DATA packets associated with the new call automatically terminate the old call.
--- net/rxrpc/input.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
net/rxrpc/input.c +9 -6
@@ -1240,16 +1240,19 @@ void rxrpc_data_ready(struct sock *udp_s goto discard_unlock;if (sp->hdr.callNumber == chan->last_call) { -/* For the previous service call, if completed successfully, we -* discard all further packets. +if (chan->call || + sp->hdr.type ==RXRPC_PACKET_TYPE_ABORT ) + goto discard_unlock; + +/* For the previous service call, if completed +* successfully, we discard all further packets. */ if (rxrpc_conn_is_service (conn) && - (chan->last_type ==RXRPC_PACKET_TYPE_ACK || - sp->hdr.type ==RXRPC_PACKET_TYPE_ABORT )) + chan->last_type ==RXRPC_PACKET_TYPE_ACK ) goto discard_unlock; -/* But otherwise we need to retransmit the final packet from -* data cached in the connection record. +/* But otherwise we need to retransmit the final packet +* from data cached in the connection record. */ rxrpc_post_packet_to_conn (conn, skb); goto out_unlock;
Greg Kroah-Hartman
maintainerPATCH 97/272 xen/acpi: off by one in read_acpi_id()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit c37a3c94775855567b90f91775b9691e10bd2806 ]
If acpi_id is == nr_acpi_bits, then we access one element beyond the end of the acpi_psd[] array or we set one bit beyond the end of the bit map when we do __set_bit(acpi_id, acpi_id_present);
--- drivers/xen/xen-acpi-processor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/xen/xen-acpi-processor.c +3 -3
@@ -362,9 +362,9 @@ read_acpi_id(acpi_handle handle, u32 lvl }/* There are more ACPI Processor objects than in x2APIC or MADT. * This can happen with incorrect ACPI SSDT declerations. */ -if (acpi_id > nr_acpi_bits) { -pr_debug ("We only have %u, trying to set %u\n" , - nr_acpi_bits, acpi_id); +if (acpi_id >= nr_acpi_bits) { +pr_debug ("max acpi id %u, trying to set %u\n" , + nr_acpi_bits -1 , acpi_id);return AE_OK ; }/* OK, There is a ACPI Processor object */
Greg Kroah-Hartman
maintainerPATCH 82/272 dmaengine: rcar-dmac: Fix too early/late system suspend/resume callbacks
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 73dcc666d6bd0db56cd556010f93d8f04c1cc70c ]
If serial console wake-up is enabled ("echo enabled > /sys/.../ttySC0/power/wakeup"), and any serial input is received while the system is suspended, serial port input no longer works after system resume.
Note that:
1) The system can still be woken up using the serial console,
2) Serial port input keeps working if the system is woken up in some other way (e.g. Wake-on-LAN or gpio-keys), and no serial input was received while suspended.
To fix this, replace SET_LATE_SYSTEM_SLEEP_PM_OPS() by SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(), as the callbacks installed by the former happen too early resp. late in the suspend resp. resume process.
--- drivers/dma/sh/rcar-dmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/sh/rcar-dmac.c +2 -2
@@ -1677,8 +1677,8 @@ static const struct dev_pm_ops rcar_dmac* - Wait for the current transfer to complete and stop the device, * - Resume transfers, if any. */ -SET_LATE_SYSTEM_SLEEP_PM_OPS (pm_runtime_force_suspend, - pm_runtime_force_resume) +SET_NOIRQ_SYSTEM_SLEEP_PM_OPS (pm_runtime_force_suspend, + pm_runtime_force_resume)SET_RUNTIME_PM_OPS (rcar_dmac_runtime_suspend, rcar_dmac_runtime_resume, NULL) };
Greg Kroah-Hartman
maintainerPATCH 100/272 powerpc/mpic: Check if cpu_possible() in mpic_physmask()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit 0834d627fbea00c1444075eb3e448e1974da452d ]
In mpic_physmask() we loop over all CPUs up to 32, then get the hard SMP processor id of that CPU.
Currently that's possibly walking off the end of the paca array, but in a future patch we will change the paca array to be an array of pointers, and in that case we will get a NULL for missing CPUs and oops. eg:
Unable to handle kernel paging request for data at address 0x88888888888888b8 Faulting instruction address: 0xc00000000004e380 Oops: Kernel access of bad area, sig: 11 [#1] ... NIP .mpic_set_affinity+0x60/0x1a0 LR .irq_do_set_affinity+0x48/0x100
Fix it by checking the CPU is possible, this also fixes the code if there are gaps in the CPU numbering which probably never happens on mpic systems but who knows.
--- arch/powerpc/sysdev/mpic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/sysdev/mpic.c +1 -1
@@ -626,7 +626,7 @@ static inline u32 mpic_physmask(u32 cpumint i;u32 mask =0 ; -for (i =0 ; i <min (32 ,NR_CPUS ); ++i, cpumask >>=1 ) +for (i =0 ; i <min (32 ,NR_CPUS ) &&cpu_possible (i); ++i, cpumask >>=1 ) mask |= (cpumask &1 ) <<get_hard_smp_processor_id (i);return mask; }
Greg Kroah-Hartman
maintainerPATCH 102/272 ath10k: advertize beacon_int_min_gcd
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anilkumar Kolli <[email protected]>
[ Upstream commit 8ebee73b574ad3dd1f14d461f65ceaffbd637650 ]
This patch fixes regression caused by 0c317a02ca98 ("cfg80211: support virtual interfaces with different beacon intervals"), with this change cfg80211 expects the driver to advertize 'beacon_int_min_gcd' to support different beacon intervals in multivap scenario. This support is added for, QCA988X/QCA99X0/QCA9984/QCA4019.
Verifed AP + mesh bring up on QCA9984 with beacon interval 100msec and 1000msec respectively.
Frimware: firmware-5.bin_10.4-3.5.3-00053
--- drivers/net/wireless/ath/ath10k/mac.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/ath/ath10k/mac.c +2 -0
@@ -7873,6 +7873,7 @@ static const struct ieee80211_iface_comb .max_interfaces = 8, .num_different_channels = 1, .beacon_int_infra_match = true, + .beacon_int_min_gcd =1 , #ifdef CONFIG_ATH10K_DFS_CERTIFIED .radar_detect_widths =BIT (NL80211_CHAN_WIDTH_20_NOHT ) | BIT(NL80211_CHAN_WIDTH_20) |
@@ -7996,6 +7997,7 @@ static const struct ieee80211_iface_comb .max_interfaces = 16, .num_different_channels = 1, .beacon_int_infra_match = true, + .beacon_int_min_gcd =1 , #ifdef CONFIG_ATH10K_DFS_CERTIFIED .radar_detect_widths =BIT (NL80211_CHAN_WIDTH_20_NOHT ) | BIT(NL80211_CHAN_WIDTH_20) |
Greg Kroah-Hartman
maintainerPATCH 104/272 intel_th: Use correct method of finding hub
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Shishkin <[email protected]>
[ Upstream commit 9ad577087165478c9d9be82b15ed9bf2db5835f5 ]
Since commit 8edc514b01e9 ("intel_th: Make SOURCE devices children of the root device") the hub is not the parent of SOURCE devices any more, so the new helper function should be used for that instead of always using the parent. The intel_th_set_output() path, however, still uses the old logic, leading to the hub driver structure being aliased with something else, like struct pci_driver or struct acpi_driver, and an incorrect call to an address inferred from that, potentially resulting in a crash.
--- drivers/hwtracing/intel_th/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/intel_th/core.c +1 -1
@@ -935,7 +935,7 @@ EXPORT_SYMBOL_GPL(intel_th_trace_disableint intel_th_set_output (struct intel_th_device *thdev,unsigned int master) { -struct intel_th_device *hub =to_intel_th_device (thdev->dev.parent); +struct intel_th_device *hub =to_intel_th_hub (thdev);struct intel_th_driver *hubdrv =to_intel_th_driver (hub->dev.driver);if (!hubdrv->set_output)
Greg Kroah-Hartman
maintainerPATCH 105/272 m68k: set dma and coherent masks for platform FEC ethernets
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Ungerer <[email protected]>
[ Upstream commit f61e64310b75733d782e930d1fb404b84699eed6 ]
As of commit 205e1b7f51e4 ("dma-mapping: warn when there is no coherent_dma_mask") the Freescale FEC driver is issuing the following warning on driver initialization on ColdFire systems:
WARNING: CPU: 0 PID: 1 at ./include/linux/dma-mapping.h:516 0x40159e20
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.16.0-rc7-dirty #4
Stack from 41833dd8:
41833dd8 40259c53 40025534 40279e26 00000003 00000000 4004e514 41827000
400255de 40244e42 00000204 40159e20 00000009 00000000 00000000 4024531d
40159e20 40244e42 00000204 00000000 00000000 00000000 00000007 00000000
00000000 40279e26 4028d040 40226576 4003ae88 40279e26 418273f6 41833ef8
7fffffff 418273f2 41867028 4003c9a2 4180ac6c 00000004 41833f8c 4013e71c
40279e1c 40279e26 40226c16 4013ced2 40279e26 40279e58 4028d040 00000000
Call Trace:
[<40025534>] 0x40025534
[<4004e514>] 0x4004e514
[<400255de>] 0x400255de
[<40159e20>] 0x40159e20
[<40159e20>] 0x40159e20It is not fatal, the driver and the system continue to function normally.
As per the warning the coherent_dma_mask is not set on this device. There is nothing special about the DMA memory coherency on this hardware so we can just set the mask to 32bits in the platform data for the FEC ethernet devices.
--- arch/m68k/coldfire/device.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/m68k/coldfire/device.c +10 -2
@@ -135,7 +135,11 @@ static struct platform_device mcf_fec0 = .id = 0, .num_resources = ARRAY_SIZE(mcf_fec0_resources), .resource = mcf_fec0_resources, - .dev.platform_data = FEC_PDATA, + .dev = { + .dma_mask = &mcf_fec0.dev.coherent_dma_mask, + .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = FEC_PDATA, + } };#ifdef MCFFEC_BASE1
@@ -167,7 +171,11 @@ static struct platform_device mcf_fec1 = .id = 1, .num_resources = ARRAY_SIZE(mcf_fec1_resources), .resource = mcf_fec1_resources, - .dev.platform_data = FEC_PDATA, + .dev = { + .dma_mask = &mcf_fec1.dev.coherent_dma_mask, + .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = FEC_PDATA, + } };#endif /* MCFFEC_BASE1 */ #endif /* CONFIG_FEC */
Greg Kroah-Hartman
maintainerPATCH 106/272 iwlwifi: mvm: check if mac80211_queue is valid in iwl_mvm_disable_txq
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Coelho <[email protected]>
[ Upstream commit 9a233bb8025105db9a60b5d761005cc5a6c77f3d ]
Sometimes iwl_mvm_disable_txq() may be called with mac80211_queue == IEEE80211_INVAL_HW_QUEUE, and this would cause us to use BIT(0xFF) which is way too large for the u16 we used to store it in hw_queue_to_mac820211. If this happens the following UBSAN warning will be generated:
[ 167.185167] UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5 [ 167.185171] shift exponent 255 is too large for 64-bit type 'long unsigned int'
Fix that by checking that it is not IEEE80211_INVAL_HW_QUEUE and, while at it, add a warning if the queue number is larger than IEEE80211_MAX_QUEUES.
--- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/utils.c +9 -2
@@ -800,12 +800,19 @@ int iwl_mvm_disable_txq(struct iwl_mvm * .scd_queue = queue, .action = SCD_CFG_DISABLE_QUEUE, }; -bool remove_mac_queue = true; +bool remove_mac_queue = mac80211_queue !=IEEE80211_INVAL_HW_QUEUE ;int ret; +if (WARN_ON (remove_mac_queue && mac80211_queue >=IEEE80211_MAX_QUEUES )) +return -EINVAL ; +if (iwl_mvm_has_new_tx_api (mvm)) {spin_lock_bh (&mvm->queue_info_lock); - mvm->hw_queue_to_mac80211[queue] &= ~BIT (mac80211_queue); + +if (remove_mac_queue) + mvm->hw_queue_to_mac80211[queue] &= + ~BIT (mac80211_queue); +spin_unlock_bh (&mvm->queue_info_lock);iwl_trans_txq_free (mvm->trans, queue);
Greg Kroah-Hartman
maintainerPATCH 107/272 iwlwifi: mvm: take RCU lock before dereferencing
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sara Sharon <[email protected]>
[ Upstream commit f4f155e5ec04d381b2f0870817d93dbdc259aa63 ]
RCU isn't properly locked.
--- drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c +5 -1
@@ -234,13 +234,15 @@ void iwl_mvm_tlc_update_notif(struct iwlstruct iwl_mvm_sta *mvmsta;struct iwl_lq_sta_rs_fw *lq_sta; +rcu_read_lock (); + notif = (void *)pkt->data; mvmsta =iwl_mvm_sta_from_staid_rcu (mvm, notif->sta_id);if (!mvmsta) {IWL_ERR (mvm,"Invalid sta id (%d) in FW TLC notification\n" , notif->sta_id); -return ; + goto out; } lq_sta = &mvmsta->lq_sta.rs_fw;
@@ -251,6 +253,8 @@ void iwl_mvm_tlc_update_notif(struct iwlIWL_DEBUG_RATE (mvm,"new rate_n_flags: 0x%X\n" , lq_sta->last_rate_n_flags); } +out: +rcu_read_unlock (); } void rs_fw_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
Greg Kroah-Hartman
maintainerPATCH 108/272 net/mlx5e: Move all TX timeout logic to be under state lock
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eran Ben Elisha <[email protected]>
[ Upstream commit bfc647d52e67dc756c605e9a50d45b71054c2533 ]
Driver callback for handling TX timeout should access some internal resources (SQ, CQ) in order to decide if the tx timeout work should be scheduled. These resources might be unavailable if channels are closed in parallel (ifdown for example).
The state lock is the mechanism to protect from such races. Move all TX timeout logic to be in the work under a state lock.
In addition, Move the work from the global WQ to mlx5e WQ to make sure this work is flushed when device is detached..
Also, move the mlx5e_tx_timeout_work code to be next to the TX timeout NDO for better code locality.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 61 ++++++++++++---------- 1 file changed, 34 insertions(+), 27 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +34 -27
@@ -153,26 +153,6 @@ static void mlx5e_update_carrier_work(stmutex_unlock (&priv->state_lock); } -static void mlx5e_tx_timeout_work (struct work_struct *work) -{ - struct mlx5e_priv *priv = container_of(work, struct mlx5e_priv, - tx_timeout_work); -int err; - -rtnl_lock (); -mutex_lock (&priv->state_lock); -if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) - goto unlock; -mlx5e_close_locked (priv->netdev); - err =mlx5e_open_locked (priv->netdev); -if (err) -netdev_err (priv->netdev,"mlx5e_open_locked failed recovering from a tx_timeout, err(%d).\n" , - err); -unlock: -mutex_unlock (&priv->state_lock); -rtnl_unlock (); -} -void mlx5e_update_stats (struct mlx5e_priv *priv) {int i;
@@ -3632,13 +3612,19 @@ static bool mlx5e_tx_timeout_eq_recover(return true; } -static void mlx5e_tx_timeout (struct net_device *dev) +static void mlx5e_tx_timeout_work (struct work_struct *work) { -struct mlx5e_priv *priv =netdev_priv (dev); + struct mlx5e_priv *priv = container_of(work, struct mlx5e_priv, + tx_timeout_work); +struct net_device *dev = priv->netdev;bool reopen_channels = false; -int i; +int i, err; -netdev_err (dev,"TX timeout detected\n" ); +rtnl_lock (); +mutex_lock (&priv->state_lock); + +if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) + goto unlock;for (i =0 ; i < priv->channels.num * priv->channels.params.num_tc; i++) {struct netdev_queue *dev_queue =netdev_get_tx_queue (dev, i);
@@ -3646,7 +3632,9 @@ static void mlx5e_tx_timeout(struct net_if (!netif_xmit_stopped (dev_queue))continue ; -netdev_err (dev,"TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x, usecs since last trans: %u\n" , + +netdev_err (dev, +"TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x, usecs since last trans: %u\n" , i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc,jiffies_to_usecs (jiffies - dev_queue->trans_start));
@@ -3659,8 +3647,27 @@ static void mlx5e_tx_timeout(struct net_ } } -if (reopen_channels &&test_bit (MLX5E_STATE_OPENED , &priv->state)) -schedule_work (&priv->tx_timeout_work); +if (!reopen_channels) + goto unlock; + +mlx5e_close_locked (dev); + err =mlx5e_open_locked (dev); +if (err) +netdev_err (priv->netdev, +"mlx5e_open_locked failed recovering from a tx_timeout, err(%d).\n" , + err); + +unlock: +mutex_unlock (&priv->state_lock); +rtnl_unlock (); +} + +static void mlx5e_tx_timeout (struct net_device *dev) +{ +struct mlx5e_priv *priv =netdev_priv (dev); + +netdev_err (dev,"TX timeout detected\n" ); +queue_work (priv->wq, &priv->tx_timeout_work); }static int mlx5e_xdp_set (struct net_device *netdev,struct bpf_prog *prog)
Greg Kroah-Hartman
maintainerPATCH 109/272 parisc/pci: Switch LBA PCI bus from Hard Fail to Soft Fail mode
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
[ Upstream commit b845f66f78bf42a4ce98e5cfe0e94fab41dd0742 ]
Carlo Pisani noticed that his C3600 workstation behaved unstable during heavy I/O on the PCI bus with a VIA VT6421 IDE/SATA PCI card.
To avoid such instability, this patch switches the LBA PCI bus from Hard Fail mode into Soft Fail mode. In this mode the bus will return -1UL for timed out MMIO transactions, which is exactly how the x86 (and most other architectures) PCI busses behave.
This patch is based on a proposal by Grant Grundler and Kyle McMartin 10 years ago:
https://www.spinics.net/lists/linux-parisc/msg01027.html
--- drivers/parisc/lba_pci.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/parisc/lba_pci.c +19 -1
@@ -1403,9 +1403,27 @@ lba_hw_init(struct lba_device *d)WRITE_REG32 (stat, d->hba.base_addr +LBA_ERROR_CONFIG ); } -/* Set HF mode as the default (vs. -1 mode). */ + +/* +* Hard Fail vs. Soft Fail on PCI "Master Abort". +* +* "Master Abort" means the MMIO transaction timed out - usually due to +* the device not responding to an MMIO read. We would like HF to be +* enabled to find driver problems, though it means the system will +* crash with a HPMC. +* +* In SoftFail mode "~0L" is returned as a result of a timeout on the +* pci bus. This is like how PCI busses on x86 and most other +* architectures behave. In order to increase compatibility with +* existing (x86) PCI hardware and existing Linux drivers we enable +* Soft Faul mode on PA-RISC now too. +*/ stat =READ_REG32 (d->hba.base_addr +LBA_STAT_CTL ); +#if defined(ENABLE_HARDFAIL )WRITE_REG32 (stat |HF_ENABLE , d->hba.base_addr +LBA_STAT_CTL ); +#else +WRITE_REG32 (stat & ~HF_ENABLE , d->hba.base_addr +LBA_STAT_CTL ); +#endif /* ** Writing a zero to STAT_CTL.rf (bit 0) will clear reset signal
Greg Kroah-Hartman
maintainerPATCH 110/272 perf mmap: Fix accessing unmapped mmap in perf_mmap__read_done()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
[ Upstream commit f58385f629c87a9e210108b39c1f4950d0363ad2 ]
There is a segmentation fault when running 'perf trace'. For example:
[root@jouet e]# perf trace -e *chdir -o /tmp/bla perf report --ignore-vmlinux -i ../perf.data
The perf_mmap__consume() could unmap the mmap. It needs to check the refcnt in perf_mmap__read_done().
--- tools/perf/util/mmap.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/util/mmap.c +6 -0
@@ -344,5 +344,11 @@ out:*/ void perf_mmap__read_done (struct perf_mmap *map) { +/* +* Check if event was unmapped due to a POLLHUP/POLLERR. +*/ +if (!refcount_read (&map->refcnt)) +return ; + map->prev =perf_mmap__read_head (map); }
Greg Kroah-Hartman
maintainerPATCH 87/272 net: bgmac: Correctly annotate register space
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 16a1c0646e55c3345bce8e4edfc06ad119d27c04 ]
All the members: base, idm_base and nicpm_base should be annotated with __iomem since they are pointers to register space. This fixes a bunch of sparse reported warnings.
--- drivers/net/ethernet/broadcom/bgmac.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bgmac.h +3 -3
@@ -479,9 +479,9 @@ struct bgmac_rx_header { struct bgmac { union { struct { - void *base; - void *idm_base; - void *nicpm_base; + void __iomem *base; + void __iomem *idm_base; + void __iomem *nicpm_base; } plat; struct { struct bcma_device *core;
Greg Kroah-Hartman
maintainerPATCH 88/272 bnxt_en: fix clear flags in ethtool reset handling
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Scott Branden <[email protected]>
[ Upstream commit 2373d8d6a7932d28b8e31ea2a70bf6c002d97ac8 ]
Clear flags when reset command processed successfully for components specified.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +6 -2
@@ -2552,16 +2552,20 @@ static int bnxt_reset(struct net_devicereturn -EOPNOTSUPP ; rc =bnxt_firmware_reset (dev,BNXT_FW_RESET_CHIP ); -if (!rc) +if (!rc) {netdev_info (dev,"Reset request successful. Reload driver to complete reset\n" ); + *flags =0 ; + } }else if (*flags ==ETH_RESET_AP ) {/* This feature is not supported in older firmware versions */ if (bp->hwrm_spec_code <0x10803 )return -EOPNOTSUPP ; rc =bnxt_firmware_reset (dev,BNXT_FW_RESET_AP ); -if (!rc) +if (!rc) {netdev_info (dev,"Reset Application Processor request successful.\n" ); + *flags =0 ; + } }else { rc = -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 89/272 powerpc/64s: sreset panic if there is no debugger or crash dump handlers
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
[ Upstream commit d40b6768e45bd9213139b2d91d30c7692b6007b1 ]
system_reset_exception does most of its own crash handling now, invoking the debugger or crash dumps if they are registered. If not, then it goes through to die() to print stack traces, and then is supposed to panic (according to comments).
However after die() prints oopses, it does its own handling which doesn't allow system_reset_exception to panic (e.g., it may just kill the current process). This patch causes sreset exceptions to return from die after it prints messages but before acting.
This also stops die from invoking the debugger on 0x100 crashes. system_reset_exception similarly calls the debugger. It had been thought this was harmless (because if the debugger was disabled, neither call would fire, and if it was enabled the first call would return). However in some cases like xmon 'X' command, the debugger returns 0, which currently causes it to be entered again (first in system_reset_exception, then in die), which is confusing.
--- arch/powerpc/kernel/traps.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
arch/powerpc/kernel/traps.c +13 -2
@@ -208,6 +208,12 @@ static void oops_end(unsigned long flags }raw_local_irq_restore (flags); +/* +* system_reset_excption handles debugger, crash dump, panic, for 0x100 +*/ +if (TRAP (regs) ==0x100 ) +return ; +crash_fadump (regs,"die oops" );if (kexec_should_crash (current))
@@ -272,8 +278,13 @@ void die(const char *str, struct pt_regs {unsigned long flags; -if (debugger (regs)) -return ; +/* +* system_reset_excption handles debugger, crash dump, panic, for 0x100 +*/ +if (TRAP (regs) !=0x100 ) { +if (debugger (regs)) +return ; + } flags =oops_begin (regs);if (__die (str, regs, err))
Greg Kroah-Hartman
maintainerPATCH 80/272 lan78xx: Connect phy early
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Graf <[email protected]>
[ Upstream commit 92571a1aae40d291158d16e7142637908220f470 ]
When using wicked with a lan78xx device attached to the system, we end up with ethtool commands issued on the device before an ifup got issued. That lead to the following crash:
Unable to handle kernel NULL pointer dereference at virtual address 0000039c
pgd = ffff800035b30000
[0000039c] *pgd=0000000000000000
Internal error: Oops: 96000004 [#1] SMP
Modules linked in: [...]
Supported: Yes
CPU: 3 PID: 638 Comm: wickedd Tainted: G E 4.12.14-0-default #1
Hardware name: raspberrypi rpi/rpi, BIOS 2018.03-rc2 02/21/2018
task: ffff800035e74180 task.stack: ffff800036718000
PC is at phy_ethtool_ksettings_get+0x20/0x98
LR is at lan78xx_get_link_ksettings+0x44/0x60 [lan78xx]
pc : [<ffff0000086f7f30>] lr : [<ffff000000dcca84>] pstate: 20000005
sp : ffff80003671bb20
x29: ffff80003671bb20 x28: ffff800035e74180
x27: ffff000008912000 x26: 000000000000001d
x25: 0000000000000124 x24: ffff000008f74d00
x23: 0000004000114809 x22: 0000000000000000
x21: ffff80003671bbd0 x20: 0000000000000000
x19: ffff80003671bbd0 x18: 000000000000040d
x17: 0000000000000001 x16: 0000000000000000
x15: 0000000000000000 x14: ffffffffffffffff
x13: 0000000000000000 x12: 0000000000000020
x11: 0101010101010101 x10: fefefefefefefeff
x9 : 7f7f7f7f7f7f7f7f x8 : fefefeff31677364
x7 : 0000000080808080 x6 : ffff80003671bc9c
x5 : ffff80003671b9f8 x4 : ffff80002c296190
x3 : 0000000000000000 x2 : 0000000000000000
x1 : ffff80003671bbd0 x0 : ffff80003671bc00
Process wickedd (pid: 638, stack limit = 0xffff800036718000)
Call trace:
Exception stack(0xffff80003671b9e0 to 0xffff80003671bb20)
b9e0: ffff80003671bc00 ffff80003671bbd0 0000000000000000 0000000000000000
ba00: ffff80002c296190 ffff80003671b9f8 ffff80003671bc9c 0000000080808080
ba20: fefefeff31677364 7f7f7f7f7f7f7f7f fefefefefefefeff 0101010101010101
ba40: 0000000000000020 0000000000000000 ffffffffffffffff 0000000000000000
ba60: 0000000000000000 0000000000000001 000000000000040d ffff80003671bbd0
ba80: 0000000000000000 ffff80003671bbd0 0000000000000000 0000004000114809
baa0: ffff000008f74d00 0000000000000124 000000000000001d ffff000008912000
bac0: ffff800035e74180 ffff80003671bb20 ffff000000dcca84 ffff80003671bb20
bae0: ffff0000086f7f30 0000000020000005 ffff80002c296000 ffff800035223900
bb00: 0000ffffffffffff 0000000000000000 ffff80003671bb20 ffff0000086f7f30
[<ffff0000086f7f30>] phy_ethtool_ksettings_get+0x20/0x98
[<ffff000000dcca84>] lan78xx_get_link_ksettings+0x44/0x60 [lan78xx]
[<ffff0000087cbc40>] ethtool_get_settings+0x68/0x210
[<ffff0000087cc0d4>] dev_ethtool+0x214/0x2180
[<ffff0000087e5008>] dev_ioctl+0x400/0x630
[<ffff00000879dd00>] sock_do_ioctl+0x70/0x88
[<ffff00000879f5f8>] sock_ioctl+0x208/0x368
[<ffff0000082cde10>] do_vfs_ioctl+0xb0/0x848
[<ffff0000082ce634>] SyS_ioctl+0x8c/0xa8
Exception stack(0xffff80003671bec0 to 0xffff80003671c000)
bec0: 0000000000000009 0000000000008946 0000fffff4e841d0 0000aa0032687465
bee0: 0000aaaafa2319d4 0000fffff4e841d4 0000000032687465 0000000032687465
bf00: 000000000000001d 7f7fff7f7f7f7f7f 72606b622e71ff4c 7f7f7f7f7f7f7f7f
bf20: 0101010101010101 0000000000000020 ffffffffffffffff 0000ffff7f510c68
bf40: 0000ffff7f6a9d18 0000ffff7f44ce30 000000000000040d 0000ffff7f6f98f0
bf60: 0000fffff4e842c0 0000000000000001 0000aaaafa2c2e00 0000ffff7f6ab000
bf80: 0000fffff4e842c0 0000ffff7f62a000 0000aaaafa2b9f20 0000aaaafa2c2e00
bfa0: 0000fffff4e84818 0000fffff4e841a0 0000ffff7f5ad0cc 0000fffff4e841a0
bfc0: 0000ffff7f44ce3c 0000000080000000 0000000000000009 000000000000001d
bfe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000The culprit is quite simple: The driver tries to access the phy left and right, but only actually has a working reference to it when the device is up.
The fix thus is quite simple too: Get a reference to the phy on probe already and keep it even when the device is going down.
With this patch applied, I can successfully run wicked on my system and bring the interface up and down as many times as I want, without getting NULL pointer dereferences in between.
--- drivers/net/usb/lan78xx.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-)
drivers/net/usb/lan78xx.c +18 -16
@@ -2083,10 +2083,6 @@ static int lan78xx_phy_init(struct lan78 dev->fc_autoneg = phydev->autoneg; -phy_start (phydev); - -netif_dbg (dev, ifup, dev->net,"phy initialised successfully" ); -return 0 ; error:
@@ -2523,9 +2519,9 @@ static int lan78xx_open(struct net_devicif (ret <0 ) goto done; - ret =lan78xx_phy_init (dev); -if (ret <0 ) - goto done; +phy_start (net->phydev); + +netif_dbg (dev, ifup, dev->net,"phy initialised successfully" );/* for Link Check */ if (dev->urb_intr) {
@@ -2586,13 +2582,8 @@ static int lan78xx_stop(struct net_devicif (timer_pending (&dev->stat_monitor))del_timer_sync (&dev->stat_monitor); -phy_unregister_fixup_for_uid (PHY_KSZ9031RNX ,0xfffffff0 ); -phy_unregister_fixup_for_uid (PHY_LAN8835 ,0xfffffff0 ); - -phy_stop (net->phydev); -phy_disconnect (net->phydev); - - net->phydev =NULL ; +if (net->phydev) +phy_stop (net->phydev);clear_bit (EVENT_DEV_OPEN , &dev->flags);netif_stop_queue (net);
@@ -3507,8 +3498,13 @@ static void lan78xx_disconnect(struct usreturn ; udev =interface_to_usbdev (intf); - net = dev->net; + +phy_unregister_fixup_for_uid (PHY_KSZ9031RNX ,0xfffffff0 ); +phy_unregister_fixup_for_uid (PHY_LAN8835 ,0xfffffff0 ); + +phy_disconnect (net->phydev); +unregister_netdev (net);cancel_delayed_work_sync (&dev->wq);
@@ -3664,8 +3660,14 @@ static int lan78xx_probe(struct usb_intepm_runtime_set_autosuspend_delay (&udev->dev,DEFAULT_AUTOSUSPEND_DELAY ); + ret =lan78xx_phy_init (dev); +if (ret <0 ) + goto out4; +return 0 ; +out4: +unregister_netdev (netdev); out3:lan78xx_unbind (dev, intf); out2:
@@ -4013,7 +4015,7 @@ static int lan78xx_reset_resume(struct ulan78xx_reset (dev); -lan78xx_phy_init (dev); +phy_start (dev->net->phydev);return lan78xx_resume (intf); }
Greg Kroah-Hartman
maintainerPATCH 112/272 mt76x2: fix possible NULL pointer dereferencing in mt76x2_tx()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 6958b027435aa54d82bbef09a007fd287f439977 ]
Fix a theoretical NULL pointer dereferencing in mt76x2_tx routine that can occurs for injected frames in a monitor vif since vif pointer could be NULL for that interfaces
--- drivers/net/wireless/mediatek/mt76/mt76x2_tx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76x2_tx.c +4 -1
@@ -36,9 +36,12 @@ void mt76x2_tx(struct ieee80211_hw *hw, msta = (struct mt76x2_sta *) control->sta->drv_priv; wcid = &msta->wcid; +/* sw encrypted frames */ +if (!info->control.hw_key && wcid->hw_key_idx !=-1 ) + control->sta =NULL ; } -if (vif || (!info->control.hw_key && wcid->hw_key_idx !=-1 )) { +if (vif && !control->sta) {struct mt76x2_vif *mvif; mvif = (struct mt76x2_vif *) vif->drv_priv;
Greg Kroah-Hartman
maintainerPATCH 121/272 watchdog: davinci_wdt: fix error handling in davinci_wdt_probe()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Khoroshilov <[email protected]>
[ Upstream commit d66e53649c18377edc08d48901e658e4fd491d46 ]
clk_disable_unprepare() was added to one error path, but there is another one. The patch makes sure clk is disabled at the both of them.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/watchdog/davinci_wdt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/watchdog/davinci_wdt.c +11 -4
@@ -236,15 +236,22 @@ static int davinci_wdt_probe(struct plat wdt_mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); davinci_wdt->base =devm_ioremap_resource (dev, wdt_mem); -if (IS_ERR (davinci_wdt->base)) -return PTR_ERR (davinci_wdt->base); +if (IS_ERR (davinci_wdt->base)) { + ret =PTR_ERR (davinci_wdt->base); + goto err_clk_disable; + } ret =watchdog_register_device (wdd); -if (ret <0 ) { -clk_disable_unprepare (davinci_wdt->clk); +if (ret) {dev_err (dev,"cannot register watchdog device\n" ); + goto err_clk_disable; } +return 0 ; + +err_clk_disable: +clk_disable_unprepare (davinci_wdt->clk); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 122/272 net: hns3: fix for the wrong shift problem in hns3_set_txbd_baseinfo
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuyun Liang <[email protected]>
[ Upstream commit 3c8f5c0339515202e8662b6e3ae36a7b16610caf ]
Third parameter of hnae_set_field is shift, But a mask is given. This patch fixes it by replacing HNS3_TXD_BDTYPE_M with HNS3_TXD_BDTYPE_S.
--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +1 -1
@@ -747,7 +747,7 @@ static void hns3_set_txbd_baseinfo(u16 * {/* Config bd buffer end */ hnae_set_field (*bdtp_fe_sc_vld_ra_ri,HNS3_TXD_BDTYPE_M , -HNS3_TXD_BDTYPE_M ,0 ); +HNS3_TXD_BDTYPE_S ,0 );hnae_set_bit (*bdtp_fe_sc_vld_ra_ri,HNS3_TXD_FE_B , !!frag_end);hnae_set_bit (*bdtp_fe_sc_vld_ra_ri,HNS3_TXD_VLD_B ,1 );hnae_set_field (*bdtp_fe_sc_vld_ra_ri,HNS3_TXD_SC_M ,HNS3_TXD_SC_S ,0 );
Greg Kroah-Hartman
maintainerPATCH 123/272 net: hns3: fix for returning wrong value problem in hns3_get_rss_indir_size
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuyun Liang <[email protected]>
[ Upstream commit da44a00f06df1f823ea449065e79581ee624de4b ]
The return type of hns3_get_rss_indir_size is u32. But a negative value is returned. This patch fixes it by replacing the negative value with zero.
--- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +1 -1
@@ -709,7 +709,7 @@ static u32 hns3_get_rss_indir_size(strucif (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_rss_indir_size) -return -EOPNOTSUPP ; +return 0 ;return h->ae_algo->ops->get_rss_indir_size (h); }
Greg Kroah-Hartman
maintainerPATCH 124/272 net: hns3: fix for returning wrong value problem in hns3_get_rss_key_size
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuyun Liang <[email protected]>
[ Upstream commit 3bd6d258b1d5f76744567855d1376358a94f127d ]
The return type of hns3_get_rss_key_size is u32. But a negative value is returned. This patch fixes it by replacing the negative value with zero.
--- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +1 -1
@@ -698,7 +698,7 @@ static u32 hns3_get_rss_key_size(structif (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_rss_key_size) -return -EOPNOTSUPP ; +return 0 ;return h->ae_algo->ops->get_rss_key_size (h); }
Greg Kroah-Hartman
maintainerPATCH 125/272 net: qualcomm: rmnet: check for null ep to avoid null pointer dereference
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
[ Upstream commit 0c29ba1b43df1eb7d8beb03fc929d2dac4c15f7e ]
The call to rmnet_get_endpoint can potentially return NULL so check for this to avoid any subsequent null pointer dereferences on a NULL ep.
Detected by CoverityScan, CID#1465385 ("Dereference null return value")
--- drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +2 -0
@@ -307,6 +307,8 @@ static int rmnet_changelink(struct net_dif (data[IFLA_VLAN_ID ]) { mux_id =nla_get_u16 (data[IFLA_VLAN_ID ]); ep =rmnet_get_endpoint (port, priv->mux_id); +if (!ep) +return -ENODEV ;hlist_del_init_rcu (&ep->hlnode);hlist_add_head_rcu (&ep->hlnode, &port->muxed_ep[mux_id]);
Greg Kroah-Hartman
maintainerPATCH 127/272 nvme_fc: fix abort race on teardown with lld reject
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Smart <[email protected]>
[ Upstream commit b12740d316fa89f3f6191b71f986cf3b9383d379 ]
Another abort race: An io request is started, becomes active, and is attempted to be started with the lldd. At the same time the controller is stopped/torndown and an itterator is run to abort the ios. As the io is active, it is added to the outstanding aborted io count. However on the original io request thread, the driver ends up rejecting the io due to the condition that induced the controller teardown. The driver reject path didn't check whether it was in the outstanding io count. This left the count outstanding stopping controller teardown.
Correct by, in the driver reject case, setting the state to inactive and checking whether it was in the outstanding io count.
--- drivers/nvme/host/fc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/host/fc.c +4 -1
@@ -2191,7 +2191,7 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrlstruct nvme_fc_cmd_iu *cmdiu = &op->cmd_iu;struct nvme_command *sqe = &cmdiu->sqe;u32 csn; -int ret; +int ret, opstate;/* * before attempting to send the io, check to see if we believe
@@ -2269,6 +2269,9 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl queue->lldd_handle, &op->fcp_req);if (ret) { + opstate =atomic_xchg (&op->state,FCPOP_STATE_COMPLETE ); +__nvme_fc_fcpop_chk_teardowns (ctrl, op, opstate); +if (!(op->flags &FCOP_FLAGS_AEN ))nvme_fc_unmap_data (ctrl, op->rq, op);
Greg Kroah-Hartman
maintainerPATCH 130/272 btrfs: fix null pointer deref when target device is missing
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
[ Upstream commit acf18c56fdcb952a06650282192e3b4ca1855c5e ]
The replace target device can be missing when mounted with -o degraded, but we wont allocate a missing btrfs_device to it. So check the device before accessing.
BUG: unable to handle kernel NULL pointer dereference at 00000000000000b0 IP: btrfs_destroy_dev_replace_tgtdev+0x43/0xf0 [btrfs] Call Trace: btrfs_dev_replace_cancel+0x15f/0x180 [btrfs] btrfs_ioctl+0x2216/0x2590 [btrfs] do_vfs_ioctl+0x625/0x650 SyS_ioctl+0x4e/0x80 do_syscall_64+0x5d/0x160 entry_SYSCALL64_slow_path+0x25/0x25
This patch has been moved in front of patch "btrfs: log, when replace, is canceled by the user" that could reproduce the crash if the system reboots inside btrfs_dev_replace_start before the btrfs_dev_replace_finishing call.
$ mkfs /dev/sda $ mount /dev/sda mnt $ btrfs replace start /dev/sda /dev/sdb <insert reboot> $ mount po degraded /dev/sdb mnt <crash>
--- fs/btrfs/dev-replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/dev-replace.c +1 -1
@@ -307,7 +307,7 @@ void btrfs_after_dev_replace_commit(strustatic char *btrfs_dev_name (struct btrfs_device *device) { -if (test_bit (BTRFS_DEV_STATE_MISSING , &device->dev_state)) +if (!device ||test_bit (BTRFS_DEV_STATE_MISSING , &device->dev_state))return "<missing disk>" ;else return rcu_str_deref (device->name);
Greg Kroah-Hartman
maintainerPATCH 113/272 mt76x2: fix warning in ieee80211_get_key_rx_seq()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit c03a5aacde0c86f6dabab8f17a6d1911ee13b6c4 ]
Fall back to software encryption for hw unsupported ciphers in order to fix the following warning in ieee80211_get_key_rx_seq routine:
WARNING: CPU: 1 PID: 1277 at backports-2017-11-01/net/mac80211/key.c:
1010 mt76_wcid_key_setup+0x6c/0x138 [mt76]
CPU: 1 PID: 1277 Comm: hostapd Tainted: G W 4.9.86 #0
Stack : 00000000 00000000 80527b4a 00000042 80523824 00000000 00000000 80520000
8fd79a9c 804bbda7 80454c84 00000001 000004fd 80523824 8f7e4ba0 8eceda12
00000010 8006af94 00000001 80520000 804c1f04 804c1f08 80459890 8ec999b4
00000003 800a7840 8f7e4ba0 8eceda12 8121de20 00000000 00000001 00c999b4
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
...
Call Trace:
[<8000f52c>] show_stack+0x70/0x8c
[<801d8d04>] dump_stack+0x94/0xd0
[<8002bcd4>] __warn+0x110/0x118
[<8002bd70>] warn_slowpath_null+0x1c/0x2c
[<8f0415cc>] mt76_wcid_key_setup+0x6c/0x138 [mt76]
[<8f1311b4>] mt76x2_dma_cleanup+0xa38/0x1048 [mt76x2e]--- drivers/net/wireless/mediatek/mt76/mt76x2_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76x2_main.c +11 -0
@@ -336,6 +336,17 @@ mt76x2_set_key(struct ieee80211_hw *hw,int idx = key->keyidx;int ret; +/* fall back to sw encryption for unsupported ciphers */ +switch (key->cipher) { +case WLAN_CIPHER_SUITE_WEP40 : +case WLAN_CIPHER_SUITE_WEP104 : +case WLAN_CIPHER_SUITE_TKIP : +case WLAN_CIPHER_SUITE_CCMP : +break ; +default : +return -EOPNOTSUPP ; + } +/* * The hardware does not support per-STA RX GTK, fall back * to software mode for these.
Greg Kroah-Hartman
maintainerPATCH 131/272 cxgb4: Setup FW queues before registering netdev
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arjun Vynipadath <[email protected]>
[ Upstream commit 843bd7db79c861b49e2912d723625f5fa8e94502 ]
When NetworkManager is enabled, there are chances that interface up is called even before probe completes. This means we have not yet allocated the FW sge queues, hence rest of ingress queue allocation wont be proper. Fix this by calling setup_fw_sge_queues() before register_netdev().
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +8 -3
@@ -833,8 +833,6 @@ static int setup_fw_sge_queues(struct ad err =t4_sge_alloc_rxq (adap, &s->fw_evtq, true, adap->port[0 ], adap->msi_idx,NULL , fwevtq_handler,NULL ,-1 ); -if (err) -t4_free_sge_resources (adap);return err; }
@@ -5474,6 +5472,13 @@ static int init_one(struct pci_dev *pdevif (err) goto out_free_dev; + err =setup_fw_sge_queues (adapter); +if (err) { +dev_err (adapter->pdev_dev, +"FW sge queue allocation failed, err %d" , err); + goto out_free_dev; + } +/* * The card is now ready to go. If any errors occur during device * registration we do not fail the whole card but rather proceed only
@@ -5522,10 +5527,10 @@ static int init_one(struct pci_dev *pdevcxgb4_ptp_init (adapter);print_adapter_info (adapter); -setup_fw_sge_queues (adapter);return 0 ; out_free_dev: +t4_free_sge_resources (adapter);free_some_resources (adapter);if (adapter->flags &USING_MSIX )free_msix_info (adapter);
Greg Kroah-Hartman
maintainerPATCH 132/272 hv_netvsc: Fix the return status in RX path
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haiyang Zhang <[email protected]>
[ Upstream commit 5c71dadbb45970a8f0544a27ae8f1cbd9750e516 ]
As defined in hyperv_net.h, the NVSP_STAT_SUCCESS is one not zero. Some functions returns 0 when it actually means NVSP_STAT_SUCCESS. This patch fixes them.
In netvsc_receive(), it puts the last RNDIS packet's receive status for all packets in a vmxferpage which may contain multiple RNDIS packets.
This patch puts NVSP_STAT_FAIL in the receive completion if one of the packets in a vmxferpage fails.
--- drivers/net/hyperv/netvsc.c | 8 ++++++-- drivers/net/hyperv/netvsc_drv.c | 2 +- drivers/net/hyperv/rndis_filter.c | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-)
drivers/net/hyperv/netvsc.c +6 -2
@@ -1078,10 +1078,14 @@ static int netvsc_receive(struct net_devvoid *data = recv_buf + vmxferpage_packet->ranges[i].byte_offset;u32 buflen = vmxferpage_packet->ranges[i].byte_count; +int ret;/* Pass it to the upper layer */ - status =rndis_filter_receive (ndev, net_device, - channel, data, buflen); + ret =rndis_filter_receive (ndev, net_device, + channel, data, buflen); + +if (unlikely (ret !=NVSP_STAT_SUCCESS )) + status =NVSP_STAT_FAIL ; } enq_receive_complete(ndev, net_device, q_idx,
drivers/net/hyperv/netvsc_drv.c +1 -1
@@ -831,7 +831,7 @@ int netvsc_recv_callback(struct net_deviu64_stats_update_end (&rx_stats->syncp);napi_gro_receive (&nvchan->napi, skb); -return 0 ; +return NVSP_STAT_SUCCESS ; } static void netvsc_get_drvinfo(struct net_device *net,
drivers/net/hyperv/rndis_filter.c +2 -2
@@ -434,10 +434,10 @@ int rndis_filter_receive(struct net_devi"unhandled rndis message (type %u len %u)\n" , rndis_msg->ndis_msg_type, rndis_msg->msg_len); -break ; +return NVSP_STAT_FAIL ; } -return 0 ; +return NVSP_STAT_SUCCESS ; } static int rndis_filter_query_device(struct rndis_device *dev,
Greg Kroah-Hartman
maintainerPATCH 133/272 ima: Fix Kconfig to select TPM 2.0 CRB interface
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiandi An <[email protected]>
[ Upstream commit fac37c628fd5d68fd7298d9b57ae8601ee1b4723 ]
TPM_CRB driver provides TPM CRB 2.0 support. If it is built as a module, the TPM chip is registered after IMA init. tpm_pcr_read() in IMA fails and displays the following message even though eventually there is a TPM chip on the system.
ima: No TPM chip found, activating TPM-bypass! (rc=-19)
Fix IMA Kconfig to select TPM_CRB so TPM_CRB driver is built in the kernel and initializes before IMA.
--- security/integrity/ima/Kconfig | 1 + 1 file changed, 1 insertion(+)
security/integrity/ima/Kconfig +1 -0
@@ -10,6 +10,7 @@ config IMA select CRYPTO_HASH_INFO select TCG_TPM if HAS_IOMEM && !UML select TCG_TIS if TCG_TPM && X86 + select TCG_CRB if TCG_TPM && ACPI select TCG_IBMVTPM if TCG_TPM && PPC_PSERIES help The Trusted Computing Group(TCG) runtime Integrity
Greg Kroah-Hartman
maintainerPATCH 134/272 ima: Fallback to the builtin hash algorithm
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Vorel <[email protected]>
[ Upstream commit ab60368ab6a452466885ef4edf0cefd089465132 ]
IMA requires having it's hash algorithm be compiled-in due to it's early use. The default IMA algorithm is protected by Kconfig to be compiled-in.
The ima_hash kernel parameter allows to choose the hash algorithm. When the specified algorithm is not available or available as a module, IMA initialization fails, which leads to a kernel panic (mknodat syscall calls ima_post_path_mknod()). Therefore as fallback we force IMA to use the default builtin Kconfig hash algorithm.
Fixed crash:
$ grep CONFIG_CRYPTO_MD4 .config CONFIG_CRYPTO_MD4=m
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.12.14-2.3-default root=UUID=74ae8202-9ca7-4e39-813b-22287ec52f7a video=1024x768-16 plymouth.ignore-serial-consoles console=ttyS0 console=tty resume=/dev/disk/by-path/pci-0000:00:07.0-part3 splash=silent showopts ima_hash=md4 ... [ 1.545190] ima: Can not allocate md4 (reason: -2) ... [ 2.610120] BUG: unable to handle kernel NULL pointer dereference at (null) [ 2.611903] IP: ima_match_policy+0x23/0x390 [ 2.612967] PGD 0 P4D 0 [ 2.613080] Oops: 0000 [#1] SMP [ 2.613080] Modules linked in: autofs4 [ 2.613080] Supported: Yes [ 2.613080] CPU: 0 PID: 1 Comm: systemd Not tainted 4.12.14-2.3-default #1 [ 2.613080] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 [ 2.613080] task: ffff88003e2d0040 task.stack: ffffc90000190000 [ 2.613080] RIP: 0010:ima_match_policy+0x23/0x390 [ 2.613080] RSP: 0018:ffffc90000193e88 EFLAGS: 00010296 [ 2.613080] RAX: 0000000000000000 RBX: 000000000000000c RCX: 0000000000000004 [ 2.613080] RDX: 0000000000000010 RSI: 0000000000000001 RDI: ffff880037071728 [ 2.613080] RBP: 0000000000008000 R08: 0000000000000000 R09: 0000000000000000 [ 2.613080] R10: 0000000000000008 R11: 61c8864680b583eb R12: 00005580ff10086f [ 2.613080] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000008000 [ 2.613080] FS: 00007f5c1da08940(0000) GS:ffff88003fc00000(0000) knlGS:0000000000000000 [ 2.613080] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2.613080] CR2: 0000000000000000 CR3: 0000000037002000 CR4: 00000000003406f0 [ 2.613080] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 2.613080] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 2.613080] Call Trace: [ 2.613080] ? shmem_mknod+0xbf/0xd0 [ 2.613080] ima_post_path_mknod+0x1c/0x40 [ 2.613080] SyS_mknod+0x210/0x220 [ 2.613080] entry_SYSCALL_64_fastpath+0x1a/0xa5 [ 2.613080] RIP: 0033:0x7f5c1bfde570 [ 2.613080] RSP: 002b:00007ffde1c90dc8 EFLAGS: 00000246 ORIG_RAX: 0000000000000085 [ 2.613080] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5c1bfde570 [ 2.613080] RDX: 0000000000000000 RSI: 0000000000008000 RDI: 00005580ff10086f [ 2.613080] RBP: 00007ffde1c91040 R08: 00005580ff10086f R09: 0000000000000000 [ 2.613080] R10: 0000000000104000 R11: 0000000000000246 R12: 00005580ffb99660 [ 2.613080] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000002 [ 2.613080] Code: 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 41 57 41 56 44 8d 14 09 41 55 41 54 55 53 44 89 d3 09 cb 48 83 ec 38 48 8b 05 c5 03 29 01 <4c> 8b 20 4c 39 e0 0f 84 d7 01 00 00 4c 89 44 24 08 89 54 24 20 [ 2.613080] RIP: ima_match_policy+0x23/0x390 RSP: ffffc90000193e88 [ 2.613080] CR2: 0000000000000000 [ 2.613080] ---[ end trace 9a9f0a8a73079f6a ]--- [ 2.673052] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009 [ 2.673052] [ 2.675337] Kernel Offset: disabled [ 2.676405] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
--- security/integrity/ima/ima_crypto.c | 2 ++ security/integrity/ima/ima_main.c | 13 +++++++++++++ 2 files changed, 15 insertions(+)
security/integrity/ima/ima_crypto.c +2 -0
@@ -73,6 +73,8 @@ int __init ima_init_crypto(void) hash_algo_name[ima_hash_algo], rc);return rc; } +pr_info ("Allocated hash algorithm: %s\n" , + hash_algo_name[ima_hash_algo]);return 0 ; }
security/integrity/ima/ima_main.c +13 -0
@@ -16,6 +16,9 @@* implements the IMA hooks: ima_bprm_check, ima_file_mmap, * and ima_file_check. */ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/module.h> #include <linux/file.h> #include <linux/binfmts.h>
@@ -472,6 +475,16 @@ static int __init init_ima(void)ima_init_template_list ();hash_setup (CONFIG_IMA_DEFAULT_HASH ); error =ima_init (); + +if (error &&strcmp (hash_algo_name[ima_hash_algo], +CONFIG_IMA_DEFAULT_HASH ) !=0 ) { +pr_info ("Allocating %s failed, going to use default hash algorithm %s\n" , + hash_algo_name[ima_hash_algo],CONFIG_IMA_DEFAULT_HASH ); + hash_setup_done =0 ; +hash_setup (CONFIG_IMA_DEFAULT_HASH ); + error =ima_init (); + } +if (!error) { ima_initialized =1 ;ima_update_policy_flag ();
Greg Kroah-Hartman
maintainerPATCH 135/272 watchdog: aspeed: Allow configuring for alternate boot
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Milton Miller <[email protected]>
[ Upstream commit 6ffa3402211acc30e47e691e14d62f3fd065a54e ]
Allow the device tree to specify a watchdog to fallover to the alternate boot source.
The aspeeed watchdog can set a latch directing flash chip select 0 to chip select 1, allowing boot from an alternate media if the watchdog is not reset in time. On the ast2400 bank 1 also goes to flash bank 1, while on the ast2500 the chip selects are swapped.
Also clear the secondary boot bit during the machine restart operation. Otherwise, the system will switch to the alternate boot after every reboot, which is not desired.
--- drivers/watchdog/aspeed_wdt.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/watchdog/aspeed_wdt.c +4 -0
@@ -46,6 +46,7 @@ MODULE_DEVICE_TABLE(of, aspeed_wdt_of_ta#define WDT_RELOAD_VALUE 0x04#define WDT_RESTART 0x08#define WDT_CTRL 0x0C +#define WDT_CTRL_BOOT_SECONDARY BIT(7)#define WDT_CTRL_RESET_MODE_SOC (0x00 << 5)#define WDT_CTRL_RESET_MODE_FULL_CHIP (0x01 << 5)#define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5)
@@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct wat {struct aspeed_wdt *wdt =to_aspeed_wdt (wdd); + wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY ;aspeed_wdt_enable (wdt,128 *WDT_RATE_1MHZ /1000 );mdelay (1000 );
@@ -242,6 +244,8 @@ static int aspeed_wdt_probe(struct platf }if (of_property_read_bool (np,"aspeed,external-signal" )) wdt->ctrl |=WDT_CTRL_WDT_EXT ; +if (of_property_read_bool (np,"aspeed,alt-boot" )) + wdt->ctrl |=WDT_CTRL_BOOT_SECONDARY ;if (readl (wdt->base +WDT_CTRL ) &WDT_CTRL_ENABLE ) {/*
Greg Kroah-Hartman
maintainerPATCH 136/272 gfs2: Check for the end of metadata in punch_hole
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit bb491ce67aa7c1635e5ae4f2f304a7d13d3dbe71 ]
When punching a hole or truncating an inode down to a given size, also check if the truncate point / start of the hole is within the range we have metadata for. Otherwise, we can end up freeing blocks that shouldn't be freed, corrupting the inode, or crashing the machine when trying to punch a hole into the void.
When growing an inode via truncate, we set the new size but we don't allocate additional levels of indirect blocks and grow the inode height. When shrinking that inode again, the new size may still point beyond the end of the inode's metadata.
Fixes xfstest generic/476.
--- fs/gfs2/bmap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/gfs2/bmap.c +9 -1
@@ -1344,6 +1344,7 @@ static inline bool walk_done(struct gfs2static int punch_hole (struct gfs2_inode *ip,u64 offset,u64 length) {struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode); +u64 maxsize = sdp->sd_heightsize[ip->i_height];struct metapath mp = {};struct buffer_head *dibh, *bh;struct gfs2_holder rd_gh;
@@ -1359,6 +1360,14 @@ static int punch_hole(struct gfs2_inodeu64 prev_bnr =0 ;__be64 *start, *end; +if (offset >= maxsize) { +/* +* The starting point lies beyond the allocated meta-data; +* there are no blocks do deallocate. +*/ +return 0 ; + } +/* * The start position of the hole is defined by lblock, start_list, and * start_aligned. The end position of the hole is defined by lend,
@@ -1372,7 +1381,6 @@ static int punch_hole(struct gfs2_inode*/ if (length) { -u64 maxsize = sdp->sd_heightsize[ip->i_height];u64 end_offset = offset + length;u64 lend;
Greg Kroah-Hartman
maintainerPATCH 137/272 virtio-net: Fix operstate for virtio when no VIRTIO_NET_F_STATUS
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jay Vosburgh <[email protected]>
[ Upstream commit bda7fab54828bbef2164bb23c0f6b1a7d05cc718 ]
The operstate update logic will leave an interface in the default UNKNOWN operstate if the interface carrier state never changes from the default carrier up state set at creation. This includes the case of an explicit call to netif_carrier_on, as the carrier on to on transition has no effect on operstate.
This affects virtio-net for the case that the virtio peer does
not support VIRTIO_NET_F_STATUS (the feature that provides carrier state updates). Without this feature, the virtio specification states that "the link should be assumed active," so, logically, the operstate should be UP instead of UNKNOWN. This has impact on user space applications that use the operstate to make availability decisions for the interface.
Resolve this by changing the virtio probe logic slightly to callnetif_carrier_off for both the "with" and "without" VIRTIO_NET_F_STATUS cases, and then the existing call to netif_carrier_on for the "without" case will cause an operstate transition.
--- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio_net.c +1 -1
@@ -2874,8 +2874,8 @@ static int virtnet_probe(struct virtio_d/* Assume link up if device can't report link status, otherwise get link status from config. */ +netif_carrier_off (dev);if (virtio_has_feature (vi->vdev,VIRTIO_NET_F_STATUS )) { -netif_carrier_off (dev);schedule_work (&vi->config_work); }else { vi->status =VIRTIO_NET_S_LINK_UP ;
Greg Kroah-Hartman
maintainerPATCH 138/272 arm: dts: socfpga: fix GIC PPI warning
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philipp Puschmann <[email protected]>
[ Upstream commit 6d97d5aba08b26108f95dc9fb7bbe4d9436c769c ]
Fixes the warning "GIC: PPI13 is secure or misconfigured" by changing the interrupt type from level_low to edge_raising
--- arch/arm/boot/dts/socfpga.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/socfpga.dtsi +1 -1
@@ -831,7 +831,7 @@ timer@fffec600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0xfffec600 0x100>; - interrupts = <1 13 0xf04>; + interrupts = <1 13 0xf01>; clocks = <&mpu_periph_clk>; };
Greg Kroah-Hartman
maintainerPATCH 139/272 ima: clear IMA_HASH
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mimi Zohar <[email protected]>
[ Upstream commit a9a4935d44b58c858a81393694bc232a96cdcbd4 ]
The IMA_APPRAISE and IMA_HASH policies overlap. Clear IMA_HASH properly.
--- security/integrity/ima/ima_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_policy.c +1 -1
@@ -384,7 +384,7 @@ int ima_match_policy(struct inode *inode action |= entry->action &IMA_DO_MASK ;if (entry->action &IMA_APPRAISE ) { action |=get_subaction (entry, func); - action ^=IMA_HASH ; + action &= ~IMA_HASH ; }if (entry->action &IMA_DO_MASK )
Greg Kroah-Hartman
maintainerPATCH 140/272 ext4: dont complain about incorrect features when probing
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Sandeen <[email protected]>
[ Upstream commit 0d9366d67bcf066b028e57d09c9a86ce879bcc28 ]
If mount is auto-probing for filesystem type, it will try various filesystems in order, with the MS_SILENT flag set. We get that flag as the silent arg to ext4_fill_super.
If we're probing (silent==1) then don't complain about feature incompatibilities that are found if it looks like it's actually a different valid extN type - failed probes should be silent in this case.
If the on-disk features are unknown even to ext4, then complain.
--- fs/ext4/super.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/ext4/super.c +12 -0
@@ -3663,6 +3663,12 @@ static int ext4_fill_super(struct super_ext4_msg (sb,KERN_INFO ,"mounting ext2 file system " "using the ext4 subsystem" ); else { +/* +* If we're probing be silent, if this looks like +* it's actually an ext[34] filesystem. +*/ +if (silent &&ext4_feature_set_ok (sb,sb_rdonly (sb))) + goto failed_mount;ext4_msg (sb,KERN_ERR ,"couldn't mount as ext2 due " "to feature incompatibilities" ); goto failed_mount;
@@ -3674,6 +3680,12 @@ static int ext4_fill_super(struct super_ext4_msg (sb,KERN_INFO ,"mounting ext3 file system " "using the ext4 subsystem" ); else { +/* +* If we're probing be silent, if this looks like +* it's actually an ext4 filesystem. +*/ +if (silent &&ext4_feature_set_ok (sb,sb_rdonly (sb))) + goto failed_mount;ext4_msg (sb,KERN_ERR ,"couldn't mount as ext3 due " "to feature incompatibilities" ); goto failed_mount;
Greg Kroah-Hartman
maintainerPATCH 114/272 powerpc/perf: Prevent kernel address leak to userspace via BHRB buffer
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Madhavan Srinivasan <[email protected]>
[ Upstream commit bb19af816025d495376bd76bf6fbcf4244f9a06d ]
The current Branch History Rolling Buffer (BHRB) code does not check for any privilege levels before updating the data from BHRB. This could leak kernel addresses to userspace even when profiling only with userspace privileges. Add proper checks to prevent it.
--- arch/powerpc/perf/core-book3s.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/powerpc/perf/core-book3s.c +10 -0
@@ -457,6 +457,16 @@ static void power_pmu_bhrb_read(struct c/* invalid entry */ continue ; +/* +* BHRB rolling buffer could very much contain the kernel +* addresses at this point. Check the privileges before +* exporting it to userspace (avoid exposure of regions +* where we could have speculative execution) +*/ +if (perf_paranoid_kernel () && !capable (CAP_SYS_ADMIN ) && +is_kernel_addr (addr)) +continue ; +/* Branches are read most recent first (ie. mfbhrb 0 is * the most recent branch). * There are two types of valid entries:
Greg Kroah-Hartman
maintainerPATCH 141/272 drm/vmwgfx: Unpin the screen object backup buffer when not used
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellstrom <[email protected]>
[ Upstream commit 20fb5a635a0c8478ac98f15cfafc2ea83df29565 ]
We were relying on the pinned screen object backup buffer to be destroyed when not used. But if we hold a copy of the atomic state, like when hibernating, the backup buffer might not be destroyed since it's refcounted by the atomic state. This causes us to hibernate with a buffer pinned in VRAM.
Fix this by only having the buffer pinned when it is actually used by a screen object.
--- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +21 -8
@@ -453,7 +453,11 @@ vmw_sou_primary_plane_cleanup_fb(struct struct drm_plane_state *old_state) {struct vmw_plane_state *vps =vmw_plane_state_to_vps (old_state); +struct drm_crtc *crtc = plane->state->crtc ? + plane->state->crtc : old_state->crtc; +if (vps->dmabuf) +vmw_dmabuf_unpin (vmw_priv (crtc->dev), vps->dmabuf, false);vmw_dmabuf_unreference (&vps->dmabuf); vps->dmabuf_size =0 ;
@@ -491,10 +495,17 @@ vmw_sou_primary_plane_prepare_fb(struct } size = new_state->crtc_w * new_state->crtc_h *4 ; + dev_priv =vmw_priv (crtc->dev);if (vps->dmabuf) { -if (vps->dmabuf_size == size) -return 0 ; +if (vps->dmabuf_size == size) { +/* +* Note that this might temporarily up the pin-count +* to 2, until cleanup_fb() is called. +*/ +return vmw_dmabuf_pin_in_vram (dev_priv, vps->dmabuf, + true); + }vmw_dmabuf_unreference (&vps->dmabuf); vps->dmabuf_size =0 ;
@@ -504,7 +515,6 @@ vmw_sou_primary_plane_prepare_fb(structif (!vps->dmabuf)return -ENOMEM ; - dev_priv =vmw_priv (crtc->dev);vmw_svga_enable (dev_priv);/* After we have alloced the backing store might not be able to
@@ -515,13 +525,16 @@ vmw_sou_primary_plane_prepare_fb(struct &vmw_vram_ne_placement, false, &vmw_dmabuf_bo_free);vmw_overlay_resume_all (dev_priv); - -if (ret !=0 ) +if (ret) { vps->dmabuf =NULL ;/* vmw_dmabuf_init frees on error */ -else - vps->dmabuf_size = size; +return ret; + } -return ret; +/* +* TTM already thinks the buffer is pinned, but make sure the +* pin_count is upped. +*/ +return vmw_dmabuf_pin_in_vram (dev_priv, vps->dmabuf, true); }
Greg Kroah-Hartman
maintainerPATCH 142/272 iommu/mediatek: Fix protect memory setting
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yong Wu <[email protected]>
[ Upstream commit 70ca608b2ec6dafa6bb1c2b0691852fc78f8f717 ]
In MediaTek's IOMMU design, When a iommu translation fault occurs (HW can NOT translate the destination address to a valid physical address), the IOMMU HW output the dirty data into a special memory to avoid corrupting the main memory, this is called "protect memory". the register(0x114) for protect memory is a little different between mt8173 and mt2712.
In the mt8173, bit[30:6] in the register represents [31:7] of the physical address. In the 4GB mode, the register bit[31] should be 1. While in the mt2712, the bits don't shift. bit[31:7] in the register represents [31:7] in the physical address, and bit[1:0] in the register represents bit[33:32] of the physical address if it has.
--- drivers/iommu/mtk_iommu.c | 15 ++++++++++----- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/iommu/mtk_iommu.c +10 -5
@@ -60,7 +60,7 @@ (((prot) & 0x3) << F_MMU_TF_PROTECT_SEL_SHIFT(data))#define REG_MMU_IVRP_PADDR 0x114 -#define F_MMU_IVRP_PA_SET (pa, ext) (((pa) >> 1) | ((!!(ext)) << 31)) +#define REG_MMU_VLD_PA_RNG 0x118#define F_MMU_VLD_PA_RNG (EA ,SA ) (((EA) << 8) | (SA))
@@ -539,8 +539,13 @@ static int mtk_iommu_hw_init(const strucF_INT_PRETETCH_TRANSATION_FIFO_FAULT ;writel_relaxed (regval, data->base +REG_MMU_INT_MAIN_CONTROL ); -writel_relaxed (F_MMU_IVRP_PA_SET (data->protect_base, data->enable_4GB), - data->base +REG_MMU_IVRP_PADDR ); +if (data->m4u_plat ==M4U_MT8173 ) + regval = (data->protect_base >>1 ) | (data->enable_4GB <<31 ); +else + regval =lower_32_bits (data->protect_base) | +upper_32_bits (data->protect_base); +writel_relaxed (regval, data->base +REG_MMU_IVRP_PADDR ); +if (data->enable_4GB && data->m4u_plat !=M4U_MT8173 ) {/* * If 4GB mode is enabled, the validate PA range is from
@@ -695,6 +700,7 @@ static int __maybe_unused mtk_iommu_susp reg->ctrl_reg =readl_relaxed (base +REG_MMU_CTRL_REG ); reg->int_control0 =readl_relaxed (base +REG_MMU_INT_CONTROL0 ); reg->int_main_control =readl_relaxed (base +REG_MMU_INT_MAIN_CONTROL ); + reg->ivrp_paddr =readl_relaxed (base +REG_MMU_IVRP_PADDR );clk_disable_unprepare (data->bclk);return 0 ; }
@@ -717,8 +723,7 @@ static int __maybe_unused mtk_iommu_resuwritel_relaxed (reg->ctrl_reg, base +REG_MMU_CTRL_REG );writel_relaxed (reg->int_control0, base +REG_MMU_INT_CONTROL0 );writel_relaxed (reg->int_main_control, base +REG_MMU_INT_MAIN_CONTROL ); -writel_relaxed (F_MMU_IVRP_PA_SET (data->protect_base, data->enable_4GB), - base +REG_MMU_IVRP_PADDR ); +writel_relaxed (reg->ivrp_paddr, base +REG_MMU_IVRP_PADDR );if (data->m4u_dom)writel (data->m4u_dom->cfg.arm_v7s_cfg.ttbr[0 ], base +REG_MMU_PT_BASE_ADDR );
drivers/iommu/mtk_iommu.h +1 -0
@@ -32,6 +32,7 @@ struct mtk_iommu_suspend_reg {u32 ctrl_reg;u32 int_control0;u32 int_main_control; +u32 ivrp_paddr; };enum mtk_iommu_plat {
Greg Kroah-Hartman
maintainerPATCH 143/272 cpufreq: cppc_cpufreq: Fix cppc_cpufreq_init() failure path
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chunyu Hu <[email protected]>
[ Upstream commit 55b55abc17f238c61921360e61dde90dd9a326d1 ]
Kmemleak reported the below leak. When cppc_cpufreq_init went into failure path, the cpu mask is not freed. After fix, this report is gone. And to avaoid potential NULL pointer reference, check the cpu value first.
unreferenced object 0xffff800fd5ea4880 (size 128):
comm "swapper/0", pid 1, jiffies 4294939510 (age 668.680s) hex dump (first 32 bytes):
00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 .... ...........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffff0000082c4ae4>] __kmalloc_node+0x278/0x634
[<ffff0000088f4a74>] alloc_cpumask_var_node+0x28/0x60
[<ffff0000088f4af0>] zalloc_cpumask_var+0x14/0x1c
[<ffff000008d20254>] cppc_cpufreq_init+0xd0/0x19c
[<ffff000008083828>] do_one_initcall+0xec/0x15c
[<ffff000008cd1018>] kernel_init_freeable+0x1f4/0x2a4
[<ffff0000089099b0>] kernel_init+0x18/0x10c
[<ffff000008084d50>] ret_from_fork+0x10/0x18
[<ffffffffffffffff>] 0xffffffffffffffff--- drivers/cpufreq/cppc_cpufreq.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +7 -2
@@ -243,8 +243,13 @@ static int __init cppc_cpufreq_init(voidreturn ret; out: -for_each_possible_cpu (i) -kfree (all_cpu_data[i]); +for_each_possible_cpu (i) { + cpu = all_cpu_data[i]; +if (!cpu) +break ; +free_cpumask_var (cpu->shared_cpu_map); +kfree (cpu); + }kfree (all_cpu_data);return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 144/272 firmware: fix checking for return values for fw_add_devm_name()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Luis R. Rodriguez" <[email protected]>
[ Upstream commit d15d7311550983be97dca44ad68cbc2ca001297b ]
Currently fw_add_devm_name() returns 1 if the firmware cache was already set. This makes it complicated for us to check for correctness. It is actually non-fatal if the firmware cache is already setup, so just return 0, and simplify the checkers.
fw_add_devm_name() adds device's name onto the devres for the device so that prior to suspend we cache the firmware onto memory, so that on resume the firmware is reliably available. We never were checking for success for this call though, meaning in some really rare cases we my have never setup the firmware cache for a device, which could in turn make resume fail.
This is all theoretical, no known issues have been reported. This small issue has been present way since the addition of the devres firmware cache names on v3.7.
--- drivers/base/firmware_class.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/base/firmware_class.c +9 -3
@@ -524,7 +524,7 @@ static int fw_add_devm_name(struct devic fwn =fw_find_devm_name (dev, name);if (fwn) -return 1 ; +return 0 ; fwn =devres_alloc (fw_name_devm_release,sizeof (struct fw_name_devm ),GFP_KERNEL );
@@ -552,6 +552,7 @@ static int assign_fw(struct firmware *fw unsigned int opt_flags) {struct fw_priv *fw_priv = fw->priv; +int ret;mutex_lock (&fw_lock);if (!fw_priv->size ||fw_state_is_aborted (fw_priv)) {
@@ -568,8 +569,13 @@ static int assign_fw(struct firmware *fw*/ /* don't cache firmware handled without uevent */ if (device && (opt_flags &FW_OPT_UEVENT ) && - !(opt_flags &FW_OPT_NOCACHE )) -fw_add_devm_name (device, fw_priv->fw_name); + !(opt_flags &FW_OPT_NOCACHE )) { + ret =fw_add_devm_name (device, fw_priv->fw_name); +if (ret) { +mutex_unlock (&fw_lock); +return ret; + } + }/* * After caching firmware image is started, let it piggyback
Greg Kroah-Hartman
maintainerPATCH 145/272 IB/mlx5: Set the default active rate and width to QDR and 4X
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Honggang Li <[email protected]>
[ Upstream commit 7672ed33c4c15dbe9d56880683baaba4227cf940 ]
Before commit f1b65df5a232 ("IB/mlx5: Add support for active_width and active_speed in RoCE"), the mlx5_ib driver set the default active_width and active_speed to IB_WIDTH_4X and IB_SPEED_QDR.
When the RoCE port is down, the RoCE port does not negotiate the active width with the remote side, causing the active width to be zero. When running userspace ibstat to view the port status, ibstat will panic as it reads an invalid width from sys file.
This patch restores the original behavior.
--- drivers/infiniband/hw/mlx5/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/mlx5/main.c +3 -0
@@ -388,6 +388,9 @@ static int mlx5_query_port_roce(struct iif (err) goto out; + props->active_width =IB_WIDTH_4X ; + props->active_speed =IB_SPEED_QDR ; +translate_eth_proto_oper (eth_prot_oper, &props->active_speed, &props->active_width);
Greg Kroah-Hartman
maintainerPATCH 146/272 zorro: Set up z->dev.dma_mask for the DMA API
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Schmitz <[email protected]>
[ Upstream commit 55496d3fe2acd1a365c43cbd613a20ecd4d74395 ]
The generic DMA API uses dev->dma_mask to check the DMA addressable memory bitmask, and warns if no mask is set or even allocated.
Set z->dev.dma_coherent_mask on Zorro bus scan, and make z->dev.dma_mask to point to z->dev.dma_coherent_mask so device drivers that need DMA have everything set up to avoid warnings from dma_alloc_coherent(). Drivers can still use dma_set_mask_and_coherent() to explicitly set their DMA bit mask.
--- drivers/zorro/zorro.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/zorro/zorro.c +12 -0
@@ -16,6 +16,7 @@#include <linux/bitops.h> #include <linux/string.h> #include <linux/platform_device.h> +#include <linux/dma-mapping.h> #include <linux/slab.h> #include <asm/byteorder.h>
@@ -185,6 +186,17 @@ static int __init amiga_zorro_probe(stru z->dev.parent = &bus->dev; z->dev.bus = &zorro_bus_type; z->dev.id = i; +switch (z->rom.er_Type &ERT_TYPEMASK ) { +case ERT_ZORROIII : + z->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); +break ; + +case ERT_ZORROII : +default : + z->dev.coherent_dma_mask =DMA_BIT_MASK (24 ); +break ; + } + z->dev.dma_mask = &z->dev.coherent_dma_mask; }/* ... then register them */
Greg Kroah-Hartman
maintainerPATCH 147/272 bcache: quit dc->writeback_thread when BCACHE_DEV_DETACHING is set
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Coly Li <[email protected]>
[ Upstream commit fadd94e05c02afec7b70b0b14915624f1782f578 ]
In patch "bcache: fix cached_dev->count usage for bch_cache_set_error()", cached_dev_get() is called when creating dc->writeback_thread, and cached_dev_put() is called when exiting dc->writeback_thread. This modification works well unless people detach the bcache device manually by
'echo 1 > /sys/block/bcache<N>/bcache/detach'
Because this sysfs interface only calls bch_cached_dev_detach() which wakes up dc->writeback_thread but does not stop it. The reason is, before patch "bcache: fix cached_dev->count usage for bch_cache_set_error()", inside bch_writeback_thread(), if cache is not dirty after writeback, cached_dev_put() will be called here. And in cached_dev_make_request() when a new write request makes cache from clean to dirty, cached_dev_get() will be called there. Since we don't operate dc->count in these locations, refcount d->count cannot be dropped after cache becomes clean, and cached_dev_detach_finish() won't be called to detach bcache device.
This patch fixes the issue by checking whether BCACHE_DEV_DETACHING is set inside bch_writeback_thread(). If this bit is set and cache is clean (no existing writeback_keys), break the while-loop, call cached_dev_put() and quit the writeback thread.
Please note if cache is still dirty, even BCACHE_DEV_DETACHING is set the writeback thread should continue to perform writeback, this is the original design of manually detach.
It is safe to do the following check without locking, let me explain why,
+ if (!test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) &&
+ (!atomic_read(&dc->has_dirty) || !dc->writeback_running)) {
If the kenrel thread does not sleep and continue to run due to conditions are not updated in time on the running CPU core, it just consumes more CPU cycles and has no hurt. This should-sleep-but-run is safe here. We just focus on the should-run-but-sleep condition, which means the writeback thread goes to sleep in mistake while it should continue to run. 1, First of all, no matter the writeback thread is hung or not,
kthread_stop() from cached_dev_detach_finish() will wake up it and terminate by making kthread_should_stop() return true. And in normal run time, bit on index BCACHE_DEV_DETACHING is always cleared, the condition
!test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)
is always true and can be ignored as constant value.
2, If one of the following conditions is true, the writeback thread should
go to sleep,
"!atomic_read(&dc->has_dirty)" or "!dc->writeback_running)" each of them independently controls the writeback thread should sleep or not, let's analyse them one by one.
2.1 condition "!atomic_read(&dc->has_dirty)"
If dc->has_dirty is set from 0 to 1 on another CPU core, bcache will call bch_writeback_queue() immediately or call bch_writeback_add() which indirectly calls bch_writeback_queue() too. In bch_writeback_queue(), wake_up_process(dc->writeback_thread) is called. It sets writeback thread's task state to TASK_RUNNING and following an implicit memory barrier, then tries to wake up the writeback thread.
In writeback thread, its task state is set to TASK_INTERRUPTIBLE before doing the condition check. If other CPU core sets the TASK_RUNNING state after writeback thread setting TASK_INTERRUPTIBLE, the writeback thread will be scheduled to run very soon because its state is not TASK_INTERRUPTIBLE. If other CPU core sets the TASK_RUNNING state before writeback thread setting TASK_INTERRUPTIBLE, the implict memory barrier of wake_up_process() will make sure modification of dc->has_dirty on other CPU core is updated and observed on the CPU core of writeback thread. Therefore the condition check will correctly be false, and continue writeback code without sleeping.
2.2 condition "!dc->writeback_running)"
dc->writeback_running can be changed via sysfs file, every time it is modified, a following bch_writeback_queue() is alwasy called. So the change is always observed on the CPU core of writeback thread. If dc->writeback_running is changed from 0 to 1 on other CPU core, this condition check will observe the modification and allow writeback thread to continue to run without sleeping.
Now we can see, even without a locking protection, multiple conditions check is safe here, no deadlock or process hang up will happen.
I compose a separte patch because that patch "bcache: fix cached_dev->count usage for bch_cache_set_error()" already gets a "Reviewed-by:" from Hannes Reinecke. Also this fix is not trivial and good for a separate patch.
--- drivers/md/bcache/writeback.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/md/bcache/writeback.c +17 -3
@@ -565,9 +565,15 @@ static int bch_writeback_thread(void *arwhile (!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)) { +/* +* If the bache device is detaching, skip here and continue +* to perform writeback. Otherwise, if no dirty data on cache, +* or there is dirty data on cache but writeback is disabled, +* the writeback thread should sleep here and wait for others +* to wake up it. +*/ +if (!test_bit (BCACHE_DEV_DETACHING , &dc->disk.flags) && + (!atomic_read (&dc->has_dirty) || !dc->writeback_running)) {up_write (&dc->writeback_lock);if (kthread_should_stop ()) {
@@ -588,6 +594,14 @@ static int bch_writeback_thread(void *arcached_dev_put (dc);SET_BDEV_STATE (&dc->sb,BDEV_STATE_CLEAN );bch_write_bdev_super (dc,NULL ); +/* +* If bcache device is detaching via sysfs interface, +* writeback thread should stop after there is no dirty +* data on cache. BCACHE_DEV_DETACHING flag is set in +* bch_cached_dev_detach(). +*/ +if (test_bit (BCACHE_DEV_DETACHING , &dc->disk.flags)) +break ; }up_write (&dc->writeback_lock);
Greg Kroah-Hartman
maintainerPATCH 148/272 remoteproc: imx_rproc: Fix an error handling path in imx_rproc_probe()
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit de6f83f85be94e0b7d0d324c29ccc9d78a6bb4e7 ]
If 'of_device_get_match_data()' fails, we must undo the previous 'rproc_alloc()' call.
--- drivers/remoteproc/imx_rproc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +4 -2
@@ -339,8 +339,10 @@ static int imx_rproc_probe(struct platfo } dcfg =of_device_get_match_data (dev); -if (!dcfg) -return -EINVAL ; +if (!dcfg) { + ret = -EINVAL ; + goto err_put_rproc; + } priv = rproc->priv; priv->rproc = rproc;
Greg Kroah-Hartman
maintainerPATCH 115/272 powerpc/perf: Fix kernel address leak via sampling registers
In reply to Greg Kroah-Hartman4.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit e1ebd0e5b9d0a10ba65e63a3514b6da8c6a5a819 ]
Current code in power_pmu_disable() does not clear the sampling registers like Sampling Instruction Address Register (SIAR) and Sampling Data Address Register (SDAR) after disabling the PMU. Since these are userspace readable and could contain kernel addresses, add code to explicitly clear the content of these registers.
Also add a "context synchronizing instruction" to enforce no further updates to these registers as suggested by Power ISA v3.0B. From section 9.4, on page 1108:
"If an mtspr instruction is executed that changes the value of a Performance Monitor register other than SIAR, SDAR, and SIER, the change is not guaranteed to have taken effect until after a subsequent context synchronizing instruction has been executed (see Chapter 11. "Synchronization Requirements for Context Alterations" on page 1133)."
--- arch/powerpc/perf/core-book3s.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/powerpc/perf/core-book3s.c +15 -0
@@ -1236,6 +1236,7 @@ static void power_pmu_disable(struct pmu*/ write_mmcr0 (cpuhw, val);mb (); +isync ();/* * Disable instruction sampling if it was enabled
@@ -1244,12 +1245,26 @@ static void power_pmu_disable(struct pmumtspr (SPRN_MMCRA , cpuhw->mmcr[2 ] & ~MMCRA_SAMPLE_ENABLE );mb (); +isync (); } cpuhw->disabled =1 ; cpuhw->n_added =0 ;ebb_switch_out (mmcr0); + +#ifdef CONFIG_PPC64 +/* +* These are readable by userspace, may contain kernel +* addresses and are not switched by context switch, so clear +* them now to avoid leaking anything to userspace in general +* including to another process. +*/ +if (ppmu->flags &PPMU_ARCH_207S ) { +mtspr (SPRN_SDAR ,0 ); +mtspr (SPRN_SIAR ,0 ); + } +#endif }local_irq_restore (flags);