Guard against inappropriate protocol data.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Mon, 18 Mar 2024 01:33:16 +0000 (10:33 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Mon, 18 Mar 2024 04:53:26 +0000 (13:53 +0900)
commitb929717b26aa33a8175ff50b20f7b0ccd76d1109
tree70f599e9fde49efecd9b18f838ec9ebe8604732a
parent927d7aed96b23c0109a69afbf16a9313e21c0084
Guard against inappropriate protocol data.

If a simple query message arrives before a sequence of extended query
messages ends (that is, no sync message arrives or some ready for
query messages corresponding the sync message do not arrive yet),
pgpool could hang.  This is because the query context in the session
context for the simple query is overwritten by the query contexts of
the extended query messages.

This commit implements a guard in SimpleQuery() by checking whether
extended query protocol messages ended. If they do not end, raise a
FATAL error. A known example detected by this checking is JDBC
driver's "autosave=always" option. This means pgpool will not accept
the option after this commit until the issue (sending a simple
protocol message before ending extended query message protocol) is
fixed by the JDBC driver side.

Discussion:
[pgpool-hackers: 4427] Guard against ill mannered frontend
https://www.pgpool.net/pipermail/pgpool-hackers/2024-February/004428.html
src/protocol/pool_proto_modules.c
src/test/regression/tests/082.guard_against_bad_protocol/pgproto.data [new file with mode: 0644]
src/test/regression/tests/082.guard_against_bad_protocol/test.sh [new file with mode: 0755]