Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 May 2017 20:05:47 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-geom@FreeBSD.org
Subject:   [Bug 198500] [gjournal] sysctl kern.geom.journal.cache.limit 32 bit integer overflow
Message-ID:  <bug-198500-14739-cWT8Jy1THZ@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-198500-14739@https.bugs.freebsd.org/bugzilla/>
References:  <bug-198500-14739@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D198500

--- Comment #3 from longwitz@incore.de ---
Yes, my patch was for 10.3 r317782 and worked only for amd64. The following
(untested) patch is against HEAD and should work for both i386 and amd64:

--- g_journal.c.orig    2017-05-10 21:25:30.000000000 +0200
+++ g_journal.c 2017-05-10 21:43:24.000000000 +0200
@@ -130,26 +130,26 @@
 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;
+static u_long g_journal_cache_used =3D 0;
+static u_long g_journal_cache_limit =3D 64 * 1024 * 1024;
 static u_int g_journal_cache_divisor =3D 2;
 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;
@@ -157,7 +157,7 @@
        return (0);
 }
 SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit,
-    CTLTYPE_UINT | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "=
I",
+    CTLTYPE_ULONG | CTLFLAG_RWTUN, 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,
@@ -3046,9 +3046,9 @@
                        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,
-                           g_journal_cache_limit);
+                       GJ_DEBUG(1, "Out of cache, force switch (used=3D%jd=
 "
+                           "limit=3D%jd).", (intmax_t)g_journal_cache_used,
+                           (intmax_t)g_journal_cache_limit);
                }
                GJ_TIMER_START(1, &bt);
                g_journal_do_switch(mp);

I like to mention that kern.geom.journal.cache.limit does not work as a tun=
able
in loader.conf because g_journal.c overwrites this immediately in
g_journal_init(). Therefore I use kern.geom.journal.cache.divisor in
loader.conf to justify the cache at boottime.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-198500-14739-cWT8Jy1THZ>