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

Do not zeroize receive buffer #2763

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions doc/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,15 @@

* libspdm never writes data to the receive buffer so the buffer may be read-only.
* libspdm both reads from and writes to the send buffer. Note that in a future release libspdm
may never read from the send buffer, allowing it to be write-only.
may never read from the send buffer, allowing it to be write-only.
* libspdm always releases the send buffer before acquiring the receive buffer and releases the
receive buffer before acquiring the send buffer. Because of this the send buffer and receive buffer
may overlap or be the same buffer.
* libspdm assumes that, when populating the send buffer or parsing the receive buffer, both buffers
cannot be modified by external agents. It is the library Integrator's responsibility to ensure that
the buffers cannot be tampered with while libspdm is accessing them.
receive buffer before acquiring the send buffer. Because of this the send buffer and receive
buffer may overlap or be the same buffer.
* libspdm assumes that, when populating the send buffer or parsing the receive buffer, both
buffers cannot be modified by external agents. It is the library Integrator's responsibility to
ensure that the buffers cannot be tampered with while libspdm is accessing them.
* If the buffers contain data that should not be shared with libspdm, the Integrator must erase
or zeroize the buffers before granting access to libspdm.

8) [spdm_lib_config.h](https://github.com/DMTF/libspdm/blob/main/include/library/spdm_lib_config.h) provides an example of the configuration macros used in the libspdm library.

Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_challenge.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ static libspdm_return_t libspdm_try_challenge(libspdm_context_t *spdm_context,
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, NULL, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
5 changes: 1 addition & 4 deletions library/spdm_requester_lib/libspdm_req_encap_request.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright Notice:
* Copyright 2021-2022 DMTF. All rights reserved.
* Copyright 2021-2024 DMTF. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

Expand Down Expand Up @@ -236,7 +236,6 @@ libspdm_return_t libspdm_encapsulated_request(libspdm_context_t *spdm_context,
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, session_id, &spdm_response_size,
(void **)&spdm_response);
Expand Down Expand Up @@ -340,8 +339,6 @@ libspdm_return_t libspdm_encapsulated_request(libspdm_context_t *spdm_context,
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);

status = libspdm_receive_spdm_response(
spdm_context, session_id, &spdm_response_size,
(void **)&spdm_response);
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_end_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static libspdm_return_t libspdm_try_send_receive_end_session(libspdm_context_t *
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, &session_id, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_finish.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ static libspdm_return_t libspdm_try_send_receive_finish(libspdm_context_t *spdm_
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, &session_id, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_get_capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ static libspdm_return_t libspdm_try_get_capabilities(libspdm_context_t *spdm_con
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(spdm_context, NULL, &spdm_response_size,
(void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_get_certificate.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ static libspdm_return_t libspdm_try_get_certificate(libspdm_context_t *spdm_cont
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(spdm_context, session_id,
&spdm_response_size,
(void **)&spdm_response);
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_get_csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ static libspdm_return_t libspdm_try_get_csr(libspdm_context_t *spdm_context,
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(spdm_context, session_id,
&spdm_response_size, (void **)&spdm_response);

Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_get_digests.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ static libspdm_return_t libspdm_try_get_digest(libspdm_context_t *spdm_context,
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, session_id, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_get_event_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ static libspdm_return_t libspdm_try_get_event_types(libspdm_context_t *spdm_cont
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, &session_id, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ static libspdm_return_t libspdm_try_get_measurement_extension_log(libspdm_contex
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(spdm_context, session_id,
&spdm_response_size,
(void **)&spdm_response);
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_get_measurements.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ static libspdm_return_t libspdm_try_get_measurement(libspdm_context_t *spdm_cont
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, session_id, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_get_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ static libspdm_return_t libspdm_try_get_version(libspdm_context_t *spdm_context,
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(spdm_context, NULL, &spdm_response_size,
(void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ static libspdm_return_t libspdm_requester_respond_if_ready(libspdm_context_t *sp
}
LIBSPDM_ASSERT (*response_size >= transport_header_size);

libspdm_zero_mem(*response, *response_size);
status = libspdm_receive_spdm_response(spdm_context, session_id,
response_size, response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ static libspdm_return_t libspdm_try_heartbeat(libspdm_context_t *spdm_context, u
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, &session_id, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_key_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ static libspdm_return_t libspdm_try_send_receive_key_exchange(
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, NULL, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
2 changes: 0 additions & 2 deletions library/spdm_requester_lib/libspdm_req_key_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ static libspdm_return_t libspdm_try_key_update(libspdm_context_t *spdm_context,
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, &session_id, &spdm_response_size, (void **)&spdm_response);

Expand Down Expand Up @@ -273,7 +272,6 @@ static libspdm_return_t libspdm_try_key_update(libspdm_context_t *spdm_context,
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, &session_id, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ static libspdm_return_t libspdm_try_negotiate_algorithms(libspdm_context_t *spdm
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(spdm_context, NULL, &spdm_response_size,
(void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_psk_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ static libspdm_return_t libspdm_try_send_receive_psk_exchange(
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, NULL, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_psk_finish.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ static libspdm_return_t libspdm_try_send_receive_psk_finish(libspdm_context_t *s
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(
spdm_context, &session_id, &spdm_response_size, (void **)&spdm_response);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_set_certificate.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ static libspdm_return_t libspdm_try_set_certificate(libspdm_context_t *spdm_cont
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(spdm_context, session_id,
&spdm_response_size, (void **)&spdm_response);

Expand Down
1 change: 0 additions & 1 deletion library/spdm_requester_lib/libspdm_req_vendor_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ libspdm_return_t libspdm_try_vendor_send_request_receive_response(
spdm_response = (void *)(message);
spdm_response_size = message_size;

libspdm_zero_mem(spdm_response, spdm_response_size);
status = libspdm_receive_spdm_response(spdm_context, session_id,
&spdm_response_size,
(void **)&spdm_response);
Expand Down
Loading