From owner-freebsd-geom@freebsd.org Mon May 8 19:27:25 2017 Return-Path: Delivered-To: freebsd-geom@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1873D63447 for ; Mon, 8 May 2017 19:27:25 +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 mx1.freebsd.org (Postfix) with ESMTPS id 5EAA917E8 for ; Mon, 8 May 2017 19:27:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v48JRNHZ019609 for ; Mon, 8 May 2017 19:27:25 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-geom@FreeBSD.org Subject: [Bug 198500] [gjournal] sysctl kern.geom.journal.cache.limit 32 bit integer overflow Date: Mon, 08 May 2017 19:27:24 +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: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: longwitz@incore.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-geom@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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-geom@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 May 2017 19:27:25 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D198500 longwitz@incore.de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |longwitz@incore.de --- Comment #1 from longwitz@incore.de --- The main problem caused by the mixed use of u_int and u_long variables in g_journal.c is the suspicious value of kern.geom.journal.cache.limit for machines with more than 8 GB of memory. Therefore I propose the followi= ng patch for this problem for FreeBSD 10.3-STABLE #0 r317782: --- sys/geom/journal/g_journal.c.orig 2017-05-04 10:02:46.000000000 +0200 +++ sys/geom/journal/g_journal.c 2017-05-05 23:37:57.625783000 +0200 @@ -131,28 +131,28 @@ SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW, &g_journal_do_optimize, 0, "Try to combine bios on flush and copy"); -static u_int g_journal_cache_used =3D 0; -static u_int g_journal_cache_limit =3D 64 * 1024 * 1024; -TUNABLE_INT("kern.geom.journal.cache.limit", &g_journal_cache_limit); +static u_long g_journal_cache_used =3D 0; +static u_long g_journal_cache_limit =3D 64 * 1024 * 1024; +TUNABLE_ULONG("kern.geom.journal.cache.limit", &g_journal_cache_limit); static u_int g_journal_cache_divisor =3D 2; TUNABLE_INT("kern.geom.journal.cache.divisor", &g_journal_cache_divisor); static u_int g_journal_cache_switch =3D 90; static u_int g_journal_cache_misses =3D 0; static u_int g_journal_cache_alloc_failures =3D 0; -static u_int g_journal_cache_low =3D 0; +static u_long g_journal_cache_low =3D 0; static SYSCTL_NODE(_kern_geom_journal, OID_AUTO, cache, CTLFLAG_RW, 0, "GEOM_JOURNAL cache"); -SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, used, CTLFLAG_RD, +SYSCTL_ULONG(_kern_geom_journal_cache, OID_AUTO, used, CTLFLAG_RD, &g_journal_cache_used, 0, "Number of allocated bytes"); static int g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) { - u_int limit; + u_long limit; int error; limit =3D g_journal_cache_limit; - error =3D sysctl_handle_int(oidp, &limit, 0, req); + error =3D sysctl_handle_long(oidp, &limit, 0, req); if (error !=3D 0 || req->newptr =3D=3D NULL) return (error); g_journal_cache_limit =3D limit; @@ -160,7 +160,7 @@ return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit, - CTLTYPE_UINT | CTLFLAG_RW, NULL, 0, g_journal_cache_limit_sysctl, "I", + CTLTYPE_ULONG | CTLFLAG_RW, NULL, 0, g_journal_cache_limit_sysctl, "LU= ", "Maximum number of allocated bytes"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN, &g_journal_cache_divisor, 0, @@ -3035,8 +3035,8 @@ kproc_exit(0); } if (error =3D=3D 0 && g_journal_sync_requested =3D=3D 0) { - GJ_DEBUG(1, "Out of cache, force switch (used=3D%u " - "limit=3D%u).", g_journal_cache_used, + GJ_DEBUG(1, "Out of cache, force switch (used=3D%jd= " + "limit=3D%jd).", g_journal_cache_used, g_journal_cache_limit); } GJ_TIMER_START(1, &bt); --=20 You are receiving this mail because: You are the assignee for the bug.=