diff mbox series

[v5,3/7] net/eth: Make ip6_ext_hdr *ext_hdr pointer to const

Message ID 20210310160135.1148272-4-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series net/eth: Fix stack-buffer-overflow in _eth_get_rss_ex_dst_addr() | expand

Commit Message

Philippe Mathieu-Daudé March 10, 2021, 4:01 p.m. UTC
As the callee doesn't need to modify the ext_hdr buffer,
mark it const.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 net/eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Garzarella March 10, 2021, 4:46 p.m. UTC | #1
On Wed, Mar 10, 2021 at 05:01:31PM +0100, Philippe Mathieu-Daudé wrote:
>As the callee doesn't need to modify the ext_hdr buffer,
>mark it const.
>
>Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>---
> net/eth.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/net/eth.c b/net/eth.c
>index 6a5a1d04e0b..7c47a267a7a 100644
>--- a/net/eth.c
>+++ b/net/eth.c
>@@ -402,7 +402,7 @@ eth_is_ip6_extension_header_type(uint8_t hdr_type)
> static bool
> _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
>                         size_t ext_hdr_offset,
>-                        struct ip6_ext_hdr *ext_hdr,
>+                        const struct ip6_ext_hdr *ext_hdr,
>                         struct in6_address *dst_addr)
> {
>     struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *) ext_hdr;
>-- 
>2.26.2
>

This patch is fine, but after the last patch of this series, 'ext_hdr' 
is not used anymore, so what about removing this parameter?

Thanks,
Stefano
Philippe Mathieu-Daudé March 10, 2021, 5:25 p.m. UTC | #2
On 3/10/21 5:46 PM, Stefano Garzarella wrote:
> On Wed, Mar 10, 2021 at 05:01:31PM +0100, Philippe Mathieu-Daudé wrote:
>> As the callee doesn't need to modify the ext_hdr buffer,
>> mark it const.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> net/eth.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/eth.c b/net/eth.c
>> index 6a5a1d04e0b..7c47a267a7a 100644
>> --- a/net/eth.c
>> +++ b/net/eth.c
>> @@ -402,7 +402,7 @@ eth_is_ip6_extension_header_type(uint8_t hdr_type)
>> static bool
>> _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
>>                         size_t ext_hdr_offset,
>> -                        struct ip6_ext_hdr *ext_hdr,
>> +                        const struct ip6_ext_hdr *ext_hdr,
>>                         struct in6_address *dst_addr)
>> {
>>     struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *)
>> ext_hdr;
>> -- 
>> 2.26.2
>>
> 
> This patch is fine, but after the last patch of this series, 'ext_hdr'
> is not used anymore, so what about removing this parameter?

Clever :)
diff mbox series

Patch

diff --git a/net/eth.c b/net/eth.c
index 6a5a1d04e0b..7c47a267a7a 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -402,7 +402,7 @@  eth_is_ip6_extension_header_type(uint8_t hdr_type)
 static bool
 _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
                         size_t ext_hdr_offset,
-                        struct ip6_ext_hdr *ext_hdr,
+                        const struct ip6_ext_hdr *ext_hdr,
                         struct in6_address *dst_addr)
 {
     struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *) ext_hdr;