Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Jul 2021 11:13:05 GMT
From:      =?utf-8?Q?Stefan E=C3=9Fer?= <se@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 58080fbca09f - main - libalias: fix divide by zero causing panic
Message-ID:  <202107101113.16ABD5dG009026@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by se:

URL: https://cgit.FreeBSD.org/src/commit/?id=58080fbca09fda6d5f011d37059edbca8ceb4c58

commit 58080fbca09fda6d5f011d37059edbca8ceb4c58
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2021-07-10 11:00:56 +0000
Commit:     Stefan Eßer <se@FreeBSD.org>
CommitDate: 2021-07-10 11:08:18 +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.
    
    Since this is a fix for a panic observed in stable/12, merging this
    fix to stable/12 and stable/13 before expiry of the 3 day waiting
    period might be justified, if it works for the reporter of the issue.
    
    Reported by:    Karl Denninger <karl@denninger.net>
    MFC after:      3 days
---
 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 c09ad4352ce4..4612b32c139c 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107101113.16ABD5dG009026>