Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: herbert@gondor.apana.org.au
Cc: tgraf@suug.ch, linux-crypto@vger.kernel.org,
	Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] rhashtable: Fix safe iterator cursor substitution
Date: Sat, 21 Nov 2026 09:24:55 +0200	[thread overview]
Message-ID: <20261121072454.27804-2-thnkslprpt@gmail.com> (raw)

rht_for_each_entry_safe() uses next as both a macro parameter and the
rhash_head member name. Passing a cursor with another name substitutes
that name into pos->next, producing a nonexistent struct member and a
compilation failure.

Rename the cursor parameter to _next to preserve the pos->next member
accesses regardless of the caller's variable name.

Fixes: 88d6ed15acff ("rhashtable: Convert bucket iterators to take table and index")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---

Alternative approaches considered:
- Use a differently named cursor parameter such as next_node. This is
  equivalent in behavior; _next keeps the change smaller.
- Remove the unused macro. That avoids the broken expansion but also
  removes an existing interface potentially used outside the tree.

Validation:
- Original macro: next compiles; saved, tmp and next_entry fail.
- Corrected macro: all four names compile in the isolated source probe.
- The original next expansion is byte-identical after the correction.
- No in-tree expanding consumer was found in the tested base revision.
- Full kernel Kbuild, runtime and external consumers were not tested.

 include/linux/rhashtable.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 70dac9214617..00838bf88117 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -482,7 +482,7 @@ static inline void rht_assign_unlock(struct bucket_table *tbl,
  * rht_for_each_entry_safe - safely iterate over hash chain of given type
  * @tpos:	the type * to use as a loop cursor.
  * @pos:	the &struct rhash_head to use as a loop cursor.
- * @next:	the &struct rhash_head to use as next in loop cursor.
+ * @_next:	the &struct rhash_head to use as next in loop cursor.
  * @tbl:	the &struct bucket_table
  * @hash:	the hash value / bucket index
  * @member:	name of the &struct rhash_head within the hashable struct.
@@ -490,13 +490,13 @@ static inline void rht_assign_unlock(struct bucket_table *tbl,
  * This hash chain list-traversal primitive allows for the looped code to
  * remove the loop cursor from the list.
  */
-#define rht_for_each_entry_safe(tpos, pos, next, tbl, hash, member)	      \
+#define rht_for_each_entry_safe(tpos, pos, _next, tbl, hash, member)	      \
 	for (pos = rht_ptr(rht_bucket(tbl, hash), tbl, hash),		      \
-	     next = !rht_is_a_nulls(pos) ?				      \
+	     _next = !rht_is_a_nulls(pos) ?				      \
 		       rht_dereference_bucket(pos->next, tbl, hash) : NULL;   \
 	     (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member);	      \
-	     pos = next,						      \
-	     next = !rht_is_a_nulls(pos) ?				      \
+	     pos = _next,						      \
+	     _next = !rht_is_a_nulls(pos) ?				      \
 		       rht_dereference_bucket(pos->next, tbl, hash) : NULL)
 
 /**

base-commit: 65e4fd942f72a9dba0e4e257290c4fa1aa756854
-- 
2.43.0


                 reply	other threads:[~2026-11-21  7:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261121072454.27804-2-thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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