diff options
| author | Peter Marko <peter.marko@siemens.com> | 2025-04-19 00:17:30 +0200 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-05-02 08:12:41 -0700 |
| commit | ade4d1829a9adb5863be5589d732940313d39830 (patch) | |
| tree | a593c37ea45790d677b35ac24b6daeeccec43c00 | |
| parent | 6eba29d9462a5833fbd49064ea32502c8da6405c (diff) | |
| download | poky-ade4d1829a9adb5863be5589d732940313d39830.tar.gz | |
sqlite3: patch CVE-2025-29088
Pick commit [1] mentioned in [2].
[1] https://github.com/sqlite/sqlite/commit/56d2fd008b108109f489339f5fd55212bb50afd4
[2] https://nvd.nist.gov/vuln/detail/CVE-2025-29088
(From OE-Core rev: 70d2d56f89d6f4589d65a0b4f0cbda20d2172167)
Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-support/sqlite/files/CVE-2025-29088.patch | 179 | ||||
| -rw-r--r-- | meta/recipes-support/sqlite/sqlite3_3.38.5.bb | 1 |
2 files changed, 180 insertions, 0 deletions
diff --git a/meta/recipes-support/sqlite/files/CVE-2025-29088.patch b/meta/recipes-support/sqlite/files/CVE-2025-29088.patch new file mode 100644 index 0000000000..470ee9564c --- /dev/null +++ b/meta/recipes-support/sqlite/files/CVE-2025-29088.patch | |||
| @@ -0,0 +1,179 @@ | |||
| 1 | From 40f668e88d70d47b17652ca629d5f36fafaae0e8 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: drh <> | ||
| 3 | Date: Mon, 17 Feb 2025 14:16:49 +0000 | ||
| 4 | Subject: [PATCH] Harden the SQLITE_DBCONFIG_LOOKASIDE interface against | ||
| 5 | misuse, such as described in [forum:/forumpost/48f365daec|forum post | ||
| 6 | 48f365daec]. Enhancements to the SQLITE_DBCONFIG_LOOKASIDE documentation. | ||
| 7 | Test cases in TH3. | ||
| 8 | |||
| 9 | FossilOrigin-Name: 1ec4c308c76c69fba031184254fc3340f07607cfbf8342b13713ab445563d377 | ||
| 10 | |||
| 11 | CVE: CVE-2025-29088 | ||
| 12 | Upstream-Status: Backport [https://github.com/sqlite/sqlite/commit/56d2fd008b108109f489339f5fd55212bb50afd4] | ||
| 13 | Signed-off-by: Peter Marko <peter.marko@siemens.com> | ||
| 14 | --- | ||
| 15 | sqlite3.c | 42 +++++++++++++++++++++++--------------- | ||
| 16 | sqlite3.h | 60 +++++++++++++++++++++++++++++++++++++------------------ | ||
| 17 | 2 files changed, 67 insertions(+), 35 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/sqlite3.c b/sqlite3.c | ||
| 20 | index 0b979f7a7d..27bea6f2e0 100644 | ||
| 21 | --- a/sqlite3.c | ||
| 22 | +++ b/sqlite3.c | ||
| 23 | @@ -169267,17 +169267,22 @@ SQLITE_API int sqlite3_config(int op, ...){ | ||
| 24 | ** If lookaside is already active, return SQLITE_BUSY. | ||
| 25 | ** | ||
| 26 | ** The sz parameter is the number of bytes in each lookaside slot. | ||
| 27 | -** The cnt parameter is the number of slots. If pStart is NULL the | ||
| 28 | -** space for the lookaside memory is obtained from sqlite3_malloc(). | ||
| 29 | -** If pStart is not NULL then it is sz*cnt bytes of memory to use for | ||
| 30 | -** the lookaside memory. | ||
| 31 | +** The cnt parameter is the number of slots. If pBuf is NULL the | ||
| 32 | +** space for the lookaside memory is obtained from sqlite3_malloc() | ||
| 33 | +** or similar. If pBuf is not NULL then it is sz*cnt bytes of memory | ||
| 34 | +** to use for the lookaside memory. | ||
| 35 | */ | ||
| 36 | -static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ | ||
| 37 | +static int setupLookaside( | ||
| 38 | + sqlite3 *db, /* Database connection being configured */ | ||
| 39 | + void *pBuf, /* Memory to use for lookaside. May be NULL */ | ||
| 40 | + int sz, /* Desired size of each lookaside memory slot */ | ||
| 41 | + int cnt /* Number of slots to allocate */ | ||
| 42 | +){ | ||
| 43 | #ifndef SQLITE_OMIT_LOOKASIDE | ||
| 44 | - void *pStart; | ||
| 45 | - sqlite3_int64 szAlloc = sz*(sqlite3_int64)cnt; | ||
| 46 | - int nBig; /* Number of full-size slots */ | ||
| 47 | - int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */ | ||
| 48 | + void *pStart; /* Start of the lookaside buffer */ | ||
| 49 | + sqlite3_int64 szAlloc; /* Total space set aside for lookaside memory */ | ||
| 50 | + int nBig; /* Number of full-size slots */ | ||
| 51 | + int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */ | ||
| 52 | |||
| 53 | if( sqlite3LookasideUsed(db,0)>0 ){ | ||
| 54 | return SQLITE_BUSY; | ||
| 55 | @@ -169290,17 +169295,22 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ | ||
| 56 | sqlite3_free(db->lookaside.pStart); | ||
| 57 | } | ||
| 58 | /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger | ||
| 59 | - ** than a pointer to be useful. | ||
| 60 | + ** than a pointer and small enough to fit in a u16. | ||
| 61 | */ | ||
| 62 | - sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */ | ||
| 63 | + sz = ROUNDDOWN8(sz); | ||
| 64 | if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0; | ||
| 65 | - if( cnt<0 ) cnt = 0; | ||
| 66 | - if( sz==0 || cnt==0 ){ | ||
| 67 | + if( sz>65528 ) sz = 65528; | ||
| 68 | + /* Count must be at least 1 to be useful, but not so large as to use | ||
| 69 | + ** more than 0x7fff0000 total bytes for lookaside. */ | ||
| 70 | + if( cnt<1 ) cnt = 0; | ||
| 71 | + if( sz>0 && cnt>(0x7fff0000/sz) ) cnt = 0x7fff0000/sz; | ||
| 72 | + szAlloc = (i64)sz*(i64)cnt; | ||
| 73 | + if( szAlloc==0 ){ | ||
| 74 | sz = 0; | ||
| 75 | pStart = 0; | ||
| 76 | }else if( pBuf==0 ){ | ||
| 77 | sqlite3BeginBenignMalloc(); | ||
| 78 | - pStart = sqlite3Malloc( szAlloc ); /* IMP: R-61949-35727 */ | ||
| 79 | + pStart = sqlite3Malloc( szAlloc ); | ||
| 80 | sqlite3EndBenignMalloc(); | ||
| 81 | if( pStart ) szAlloc = sqlite3MallocSize(pStart); | ||
| 82 | }else{ | ||
| 83 | @@ -169309,10 +169319,10 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ | ||
| 84 | #ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE | ||
| 85 | if( sz>=LOOKASIDE_SMALL*3 ){ | ||
| 86 | nBig = szAlloc/(3*LOOKASIDE_SMALL+sz); | ||
| 87 | - nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL; | ||
| 88 | + nSm = (szAlloc - (i64)sz*(i64)nBig)/LOOKASIDE_SMALL; | ||
| 89 | }else if( sz>=LOOKASIDE_SMALL*2 ){ | ||
| 90 | nBig = szAlloc/(LOOKASIDE_SMALL+sz); | ||
| 91 | - nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL; | ||
| 92 | + nSm = (szAlloc - (i64)sz*(i64)nBig)/LOOKASIDE_SMALL; | ||
| 93 | }else | ||
| 94 | #endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ | ||
| 95 | if( sz>0 ){ | ||
| 96 | diff --git a/sqlite3.h b/sqlite3.h | ||
| 97 | index de393da9dc..04e6b616d5 100644 | ||
| 98 | --- a/sqlite3.h | ||
| 99 | +++ b/sqlite3.h | ||
| 100 | @@ -1914,13 +1914,16 @@ struct sqlite3_mem_methods { | ||
| 101 | ** | ||
| 102 | ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt> | ||
| 103 | ** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine | ||
| 104 | -** the default size of lookaside memory on each [database connection]. | ||
| 105 | +** the default size of [lookaside memory] on each [database connection]. | ||
| 106 | ** The first argument is the | ||
| 107 | -** size of each lookaside buffer slot and the second is the number of | ||
| 108 | -** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE | ||
| 109 | -** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] | ||
| 110 | -** option to [sqlite3_db_config()] can be used to change the lookaside | ||
| 111 | -** configuration on individual connections.)^ </dd> | ||
| 112 | +** size of each lookaside buffer slot ("sz") and the second is the number of | ||
| 113 | +** slots allocated to each database connection ("cnt").)^ | ||
| 114 | +** ^(SQLITE_CONFIG_LOOKASIDE sets the <i>default</i> lookaside size. | ||
| 115 | +** The [SQLITE_DBCONFIG_LOOKASIDE] option to [sqlite3_db_config()] can | ||
| 116 | +** be used to change the lookaside configuration on individual connections.)^ | ||
| 117 | +** The [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to change the | ||
| 118 | +** default lookaside configuration at compile-time. | ||
| 119 | +** </dd> | ||
| 120 | ** | ||
| 121 | ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt> | ||
| 122 | ** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is | ||
| 123 | @@ -2133,24 +2136,43 @@ struct sqlite3_mem_methods { | ||
| 124 | ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt> | ||
| 125 | ** <dd> ^This option takes three additional arguments that determine the | ||
| 126 | ** [lookaside memory allocator] configuration for the [database connection]. | ||
| 127 | -** ^The first argument (the third parameter to [sqlite3_db_config()] is a | ||
| 128 | +** <ol> | ||
| 129 | +** <li><p>The first argument ("buf") is a | ||
| 130 | ** pointer to a memory buffer to use for lookaside memory. | ||
| 131 | -** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb | ||
| 132 | -** may be NULL in which case SQLite will allocate the | ||
| 133 | -** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the | ||
| 134 | -** size of each lookaside buffer slot. ^The third argument is the number of | ||
| 135 | -** slots. The size of the buffer in the first argument must be greater than | ||
| 136 | -** or equal to the product of the second and third arguments. The buffer | ||
| 137 | -** must be aligned to an 8-byte boundary. ^If the second argument to | ||
| 138 | -** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally | ||
| 139 | -** rounded down to the next smaller multiple of 8. ^(The lookaside memory | ||
| 140 | +** The first argument may be NULL in which case SQLite will allocate the | ||
| 141 | +** lookaside buffer itself using [sqlite3_malloc()]. | ||
| 142 | +** <li><P>The second argument ("sz") is the | ||
| 143 | +** size of each lookaside buffer slot. Lookaside is disabled if "sz" | ||
| 144 | +** is less than 8. The "sz" argument should be a multiple of 8 less than | ||
| 145 | +** 65536. If "sz" does not meet this constraint, it is reduced in size until | ||
| 146 | +** it does. | ||
| 147 | +** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled | ||
| 148 | +** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so | ||
| 149 | +** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt" | ||
| 150 | +** parameter is usually chosen so that the product of "sz" and "cnt" is less | ||
| 151 | +** than 1,000,000. | ||
| 152 | +** </ol> | ||
| 153 | +** <p>If the "buf" argument is not NULL, then it must | ||
| 154 | +** point to a memory buffer with a size that is greater than | ||
| 155 | +** or equal to the product of "sz" and "cnt". | ||
| 156 | +** The buffer must be aligned to an 8-byte boundary. | ||
| 157 | +** The lookaside memory | ||
| 158 | ** configuration for a database connection can only be changed when that | ||
| 159 | ** connection is not currently using lookaside memory, or in other words | ||
| 160 | -** when the "current value" returned by | ||
| 161 | -** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. | ||
| 162 | +** when the value returned by [SQLITE_DBSTATUS_LOOKASIDE_USED] is zero. | ||
| 163 | ** Any attempt to change the lookaside memory configuration when lookaside | ||
| 164 | ** memory is in use leaves the configuration unchanged and returns | ||
| 165 | -** [SQLITE_BUSY].)^</dd> | ||
| 166 | +** [SQLITE_BUSY]. | ||
| 167 | +** If the "buf" argument is NULL and an attempt | ||
| 168 | +** to allocate memory based on "sz" and "cnt" fails, then | ||
| 169 | +** lookaside is silently disabled. | ||
| 170 | +** <p> | ||
| 171 | +** The [SQLITE_CONFIG_LOOKASIDE] configuration option can be used to set the | ||
| 172 | +** default lookaside configuration at initialization. The | ||
| 173 | +** [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to set the default lookaside | ||
| 174 | +** configuration at compile-time. Typical values for lookaside are 1200 for | ||
| 175 | +** "sz" and 40 to 100 for "cnt". | ||
| 176 | +** </dd> | ||
| 177 | ** | ||
| 178 | ** [[SQLITE_DBCONFIG_ENABLE_FKEY]] | ||
| 179 | ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt> | ||
diff --git a/meta/recipes-support/sqlite/sqlite3_3.38.5.bb b/meta/recipes-support/sqlite/sqlite3_3.38.5.bb index 0a7a136c53..f47a9871e2 100644 --- a/meta/recipes-support/sqlite/sqlite3_3.38.5.bb +++ b/meta/recipes-support/sqlite/sqlite3_3.38.5.bb | |||
| @@ -8,6 +8,7 @@ SRC_URI = "http://www.sqlite.org/2022/sqlite-autoconf-${SQLITE_PV}.tar.gz \ | |||
| 8 | file://CVE-2022-46908.patch \ | 8 | file://CVE-2022-46908.patch \ |
| 9 | file://CVE-2023-36191.patch \ | 9 | file://CVE-2023-36191.patch \ |
| 10 | file://CVE-2023-7104.patch \ | 10 | file://CVE-2023-7104.patch \ |
| 11 | file://CVE-2025-29088.patch \ | ||
| 11 | " | 12 | " |
| 12 | SRC_URI[sha256sum] = "5af07de982ba658fd91a03170c945f99c971f6955bc79df3266544373e39869c" | 13 | SRC_URI[sha256sum] = "5af07de982ba658fd91a03170c945f99c971f6955bc79df3266544373e39869c" |
| 13 | 14 | ||
