Skip to content

Commit c202baf

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "13 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: memcg: disable hierarchy support if bound to the legacy cgroup hierarchy mm: reorder can_do_mlock to fix audit denial kasan, module: move MODULE_ALIGN macro into <linux/moduleloader.h> kasan, module, vmalloc: rework shadow allocation for modules fanotify: fix event filtering with FAN_ONDIR set mm/nommu.c: export symbol max_mapnr arch/c6x/include/asm/pgtable.h: define dummy pgprot_writecombine for !MMU nilfs2: fix deadlock of segment constructor during recovery mm: cma: fix CMA aligned offset calculation mm, hugetlb: close race when setting PageTail for gigantic pages mm, oom: do not fail __GFP_NOFAIL allocation if oom killer is disabled drivers/rtc/rtc-s3c.c: add .needs_src_clk to s3c6410 RTC data ocfs2: make append_dio an incompat feature
2 parents ba68bc0 + 7feee59 commit c202baf

File tree

18 files changed

+63
-33
lines changed

18 files changed

+63
-33
lines changed

arch/c6x/include/asm/pgtable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ extern unsigned long empty_zero_page;
6767
*/
6868
#define pgtable_cache_init() do { } while (0)
6969

70+
/*
71+
* c6x is !MMU, so define the simpliest implementation
72+
*/
73+
#define pgprot_writecombine pgprot_noncached
74+
7075
#include <asm-generic/pgtable.h>
7176

7277
#endif /* _ASM_C6X_PGTABLE_H */

drivers/rtc/rtc-s3c.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ static struct s3c_rtc_data const s3c2443_rtc_data = {
849849

850850
static struct s3c_rtc_data const s3c6410_rtc_data = {
851851
.max_user_freq = 32768,
852+
.needs_src_clk = true,
852853
.irq_handler = s3c6410_rtc_irq,
853854
.set_freq = s3c6410_rtc_setfreq,
854855
.enable_tick = s3c6410_rtc_enable_tick,

fs/nilfs2/segment.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,7 @@ static void nilfs_segctor_drop_written_files(struct nilfs_sc_info *sci,
19071907
struct the_nilfs *nilfs)
19081908
{
19091909
struct nilfs_inode_info *ii, *n;
1910+
int during_mount = !(sci->sc_super->s_flags & MS_ACTIVE);
19101911
int defer_iput = false;
19111912

19121913
spin_lock(&nilfs->ns_inode_lock);
@@ -1919,10 +1920,10 @@ static void nilfs_segctor_drop_written_files(struct nilfs_sc_info *sci,
19191920
brelse(ii->i_bh);
19201921
ii->i_bh = NULL;
19211922
list_del_init(&ii->i_dirty);
1922-
if (!ii->vfs_inode.i_nlink) {
1923+
if (!ii->vfs_inode.i_nlink || during_mount) {
19231924
/*
1924-
* Defer calling iput() to avoid a deadlock
1925-
* over I_SYNC flag for inodes with i_nlink == 0
1925+
* Defer calling iput() to avoid deadlocks if
1926+
* i_nlink == 0 or mount is not yet finished.
19261927
*/
19271928
list_add_tail(&ii->i_dirty, &sci->sc_iput_queue);
19281929
defer_iput = true;

fs/notify/fanotify/fanotify.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark,
143143
!(marks_mask & FS_ISDIR & ~marks_ignored_mask))
144144
return false;
145145

146-
if (event_mask & marks_mask & ~marks_ignored_mask)
146+
if (event_mask & FAN_ALL_OUTGOING_EVENTS & marks_mask &
147+
~marks_ignored_mask)
147148
return true;
148149

149150
return false;

fs/ocfs2/ocfs2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static inline int ocfs2_writes_unwritten_extents(struct ocfs2_super *osb)
502502

503503
static inline int ocfs2_supports_append_dio(struct ocfs2_super *osb)
504504
{
505-
if (osb->s_feature_ro_compat & OCFS2_FEATURE_RO_COMPAT_APPEND_DIO)
505+
if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_APPEND_DIO)
506506
return 1;
507507
return 0;
508508
}

fs/ocfs2/ocfs2_fs.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@
102102
| OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \
103103
| OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \
104104
| OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG \
105-
| OCFS2_FEATURE_INCOMPAT_CLUSTERINFO)
105+
| OCFS2_FEATURE_INCOMPAT_CLUSTERINFO \
106+
| OCFS2_FEATURE_INCOMPAT_APPEND_DIO)
106107
#define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
107108
| OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
108-
| OCFS2_FEATURE_RO_COMPAT_GRPQUOTA \
109-
| OCFS2_FEATURE_RO_COMPAT_APPEND_DIO)
109+
| OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
110110

111111
/*
112112
* Heartbeat-only devices are missing journals and other files. The
@@ -178,6 +178,11 @@
178178
*/
179179
#define OCFS2_FEATURE_INCOMPAT_CLUSTERINFO 0x4000
180180

181+
/*
182+
* Append Direct IO support
183+
*/
184+
#define OCFS2_FEATURE_INCOMPAT_APPEND_DIO 0x8000
185+
181186
/*
182187
* backup superblock flag is used to indicate that this volume
183188
* has backup superblocks.
@@ -200,10 +205,6 @@
200205
#define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
201206
#define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
202207

203-
/*
204-
* Append Direct IO support
205-
*/
206-
#define OCFS2_FEATURE_RO_COMPAT_APPEND_DIO 0x0008
207208

208209
/* The byte offset of the first backup block will be 1G.
209210
* The following will be 4G, 16G, 64G, 256G and 1T.

include/linux/kasan.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
struct kmem_cache;
77
struct page;
8+
struct vm_struct;
89

910
#ifdef CONFIG_KASAN
1011

@@ -49,15 +50,11 @@ void kasan_krealloc(const void *object, size_t new_size);
4950
void kasan_slab_alloc(struct kmem_cache *s, void *object);
5051
void kasan_slab_free(struct kmem_cache *s, void *object);
5152

52-
#define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
53-
5453
int kasan_module_alloc(void *addr, size_t size);
55-
void kasan_module_free(void *addr);
54+
void kasan_free_shadow(const struct vm_struct *vm);
5655

5756
#else /* CONFIG_KASAN */
5857

59-
#define MODULE_ALIGN 1
60-
6158
static inline void kasan_unpoison_shadow(const void *address, size_t size) {}
6259

6360
static inline void kasan_enable_current(void) {}
@@ -82,7 +79,7 @@ static inline void kasan_slab_alloc(struct kmem_cache *s, void *object) {}
8279
static inline void kasan_slab_free(struct kmem_cache *s, void *object) {}
8380

8481
static inline int kasan_module_alloc(void *addr, size_t size) { return 0; }
85-
static inline void kasan_module_free(void *addr) {}
82+
static inline void kasan_free_shadow(const struct vm_struct *vm) {}
8683

8784
#endif /* CONFIG_KASAN */
8885

include/linux/moduleloader.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,12 @@ void module_arch_cleanup(struct module *mod);
8484

8585
/* Any cleanup before freeing mod->module_init */
8686
void module_arch_freeing_init(struct module *mod);
87+
88+
#ifdef CONFIG_KASAN
89+
#include <linux/kasan.h>
90+
#define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
91+
#else
92+
#define MODULE_ALIGN PAGE_SIZE
93+
#endif
94+
8795
#endif

include/linux/vmalloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
1717
#define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
1818
#define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
1919
#define VM_NO_GUARD 0x00000040 /* don't add guard page */
20+
#define VM_KASAN 0x00000080 /* has allocated kasan shadow memory */
2021
/* bits [20..32] reserved for arch specific ioremap internals */
2122

2223
/*

kernel/module.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include <linux/async.h>
5757
#include <linux/percpu.h>
5858
#include <linux/kmemleak.h>
59-
#include <linux/kasan.h>
6059
#include <linux/jump_label.h>
6160
#include <linux/pfn.h>
6261
#include <linux/bsearch.h>
@@ -1814,7 +1813,6 @@ static void unset_module_init_ro_nx(struct module *mod) { }
18141813
void __weak module_memfree(void *module_region)
18151814
{
18161815
vfree(module_region);
1817-
kasan_module_free(module_region);
18181816
}
18191817

18201818
void __weak module_arch_cleanup(struct module *mod)

mm/cma.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ static unsigned long cma_bitmap_aligned_mask(struct cma *cma, int align_order)
6464
return (1UL << (align_order - cma->order_per_bit)) - 1;
6565
}
6666

67+
/*
68+
* Find a PFN aligned to the specified order and return an offset represented in
69+
* order_per_bits.
70+
*/
6771
static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
6872
{
69-
unsigned int alignment;
70-
7173
if (align_order <= cma->order_per_bit)
7274
return 0;
73-
alignment = 1UL << (align_order - cma->order_per_bit);
74-
return ALIGN(cma->base_pfn, alignment) -
75-
(cma->base_pfn >> cma->order_per_bit);
75+
76+
return (ALIGN(cma->base_pfn, (1UL << align_order))
77+
- cma->base_pfn) >> cma->order_per_bit;
7678
}
7779

7880
static unsigned long cma_bitmap_maxno(struct cma *cma)

mm/hugetlb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,6 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order)
917917
__SetPageHead(page);
918918
__ClearPageReserved(page);
919919
for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) {
920-
__SetPageTail(p);
921920
/*
922921
* For gigantic hugepages allocated through bootmem at
923922
* boot, it's safer to be consistent with the not-gigantic
@@ -933,6 +932,9 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order)
933932
__ClearPageReserved(p);
934933
set_page_count(p, 0);
935934
p->first_page = page;
935+
/* Make sure p->first_page is always valid for PageTail() */
936+
smp_wmb();
937+
__SetPageTail(p);
936938
}
937939
}
938940

mm/kasan/kasan.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/stacktrace.h>
3030
#include <linux/string.h>
3131
#include <linux/types.h>
32+
#include <linux/vmalloc.h>
3233
#include <linux/kasan.h>
3334

3435
#include "kasan.h"
@@ -414,12 +415,19 @@ int kasan_module_alloc(void *addr, size_t size)
414415
GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
415416
PAGE_KERNEL, VM_NO_GUARD, NUMA_NO_NODE,
416417
__builtin_return_address(0));
417-
return ret ? 0 : -ENOMEM;
418+
419+
if (ret) {
420+
find_vm_area(addr)->flags |= VM_KASAN;
421+
return 0;
422+
}
423+
424+
return -ENOMEM;
418425
}
419426

420-
void kasan_module_free(void *addr)
427+
void kasan_free_shadow(const struct vm_struct *vm)
421428
{
422-
vfree(kasan_mem_to_shadow(addr));
429+
if (vm->flags & VM_KASAN)
430+
vfree(kasan_mem_to_shadow(vm->addr));
423431
}
424432

425433
static void register_global(struct kasan_global *global)

mm/memcontrol.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5232,7 +5232,9 @@ static void mem_cgroup_bind(struct cgroup_subsys_state *root_css)
52325232
* on for the root memcg is enough.
52335233
*/
52345234
if (cgroup_on_dfl(root_css->cgroup))
5235-
mem_cgroup_from_css(root_css)->use_hierarchy = true;
5235+
root_mem_cgroup->use_hierarchy = true;
5236+
else
5237+
root_mem_cgroup->use_hierarchy = false;
52365238
}
52375239

52385240
static u64 memory_current_read(struct cgroup_subsys_state *css,

mm/mlock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
int can_do_mlock(void)
2828
{
29-
if (capable(CAP_IPC_LOCK))
30-
return 1;
3129
if (rlimit(RLIMIT_MEMLOCK) != 0)
3230
return 1;
31+
if (capable(CAP_IPC_LOCK))
32+
return 1;
3333
return 0;
3434
}
3535
EXPORT_SYMBOL(can_do_mlock);

mm/nommu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void *high_memory;
6262
EXPORT_SYMBOL(high_memory);
6363
struct page *mem_map;
6464
unsigned long max_mapnr;
65+
EXPORT_SYMBOL(max_mapnr);
6566
unsigned long highest_memmap_pfn;
6667
struct percpu_counter vm_committed_as;
6768
int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */

mm/page_alloc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,8 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
23732373
goto out;
23742374
}
23752375
/* Exhausted what can be done so it's blamo time */
2376-
if (out_of_memory(ac->zonelist, gfp_mask, order, ac->nodemask, false))
2376+
if (out_of_memory(ac->zonelist, gfp_mask, order, ac->nodemask, false)
2377+
|| WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL))
23772378
*did_some_progress = 1;
23782379
out:
23792380
oom_zonelist_unlock(ac->zonelist, gfp_mask);

mm/vmalloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,7 @@ struct vm_struct *remove_vm_area(const void *addr)
14181418
spin_unlock(&vmap_area_lock);
14191419

14201420
vmap_debug_free_range(va->va_start, va->va_end);
1421+
kasan_free_shadow(vm);
14211422
free_unmap_vmap_area(va);
14221423
vm->size -= PAGE_SIZE;
14231424

0 commit comments

Comments
 (0)