Skip to content

pgaudit: guard against NULL auditEventStack in ExecutorCheckPerms_hook (avoid SIGSEGV on non-executor permission checks) #32512

Description

@HarshDaryani896

Summary
pgaudit's ExecutorCheckPerms_hook handler (log_select_dml) assumes auditEventStack is non-NULL. That stack is only established during executor startup, so when ExecCheckRTPerms() is called outside a running executor, the hook fires with auditEventStack == NULL and dereferences it → SIGSEGV in pgaudit.c.

How it's hit
An extension that performs table permission checks at plan time or from a utility command (before ExecutorStart builds the audit stack) triggers this whenever pgaudit is loaded. pg_duckdb (preview) calls ExecCheckRTPerms() from its planner and utility/COPY handling, so with pgaudit preloaded the backend crashes.

Ask
Add a NULL-auditEventStack guard in pgaudit's ExecutorCheckPerms_hook path so it safely no-ops when there is no active audit event stack.

Follow-on cleanup
Once hardened, pg_duckdb can delete its YbExecCheckRTPerms workaround (which temporarily clears ExecutorCheckPerms_hook) and call ExecCheckRTPerms() directly. Pre-GA item for pg_duckdb.


automated · Claude Code (Opus 4.8)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions