5.3.17-stable review
Subsystems (10)
Greg Kroah-Hartman
maintainerPATCH 167/180 omap: pdata-quirks: remove openpandora quirks for mmc3 and wl1251
In reply to Greg Kroah-HartmanFrom: H. Nikolaus Schaller <[email protected]>
[ Upstream commit 2398c41d64321e62af54424fd399964f3d48cdc2 ]
With a wl1251 child node of mmc3 in the device tree decoded in omap_hsmmc.c to handle special wl1251 initialization, we do no longer need to instantiate the mmc3 through pdata quirks.
We also can remove the wlan regulator and reset/interrupt definitions and do them through device tree.
--- arch/arm/mach-omap2/pdata-quirks.c | 93 ------------------------------ 1 file changed, 93 deletions(-)
arch/arm/mach-omap2/pdata-quirks.c +0 -93
@@ -303,108 +303,15 @@ static void __init omap3_logicpd_torpedo_init(void) }/* omap3pandora legacy devices */ -#define PANDORA_WIFI_IRQ_GPIO 21 -#define PANDORA_WIFI_NRESET_GPIO 23static struct platform_device pandora_backlight = { .name ="pandora-backlight" , .id =-1 , }; -static struct regulator_consumer_supply pandora_vmmc3_supply[] = { -REGULATOR_SUPPLY ("vmmc" ,"omap_hsmmc.2" ), -}; - -static struct regulator_init_data pandora_vmmc3 = { - .constraints = { - .valid_ops_mask =REGULATOR_CHANGE_STATUS , - }, - .num_consumer_supplies =ARRAY_SIZE (pandora_vmmc3_supply), - .consumer_supplies = pandora_vmmc3_supply, -}; - -static struct fixed_voltage_config pandora_vwlan = { - .supply_name ="vwlan" , - .microvolts =1800000 ,/* 1.8V */ - .gpio =PANDORA_WIFI_NRESET_GPIO , - .startup_delay =50000 ,/* 50ms */ - .enable_high =1 , - .init_data = &pandora_vmmc3, -}; - -static struct platform_device pandora_vwlan_device = { - .name ="reg-fixed-voltage" , - .id =1 , - .dev = { - .platform_data = &pandora_vwlan, - }, -}; - -static void pandora_wl1251_init_card (struct mmc_card *card) -{ -/* -* We have TI wl1251 attached to MMC3. Pass this information to -* SDIO core because it can't be probed by normal methods. -*/ -if (card->type ==MMC_TYPE_SDIO || card->type ==MMC_TYPE_SD_COMBO ) { - card->quirks |=MMC_QUIRK_NONSTD_SDIO ; - card->cccr.wide_bus =1 ; - card->cis.vendor =0x104c ; - card->cis.device =0x9066 ; - card->cis.blksize =512 ; - card->cis.max_dtr =24000000 ; - card->ocr =0x80 ; - } -} - -static struct omap2_hsmmc_info pandora_mmc3[] = { - { - .mmc =3 , - .caps =MMC_CAP_4_BIT_DATA |MMC_CAP_POWER_OFF_CARD , - .gpio_cd = -EINVAL , - .gpio_wp = -EINVAL , - .init_card = pandora_wl1251_init_card, - }, - {}/* Terminator */ -}; - -static void __init pandora_wl1251_init (void ) -{ -struct wl1251_platform_data pandora_wl1251_pdata; -int ret; - -memset (&pandora_wl1251_pdata,0 ,sizeof (pandora_wl1251_pdata)); - - pandora_wl1251_pdata.power_gpio =-1 ; - - ret =gpio_request_one (PANDORA_WIFI_IRQ_GPIO ,GPIOF_IN ,"wl1251 irq" ); -if (ret <0 ) - goto fail; - - pandora_wl1251_pdata.irq =gpio_to_irq (PANDORA_WIFI_IRQ_GPIO ); -if (pandora_wl1251_pdata.irq <0 ) - goto fail_irq; - - pandora_wl1251_pdata.use_eeprom = true; - ret =wl1251_set_platform_data (&pandora_wl1251_pdata); -if (ret <0 ) - goto fail_irq; - -return ; - -fail_irq: -gpio_free (PANDORA_WIFI_IRQ_GPIO ); -fail: -pr_err ("wl1251 board initialisation failed\n" ); -} -static void __init omap3_pandora_legacy_init (void ) {platform_device_register (&pandora_backlight); -platform_device_register (&pandora_vwlan_device); -omap_hsmmc_init (pandora_mmc3); -omap_hsmmc_late_init (pandora_mmc3); -pandora_wl1251_init (); }#endif /* CONFIG_ARCH_OMAP3 */
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 168/180 powerpc: Avoid clang warnings around setjmp and longjmp
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit c9029ef9c95765e7b63c4d9aa780674447db1ec0 ]
Commit aea447141c7e ("powerpc: Disable -Wbuiltin-requires-header when setjmp is used") disabled -Wbuiltin-requires-header because of a warning about the setjmp and longjmp declarations.
r367387 in clang added another diagnostic around this, complaining that there is no jmp_buf declaration.
In file included from ../arch/powerpc/xmon/xmon.c:47:
../arch/powerpc/include/asm/setjmp.h:10:13: error: declaration of built-in function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>. [-Werror,-Wincomplete-setjmp-declaration]
extern long setjmp(long *);
^
../arch/powerpc/include/asm/setjmp.h:11:13: error: declaration of
built-in function 'longjmp' requires the declaration of the 'jmp_buf'
type, commonly provided in the header <setjmp.h>.
[-Werror,-Wincomplete-setjmp-declaration]
extern void longjmp(long *, long);
^2 errors generated.
We are not using the standard library's longjmp/setjmp implementations for obvious reasons; make this clear to clang by using -ffreestanding on these files.
--- arch/powerpc/kernel/Makefile | 4 ++-- arch/powerpc/xmon/Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/kernel/Makefile +2 -2
@@ -5,8 +5,8 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' -# Disable clang warning for using setjmp without setjmp.h header -CFLAGS_crash.o += $(call cc-disable-warning, builtin-requires-header) +# Avoid clang warnings around longjmp/setjmp declarations +CFLAGS_crash.o += -ffreestanding ifdef CONFIG_PPC64 CFLAGS_prom_init.o += $(NO_MINIMAL_TOC)
arch/powerpc/xmon/Makefile +2 -2
@@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for xmon -# Disable clang warning for using setjmp without setjmp.h header -subdir-ccflags-y := $(call cc-disable-warning, builtin-requires-header) +# Avoid clang warnings around longjmp/setjmp declarations +subdir-ccflags-y := -ffreestanding GCOV_PROFILE := n KCOV_INSTRUMENT := n
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 169/180 powerpc: Fix vDSO clock_getres()
In reply to Greg Kroah-HartmanFrom: Vincenzo Frascino <[email protected]>
[ Upstream commit 552263456215ada7ee8700ce022d12b0cffe4802 ]
clock_getres in the vDSO library has to preserve the same behaviour of posix_get_hrtimer_res().
In particular, posix_get_hrtimer_res() does:
sec = 0;
ns = hrtimer_resolution;and hrtimer_resolution depends on the enablement of the high resolution timers that can happen either at compile or at run time.
Fix the powerpc vdso implementation of clock_getres keeping a copy of hrtimer_resolution in vdso data and using that directly.
--- arch/powerpc/include/asm/vdso_datapage.h | 2 ++ arch/powerpc/kernel/asm-offsets.c | 2 +- arch/powerpc/kernel/time.c | 1 + arch/powerpc/kernel/vdso32/gettimeofday.S | 7 +++++-- arch/powerpc/kernel/vdso64/gettimeofday.S | 7 +++++-- 5 files changed, 14 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/vdso_datapage.h +2 -0
@@ -82,6 +82,7 @@ struct vdso_data {__s32 wtom_clock_nsec;/* Wall to monotonic clock nsec */ __s64 wtom_clock_sec;/* Wall to monotonic clock sec */ struct timespec stamp_xtime;/* xtime as at tb_orig_stamp */ +__u32 hrtimer_res;/* hrtimer resolution */ __u32 syscall_map_64[SYSCALL_MAP_SIZE ];/* map of syscalls */ __u32 syscall_map_32[SYSCALL_MAP_SIZE ];/* map of syscalls */ };
@@ -103,6 +104,7 @@ struct vdso_data {__s32 wtom_clock_nsec;struct timespec stamp_xtime;/* xtime as at tb_orig_stamp */ __u32 stamp_sec_fraction;/* fractional seconds of stamp_xtime */ +__u32 hrtimer_res;/* hrtimer resolution */ __u32 syscall_map_32[SYSCALL_MAP_SIZE ];/* map of syscalls */ __u32 dcache_block_size;/* L1 d-cache block size */ __u32 icache_block_size;/* L1 i-cache block size */
arch/powerpc/kernel/asm-offsets.c +1 -1
@@ -387,6 +387,7 @@ int main(void)OFFSET (WTOM_CLOCK_NSEC , vdso_data, wtom_clock_nsec);OFFSET (STAMP_XTIME , vdso_data, stamp_xtime);OFFSET (STAMP_SEC_FRAC , vdso_data, stamp_sec_fraction); +OFFSET (CLOCK_HRTIMER_RES , vdso_data, hrtimer_res);OFFSET (CFG_ICACHE_BLOCKSZ , vdso_data, icache_block_size);OFFSET (CFG_DCACHE_BLOCKSZ , vdso_data, dcache_block_size);OFFSET (CFG_ICACHE_LOGBLOCKSZ , vdso_data, icache_log_block_size);
@@ -417,7 +418,6 @@ int main(void)DEFINE (CLOCK_REALTIME_COARSE ,CLOCK_REALTIME_COARSE );DEFINE (CLOCK_MONOTONIC_COARSE ,CLOCK_MONOTONIC_COARSE );DEFINE (NSEC_PER_SEC ,NSEC_PER_SEC ); -DEFINE (CLOCK_REALTIME_RES ,MONOTONIC_RES_NSEC );#ifdef CONFIG_BUG DEFINE (BUG_ENTRY_SIZE ,sizeof (struct bug_entry ));
arch/powerpc/kernel/time.c +1 -0
@@ -959,6 +959,7 @@ void update_vsyscall(struct timekeeper *tk) vdso_data->wtom_clock_nsec = tk->wall_to_monotonic.tv_nsec; vdso_data->stamp_xtime = xt; vdso_data->stamp_sec_fraction = frac_sec; + vdso_data->hrtimer_res = hrtimer_resolution;smp_wmb (); ++(vdso_data->tb_update_count); }
arch/powerpc/kernel/vdso32/gettimeofday.S +5 -2
@@ -156,12 +156,15 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) cror cr0*4+eq,cr0*4+eq,cr1*4+eq bne cr0,99f + mflr r12 + .cfi_register lr,r12 + bl __get_datapage@local /* get data page */ + lwz r5, CLOCK_HRTIMER_RES(r3) + mtlr r12 li r3,0 cmpli cr0,r4,0 crclr cr0*4+so beqlr - lis r5,CLOCK_REALTIME_RES@h - ori r5,r5,CLOCK_REALTIME_RES@l stw r3,TSPC32_TV_SEC(r4) stw r5,TSPC32_TV_NSEC(r4) blr
arch/powerpc/kernel/vdso64/gettimeofday.S +5 -2
@@ -186,12 +186,15 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) cror cr0*4+eq,cr0*4+eq,cr1*4+eq bne cr0,99f + mflr r12 + .cfi_register lr,r12 + bl V_LOCAL_FUNC(__get_datapage) + lwz r5, CLOCK_HRTIMER_RES(r3) + mtlr r12 li r3,0 cmpldi cr0,r4,0 crclr cr0*4+so beqlr - lis r5,CLOCK_REALTIME_RES@h - ori r5,r5,CLOCK_REALTIME_RES@l std r3,TSPC64_TV_SEC(r4) std r5,TSPC64_TV_NSEC(r4) blr
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 170/180 mm, memfd: fix COW issue on MAP_PRIVATE and F_SEAL_FUTURE_WRITE mappings
In reply to Greg Kroah-HartmanFrom: Nicolas Geoffray <[email protected]>
commit 05d351102dbe4e103d6bdac18b1122cd3cd04925 upstream.
F_SEAL_FUTURE_WRITE has unexpected behavior when used with MAP_PRIVATE:
A private mapping created after the memfd file that gets sealed with F_SEAL_FUTURE_WRITE loses the copy-on-write at fork behavior, meaning children and parent share the same memory, even though the mapping is private.
The reason for this is due to the code below:
static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
{
struct shmem_inode_info *info = SHMEM_I(file_inode(file)); if (info->seals & F_SEAL_FUTURE_WRITE) {
/*
* New PROT_WRITE and MAP_SHARED mmaps are not allowed when
* "future write" seal active.
*/
if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
return -EPERM;
/*
* Since the F_SEAL_FUTURE_WRITE seals allow for a MAP_SHARED
* read-only mapping, take care to not allow mprotect to revert
* protections.
*/
vma->vm_flags &= ~(VM_MAYWRITE);
}
...}
And for the mm to know if a mapping is copy-on-write:
static inline bool is_cow_mapping(vm_flags_t flags)
{
return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
}The patch fixes the issue by making the mprotect revert protection happen only for shared mappings. For private mappings, using mprotect will have no effect on the seal behavior.
The F_SEAL_FUTURE_WRITE feature was introduced in v5.1 so v5.3.x stable kernels would need a backport.
--- mm/shmem.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
mm/shmem.c +7 -4
@@ -2198,11 +2198,14 @@ static int shmem_mmap(struct file *file,return -EPERM ;/* -* Since the F_SEAL_FUTURE_WRITE seals allow for a MAP_SHARED -* read-only mapping, take care to not allow mprotect to revert -* protections. +* Since an F_SEAL_FUTURE_WRITE sealed memfd can be mapped as +* MAP_SHARED and read-only, take care to not allow mprotect to +* revert protections on such mappings. Do this only for shared +* mappings. For private mappings, don't need to mask +* VM_MAYWRITE as we still want them to be COW-writable. */ - vma->vm_flags &= ~(VM_MAYWRITE ); +if (vma->vm_flags &VM_SHARED ) + vma->vm_flags &= ~(VM_MAYWRITE ); }file_accessed (file);
Greg Kroah-Hartman
maintainerPATCH 171/180 mfd: rk808: Fix RK818 ID template
In reply to Greg Kroah-HartmanFrom: Daniel Schultz <[email protected]>
commit 37ef8c2c15bdc1322b160e38986c187de2b877b2 upstream.
The Rockchip PMIC driver can automatically detect connected component versions by reading the ID_MSB and ID_LSB registers. The probe function will always fail with RK818 PMICs because the ID_MSK is 0xFFF0 and the RK818 template ID is 0x8181.
This patch changes this value to 0x8180.
--- include/linux/mfd/rk808.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mfd/rk808.h +1 -1
@@ -610,7 +610,7 @@ enum {RK808_ID =0x0000 ,RK809_ID =0x8090 ,RK817_ID =0x8170 , - RK818_ID = 0x8181, + RK818_ID = 0x8180, }; struct rk808 {
Greg Kroah-Hartman
maintainerPATCH 172/180 mm: memcg/slab: wait for !root kmem_cache refcnt killing on root kmem_cache destruction
In reply to Greg Kroah-HartmanFrom: Roman Gushchin <[email protected]>
commit a264df74df38855096393447f1b8f386069a94b9 upstream.
Christian reported a warning like the following obtained during running some KVM-related tests on s390:
WARNING: CPU: 8 PID: 208 at lib/percpu-refcount.c:108 percpu_ref_exit+0x50/0x58
Modules linked in: kvm(-) xt_CHECKSUM xt_MASQUERADE bonding xt_tcpudp ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ip6table_na>
CPU: 8 PID: 208 Comm: kworker/8:1 Not tainted 5.2.0+ #66
Hardware name: IBM 2964 NC9 712 (LPAR)
Workqueue: events sysfs_slab_remove_workfn
Krnl PSW : 0704e00180000000 0000001529746850 (percpu_ref_exit+0x50/0x58)
R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:2 PM:0 RI:0 EA:3
Krnl GPRS: 00000000ffff8808 0000001529746740 000003f4e30e8e18 0036008100000000
0000001f00000000 0035008100000000 0000001fb3573ab8 0000000000000000
0000001fbdb6de00 0000000000000000 0000001529f01328 0000001fb3573b00
0000001fbb27e000 0000001fbdb69300 000003e009263d00 000003e009263cd0
Krnl Code: 0000001529746842: f0a0000407fe srp 4(11,%r0),2046,0
0000001529746848: 47000700 bc 0,1792
#000000152974684c: a7f40001 brc 15,152974684e
>0000001529746850: a7f4fff2 brc 15,1529746834
0000001529746854: 0707 bcr 0,%r7
0000001529746856: 0707 bcr 0,%r7
0000001529746858: eb8ff0580024 stmg %r8,%r15,88(%r15)
000000152974685e: a738ffff lhi %r3,-1
Call Trace:
([<000003e009263d00>] 0x3e009263d00)
[<00000015293252ea>] slab_kmem_cache_release+0x3a/0x70
[<0000001529b04882>] kobject_put+0xaa/0xe8
[<000000152918cf28>] process_one_work+0x1e8/0x428
[<000000152918d1b0>] worker_thread+0x48/0x460
[<00000015291942c6>] kthread+0x126/0x160
[<0000001529b22344>] ret_from_fork+0x28/0x30
[<0000001529b2234c>] kernel_thread_starter+0x0/0x10
Last Breaking-Event-Address:
[<000000152974684c>] percpu_ref_exit+0x4c/0x58
---[ end trace b035e7da5788eb09 ]---The problem occurs because kmem_cache_destroy() is called immediately after deleting of a memcg, so it races with the memcg kmem_cache deactivation.
flush_memcg_workqueue() at the beginning of kmem_cache_destroy() is supposed to guarantee that all deactivation processes are finished, but failed to do so. It waits for an rcu grace period, after which all children kmem_caches should be deactivated. During the deactivation percpu_ref_kill() is called for non root kmem_cache refcounters, but it requires yet another rcu grace period to finish the transition to the atomic (dead) state.
So in a rare case when not all children kmem_caches are destroyed at the moment when the root kmem_cache is about to be gone, we need to wait another rcu grace period before destroying the root kmem_cache.
This issue can be triggered only with dynamically created kmem_caches which are used with memcg accounting. In this case per-memcg child kmem_caches are created. They are deactivated from the cgroup removing path. If the destruction of the root kmem_cache is racing with the removal of the cgroup (both are quite complicated multi-stage processes), the described issue can occur. The only known way to trigger it in the real life, is to unload some kernel module which creates a dedicated kmem_cache, used from different memory cgroups with GFP_ACCOUNT flag. If the unloading happens immediately after calling rmdir on the corresponding cgroup, there is some chance to trigger the issue.
--- mm/slab_common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
mm/slab_common.c +12 -0
@@ -904,6 +904,18 @@ static void flush_memcg_workqueue(struct* previous workitems on workqueue are processed. */ flush_workqueue (memcg_kmem_cache_wq); + +/* +* If we're racing with children kmem_cache deactivation, it might +* take another rcu grace period to complete their destruction. +* At this moment the corresponding percpu_ref_kill() call should be +* done, but it might take another rcu grace period to complete +* switching to the atomic mode. +* Please, note that we check without grabbing the slab_mutex. It's safe +* because at this moment the children list can't grow. +*/ +if (!list_empty (&s->memcg_params.children)) + rcu_barrier(); }#else static inline int shutdown_memcg_caches (struct kmem_cache *s)
Greg Kroah-Hartman
maintainerPATCH 173/180 ext4: work around deleting a file with i_nlink == 0 safely
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit c7df4a1ecb8579838ec8c56b2bb6a6716e974f37 upstream.
If the file system is corrupted such that a file's i_links_count is too small, then it's possible that when unlinking that file, i_nlink will already be zero. Previously we were working around this kind of corruption by forcing i_nlink to one; but we were doing this before trying to delete the directory entry --- and if the file system is corrupted enough that ext4_delete_entry() fails, then we exit with i_nlink elevated, and this causes the orphan inode list handling to be FUBAR'ed, such that when we unmount the file system, the orphan inode list can get corrupted.
A better way to fix this is to simply skip trying to call drop_nlink() if i_nlink is already zero, thus moving the check to the place where it makes the most sense.
https://bugzilla.kernel.org/show_bug.cgi?id=205433
--- fs/ext4/namei.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/ext4/namei.c +5 -6
@@ -3182,18 +3182,17 @@ static int ext4_unlink(struct inode *dirif (IS_DIRSYNC (dir))ext4_handle_sync (handle); -if (inode->i_nlink ==0 ) { -ext4_warning_inode (inode,"Deleting file '%.*s' with no links" , - dentry->d_name.len, dentry->d_name.name); -set_nlink (inode,1 ); - } retval =ext4_delete_entry (handle, dir, de, bh);if (retval) goto end_unlink; dir->i_ctime = dir->i_mtime =current_time (dir);ext4_update_dx_flag (dir);ext4_mark_inode_dirty (handle, dir); -drop_nlink (inode); +if (inode->i_nlink ==0 ) +ext4_warning_inode (inode,"Deleting file '%.*s' with no links" , + dentry->d_name.len, dentry->d_name.name); +else +drop_nlink (inode);if (!inode->i_nlink)ext4_orphan_add (handle, inode); inode->i_ctime =current_time (inode);
Greg Kroah-Hartman
maintainerPATCH 174/180 firmware: qcom: scm: Ensure a0 status code is treated as signed
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
commit ff34f3cce278a0982a7b66b1afaed6295141b1fc upstream.
The 'a0' member of 'struct arm_smccc_res' is declared as 'unsigned long', however the Qualcomm SCM firmware interface driver expects to receive negative error codes via this field, so ensure that it's cast to 'long' before comparing to see if it is less than 0.
--- drivers/firmware/qcom_scm-64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/qcom_scm-64.c +1 -1
@@ -150,7 +150,7 @@ static int qcom_scm_call(struct device *kfree (args_virt); } -if (res->a0 <0 ) +if ((long )res->a0 <0 )return qcom_scm_remap_error (res->a0);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 175/180 s390/smp,vdso: fix ASCE handling
In reply to Greg Kroah-HartmanFrom: Heiko Carstens <[email protected]>
commit a2308c11ecbc3471ebb7435ee8075815b1502ef0 upstream.
When a secondary CPU is brought up it must initialize its control registers. CPU A which triggers that a secondary CPU B is brought up stores its control register contents into the lowcore of new CPU B, which then loads these values on startup.
This is problematic in various ways: the control register which contains the home space ASCE will correctly contain the kernel ASCE; however control registers for primary and secondary ASCEs are initialized with whatever values were present in CPU A.
Typically:
- the primary ASCE will contain the user process ASCE of the process that triggered onlining of CPU B.
- the secondary ASCE will contain the percpu VDSO ASCE of CPU A.
Due to lazy ASCE handling we may also end up with other combinations.
When then CPU B switches to a different process (!= idle) it will fixup the primary ASCE. However the problem is that the (wrong) ASCE from CPU A was loaded into control register 1: as soon as an ASCE is attached (aka loaded) a CPU is free to generate TLB entries using that address space.
Even though it is very unlikey that CPU B will actually generate such entries, this could result in TLB entries of the address space of the process that ran on CPU A. These entries shouldn't exist at all and could cause problems later on.
Furthermore the secondary ASCE of CPU B will not be updated correctly. This means that processes may see wrong results or even crash if they access VDSO data on CPU B. The correct VDSO ASCE will eventually be loaded on return to user space as soon as the kernel executed a call to strnlen_user or an atomic futex operation on CPU B.
Fix both issues by intializing the to be loaded control register contents with the correct ASCEs and also enforce (re-)loading of the ASCEs upon first context switch and return to user space.
--- arch/s390/kernel/smp.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/s390/kernel/smp.c +5 -0
@@ -262,10 +262,13 @@ static void pcpu_prepare_secondary(struc lc->spinlock_index =0 ; lc->percpu_offset = __per_cpu_offset[cpu]; lc->kernel_asce = S390_lowcore.kernel_asce; + lc->user_asce = S390_lowcore.kernel_asce; lc->machine_flags = S390_lowcore.machine_flags; lc->user_timer = lc->system_timer = lc->steal_timer = lc->avg_steal_timer =0 ;__ctl_store (lc->cregs_save_area,0 ,15 ); + lc->cregs_save_area[1 ] = lc->kernel_asce; + lc->cregs_save_area[7 ] = lc->vdso_asce;save_access_regs ((unsigned int *) lc->access_regs_save_area);memcpy (lc->stfle_fac_list, S390_lowcore.stfle_fac_list,sizeof (lc->stfle_fac_list));
@@ -816,6 +819,8 @@ static void smp_init_secondary(void) S390_lowcore.last_update_clock =get_tod_clock ();restore_access_regs (S390_lowcore.access_regs_save_area); +set_cpu_flag (CIF_ASCE_PRIMARY ); +set_cpu_flag (CIF_ASCE_SECONDARY );cpu_init ();preempt_disable ();init_cpu_timer ();
Greg Kroah-Hartman
maintainerPATCH 176/180 s390/kaslr: store KASLR offset for early dumps
In reply to Greg Kroah-HartmanFrom: Gerald Schaefer <[email protected]>
commit a9f2f6865d784477e1c7b59269d3a384abafd9ca upstream.
The KASLR offset is added to vmcoreinfo in arch_crash_save_vmcoreinfo(), so that it can be found by crash when processing kernel dumps.
However, arch_crash_save_vmcoreinfo() is called during a subsys_initcall, so if the kernel crashes before that, we have no vmcoreinfo and no KASLR offset.
Fix this by storing the KASLR offset in the lowcore, where the vmcore_info pointer will be stored, and where it can be found by crash. In order to make it distinguishable from a real vmcore_info pointer, mark it as uneven (KASLR offset itself is aligned to THREAD_SIZE).
When arch_crash_save_vmcoreinfo() stores the real vmcore_info pointer in the lowcore, it overwrites the KASLR offset. At that point, the KASLR offset is not yet added to vmcoreinfo, so we also need to move the mem_assign_absolute() behind the vmcoreinfo_append_str().
--- arch/s390/boot/startup.c | 5 +++++ arch/s390/kernel/machine_kexec.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
arch/s390/boot/startup.c +5 -0
@@ -164,6 +164,11 @@ void startup_kernel(void)handle_relocs (__kaslr_offset);if (__kaslr_offset) { +/* +* Save KASLR offset for early dumps, before vmcore_info is set. +* Mark as uneven to distinguish from real vmcore_info pointer. +*/ + S390_lowcore.vmcore_info = __kaslr_offset |0x1UL ;/* Clear non-relocated kernel */ if (IS_ENABLED (CONFIG_KERNEL_UNCOMPRESSED ))memset (img,0 , vmlinux.image_size);
arch/s390/kernel/machine_kexec.c +1 -1
@@ -254,10 +254,10 @@ void arch_crash_save_vmcoreinfo(void)VMCOREINFO_SYMBOL (lowcore_ptr);VMCOREINFO_SYMBOL (high_memory);VMCOREINFO_LENGTH (lowcore_ptr,NR_CPUS ); -mem_assign_absolute (S390_lowcore.vmcore_info,paddr_vmcoreinfo_note ());vmcoreinfo_append_str ("SDMA=%lx\n" , __sdma);vmcoreinfo_append_str ("EDMA=%lx\n" , __edma);vmcoreinfo_append_str ("KERNELOFFSET=%lx\n" ,kaslr_offset ()); +mem_assign_absolute (S390_lowcore.vmcore_info,paddr_vmcoreinfo_note ()); }void machine_shutdown (void )
Greg Kroah-Hartman
maintainerPATCH 177/180 mm/shmem.c: cast the type of unmap_start to u64
In reply to Greg Kroah-HartmanFrom: Chen Jun <[email protected]>
commit aa71ecd8d86500da6081a72da6b0b524007e0627 upstream.
In 64bit system. sb->s_maxbytes of shmem filesystem is MAX_LFS_FILESIZE, which equal LLONG_MAX.
If offset > LLONG_MAX - PAGE_SIZE, offset + len < LLONG_MAX in shmem_fallocate, which will pass the checking in vfs_fallocate.
/* Check for wrap through zero too */ if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) return -EFBIG;
loff_t unmap_start = round_up(offset, PAGE_SIZE) in shmem_fallocate causes a overflow.
Syzkaller reports a overflow problem in mm/shmem:
UBSAN: Undefined behaviour in mm/shmem.c:2014:10
signed integer overflow: '9223372036854775807 + 1' cannot be represented in type 'long long int'
CPU: 0 PID:17076 Comm: syz-executor0 Not tainted 4.1.46+ #1
Hardware name: linux, dummy-virt (DT)
Call trace:
dump_backtrace+0x0/0x2c8 arch/arm64/kernel/traps.c:100
show_stack+0x20/0x30 arch/arm64/kernel/traps.c:238
__dump_stack lib/dump_stack.c:15 [inline]
ubsan_epilogue+0x18/0x70 lib/ubsan.c:164
handle_overflow+0x158/0x1b0 lib/ubsan.c:195
shmem_fallocate+0x6d0/0x820 mm/shmem.c:2104
vfs_fallocate+0x238/0x428 fs/open.c:312
SYSC_fallocate fs/open.c:335 [inline]
SyS_fallocate+0x54/0xc8 fs/open.c:239The highest bit of unmap_start will be appended with sign bit 1 (overflow) when calculate shmem_falloc.start:
shmem_falloc.start = unmap_start >> PAGE_SHIFT.
Fix it by casting the type of unmap_start to u64, when right shifted.
This bug is found in LTS Linux 4.1. It also seems to exist in mainline.
--- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -1
@@ -2730,7 +2730,7 @@ static long shmem_fallocate(struct file } shmem_falloc.waitq = &shmem_falloc_waitq; - shmem_falloc.start = unmap_start >>PAGE_SHIFT ; + shmem_falloc.start = (u64 )unmap_start >>PAGE_SHIFT ; shmem_falloc.next = (unmap_end +1 ) >>PAGE_SHIFT ;spin_lock (&inode->i_lock); inode->i_private = &shmem_falloc;
Greg Kroah-Hartman
maintainerPATCH 178/180 rtc: disable uie before setting time and enable after
In reply to Greg Kroah-HartmanFrom: Alexandre Belloni <[email protected]>
commit 7e7c005b4b1f1f169bcc4b2c3a40085ecc663df2 upstream.
When setting the time in the future with the uie timer enabled, rtc_timer_do_work will loop for a while because the expiration of the uie timer was way before the current RTC time and a new timer will be enqueued until the current rtc time is reached.
If the uie timer is enabled, disable it before setting the time and enable it after expiring current timers (which may actually be an alarm).
This is the safest thing to do to ensure the uie timer is still synchronized with the RTC, especially in the UIE emulation case.
--- drivers/rtc/interface.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/rtc/interface.c +18 -1
@@ -125,7 +125,7 @@ EXPORT_SYMBOL_GPL(rtc_read_time);int rtc_set_time (struct rtc_device *rtc,struct rtc_time *tm) { -int err; +int err, uie; err =rtc_valid_tm (tm);if (err !=0 )
@@ -137,6 +137,17 @@ int rtc_set_time(struct rtc_device *rtc,rtc_subtract_offset (rtc, tm); +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL + uie = rtc->uie_rtctimer.enabled || rtc->uie_irq_active; +#else + uie = rtc->uie_rtctimer.enabled; +#endif +if (uie) { + err =rtc_update_irq_enable (rtc,0 ); +if (err) +return err; + } + err =mutex_lock_interruptible (&rtc->ops_lock);if (err)return err;
@@ -153,6 +164,12 @@ int rtc_set_time(struct rtc_device *rtc,/* A timer might have just expired */ schedule_work (&rtc->irqwork); +if (uie) { + err =rtc_update_irq_enable (rtc,1 ); +if (err) +return err; + } +trace_rtc_set_time (rtc_tm_to_time64 (tm), err);return err; }
Greg Kroah-Hartman
maintainerPATCH 179/180 splice: only read in as much information as there is pipe buffer space
In reply to Greg Kroah-HartmanFrom: Darrick J. Wong <[email protected]>
commit 3253d9d093376d62b4a56e609f15d2ec5085ac73 upstream.
Andreas Grünbacher reports that on the two filesystems that support iomap directio, it's possible for splice() to return -EAGAIN (instead of a short splice) if the pipe being written to has less space available in its pipe buffers than the length supplied by the calling process.
Months ago we fixed splice_direct_to_actor to clamp the length of the read request to the size of the splice pipe. Do the same to do_splice.
--- fs/splice.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/splice.c +11 -3
@@ -945,12 +945,13 @@ ssize_t splice_direct_to_actor(struct fiWARN_ON_ONCE (pipe->nrbufs !=0 );while (len) { +unsigned int pipe_pages;size_t read_len;loff_t pos = sd->pos, prev_pos = pos;/* Don't try to read more the pipe has space for. */ - read_len =min_t (size_t, len, - (pipe->buffers - pipe->nrbufs) <<PAGE_SHIFT ); + pipe_pages = pipe->buffers - pipe->nrbufs; + read_len =min (len, (size_t )pipe_pages <<PAGE_SHIFT ); ret =do_splice_to (in, &pos, pipe, read_len, flags);if (unlikely (ret <=0 )) goto out_release;
@@ -1180,8 +1181,15 @@ static long do_splice(struct file *in, lpipe_lock (opipe); ret =wait_for_space (opipe, flags); -if (!ret) +if (!ret) { +unsigned int pipe_pages; + +/* Don't try to read more the pipe has space for. */ + pipe_pages = opipe->buffers - opipe->nrbufs; + len =min (len, (size_t )pipe_pages <<PAGE_SHIFT ); + ret =do_splice_to (in, &offset, opipe, len, flags); + }pipe_unlock (opipe);if (ret >0 )wakeup_pipe_readers (opipe);
Greg Kroah-Hartman
maintainerPATCH 180/180 ext4: fix a bug in ext4_wait_for_tail_page_commit
In reply to Greg Kroah-HartmanFrom: yangerkun <[email protected]>
commit 565333a1554d704789e74205989305c811fd9c7a upstream.
No need to wait for any commit once the page is fully truncated. Besides, it may confuse e.g. concurrent ext4_writepage() with the page still be dirty (will be cleared by truncate_pagecache() in ext4_setattr()) but buffers has been freed; and then trigger a bug show as below:
[ 26.057508] ------------[ cut here ]------------ [ 26.058531] kernel BUG at fs/ext4/inode.c:2134! ... [ 26.088130] Call trace: [ 26.088695] ext4_writepage+0x914/0xb28 [ 26.089541] writeout.isra.4+0x1b4/0x2b8 [ 26.090409] move_to_new_page+0x3b0/0x568 [ 26.091338] __unmap_and_move+0x648/0x988 [ 26.092241] unmap_and_move+0x48c/0xbb8 [ 26.093096] migrate_pages+0x220/0xb28 [ 26.093945] kernel_mbind+0x828/0xa18 [ 26.094791] __arm64_sys_mbind+0xc8/0x138 [ 26.095716] el0_svc_common+0x190/0x490 [ 26.096571] el0_svc_handler+0x60/0xd0 [ 26.097423] el0_svc+0x8/0xc
Run the procedure (generate by syzkaller) parallel with ext3.
void main()
{
int fd, fd1, ret;
void *addr;
size_t length = 4096;
int flags;
off_t offset = 0;
char *str = "12345";
fd = open("a", O_RDWR | O_CREAT);
assert(fd >= 0);
/* Truncate to 4k */
ret = ftruncate(fd, length);
assert(ret == 0);
/* Journal data mode */
flags = 0xc00f;
ret = ioctl(fd, _IOW('f', 2, long), &flags);
assert(ret == 0);
/* Truncate to 0 */
fd1 = open("a", O_TRUNC | O_NOATIME);
assert(fd1 >= 0);
addr = mmap(NULL, length, PROT_WRITE | PROT_READ,
MAP_SHARED, fd, offset);
assert(addr != (void *)-1);
memcpy(addr, str, 5);
mbind(addr, length, 0, 0, 0, MPOL_MF_MOVE);
}And the bug will be triggered once we seen the below order.
reproduce1 reproduce2
... | ...
truncate to 4k |
change to journal data mode |
| memcpy(set page dirty)
truncate to 0: |
ext4_setattr: |
... |
ext4_wait_for_tail_page_commit |
| mbind(trigger bug)
truncate_pagecache(clean dirty)| ...
... |mbind will call ext4_writepage() since the page still be dirty, and then report the bug since the buffers has been free. Fix it by return directly once offset equals to 0 which means the page has been fully truncated.
--- fs/ext4/inode.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/ext4/inode.c +8 -4
@@ -5493,11 +5493,15 @@ static void ext4_wait_for_tail_page_comm offset = inode->i_size & (PAGE_SIZE -1 );/* -* All buffers in the last page remain valid? Then there's nothing to -* do. We do the check mainly to optimize the common PAGE_SIZE == -* blocksize case +* If the page is fully truncated, we don't need to wait for any commit +* (and we even should not as __ext4_journalled_invalidatepage() may +* strip all buffers from the page but keep the page dirty which can then +* confuse e.g. concurrent ext4_writepage() seeing dirty page without +* buffers). Also we don't need to wait for any commit if all buffers in +* the page remain valid. This is most beneficial for the common case of +* blocksize == PAGESIZE. */ -if (offset >PAGE_SIZE -i_blocksize (inode)) +if (!offset || offset > (PAGE_SIZE -i_blocksize (inode)))return ;while (1 ) { page = find_lock_page(inode->i_mapping,
shuah
maintainerQuoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.17 release. There are 180 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, 18 Dec 2019 17:41:25 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.3.17-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.3.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. NO dmesg regressions.
thanks,
-- Shuah
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.17 release. There are 180 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, 18 Dec 2019 17:41:25 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.3.17-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.3.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 5.3.17-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-5.3.y
git commit: 5770ae7aea0c5937b7ac1e2007f4c04adb0f58d4
git describe: v5.3.16-181-g5770ae7aea0c
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-5.3-oe/build/v5.3.16-181-g5770ae7aea0c
No regressions (compared to build v5.3.16)
No fixes (compared to build v5.3.16)
Ran 23086 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c
- hi6220-hikey
- i386
- juno-r2
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15
- x86
Test Suites
-----------
* build
* install-android-platform-tools-r2600
* kselftest
* libgpiod
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* network-basic-tests
* perf
* spectre-meltdown-checker-test
* v4l2-compliance
* ltp-open-posix-tests
* kvm-unit-tests
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none
* ssuite
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Jon Hunter
maintainerQuoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.17 release. There are 180 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, 18 Dec 2019 17:41:25 +0000. 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/v5.x/stable-review/patch-5.3.17-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.3.y
and the diffstat can be found below.
Quoted 5 lines
thanks,
greg k-h
-------------
All tests are passing for Tegra ...
Test results for stable-v5.3:
13 builds: 13 pass, 0 fail
22 boots: 22 pass, 0 fail
38 tests: 38 pass, 0 failLinux version: 5.3.17-rc1-g5770ae7aea0c
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04Cheers
Jon
Signature · 1 line
nvpublic
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.17 release. There are 180 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, 18 Dec 2019 17:41:25 +0000. Anything received after that time might be too late.
Build results:
total: 158 pass: 158 fail: 0 Qemu test results: total: 384 pass: 384 fail: 0
Guenter