提交 228e4183 编写于 作者: D Daniel Jordan 提交者: Xie XiuQi

mm: enlarge type of offset argument in mem_map_offset and mem_map_next

hulk inclusion
category: feature
bugzilla: 13228
CVE: NA
---------------------------

Changes the type of 'offset' from int to unsigned long in both
mem_map_offset and mem_map_next.

This facilitates ktask's use of mem_map_next with its unsigned long
types to avoid silent truncation when these unsigned longs are passed as
ints.

It also fixes the preexisting truncation of 'offset' from unsigned long
to int by the sole caller of mem_map_offset, follow_hugetlb_page.
Signed-off-by: NDaniel Jordan <daniel.m.jordan@oracle.com>
Signed-off-by: NHongbo Yao <yaohongbo@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Tested-by: NHongbo Yao <yaohongbo@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 22705b26
...@@ -366,7 +366,8 @@ static inline void mlock_migrate_page(struct page *new, struct page *old) { } ...@@ -366,7 +366,8 @@ static inline void mlock_migrate_page(struct page *new, struct page *old) { }
* the maximally aligned gigantic page 'base'. Handle any discontiguity * the maximally aligned gigantic page 'base'. Handle any discontiguity
* in the mem_map at MAX_ORDER_NR_PAGES boundaries. * in the mem_map at MAX_ORDER_NR_PAGES boundaries.
*/ */
static inline struct page *mem_map_offset(struct page *base, int offset) static inline struct page *mem_map_offset(struct page *base,
unsigned long offset)
{ {
if (unlikely(offset >= MAX_ORDER_NR_PAGES)) if (unlikely(offset >= MAX_ORDER_NR_PAGES))
return nth_page(base, offset); return nth_page(base, offset);
...@@ -377,8 +378,8 @@ static inline struct page *mem_map_offset(struct page *base, int offset) ...@@ -377,8 +378,8 @@ static inline struct page *mem_map_offset(struct page *base, int offset)
* Iterator over all subpages within the maximally aligned gigantic * Iterator over all subpages within the maximally aligned gigantic
* page 'base'. Handle any discontiguity in the mem_map. * page 'base'. Handle any discontiguity in the mem_map.
*/ */
static inline struct page *mem_map_next(struct page *iter, static inline struct page *mem_map_next(struct page *iter, struct page *base,
struct page *base, int offset) unsigned long offset)
{ {
if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) { if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) {
unsigned long pfn = page_to_pfn(base) + offset; unsigned long pfn = page_to_pfn(base) + offset;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册