From: Will Hawkins <hawkinsw@obs.cr>
To: David Faust <david.faust@oracle.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] btf: Protect BTF_KIND_INFO against invalid kind
Date: Wed, 7 Aug 2024 13:19:34 -0400 [thread overview]
Message-ID: <CADx9qWiyTvq=O1pNTCCktJcy=KJVPpyJ=7nLBbJjRghJmMp-8w@mail.gmail.com> (raw)
In-Reply-To: <4836e015-5833-4284-addb-3f85e8c118c2@oracle.com>
On Mon, Jul 29, 2024 at 2:14 PM David Faust <david.faust@oracle.com> wrote:
>
>
> On 7/29/24 07:42, Will Hawkins wrote:
> > If the user provides a kind value that is more than 5 bits, the
> > BTF_KIND_INFO macro would emit incorrect values for info (by clobbering
> > values of the kind flag).
> >
> > Tested on x86_64-redhat-linux.
>
> OK, thanks.
Just let me know if there is anything else that you need from me!
Will
>
> >
> > include/ChangeLog:
> >
> > * btf.h (BTF_TYPE_INFO): Protect against user providing invalid
> > kind.
> >
> > Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
> > ---
> >
> > Notes:
> > I have a small out-of-tree test but was not sure whether a) it should
> > be included and/or b) where it should be included. If you would
> > like me to include it, please just let me know where it should go!
> >
> > include/btf.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/btf.h b/include/btf.h
> > index 3f45ffb0b6b..0c3e1a1cf51 100644
> > --- a/include/btf.h
> > +++ b/include/btf.h
> > @@ -82,7 +82,7 @@ struct btf_type
> > };
> > };
> >
> > -/* The folloing macros access the information encoded in btf_type.info. */
> > +/* The following macros access the information encoded in btf_type.info. */
> > /* Type kind. See below. */
> > #define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f)
> > /* Number of entries of variable length data following certain type kinds.
> > @@ -95,7 +95,7 @@ struct btf_type
> >
> > /* Encoding for struct btf_type.info. */
> > #define BTF_TYPE_INFO(kind, kflag, vlen) \
> > - ((((kflag) ? 1 : 0 ) << 31) | ((kind) << 24) | ((vlen) & 0xffff))
> > + ((((kflag) ? 1 : 0 ) << 31) | ((kind & 0x1f) << 24) | ((vlen) & 0xffff))
> >
> > #define BTF_KIND_UNKN 0 /* Unknown or invalid. */
> > #define BTF_KIND_INT 1 /* Integer. */
next prev parent reply other threads:[~2024-08-07 17:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 14:42 Will Hawkins
2024-07-29 18:14 ` David Faust
2024-08-07 17:19 ` Will Hawkins [this message]
2024-08-09 15:58 ` David Faust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADx9qWiyTvq=O1pNTCCktJcy=KJVPpyJ=7nLBbJjRghJmMp-8w@mail.gmail.com' \
--to=hawkinsw@obs.cr \
--cc=david.faust@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).