linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: patchwork-bot+netdevbpf@kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: davem@davemloft.net, kuba@kernel.org, yoshfuji@linux-ipv6.org,
	dsahern@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] net/ipv4: Replace one-element array with flexible-array member
Date: Mon, 2 Aug 2021 14:15:40 -0500	[thread overview]
Message-ID: <4a9987c1-1f7a-35af-af6a-01b96292d2ee@embeddedor.com> (raw)
In-Reply-To: <6d3c2ba1-ea01-dbc1-1e18-1ba9c7a15181@embeddedor.com>



On 8/2/21 13:46, Gustavo A. R. Silva wrote:
> 
> 
> On 8/2/21 09:20, patchwork-bot+netdevbpf@kernel.org wrote:
>> Hello:
>>
>> This patch was applied to netdev/net-next.git (refs/heads/master):
>>
>> On Sat, 31 Jul 2021 12:08:30 -0500 you wrote:
>>> There is a regular need in the kernel to provide a way to declare having
>>> a dynamically sized set of trailing elements in a structure. Kernel code
>>> should always use “flexible array members”[1] for these cases. The older
>>> style of one-element or zero-length arrays should no longer be used[2].
>>>
>>> Use an anonymous union with a couple of anonymous structs in order to
>>> keep userspace unchanged:
>>>
>>> [...]
>>
>> Here is the summary with links:
>>   - [next] net/ipv4: Replace one-element array with flexible-array member
>>     https://git.kernel.org/netdev/net-next/c/2d3e5caf96b9
> 
> arghh... this has a bug. Sorry, Dave. I will send a fix for this, shortly.
> 

BTW... can we expect msf->imsf_numsrc to be zero at some point in the following
pieces of code?

net/ipv4/igmp.c:
2553         copycount = count < msf->imsf_numsrc ? count : msf->imsf_numsrc;
2554         len = copycount * sizeof(psl->sl_addr[0]);
2555         msf->imsf_numsrc = count;
2556         if (put_user(IP_MSFILTER_SIZE(copycount), optlen) ||
2557             copy_to_user(optval, msf, IP_MSFILTER_SIZE(0))) {
2558                 return -EFAULT;
2559         }

net/ipv4/ip_sockglue.c:
1228         case IP_MSFILTER:
1229         {
1230                 struct ip_msfilter *msf;
1231
1232                 if (optlen < IP_MSFILTER_SIZE(0))
1233                         goto e_inval;
1234                 if (optlen > sysctl_optmem_max) {
1235                         err = -ENOBUFS;
1236                         break;
1237                 }
1238                 msf = memdup_sockptr(optval, optlen);
1239                 if (IS_ERR(msf)) {

			...

1250                 if (IP_MSFILTER_SIZE(msf->imsf_numsrc) > optlen) {
1251                         kfree(msf);
1252                         err = -EINVAL;
1253                         break;
1254                 }
1255                 err = ip_mc_msfilter(sk, msf, 0);
1256                 kfree(msf);
1257                 break;
1258         }

Thanks
--
Gustavo

      reply	other threads:[~2021-08-02 19:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31 17:08 [PATCH][next] net/ipv4: Replace one-element array with flexible-array member Gustavo A. R. Silva
     [not found] ` <162791400741.18419.5941105433257893840.git-patchwork-notify@kernel.org>
2021-08-02 18:46   ` Gustavo A. R. Silva
2021-08-02 19:15     ` Gustavo A. R. Silva [this message]

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=4a9987c1-1f7a-35af-af6a-01b96292d2ee@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=patchwork-bot+netdevbpf@kernel.org \
    --cc=yoshfuji@linux-ipv6.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 NNTP newsgroup(s).