[gnutls-devel] GnuTLS | WIP: fixed operation under multiple threads (!935)

Development of GNU's TLS library gnutls-devel at lists.gnutls.org
Mon Feb 25 14:59:01 CET 2019


As you already said, on all supported platform the read and write to/from int already is atomic. Making the variable atomic just helps unsupported platforms (e.g. 16 bit data bus).

What I think of is code like
```
if (session->internals.recv_state != RECV_STATE_FALSE_START &&
    session->internals.recv_state != RECV_STATE_FALSE_START_HANDLING &&
    session->internals.recv_state != RECV_STATE_EARLY_START &&
    session->internals.recv_state != RECV_STATE_EARLY_START_HANDLING &&
    !(session->internals.hsk_flags & HSK_EARLY_DATA_IN_FLIGHT))
...
```

If a non-optimizing compiler reads the variable 4x, this allows a second thread to change the value between two comparisons. It might be unlikely, but to be sure you would save `session->internals.recv_state` into a temp variable and use that for comparison.

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/merge_requests/935#note_144663146
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20190225/5ac143c8/attachment-0001.html>


More information about the Gnutls-devel mailing list