From: Linus Walleij <linusw@kernel.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rosen Penev <rosenp@gmail.com>,
linux-gpio@vger.kernel.org, "Enrico Weigelt,
metux IT consult" <info@metux.net>,
Viresh Kumar <vireshk@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"open list:VIRTIO GPIO DRIVER" <virtualization@lists.linux.dev>,
open list <linux-kernel@vger.kernel.org>,
"open list:KERNEL HARDENING (not covered by other
areas):Keyword:b__counted_by(_le|_be)?b"
<linux-hardening@vger.kernel.org>
Subject: Re: [PATCHv3] gpio: virtio: remove one kcalloc
Date: Tue, 17 Mar 2026 10:45:19 +0100 [thread overview]
Message-ID: <CAD++jLkKqF4ooL7zC0dyT+k7o1MC7AyY-Xat5xSTzSZ6KdLHfw@mail.gmail.com> (raw)
In-Reply-To: <bh5rgccasvor5xjunkc7wjp3resyulehnqafhzlfwqx2ealwxw@eqohebwzjq2a>
On Tue, Mar 17, 2026 at 9:49 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 16-03-26, 15:00, Linus Walleij wrote:
> > On Fri, Mar 13, 2026 at 7:09 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> >
> > > I wonder if it is worth it anymore. Why combining allocations is better when we
> > > are ending up using more memory ?
> >
> > For the same reason we are starting to use Rust in the kernel, despite
> > it sometimes will take more memory essentially. __counted_by() enforce
> > the same type of runtime size checks as Rust do on arrays.
>
> Right. I don't have any issue with __counted_by(). It does the right thing for
> flexible length arrays. But we don't need a flexible length array here and so my
> question.
So why check for something that "can't go wrong".
IIUC it still removes undefined behaviour from the object code.
If someone managed to compromise the kernel using return-oriented programming
they cannot call back into this function to overwrite the memory
beyond where the
array is stored, because the runtime checks will block this.
But Kees & Gustavo can tell if I understand this correctly.
Yours,
Linus Walleij
next prev parent reply other threads:[~2026-03-17 9:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 19:37 [PATCHv3] gpio: virtio: remove one kcalloc Rosen Penev
2026-03-13 6:09 ` Viresh Kumar
2026-03-13 6:29 ` Rosen Penev
2026-03-16 14:08 ` Linus Walleij
2026-03-16 14:00 ` Linus Walleij
2026-03-17 8:48 ` Viresh Kumar
2026-03-17 9:45 ` Linus Walleij [this message]
2026-03-16 13:59 ` Linus Walleij
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=CAD++jLkKqF4ooL7zC0dyT+k7o1MC7AyY-Xat5xSTzSZ6KdLHfw@mail.gmail.com \
--to=linusw@kernel.org \
--cc=brgl@kernel.org \
--cc=gustavoars@kernel.org \
--cc=info@metux.net \
--cc=kees@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rosenp@gmail.com \
--cc=viresh.kumar@linaro.org \
--cc=vireshk@kernel.org \
--cc=virtualization@lists.linux.dev \
/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