On Mon, Dec 13, 2021 at 01:05:43AM +0800, Coly Li wrote: > + /* > + * parameters of bitmap_set/clear are unsigned int. > + * Given currently size of nvm is far from exceeding this limit, > + * so only add a WARN_ON message. > + */ > + WARN_ON(BITS_TO_LONGS(ns->pages_total) > UINT_MAX); > + ns->pages_bitmap = kvcalloc(BITS_TO_LONGS(ns->pages_total), > + sizeof(unsigned long), GFP_KERNEL); BITS_TO_LONGS() has a potential integer overflow if we're talking about truly giant numbers. It will return zero if ns->pages_total is more than U64_MAX - 64. In that case kvcalloc() will return ZERO_SIZE_PTR. Btw, kvcalloc() will never let you allocate more than INT_MAX. It will trigger a WARN_ONCE(). If people want to allocate more than 2GB of RAM then they have to plan ahead of time and use vmalloc(). regards, dan carpenter