Tetsuo Handa wrote:
> Commit 095dc8e0c3686d58 ("tcp: fix/cleanup inet_ehash_locks_alloc()")
> silently changed from kmalloc() to kmalloc_array(). The latter has
> overflow check whereas the former doesn't have.
>
> If nblocks * locksz might overflow, we need to do like
>
> - if (!hashinfo->ehash_locks && nblocks > SIZE_MAX / locksz)
> + if (!hashinfo->ehash_locks && nblocks > SIZE_MAX / locksz)
Oops, I meant
- if (!hashinfo->ehash_locks)
+ if (!hashinfo->ehash_locks && nblocks > SIZE_MAX / locksz)
here.
> hashinfo->ehash_locks = vmalloc(nblocks * locksz);
>
> because kmalloc_array() detects overflow and returns NULL.
> But if nblocks * locksz is guaranteed not to overflow, there is
> no need to use kmalloc_array().
>
> Since I assume it won't overflow, use kmalloc() than kmalloc_array().
I don't know about possible value range.
Please confirm that it can't overflow.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html