android_kernel_xiaomi_sm8350/drivers/infiniband/core
Roland Dreier 8079ffa0e1 IB/umem: Avoid sign problems when demoting npages to integer
On a 64-bit architecture, if ib_umem_get() is called with a size value
that is so big that npages is negative when cast to int, then the
length of the page list passed to get_user_pages(), namely

	min_t(int, npages, PAGE_SIZE / sizeof (struct page *))

will be negative, and get_user_pages() will immediately return 0 (at
least since 900cf086, "Be more robust about bad arguments in
get_user_pages()").  This leads to an infinite loop in ib_umem_get(),
since the code boils down to:

	while (npages) {
		ret = get_user_pages(...);
		npages -= ret;
	}

Fix this by taking the minimum as unsigned longs, so that the value of
npages is never truncated.

The impact of this bug isn't too severe, since the value of npages is
checked against RLIMIT_MEMLOCK, so a process would need to have an
astronomical limit or have CAP_IPC_LOCK to be able to trigger this,
and such a process could already cause lots of mischief.  But it does
let buggy userspace code cause a kernel lock-up; for example I hit
this with code that passes a negative value into a memory registartion
function where it is promoted to a huge u64 value.

Cc: <stable@kernel.org>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
2008-06-06 21:38:37 -07:00
..
addr.c
agent.c
agent.h
cache.c
cm_msgs.h
cm.c
cma.c
core_priv.h
device.c
fmr_pool.c
iwcm.c
iwcm.h
mad_priv.h
mad_rmpp.c
mad_rmpp.h
mad.c IB/mad: Fix kernel crash when .process_mad() returns SUCCESS|CONSUMED 2008-05-23 10:52:59 -07:00
Makefile
multicast.c
packer.c
sa_query.c
sa.h
smi.c
smi.h
sysfs.c
ucm.c
ucma.c
ud_header.c
umem.c IB/umem: Avoid sign problems when demoting npages to integer 2008-06-06 21:38:37 -07:00
user_mad.c
uverbs_cmd.c
uverbs_main.c
uverbs_marshall.c
uverbs.h
verbs.c