Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #75

Closed

Conversation

SudhakarKuppusamy1
Copy link
Contributor

@SudhakarKuppusamy1 SudhakarKuppusamy1 commented Oct 26, 2023

It has the following bug fixes

  1. In verify/read, reading of timestamp from variable
  2. In generate, trustedcadb allow only CA cert
  3. misbehavior of verify with -p and write

when read variable from path, read timestamp from variable and show it as humanreadble form

Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Moved read_timestamp to util and reads the timestamp when use -v

Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
-w option available only when use -u with -p. otherwise throwing error message

Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
In generating trustedcadb auth file, checked to have basicConstraints CA:TRUE
for any certificate added to trustedcadb, else returned as invalid certificate.

Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
issue: verify with -u, -p and -w, verify of variable auth file failed
if variable not available in /sys/firmware/secvar/vars/.

fix: allowing the variable auth file verify and write
if variable not available in /sys/firmware/secvar/vars/.

Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Comment on lines +44 to +53
bool is_trustedcadb_variable(const char *variable_name)
{
int len = strlen(variable_name);

if (memcmp(variable_name, TRUSTEDCADB_VARIABLE, len) == 0)
return true;

return false;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool is_trustedcadb_variable(const char *variable_name)
{
    return !strcmp(variable_name, TRUSTEDCADB_VARIABLE);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged.

Comment on lines -115 to +117
return INVALID_FILE;
prlog(PR_WARNING, "WARNING: %s file does not have data\n", (char *)esl_file);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not returning an error code here? It seems like this can only be reached if we fail to allocate memory for the file, or fail to read from the file (is_file checks that it exists and can be opened, which does return an error code). In both cases, this should be signaled to the calling function that something went wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional note: it appears get_auth_data() does return INVALID_FILE in its similar error else case, around ~L147

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged, we should return INVALID_FILE in this case as it will avoid unnecessary operations at a later stage.

if (esl_data == NULL)
return;

memcpy(&timestamp, esl_data + 1, TIMESTAMP_LEN - 1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we skip the first byte of the timestamp here?

Also, since this function does not do any check on the size of the buffer *esl_data points to, please include a comment that states that the caller must confirm the input buffer contains at least TIMESTAMP_LEN bytes.

Copy link

@soura15 soura15 Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the structure of the plpks_get_variable under linux/arch/powerpc/platforms/pseries/plpks-secvar.c, it seems the esl_data size will always be fixed to align with timestamp_len, my question is that do we support variable key sizes for the secure variables?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't warrant a comment as per my understanding because we have used TIMESTAMP_LEN at multiple places and I don't think there can be a scenario where we will get esl_data_size less than the TIMESTAMP_LEN.

Comment on lines -267 to -269
else
prlog(PR_WARNING, "WARNING: The %s database is empty.\n",
variable_name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little unclear on the change to the conditionals here. I assume a variable will be completely empty if it hadn't yet stored data or freshly reset, but otherwise it should at least contain a data size of TIMESTAMP_LEN. Removing the else condition would remove some error cases that should handled.

It seems like there are four conditions:

  1. esl_data_size >= TIMESTAMP_LEN ➔ normal case, variable data at least (probably) contains a timestamp
  2. 0 < esl_data_size < TIMESTAMP_LEN ➔ malformed variable contents?
  3. esl_data_size == 0 ➔ empty variable that hasn't been written to, might be worth printing that it is empty
  4. esl_data_size == -1 ➔ an error that should be printed, although I don't think this can be hit if variable_from_path() call returns SUCCESS.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this appears again later in the function.

Copy link

@soura15 soura15 Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think conditions 2 and 4 can ever occur? We can remove the esl_data_size != -1 check here.

@erichte-ibm
Copy link
Collaborator

Closing this PR, as these commits were merged in #77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants