Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jan 2015 11:19:23 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        Davide Italiano <davide@freebsd.org>
Subject:   Re: [PATCH] nmbclusters should be always positive
Message-ID:  <201501201119.23123.jhb@freebsd.org>
In-Reply-To: <CACYV=-HiK_DHTaZzjs2G9%2BchwYYyX=LnkztF7UKNAUY0RpTGZQ@mail.gmail.com>
References:  <CACYV=-HiK_DHTaZzjs2G9%2BchwYYyX=LnkztF7UKNAUY0RpTGZQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, January 19, 2015 6:12:25 pm Davide Italiano wrote:
> Currently, the following is allowed in FreeBSD:
> 
> root@rabbit1:/home/davide/udp-clt # sysctl kern.ipc.nmbclusters=2147483647
> kern.ipc.nmbclusters: 2036598 -> -2147483648
> 
> The following is an attempt of fixing.
> I also think nmbcluster should actually be u_int and not it, but this
> is a discussion for another day, maybe.
> 
> diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
> index 7ab6509..15b38a9 100644
> --- a/sys/kern/kern_mbuf.c
> +++ b/sys/kern/kern_mbuf.c
> @@ -162,7 +162,7 @@ sysctl_nmbclusters(SYSCTL_HANDLER_ARGS)
>         newnmbclusters = nmbclusters;
>         error = sysctl_handle_int(oidp, &newnmbclusters, 0, req);
>         if (error == 0 && req->newptr && newnmbclusters != nmbclusters) {
> -               if (newnmbclusters > nmbclusters &&
> +               if (newnmbclusters > 0 && newnmbclusters > nmbclusters &&
>                     nmbufs >= nmbclusters + nmbjumbop + nmbjumbo9 +
> nmbjumbo16) {
>                         nmbclusters = newnmbclusters;
>                         nmbclusters = uma_zone_set_max(zone_clust, 
nmbclusters);

1) If you fix this one you need to fix the other handlers in this file (all 
the jumbo ones, etc.)

2) Shouldn't the 'newnmbclusters > nmbclusters' check catch this already?  
That should fail right?  Might be worth figuring out why it isn't.

-- 
John Baldwin



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