git: 5c55ab57c818 - stable/12 - libalias: fix divide by zero causing panic

Lutz Donnerhacke donner at FreeBSD.org
Wed Jul 14 11:54:38 UTC 2021


The branch stable/12 has been updated by donner:

URL: https://cgit.FreeBSD.org/src/commit/?id=5c55ab57c81885cf6b269bfb77dbb334ca0a9bde

commit 5c55ab57c81885cf6b269bfb77dbb334ca0a9bde
Author:     Stefan Eßer <se at FreeBSD.org>
AuthorDate: 2021-07-10 11:00:56 +0000
Commit:     Lutz Donnerhacke <donner at FreeBSD.org>
CommitDate: 2021-07-14 11:54:15 +0000

    libalias: fix divide by zero causing panic
    
    The packet_limit can fall to 0, leading to a divide by zero abort in
    the "packets % packet_limit".
    
    An possible solution would be to apply a lower limit of 1 after the
    calculation of packet_limit, but since any number modulo 1 gives 0,
    the more efficient solution is to skip the modulo operation for
    packet_limit <= 1.
    
    Reported by:    Karl Denninger <karl at denninger.net>
    
    (cherry picked from commit 58080fbca09fda6d5f011d37059edbca8ceb4c58)
---
 sys/netinet/libalias/alias_db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c
index 783a8ca3baa8..ed222c4133d4 100644
--- a/sys/netinet/libalias/alias_db.c
+++ b/sys/netinet/libalias/alias_db.c
@@ -1769,7 +1769,7 @@ HouseKeeping(struct libalias *la)
 	 * Reduce the amount of house keeping work substantially by
 	 * sampling over the packets.
 	 */
-	if (packets % packet_limit == 0) {
+	if (packet_limit <= 1 || packets % packet_limit == 0) {
 		time_t now;
 
 #ifdef _KERNEL


More information about the dev-commits-src-all mailing list