diff options
author | Peter Marko <peter.marko@siemens.com> | 2025-05-20 22:20:27 +0200 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2025-06-02 10:26:30 -0700 |
commit | 11c14e791bb540c8cb9c0943dd63420fa03277da (patch) | |
tree | 2b8cbccd0a7dc93aefdf95caf35b2d80410b93a1 | |
parent | 42f60f3fd10186fc22c8bae708ff82b254f8464f (diff) | |
download | poky-11c14e791bb540c8cb9c0943dd63420fa03277da.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: bf22e18843bf10418e7f8f182036eaf78de98413)
Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r-- | meta/recipes-support/sqlite/sqlite3/CVE-2025-29088.patch | 179 | ||||
-rw-r--r-- | meta/recipes-support/sqlite/sqlite3_3.48.0.bb | 1 |
2 files changed, 180 insertions, 0 deletions
diff --git a/meta/recipes-support/sqlite/sqlite3/CVE-2025-29088.patch b/meta/recipes-support/sqlite/sqlite3/CVE-2025-29088.patch new file mode 100644 index 0000000000..12a025fdd8 --- /dev/null +++ b/meta/recipes-support/sqlite/sqlite3/CVE-2025-29088.patch | |||
@@ -0,0 +1,179 @@ | |||
1 | From 57d1e61dda969659f59a0b7841c7d0287d724bc6 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 24d0d954d9..2574a43f3e 100644 | ||
21 | --- a/sqlite3.c | ||
22 | +++ b/sqlite3.c | ||
23 | @@ -182001,17 +182001,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 | @@ -182024,17 +182029,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 | @@ -182043,10 +182053,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 2618b37a7b..056511f577 100644 | ||
98 | --- a/sqlite3.h | ||
99 | +++ b/sqlite3.h | ||
100 | @@ -1989,13 +1989,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 | @@ -2225,24 +2228,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_DBSTATUS_LOOKASIDE_USED],...) 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.48.0.bb b/meta/recipes-support/sqlite/sqlite3_3.48.0.bb index 86983f21bd..11f103dddc 100644 --- a/meta/recipes-support/sqlite/sqlite3_3.48.0.bb +++ b/meta/recipes-support/sqlite/sqlite3_3.48.0.bb | |||
@@ -5,6 +5,7 @@ LIC_FILES_CHKSUM = "file://sqlite3.h;endline=11;md5=786d3dc581eff03f4fd9e4a77ed0 | |||
5 | 5 | ||
6 | SRC_URI = "http://www.sqlite.org/2025/sqlite-autoconf-${SQLITE_PV}.tar.gz \ | 6 | SRC_URI = "http://www.sqlite.org/2025/sqlite-autoconf-${SQLITE_PV}.tar.gz \ |
7 | file://CVE-2025-3277.patch \ | 7 | file://CVE-2025-3277.patch \ |
8 | file://CVE-2025-29088.patch \ | ||
8 | " | 9 | " |
9 | SRC_URI[sha256sum] = "ac992f7fca3989de7ed1fe99c16363f848794c8c32a158dafd4eb927a2e02fd5" | 10 | SRC_URI[sha256sum] = "ac992f7fca3989de7ed1fe99c16363f848794c8c32a158dafd4eb927a2e02fd5" |
10 | 11 | ||