mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-26556 An improper locking bug(s) due to unreleased lock.
Get rid of the global big_buffer.
This commit is contained in:
@ -261,6 +261,9 @@ A B C D
|
|||||||
A B C D
|
A B C D
|
||||||
set global server_audit_query_log_limit= 1024;
|
set global server_audit_query_log_limit= 1024;
|
||||||
drop database sa_db;
|
drop database sa_db;
|
||||||
|
select length('01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789');
|
||||||
|
length('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
|
||||||
|
2750
|
||||||
set global server_audit_file_path='.';
|
set global server_audit_file_path='.';
|
||||||
show status like 'server_audit_current_log';
|
show status like 'server_audit_current_log';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
@ -485,6 +488,7 @@ TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,proc,
|
|||||||
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc,
|
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc,
|
||||||
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event,
|
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event,
|
||||||
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0
|
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0
|
||||||
|
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select length(\'012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567',0
|
||||||
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0
|
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0
|
||||||
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0
|
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0
|
||||||
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0
|
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0
|
||||||
|
@ -210,6 +210,8 @@ select 'A', 'B', 'C', 'D';
|
|||||||
set global server_audit_query_log_limit= 1024;
|
set global server_audit_query_log_limit= 1024;
|
||||||
drop database sa_db;
|
drop database sa_db;
|
||||||
|
|
||||||
|
select length('01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789');
|
||||||
|
|
||||||
set global server_audit_file_path='.';
|
set global server_audit_file_path='.';
|
||||||
--replace_regex /\.[\\\/]/HOME_DIR\//
|
--replace_regex /\.[\\\/]/HOME_DIR\//
|
||||||
show status like 'server_audit_current_log';
|
show status like 'server_audit_current_log';
|
||||||
|
@ -301,8 +301,6 @@ static char logging;
|
|||||||
static volatile int internal_stop_logging= 0;
|
static volatile int internal_stop_logging= 0;
|
||||||
static char incl_user_buffer[1024];
|
static char incl_user_buffer[1024];
|
||||||
static char excl_user_buffer[1024];
|
static char excl_user_buffer[1024];
|
||||||
static char *big_buffer= NULL;
|
|
||||||
static size_t big_buffer_alloced= 0;
|
|
||||||
static unsigned int query_log_limit= 0;
|
static unsigned int query_log_limit= 0;
|
||||||
|
|
||||||
static char servhost[256];
|
static char servhost[256];
|
||||||
@ -555,20 +553,16 @@ static struct st_mysql_show_var audit_status[]=
|
|||||||
/* These belong to the service initialization */
|
/* These belong to the service initialization */
|
||||||
static PSI_mutex_key key_LOCK_operations;
|
static PSI_mutex_key key_LOCK_operations;
|
||||||
static PSI_mutex_key key_LOCK_atomic;
|
static PSI_mutex_key key_LOCK_atomic;
|
||||||
static PSI_mutex_key key_LOCK_bigbuffer;
|
|
||||||
static PSI_mutex_info mutex_key_list[]=
|
static PSI_mutex_info mutex_key_list[]=
|
||||||
{
|
{
|
||||||
{ &key_LOCK_operations, "SERVER_AUDIT_plugin::lock_operations",
|
{ &key_LOCK_operations, "SERVER_AUDIT_plugin::lock_operations",
|
||||||
PSI_FLAG_GLOBAL},
|
PSI_FLAG_GLOBAL},
|
||||||
{ &key_LOCK_atomic, "SERVER_AUDIT_plugin::lock_atomic",
|
{ &key_LOCK_atomic, "SERVER_AUDIT_plugin::lock_atomic",
|
||||||
PSI_FLAG_GLOBAL},
|
PSI_FLAG_GLOBAL},
|
||||||
{ &key_LOCK_bigbuffer, "SERVER_AUDIT_plugin::lock_bigbuffer",
|
|
||||||
PSI_FLAG_GLOBAL}
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
static mysql_mutex_t lock_operations;
|
static mysql_mutex_t lock_operations;
|
||||||
static mysql_mutex_t lock_atomic;
|
static mysql_mutex_t lock_atomic;
|
||||||
static mysql_mutex_t lock_bigbuffer;
|
|
||||||
|
|
||||||
/* The Percona server and partly MySQL don't support */
|
/* The Percona server and partly MySQL don't support */
|
||||||
/* launching client errors in the 'update_variable' methods. */
|
/* launching client errors in the 'update_variable' methods. */
|
||||||
@ -1700,7 +1694,7 @@ static int log_statement_ex(const struct connection_info *cn,
|
|||||||
int error_code, const char *type, int take_lock)
|
int error_code, const char *type, int take_lock)
|
||||||
{
|
{
|
||||||
size_t csize;
|
size_t csize;
|
||||||
char message_loc[1024];
|
char message_loc[2048];
|
||||||
char *message= message_loc;
|
char *message= message_loc;
|
||||||
size_t message_size= sizeof(message_loc);
|
size_t message_size= sizeof(message_loc);
|
||||||
char *uh_buffer;
|
char *uh_buffer;
|
||||||
@ -1709,6 +1703,7 @@ static int log_statement_ex(const struct connection_info *cn,
|
|||||||
unsigned int db_length;
|
unsigned int db_length;
|
||||||
long long query_id;
|
long long query_id;
|
||||||
int result;
|
int result;
|
||||||
|
char *big_buffer= NULL;
|
||||||
|
|
||||||
if ((db= cn->db))
|
if ((db= cn->db))
|
||||||
db_length= cn->db_length;
|
db_length= cn->db_length;
|
||||||
@ -1791,17 +1786,9 @@ do_log_query:
|
|||||||
|
|
||||||
if (query_len > (message_size - csize)/2)
|
if (query_len > (message_size - csize)/2)
|
||||||
{
|
{
|
||||||
flogger_mutex_lock(&lock_bigbuffer);
|
size_t big_buffer_alloced= (query_len * 2 + csize + 4095) & ~4095L;
|
||||||
if (big_buffer_alloced < (query_len * 2 + csize))
|
if(!(big_buffer= malloc(big_buffer_alloced)))
|
||||||
{
|
return 0;
|
||||||
big_buffer_alloced= (query_len * 2 + csize + 4095) & ~4095L;
|
|
||||||
big_buffer= realloc(big_buffer, big_buffer_alloced);
|
|
||||||
if (big_buffer == NULL)
|
|
||||||
{
|
|
||||||
big_buffer_alloced= 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(big_buffer, message, csize);
|
memcpy(big_buffer, message, csize);
|
||||||
message= big_buffer;
|
message= big_buffer;
|
||||||
@ -1846,8 +1833,8 @@ do_log_query:
|
|||||||
"\',%d", error_code);
|
"\',%d", error_code);
|
||||||
message[csize]= '\n';
|
message[csize]= '\n';
|
||||||
result= write_log(message, csize + 1, take_lock);
|
result= write_log(message, csize + 1, take_lock);
|
||||||
if (message == big_buffer)
|
if (big_buffer)
|
||||||
flogger_mutex_unlock(&lock_bigbuffer);
|
free(big_buffer);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2496,7 +2483,6 @@ static int server_audit_init(void *p __attribute__((unused)))
|
|||||||
#endif
|
#endif
|
||||||
flogger_mutex_init(key_LOCK_operations, &lock_operations, MY_MUTEX_INIT_FAST);
|
flogger_mutex_init(key_LOCK_operations, &lock_operations, MY_MUTEX_INIT_FAST);
|
||||||
flogger_mutex_init(key_LOCK_operations, &lock_atomic, MY_MUTEX_INIT_FAST);
|
flogger_mutex_init(key_LOCK_operations, &lock_atomic, MY_MUTEX_INIT_FAST);
|
||||||
flogger_mutex_init(key_LOCK_operations, &lock_bigbuffer, MY_MUTEX_INIT_FAST);
|
|
||||||
|
|
||||||
coll_init(&incl_user_coll);
|
coll_init(&incl_user_coll);
|
||||||
coll_init(&excl_user_coll);
|
coll_init(&excl_user_coll);
|
||||||
@ -2581,10 +2567,8 @@ static int server_audit_deinit(void *p __attribute__((unused)))
|
|||||||
else if (output_type == OUTPUT_SYSLOG)
|
else if (output_type == OUTPUT_SYSLOG)
|
||||||
closelog();
|
closelog();
|
||||||
|
|
||||||
(void) free(big_buffer);
|
|
||||||
flogger_mutex_destroy(&lock_operations);
|
flogger_mutex_destroy(&lock_operations);
|
||||||
flogger_mutex_destroy(&lock_atomic);
|
flogger_mutex_destroy(&lock_atomic);
|
||||||
flogger_mutex_destroy(&lock_bigbuffer);
|
|
||||||
|
|
||||||
error_header();
|
error_header();
|
||||||
fprintf(stderr, "STOPPED\n");
|
fprintf(stderr, "STOPPED\n");
|
||||||
|
Reference in New Issue
Block a user