[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201511080058.FBI87526.FLOVOtFHJMQSOF@I-love.SAKURA.ne.jp>
Date: Sun, 8 Nov 2015 00:58:50 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: edumazet@...gle.com
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH] tcp: use kmalloc() than kmalloc_array().
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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists