* [PATCH] btf: Protect BTF_KIND_INFO against invalid kind
@ 2024-07-29 14:42 Will Hawkins
2024-07-29 18:14 ` David Faust
0 siblings, 1 reply; 4+ messages in thread
From: Will Hawkins @ 2024-07-29 14:42 UTC (permalink / raw)
To: gcc-patches; +Cc: Will Hawkins
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.
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. */
--
2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btf: Protect BTF_KIND_INFO against invalid kind
2024-07-29 14:42 [PATCH] btf: Protect BTF_KIND_INFO against invalid kind Will Hawkins
@ 2024-07-29 18:14 ` David Faust
2024-08-07 17:19 ` Will Hawkins
0 siblings, 1 reply; 4+ messages in thread
From: David Faust @ 2024-07-29 18:14 UTC (permalink / raw)
To: Will Hawkins; +Cc: gcc-patches
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.
>
> 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. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btf: Protect BTF_KIND_INFO against invalid kind
2024-07-29 18:14 ` David Faust
@ 2024-08-07 17:19 ` Will Hawkins
2024-08-09 15:58 ` David Faust
0 siblings, 1 reply; 4+ messages in thread
From: Will Hawkins @ 2024-08-07 17:19 UTC (permalink / raw)
To: David Faust; +Cc: gcc-patches
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. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btf: Protect BTF_KIND_INFO against invalid kind
2024-08-07 17:19 ` Will Hawkins
@ 2024-08-09 15:58 ` David Faust
0 siblings, 0 replies; 4+ messages in thread
From: David Faust @ 2024-08-09 15:58 UTC (permalink / raw)
To: Will Hawkins; +Cc: gcc-patches
On 8/7/24 10:19, Will Hawkins wrote:
> 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
I just checked this in on your behalf. Apologies for the delay.
Thanks!
>
>>
>>>
>>> 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. */
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-09 15:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-29 14:42 [PATCH] btf: Protect BTF_KIND_INFO against invalid kind Will Hawkins
2024-07-29 18:14 ` David Faust
2024-08-07 17:19 ` Will Hawkins
2024-08-09 15:58 ` David Faust
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).