Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Nov 2023 18:23:35 +0100
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        Gleb Smirnoff <glebius@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org,  dev-commits-src-main@freebsd.org
Subject:   Re: git: e1e847374bcc - main - Add DEBUG_POISON_POINTER
Message-ID:  <CAGudoHGiE9_oDzWeGcpJ%2BE8SMewrd3Hay7sLkQFy%2BwpjioA4cA@mail.gmail.com>
In-Reply-To: <ZWYhoEZSRqgvKKOF@FreeBSD.org>
References:  <202311281635.3ASGZeew027691@gitrepo.freebsd.org> <ZWYhoEZSRqgvKKOF@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/28/23, Gleb Smirnoff <glebius@freebsd.org> wrote:
>   Mateusz,
>
> On Tue, Nov 28, 2023 at 04:35:40PM +0000, Mateusz Guzik wrote:
> M>     Add DEBUG_POISON_POINTER
> M>
> M>     If you have a pointer which you know points to stale data, you can
> M>     fill it with junk so that dereference later will trap
> M>
> M>     Reviewed by:    kib
> M>     Sponsored by:   Rubicon Communications, LLC ("Netgate")
> M>     Differential Revision:  https://reviews.freebsd.org/D40946
> M> ---
> M>  sys/kern/vfs_bio.c |  6 ++++++
> M>  sys/sys/kassert.h  | 31 +++++++++++++++++++++++++++++++
> M>  2 files changed, 37 insertions(+)
> M>
> M> diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
> M> index 31059f1c0a94..4e0832475c3e 100644
> M> --- a/sys/kern/vfs_bio.c
> M> +++ b/sys/kern/vfs_bio.c
> M> @@ -159,6 +159,9 @@ nbufp(unsigned i)
> M>  }
> M>
> M>  caddr_t __read_mostly unmapped_buf;
> M> +#ifdef INVARIANTS
> M> +caddr_t	poisoned_buf = (void *)-1;
> M> +#endif
>
> Is there any good reason to use caddr_t here instead of void *?
>
> Later it is casted back to normal void* in #define DEBUG_POISON_POINTER(x).
>

unmapped_buf is caddr. if you want to roll with void * feel free to change.

-- 
Mateusz Guzik <mjguzik gmail.com>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHGiE9_oDzWeGcpJ%2BE8SMewrd3Hay7sLkQFy%2BwpjioA4cA>