Re: [PATCH v3] tools/mm: Fix slabinfo crash when MAX_SLABS is exceeded

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 30 Oct 2024 10:32:08 -0300 Marc Dionne <marc.c.dionne@xxxxxxxxx> wrote:

> From: Marc Dionne <marc.dionne@xxxxxxxxxxxx>
> 
> The number of slabs can easily exceed the hard coded MAX_SLABS in the
> slabinfo tool, causing it to overwrite memory and crash.
> 
> Increase the value of MAX_SLABS, and check if that has been exceeded for
> each new slab, instead of at the end when it's already too late.  Also
> move the check for MAX_ALIASES into the loop body.
> 
> @@ -1240,6 +1240,8 @@ static void read_slab_dir(void)
>  				p--;
>  			alias->ref = strdup(p);
>  			alias++;
> +			if (alias - aliasinfo == MAX_ALIASES)
> +				fatal("Too many aliases\n");

Again, this is not correct.  It has a potential off-by-one error.

If at this point, (alias - aliasinfo == MAX_ALIASES), we *do not know*
whether there are "Too many aliases".  Because the parsing might have
reached the end of input, in which case we're fine.

A fix for this is to check for an invalid `alias' immediately before we
use it, as I described in the previous email.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux