VirtualBox

Ignore:
Timestamp:
Mar 31, 2022 9:00:36 AM (3 years ago)
Author:
vboxsync
Message:

libs/openssl: Update to 3.0.2 and switch to it, bugref:10128

Location:
trunk/src/libs/openssl-3.0.2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/openssl-3.0.2

    • Property svn:mergeinfo
      •  

        old new  
        1313/vendor/openssl/1.1.1k:145841-145843
        1414/vendor/openssl/3.0.1:150323-150324
        15 /vendor/openssl/current:147554-150322
         15/vendor/openssl/3.0.2:150728-150729
         16/vendor/openssl/current:147554-150727
  • trunk/src/libs/openssl-3.0.2/crypto/lhash/lh_stats.c

    r94082 r94404  
    11/*
    2  * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    44 * Licensed under the Apache License 2.0 (the "License").  You may not use
     
    6262void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out)
    6363{
     64    int omit_tsan = 0;
     65
     66#ifdef TSAN_REQUIRES_LOCKING
     67    if (!CRYPTO_THREAD_read_lock(lh->tsan_lock)) {
     68        BIO_printf(out, "unable to lock table, omitting TSAN counters\n");
     69        omit_tsan = 1;
     70    }
     71#endif
    6472    BIO_printf(out, "num_items             = %lu\n", lh->num_items);
    6573    BIO_printf(out, "num_nodes             = %u\n",  lh->num_nodes);
     
    6977    BIO_printf(out, "num_contracts         = %lu\n", lh->num_contracts);
    7078    BIO_printf(out, "num_contract_reallocs = %lu\n", lh->num_contract_reallocs);
    71     BIO_printf(out, "num_hash_calls        = %lu\n", lh->num_hash_calls);
    72     BIO_printf(out, "num_comp_calls        = %lu\n", lh->num_comp_calls);
     79    if (!omit_tsan) {
     80        BIO_printf(out, "num_hash_calls        = %lu\n", lh->num_hash_calls);
     81        BIO_printf(out, "num_comp_calls        = %lu\n", lh->num_comp_calls);
     82    }
    7383    BIO_printf(out, "num_insert            = %lu\n", lh->num_insert);
    7484    BIO_printf(out, "num_replace           = %lu\n", lh->num_replace);
    7585    BIO_printf(out, "num_delete            = %lu\n", lh->num_delete);
    7686    BIO_printf(out, "num_no_delete         = %lu\n", lh->num_no_delete);
    77     BIO_printf(out, "num_retrieve          = %lu\n", lh->num_retrieve);
    78     BIO_printf(out, "num_retrieve_miss     = %lu\n", lh->num_retrieve_miss);
    79     BIO_printf(out, "num_hash_comps        = %lu\n", lh->num_hash_comps);
     87    if (!omit_tsan) {
     88        BIO_printf(out, "num_retrieve          = %lu\n", lh->num_retrieve);
     89        BIO_printf(out, "num_retrieve_miss     = %lu\n", lh->num_retrieve_miss);
     90        BIO_printf(out, "num_hash_comps        = %lu\n", lh->num_hash_comps);
     91#ifdef TSAN_REQUIRES_LOCKING
     92        CRYPTO_THREAD_unlock(lh->tsan_lock);
     93#endif
     94    }
    8095}
    8196
  • trunk/src/libs/openssl-3.0.2/crypto/lhash/lhash.c

    r94082 r94404  
    11/*
    2  * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    44 * Licensed under the Apache License 2.0 (the "License").  You may not use
     
    4545static OPENSSL_LH_NODE **getrn(OPENSSL_LHASH *lh, const void *data, unsigned long *rhash);
    4646
     47static ossl_inline int tsan_lock(const OPENSSL_LHASH *lh)
     48{
     49#ifdef TSAN_REQUIRES_LOCKING
     50    if (!CRYPTO_THREAD_write_lock(lh->tsan_lock))
     51        return 0;
     52#endif
     53    return 1;
     54}
     55
     56static ossl_inline void tsan_unlock(const OPENSSL_LHASH *lh)
     57{
     58#ifdef TSAN_REQUIRES_LOCKING
     59    CRYPTO_THREAD_unlock(lh->tsan_lock);
     60#endif
     61}
     62
    4763OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c)
    4864{
     
    5975    if ((ret->b = OPENSSL_zalloc(sizeof(*ret->b) * MIN_NODES)) == NULL)
    6076        goto err;
     77#ifdef TSAN_REQUIRES_LOCKING
     78    if ((ret->tsan_lock = CRYPTO_THREAD_lock_new()) == NULL)
     79        goto err;
     80#endif
    6181    ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c);
    6282    ret->hash = ((h == NULL) ? (OPENSSL_LH_HASHFUNC)OPENSSL_LH_strhash : h);
     
    80100
    81101    OPENSSL_LH_flush(lh);
     102#ifdef TSAN_REQUIRES_LOCKING
     103    CRYPTO_THREAD_lock_free(lh->tsan_lock);
     104#endif
    82105    OPENSSL_free(lh->b);
    83106    OPENSSL_free(lh);
     
    167190    unsigned long hash;
    168191    OPENSSL_LH_NODE **rn;
    169     void *ret;
    170 
     192
     193    /*-
     194     * This should be atomic without tsan.
     195     * It's not clear why it was done this way and not elsewhere.
     196     */
    171197    tsan_store((TSAN_QUALIFIER int *)&lh->error, 0);
    172198
    173199    rn = getrn(lh, data, &hash);
    174200
    175     if (*rn == NULL) {
    176         tsan_counter(&lh->num_retrieve_miss);
    177         return NULL;
    178     } else {
    179         ret = (*rn)->data;
    180         tsan_counter(&lh->num_retrieve);
    181     }
    182 
    183     return ret;
     201    if (tsan_lock(lh)) {
     202        tsan_counter(*rn == NULL ? &lh->num_retrieve_miss : &lh->num_retrieve);
     203        tsan_unlock(lh);
     204    }
     205    return *rn == NULL ? NULL : (*rn)->data;
    184206}
    185207
     
    308330    unsigned long hash, nn;
    309331    OPENSSL_LH_COMPFUNC cf;
    310 
     332    int do_tsan = 1;
     333
     334#ifdef TSAN_REQUIRES_LOCKING
     335    do_tsan = tsan_lock(lh);
     336#endif
    311337    hash = (*(lh->hash)) (data);
    312     tsan_counter(&lh->num_hash_calls);
     338    if (do_tsan)
     339        tsan_counter(&lh->num_hash_calls);
    313340    *rhash = hash;
    314341
     
    320347    ret = &(lh->b[(int)nn]);
    321348    for (n1 = *ret; n1 != NULL; n1 = n1->next) {
    322         tsan_counter(&lh->num_hash_comps);
     349        if (do_tsan)
     350            tsan_counter(&lh->num_hash_comps);
    323351        if (n1->hash != hash) {
    324352            ret = &(n1->next);
    325353            continue;
    326354        }
    327         tsan_counter(&lh->num_comp_calls);
     355        if (do_tsan)
     356            tsan_counter(&lh->num_comp_calls);
    328357        if (cf(n1->data, data) == 0)
    329358            break;
    330359        ret = &(n1->next);
    331360    }
     361    if (do_tsan)
     362        tsan_unlock(lh);
    332363    return ret;
    333364}
     
    353384        n += 0x100;
    354385        r = (int)((v >> 2) ^ v) & 0x0f;
    355         ret = (ret << r) | (ret >> (32 - r));
     386        /* cast to uint64_t to avoid 32 bit shift of 32 bit value */
     387        ret = (ret << r) | (unsigned long)((uint64_t)ret >> (32 - r));
    356388        ret &= 0xFFFFFFFFL;
    357389        ret ^= v * v;
     
    374406        v = n | ossl_tolower(*c);
    375407        r = (int)((v >> 2) ^ v) & 0x0f;
    376         ret = (ret << r) | (ret >> (32 - r));
     408        /* cast to uint64_t to avoid 32 bit shift of 32 bit value */
     409        ret = (ret << r) | (unsigned long)((uint64_t)ret >> (32 - r));
    377410        ret &= 0xFFFFFFFFL;
    378411        ret ^= v * v;
  • trunk/src/libs/openssl-3.0.2/crypto/lhash/lhash_local.h

    r94082 r94404  
    11/*
    2  * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    44 * Licensed under the Apache License 2.0 (the "License").  You may not use
     
    4242    TSAN_QUALIFIER unsigned long num_hash_comps;
    4343    int error;
     44#ifdef TSAN_REQUIRES_LOCKING
     45    CRYPTO_RWLOCK *tsan_lock;
     46#endif
    4447};
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette