You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/12/08 17:15:31 UTC

[GitHub] [incubator-nuttx] patacongo edited a comment on pull request #2497: crypto/random_pool.c: fix getrandom() when thread calling it gets can…

patacongo edited a comment on pull request #2497:
URL: https://github.com/apache/incubator-nuttx/pull/2497#issuecomment-740768984


   > We must therefore handle ECANCELED from nxsem_wait_uninterruptible() ourselves instead of silently returning without any random bytes.
   
   getrandom() is not a cancellation point and must not implement any cancellation point logic.  It should not use nxsem_wait_uninterruptible()  but should use something like nxsem_wait_noncancelable().  nxsem_wait-noncancelable() has not been formalized but would simply ignore the ECANCELED error (as well as the EINTR error).
   
   In that case, getrandom would correctly ignore the cancellation request and simply call nxsem_wait() again.
   
    ECANCELED should only occur in the deferred cancellation mode.  In other modes, the task calling getrandom() will be terminated immediately with no return value. (I think anyway.  I haven't looked at the code in a long time).  In the deferred cancellation mode, cancellation can only occur at a few cancellation points; getrandom() is not a cancellatoin point.
   
   In normal usage, ECANCELED is never seen by the application code.  It is either not generated or is handled by the lower level cancellation point (which getrandom() is not).  Hence, there is no need to return the ECANCELED error code.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org