From owner-freebsd-pf@freebsd.org Tue Feb 13 11:54:05 2018 Return-Path: Delivered-To: freebsd-pf@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BAD65F1A572 for ; Tue, 13 Feb 2018 11:54:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5396173E0F for ; Tue, 13 Feb 2018 11:54:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 969B925FCB for ; Tue, 13 Feb 2018 11:54:04 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id w1DBs4xE073677 for ; Tue, 13 Feb 2018 11:54:04 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id w1DBs4QO073676 for freebsd-pf@FreeBSD.org; Tue, 13 Feb 2018 11:54:04 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: freebsd-pf@FreeBSD.org Subject: [Bug 209475] pf didn't check if enough free RAM for net.pf.states_hashsize Date: Tue, 13 Feb 2018 11:54:04 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 10.3-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: fnoyanisi@yahoo.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-pf@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.isobsolete attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Feb 2018 11:54:06 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D209475 fehmi noyan isi changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #190429|0 |1 is obsolete| | --- Comment #28 from fehmi noyan isi --- Created attachment 190574 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D190574&action= =3Dedit patch with mallocarray(9), printf(9) and a single fallback block Attached is the latest patch with a single fallback block which is executed depending on the return values from mallcoarray(... | M_NOWAIT) calls. The = code sets the value of respective variable that is passed to mallocarray(9) rath= er than directly using PH_HASHSIZ in the mallocarray(9) call. I tried the patch on a 512MB VM running FreeBSD-12.0CURRENT and verified th= at PF initialisation went okay. A log message indicating the memory allocation issue is present in /var/log/messages (and in the console). root@test-vm:~ # uname -a FreeBSD test-vm 12.0-CURRENT FreeBSD 12.0-CURRENT #13: Wed Feb 14 13:28:52 = NZDT 2018 root@test-vm:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 root@test-vm:~ # cat /boot/loader.conf net.pf.states_hashsize=3D"2147483648" root@test-vm:~ # sysctl hw.realmem hw.realmem: 536805376 root@test-vm:~ # kldstat Id Refs Address Size Name 1 1 0xffffffff80200000 20bf2d0 kernel root@test-vm:~ # service pf onestart Enabling pf. root@test-vm:~ # kldstat Id Refs Address Size Name 1 3 0xffffffff80200000 20bf2d0 kernel 2 1 0xffffffff82419000 33590 pf.ko root@test-vm:~ # grep pf_initialize /var/log/messages Feb 14 13:40:20 test-vm kernel: pf_initialize : Not enough memory for 85899345920 bytes. --=20 You are receiving this mail because: You are the assignee for the bug.=