Skip to content

Calling RAND_DRBG_get0_public without locks initialized segfaults on platforms without atomics #7870

@kuncao

Description

@kuncao

Hi ,every experts.
I am newbie in Openssl.
I have a issue when call RAND_DRBG_get0_public in program.
The following is the detail information,please help to check what's wrong?
Thanks in advance.

uname -a
Linux linux 2.6.32.45-0.3-default #1 SMP 2011-08-22 10:12:58 +0200 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1

code snap:

static RAND_DRBG *public_drbg;
bool init_drbg(void)
{
	unsigned int reseedinterval = 0;
	time_t health_check_interval = 0;
	
	public_drbg = RAND_DRBG_get0_public();
	if (public_drbg == NULL)
	{
		return false;
	}
}

core stack information:

#0  0x00007f7a8e455c8a in pthread_rwlock_wrlock () from /lib64/libpthread.so.0
(gdb) bt
#0  0x00007f7a8e455c8a in pthread_rwlock_wrlock () from /lib64/libpthread.so.0
#1  0x00007f7a8dee0d89 in CRYPTO_THREAD_write_lock () from /usr/local/lib64/libcrypto.so.1.1
#2  0x0000000000007cf7 in ?? ()
#3  0x00007f7a8dee0dcc in CRYPTO_atomic_add () from /usr/local/lib64/libcrypto.so.1.1
#4  0x5bf3984a0008b192 in ?? ()
#5  0x0000000000000000 in ?? ()
(gdb)

but when call like following

public_drbg = RAND_DRBG_new(NID_aes_256_ctr, 0, NULL);

the program is ok, not coredump will be issued.

Metadata

Metadata

Assignees

No one assigned

    Labels

    branch: 1.1.1Applies to OpenSSL_1_1_1-stable branch (EOL)triaged: bugThe issue/pr is/fixes a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions