From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Thorsten Blum <thorsten.blum@toblux.com>,
paulmck@kernel.org, frederic@kernel.org,
neeraj.upadhyay@kernel.org, joel@joelfernandes.org,
josh@joshtriplett.org, boqun.feng@gmail.com, urezki@gmail.com,
rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
jiangshanlai@gmail.com, qiang.zhang1211@gmail.com,
kees@kernel.org, gustavoars@kernel.org
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] rcu: Annotate struct kvfree_rcu_bulk_data with __counted_by()
Date: Wed, 7 Aug 2024 09:29:09 -0600 [thread overview]
Message-ID: <bcb88692-a384-4da8-b2b9-a116ecb17530@embeddedor.com> (raw)
In-Reply-To: <20240807095459.1400-2-thorsten.blum@toblux.com>
On 07/08/24 03:55, Thorsten Blum wrote:
> Add the __counted_by compiler attribute to the flexible array member
> records to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
>
> Increment nr_records before adding a new pointer to the records array.
>
Looks good.
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks
--
Gustavo
> ---
> kernel/rcu/tree.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index e641cc681901..76d8d75dd8b3 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -3227,7 +3227,7 @@ struct kvfree_rcu_bulk_data {
> struct list_head list;
> struct rcu_gp_oldstate gp_snap;
> unsigned long nr_records;
> - void *records[];
> + void *records[] __counted_by(nr_records);
> };
>
> /*
> @@ -3767,7 +3767,8 @@ add_ptr_to_bulk_krc_lock(struct kfree_rcu_cpu **krcp,
> }
>
> // Finally insert and update the GP for this page.
> - bnode->records[bnode->nr_records++] = ptr;
> + bnode->nr_records++;
> + bnode->records[bnode->nr_records - 1] = ptr;
> get_state_synchronize_rcu_full(&bnode->gp_snap);
> atomic_inc(&(*krcp)->bulk_count[idx]);
>
next prev parent reply other threads:[~2024-08-07 15:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 9:55 Thorsten Blum
2024-08-07 15:29 ` Gustavo A. R. Silva [this message]
2024-08-07 15:35 ` Uladzislau Rezki
2024-08-08 18:02 ` Paul E. McKenney
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=bcb88692-a384-4da8-b2b9-a116ecb17530@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=gustavoars@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang1211@gmail.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=thorsten.blum@toblux.com \
--cc=urezki@gmail.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®