Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Nov 2020 13:41:53 -0800
From:      John Baldwin <jhb@FreeBSD.org>
To:        Pawel Biernacki <kaktus@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r368022 - head/lib/libsysdecode
Message-ID:  <faef09d1-c1ee-4e2b-115e-867900153371@FreeBSD.org>
In-Reply-To: <202011251630.0APGUvVO072230@repo.freebsd.org>
References:  <202011251630.0APGUvVO072230@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/25/20 8:30 AM, Pawel Biernacki wrote:
> Author: kaktus
> Date: Wed Nov 25 16:30:57 2020
> New Revision: 368022
> URL: https://svnweb.freebsd.org/changeset/base/368022
> 
> Log:
>   libsysdecode: correctly decode mmap flags
>   
>   r352913 added decoding of mmap PROT_MAX()'d flags but didn’t account for the
>   case where different values were specified for PROT_MAX and regular flags.
>   Fix it.
>   
>   Submitted by:	sigsys_gmail.com
>   Reported by:	sigsys_gmail.com
>   MFC after:	7 days
>   Differential Revision:	https://reviews.freebsd.org/D27312
> 
> Modified:
>   head/lib/libsysdecode/flags.c
> 
> Modified: head/lib/libsysdecode/flags.c
> ==============================================================================
> --- head/lib/libsysdecode/flags.c	Wed Nov 25 15:45:20 2020	(r368021)
> +++ head/lib/libsysdecode/flags.c	Wed Nov 25 16:30:57 2020	(r368022)
> @@ -662,11 +662,11 @@ sysdecode_mmap_prot(FILE *fp, int prot, int *rem)
>  
>  	printed = false;
>  	protm = PROT_MAX_EXTRACT(prot);
> +	prot = PROT_EXTRACT(prot);
>  	if (protm != 0) {
>  		fputs("PROT_MAX(", fp);
>  		printed = print_mask_int(fp, mmapprot, protm, rem);
>  		fputs(")|", fp);
> -		prot = protm;

This was probably meant to be something more like 'prot &= ~PROT_MAX(protm);'.

As it is, if there are any invalid bits set, those are now lost.  The change
to mask off only the PROT_MAX bits would preserve any invalid/unknown bits.
(To test, try passing -1 or the like as a prot value and comparing the
decoded output for kdump or truss.)

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?faef09d1-c1ee-4e2b-115e-867900153371>