Skip to content

Commit

Permalink
swtpm: Do not follow symlinks when opening lockfile (CVE-2020-28407)
Browse files Browse the repository at this point in the history
This patch addresses CVE-2020-28407.

Prevent us from following symliks when we open the lockfile
for writing.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Nov 14, 2020
1 parent e9c9778 commit 4cc42c0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/swtpm/swtpm_nvfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static TPM_RESULT SWTPM_NVRAM_Lock_Lockfile(const char *directory,
return TPM_FAIL;
}

*fd = open(lockfile, O_WRONLY|O_CREAT|O_TRUNC, 0660);
*fd = open(lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_NOFOLLOW, 0660);
if (*fd < 0) {
logprintf(STDERR_FILENO,
"SWTPM_NVRAM_Lock_Lockfile: Could not open lockfile: %s\n",
Expand Down

0 comments on commit 4cc42c0

Please sign in to comment.