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

RNR: do not update ErrorData if a previous request has not been completed #2872

Open
rw8896 opened this issue Oct 28, 2024 · 6 comments
Open

Comments

@rw8896
Copy link
Contributor

rw8896 commented Oct 28, 2024

As described in the first line comment below, the code shouldn't update the ErrorData.
Returning a Busy SPDM error message looks more appropriate as the Responder is supposed to be busy processing the previous request when response state is LIBSPDM_RESPONSE_STATE_NOT_READY?

/*do not update ErrorData if a previous request has not been completed*/
if(request_code != SPDM_RESPOND_IF_READY) {
spdm_context->cache_spdm_request_size = spdm_context->last_spdm_request_size;
libspdm_copy_mem(spdm_context->cache_spdm_request,
libspdm_get_scratch_buffer_cache_spdm_request_capacity(spdm_context),
spdm_context->last_spdm_request,
spdm_context->last_spdm_request_size);
spdm_context->error_data.rd_exponent = 1;
spdm_context->error_data.rd_tm = 1;
spdm_context->error_data.request_code = request_code;
spdm_context->error_data.token = spdm_context->current_token++;
}

@steven-bellock
Copy link
Contributor

I have never understood how an Integrator would use this. In particular why would a Responder be evaluating requests if its state is LIBSPDM_RESPONSE_STATE_NOT_READY. Those parameters are also hardcoded, see #1983.

@rw8896 do you need real ResponseNotReady support? If so that will need a design.

@jyao1
Copy link
Member

jyao1 commented Oct 28, 2024

The original code can be used to validate the requester.

Yes, if we need responder, we need a design.

@rw8896
Copy link
Contributor Author

rw8896 commented Oct 29, 2024

I think a real ResponseNotReady design will be needed as the lower transport layers will not always be dedicated for SPDM use.
If SPDM procedures take too long, it might impact other protocol entities sharing the same underneath layers. For example, if the BMC temperature reading is blocked for too long, it might trigger the BMC to reset/shutdown the whole system.

It becomes a concern especially for the SET_CERTIFICATE command, which could use several crypto operations to verify the certificate chain plus it also needs to erase/write the NVRAM. That consumes quite a lot of time and is very possible to cause such side effects.

@steven-bellock
Copy link
Contributor

If SPDM procedures take too long, it might impact other protocol entities sharing the same underneath layers.

How does ResponseNotReady help with that scenario?

@rw8896
Copy link
Contributor Author

rw8896 commented Oct 29, 2024

The high level idea is the handler function could create another task to process the request, set response state to LIBSPDM_RESPONSE_STATE_NOT_READY and return ResponseNotReady from the libspdm running task. The created task populates the response and sets the response state back to LIBSPDM_RESPONSE_STATE_NORMAL. The handler function needs a mechanism to tell if it should return ResponseNotReady and delegate the work to other task or the response populated by the created task.

I didn't think of a general design to implement it with current code. Perhaps it will need to allow integrators to override the default libspdm handler function to realize their own ResponseNotReady design for specific request. Probably could be done via something similar to libspdm_register_get_response_func?

@rw8896
Copy link
Contributor Author

rw8896 commented Nov 1, 2024

Actually I probably could just create a separate task running libspdm.
The original code to validate the requester still needs to be reviewed or moved to unit test code?

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

No branches or pull requests

3 participants