mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "GONG, Ruiqi" <gongruiqi@huaweicloud.com>
To: Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	Florian Westphal <fw@strlen.de>, Roopa Prabhu <roopa@nvidia.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Kees Cook <keescook@chromium.org>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, linux-hardening@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Wang Weiyang <wangweiyang2@huawei.com>,
	Xiu Jianfeng <xiujianfeng@huawei.com>,
	gongruiqi1@huawei.com
Subject: Re: [PATCH v2] netfilter: ebtables: fix fortify warnings
Date: Wed, 9 Aug 2023 15:00:01 +0800	[thread overview]
Message-ID: <dc5efa8d-ce1b-2dc0-1e4b-bfc9993206bf@huaweicloud.com> (raw)
In-Reply-To: <5E8E0F9C-EE3F-4B0D-B827-DC47397E2A4A@kernel.org>


On 2023/08/09 6:53, Kees Cook wrote:
> 
> [...]
>>>
>>> diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h
>>> index a494cf43a755..b0caad82b693 100644
>>> --- a/include/uapi/linux/netfilter_bridge/ebtables.h
>>> +++ b/include/uapi/linux/netfilter_bridge/ebtables.h
>>> @@ -182,12 +182,14 @@ struct ebt_entry {
>>>  	unsigned char sourcemsk[ETH_ALEN];
>>>  	unsigned char destmac[ETH_ALEN];
>>>  	unsigned char destmsk[ETH_ALEN];
>>> -	/* sizeof ebt_entry + matches */
>>> -	unsigned int watchers_offset;
>>> -	/* sizeof ebt_entry + matches + watchers */
>>> -	unsigned int target_offset;
>>> -	/* sizeof ebt_entry + matches + watchers + target */
>>> -	unsigned int next_offset;
>>> +	__struct_group(/* no tag */, offsets, /* no attrs */,
>>> +		/* sizeof ebt_entry + matches */
>>> +		unsigned int watchers_offset;
>>> +		/* sizeof ebt_entry + matches + watchers */
>>> +		unsigned int target_offset;
>>> +		/* sizeof ebt_entry + matches + watchers + target */
>>> +		unsigned int next_offset;
>>> +	);
>>>  	unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
> 
> While we're here, can we drop this [0] in favor of []?
> 
> -Kees
> 

Look like it could be done. Will do in v3. Thanks!

>>>  };
>>>  
>>> diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
>>> index 757ec46fc45a..5ec66b1ebb64 100644
>>> --- a/net/bridge/netfilter/ebtables.c
>>> +++ b/net/bridge/netfilter/ebtables.c
>>> @@ -2115,8 +2115,7 @@ static int size_entry_mwt(const struct ebt_entry *entry, const unsigned char *ba
>>>  		return ret;
>>>  
>>>  	offsets[0] = sizeof(struct ebt_entry); /* matches come first */
>>> -	memcpy(&offsets[1], &entry->watchers_offset,
>>> -			sizeof(offsets) - sizeof(offsets[0]));
>>> +	memcpy(&offsets[1], &entry->offsets, sizeof(offsets) - sizeof(offsets[0]));
>> 							^^^^^^^^^^^^
>> You now can replace this ____________________________________|
>> with just `sizeof(entry->offsets)`
>>
>> With that change you can add my
>> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>>
>> Thank you
>> --
>> Gustavo
>>
>>>  
>>>  	if (state->buf_kern_start) {
>>>  		buf_start = state->buf_kern_start + state->buf_kern_offset;
>>> -- 
>>> 2.41.0
>>>
> 
> 


  reply	other threads:[~2023-08-09  7:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08 13:30 GONG, Ruiqi
2023-08-08 16:32 ` Gustavo A. R. Silva
2023-08-08 22:53   ` Kees Cook
2023-08-09  7:00     ` GONG, Ruiqi [this message]
2023-08-09  7:31     ` GONG, Ruiqi
2023-08-08 23:00   ` Kees Cook
2023-08-09  3:25   ` GONG, Ruiqi

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=dc5efa8d-ce1b-2dc0-1e4b-bfc9993206bf@huaweicloud.com \
    --to=gongruiqi@huaweicloud.com \
    --cc=coreteam@netfilter.org \
    --cc=fw@strlen.de \
    --cc=gongruiqi1@huawei.com \
    --cc=gustavoars@kernel.org \
    --cc=kadlec@netfilter.org \
    --cc=kees@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=razor@blackwall.org \
    --cc=roopa@nvidia.com \
    --cc=wangweiyang2@huawei.com \
    --cc=xiujianfeng@huawei.com \
    /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

all inboxes | Powered by JetHome®