| From: | Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp> |
|---|---|
| To: | "pgpool-hackers(at)lists(dot)postgresql(dot)org" <pgpool-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Emond Papegaaij <emond(dot)papegaaij(at)gmail(dot)com> |
| Subject: | Fix unsigned underflow in inject_cached_message |
| Date: | 2026-07-21 05:59:11 |
| Message-ID: | TY4PR01MB17374089B6E89C4B9F44817B094C22@TY4PR01MB17374.jpnprd01.prod.outlook.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgpool-hackers |
I have reviewed the patch(011-inject-cached-message-underflow) from Emond.
It has also passed all regression tests.
This patch modifies the packet length validation in inject_cached_message to prevent
a session crash caused by an unsigned integer underflow.
Previously, the logic determined whether to process a query cache message by checking
if the packet length minus its header size was greater than zero(if ((ntohl(len) - sizeof(len)) > 0)).
However, this evaluation method introduced a critical vulnerability under unsigned arithmetic rules.
When a corrupt packet with a payload length shorter than the header size is processed,
the subtraction underflows into a massive positive integer,
bypassing the guard and forcing a fatal memory allocation failure that terminates the session.
In our local test environment, injecting a short packet successfully reproduced this exact behavior,
causing a memory context allocation crash.
The updated logic changes the condition to a direct comparison
before subtraction(if (ntohl(len) > (uint32) sizeof(len))),
ensuring that invalid short packets are securely blocked and the session remains stable,
which proves the fix is highly valid.
Thank you Emond.
Taiki Koshino<koshino(at)sraoss(dot)co(dot)jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-unsigned-underflow-in-inject_cached_message.patch | application/octet-stream | 2.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Koshino Taiki | 2026-07-21 06:01:46 | Convert close_idle_connection (SIGUSR1) to flag-only handler with main-loop processing. |
| Previous Message | Koshino Taiki | 2026-07-21 05:55:47 | Delimit query-cache key to prevent collisions |