Skip to content

Commit 922c010

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "22 fixes" * emailed patches from Andrew Morton <[email protected]>: (22 commits) fs/proc/proc_sysctl.c: fix NULL pointer dereference in put_links fs: fs_parser: fix printk format warning checkpatch: add %pt as a valid vsprintf extension mm/migrate.c: add missing flush_dcache_page for non-mapped page migrate drivers/block/zram/zram_drv.c: fix idle/writeback string compare mm/page_isolation.c: fix a wrong flag in set_migratetype_isolate() mm/memory_hotplug.c: fix notification in offline error path ptrace: take into account saved_sigmask in PTRACE{GET,SET}SIGMASK fs/proc/kcore.c: make kcore_modules static include/linux/list.h: fix list_is_first() kernel-doc mm/debug.c: fix __dump_page when mapping->host is not set mm: mempolicy: make mbind() return -EIO when MPOL_MF_STRICT is specified include/linux/hugetlb.h: convert to use vm_fault_t iommu/io-pgtable-arm-v7s: request DMA32 memory, and improve debugging mm: add support for kmem caches in DMA32 zone ocfs2: fix inode bh swapping mixup in ocfs2_reflink_inodes_lock mm/hotplug: fix offline undo_isolate_page_range() fs/open.c: allow opening only regular files during execve() mailmap: add Changbin Du mm/debug.c: add a cast to u64 for atomic64_read() ...
2 parents f9007cc + 23da958 commit 922c010

28 files changed

+210
-112
lines changed

.mailmap

+2
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,5 @@ Yakir Yang <[email protected]> <[email protected]>
224224
Yusuke Goda <[email protected]>
225225
Gustavo Padovan <[email protected]>
226226
Gustavo Padovan <[email protected]>
227+
228+

drivers/block/zram/zram_drv.c

+6-26
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,8 @@ static ssize_t idle_store(struct device *dev,
290290
struct zram *zram = dev_to_zram(dev);
291291
unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
292292
int index;
293-
char mode_buf[8];
294-
ssize_t sz;
295293

296-
sz = strscpy(mode_buf, buf, sizeof(mode_buf));
297-
if (sz <= 0)
298-
return -EINVAL;
299-
300-
/* ignore trailing new line */
301-
if (mode_buf[sz - 1] == '\n')
302-
mode_buf[sz - 1] = 0x00;
303-
304-
if (strcmp(mode_buf, "all"))
294+
if (!sysfs_streq(buf, "all"))
305295
return -EINVAL;
306296

307297
down_read(&zram->init_lock);
@@ -635,25 +625,15 @@ static ssize_t writeback_store(struct device *dev,
635625
struct bio bio;
636626
struct bio_vec bio_vec;
637627
struct page *page;
638-
ssize_t ret, sz;
639-
char mode_buf[8];
640-
int mode = -1;
628+
ssize_t ret;
629+
int mode;
641630
unsigned long blk_idx = 0;
642631

643-
sz = strscpy(mode_buf, buf, sizeof(mode_buf));
644-
if (sz <= 0)
645-
return -EINVAL;
646-
647-
/* ignore trailing newline */
648-
if (mode_buf[sz - 1] == '\n')
649-
mode_buf[sz - 1] = 0x00;
650-
651-
if (!strcmp(mode_buf, "idle"))
632+
if (sysfs_streq(buf, "idle"))
652633
mode = IDLE_WRITEBACK;
653-
else if (!strcmp(mode_buf, "huge"))
634+
else if (sysfs_streq(buf, "huge"))
654635
mode = HUGE_WRITEBACK;
655-
656-
if (mode == -1)
636+
else
657637
return -EINVAL;
658638

659639
down_read(&zram->init_lock);

drivers/iommu/io-pgtable-arm-v7s.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@
160160

161161
#define ARM_V7S_TCR_PD1 BIT(5)
162162

163+
#ifdef CONFIG_ZONE_DMA32
164+
#define ARM_V7S_TABLE_GFP_DMA GFP_DMA32
165+
#define ARM_V7S_TABLE_SLAB_FLAGS SLAB_CACHE_DMA32
166+
#else
167+
#define ARM_V7S_TABLE_GFP_DMA GFP_DMA
168+
#define ARM_V7S_TABLE_SLAB_FLAGS SLAB_CACHE_DMA
169+
#endif
170+
163171
typedef u32 arm_v7s_iopte;
164172

165173
static bool selftest_running;
@@ -197,13 +205,16 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp,
197205
void *table = NULL;
198206

199207
if (lvl == 1)
200-
table = (void *)__get_dma_pages(__GFP_ZERO, get_order(size));
208+
table = (void *)__get_free_pages(
209+
__GFP_ZERO | ARM_V7S_TABLE_GFP_DMA, get_order(size));
201210
else if (lvl == 2)
202-
table = kmem_cache_zalloc(data->l2_tables, gfp | GFP_DMA);
211+
table = kmem_cache_zalloc(data->l2_tables, gfp);
203212
phys = virt_to_phys(table);
204-
if (phys != (arm_v7s_iopte)phys)
213+
if (phys != (arm_v7s_iopte)phys) {
205214
/* Doesn't fit in PTE */
215+
dev_err(dev, "Page table does not fit in PTE: %pa", &phys);
206216
goto out_free;
217+
}
207218
if (table && !(cfg->quirks & IO_PGTABLE_QUIRK_NO_DMA)) {
208219
dma = dma_map_single(dev, table, size, DMA_TO_DEVICE);
209220
if (dma_mapping_error(dev, dma))
@@ -733,7 +744,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg,
733744
data->l2_tables = kmem_cache_create("io-pgtable_armv7s_l2",
734745
ARM_V7S_TABLE_SIZE(2),
735746
ARM_V7S_TABLE_SIZE(2),
736-
SLAB_CACHE_DMA, NULL);
747+
ARM_V7S_TABLE_SLAB_FLAGS, NULL);
737748
if (!data->l2_tables)
738749
goto out_free_data;
739750

fs/fs_parser.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ bool fs_validate_description(const struct fs_parameter_description *desc)
410410
for (param = desc->specs; param->name; param++) {
411411
if (param->opt == e->opt &&
412412
param->type != fs_param_is_enum) {
413-
pr_err("VALIDATE %s: e[%lu] enum val for %s\n",
413+
pr_err("VALIDATE %s: e[%tu] enum val for %s\n",
414414
name, e - desc->enums, param->name);
415415
good = false;
416416
}

fs/ocfs2/refcounttree.c

+24-18
Original file line numberDiff line numberDiff line change
@@ -4719,22 +4719,23 @@ loff_t ocfs2_reflink_remap_blocks(struct inode *s_inode,
47194719

47204720
/* Lock an inode and grab a bh pointing to the inode. */
47214721
int ocfs2_reflink_inodes_lock(struct inode *s_inode,
4722-
struct buffer_head **bh1,
4722+
struct buffer_head **bh_s,
47234723
struct inode *t_inode,
4724-
struct buffer_head **bh2)
4724+
struct buffer_head **bh_t)
47254725
{
4726-
struct inode *inode1;
4727-
struct inode *inode2;
4726+
struct inode *inode1 = s_inode;
4727+
struct inode *inode2 = t_inode;
47284728
struct ocfs2_inode_info *oi1;
47294729
struct ocfs2_inode_info *oi2;
4730+
struct buffer_head *bh1 = NULL;
4731+
struct buffer_head *bh2 = NULL;
47304732
bool same_inode = (s_inode == t_inode);
4733+
bool need_swap = (inode1->i_ino > inode2->i_ino);
47314734
int status;
47324735

47334736
/* First grab the VFS and rw locks. */
47344737
lock_two_nondirectories(s_inode, t_inode);
4735-
inode1 = s_inode;
4736-
inode2 = t_inode;
4737-
if (inode1->i_ino > inode2->i_ino)
4738+
if (need_swap)
47384739
swap(inode1, inode2);
47394740

47404741
status = ocfs2_rw_lock(inode1, 1);
@@ -4757,17 +4758,13 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode,
47574758
trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno,
47584759
(unsigned long long)oi2->ip_blkno);
47594760

4760-
if (*bh1)
4761-
*bh1 = NULL;
4762-
if (*bh2)
4763-
*bh2 = NULL;
4764-
47654761
/* We always want to lock the one with the lower lockid first. */
47664762
if (oi1->ip_blkno > oi2->ip_blkno)
47674763
mlog_errno(-ENOLCK);
47684764

47694765
/* lock id1 */
4770-
status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_REFLINK_TARGET);
4766+
status = ocfs2_inode_lock_nested(inode1, &bh1, 1,
4767+
OI_LS_REFLINK_TARGET);
47714768
if (status < 0) {
47724769
if (status != -ENOENT)
47734770
mlog_errno(status);
@@ -4776,15 +4773,25 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode,
47764773

47774774
/* lock id2 */
47784775
if (!same_inode) {
4779-
status = ocfs2_inode_lock_nested(inode2, bh2, 1,
4776+
status = ocfs2_inode_lock_nested(inode2, &bh2, 1,
47804777
OI_LS_REFLINK_TARGET);
47814778
if (status < 0) {
47824779
if (status != -ENOENT)
47834780
mlog_errno(status);
47844781
goto out_cl1;
47854782
}
4786-
} else
4787-
*bh2 = *bh1;
4783+
} else {
4784+
bh2 = bh1;
4785+
}
4786+
4787+
/*
4788+
* If we swapped inode order above, we have to swap the buffer heads
4789+
* before passing them back to the caller.
4790+
*/
4791+
if (need_swap)
4792+
swap(bh1, bh2);
4793+
*bh_s = bh1;
4794+
*bh_t = bh2;
47884795

47894796
trace_ocfs2_double_lock_end(
47904797
(unsigned long long)oi1->ip_blkno,
@@ -4794,8 +4801,7 @@ int ocfs2_reflink_inodes_lock(struct inode *s_inode,
47944801

47954802
out_cl1:
47964803
ocfs2_inode_unlock(inode1, 1);
4797-
brelse(*bh1);
4798-
*bh1 = NULL;
4804+
brelse(bh1);
47994805
out_rw2:
48004806
ocfs2_rw_unlock(inode2, 1);
48014807
out_i2:

fs/open.c

+6
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,12 @@ static int do_dentry_open(struct file *f,
733733
return 0;
734734
}
735735

736+
/* Any file opened for execve()/uselib() has to be a regular file. */
737+
if (unlikely(f->f_flags & FMODE_EXEC && !S_ISREG(inode->i_mode))) {
738+
error = -EACCES;
739+
goto cleanup_file;
740+
}
741+
736742
if (f->f_mode & FMODE_WRITE && !special_file(inode->i_mode)) {
737743
error = get_write_access(inode);
738744
if (unlikely(error))

fs/proc/kcore.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static void __init proc_kcore_text_init(void)
615615
/*
616616
* MODULES_VADDR has no intersection with VMALLOC_ADDR.
617617
*/
618-
struct kcore_list kcore_modules;
618+
static struct kcore_list kcore_modules;
619619
static void __init add_modules_range(void)
620620
{
621621
if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) {

fs/proc/proc_sysctl.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,8 @@ static void drop_sysctl_table(struct ctl_table_header *header)
16261626
if (--header->nreg)
16271627
return;
16281628

1629-
put_links(header);
1629+
if (parent)
1630+
put_links(header);
16301631
start_unregistering(header);
16311632
if (!--header->count)
16321633
kfree_rcu(header, rcu);

include/linux/hugetlb.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ static inline void hugetlb_show_meminfo(void)
203203
#define pud_huge(x) 0
204204
#define is_hugepage_only_range(mm, addr, len) 0
205205
#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
206-
#define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; })
207206
#define hugetlb_mcopy_atomic_pte(dst_mm, dst_pte, dst_vma, dst_addr, \
208207
src_addr, pagep) ({ BUG(); 0; })
209208
#define huge_pte_offset(mm, address, sz) 0
@@ -234,6 +233,13 @@ static inline void __unmap_hugepage_range(struct mmu_gather *tlb,
234233
{
235234
BUG();
236235
}
236+
static inline vm_fault_t hugetlb_fault(struct mm_struct *mm,
237+
struct vm_area_struct *vma, unsigned long address,
238+
unsigned int flags)
239+
{
240+
BUG();
241+
return 0;
242+
}
237243

238244
#endif /* !CONFIG_HUGETLB_PAGE */
239245
/*

include/linux/list.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static inline void list_bulk_move_tail(struct list_head *head,
207207
}
208208

209209
/**
210-
* list_is_first -- tests whether @ list is the first entry in list @head
210+
* list_is_first -- tests whether @list is the first entry in list @head
211211
* @list: the entry to test
212212
* @head: the head of the list
213213
*/

include/linux/page-isolation.h

-10
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ int move_freepages_block(struct zone *zone, struct page *page,
4141

4242
/*
4343
* Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE.
44-
* If specified range includes migrate types other than MOVABLE or CMA,
45-
* this will fail with -EBUSY.
46-
*
47-
* For isolating all pages in the range finally, the caller have to
48-
* free all pages in the range. test_page_isolated() can be used for
49-
* test it.
50-
*
51-
* The following flags are allowed (they can be combined in a bit mask)
52-
* SKIP_HWPOISON - ignore hwpoison pages
53-
* REPORT_FAILURE - report details about the failure to isolate the range
5444
*/
5545
int
5646
start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,

include/linux/sched/signal.h

+18
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,20 @@ static inline void set_restore_sigmask(void)
418418
set_thread_flag(TIF_RESTORE_SIGMASK);
419419
WARN_ON(!test_thread_flag(TIF_SIGPENDING));
420420
}
421+
422+
static inline void clear_tsk_restore_sigmask(struct task_struct *tsk)
423+
{
424+
clear_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK);
425+
}
426+
421427
static inline void clear_restore_sigmask(void)
422428
{
423429
clear_thread_flag(TIF_RESTORE_SIGMASK);
424430
}
431+
static inline bool test_tsk_restore_sigmask(struct task_struct *tsk)
432+
{
433+
return test_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK);
434+
}
425435
static inline bool test_restore_sigmask(void)
426436
{
427437
return test_thread_flag(TIF_RESTORE_SIGMASK);
@@ -439,6 +449,10 @@ static inline void set_restore_sigmask(void)
439449
current->restore_sigmask = true;
440450
WARN_ON(!test_thread_flag(TIF_SIGPENDING));
441451
}
452+
static inline void clear_tsk_restore_sigmask(struct task_struct *tsk)
453+
{
454+
tsk->restore_sigmask = false;
455+
}
442456
static inline void clear_restore_sigmask(void)
443457
{
444458
current->restore_sigmask = false;
@@ -447,6 +461,10 @@ static inline bool test_restore_sigmask(void)
447461
{
448462
return current->restore_sigmask;
449463
}
464+
static inline bool test_tsk_restore_sigmask(struct task_struct *tsk)
465+
{
466+
return tsk->restore_sigmask;
467+
}
450468
static inline bool test_and_clear_restore_sigmask(void)
451469
{
452470
if (!current->restore_sigmask)

include/linux/slab.h

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U)
3333
/* Use GFP_DMA memory */
3434
#define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U)
35+
/* Use GFP_DMA32 memory */
36+
#define SLAB_CACHE_DMA32 ((slab_flags_t __force)0x00008000U)
3537
/* DEBUG: Store the last owner for bug hunting */
3638
#define SLAB_STORE_USER ((slab_flags_t __force)0x00010000U)
3739
/* Panic if kmem_cache_create() fails */

kernel/ptrace.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/hw_breakpoint.h>
3030
#include <linux/cn_proc.h>
3131
#include <linux/compat.h>
32+
#include <linux/sched/signal.h>
3233

3334
/*
3435
* Access another process' address space via ptrace.
@@ -924,18 +925,26 @@ int ptrace_request(struct task_struct *child, long request,
924925
ret = ptrace_setsiginfo(child, &siginfo);
925926
break;
926927

927-
case PTRACE_GETSIGMASK:
928+
case PTRACE_GETSIGMASK: {
929+
sigset_t *mask;
930+
928931
if (addr != sizeof(sigset_t)) {
929932
ret = -EINVAL;
930933
break;
931934
}
932935

933-
if (copy_to_user(datavp, &child->blocked, sizeof(sigset_t)))
936+
if (test_tsk_restore_sigmask(child))
937+
mask = &child->saved_sigmask;
938+
else
939+
mask = &child->blocked;
940+
941+
if (copy_to_user(datavp, mask, sizeof(sigset_t)))
934942
ret = -EFAULT;
935943
else
936944
ret = 0;
937945

938946
break;
947+
}
939948

940949
case PTRACE_SETSIGMASK: {
941950
sigset_t new_set;
@@ -961,6 +970,8 @@ int ptrace_request(struct task_struct *child, long request,
961970
child->blocked = new_set;
962971
spin_unlock_irq(&child->sighand->siglock);
963972

973+
clear_tsk_restore_sigmask(child);
974+
964975
ret = 0;
965976
break;
966977
}

mm/debug.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void __dump_page(struct page *page, const char *reason)
7979
pr_warn("ksm ");
8080
else if (mapping) {
8181
pr_warn("%ps ", mapping->a_ops);
82-
if (mapping->host->i_dentry.first) {
82+
if (mapping->host && mapping->host->i_dentry.first) {
8383
struct dentry *dentry;
8484
dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias);
8585
pr_warn("name:\"%pd\" ", dentry);
@@ -168,7 +168,7 @@ void dump_mm(const struct mm_struct *mm)
168168
mm_pgtables_bytes(mm),
169169
mm->map_count,
170170
mm->hiwater_rss, mm->hiwater_vm, mm->total_vm, mm->locked_vm,
171-
atomic64_read(&mm->pinned_vm),
171+
(u64)atomic64_read(&mm->pinned_vm),
172172
mm->data_vm, mm->exec_vm, mm->stack_vm,
173173
mm->start_code, mm->end_code, mm->start_data, mm->end_data,
174174
mm->start_brk, mm->brk, mm->start_stack,

0 commit comments

Comments
 (0)