An error occurred while fetching folder content.
mm/shmem.c: cast the type of unmap_start to u64
Chen Jun authored
commit aa71ecd8 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...
f49aa24d
Name Last commit Last update
..
kasan kasan: fix shadow_size calculation error in kasan_module_alloc
Kconfig mm/hmm: select mmu notifier when selecting HMM
Kconfig.debug kmemcheck: rip it out
Makefile kmemcheck: rip it out
backing-dev.c writeback: synchronize sync(2) against cgroup writeback membership switches
balloon_compaction.c virtio_balloon: fix deadlock on OOM
bootmem.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license
cleancache.c fs: switch ->s_uuid to uuid_t
cma.c mm/cma.c: fail if fixed declaration can't be honored
cma.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license
cma_debug.c mm/cma_debug.c: fix the break condition in cma_maxchunk_get()
compaction.c mm/compaction.c: clear total_{migrate,free}_scanned before scanning a new zone
debug.c mm: get rid of vmacache_flush_all() entirely
debug_page_ref.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license
dmapool.c lib/vsprintf.c: remove %Z support
early_ioremap.c mm/early_ioremap: Fix boot hang with earlyprintk=efi,keep
fadvise.c mm/fadvise.c: fix signed overflow UBSAN complaint
failslab.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license
filemap.c mm/filemap.c: don't initiate writeback if mapping has no dirty pages
frame_vector.c mm/frame_vector.c: release a semaphore in 'get_vaddr_frames()'
frontswap.c mm, frontswap: convert frontswap_enabled to static key
gup.c mm/gup.c: remove some BUG_ONs from get_gate_page()
highmem.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license
hmm.c mm, hmm: mark hmm_devmem_{add, add_resource} EXPORT_SYMBOL_GPL
huge_memory.c mm, page_owner: handle THP splits correctly
hugetlb.c
hugetlb_cgroup.c
hwpoison-inject.c
init-mm.c
internal.h
interval_tree.c
khugepaged.c
kmemleak-test.c
kmemleak.c
ksm.c
list_lru.c
maccess.c
madvise.c
memblock.c
memcontrol.c
memory-failure.c
memory.c
memory_hotplug.c
mempolicy.c
mempool.c
memtest.c
migrate.c
mincore.c
mlock.c
mm_init.c
mmap.c
mmu_context.c
mmu_notifier.c
mmzone.c
mprotect.c
mremap.c
msync.c
nobootmem.c
nommu.c
oom_kill.c
page-writeback.c
page_alloc.c
page_counter.c
page_ext.c
page_idle.c
page_io.c
page_isolation.c
page_owner.c
page_poison.c
page_vma_mapped.c
pagewalk.c
percpu-internal.h
percpu-km.c
percpu-stats.c
percpu-vm.c
percpu.c
pgtable-generic.c
process_vm_access.c
quicklist.c
readahead.c
rmap.c
rodata_test.c
shmem.c
slab.c
slab.h
slab_common.c
slob.c
slub.c
sparse-vmemmap.c
sparse.c
swap.c
swap_cgroup.c
swap_slots.c
swap_state.c
swapfile.c
truncate.c
usercopy.c
userfaultfd.c
util.c
vmacache.c