Skip to content

Commit 2c4083a

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 8800a63 commit 2c4083a

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
@@ -28,15 +28,6 @@ typedef struct TDESMgrRelationData
2828

2929
typedef TDESMgrRelationData *TDESMgrRelation;
3030

31-
/*
32-
* we only encrypt main and init forks
33-
*/
34-
static inline bool
35-
tde_is_encryption_required(TDESMgrRelation tdereln, ForkNumber forknum)
36-
{
37-
return (tdereln->encrypted_relation && (forknum == MAIN_FORKNUM || forknum == INIT_FORKNUM));
38-
}
39-
4031
static InternalKey *
4132
tde_smgr_get_key(SMgrRelation reln, RelFileLocator *old_locator, bool can_create)
4233
{
@@ -102,7 +93,7 @@ tde_mdwritev(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
10293
TDESMgrRelation tdereln = (TDESMgrRelation) reln;
10394
InternalKey *int_key = &tdereln->relKey;
10495

105-
if (!tde_is_encryption_required(tdereln, forknum))
96+
if (!tdereln->encrypted_relation)
10697
{
10798
mdwritev(reln, forknum, blocknum, buffers, nblocks, skipFsync);
10899
}
@@ -143,7 +134,7 @@ tde_mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
143134
TDESMgrRelation tdereln = (TDESMgrRelation) reln;
144135
InternalKey *int_key = &tdereln->relKey;
145136

146-
if (!tde_is_encryption_required(tdereln, forknum))
137+
if (!tdereln->encrypted_relation)
147138
{
148139
mdextend(reln, forknum, blocknum, buffer, skipFsync);
149140
}
@@ -177,7 +168,7 @@ tde_mdreadv(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
177168

178169
mdreadv(reln, forknum, blocknum, buffers, nblocks);
179170

180-
if (!tde_is_encryption_required(tdereln, forknum))
171+
if (!tdereln->encrypted_relation)
181172
return;
182173

183174
AesInit();

0 commit comments

Comments
 (0)