Skip to content

Commit f120a15

Browse files
committed
MDEV-19212 4GB Limit on large_pages - integer overflow
os_mem_alloc_large(): Invoke the macro ut_2pow_round() with the correct argument type. innobase_large_page_size, innobase_use_large_pages, os_use_large_pages, os_large_page_size: Remove. Simply refer to opt_large_page_size, my_use_large_pages.
1 parent caa8c20 commit f120a15

File tree

5 files changed

+16
-35
lines changed

5 files changed

+16
-35
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,6 @@ const char *defaults_group = "mysqld";
221221
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
222222
#define HA_INNOBASE_RANGE_COUNT 100
223223

224-
ulong innobase_large_page_size = 0;
225-
226224
/* The default values for the following, type long or longlong, start-up
227225
parameters are declared in mysqld.cc: */
228226

@@ -247,7 +245,6 @@ affects Windows: */
247245
char* innobase_unix_file_flush_method;
248246

249247
my_bool innobase_use_doublewrite;
250-
my_bool innobase_use_large_pages;
251248
my_bool innobase_file_per_table;
252249
my_bool innobase_locks_unsafe_for_binlog;
253250
my_bool innobase_rollback_on_timeout;
@@ -1919,8 +1916,6 @@ innodb_init_param(void)
19191916

19201917
srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
19211918

1922-
os_use_large_pages = (ibool) innobase_use_large_pages;
1923-
os_large_page_size = (ulint) innobase_large_page_size;
19241919
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
19251920

19261921
srv_file_per_table = (my_bool) innobase_file_per_table;

storage/innobase/buf/buf0buf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ buf_chunk_init(
15661566
chunk->blocks = (buf_block_t*) chunk->mem;
15671567

15681568
/* Align a pointer to the first frame. Note that when
1569-
os_large_page_size is smaller than UNIV_PAGE_SIZE,
1569+
opt_large_page_size is smaller than UNIV_PAGE_SIZE,
15701570
we may allocate one fewer block than requested. When
15711571
it is bigger, we may allocate more blocks than requested. */
15721572

storage/innobase/handler/ha_innodb.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,12 +4265,6 @@ innobase_init(
42654265
innodb_log_checksums = innodb_log_checksums_func_update(
42664266
NULL, innodb_log_checksums);
42674267

4268-
#ifdef HAVE_LINUX_LARGE_PAGES
4269-
if ((os_use_large_pages = my_use_large_pages)) {
4270-
os_large_page_size = opt_large_page_size;
4271-
}
4272-
#endif
4273-
42744268
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
42754269

42764270
srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;

storage/innobase/include/os0proc.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2017, MariaDB Corporation.
4+
Copyright (c) 2017, 2019, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -42,12 +42,6 @@ typedef unsigned long int os_process_id_t;
4242
system with os_mem_alloc_large(). */
4343
extern ulint os_total_large_mem_allocated;
4444

45-
/** Whether to use large pages in the buffer pool */
46-
extern my_bool os_use_large_pages;
47-
48-
/** Large page size. This may be a boot-time option on some platforms */
49-
extern uint os_large_page_size;
50-
5145
/** Converts the current process id to a number.
5246
@return process id as a number */
5347
ulint

storage/innobase/os/os0proc.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2019, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -25,6 +26,9 @@ Created 9/30/1995 Heikki Tuuri
2526
*******************************************************/
2627

2728
#include "univ.i"
29+
#ifdef HAVE_LINUX_LARGE_PAGES
30+
# include "mysqld.h"
31+
#endif
2832

2933
/* FreeBSD for example has only MAP_ANON, Linux has MAP_ANONYMOUS and
3034
MAP_ANON but MAP_ANON is marked as deprecated */
@@ -38,12 +42,6 @@ MAP_ANON but MAP_ANON is marked as deprecated */
3842
system with os_mem_alloc_large(). */
3943
ulint os_total_large_mem_allocated = 0;
4044

41-
/** Whether to use large pages in the buffer pool */
42-
my_bool os_use_large_pages;
43-
44-
/** Large page size. This may be a boot-time option on some platforms */
45-
uint os_large_page_size;
46-
4745
/** Converts the current process id to a number.
4846
@return process id as a number */
4947
ulint
@@ -66,18 +64,18 @@ os_mem_alloc_large(
6664
{
6765
void* ptr;
6866
ulint size;
69-
#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX
67+
#ifdef HAVE_LINUX_LARGE_PAGES
7068
int shmid;
7169
struct shmid_ds buf;
7270

73-
if (!os_use_large_pages || !os_large_page_size) {
71+
if (!my_use_large_pages || !opt_large_page_size) {
7472
goto skip;
7573
}
7674

77-
/* Align block size to os_large_page_size */
78-
ut_ad(ut_is_2pow(os_large_page_size));
79-
size = ut_2pow_round(*n + (os_large_page_size - 1),
80-
os_large_page_size);
75+
/* Align block size to opt_large_page_size */
76+
ut_ad(ut_is_2pow(opt_large_page_size));
77+
size = ut_2pow_round(*n + opt_large_page_size - 1,
78+
ulint(opt_large_page_size));
8179

8280
shmid = shmget(IPC_PRIVATE, (size_t) size, SHM_HUGETLB | SHM_R | SHM_W);
8381
if (shmid < 0) {
@@ -109,7 +107,7 @@ os_mem_alloc_large(
109107

110108
ib::warn() << "Using conventional memory pool";
111109
skip:
112-
#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */
110+
#endif /* HAVE_LINUX_LARGE_PAGES */
113111

114112
#ifdef _WIN32
115113
SYSTEM_INFO system_info;
@@ -161,13 +159,13 @@ os_mem_free_large(
161159
{
162160
ut_a(os_total_large_mem_allocated >= size);
163161

164-
#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX
165-
if (os_use_large_pages && os_large_page_size && !shmdt(ptr)) {
162+
#ifdef HAVE_LINUX_LARGE_PAGES
163+
if (my_use_large_pages && opt_large_page_size && !shmdt(ptr)) {
166164
my_atomic_addlint(
167165
&os_total_large_mem_allocated, -size);
168166
return;
169167
}
170-
#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */
168+
#endif /* HAVE_LINUX_LARGE_PAGES */
171169
#ifdef _WIN32
172170
/* When RELEASE memory, the size parameter must be 0.
173171
Do not use MEM_RELEASE with MEM_DECOMMIT. */

0 commit comments

Comments
 (0)