Re: + hugetlbfs-check-for-pgoff-value-overflow-v3-fix.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 14 Mar 2018 10:47:00 +0100 Michal Hocko <mhocko@xxxxxxxxxx> wrote:

> On Thu 08-03-18 17:05:24, Andrew Morton wrote:
> > @@ -4374,11 +4375,8 @@ int hugetlb_reserve_pages(struct inode *
> >  	struct resv_map *resv_map;
> >  	long gbl_reserve;
> >  
> > -	/* This should never happen */
> > -	if (from > to) {
> > -		VM_WARN(1, "%s called with a negative range\n", __func__);
> > +	if (VM_WARN(from > to, "%s called with a negative range\n", __func__))
> >  		return -EINVAL;
> > -	}
> >  
> >  	/*
> >  	 * Only apply hugepage reservation if asked. At fault time, an
> 
> My compiler chokes on this with
> In file included from ./include/linux/kernel.h:15:0,
>                  from ./include/linux/list.h:9,
>                  from mm/hugetlb.c:5:
> mm/hugetlb.c: In function 'hugetlb_reserve_pages':
> ./include/linux/build_bug.h:36:33: error: void value not ignored as it ought to be
>  #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
>                                  ^
> ./include/linux/mmdebug.h:52:34: note: in expansion of macro 'BUILD_BUG_ON_INVALID'
>  #define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond)
>                                   ^
> mm/hugetlb.c:4379:6: note: in expansion of macro 'VM_WARN'
>   if (VM_WARN(from > to, "%s called with a negative range\n", __func__))
> 
> I haven't explored it further yet.

Yes, sfr hit that as well.  Seems that nobody has tried to use the
return value from VM_WARN[_foo]() with CONFIG_DEBUG_VM=n.

This seems to work - I'll poke at it a bit more.

--- a/include/linux/mmdebug.h~a
+++ a/include/linux/mmdebug.h
@@ -46,10 +46,10 @@ void dump_mm(const struct mm_struct *mm)
 #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
 #define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond)
 #define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond)
-#define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond)
-#define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
-#define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
-#define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond)
+#define VM_WARN_ON(cond) ({ BUILD_BUG_ON_INVALID(cond); 0; })
+#define VM_WARN_ON_ONCE(cond) ({ BUILD_BUG_ON_INVALID(cond); 0; })
+#define VM_WARN_ONCE(cond, format...) ({ BUILD_BUG_ON_INVALID(cond); 0; })
+#define VM_WARN(cond, format...) ({ BUILD_BUG_ON_INVALID(cond); 0; })
 #endif
 
 #ifdef CONFIG_DEBUG_VIRTUAL
_

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux