Skip to content

Commit dfa377c

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "7 patches. Subsystems affected by this patch series: mm (kasan, mm/slub, mm/madvise, and memcg), and lib" * emailed patches from Andrew Morton <[email protected]>: lib: use PFN_PHYS() in devmem_is_allowed() mm/memcg: fix incorrect flushing of lruvec data in obj_stock mm/madvise: report SIGBUS as -EFAULT for MADV_POPULATE_(READ|WRITE) mm: slub: fix slub_debug disabling for list of slabs slub: fix kmalloc_pagealloc_invalid_free unit test kasan, slub: reset tag when printing address kasan, kmemleak: reset tags when scanning block
2 parents 27b2eaa + 854f326 commit dfa377c

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

lib/devmem_is_allowed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
int devmem_is_allowed(unsigned long pfn)
2121
{
22-
if (iomem_is_exclusive(pfn << PAGE_SHIFT))
22+
if (iomem_is_exclusive(PFN_PHYS(pfn)))
2323
return 0;
2424
if (!page_is_ram(pfn))
2525
return 1;

mm/gup.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,9 +1558,12 @@ long faultin_vma_page_range(struct vm_area_struct *vma, unsigned long start,
15581558
gup_flags |= FOLL_WRITE;
15591559

15601560
/*
1561-
* See check_vma_flags(): Will return -EFAULT on incompatible mappings
1562-
* or with insufficient permissions.
1561+
* We want to report -EINVAL instead of -EFAULT for any permission
1562+
* problems or incompatible mappings.
15631563
*/
1564+
if (check_vma_flags(vma, gup_flags))
1565+
return -EINVAL;
1566+
15641567
return __get_user_pages(mm, start, nr_pages, gup_flags,
15651568
NULL, NULL, locked);
15661569
}

mm/kmemleak.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static void hex_dump_object(struct seq_file *seq,
290290
warn_or_seq_printf(seq, " hex dump (first %zu bytes):\n", len);
291291
kasan_disable_current();
292292
warn_or_seq_hex_dump(seq, DUMP_PREFIX_NONE, HEX_ROW_SIZE,
293-
HEX_GROUP_SIZE, ptr, len, HEX_ASCII);
293+
HEX_GROUP_SIZE, kasan_reset_tag((void *)ptr), len, HEX_ASCII);
294294
kasan_enable_current();
295295
}
296296

@@ -1171,7 +1171,7 @@ static bool update_checksum(struct kmemleak_object *object)
11711171

11721172
kasan_disable_current();
11731173
kcsan_disable_current();
1174-
object->checksum = crc32(0, (void *)object->pointer, object->size);
1174+
object->checksum = crc32(0, kasan_reset_tag((void *)object->pointer), object->size);
11751175
kasan_enable_current();
11761176
kcsan_enable_current();
11771177

@@ -1246,7 +1246,7 @@ static void scan_block(void *_start, void *_end,
12461246
break;
12471247

12481248
kasan_disable_current();
1249-
pointer = *ptr;
1249+
pointer = *(unsigned long *)kasan_reset_tag((void *)ptr);
12501250
kasan_enable_current();
12511251

12521252
untagged_ptr = (unsigned long)kasan_reset_tag((void *)pointer);

mm/madvise.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,12 @@ static long madvise_populate(struct vm_area_struct *vma,
862862
switch (pages) {
863863
case -EINTR:
864864
return -EINTR;
865-
case -EFAULT: /* Incompatible mappings / permissions. */
865+
case -EINVAL: /* Incompatible mappings / permissions. */
866866
return -EINVAL;
867867
case -EHWPOISON:
868868
return -EHWPOISON;
869+
case -EFAULT: /* VM_FAULT_SIGBUS or VM_FAULT_SIGSEGV */
870+
return -EFAULT;
869871
default:
870872
pr_warn_once("%s: unhandled return value: %ld\n",
871873
__func__, pages);

mm/memcontrol.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,13 +3106,15 @@ void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat,
31063106
stock->cached_pgdat = pgdat;
31073107
} else if (stock->cached_pgdat != pgdat) {
31083108
/* Flush the existing cached vmstat data */
3109+
struct pglist_data *oldpg = stock->cached_pgdat;
3110+
31093111
if (stock->nr_slab_reclaimable_b) {
3110-
mod_objcg_mlstate(objcg, pgdat, NR_SLAB_RECLAIMABLE_B,
3112+
mod_objcg_mlstate(objcg, oldpg, NR_SLAB_RECLAIMABLE_B,
31113113
stock->nr_slab_reclaimable_b);
31123114
stock->nr_slab_reclaimable_b = 0;
31133115
}
31143116
if (stock->nr_slab_unreclaimable_b) {
3115-
mod_objcg_mlstate(objcg, pgdat, NR_SLAB_UNRECLAIMABLE_B,
3117+
mod_objcg_mlstate(objcg, oldpg, NR_SLAB_UNRECLAIMABLE_B,
31163118
stock->nr_slab_unreclaimable_b);
31173119
stock->nr_slab_unreclaimable_b = 0;
31183120
}

mm/slub.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ static void print_section(char *level, char *text, u8 *addr,
576576
unsigned int length)
577577
{
578578
metadata_access_enable();
579-
print_hex_dump(level, kasan_reset_tag(text), DUMP_PREFIX_ADDRESS,
580-
16, 1, addr, length, 1);
579+
print_hex_dump(level, text, DUMP_PREFIX_ADDRESS,
580+
16, 1, kasan_reset_tag((void *)addr), length, 1);
581581
metadata_access_disable();
582582
}
583583

@@ -1400,12 +1400,13 @@ parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init)
14001400
static int __init setup_slub_debug(char *str)
14011401
{
14021402
slab_flags_t flags;
1403+
slab_flags_t global_flags;
14031404
char *saved_str;
14041405
char *slab_list;
14051406
bool global_slub_debug_changed = false;
14061407
bool slab_list_specified = false;
14071408

1408-
slub_debug = DEBUG_DEFAULT_FLAGS;
1409+
global_flags = DEBUG_DEFAULT_FLAGS;
14091410
if (*str++ != '=' || !*str)
14101411
/*
14111412
* No options specified. Switch on full debugging.
@@ -1417,7 +1418,7 @@ static int __init setup_slub_debug(char *str)
14171418
str = parse_slub_debug_flags(str, &flags, &slab_list, true);
14181419

14191420
if (!slab_list) {
1420-
slub_debug = flags;
1421+
global_flags = flags;
14211422
global_slub_debug_changed = true;
14221423
} else {
14231424
slab_list_specified = true;
@@ -1426,16 +1427,18 @@ static int __init setup_slub_debug(char *str)
14261427

14271428
/*
14281429
* For backwards compatibility, a single list of flags with list of
1429-
* slabs means debugging is only enabled for those slabs, so the global
1430-
* slub_debug should be 0. We can extended that to multiple lists as
1430+
* slabs means debugging is only changed for those slabs, so the global
1431+
* slub_debug should be unchanged (0 or DEBUG_DEFAULT_FLAGS, depending
1432+
* on CONFIG_SLUB_DEBUG_ON). We can extended that to multiple lists as
14311433
* long as there is no option specifying flags without a slab list.
14321434
*/
14331435
if (slab_list_specified) {
14341436
if (!global_slub_debug_changed)
1435-
slub_debug = 0;
1437+
global_flags = slub_debug;
14361438
slub_debug_string = saved_str;
14371439
}
14381440
out:
1441+
slub_debug = global_flags;
14391442
if (slub_debug != 0 || slub_debug_string)
14401443
static_branch_enable(&slub_debug_enabled);
14411444
else
@@ -3236,12 +3239,12 @@ struct detached_freelist {
32363239
struct kmem_cache *s;
32373240
};
32383241

3239-
static inline void free_nonslab_page(struct page *page)
3242+
static inline void free_nonslab_page(struct page *page, void *object)
32403243
{
32413244
unsigned int order = compound_order(page);
32423245

32433246
VM_BUG_ON_PAGE(!PageCompound(page), page);
3244-
kfree_hook(page_address(page));
3247+
kfree_hook(object);
32453248
mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, -(PAGE_SIZE << order));
32463249
__free_pages(page, order);
32473250
}
@@ -3282,7 +3285,7 @@ int build_detached_freelist(struct kmem_cache *s, size_t size,
32823285
if (!s) {
32833286
/* Handle kalloc'ed objects */
32843287
if (unlikely(!PageSlab(page))) {
3285-
free_nonslab_page(page);
3288+
free_nonslab_page(page, object);
32863289
p[size] = NULL; /* mark object processed */
32873290
return size;
32883291
}
@@ -4258,7 +4261,7 @@ void kfree(const void *x)
42584261

42594262
page = virt_to_head_page(x);
42604263
if (unlikely(!PageSlab(page))) {
4261-
free_nonslab_page(page);
4264+
free_nonslab_page(page, object);
42624265
return;
42634266
}
42644267
slab_free(page->slab_cache, page, object, NULL, 1, _RET_IP_);

0 commit comments

Comments
 (0)