On Thu, Sep 19, 2002 at 06:28:16PM -0700, Patrick McCormick wrote:

>> No locking should be needed because the assignments are idempotent.

> However, the assignments are not atomic.  The following unprotected
> operation:
> 
>     if (init)
>         {
>         memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(),
>             sizeof(SSL_METHOD));
>         SSLv3_server_data.ssl_accept=ssl3_accept;
>         SSLv3_server_data.get_ssl_method=ssl3_get_server_method;
>         init=0;
>         }
> 
> can result in a thread calling .ssl_accept or .get_ssl_method after the
> memcpy but before the assignment.

Can you elaborate?  In such cases the other thread should execute the
'if' body too.  A potential problem is not about atomicity, but about
reordering of statements (if the assignment to 'init' happens before
on of the other assignements, we have a problem), so it might be
better to make those static variables 'volatile'.

(I'm aware that the code still is bad in theory, but it should work
for all implementations.  There's more stuff like that in OpenSSL, but
I can't rewrite all of it ...)


-- 
Bodo Möller <[EMAIL PROTECTED]>
PGP http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/moeller/0x36d2c658.html
* TU Darmstadt, Theoretische Informatik, Alexanderstr. 10, D-64283 Darmstadt
* Tel. +49-6151-16-6628, Fax +49-6151-16-6036
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to