mirror of
https://github.com/torvalds/linux.git
synced 2024-10-23 21:50:43 +00:00
net/tcp_sigpool: Fix some off by one bugs
The "cpool_populated" variable is the number of elements in the cpool[]
array that have been populated. It is incremented in
tcp_sigpool_alloc_ahash() every time we populate a new element.
Unpopulated elements are NULL but if we have populated every element then
this code will read one element beyond the end of the array.
Fixes: 8c73b26315
("net/tcp: Prepare tcp_md5sig_pool for TCP-AO")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Dmitry Safonov <dima@arista.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/ce915d61-04bc-44fb-b450-35fcc9fc8831@moroto.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
19b3f72a41
commit
74da779213
|
@ -231,7 +231,7 @@ static void cpool_schedule_cleanup(struct kref *kref)
|
|||
*/
|
||||
void tcp_sigpool_release(unsigned int id)
|
||||
{
|
||||
if (WARN_ON_ONCE(id > cpool_populated || !cpool[id].alg))
|
||||
if (WARN_ON_ONCE(id >= cpool_populated || !cpool[id].alg))
|
||||
return;
|
||||
|
||||
/* slow-path */
|
||||
|
@ -245,7 +245,7 @@ EXPORT_SYMBOL_GPL(tcp_sigpool_release);
|
|||
*/
|
||||
void tcp_sigpool_get(unsigned int id)
|
||||
{
|
||||
if (WARN_ON_ONCE(id > cpool_populated || !cpool[id].alg))
|
||||
if (WARN_ON_ONCE(id >= cpool_populated || !cpool[id].alg))
|
||||
return;
|
||||
kref_get(&cpool[id].kref);
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ int tcp_sigpool_start(unsigned int id, struct tcp_sigpool *c) __cond_acquires(RC
|
|||
struct crypto_ahash *hash;
|
||||
|
||||
rcu_read_lock_bh();
|
||||
if (WARN_ON_ONCE(id > cpool_populated || !cpool[id].alg)) {
|
||||
if (WARN_ON_ONCE(id >= cpool_populated || !cpool[id].alg)) {
|
||||
rcu_read_unlock_bh();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ EXPORT_SYMBOL_GPL(tcp_sigpool_end);
|
|||
*/
|
||||
size_t tcp_sigpool_algo(unsigned int id, char *buf, size_t buf_len)
|
||||
{
|
||||
if (WARN_ON_ONCE(id > cpool_populated || !cpool[id].alg))
|
||||
if (WARN_ON_ONCE(id >= cpool_populated || !cpool[id].alg))
|
||||
return -EINVAL;
|
||||
|
||||
return strscpy(buf, cpool[id].alg, buf_len);
|
||||
|
|
Loading…
Reference in New Issue
Block a user