Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
AES doesn't clear out the context data before it frees it in two places:
AES_ContextDestroy in rijndael.c
intel_AES_GCM_DestroyContext in intel-gcm-wrap.c
Created attachment 1407755[details]
Patch to zero the context (which key information) when finished with them.
Comment 4Kai Engert (:kaie) (inactive account)
2018-03-14 11:09:55 UTC
void
AES_DestroyContext(AESContext *cx, PRBool freeit)
{
+ void *mem = cx->mem;
if (cx->worker_cx && cx->destroy) {
(*cx->destroy)(cx->worker_cx, PR_TRUE);
cx->worker_cx = NULL;
cx->destroy = NULL;
}
+ PORT_Memset(cx, 0, sizeof(AESContext));
if (freeit) {
- PORT_Free(cx->mem);
+ PORT_Free(mem);
}
}
The code seems correct, and I agree it clears the context structures.
But I have two suggestions/questions:
Q1: The code doesn't clear the contents of cx->mem. Should it? But that would require to know the size of that block. Is it known?
Q2: The helper variable "mem" seems unnecessary. Why not simply place the memset call as the very last line in this function?
I explained this to kai verbally, but it's worth documenting.
cx is contained in mem:
mem-> +---------+
| |
. .
. .
. .
| |
cx-> +---------+
| |
| |
. .
. .
| cx->mem |
. .
. .
| |
end of cx +---------+
| |
. .
. .
| |
end of mem +---------+
This is done for memory alignment purposes. So space is allocated sizeof(cx) + sizeof(alignment) and assigned to mem. cx is set to the aligned pointer within mem, and cx->mem is set to mem. cx is used as the active context (the extra space in mem is not touched. This was all added by mozilla in the last year to speed up AES performance.
So the order in the patch is important.
1. We need to save mem before we clear the cx (because cx->mem would be cleared and we can't reference it later).
2. We have to clear the cx before we free mem, (because cx is embedded in the mem block and freeing mem frees cx)
3. Finally with mem saved and cx cleared we can safely free mem.