Skip to content

Commit 049c28f

Browse files
committed
PoC: PG-1392 Encrypt all relation forks
It is unclear to me why we stopped encrypting the FSM and visibility map forks in commit e514ac5 which sadly does not explain why we stopped doing so. Both of them leak metadata that we do not have to. Especially once we also encrypt the catalogs.
1 parent 148a051 commit 049c28f

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

contrib/pg_tde/src/smgr/pg_tde_smgr.c

+3-12
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ typedef struct TDESMgrRelationData
2626

2727
typedef TDESMgrRelationData *TDESMgrRelation;
2828

29-
/*
30-
* we only encrypt main and init forks
31-
*/
32-
static inline bool
33-
tde_is_encryption_required(TDESMgrRelation tdereln, ForkNumber forknum)
34-
{
35-
return (tdereln->encrypted_relation && (forknum == MAIN_FORKNUM || forknum == INIT_FORKNUM));
36-
}
37-
3829
static InternalKey *
3930
tde_smgr_get_key(SMgrRelation reln, RelFileLocator *old_locator, bool can_create)
4031
{
@@ -90,7 +81,7 @@ tde_mdwritev(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
9081
TDESMgrRelation tdereln = (TDESMgrRelation) reln;
9182
InternalKey *int_key = &tdereln->relKey;
9283

93-
if (!tde_is_encryption_required(tdereln, forknum))
84+
if (!tdereln->encrypted_relation)
9485
{
9586
mdwritev(reln, forknum, blocknum, buffers, nblocks, skipFsync);
9687
}
@@ -131,7 +122,7 @@ tde_mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
131122
TDESMgrRelation tdereln = (TDESMgrRelation) reln;
132123
InternalKey *int_key = &tdereln->relKey;
133124

134-
if (!tde_is_encryption_required(tdereln, forknum))
125+
if (!tdereln->encrypted_relation)
135126
{
136127
mdextend(reln, forknum, blocknum, buffer, skipFsync);
137128
}
@@ -165,7 +156,7 @@ tde_mdreadv(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
165156

166157
mdreadv(reln, forknum, blocknum, buffers, nblocks);
167158

168-
if (!tde_is_encryption_required(tdereln, forknum))
159+
if (!tdereln->encrypted_relation)
169160
return;
170161

171162
AesInit();

0 commit comments

Comments
 (0)