Re: Delimit query-cache key to prevent collisions

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: koshino(at)sraoss(dot)co(dot)jp
Cc: pgpool-hackers(at)lists(dot)postgresql(dot)org, emond(dot)papegaaij(at)gmail(dot)com
Subject: Re: Delimit query-cache key to prevent collisions
Date: 2026-08-17 06:13:53
Message-ID: 20260817.151353.1879550267380049053.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-hackers

> I have reviewed the patch(009-encode-key-delimiter) from Emond.
> It has also passed all regression tests.
>
> encode_key() constructs the cache key using md5(user || query || database) without delimiters.
> This allows different sessions to produce identical keys
> (e.g., "admin" + "Q" + "testdb" and "adm" + "Q" + "intestdb"),
> leading to data leakage between users/databases.
>
> Changes:
> Explicit Delimiters: Insert NUL bytes between the user, query, and database fields in the buffer.
> Hash Full Range: Updated the hash function to process the entire byte range (including NUL separators)
> instead of stopping at the first NUL byte.
>
> Thank you, Emond.

I have looked into this. The patch looks good to me. Also I ran some
of query cache related regression tests on master branch.

testing 006.memqcache...ok.
testing 007.memqcache-memcached...ok.
testing 008.dbredirect...ok.
testing 120.memory_leak_extended_memqcache...ok.
testing 124.bug700_memqcache_segfault...ok.

They all passed here.

Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

In response to

Responses

Browse pgpool-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-08-17 06:18:07 Re: Fix unsigned underflow in inject_cached_message
Previous Message Tatsuo Ishii 2026-07-21 12:02:26 Re: Adding volatile qualifer