agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH v22 1/3] vacuum errcontext to show block being processed 263+ messages / 2 participants [nested] [flat]
* [PATCH v22 1/3] vacuum errcontext to show block being processed @ 2019-12-13 02:54 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Justin Pryzby @ 2019-12-13 02:54 UTC (permalink / raw) Discussion: https://www.postgresql.org/message-id/[email protected] --- src/backend/access/heap/vacuumlazy.c | 162 +++++++++++++++++++++++++++++++---- 1 file changed, 144 insertions(+), 18 deletions(-) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 03c43ef..d34d0c5 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -270,6 +270,8 @@ typedef struct LVParallelState typedef struct LVRelStats { + char *relnamespace; + char *relname; /* useindex = true means two-pass strategy; false means one-pass */ bool useindex; /* Overall statistics about rel */ @@ -290,8 +292,12 @@ typedef struct LVRelStats int num_index_scans; TransactionId latestRemovedXid; bool lock_waiter_detected; -} LVRelStats; + /* Used for error callback: */ + char *indname; + BlockNumber blkno; /* used only for heap operations */ + int phase; /* Reusing same constants as for progress reporting */ +} LVRelStats; /* A few variables that don't seem worth passing around as parameters */ static int elevel = -1; @@ -314,10 +320,10 @@ static void lazy_vacuum_all_indexes(Relation onerel, Relation *Irel, LVRelStats *vacrelstats, LVParallelState *lps, int nindexes); static void lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats, - LVDeadTuples *dead_tuples, double reltuples); + LVDeadTuples *dead_tuples, double reltuples, LVRelStats *vacrelstats); static void lazy_cleanup_index(Relation indrel, IndexBulkDeleteResult **stats, - double reltuples, bool estimated_count); + double reltuples, bool estimated_count, LVRelStats *vacrelstats); static int lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer, int tupindex, LVRelStats *vacrelstats, Buffer *vmbuffer); static bool should_attempt_truncation(VacuumParams *params, @@ -361,6 +367,9 @@ static void end_parallel_vacuum(Relation *Irel, IndexBulkDeleteResult **stats, LVParallelState *lps, int nindexes); static LVSharedIndStats *get_indstats(LVShared *lvshared, int n); static bool skip_parallel_vacuum_index(Relation indrel, LVShared *lvshared); +static void vacuum_error_callback(void *arg); +static void update_vacuum_error_cbarg(LVRelStats *errcbarg, int phase, + BlockNumber blkno, Relation rel); /* @@ -460,6 +469,9 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, vacrelstats = (LVRelStats *) palloc0(sizeof(LVRelStats)); + vacrelstats->relnamespace = get_namespace_name(RelationGetNamespace(onerel)); + vacrelstats->relname = pstrdup(RelationGetRelationName(onerel)); + vacrelstats->indname = NULL; vacrelstats->old_rel_pages = onerel->rd_rel->relpages; vacrelstats->old_live_tuples = onerel->rd_rel->reltuples; vacrelstats->num_index_scans = 0; @@ -699,7 +711,6 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, BlockNumber nblocks, blkno; HeapTupleData tuple; - char *relname; TransactionId relfrozenxid = onerel->rd_rel->relfrozenxid; TransactionId relminmxid = onerel->rd_rel->relminmxid; BlockNumber empty_pages, @@ -724,20 +735,20 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, PROGRESS_VACUUM_MAX_DEAD_TUPLES }; int64 initprog_val[3]; + ErrorContextCallback errcallback; pg_rusage_init(&ru0); - relname = RelationGetRelationName(onerel); if (aggressive) ereport(elevel, (errmsg("aggressively vacuuming \"%s.%s\"", - get_namespace_name(RelationGetNamespace(onerel)), - relname))); + vacrelstats->relnamespace, + vacrelstats->relname))); else ereport(elevel, (errmsg("vacuuming \"%s.%s\"", - get_namespace_name(RelationGetNamespace(onerel)), - relname))); + vacrelstats->relnamespace, + vacrelstats->relname))); empty_pages = vacuumed_pages = 0; next_fsm_block_to_vacuum = (BlockNumber) 0; @@ -870,6 +881,14 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, else skipping_blocks = false; + /* Setup error traceback support for ereport() */ + update_vacuum_error_cbarg(vacrelstats, PROGRESS_VACUUM_PHASE_SCAN_HEAP, + InvalidBlockNumber, NULL); + errcallback.callback = vacuum_error_callback; + errcallback.arg = vacrelstats; + errcallback.previous = error_context_stack; + error_context_stack = &errcallback; + for (blkno = 0; blkno < nblocks; blkno++) { Buffer buf; @@ -891,6 +910,8 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, #define FORCE_CHECK_PAGE() \ (blkno == nblocks - 1 && should_attempt_truncation(params, vacrelstats)) + vacrelstats->blkno = blkno; + pgstat_progress_update_param(PROGRESS_VACUUM_HEAP_BLKS_SCANNED, blkno); if (blkno == next_unskippable_block) @@ -1011,6 +1032,10 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, /* Report that we are once again scanning the heap */ pgstat_progress_update_param(PROGRESS_VACUUM_PHASE, PROGRESS_VACUUM_PHASE_SCAN_HEAP); + + /* Set the error context while continuing heap scan */ + update_vacuum_error_cbarg(vacrelstats, + PROGRESS_VACUUM_PHASE_SCAN_HEAP, blkno, NULL); } /* @@ -1534,7 +1559,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, && VM_ALL_VISIBLE(onerel, blkno, &vmbuffer)) { elog(WARNING, "page is not marked all-visible but visibility map bit is set in relation \"%s\" page %u", - relname, blkno); + vacrelstats->relname, blkno); visibilitymap_clear(onerel, blkno, vmbuffer, VISIBILITYMAP_VALID_BITS); } @@ -1555,7 +1580,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, else if (PageIsAllVisible(page) && has_dead_tuples) { elog(WARNING, "page containing dead tuples is marked as all-visible in relation \"%s\" page %u", - relname, blkno); + vacrelstats->relname, blkno); PageClearAllVisible(page); MarkBufferDirty(buf); visibilitymap_clear(onerel, blkno, vmbuffer, @@ -1651,6 +1676,9 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, if (vacrelstats->useindex) lazy_cleanup_all_indexes(Irel, indstats, vacrelstats, lps, nindexes); + /* Pop the error context stack */ + error_context_stack = errcallback.previous; + /* * End parallel mode before updating index statistics as we cannot write * during parallel mode. @@ -1744,7 +1772,7 @@ lazy_vacuum_all_indexes(Relation onerel, Relation *Irel, for (idx = 0; idx < nindexes; idx++) lazy_vacuum_index(Irel[idx], &stats[idx], vacrelstats->dead_tuples, - vacrelstats->old_live_tuples); + vacrelstats->old_live_tuples, vacrelstats); } /* Increase and report the number of index scans */ @@ -1778,8 +1806,13 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats) PROGRESS_VACUUM_PHASE_VACUUM_HEAP); pg_rusage_init(&ru0); - npages = 0; + /* Setup error traceback support for ereport() */ + update_vacuum_error_cbarg(vacrelstats, + PROGRESS_VACUUM_PHASE_VACUUM_HEAP, InvalidBlockNumber, + NULL); + + npages = 0; tupindex = 0; while (tupindex < vacrelstats->dead_tuples->num_tuples) { @@ -1791,6 +1824,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats) vacuum_delay_point(); tblk = ItemPointerGetBlockNumber(&vacrelstats->dead_tuples->itemptrs[tupindex]); + vacrelstats->blkno = tblk; buf = ReadBufferExtended(onerel, MAIN_FORKNUM, tblk, RBM_NORMAL, vac_strategy); if (!ConditionalLockBufferForCleanup(buf)) @@ -2203,6 +2237,26 @@ vacuum_one_index(Relation indrel, IndexBulkDeleteResult **stats, LVDeadTuples *dead_tuples) { IndexBulkDeleteResult *bulkdelete_res = NULL; + /* Init vacrelstats for error callback by parallel workers: */ + LVRelStats vacrelstats = + { + .relnamespace = get_namespace_name(RelationGetNamespace(indrel)), + .relname = pstrdup(get_rel_name(indrel->rd_index->indrelid)), + .indname = pstrdup(RelationGetRelationName(indrel)), + }; + + /* Setup error traceback support for ereport() */ + ErrorContextCallback errcallback; + update_vacuum_error_cbarg(&vacrelstats, + lvshared->for_cleanup ? + PROGRESS_VACUUM_PHASE_INDEX_CLEANUP : + PROGRESS_VACUUM_PHASE_VACUUM_INDEX, + InvalidBlockNumber, NULL); + + errcallback.callback = vacuum_error_callback; + errcallback.arg = &vacrelstats; + errcallback.previous = error_context_stack; + error_context_stack = &errcallback; if (shared_indstats) { @@ -2220,10 +2274,13 @@ vacuum_one_index(Relation indrel, IndexBulkDeleteResult **stats, /* Do vacuum or cleanup of the index */ if (lvshared->for_cleanup) lazy_cleanup_index(indrel, stats, lvshared->reltuples, - lvshared->estimated_count); + lvshared->estimated_count, &vacrelstats); else lazy_vacuum_index(indrel, stats, dead_tuples, - lvshared->reltuples); + lvshared->reltuples, &vacrelstats); + + /* Pop the error context stack */ + error_context_stack = errcallback.previous; /* * Copy the index bulk-deletion result returned from ambulkdelete and @@ -2298,7 +2355,8 @@ lazy_cleanup_all_indexes(Relation *Irel, IndexBulkDeleteResult **stats, for (idx = 0; idx < nindexes; idx++) lazy_cleanup_index(Irel[idx], &stats[idx], vacrelstats->new_rel_tuples, - vacrelstats->tupcount_pages < vacrelstats->rel_pages); + vacrelstats->tupcount_pages < vacrelstats->rel_pages, + vacrelstats); } } @@ -2313,7 +2371,7 @@ lazy_cleanup_all_indexes(Relation *Irel, IndexBulkDeleteResult **stats, */ static void lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats, - LVDeadTuples *dead_tuples, double reltuples) + LVDeadTuples *dead_tuples, double reltuples, LVRelStats *vacrelstats) { IndexVacuumInfo ivinfo; const char *msg; @@ -2329,6 +2387,11 @@ lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats, ivinfo.num_heap_tuples = reltuples; ivinfo.strategy = vac_strategy; + /* Setup error traceback support for ereport() */ + update_vacuum_error_cbarg(vacrelstats, + PROGRESS_VACUUM_PHASE_VACUUM_INDEX, InvalidBlockNumber, + indrel); + /* Do bulk deletion */ *stats = index_bulk_delete(&ivinfo, *stats, lazy_tid_reaped, (void *) dead_tuples); @@ -2354,7 +2417,7 @@ lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats, static void lazy_cleanup_index(Relation indrel, IndexBulkDeleteResult **stats, - double reltuples, bool estimated_count) + double reltuples, bool estimated_count, LVRelStats *vacrelstats) { IndexVacuumInfo ivinfo; const char *msg; @@ -2371,6 +2434,10 @@ lazy_cleanup_index(Relation indrel, ivinfo.num_heap_tuples = reltuples; ivinfo.strategy = vac_strategy; + /* Setup error traceback support for ereport() */ + update_vacuum_error_cbarg(vacrelstats, + PROGRESS_VACUUM_PHASE_INDEX_CLEANUP, InvalidBlockNumber, indrel); + *stats = index_vacuum_cleanup(&ivinfo, *stats); if (!(*stats)) @@ -3376,3 +3443,62 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc) table_close(onerel, ShareUpdateExclusiveLock); pfree(stats); } + +/* + * Error context callback for errors occurring during vacuum. + */ +static void +vacuum_error_callback(void *arg) +{ + LVRelStats *cbarg = arg; + + switch (cbarg->phase) { + case PROGRESS_VACUUM_PHASE_SCAN_HEAP: + if (BlockNumberIsValid(cbarg->blkno)) + errcontext("while scanning block %u of relation \"%s.%s\"", + cbarg->blkno, cbarg->relnamespace, cbarg->relname); + break; + + case PROGRESS_VACUUM_PHASE_VACUUM_HEAP: + if (BlockNumberIsValid(cbarg->blkno)) + errcontext("while vacuuming block %u of relation \"%s.%s\"", + cbarg->blkno, cbarg->relnamespace, cbarg->relname); + break; + + case PROGRESS_VACUUM_PHASE_VACUUM_INDEX: + errcontext("while vacuuming index \"%s\" of relation \"%s.%s\"", + cbarg->indname, cbarg->relnamespace, cbarg->relname); + break; + + case PROGRESS_VACUUM_PHASE_INDEX_CLEANUP: + errcontext("while cleaning up index \"%s\" of relation \"%s.%s\"", + cbarg->indname, cbarg->relnamespace, cbarg->relname); + break; + + case PROGRESS_VACUUM_PHASE_TRUNCATE: + case PROGRESS_VACUUM_PHASE_FINAL_CLEANUP: + default: + return; /* Shouldn't happen: do nothing */ + } +} + +/* Update vacuum error callback for current phase, block and index */ +static void +update_vacuum_error_cbarg(LVRelStats *errcbarg, int phase, BlockNumber blkno, + Relation indrel) +{ + errcbarg->blkno = blkno; + errcbarg->phase = phase; + + /* Free index name from any previous phase */ + if (errcbarg->indname) { + pfree(errcbarg->indname); + errcbarg->indname = NULL; + } + + /* For index phases, save the name of the current index for the callback */ + if (indrel) { + Assert(indrel->rd_rel->relkind == RELKIND_INDEX); + errcbarg->indname = pstrdup(RelationGetRelationName(indrel)); + } +} -- 2.7.4 --Q68bSM7Ycu6FN28Q Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v22-0002-add-callback-for-truncation.patch" ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v1] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --Dqk2D9QbcLZswiIf-- ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v1] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --Dqk2D9QbcLZswiIf-- ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
* [PATCH v6 1/2] Clear padding in PgStat_HashKey keys @ 2024-11-02 14:21 Bertrand Drouvot <[email protected]> 0 siblings, 0 replies; 263+ messages in thread From: Bertrand Drouvot @ 2024-11-02 14:21 UTC (permalink / raw) PgStat_HashKey keys are currently initialized in a way that could result in random data in the padding bytes (if there was padding in PgStat_HashKey which is not the case currently). We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as input. So, we have to ensure that no random data can be stored in the padding bytes (if any) of a PgStat_HashKey key. --- src/backend/utils/activity/pgstat.c | 3 +++ src/backend/utils/activity/pgstat_shmem.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index be48432cc3..ea8c5691e8 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -938,6 +938,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid) pgstat_prep_snapshot(); + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + key.kind = kind; key.dboid = dboid; key.objid = objid; diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index a09c6fee05..c1b7ff76b1 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -432,11 +432,18 @@ PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shhashent; PgStatShared_Common *shheader = NULL; PgStat_EntryRef *entry_ref; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* * passing in created_entry only makes sense if we possibly could create * entry. @@ -908,10 +915,17 @@ pgstat_drop_database_and_contents(Oid dboid) bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid) { - PgStat_HashKey key = {.kind = kind,.dboid = dboid,.objid = objid}; + PgStat_HashKey key; PgStatShared_HashEntry *shent; bool freed = true; + /* clear padding */ + memset(&key, 0, sizeof(struct PgStat_HashKey)); + + key.kind = kind; + key.dboid = dboid; + key.objid = objid; + /* delete local reference */ if (pgStatEntryRefHash) { -- 2.34.1 --gvmrl0mfoTEJEfPE Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v6-0002-Provide-relfilenode-statistics.patch" Content-Transfer-Encoding: 8bit ^ permalink raw reply [nested|flat] 263+ messages in thread
end of thread, other threads:[~2024-11-02 14:21 UTC | newest] Thread overview: 263+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-12-13 02:54 [PATCH v22 1/3] vacuum errcontext to show block being processed Justin Pryzby <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v1] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v1] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]> 2024-11-02 14:21 [PATCH v6 1/2] Clear padding in PgStat_HashKey keys Bertrand Drouvot <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox