mirror of
https://git.yoctoproject.org/poky
synced 2026-02-22 09:29:40 +01:00
Compare commits
120 Commits
dunfell-23
...
yocto-3.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bba3233897 | ||
|
|
d752cbcbbe | ||
|
|
2bfe7e096d | ||
|
|
e256885889 | ||
|
|
c72a9d0a6d | ||
|
|
744c593c3d | ||
|
|
243f90cb86 | ||
|
|
ab23ceac12 | ||
|
|
dadebc61f4 | ||
|
|
f439e82404 | ||
|
|
ce2db1116c | ||
|
|
8c58e222ea | ||
|
|
b618e57f79 | ||
|
|
95491a12ea | ||
|
|
6348d2d8a0 | ||
|
|
7a4fa28642 | ||
|
|
1e4665204b | ||
|
|
07755db699 | ||
|
|
e1f86e7761 | ||
|
|
2be5df9182 | ||
|
|
192834adc0 | ||
|
|
6ec2230291 | ||
|
|
ee62d4540e | ||
|
|
ee9345f864 | ||
|
|
34ba446157 | ||
|
|
4a14c922d8 | ||
|
|
cbc25057f1 | ||
|
|
3432003435 | ||
|
|
e2aa712775 | ||
|
|
d62ff88963 | ||
|
|
6a3354025c | ||
|
|
c1599e44e1 | ||
|
|
cfd64997c4 | ||
|
|
5457198984 | ||
|
|
b72fe527c9 | ||
|
|
9e75884e0a | ||
|
|
468588819e | ||
|
|
2b65abb255 | ||
|
|
e1fbe6c4a3 | ||
|
|
c55481b806 | ||
|
|
6e6ede294c | ||
|
|
0490ee5944 | ||
|
|
ee0220a2bb | ||
|
|
56e9d560b0 | ||
|
|
98d21218fc | ||
|
|
846e457b35 | ||
|
|
8a1fc484cc | ||
|
|
b2c0b6caf9 | ||
|
|
d19c2eba98 | ||
|
|
f06e7a026d | ||
|
|
4750894a6a | ||
|
|
3e9902aa6c | ||
|
|
11880c6987 | ||
|
|
1e13a3f914 | ||
|
|
9564dc31cb | ||
|
|
bd07080415 | ||
|
|
f4a6761f47 | ||
|
|
30231b2354 | ||
|
|
795339092f | ||
|
|
38793eecda | ||
|
|
25e51ec82a | ||
|
|
963a35872c | ||
|
|
75dde71fba | ||
|
|
9bb220ccc1 | ||
|
|
b8623317df | ||
|
|
8967fcbcc4 | ||
|
|
22767ef398 | ||
|
|
ec21b227cd | ||
|
|
947e5ff11c | ||
|
|
56485d82f6 | ||
|
|
80306758c6 | ||
|
|
bdfabf0409 | ||
|
|
cf5a00721f | ||
|
|
02bd7ece75 | ||
|
|
69f5804c8a | ||
|
|
11d99fba1f | ||
|
|
746b301d37 | ||
|
|
038e25aec3 | ||
|
|
1a6bf73119 | ||
|
|
57b3bf09e1 | ||
|
|
fc34eadb56 | ||
|
|
652e053d0c | ||
|
|
215a1a8237 | ||
|
|
3a71f5c1bf | ||
|
|
643c3b7bf3 | ||
|
|
80132fb2df | ||
|
|
0e5c82c4c9 | ||
|
|
15d764e697 | ||
|
|
1f2cf291e7 | ||
|
|
090075eb3a | ||
|
|
d875c5e57b | ||
|
|
f18d2289d0 | ||
|
|
de97f0eccc | ||
|
|
104c0e6938 | ||
|
|
8ee284f8b2 | ||
|
|
46f68b5121 | ||
|
|
e24afc304a | ||
|
|
22c84eea24 | ||
|
|
6e1c3966d1 | ||
|
|
44ce6c4a5d | ||
|
|
e1e7e3c7ba | ||
|
|
89a0148b50 | ||
|
|
47d6478126 | ||
|
|
30b0a2e1c5 | ||
|
|
82b03a6837 | ||
|
|
e006c87e22 | ||
|
|
1a5fb730ac | ||
|
|
3d9e8146d0 | ||
|
|
695c0cd680 | ||
|
|
8821203873 | ||
|
|
0beeed7d25 | ||
|
|
409df675a8 | ||
|
|
b2089f012a | ||
|
|
e4e3cfdf9c | ||
|
|
9071e52286 | ||
|
|
7b8020e282 | ||
|
|
37cc520f28 | ||
|
|
349e53d3cc | ||
|
|
1db38c5a18 | ||
|
|
b409a428c1 |
@@ -6,24 +6,24 @@ of OpenEmbedded. It is distro-less (can build a functional image with
|
||||
DISTRO = "nodistro") and contains only emulated machine support.
|
||||
|
||||
For information about OpenEmbedded, see the OpenEmbedded website:
|
||||
http://www.openembedded.org/
|
||||
https://www.openembedded.org/
|
||||
|
||||
The Yocto Project has extensive documentation about OE including a reference manual
|
||||
which can be found at:
|
||||
http://yoctoproject.org/documentation
|
||||
https://docs.yoctoproject.org/
|
||||
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Please refer to
|
||||
http://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded
|
||||
https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded
|
||||
for guidelines on how to submit patches.
|
||||
|
||||
Mailing list:
|
||||
|
||||
http://lists.openembedded.org/mailman/listinfo/openembedded-core
|
||||
https://lists.openembedded.org/g/openembedded-core
|
||||
|
||||
Source code:
|
||||
|
||||
http://git.openembedded.org/openembedded-core/
|
||||
https://git.openembedded.org/openembedded-core/
|
||||
|
||||
@@ -74,8 +74,12 @@ class Command:
|
||||
result = command_method(self, commandline)
|
||||
except CommandError as exc:
|
||||
return None, exc.args[0]
|
||||
except (Exception, SystemExit):
|
||||
except (Exception, SystemExit) as exc:
|
||||
import traceback
|
||||
if isinstance(exc, bb.BBHandledException):
|
||||
# We need to start returning real exceptions here. Until we do, we can't
|
||||
# tell if an exception is an instance of bb.BBHandledException
|
||||
return None, "bb.BBHandledException()\n" + traceback.format_exc()
|
||||
return None, traceback.format_exc()
|
||||
else:
|
||||
return result, None
|
||||
@@ -620,6 +624,16 @@ class CommandsAsync:
|
||||
command.finishAsyncCommand()
|
||||
findFilesMatchingInDir.needcache = False
|
||||
|
||||
def testCookerCommandEvent(self, command, params):
|
||||
"""
|
||||
Dummy command used by OEQA selftest to test tinfoil without IO
|
||||
"""
|
||||
pattern = params[0]
|
||||
|
||||
command.cooker.testCookerCommandEvent(pattern)
|
||||
command.finishAsyncCommand()
|
||||
testCookerCommandEvent.needcache = False
|
||||
|
||||
def findConfigFilePath(self, command, params):
|
||||
"""
|
||||
Find the path of the requested configuration file
|
||||
|
||||
@@ -411,6 +411,8 @@ class BBCooker:
|
||||
self.data.disableTracking()
|
||||
|
||||
def parseConfiguration(self):
|
||||
self.updateCacheSync()
|
||||
|
||||
# Change nice level if we're asked to
|
||||
nice = self.data.getVar("BB_NICE_LEVEL")
|
||||
if nice:
|
||||
@@ -1017,6 +1019,11 @@ class BBCooker:
|
||||
if matches:
|
||||
bb.event.fire(bb.event.FilesMatchingFound(filepattern, matches), self.data)
|
||||
|
||||
def testCookerCommandEvent(self, filepattern):
|
||||
# Dummy command used by OEQA selftest to test tinfoil without IO
|
||||
matches = ["A", "B"]
|
||||
bb.event.fire(bb.event.FilesMatchingFound(filepattern, matches), self.data)
|
||||
|
||||
def findProviders(self, mc=''):
|
||||
return bb.providers.findProviders(self.databuilder.mcdata[mc], self.recipecaches[mc], self.recipecaches[mc].pkg_pn)
|
||||
|
||||
|
||||
@@ -348,7 +348,12 @@ class ServerCommunicator():
|
||||
logger.info("No reply from server in 30s")
|
||||
if not self.recv.poll(30):
|
||||
raise ProcessTimeout("Timeout while waiting for a reply from the bitbake server (60s)")
|
||||
return self.recv.get()
|
||||
ret, exc = self.recv.get()
|
||||
# Should probably turn all exceptions in exc back into exceptions?
|
||||
# For now, at least handle BBHandledException
|
||||
if exc and "BBHandledException" in exc:
|
||||
raise bb.BBHandledException()
|
||||
return ret, exc
|
||||
|
||||
def updateFeatureSet(self, featureset):
|
||||
_, error = self.runCommand(["setFeatures", featureset])
|
||||
|
||||
@@ -1290,9 +1290,6 @@ class FetchCheckStatusTest(FetcherTest):
|
||||
"http://downloads.yoctoproject.org/releases/opkg/opkg-0.1.7.tar.gz",
|
||||
"http://downloads.yoctoproject.org/releases/opkg/opkg-0.3.0.tar.gz",
|
||||
"ftp://sourceware.org/pub/libffi/libffi-1.20.tar.gz",
|
||||
"http://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz",
|
||||
"https://ftp.gnu.org/gnu/chess/gnuchess-5.08.tar.gz",
|
||||
"https://ftp.gnu.org/gnu/gmp/gmp-4.0.tar.gz",
|
||||
# GitHub releases are hosted on Amazon S3, which doesn't support HEAD
|
||||
"https://github.com/kergoth/tslib/releases/download/1.1/tslib-1.1.tar.xz"
|
||||
]
|
||||
|
||||
@@ -465,7 +465,16 @@ class Tinfoil:
|
||||
commandline = [command]
|
||||
if params:
|
||||
commandline.extend(params)
|
||||
result = self.server_connection.connection.runCommand(commandline)
|
||||
try:
|
||||
result = self.server_connection.connection.runCommand(commandline)
|
||||
finally:
|
||||
while True:
|
||||
event = self.wait_event()
|
||||
if not event:
|
||||
break
|
||||
if isinstance(event, logging.LogRecord):
|
||||
if event.taskpid == 0 or event.levelno > logging.INFO:
|
||||
self.logger.handle(event)
|
||||
if result[1]:
|
||||
raise TinfoilCommandFailed(result[1])
|
||||
return result[0]
|
||||
|
||||
@@ -380,14 +380,27 @@ _evt_list = [ "bb.runqueue.runQueueExitWait", "bb.event.LogExecTTY", "logging.Lo
|
||||
"bb.event.BuildBase", "bb.build.TaskStarted", "bb.build.TaskSucceeded", "bb.build.TaskFailedSilent",
|
||||
"bb.build.TaskProgress", "bb.event.ProcessStarted", "bb.event.ProcessProgress", "bb.event.ProcessFinished"]
|
||||
|
||||
def drain_events_errorhandling(eventHandler):
|
||||
# We don't have logging setup, we do need to show any events we see before exiting
|
||||
event = True
|
||||
logger = bb.msg.logger_create('bitbake', sys.stdout)
|
||||
while event:
|
||||
event = eventHandler.waitEvent(0)
|
||||
if isinstance(event, logging.LogRecord):
|
||||
logger.handle(event)
|
||||
|
||||
def main(server, eventHandler, params, tf = TerminalFilter):
|
||||
|
||||
if not params.observe_only:
|
||||
params.updateToServer(server, os.environ.copy())
|
||||
try:
|
||||
if not params.observe_only:
|
||||
params.updateToServer(server, os.environ.copy())
|
||||
|
||||
includelogs, loglines, consolelogfile, logconfigfile = _log_settings_from_server(server, params.observe_only)
|
||||
includelogs, loglines, consolelogfile, logconfigfile = _log_settings_from_server(server, params.observe_only)
|
||||
|
||||
loglevel, _ = bb.msg.constructLogOptions()
|
||||
loglevel, _ = bb.msg.constructLogOptions()
|
||||
except bb.BBHandledException:
|
||||
drain_events_errorhandling(eventHandler)
|
||||
return 1
|
||||
|
||||
if params.options.quiet == 0:
|
||||
console_loglevel = loglevel
|
||||
|
||||
@@ -16,7 +16,8 @@ import bb.msg
|
||||
import multiprocessing
|
||||
import fcntl
|
||||
import importlib
|
||||
from importlib import machinery
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
import itertools
|
||||
import subprocess
|
||||
import glob
|
||||
@@ -1584,7 +1585,9 @@ def load_plugins(logger, plugins, pluginpath):
|
||||
logger.debug(1, 'Loading plugin %s' % name)
|
||||
spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] )
|
||||
if spec:
|
||||
return spec.loader.load_module()
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
return mod
|
||||
|
||||
logger.debug(1, 'Loading plugins from %s...' % pluginpath)
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ class ActionPlugin(LayerPlugin):
|
||||
if not (args.force or notadded):
|
||||
try:
|
||||
self.tinfoil.run_command('parseConfiguration')
|
||||
except bb.tinfoil.TinfoilUIException:
|
||||
except (bb.tinfoil.TinfoilUIException, bb.BBHandledException):
|
||||
# Restore the back up copy of bblayers.conf
|
||||
shutil.copy2(backup, bblayers_conf)
|
||||
bb.fatal("Parse failure with the specified layer added")
|
||||
bb.fatal("Parse failure with the specified layer added, aborting.")
|
||||
else:
|
||||
for item in notadded:
|
||||
sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item)
|
||||
|
||||
@@ -12,6 +12,7 @@ import math
|
||||
import os
|
||||
import signal
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
from . import chunkify, DEFAULT_MAX_CHUNK
|
||||
|
||||
@@ -419,9 +420,14 @@ class Server(object):
|
||||
self._cleanup_socket = None
|
||||
|
||||
def start_tcp_server(self, host, port):
|
||||
self.server = self.loop.run_until_complete(
|
||||
asyncio.start_server(self.handle_client, host, port)
|
||||
)
|
||||
if sys.version_info[0] == 3 and sys.version_info[1] < 6:
|
||||
self.server = self.loop.run_until_complete(
|
||||
asyncio.start_server(self.handle_client, host, port, loop=self.loop)
|
||||
)
|
||||
else:
|
||||
self.server = self.loop.run_until_complete(
|
||||
asyncio.start_server(self.handle_client, host, port)
|
||||
)
|
||||
|
||||
for s in self.server.sockets:
|
||||
logger.info('Listening on %r' % (s.getsockname(),))
|
||||
@@ -444,9 +450,14 @@ class Server(object):
|
||||
try:
|
||||
# Work around path length limits in AF_UNIX
|
||||
os.chdir(os.path.dirname(path))
|
||||
self.server = self.loop.run_until_complete(
|
||||
asyncio.start_unix_server(self.handle_client, os.path.basename(path))
|
||||
)
|
||||
if sys.version_info[0] == 3 and sys.version_info[1] < 6:
|
||||
self.server = self.loop.run_until_complete(
|
||||
asyncio.start_unix_server(self.handle_client, os.path.basename(path), loop=self.loop)
|
||||
)
|
||||
else:
|
||||
self.server = self.loop.run_until_complete(
|
||||
asyncio.start_unix_server(self.handle_client, os.path.basename(path))
|
||||
)
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ import os
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
current_version = "3.1.12"
|
||||
current_version = "3.1.13"
|
||||
bitbake_version = "1.46"
|
||||
|
||||
# String used in sidebar
|
||||
version = 'Version: ' + current_version
|
||||
@@ -82,7 +83,7 @@ extlinks = {
|
||||
|
||||
# Intersphinx config to use cross reference with Bitbake user manual
|
||||
intersphinx_mapping = {
|
||||
'bitbake': ('https://docs.yoctoproject.org/bitbake/1.46', None)
|
||||
'bitbake': ('https://docs.yoctoproject.org/bitbake/' + bitbake_version, None)
|
||||
}
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
DISTRO : "3.1.12"
|
||||
DISTRO : "3.1.13"
|
||||
DISTRO_NAME_NO_CAP : "dunfell"
|
||||
DISTRO_NAME : "Dunfell"
|
||||
DISTRO_NAME_NO_CAP_MINUS_ONE : "zeus"
|
||||
YOCTO_DOC_VERSION : "3.1.12"
|
||||
YOCTO_DOC_VERSION_MINUS_ONE : "3.0.2"
|
||||
DISTRO_REL_TAG : "yocto-3.1.12"
|
||||
POKYVERSION : "23.0.12"
|
||||
YOCTO_DOC_VERSION : "3.1.13"
|
||||
YOCTO_DOC_VERSION_MINUS_ONE : "3.0.4"
|
||||
DISTRO_REL_TAG : "yocto-3.1.13"
|
||||
POKYVERSION : "23.0.13"
|
||||
YOCTO_POKY : "poky-&DISTRO_NAME_NO_CAP;-&POKYVERSION;"
|
||||
YOCTO_DL_URL : "https://downloads.yoctoproject.org"
|
||||
YOCTO_AB_URL : "https://autobuilder.yoctoproject.org"
|
||||
|
||||
@@ -184,8 +184,7 @@ The following BitBake changes have occurred.
|
||||
exceptions. Remove this argument in any calls to
|
||||
``bb.build.exec_func()`` in custom classes or scripts.
|
||||
|
||||
- The
|
||||
:term:`bitbake:BB_SETSCENE_VERIFY_FUNCTION2`
|
||||
- The ``BB_SETSCENE_VERIFY_FUNCTION2`` variable
|
||||
is no longer used. In the unlikely event that you have any references
|
||||
to it, they should be removed.
|
||||
|
||||
|
||||
@@ -331,22 +331,19 @@ file as a patch file:
|
||||
file://file;apply=yes \
|
||||
"
|
||||
|
||||
Conversely, if you have a directory full of patch files and you want to
|
||||
exclude some so that the ``do_patch`` task does not apply them during
|
||||
the patch phase, you can use the "apply=no" parameter with the
|
||||
``SRC_URI`` statement:
|
||||
::
|
||||
Conversely, if you have a file whose file type is ``.patch`` or ``.diff``
|
||||
and you want to exclude it so that the ``do_patch`` task does not apply
|
||||
it during the patch phase, you can use the "apply=no" parameter with the
|
||||
:term:`SRC_URI` statement::
|
||||
|
||||
SRC_URI = " \
|
||||
git://path_to_repo/some_package \
|
||||
file://path_to_lots_of_patch_files \
|
||||
file://path_to_lots_of_patch_files/patch_file5;apply=no \
|
||||
file://file1.patch \
|
||||
file://file2.patch;apply=no \
|
||||
"
|
||||
|
||||
In the
|
||||
previous example, assuming all the files in the directory holding the
|
||||
patch files end with either ``.patch`` or ``.diff``, every file would be
|
||||
applied as a patch by default except for the ``patch_file5`` patch.
|
||||
In the previous example ``file1.patch`` would be applied as a patch by default
|
||||
while ``file2.patch`` would not be applied.
|
||||
|
||||
You can find out more about the patching process in the
|
||||
":ref:`patching-dev-environment`" section in
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
|
||||
|
||||
=========================
|
||||
Current Release Manuals
|
||||
=========================
|
||||
===========================
|
||||
Supported Release Manuals
|
||||
===========================
|
||||
|
||||
******************************
|
||||
Release Series 3.4 (honister)
|
||||
******************************
|
||||
|
||||
- :yocto_docs:`3.4 Documentation </3.4>`
|
||||
- :yocto_docs:`3.4.1 Documentation </3.4.1>`
|
||||
|
||||
******************************
|
||||
Release Series 3.3 (hardknott)
|
||||
******************************
|
||||
|
||||
- :yocto_docs:`3.3 Documentation </3.3>`
|
||||
- :yocto_docs:`3.3.1 Documentation </3.3.1>`
|
||||
- :yocto_docs:`3.3.2 Documentation </3.3.2>`
|
||||
- :yocto_docs:`3.3.3 Documentation </3.3.3>`
|
||||
- :yocto_docs:`3.3.4 Documentation </3.3.4>`
|
||||
|
||||
****************************
|
||||
3.1 'dunfell' Release Series
|
||||
Release Series 3.1 (dunfell)
|
||||
****************************
|
||||
|
||||
- :yocto_docs:`3.1 Documentation </3.1>`
|
||||
@@ -21,13 +38,24 @@
|
||||
- :yocto_docs:`3.1.10 Documentation </3.1.10>`
|
||||
- :yocto_docs:`3.1.11 Documentation </3.1.11>`
|
||||
- :yocto_docs:`3.1.12 Documentation </3.1.12>`
|
||||
- :yocto_docs:`3.1.13 Documentation </3.1.13>`
|
||||
|
||||
==========================
|
||||
Previous Release Manuals
|
||||
Outdated Release Manuals
|
||||
==========================
|
||||
|
||||
*******************************
|
||||
Release Series 3.2 (gatesgarth)
|
||||
*******************************
|
||||
|
||||
- :yocto_docs:`3.2 Documentation </3.2>`
|
||||
- :yocto_docs:`3.2.1 Documentation </3.2.1>`
|
||||
- :yocto_docs:`3.2.2 Documentation </3.2.2>`
|
||||
- :yocto_docs:`3.2.3 Documentation </3.2.3>`
|
||||
- :yocto_docs:`3.2.4 Documentation </3.2.4>`
|
||||
|
||||
*************************
|
||||
3.0 'zeus' Release Series
|
||||
Release Series 3.0 (zeus)
|
||||
*************************
|
||||
|
||||
- :yocto_docs:`3.0 Documentation </3.0>`
|
||||
@@ -37,7 +65,7 @@
|
||||
- :yocto_docs:`3.0.4 Documentation </3.0.4>`
|
||||
|
||||
****************************
|
||||
2.7 'warrior' Release Series
|
||||
Release Series 2.7 (warrior)
|
||||
****************************
|
||||
|
||||
- :yocto_docs:`2.7 Documentation </2.7>`
|
||||
@@ -47,7 +75,7 @@
|
||||
- :yocto_docs:`2.7.4 Documentation </2.7.4>`
|
||||
|
||||
*************************
|
||||
2.6 'thud' Release Series
|
||||
Release Series 2.6 (thud)
|
||||
*************************
|
||||
|
||||
- :yocto_docs:`2.6 Documentation </2.6>`
|
||||
@@ -57,16 +85,16 @@
|
||||
- :yocto_docs:`2.6.4 Documentation </2.6.4>`
|
||||
|
||||
*************************
|
||||
2.5 'sumo' Release Series
|
||||
Release Series 2.5 (sumo)
|
||||
*************************
|
||||
|
||||
- :yocto_docs:`2.5 Documentation </2.5>`
|
||||
- :yocto_docs:`2.5.1 Documentation </2.5.1>`
|
||||
- :yocto_docs:`2.5.2 Documentation </2.5.2>`
|
||||
- :yocto_docs:`2.5.3 Documentation </2.5.3>`
|
||||
|
||||
|
||||
**************************
|
||||
2.4 'rocko' Release Series
|
||||
Release Series 2.4 (rocko)
|
||||
**************************
|
||||
|
||||
- :yocto_docs:`2.4 Documentation </2.4>`
|
||||
@@ -76,7 +104,7 @@
|
||||
- :yocto_docs:`2.4.4 Documentation </2.4.4>`
|
||||
|
||||
*************************
|
||||
2.3 'pyro' Release Series
|
||||
Release Series 2.3 (pyro)
|
||||
*************************
|
||||
|
||||
- :yocto_docs:`2.3 Documentation </2.3>`
|
||||
@@ -86,7 +114,7 @@
|
||||
- :yocto_docs:`2.3.4 Documentation </2.3.4>`
|
||||
|
||||
**************************
|
||||
2.2 'morty' Release Series
|
||||
Release Series 2.2 (morty)
|
||||
**************************
|
||||
|
||||
- :yocto_docs:`2.2 Documentation </2.2>`
|
||||
@@ -95,7 +123,7 @@
|
||||
- :yocto_docs:`2.2.3 Documentation </2.2.3>`
|
||||
|
||||
****************************
|
||||
2.1 'krogoth' Release Series
|
||||
Release Series 2.1 (krogoth)
|
||||
****************************
|
||||
|
||||
- :yocto_docs:`2.1 Documentation </2.1>`
|
||||
@@ -104,7 +132,7 @@
|
||||
- :yocto_docs:`2.1.3 Documentation </2.1.3>`
|
||||
|
||||
***************************
|
||||
2.0 'jethro' Release Series
|
||||
Release Series 2.0 (jethro)
|
||||
***************************
|
||||
|
||||
- :yocto_docs:`1.9 Documentation </1.9>`
|
||||
@@ -114,7 +142,7 @@
|
||||
- :yocto_docs:`2.0.3 Documentation </2.0.3>`
|
||||
|
||||
*************************
|
||||
1.8 'fido' Release Series
|
||||
Release Series 1.8 (fido)
|
||||
*************************
|
||||
|
||||
- :yocto_docs:`1.8 Documentation </1.8>`
|
||||
@@ -122,7 +150,7 @@
|
||||
- :yocto_docs:`1.8.2 Documentation </1.8.2>`
|
||||
|
||||
**************************
|
||||
1.7 'dizzy' Release Series
|
||||
Release Series 1.7 (dizzy)
|
||||
**************************
|
||||
|
||||
- :yocto_docs:`1.7 Documentation </1.7>`
|
||||
@@ -131,16 +159,16 @@
|
||||
- :yocto_docs:`1.7.3 Documentation </1.7.3>`
|
||||
|
||||
**************************
|
||||
1.6 'daisy' Release Series
|
||||
Release Series 1.6 (daisy)
|
||||
**************************
|
||||
|
||||
- :yocto_docs:`1.6 Documentation </1.6>`
|
||||
- :yocto_docs:`1.6.1 Documentation </1.6.1>`
|
||||
- :yocto_docs:`1.6.2 Documentation </1.6.2>`
|
||||
- :yocto_docs:`1.6.3 Documentation </1.6.3>`
|
||||
|
||||
|
||||
*************************
|
||||
1.5 'dora' Release Series
|
||||
Release Series 1.5 (dora)
|
||||
*************************
|
||||
|
||||
- :yocto_docs:`1.5 Documentation </1.5>`
|
||||
@@ -150,7 +178,7 @@
|
||||
- :yocto_docs:`1.5.4 Documentation </1.5.4>`
|
||||
|
||||
**************************
|
||||
1.4 'dylan' Release Series
|
||||
Release Series 1.4 (dylan)
|
||||
**************************
|
||||
|
||||
- :yocto_docs:`1.4 Documentation </1.4>`
|
||||
@@ -159,9 +187,9 @@
|
||||
- :yocto_docs:`1.4.3 Documentation </1.4.3>`
|
||||
- :yocto_docs:`1.4.4 Documentation </1.4.4>`
|
||||
- :yocto_docs:`1.4.5 Documentation </1.4.5>`
|
||||
|
||||
|
||||
**************************
|
||||
1.3 'danny' Release Series
|
||||
Release Series 1.3 (danny)
|
||||
**************************
|
||||
|
||||
- :yocto_docs:`1.3 Documentation </1.3>`
|
||||
@@ -169,7 +197,7 @@
|
||||
- :yocto_docs:`1.3.2 Documentation </1.3.2>`
|
||||
|
||||
***************************
|
||||
1.2 'denzil' Release Series
|
||||
Release Series 1.2 (denzil)
|
||||
***************************
|
||||
|
||||
- :yocto_docs:`1.2 Documentation </1.2>`
|
||||
@@ -177,7 +205,7 @@
|
||||
- :yocto_docs:`1.2.2 Documentation </1.2.2>`
|
||||
|
||||
***************************
|
||||
1.1 'edison' Release Series
|
||||
Release Series 1.1 (edison)
|
||||
***************************
|
||||
|
||||
- :yocto_docs:`1.1 Documentation </1.1>`
|
||||
@@ -185,7 +213,7 @@
|
||||
- :yocto_docs:`1.1.2 Documentation </1.1.2>`
|
||||
|
||||
****************************
|
||||
1.0 'bernard' Release Series
|
||||
Release Series 1.0 (bernard)
|
||||
****************************
|
||||
|
||||
- :yocto_docs:`1.0 Documentation </1.0>`
|
||||
@@ -193,7 +221,7 @@
|
||||
- :yocto_docs:`1.0.2 Documentation </1.0.2>`
|
||||
|
||||
****************************
|
||||
0.9 'laverne' Release Series
|
||||
Release Series 0.9 (laverne)
|
||||
****************************
|
||||
|
||||
- :yocto_docs:`0.9 Documentation </0.9>`
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
'use strict';
|
||||
|
||||
var all_versions = {
|
||||
'dev': 'dev (3.3)',
|
||||
'3.1.12': '3.1.12',
|
||||
'dev': 'dev (3.5)',
|
||||
'3.4.1': '3.4.1',
|
||||
'3.3.4': '3.3.4',
|
||||
'3.2.4': '3.2.4',
|
||||
'3.1.13': '3.1.13',
|
||||
'3.0.4': '3.0.4',
|
||||
'2.7.4': '2.7.4',
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
DISTRO = "poky"
|
||||
DISTRO_NAME = "Poky (Yocto Project Reference Distro)"
|
||||
DISTRO_VERSION = "3.1.12"
|
||||
DISTRO_VERSION = "3.1.14"
|
||||
DISTRO_CODENAME = "dunfell"
|
||||
SDK_VENDOR = "-pokysdk"
|
||||
SDK_VERSION = "${@d.getVar('DISTRO_VERSION').replace('snapshot-${DATE}', 'snapshot')}"
|
||||
|
||||
@@ -7,8 +7,8 @@ KMACHINE_genericx86 ?= "common-pc"
|
||||
KMACHINE_genericx86-64 ?= "common-pc-64"
|
||||
KMACHINE_beaglebone-yocto ?= "beaglebone"
|
||||
|
||||
SRCREV_machine_genericx86 ?= "31db2b47ac7d8508080fbb7344399b501216de66"
|
||||
SRCREV_machine_genericx86-64 ?= "31db2b47ac7d8508080fbb7344399b501216de66"
|
||||
SRCREV_machine_genericx86 ?= "76404f1ae59698b6a446dba29c885ca78c69c330"
|
||||
SRCREV_machine_genericx86-64 ?= "76404f1ae59698b6a446dba29c885ca78c69c330"
|
||||
SRCREV_machine_edgerouter ?= "706efec4c1e270ec5dda92275898cd465dfdc7dd"
|
||||
SRCREV_machine_beaglebone-yocto ?= "706efec4c1e270ec5dda92275898cd465dfdc7dd"
|
||||
|
||||
@@ -17,7 +17,7 @@ COMPATIBLE_MACHINE_genericx86-64 = "genericx86-64"
|
||||
COMPATIBLE_MACHINE_edgerouter = "edgerouter"
|
||||
COMPATIBLE_MACHINE_beaglebone-yocto = "beaglebone-yocto"
|
||||
|
||||
LINUX_VERSION_genericx86 = "5.4.94"
|
||||
LINUX_VERSION_genericx86-64 = "5.4.94"
|
||||
LINUX_VERSION_genericx86 = "5.4.158"
|
||||
LINUX_VERSION_genericx86-64 = "5.4.158"
|
||||
LINUX_VERSION_edgerouter = "5.4.58"
|
||||
LINUX_VERSION_beaglebone-yocto = "5.4.58"
|
||||
|
||||
@@ -953,23 +953,19 @@ def write_latest_srcrev(d, pkghistdir):
|
||||
value = value.replace('"', '').strip()
|
||||
old_tag_srcrevs[key] = value
|
||||
with open(srcrevfile, 'w') as f:
|
||||
orig_srcrev = d.getVar('SRCREV', False) or 'INVALID'
|
||||
if orig_srcrev != 'INVALID':
|
||||
f.write('# SRCREV = "%s"\n' % orig_srcrev)
|
||||
if len(srcrevs) > 1:
|
||||
for name, srcrev in sorted(srcrevs.items()):
|
||||
orig_srcrev = d.getVar('SRCREV_%s' % name, False)
|
||||
if orig_srcrev:
|
||||
f.write('# SRCREV_%s = "%s"\n' % (name, orig_srcrev))
|
||||
f.write('SRCREV_%s = "%s"\n' % (name, srcrev))
|
||||
else:
|
||||
f.write('SRCREV = "%s"\n' % next(iter(srcrevs.values())))
|
||||
if len(tag_srcrevs) > 0:
|
||||
for name, srcrev in sorted(tag_srcrevs.items()):
|
||||
f.write('# tag_%s = "%s"\n' % (name, srcrev))
|
||||
if name in old_tag_srcrevs and old_tag_srcrevs[name] != srcrev:
|
||||
pkg = d.getVar('PN')
|
||||
bb.warn("Revision for tag %s in package %s was changed since last build (from %s to %s)" % (name, pkg, old_tag_srcrevs[name], srcrev))
|
||||
for name, srcrev in sorted(srcrevs.items()):
|
||||
suffix = "_" + name
|
||||
if name == "default":
|
||||
suffix = ""
|
||||
orig_srcrev = d.getVar('SRCREV%s' % suffix, False)
|
||||
if orig_srcrev:
|
||||
f.write('# SRCREV%s = "%s"\n' % (suffix, orig_srcrev))
|
||||
f.write('SRCREV%s = "%s"\n' % (suffix, srcrev))
|
||||
for name, srcrev in sorted(tag_srcrevs.items()):
|
||||
f.write('# tag_%s = "%s"\n' % (name, srcrev))
|
||||
if name in old_tag_srcrevs and old_tag_srcrevs[name] != srcrev:
|
||||
pkg = d.getVar('PN')
|
||||
bb.warn("Revision for tag %s in package %s was changed since last build (from %s to %s)" % (name, pkg, old_tag_srcrevs[name], srcrev))
|
||||
|
||||
else:
|
||||
if os.path.exists(srcrevfile):
|
||||
|
||||
@@ -110,7 +110,8 @@ python do_cve_check () {
|
||||
}
|
||||
|
||||
addtask cve_check before do_build after do_fetch
|
||||
do_cve_check[depends] = "cve-update-db-native:do_populate_cve_db"
|
||||
do_cve_check[lockfiles] += "${CVE_CHECK_DB_FILE_LOCK}"
|
||||
do_cve_check[depends] = "cve-update-db-native:do_fetch"
|
||||
do_cve_check[nostamp] = "1"
|
||||
|
||||
python cve_check_cleanup () {
|
||||
|
||||
@@ -315,8 +315,8 @@ do_package_write_deb[dirs] = "${PKGWRITEDIRDEB}"
|
||||
do_package_write_deb[cleandirs] = "${PKGWRITEDIRDEB}"
|
||||
do_package_write_deb[umask] = "022"
|
||||
do_package_write_deb[depends] += "${@oe.utils.build_depends_string(d.getVar('PACKAGE_WRITE_DEPS'), 'do_populate_sysroot')}"
|
||||
addtask package_write_deb after do_packagedata do_package
|
||||
|
||||
EPOCHTASK ??= ""
|
||||
addtask package_write_deb after do_packagedata do_package ${EPOCHTASK}
|
||||
|
||||
PACKAGEINDEXDEPS += "dpkg-native:do_populate_sysroot"
|
||||
PACKAGEINDEXDEPS += "apt-native:do_populate_sysroot"
|
||||
|
||||
@@ -274,7 +274,8 @@ do_package_write_ipk[dirs] = "${PKGWRITEDIRIPK}"
|
||||
do_package_write_ipk[cleandirs] = "${PKGWRITEDIRIPK}"
|
||||
do_package_write_ipk[umask] = "022"
|
||||
do_package_write_ipk[depends] += "${@oe.utils.build_depends_string(d.getVar('PACKAGE_WRITE_DEPS'), 'do_populate_sysroot')}"
|
||||
addtask package_write_ipk after do_packagedata do_package
|
||||
EPOCHTASK ??= ""
|
||||
addtask package_write_ipk after do_packagedata do_package ${EPOCHTASK}
|
||||
|
||||
PACKAGEINDEXDEPS += "opkg-utils-native:do_populate_sysroot"
|
||||
PACKAGEINDEXDEPS += "opkg-native:do_populate_sysroot"
|
||||
|
||||
@@ -743,7 +743,8 @@ do_package_write_rpm[dirs] = "${PKGWRITEDIRRPM}"
|
||||
do_package_write_rpm[cleandirs] = "${PKGWRITEDIRRPM}"
|
||||
do_package_write_rpm[umask] = "022"
|
||||
do_package_write_rpm[depends] += "${@oe.utils.build_depends_string(d.getVar('PACKAGE_WRITE_DEPS'), 'do_populate_sysroot')}"
|
||||
addtask package_write_rpm after do_packagedata do_package
|
||||
EPOCHTASK ??= ""
|
||||
addtask package_write_rpm after do_packagedata do_package ${EPOCHTASK}
|
||||
|
||||
PACKAGEINDEXDEPS += "rpm-native:do_populate_sysroot"
|
||||
PACKAGEINDEXDEPS += "createrepo-c-native:do_populate_sysroot"
|
||||
|
||||
@@ -106,6 +106,8 @@ python create_source_date_epoch_stamp() {
|
||||
os.rename(tmp_file, epochfile)
|
||||
}
|
||||
|
||||
EPOCHTASK = "do_deploy_source_date_epoch"
|
||||
|
||||
# Generate the stamp after do_unpack runs
|
||||
do_unpack[postfuncs] += "create_source_date_epoch_stamp"
|
||||
|
||||
|
||||
@@ -44,7 +44,14 @@ CVE_CHECK_WHITELIST += "CVE-2010-4756"
|
||||
# exposing this interface in an exploitable way
|
||||
CVE_CHECK_WHITELIST += "CVE-2020-29509 CVE-2020-29511"
|
||||
|
||||
|
||||
# db
|
||||
# Since Oracle relicensed bdb, the open source community is slowly but surely replacing bdb with
|
||||
# supported and open source friendly alternatives. As a result these CVEs are unlikely to ever be fixed.
|
||||
CVE_CHECK_WHITELIST += "CVE-2015-2583 CVE-2015-2624 CVE-2015-2626 CVE-2015-2640 CVE-2015-2654 \
|
||||
CVE-2015-2656 CVE-2015-4754 CVE-2015-4764 CVE-2015-4774 CVE-2015-4775 CVE-2015-4776 CVE-2015-4777 \
|
||||
CVE-2015-4778 CVE-2015-4779 CVE-2015-4780 CVE-2015-4781 CVE-2015-4782 CVE-2015-4783 CVE-2015-4784 \
|
||||
CVE-2015-4785 CVE-2015-4786 CVE-2015-4787 CVE-2015-4788 CVE-2015-4789 CVE-2015-4790 CVE-2016-0682 \
|
||||
CVE-2016-0689 CVE-2016-0692 CVE-2016-0694 CVE-2016-3418 CVE-2020-2981"
|
||||
|
||||
#### CPE update pending ####
|
||||
|
||||
|
||||
@@ -576,6 +576,7 @@ RECIPE_MAINTAINER_pn-python3 = "Oleksandr Kravchuk <open.source@oleksandr-kravch
|
||||
RECIPE_MAINTAINER_pn-python3-async = "Oleksandr Kravchuk <open.source@oleksandr-kravchuk.com>"
|
||||
RECIPE_MAINTAINER_pn-python3-dbus = "Oleksandr Kravchuk <open.source@oleksandr-kravchuk.com>"
|
||||
RECIPE_MAINTAINER_pn-python3-docutils = "Oleksandr Kravchuk <open.source@oleksandr-kravchuk.com>"
|
||||
RECIPE_MAINTAINER_pn-python3-dtschema-wrapper = "Bruce Ashfield <bruce.ashfield@gmail.com>"
|
||||
RECIPE_MAINTAINER_pn-python3-pycryptodome = "Joshua Watt <JPEWhacker@gmail.com>"
|
||||
RECIPE_MAINTAINER_pn-python3-pycryptodomex = "Joshua Watt <JPEWhacker@gmail.com>"
|
||||
RECIPE_MAINTAINER_pn-python3-extras = "Oleksandr Kravchuk <open.source@oleksandr-kravchuk.com>"
|
||||
|
||||
@@ -41,7 +41,7 @@ def find_git_folder(d, sourcedir):
|
||||
for root, dirs, files in os.walk(workdir, topdown=True):
|
||||
dirs[:] = [d for d in dirs if d not in exclude]
|
||||
if '.git' in dirs:
|
||||
return root
|
||||
return os.path.join(root, ".git")
|
||||
|
||||
bb.warn("Failed to find a git repository in WORKDIR: %s" % workdir)
|
||||
return None
|
||||
|
||||
@@ -10,7 +10,7 @@ from oeqa.core.decorator.depends import OETestDepends
|
||||
from oeqa.core.decorator.data import skipIfNotFeature
|
||||
|
||||
# need some kernel fragments
|
||||
# echo "KERNEL_FEATURES_append += \" features\/kernel\-sample\/kernel\-sample.scc\"" >> local.conf
|
||||
# echo "KERNEL_FEATURES_append = \" features\/kernel\-sample\/kernel\-sample.scc\"" >> local.conf
|
||||
class KSample(OERuntimeTestCase):
|
||||
def cmd_and_check(self, cmd='', match_string=''):
|
||||
status, output = self.target.run(cmd)
|
||||
|
||||
@@ -61,6 +61,8 @@ common_errors = [
|
||||
"[rdrand]: Initialization Failed",
|
||||
"[pulseaudio] authkey.c: Failed to open cookie file",
|
||||
"[pulseaudio] authkey.c: Failed to load authentication key",
|
||||
"was skipped because of a failed condition check",
|
||||
"was skipped because all trigger condition checks failed",
|
||||
]
|
||||
|
||||
video_related = [
|
||||
@@ -296,7 +298,7 @@ class ParseLogsTest(OERuntimeTestCase):
|
||||
grepcmd = 'grep '
|
||||
grepcmd += '-Ei "'
|
||||
for error in errors:
|
||||
grepcmd += '\<' + error + '\>' + '|'
|
||||
grepcmd += r'\<' + error + r'\>' + '|'
|
||||
grepcmd = grepcmd[:-1]
|
||||
grepcmd += '" ' + str(log) + " | grep -Eiv \'"
|
||||
|
||||
@@ -307,13 +309,13 @@ class ParseLogsTest(OERuntimeTestCase):
|
||||
errorlist = ignore_errors['default']
|
||||
|
||||
for ignore_error in errorlist:
|
||||
ignore_error = ignore_error.replace('(', '\(')
|
||||
ignore_error = ignore_error.replace(')', '\)')
|
||||
ignore_error = ignore_error.replace('(', r'\(')
|
||||
ignore_error = ignore_error.replace(')', r'\)')
|
||||
ignore_error = ignore_error.replace("'", '.')
|
||||
ignore_error = ignore_error.replace('?', '\?')
|
||||
ignore_error = ignore_error.replace('[', '\[')
|
||||
ignore_error = ignore_error.replace(']', '\]')
|
||||
ignore_error = ignore_error.replace('*', '\*')
|
||||
ignore_error = ignore_error.replace('?', r'\?')
|
||||
ignore_error = ignore_error.replace('[', r'\[')
|
||||
ignore_error = ignore_error.replace(']', r'\]')
|
||||
ignore_error = ignore_error.replace('*', r'\*')
|
||||
ignore_error = ignore_error.replace('0-9', '[0-9]')
|
||||
grepcmd += ignore_error + '|'
|
||||
grepcmd = grepcmd[:-1]
|
||||
|
||||
@@ -157,7 +157,7 @@ SSTATE_DIR = \"${TOPDIR}/download-selftest\"
|
||||
""")
|
||||
self.track_for_cleanup(os.path.join(self.builddir, "download-selftest"))
|
||||
|
||||
data = 'SRC_URI = "${GNU_MIRROR}/aspell/aspell-${PV}.tar.gz;downloadfilename=test-aspell.tar.gz"'
|
||||
data = 'SRC_URI = "https://downloads.yoctoproject.org/mirror/sources/aspell-${PV}.tar.gz;downloadfilename=test-aspell.tar.gz"'
|
||||
self.write_recipeinc('aspell', data)
|
||||
result = bitbake('-f -c fetch aspell', ignore_status=True)
|
||||
self.delete_recipeinc('aspell')
|
||||
|
||||
@@ -442,6 +442,7 @@ class DevtoolAddTests(DevtoolBase):
|
||||
tempdir = tempfile.mkdtemp(prefix='devtoolqa')
|
||||
self.track_for_cleanup(tempdir)
|
||||
url = 'gitsm://git.yoctoproject.org/mraa'
|
||||
url_branch = '%s;branch=master' % url
|
||||
checkrev = 'ae127b19a50aa54255e4330ccfdd9a5d058e581d'
|
||||
testrecipe = 'mraa'
|
||||
srcdir = os.path.join(tempdir, testrecipe)
|
||||
@@ -462,7 +463,7 @@ class DevtoolAddTests(DevtoolBase):
|
||||
checkvars = {}
|
||||
checkvars['S'] = '${WORKDIR}/git'
|
||||
checkvars['PV'] = '1.0+git${SRCPV}'
|
||||
checkvars['SRC_URI'] = url
|
||||
checkvars['SRC_URI'] = url_branch
|
||||
checkvars['SRCREV'] = '${AUTOREV}'
|
||||
self._test_recipe_contents(recipefile, checkvars, [])
|
||||
# Try with revision and version specified
|
||||
@@ -481,7 +482,7 @@ class DevtoolAddTests(DevtoolBase):
|
||||
checkvars = {}
|
||||
checkvars['S'] = '${WORKDIR}/git'
|
||||
checkvars['PV'] = '1.5+git${SRCPV}'
|
||||
checkvars['SRC_URI'] = url
|
||||
checkvars['SRC_URI'] = url_branch
|
||||
checkvars['SRCREV'] = checkrev
|
||||
self._test_recipe_contents(recipefile, checkvars, [])
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ USERADD_GID_TABLES += "files/static-group"
|
||||
def test_no_busybox_base_utils(self):
|
||||
config = """
|
||||
# Enable x11
|
||||
DISTRO_FEATURES_append += "x11"
|
||||
DISTRO_FEATURES_append = " x11"
|
||||
|
||||
# Switch to systemd
|
||||
DISTRO_FEATURES += "systemd"
|
||||
|
||||
@@ -179,6 +179,12 @@ class TestImage(OESelftestTestCase):
|
||||
self.skipTest('virgl isn\'t working with Debian 8')
|
||||
if distro and distro == 'centos-7':
|
||||
self.skipTest('virgl isn\'t working with Centos 7')
|
||||
if distro and distro == 'centos-8':
|
||||
self.skipTest('virgl isn\'t working with Centos 8')
|
||||
if distro and distro == 'fedora-34':
|
||||
self.skipTest('virgl isn\'t working with Fedora 34')
|
||||
if distro and distro == 'fedora-35':
|
||||
self.skipTest('virgl isn\'t working with Fedora 35')
|
||||
if distro and distro == 'opensuseleap-15.0':
|
||||
self.skipTest('virgl isn\'t working with Opensuse 15.0')
|
||||
|
||||
|
||||
@@ -94,16 +94,15 @@ class TinfoilTests(OESelftestTestCase):
|
||||
pass
|
||||
|
||||
pattern = 'conf'
|
||||
res = tinfoil.run_command('findFilesMatchingInDir', pattern, 'conf/machine')
|
||||
res = tinfoil.run_command('testCookerCommandEvent', pattern)
|
||||
self.assertTrue(res)
|
||||
|
||||
eventreceived = False
|
||||
commandcomplete = False
|
||||
start = time.time()
|
||||
# Wait for maximum 60s in total so we'd detect spurious heartbeat events for example
|
||||
# The test is IO load sensitive too
|
||||
# Wait for maximum 120s in total so we'd detect spurious heartbeat events for example
|
||||
while (not (eventreceived == True and commandcomplete == True)
|
||||
and (time.time() - start < 60)):
|
||||
and (time.time() - start < 120)):
|
||||
# if we received both events (on let's say a good day), we are done
|
||||
event = tinfoil.wait_event(1)
|
||||
if event:
|
||||
@@ -111,7 +110,8 @@ class TinfoilTests(OESelftestTestCase):
|
||||
commandcomplete = True
|
||||
elif isinstance(event, bb.event.FilesMatchingFound):
|
||||
self.assertEqual(pattern, event._pattern)
|
||||
self.assertIn('qemuarm.conf', event._matches)
|
||||
self.assertIn('A', event._matches)
|
||||
self.assertIn('B', event._matches)
|
||||
eventreceived = True
|
||||
elif isinstance(event, logging.LogRecord):
|
||||
continue
|
||||
|
||||
76
meta/recipes-bsp/grub/files/CVE-2020-14372.patch
Normal file
76
meta/recipes-bsp/grub/files/CVE-2020-14372.patch
Normal file
@@ -0,0 +1,76 @@
|
||||
From 0d237c0b90f0c6d4a3662c569b2371ae3ed69574 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 28 Sep 2020 20:08:41 +0200
|
||||
Subject: [PATCH] acpi: Don't register the acpi command when locked down
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The command is not allowed when lockdown is enforced. Otherwise an
|
||||
attacker can instruct the GRUB to load an SSDT table to overwrite
|
||||
the kernel lockdown configuration and later load and execute
|
||||
unsigned code.
|
||||
|
||||
Fixes: CVE-2020-14372
|
||||
|
||||
Reported-by: Máté Kukri <km@mkukri.xyz>
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=3e8e4c0549240fa209acffceb473e1e509b50c95]
|
||||
CVE: CVE-2020-14372
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
docs/grub.texi | 5 +++++
|
||||
grub-core/commands/acpi.c | 15 ++++++++-------
|
||||
2 files changed, 13 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/docs/grub.texi b/docs/grub.texi
|
||||
index 0786427..47ac7ff 100644
|
||||
--- a/docs/grub.texi
|
||||
+++ b/docs/grub.texi
|
||||
@@ -3986,6 +3986,11 @@ Normally, this command will replace the Root System Description Pointer
|
||||
(RSDP) in the Extended BIOS Data Area to point to the new tables. If the
|
||||
@option{--no-ebda} option is used, the new tables will be known only to
|
||||
GRUB, but may be used by GRUB's EFI emulation.
|
||||
+
|
||||
+Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}).
|
||||
+ Otherwise an attacker can instruct the GRUB to load an SSDT table to
|
||||
+ overwrite the kernel lockdown configuration and later load and execute
|
||||
+ unsigned code.
|
||||
@end deffn
|
||||
|
||||
|
||||
diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
|
||||
index 5a1499a..1215f2a 100644
|
||||
--- a/grub-core/commands/acpi.c
|
||||
+++ b/grub-core/commands/acpi.c
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <grub/mm.h>
|
||||
#include <grub/memory.h>
|
||||
#include <grub/i18n.h>
|
||||
+#include <grub/lockdown.h>
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
#include <grub/efi/efi.h>
|
||||
@@ -775,13 +776,13 @@ static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(acpi)
|
||||
{
|
||||
- cmd = grub_register_extcmd ("acpi", grub_cmd_acpi, 0,
|
||||
- N_("[-1|-2] [--exclude=TABLE1,TABLE2|"
|
||||
- "--load-only=TABLE1,TABLE2] FILE1"
|
||||
- " [FILE2] [...]"),
|
||||
- N_("Load host ACPI tables and tables "
|
||||
- "specified by arguments."),
|
||||
- options);
|
||||
+ cmd = grub_register_extcmd_lockdown ("acpi", grub_cmd_acpi, 0,
|
||||
+ N_("[-1|-2] [--exclude=TABLE1,TABLE2|"
|
||||
+ "--load-only=TABLE1,TABLE2] FILE1"
|
||||
+ " [FILE2] [...]"),
|
||||
+ N_("Load host ACPI tables and tables "
|
||||
+ "specified by arguments."),
|
||||
+ options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(acpi)
|
||||
130
meta/recipes-bsp/grub/files/CVE-2020-14372_1.patch
Normal file
130
meta/recipes-bsp/grub/files/CVE-2020-14372_1.patch
Normal file
@@ -0,0 +1,130 @@
|
||||
From fe7a13df6200bda934fcc0246458df249f1ef4f2 Mon Sep 17 00:00:00 2001
|
||||
From: Marco A Benatto <mbenatto@redhat.com>
|
||||
Date: Wed, 23 Sep 2020 11:33:33 -0400
|
||||
Subject: [PATCH] verifiers: Move verifiers API to kernel image
|
||||
|
||||
Move verifiers API from a module to the kernel image, so it can be
|
||||
used there as well. There are no functional changes in this patch.
|
||||
|
||||
Signed-off-by: Marco A Benatto <mbenatto@redhat.com>
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=9e95f45ceeef36fcf93cbfffcf004276883dbc99]
|
||||
CVE: CVE-2020-14372
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/Makefile.am | 1 +
|
||||
grub-core/Makefile.core.def | 6 +-----
|
||||
grub-core/kern/main.c | 4 ++++
|
||||
grub-core/{commands => kern}/verifiers.c | 8 ++------
|
||||
include/grub/verify.h | 9 ++++++---
|
||||
5 files changed, 14 insertions(+), 14 deletions(-)
|
||||
rename grub-core/{commands => kern}/verifiers.c (97%)
|
||||
|
||||
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
|
||||
index 3ea8e7f..375c30d 100644
|
||||
--- a/grub-core/Makefile.am
|
||||
+++ b/grub-core/Makefile.am
|
||||
@@ -90,6 +90,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
|
||||
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/verify.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
|
||||
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||||
index 474a63e..cff02f2 100644
|
||||
--- a/grub-core/Makefile.core.def
|
||||
+++ b/grub-core/Makefile.core.def
|
||||
@@ -140,6 +140,7 @@ kernel = {
|
||||
common = kern/rescue_parser.c;
|
||||
common = kern/rescue_reader.c;
|
||||
common = kern/term.c;
|
||||
+ common = kern/verifiers.c;
|
||||
|
||||
noemu = kern/compiler-rt.c;
|
||||
noemu = kern/mm.c;
|
||||
@@ -942,11 +943,6 @@ module = {
|
||||
cppflags = '-I$(srcdir)/lib/posix_wrap';
|
||||
};
|
||||
|
||||
-module = {
|
||||
- name = verifiers;
|
||||
- common = commands/verifiers.c;
|
||||
-};
|
||||
-
|
||||
module = {
|
||||
name = shim_lock;
|
||||
common = commands/efi/shim_lock.c;
|
||||
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
|
||||
index 9cad0c4..73967e2 100644
|
||||
--- a/grub-core/kern/main.c
|
||||
+++ b/grub-core/kern/main.c
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <grub/command.h>
|
||||
#include <grub/reader.h>
|
||||
#include <grub/parser.h>
|
||||
+#include <grub/verify.h>
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/memory.h>
|
||||
@@ -274,6 +275,9 @@ grub_main (void)
|
||||
grub_printf ("Welcome to GRUB!\n\n");
|
||||
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
|
||||
|
||||
+ /* Init verifiers API. */
|
||||
+ grub_verifiers_init ();
|
||||
+
|
||||
grub_load_config ();
|
||||
|
||||
grub_boot_time ("Before loading embedded modules.");
|
||||
diff --git a/grub-core/commands/verifiers.c b/grub-core/kern/verifiers.c
|
||||
similarity index 97%
|
||||
rename from grub-core/commands/verifiers.c
|
||||
rename to grub-core/kern/verifiers.c
|
||||
index 0dde481..aa3dc7c 100644
|
||||
--- a/grub-core/commands/verifiers.c
|
||||
+++ b/grub-core/kern/verifiers.c
|
||||
@@ -217,12 +217,8 @@ grub_verify_string (char *str, enum grub_verify_string_type type)
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
-GRUB_MOD_INIT(verifiers)
|
||||
+void
|
||||
+grub_verifiers_init (void)
|
||||
{
|
||||
grub_file_filter_register (GRUB_FILE_FILTER_VERIFY, grub_verifiers_open);
|
||||
}
|
||||
-
|
||||
-GRUB_MOD_FINI(verifiers)
|
||||
-{
|
||||
- grub_file_filter_unregister (GRUB_FILE_FILTER_VERIFY);
|
||||
-}
|
||||
diff --git a/include/grub/verify.h b/include/grub/verify.h
|
||||
index ea04914..cd129c3 100644
|
||||
--- a/include/grub/verify.h
|
||||
+++ b/include/grub/verify.h
|
||||
@@ -64,7 +64,10 @@ struct grub_file_verifier
|
||||
grub_err_t (*verify_string) (char *str, enum grub_verify_string_type type);
|
||||
};
|
||||
|
||||
-extern struct grub_file_verifier *grub_file_verifiers;
|
||||
+extern struct grub_file_verifier *EXPORT_VAR (grub_file_verifiers);
|
||||
+
|
||||
+extern void
|
||||
+grub_verifiers_init (void);
|
||||
|
||||
static inline void
|
||||
grub_verifier_register (struct grub_file_verifier *ver)
|
||||
@@ -78,7 +81,7 @@ grub_verifier_unregister (struct grub_file_verifier *ver)
|
||||
grub_list_remove (GRUB_AS_LIST (ver));
|
||||
}
|
||||
|
||||
-grub_err_t
|
||||
-grub_verify_string (char *str, enum grub_verify_string_type type);
|
||||
+extern grub_err_t
|
||||
+EXPORT_FUNC (grub_verify_string) (char *str, enum grub_verify_string_type type);
|
||||
|
||||
#endif /* ! GRUB_VERIFY_HEADER */
|
||||
431
meta/recipes-bsp/grub/files/CVE-2020-14372_2.patch
Normal file
431
meta/recipes-bsp/grub/files/CVE-2020-14372_2.patch
Normal file
@@ -0,0 +1,431 @@
|
||||
From d8aac4517fef0f0188a60a2a8ff9cafdd9c7ca42 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 28 Sep 2020 20:08:02 +0200
|
||||
Subject: [PATCH] kern: Add lockdown support
|
||||
|
||||
When the GRUB starts on a secure boot platform, some commands can be
|
||||
used to subvert the protections provided by the verification mechanism and
|
||||
could lead to booting untrusted system.
|
||||
|
||||
To prevent that situation, allow GRUB to be locked down. That way the code
|
||||
may check if GRUB has been locked down and further restrict the commands
|
||||
that are registered or what subset of their functionality could be used.
|
||||
|
||||
The lockdown support adds the following components:
|
||||
|
||||
* The grub_lockdown() function which can be used to lockdown GRUB if,
|
||||
e.g., UEFI Secure Boot is enabled.
|
||||
|
||||
* The grub_is_lockdown() function which can be used to check if the GRUB
|
||||
was locked down.
|
||||
|
||||
* A verifier that flags OS kernels, the GRUB modules, Device Trees and ACPI
|
||||
tables as GRUB_VERIFY_FLAGS_DEFER_AUTH to defer verification to other
|
||||
verifiers. These files are only successfully verified if another registered
|
||||
verifier returns success. Otherwise, the whole verification process fails.
|
||||
|
||||
For example, PE/COFF binaries verification can be done by the shim_lock
|
||||
verifier which validates the signatures using the shim_lock protocol.
|
||||
However, the verification is not deferred directly to the shim_lock verifier.
|
||||
The shim_lock verifier is hooked into the verification process instead.
|
||||
|
||||
* A set of grub_{command,extcmd}_lockdown functions that can be used by
|
||||
code registering command handlers, to only register unsafe commands if
|
||||
the GRUB has not been locked down.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=578c95298bcc46e0296f4c786db64c2ff26ce2cc]
|
||||
CVE: CVE-2020-14372
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
conf/Makefile.common | 2 +
|
||||
docs/grub-dev.texi | 27 +++++++++++++
|
||||
docs/grub.texi | 8 ++++
|
||||
grub-core/Makefile.am | 5 ++-
|
||||
grub-core/Makefile.core.def | 1 +
|
||||
grub-core/commands/extcmd.c | 23 +++++++++++
|
||||
grub-core/kern/command.c | 24 +++++++++++
|
||||
grub-core/kern/lockdown.c | 80 +++++++++++++++++++++++++++++++++++++
|
||||
include/grub/command.h | 5 +++
|
||||
include/grub/extcmd.h | 7 ++++
|
||||
include/grub/lockdown.h | 44 ++++++++++++++++++++
|
||||
11 files changed, 225 insertions(+), 1 deletion(-)
|
||||
create mode 100644 grub-core/kern/lockdown.c
|
||||
create mode 100644 include/grub/lockdown.h
|
||||
|
||||
diff --git a/conf/Makefile.common b/conf/Makefile.common
|
||||
index 6cd71cb..2a1a886 100644
|
||||
--- a/conf/Makefile.common
|
||||
+++ b/conf/Makefile.common
|
||||
@@ -84,7 +84,9 @@ CPPFLAGS_PARTTOOL_LIST = -Dgrub_parttool_register=PARTTOOL_LIST_MARKER
|
||||
CPPFLAGS_TERMINAL_LIST = '-Dgrub_term_register_input(...)=INPUT_TERMINAL_LIST_MARKER(__VA_ARGS__)'
|
||||
CPPFLAGS_TERMINAL_LIST += '-Dgrub_term_register_output(...)=OUTPUT_TERMINAL_LIST_MARKER(__VA_ARGS__)'
|
||||
CPPFLAGS_COMMAND_LIST = '-Dgrub_register_command(...)=COMMAND_LIST_MARKER(__VA_ARGS__)'
|
||||
+CPPFLAGS_COMMAND_LIST += '-Dgrub_register_command_lockdown(...)=COMMAND_LOCKDOWN_LIST_MARKER(__VA_ARGS__)'
|
||||
CPPFLAGS_COMMAND_LIST += '-Dgrub_register_extcmd(...)=EXTCOMMAND_LIST_MARKER(__VA_ARGS__)'
|
||||
+CPPFLAGS_COMMAND_LIST += '-Dgrub_register_extcmd_lockdown(...)=EXTCOMMAND_LOCKDOWN_LIST_MARKER(__VA_ARGS__)'
|
||||
CPPFLAGS_COMMAND_LIST += '-Dgrub_register_command_p1(...)=P1COMMAND_LIST_MARKER(__VA_ARGS__)'
|
||||
CPPFLAGS_FDT_LIST := '-Dgrub_fdtbus_register(...)=FDT_DRIVER_LIST_MARKER(__VA_ARGS__)'
|
||||
CPPFLAGS_MARKER = $(CPPFLAGS_FS_LIST) $(CPPFLAGS_VIDEO_LIST) \
|
||||
diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi
|
||||
index ee389fd..635ec72 100644
|
||||
--- a/docs/grub-dev.texi
|
||||
+++ b/docs/grub-dev.texi
|
||||
@@ -86,6 +86,7 @@ This edition documents version @value{VERSION}.
|
||||
* PFF2 Font File Format::
|
||||
* Graphical Menu Software Design::
|
||||
* Verifiers framework::
|
||||
+* Lockdown framework::
|
||||
* Copying This Manual:: Copying This Manual
|
||||
* Index::
|
||||
@end menu
|
||||
@@ -2086,6 +2087,32 @@ Optionally at the end of the file @samp{fini}, if it exists, is called with just
|
||||
the context. If you return no error during any of @samp{init}, @samp{write} and
|
||||
@samp{fini} then the file is considered as having succeded verification.
|
||||
|
||||
+@node Lockdown framework
|
||||
+@chapter Lockdown framework
|
||||
+
|
||||
+The GRUB can be locked down, which is a restricted mode where some operations
|
||||
+are not allowed. For instance, some commands cannot be used when the GRUB is
|
||||
+locked down.
|
||||
+
|
||||
+The function
|
||||
+@code{grub_lockdown()} is used to lockdown GRUB and the function
|
||||
+@code{grub_is_lockdown()} function can be used to check whether lockdown is
|
||||
+enabled or not. When enabled, the function returns @samp{GRUB_LOCKDOWN_ENABLED}
|
||||
+and @samp{GRUB_LOCKDOWN_DISABLED} when is not enabled.
|
||||
+
|
||||
+The following functions can be used to register the commands that can only be
|
||||
+used when lockdown is disabled:
|
||||
+
|
||||
+@itemize
|
||||
+
|
||||
+@item @code{grub_cmd_lockdown()} registers command which should not run when the
|
||||
+GRUB is in lockdown mode.
|
||||
+
|
||||
+@item @code{grub_cmd_lockdown()} registers extended command which should not run
|
||||
+when the GRUB is in lockdown mode.
|
||||
+
|
||||
+@end itemize
|
||||
+
|
||||
@node Copying This Manual
|
||||
@appendix Copying This Manual
|
||||
|
||||
diff --git a/docs/grub.texi b/docs/grub.texi
|
||||
index 8779507..d778bfb 100644
|
||||
--- a/docs/grub.texi
|
||||
+++ b/docs/grub.texi
|
||||
@@ -5581,6 +5581,7 @@ environment variables and commands are listed in the same order.
|
||||
* Using digital signatures:: Booting digitally signed code
|
||||
* UEFI secure boot and shim:: Booting digitally signed PE files
|
||||
* Measured Boot:: Measuring boot components
|
||||
+* Lockdown:: Lockdown when booting on a secure setup
|
||||
@end menu
|
||||
|
||||
@node Authentication and authorisation
|
||||
@@ -5794,6 +5795,13 @@ into @file{core.img} in order to avoid a potential gap in measurement between
|
||||
|
||||
Measured boot is currently only supported on EFI platforms.
|
||||
|
||||
+@node Lockdown
|
||||
+@section Lockdown when booting on a secure setup
|
||||
+
|
||||
+The GRUB can be locked down when booted on a secure boot environment, for example
|
||||
+if the UEFI secure boot is enabled. On a locked down configuration, the GRUB will
|
||||
+be restricted and some operations/commands cannot be executed.
|
||||
+
|
||||
@node Platform limitations
|
||||
@chapter Platform limitations
|
||||
|
||||
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
|
||||
index 375c30d..3096241 100644
|
||||
--- a/grub-core/Makefile.am
|
||||
+++ b/grub-core/Makefile.am
|
||||
@@ -79,6 +79,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fs.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
|
||||
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lockdown.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
|
||||
if COND_emu
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt-emu.h
|
||||
@@ -376,8 +377,10 @@ command.lst: $(MARKER_FILES)
|
||||
b=`basename $$pp .marker`; \
|
||||
sed -n \
|
||||
-e "/EXTCOMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
|
||||
+ -e "/EXTCOMMAND_LOCKDOWN_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
|
||||
-e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
|
||||
- -e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
|
||||
+ -e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" \
|
||||
+ -e "/COMMAND_LOCKDOWN_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
|
||||
done) | sort -u > $@
|
||||
platform_DATA += command.lst
|
||||
CLEANFILES += command.lst
|
||||
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||||
index cff02f2..651ea2a 100644
|
||||
--- a/grub-core/Makefile.core.def
|
||||
+++ b/grub-core/Makefile.core.def
|
||||
@@ -204,6 +204,7 @@ kernel = {
|
||||
efi = term/efi/console.c;
|
||||
efi = kern/acpi.c;
|
||||
efi = kern/efi/acpi.c;
|
||||
+ efi = kern/lockdown.c;
|
||||
i386_coreboot = kern/i386/pc/acpi.c;
|
||||
i386_multiboot = kern/i386/pc/acpi.c;
|
||||
i386_coreboot = kern/acpi.c;
|
||||
diff --git a/grub-core/commands/extcmd.c b/grub-core/commands/extcmd.c
|
||||
index 69574e2..90a5ca2 100644
|
||||
--- a/grub-core/commands/extcmd.c
|
||||
+++ b/grub-core/commands/extcmd.c
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/list.h>
|
||||
+#include <grub/lockdown.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/script_sh.h>
|
||||
@@ -110,6 +111,28 @@ grub_register_extcmd (const char *name, grub_extcmd_func_t func,
|
||||
summary, description, parser, 1);
|
||||
}
|
||||
|
||||
+static grub_err_t
|
||||
+grub_extcmd_lockdown (grub_extcmd_context_t ctxt __attribute__ ((unused)),
|
||||
+ int argc __attribute__ ((unused)),
|
||||
+ char **argv __attribute__ ((unused)))
|
||||
+{
|
||||
+ return grub_error (GRUB_ERR_ACCESS_DENIED,
|
||||
+ N_("%s: the command is not allowed when lockdown is enforced"),
|
||||
+ ctxt->extcmd->cmd->name);
|
||||
+}
|
||||
+
|
||||
+grub_extcmd_t
|
||||
+grub_register_extcmd_lockdown (const char *name, grub_extcmd_func_t func,
|
||||
+ grub_command_flags_t flags, const char *summary,
|
||||
+ const char *description,
|
||||
+ const struct grub_arg_option *parser)
|
||||
+{
|
||||
+ if (grub_is_lockdown () == GRUB_LOCKDOWN_ENABLED)
|
||||
+ func = grub_extcmd_lockdown;
|
||||
+
|
||||
+ return grub_register_extcmd (name, func, flags, summary, description, parser);
|
||||
+}
|
||||
+
|
||||
void
|
||||
grub_unregister_extcmd (grub_extcmd_t ext)
|
||||
{
|
||||
diff --git a/grub-core/kern/command.c b/grub-core/kern/command.c
|
||||
index acd7218..4aabcd4 100644
|
||||
--- a/grub-core/kern/command.c
|
||||
+++ b/grub-core/kern/command.c
|
||||
@@ -17,6 +17,7 @@
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
+#include <grub/lockdown.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
@@ -77,6 +78,29 @@ grub_register_command_prio (const char *name,
|
||||
return cmd;
|
||||
}
|
||||
|
||||
+static grub_err_t
|
||||
+grub_cmd_lockdown (grub_command_t cmd __attribute__ ((unused)),
|
||||
+ int argc __attribute__ ((unused)),
|
||||
+ char **argv __attribute__ ((unused)))
|
||||
+
|
||||
+{
|
||||
+ return grub_error (GRUB_ERR_ACCESS_DENIED,
|
||||
+ N_("%s: the command is not allowed when lockdown is enforced"),
|
||||
+ cmd->name);
|
||||
+}
|
||||
+
|
||||
+grub_command_t
|
||||
+grub_register_command_lockdown (const char *name,
|
||||
+ grub_command_func_t func,
|
||||
+ const char *summary,
|
||||
+ const char *description)
|
||||
+{
|
||||
+ if (grub_is_lockdown () == GRUB_LOCKDOWN_ENABLED)
|
||||
+ func = grub_cmd_lockdown;
|
||||
+
|
||||
+ return grub_register_command_prio (name, func, summary, description, 0);
|
||||
+}
|
||||
+
|
||||
void
|
||||
grub_unregister_command (grub_command_t cmd)
|
||||
{
|
||||
diff --git a/grub-core/kern/lockdown.c b/grub-core/kern/lockdown.c
|
||||
new file mode 100644
|
||||
index 0000000..1e56c0b
|
||||
--- /dev/null
|
||||
+++ b/grub-core/kern/lockdown.c
|
||||
@@ -0,0 +1,80 @@
|
||||
+/*
|
||||
+ * GRUB -- GRand Unified Bootloader
|
||||
+ * Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
+ *
|
||||
+ * GRUB is free software: you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation, either version 3 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * GRUB is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include <grub/dl.h>
|
||||
+#include <grub/file.h>
|
||||
+#include <grub/lockdown.h>
|
||||
+#include <grub/verify.h>
|
||||
+
|
||||
+static int lockdown = GRUB_LOCKDOWN_DISABLED;
|
||||
+
|
||||
+static grub_err_t
|
||||
+lockdown_verifier_init (grub_file_t io __attribute__ ((unused)),
|
||||
+ enum grub_file_type type,
|
||||
+ void **context __attribute__ ((unused)),
|
||||
+ enum grub_verify_flags *flags)
|
||||
+{
|
||||
+ *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION;
|
||||
+
|
||||
+ switch (type & GRUB_FILE_TYPE_MASK)
|
||||
+ {
|
||||
+ case GRUB_FILE_TYPE_GRUB_MODULE:
|
||||
+ case GRUB_FILE_TYPE_LINUX_KERNEL:
|
||||
+ case GRUB_FILE_TYPE_MULTIBOOT_KERNEL:
|
||||
+ case GRUB_FILE_TYPE_XEN_HYPERVISOR:
|
||||
+ case GRUB_FILE_TYPE_BSD_KERNEL:
|
||||
+ case GRUB_FILE_TYPE_XNU_KERNEL:
|
||||
+ case GRUB_FILE_TYPE_PLAN9_KERNEL:
|
||||
+ case GRUB_FILE_TYPE_NTLDR:
|
||||
+ case GRUB_FILE_TYPE_TRUECRYPT:
|
||||
+ case GRUB_FILE_TYPE_FREEDOS:
|
||||
+ case GRUB_FILE_TYPE_PXECHAINLOADER:
|
||||
+ case GRUB_FILE_TYPE_PCCHAINLOADER:
|
||||
+ case GRUB_FILE_TYPE_COREBOOT_CHAINLOADER:
|
||||
+ case GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE:
|
||||
+ case GRUB_FILE_TYPE_ACPI_TABLE:
|
||||
+ case GRUB_FILE_TYPE_DEVICE_TREE_IMAGE:
|
||||
+ *flags = GRUB_VERIFY_FLAGS_DEFER_AUTH;
|
||||
+
|
||||
+ /* Fall through. */
|
||||
+
|
||||
+ default:
|
||||
+ return GRUB_ERR_NONE;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+struct grub_file_verifier lockdown_verifier =
|
||||
+ {
|
||||
+ .name = "lockdown_verifier",
|
||||
+ .init = lockdown_verifier_init,
|
||||
+ };
|
||||
+
|
||||
+void
|
||||
+grub_lockdown (void)
|
||||
+{
|
||||
+ lockdown = GRUB_LOCKDOWN_ENABLED;
|
||||
+
|
||||
+ grub_verifier_register (&lockdown_verifier);
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+grub_is_lockdown (void)
|
||||
+{
|
||||
+ return lockdown;
|
||||
+}
|
||||
diff --git a/include/grub/command.h b/include/grub/command.h
|
||||
index eee4e84..2a6f7f8 100644
|
||||
--- a/include/grub/command.h
|
||||
+++ b/include/grub/command.h
|
||||
@@ -86,6 +86,11 @@ EXPORT_FUNC(grub_register_command_prio) (const char *name,
|
||||
const char *summary,
|
||||
const char *description,
|
||||
int prio);
|
||||
+grub_command_t
|
||||
+EXPORT_FUNC(grub_register_command_lockdown) (const char *name,
|
||||
+ grub_command_func_t func,
|
||||
+ const char *summary,
|
||||
+ const char *description);
|
||||
void EXPORT_FUNC(grub_unregister_command) (grub_command_t cmd);
|
||||
|
||||
static inline grub_command_t
|
||||
diff --git a/include/grub/extcmd.h b/include/grub/extcmd.h
|
||||
index 19fe592..fe9248b 100644
|
||||
--- a/include/grub/extcmd.h
|
||||
+++ b/include/grub/extcmd.h
|
||||
@@ -62,6 +62,13 @@ grub_extcmd_t EXPORT_FUNC(grub_register_extcmd) (const char *name,
|
||||
const char *description,
|
||||
const struct grub_arg_option *parser);
|
||||
|
||||
+grub_extcmd_t EXPORT_FUNC(grub_register_extcmd_lockdown) (const char *name,
|
||||
+ grub_extcmd_func_t func,
|
||||
+ grub_command_flags_t flags,
|
||||
+ const char *summary,
|
||||
+ const char *description,
|
||||
+ const struct grub_arg_option *parser);
|
||||
+
|
||||
grub_extcmd_t EXPORT_FUNC(grub_register_extcmd_prio) (const char *name,
|
||||
grub_extcmd_func_t func,
|
||||
grub_command_flags_t flags,
|
||||
diff --git a/include/grub/lockdown.h b/include/grub/lockdown.h
|
||||
new file mode 100644
|
||||
index 0000000..40531fa
|
||||
--- /dev/null
|
||||
+++ b/include/grub/lockdown.h
|
||||
@@ -0,0 +1,44 @@
|
||||
+/*
|
||||
+ * GRUB -- GRand Unified Bootloader
|
||||
+ * Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
+ *
|
||||
+ * GRUB is free software: you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation, either version 3 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * GRUB is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+#ifndef GRUB_LOCKDOWN_H
|
||||
+#define GRUB_LOCKDOWN_H 1
|
||||
+
|
||||
+#include <grub/symbol.h>
|
||||
+
|
||||
+#define GRUB_LOCKDOWN_DISABLED 0
|
||||
+#define GRUB_LOCKDOWN_ENABLED 1
|
||||
+
|
||||
+#ifdef GRUB_MACHINE_EFI
|
||||
+extern void
|
||||
+EXPORT_FUNC (grub_lockdown) (void);
|
||||
+extern int
|
||||
+EXPORT_FUNC (grub_is_lockdown) (void);
|
||||
+#else
|
||||
+static inline void
|
||||
+grub_lockdown (void)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static inline int
|
||||
+grub_is_lockdown (void)
|
||||
+{
|
||||
+ return GRUB_LOCKDOWN_DISABLED;
|
||||
+}
|
||||
+#endif
|
||||
+#endif /* ! GRUB_LOCKDOWN_H */
|
||||
57
meta/recipes-bsp/grub/files/CVE-2020-14372_3.patch
Normal file
57
meta/recipes-bsp/grub/files/CVE-2020-14372_3.patch
Normal file
@@ -0,0 +1,57 @@
|
||||
From bfb9c44298aa202c176fef8dc5ea48f9b0e76e5e Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 2 Feb 2021 19:59:48 +0100
|
||||
Subject: [PATCH] kern/lockdown: Set a variable if the GRUB is locked down
|
||||
|
||||
It may be useful for scripts to determine whether the GRUB is locked
|
||||
down or not. Add the lockdown variable which is set to "y" when the GRUB
|
||||
is locked down.
|
||||
|
||||
Suggested-by: Dimitri John Ledkov <xnox@ubuntu.com>
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=d90367471779c240e002e62edfb6b31fc85b4908]
|
||||
CVE: CVE-2020-14372
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
docs/grub.texi | 3 +++
|
||||
grub-core/kern/lockdown.c | 4 ++++
|
||||
2 files changed, 7 insertions(+)
|
||||
|
||||
diff --git a/docs/grub.texi b/docs/grub.texi
|
||||
index d778bfb..5e6cace 100644
|
||||
--- a/docs/grub.texi
|
||||
+++ b/docs/grub.texi
|
||||
@@ -5802,6 +5802,9 @@ The GRUB can be locked down when booted on a secure boot environment, for exampl
|
||||
if the UEFI secure boot is enabled. On a locked down configuration, the GRUB will
|
||||
be restricted and some operations/commands cannot be executed.
|
||||
|
||||
+The @samp{lockdown} variable is set to @samp{y} when the GRUB is locked down.
|
||||
+Otherwise it does not exit.
|
||||
+
|
||||
@node Platform limitations
|
||||
@chapter Platform limitations
|
||||
|
||||
diff --git a/grub-core/kern/lockdown.c b/grub-core/kern/lockdown.c
|
||||
index 1e56c0b..0bc70fd 100644
|
||||
--- a/grub-core/kern/lockdown.c
|
||||
+++ b/grub-core/kern/lockdown.c
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
+#include <grub/env.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/lockdown.h>
|
||||
#include <grub/verify.h>
|
||||
@@ -71,6 +72,9 @@ grub_lockdown (void)
|
||||
lockdown = GRUB_LOCKDOWN_ENABLED;
|
||||
|
||||
grub_verifier_register (&lockdown_verifier);
|
||||
+
|
||||
+ grub_env_set ("lockdown", "y");
|
||||
+ grub_env_export ("lockdown");
|
||||
}
|
||||
|
||||
int
|
||||
52
meta/recipes-bsp/grub/files/CVE-2020-14372_4.patch
Normal file
52
meta/recipes-bsp/grub/files/CVE-2020-14372_4.patch
Normal file
@@ -0,0 +1,52 @@
|
||||
From 0d809c0979ced9db4d0e500b3e812bba95e52972 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 28 Sep 2020 20:08:29 +0200
|
||||
Subject: [PATCH] efi: Lockdown the GRUB when the UEFI Secure Boot is enabled
|
||||
|
||||
If the UEFI Secure Boot is enabled then the GRUB must be locked down
|
||||
to prevent executing code that can potentially be used to subvert its
|
||||
verification mechanisms.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=98b00a403cbf2ba6833d1ac0499871b27a08eb77]
|
||||
CVE: CVE-2020-14372
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/kern/efi/init.c | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
|
||||
index 3dfdf2d..db84d82 100644
|
||||
--- a/grub-core/kern/efi/init.c
|
||||
+++ b/grub-core/kern/efi/init.c
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/console.h>
|
||||
#include <grub/efi/disk.h>
|
||||
+#include <grub/lockdown.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/env.h>
|
||||
@@ -39,6 +40,20 @@ grub_efi_init (void)
|
||||
/* Initialize the memory management system. */
|
||||
grub_efi_mm_init ();
|
||||
|
||||
+ /*
|
||||
+ * Lockdown the GRUB and register the shim_lock verifier
|
||||
+ * if the UEFI Secure Boot is enabled.
|
||||
+ */
|
||||
+ if (grub_efi_secure_boot ())
|
||||
+ {
|
||||
+ grub_lockdown ();
|
||||
+ /* NOTE: Our version does not have the shim_lock_verifier,
|
||||
+ * need to update below if added */
|
||||
+#if 0
|
||||
+ grub_shim_lock_verifier_setup ();
|
||||
+#endif
|
||||
+ }
|
||||
+
|
||||
efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
|
||||
0, 0, 0, NULL);
|
||||
|
||||
158
meta/recipes-bsp/grub/files/CVE-2020-14372_5.patch
Normal file
158
meta/recipes-bsp/grub/files/CVE-2020-14372_5.patch
Normal file
@@ -0,0 +1,158 @@
|
||||
From 1ad728b08ba2a21573e5f81a565114f74ca33988 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 28 Sep 2020 20:08:33 +0200
|
||||
Subject: [PATCH] efi: Use grub_is_lockdown() instead of hardcoding a disabled
|
||||
modules list
|
||||
|
||||
Now the GRUB can check if it has been locked down and this can be used to
|
||||
prevent executing commands that can be utilized to circumvent the UEFI
|
||||
Secure Boot mechanisms. So, instead of hardcoding a list of modules that
|
||||
have to be disabled, prevent the usage of commands that can be dangerous.
|
||||
|
||||
This not only allows the commands to be disabled on other platforms, but
|
||||
also properly separate the concerns. Since the shim_lock verifier logic
|
||||
should be only about preventing to run untrusted binaries and not about
|
||||
defining these kind of policies.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=8f73052885892bc0dbc01e297f79d7cf4925e491]
|
||||
CVE: CVE-2020-14372
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
docs/grub.texi | 10 ++++++++++
|
||||
grub-core/commands/i386/wrmsr.c | 5 +++--
|
||||
grub-core/commands/iorw.c | 19 ++++++++++---------
|
||||
grub-core/commands/memrw.c | 19 ++++++++++---------
|
||||
4 files changed, 33 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/docs/grub.texi b/docs/grub.texi
|
||||
index 5e6cace..0786427 100644
|
||||
--- a/docs/grub.texi
|
||||
+++ b/docs/grub.texi
|
||||
@@ -5256,6 +5256,9 @@ only applies to the particular cpu/core/thread that runs the command.
|
||||
Also, if you specify a reserved or unimplemented MSR address, it will
|
||||
cause a general protection exception (which is not currently being handled)
|
||||
and the system will reboot.
|
||||
+
|
||||
+Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}).
|
||||
+ This is done to prevent subverting various security mechanisms.
|
||||
@end deffn
|
||||
|
||||
@node xen_hypervisor
|
||||
@@ -5758,6 +5761,13 @@ security reasons. All above mentioned requirements are enforced by the
|
||||
shim_lock module. And itself it is a persistent module which means that
|
||||
it cannot be unloaded if it was loaded into the memory.
|
||||
|
||||
+All GRUB modules not stored in the @file{core.img}, OS kernels, ACPI tables,
|
||||
+Device Trees, etc. have to be signed, e.g, using PGP. Additionally, the commands
|
||||
+that can be used to subvert the UEFI secure boot mechanism, such as @command{iorw}
|
||||
+and @command{memrw} will not be available when the UEFI secure boot is enabled.
|
||||
+This is done for security reasons and are enforced by the GRUB Lockdown mechanism
|
||||
+(@pxref{Lockdown}).
|
||||
+
|
||||
@node Measured Boot
|
||||
@section Measuring boot components
|
||||
|
||||
diff --git a/grub-core/commands/i386/wrmsr.c b/grub-core/commands/i386/wrmsr.c
|
||||
index 9c5e510..56a29c2 100644
|
||||
--- a/grub-core/commands/i386/wrmsr.c
|
||||
+++ b/grub-core/commands/i386/wrmsr.c
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <grub/env.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/extcmd.h>
|
||||
+#include <grub/lockdown.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/i386/cpuid.h>
|
||||
#include <grub/i386/wrmsr.h>
|
||||
@@ -83,8 +84,8 @@ grub_cmd_msr_write (grub_command_t cmd __attribute__ ((unused)), int argc, char
|
||||
|
||||
GRUB_MOD_INIT(wrmsr)
|
||||
{
|
||||
- cmd_write = grub_register_command ("wrmsr", grub_cmd_msr_write, N_("ADDR VALUE"),
|
||||
- N_("Write a value to a CPU model specific register."));
|
||||
+ cmd_write = grub_register_command_lockdown ("wrmsr", grub_cmd_msr_write, N_("ADDR VALUE"),
|
||||
+ N_("Write a value to a CPU model specific register."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(wrmsr)
|
||||
diff --git a/grub-core/commands/iorw.c b/grub-core/commands/iorw.c
|
||||
index a0c164e..584baec 100644
|
||||
--- a/grub-core/commands/iorw.c
|
||||
+++ b/grub-core/commands/iorw.c
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <grub/env.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/i18n.h>
|
||||
+#include <grub/lockdown.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -131,17 +132,17 @@ GRUB_MOD_INIT(memrw)
|
||||
N_("PORT"), N_("Read 32-bit value from PORT."),
|
||||
options);
|
||||
cmd_write_byte =
|
||||
- grub_register_command ("outb", grub_cmd_write,
|
||||
- N_("PORT VALUE [MASK]"),
|
||||
- N_("Write 8-bit VALUE to PORT."));
|
||||
+ grub_register_command_lockdown ("outb", grub_cmd_write,
|
||||
+ N_("PORT VALUE [MASK]"),
|
||||
+ N_("Write 8-bit VALUE to PORT."));
|
||||
cmd_write_word =
|
||||
- grub_register_command ("outw", grub_cmd_write,
|
||||
- N_("PORT VALUE [MASK]"),
|
||||
- N_("Write 16-bit VALUE to PORT."));
|
||||
+ grub_register_command_lockdown ("outw", grub_cmd_write,
|
||||
+ N_("PORT VALUE [MASK]"),
|
||||
+ N_("Write 16-bit VALUE to PORT."));
|
||||
cmd_write_dword =
|
||||
- grub_register_command ("outl", grub_cmd_write,
|
||||
- N_("ADDR VALUE [MASK]"),
|
||||
- N_("Write 32-bit VALUE to PORT."));
|
||||
+ grub_register_command_lockdown ("outl", grub_cmd_write,
|
||||
+ N_("ADDR VALUE [MASK]"),
|
||||
+ N_("Write 32-bit VALUE to PORT."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(memrw)
|
||||
diff --git a/grub-core/commands/memrw.c b/grub-core/commands/memrw.c
|
||||
index 98769ea..d401a6d 100644
|
||||
--- a/grub-core/commands/memrw.c
|
||||
+++ b/grub-core/commands/memrw.c
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/i18n.h>
|
||||
+#include <grub/lockdown.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -133,17 +134,17 @@ GRUB_MOD_INIT(memrw)
|
||||
N_("ADDR"), N_("Read 32-bit value from ADDR."),
|
||||
options);
|
||||
cmd_write_byte =
|
||||
- grub_register_command ("write_byte", grub_cmd_write,
|
||||
- N_("ADDR VALUE [MASK]"),
|
||||
- N_("Write 8-bit VALUE to ADDR."));
|
||||
+ grub_register_command_lockdown ("write_byte", grub_cmd_write,
|
||||
+ N_("ADDR VALUE [MASK]"),
|
||||
+ N_("Write 8-bit VALUE to ADDR."));
|
||||
cmd_write_word =
|
||||
- grub_register_command ("write_word", grub_cmd_write,
|
||||
- N_("ADDR VALUE [MASK]"),
|
||||
- N_("Write 16-bit VALUE to ADDR."));
|
||||
+ grub_register_command_lockdown ("write_word", grub_cmd_write,
|
||||
+ N_("ADDR VALUE [MASK]"),
|
||||
+ N_("Write 16-bit VALUE to ADDR."));
|
||||
cmd_write_dword =
|
||||
- grub_register_command ("write_dword", grub_cmd_write,
|
||||
- N_("ADDR VALUE [MASK]"),
|
||||
- N_("Write 32-bit VALUE to ADDR."));
|
||||
+ grub_register_command_lockdown ("write_dword", grub_cmd_write,
|
||||
+ N_("ADDR VALUE [MASK]"),
|
||||
+ N_("Write 32-bit VALUE to ADDR."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(memrw)
|
||||
70
meta/recipes-bsp/grub/files/CVE-2020-27779.patch
Normal file
70
meta/recipes-bsp/grub/files/CVE-2020-27779.patch
Normal file
@@ -0,0 +1,70 @@
|
||||
From 584263eca1546e5cab69ba6fe7b4b07df2630a21 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Wed, 14 Oct 2020 16:33:42 +0200
|
||||
Subject: [PATCH] mmap: Don't register cutmem and badram commands when lockdown
|
||||
is enforced
|
||||
|
||||
The cutmem and badram commands can be used to remove EFI memory regions
|
||||
and potentially disable the UEFI Secure Boot. Prevent the commands to be
|
||||
registered if the GRUB is locked down.
|
||||
|
||||
Fixes: CVE-2020-27779
|
||||
|
||||
Reported-by: Teddy Reed <teddy.reed@gmail.com>
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=d298b41f90cbf1f2e5a10e29daa1fc92ddee52c9]
|
||||
CVE: CVE-2020-27779
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
docs/grub.texi | 4 ++++
|
||||
grub-core/mmap/mmap.c | 13 +++++++------
|
||||
2 files changed, 11 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/docs/grub.texi b/docs/grub.texi
|
||||
index 47ac7ff..a1aaee6 100644
|
||||
--- a/docs/grub.texi
|
||||
+++ b/docs/grub.texi
|
||||
@@ -4051,6 +4051,10 @@ this page is to be filtered. This syntax makes it easy to represent patterns
|
||||
that are often result of memory damage, due to physical distribution of memory
|
||||
cells.
|
||||
|
||||
+Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}).
|
||||
+ This prevents removing EFI memory regions to potentially subvert the
|
||||
+ security mechanisms provided by the UEFI secure boot.
|
||||
+
|
||||
@node blocklist
|
||||
@subsection blocklist
|
||||
|
||||
diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c
|
||||
index 57b4e9a..7ebf32e 100644
|
||||
--- a/grub-core/mmap/mmap.c
|
||||
+++ b/grub-core/mmap/mmap.c
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <grub/memory.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/err.h>
|
||||
+#include <grub/lockdown.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/command.h>
|
||||
@@ -534,12 +535,12 @@ static grub_command_t cmd, cmd_cut;
|
||||
|
||||
GRUB_MOD_INIT(mmap)
|
||||
{
|
||||
- cmd = grub_register_command ("badram", grub_cmd_badram,
|
||||
- N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"),
|
||||
- N_("Declare memory regions as faulty (badram)."));
|
||||
- cmd_cut = grub_register_command ("cutmem", grub_cmd_cutmem,
|
||||
- N_("FROM[K|M|G] TO[K|M|G]"),
|
||||
- N_("Remove any memory regions in specified range."));
|
||||
+ cmd = grub_register_command_lockdown ("badram", grub_cmd_badram,
|
||||
+ N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"),
|
||||
+ N_("Declare memory regions as faulty (badram)."));
|
||||
+ cmd_cut = grub_register_command_lockdown ("cutmem", grub_cmd_cutmem,
|
||||
+ N_("FROM[K|M|G] TO[K|M|G]"),
|
||||
+ N_("Remove any memory regions in specified range."));
|
||||
|
||||
}
|
||||
|
||||
105
meta/recipes-bsp/grub/files/CVE-2020-27779_2.patch
Normal file
105
meta/recipes-bsp/grub/files/CVE-2020-27779_2.patch
Normal file
@@ -0,0 +1,105 @@
|
||||
From 4ff1dfdf8c4c71bf4b0dd0488d9fa40ff2617f41 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Wed, 24 Feb 2021 09:00:05 +0100
|
||||
Subject: [PATCH] commands: Restrict commands that can load BIOS or DT blobs
|
||||
when locked down
|
||||
|
||||
There are some more commands that should be restricted when the GRUB is
|
||||
locked down. Following is the list of commands and reasons to restrict:
|
||||
|
||||
* fakebios: creates BIOS-like structures for backward compatibility with
|
||||
existing OSes. This should not be allowed when locked down.
|
||||
|
||||
* loadbios: reads a BIOS dump from storage and loads it. This action
|
||||
should not be allowed when locked down.
|
||||
|
||||
* devicetree: loads a Device Tree blob and passes it to the OS. It replaces
|
||||
any Device Tree provided by the firmware. This also should
|
||||
not be allowed when locked down.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=468a5699b249fe6816b4e7e86c5dc9d325c9b09e]
|
||||
CVE: CVE-2020-27779
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
docs/grub.texi | 3 +++
|
||||
grub-core/commands/efi/loadbios.c | 16 ++++++++--------
|
||||
grub-core/loader/arm/linux.c | 6 +++---
|
||||
grub-core/loader/efi/fdt.c | 4 ++--
|
||||
4 files changed, 16 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/docs/grub.texi b/docs/grub.texi
|
||||
index a1aaee6..ccf1908 100644
|
||||
--- a/docs/grub.texi
|
||||
+++ b/docs/grub.texi
|
||||
@@ -4236,6 +4236,9 @@ Load a device tree blob (.dtb) from a filesystem, for later use by a Linux
|
||||
kernel. Does not perform merging with any device tree supplied by firmware,
|
||||
but rather replaces it completely.
|
||||
@ref{GNU/Linux}.
|
||||
+
|
||||
+Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}).
|
||||
+ This is done to prevent subverting various security mechanisms.
|
||||
@end deffn
|
||||
|
||||
@node distrust
|
||||
diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c
|
||||
index d41d521..5c7725f 100644
|
||||
--- a/grub-core/commands/efi/loadbios.c
|
||||
+++ b/grub-core/commands/efi/loadbios.c
|
||||
@@ -205,14 +205,14 @@ static grub_command_t cmd_fakebios, cmd_loadbios;
|
||||
|
||||
GRUB_MOD_INIT(loadbios)
|
||||
{
|
||||
- cmd_fakebios = grub_register_command ("fakebios", grub_cmd_fakebios,
|
||||
- 0, N_("Create BIOS-like structures for"
|
||||
- " backward compatibility with"
|
||||
- " existing OS."));
|
||||
-
|
||||
- cmd_loadbios = grub_register_command ("loadbios", grub_cmd_loadbios,
|
||||
- N_("BIOS_DUMP [INT10_DUMP]"),
|
||||
- N_("Load BIOS dump."));
|
||||
+ cmd_fakebios = grub_register_command_lockdown ("fakebios", grub_cmd_fakebios,
|
||||
+ 0, N_("Create BIOS-like structures for"
|
||||
+ " backward compatibility with"
|
||||
+ " existing OS."));
|
||||
+
|
||||
+ cmd_loadbios = grub_register_command_lockdown ("loadbios", grub_cmd_loadbios,
|
||||
+ N_("BIOS_DUMP [INT10_DUMP]"),
|
||||
+ N_("Load BIOS dump."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(loadbios)
|
||||
diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
|
||||
index d70c174..ed23dc7 100644
|
||||
--- a/grub-core/loader/arm/linux.c
|
||||
+++ b/grub-core/loader/arm/linux.c
|
||||
@@ -493,9 +493,9 @@ GRUB_MOD_INIT (linux)
|
||||
0, N_("Load Linux."));
|
||||
cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd,
|
||||
0, N_("Load initrd."));
|
||||
- cmd_devicetree = grub_register_command ("devicetree", grub_cmd_devicetree,
|
||||
- /* TRANSLATORS: DTB stands for device tree blob. */
|
||||
- 0, N_("Load DTB file."));
|
||||
+ cmd_devicetree = grub_register_command_lockdown ("devicetree", grub_cmd_devicetree,
|
||||
+ /* TRANSLATORS: DTB stands for device tree blob. */
|
||||
+ 0, N_("Load DTB file."));
|
||||
my_mod = mod;
|
||||
current_fdt = (const void *) grub_arm_firmware_get_boot_data ();
|
||||
machine_type = grub_arm_firmware_get_machine_type ();
|
||||
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
|
||||
index ee9c559..003d07c 100644
|
||||
--- a/grub-core/loader/efi/fdt.c
|
||||
+++ b/grub-core/loader/efi/fdt.c
|
||||
@@ -165,8 +165,8 @@ static grub_command_t cmd_devicetree;
|
||||
GRUB_MOD_INIT (fdt)
|
||||
{
|
||||
cmd_devicetree =
|
||||
- grub_register_command ("devicetree", grub_cmd_devicetree, 0,
|
||||
- N_("Load DTB file."));
|
||||
+ grub_register_command_lockdown ("devicetree", grub_cmd_devicetree, 0,
|
||||
+ N_("Load DTB file."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (fdt)
|
||||
37
meta/recipes-bsp/grub/files/CVE-2020-27779_3.patch
Normal file
37
meta/recipes-bsp/grub/files/CVE-2020-27779_3.patch
Normal file
@@ -0,0 +1,37 @@
|
||||
From e4f5c16f76e137b3beb6b61a6d2435e54fcb495c Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Wed, 24 Feb 2021 22:59:59 +0100
|
||||
Subject: [PATCH] commands/setpci: Restrict setpci command when locked down
|
||||
|
||||
This command can set PCI devices register values, which makes it dangerous
|
||||
in a locked down configuration. Restrict it so can't be used on this setup.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=58b77d4069823b44c5fa916fa8ddfc9c4cd51e02]
|
||||
CVE: CVE-2020-27779
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/commands/setpci.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/setpci.c b/grub-core/commands/setpci.c
|
||||
index d5bc97d..fa2ba7d 100644
|
||||
--- a/grub-core/commands/setpci.c
|
||||
+++ b/grub-core/commands/setpci.c
|
||||
@@ -329,10 +329,10 @@ static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(setpci)
|
||||
{
|
||||
- cmd = grub_register_extcmd ("setpci", grub_cmd_setpci, 0,
|
||||
- N_("[-s POSITION] [-d DEVICE] [-v VAR] "
|
||||
- "REGISTER[=VALUE[:MASK]]"),
|
||||
- N_("Manipulate PCI devices."), options);
|
||||
+ cmd = grub_register_extcmd_lockdown ("setpci", grub_cmd_setpci, 0,
|
||||
+ N_("[-s POSITION] [-d DEVICE] [-v VAR] "
|
||||
+ "REGISTER[=VALUE[:MASK]]"),
|
||||
+ N_("Manipulate PCI devices."), options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(setpci)
|
||||
35
meta/recipes-bsp/grub/files/CVE-2020-27779_4.patch
Normal file
35
meta/recipes-bsp/grub/files/CVE-2020-27779_4.patch
Normal file
@@ -0,0 +1,35 @@
|
||||
From 7949671de268ba3116d113778e5d770574e9f9e3 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Wed, 24 Feb 2021 12:59:29 +0100
|
||||
Subject: [PATCH] commands/hdparm: Restrict hdparm command when locked down
|
||||
|
||||
The command can be used to get/set ATA disk parameters. Some of these can
|
||||
be dangerous since change the disk behavior. Restrict it when locked down.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=5c97492a29c6063567b65ed1a069f5e6f4e211f0]
|
||||
CVE: CVE-2020-27779
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/commands/hdparm.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c
|
||||
index d3fa966..2e2319e 100644
|
||||
--- a/grub-core/commands/hdparm.c
|
||||
+++ b/grub-core/commands/hdparm.c
|
||||
@@ -436,9 +436,9 @@ static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(hdparm)
|
||||
{
|
||||
- cmd = grub_register_extcmd ("hdparm", grub_cmd_hdparm, 0,
|
||||
- N_("[OPTIONS] DISK"),
|
||||
- N_("Get/set ATA disk parameters."), options);
|
||||
+ cmd = grub_register_extcmd_lockdown ("hdparm", grub_cmd_hdparm, 0,
|
||||
+ N_("[OPTIONS] DISK"),
|
||||
+ N_("Get/set ATA disk parameters."), options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(hdparm)
|
||||
62
meta/recipes-bsp/grub/files/CVE-2020-27779_5.patch
Normal file
62
meta/recipes-bsp/grub/files/CVE-2020-27779_5.patch
Normal file
@@ -0,0 +1,62 @@
|
||||
From 6993cce7c3a9d15e6573845f455d2f0de424a717 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Wed, 24 Feb 2021 15:03:26 +0100
|
||||
Subject: [PATCH] gdb: Restrict GDB access when locked down
|
||||
|
||||
The gdbstub* commands allow to start and control a GDB stub running on
|
||||
local host that can be used to connect from a remote debugger. Restrict
|
||||
this functionality when the GRUB is locked down.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=508270838998f151a82e9c13e7cb8a470a2dc23d]
|
||||
CVE: CVE-2020-27779
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/gdb/gdb.c | 32 ++++++++++++++++++--------------
|
||||
1 file changed, 18 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/grub-core/gdb/gdb.c b/grub-core/gdb/gdb.c
|
||||
index 847a1e1..1818cb6 100644
|
||||
--- a/grub-core/gdb/gdb.c
|
||||
+++ b/grub-core/gdb/gdb.c
|
||||
@@ -75,20 +75,24 @@ static grub_command_t cmd, cmd_stop, cmd_break;
|
||||
GRUB_MOD_INIT (gdb)
|
||||
{
|
||||
grub_gdb_idtinit ();
|
||||
- cmd = grub_register_command ("gdbstub", grub_cmd_gdbstub,
|
||||
- N_("PORT"),
|
||||
- /* TRANSLATORS: GDB stub is a small part of
|
||||
- GDB functionality running on local host
|
||||
- which allows remote debugger to
|
||||
- connect to it. */
|
||||
- N_("Start GDB stub on given port"));
|
||||
- cmd_break = grub_register_command ("gdbstub_break", grub_cmd_gdb_break,
|
||||
- /* TRANSLATORS: this refers to triggering
|
||||
- a breakpoint so that the user will land
|
||||
- into GDB. */
|
||||
- 0, N_("Break into GDB"));
|
||||
- cmd_stop = grub_register_command ("gdbstub_stop", grub_cmd_gdbstop,
|
||||
- 0, N_("Stop GDB stub"));
|
||||
+ cmd = grub_register_command_lockdown ("gdbstub", grub_cmd_gdbstub,
|
||||
+ N_("PORT"),
|
||||
+ /*
|
||||
+ * TRANSLATORS: GDB stub is a small part of
|
||||
+ * GDB functionality running on local host
|
||||
+ * which allows remote debugger to
|
||||
+ * connect to it.
|
||||
+ */
|
||||
+ N_("Start GDB stub on given port"));
|
||||
+ cmd_break = grub_register_command_lockdown ("gdbstub_break", grub_cmd_gdb_break,
|
||||
+ /*
|
||||
+ * TRANSLATORS: this refers to triggering
|
||||
+ * a breakpoint so that the user will land
|
||||
+ * into GDB.
|
||||
+ */
|
||||
+ 0, N_("Break into GDB"));
|
||||
+ cmd_stop = grub_register_command_lockdown ("gdbstub_stop", grub_cmd_gdbstop,
|
||||
+ 0, N_("Stop GDB stub"));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (gdb)
|
||||
61
meta/recipes-bsp/grub/files/CVE-2020-27779_6.patch
Normal file
61
meta/recipes-bsp/grub/files/CVE-2020-27779_6.patch
Normal file
@@ -0,0 +1,61 @@
|
||||
From 73f214761cff76a18a2a867976bdd3a9adb00b67 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Wed, 24 Feb 2021 14:44:38 +0100
|
||||
Subject: [PATCH] loader/xnu: Don't allow loading extension and packages when
|
||||
locked down
|
||||
|
||||
The shim_lock verifier validates the XNU kernels but no its extensions
|
||||
and packages. Prevent these to be loaded when the GRUB is locked down.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=9c5565135f12400a925ee901b25984e7af4442f5]
|
||||
CVE: CVE-2020-27779
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/loader/xnu.c | 31 +++++++++++++++++--------------
|
||||
1 file changed, 17 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
|
||||
index 77d7060..07232d2 100644
|
||||
--- a/grub-core/loader/xnu.c
|
||||
+++ b/grub-core/loader/xnu.c
|
||||
@@ -1482,20 +1482,23 @@ GRUB_MOD_INIT(xnu)
|
||||
N_("Load XNU image."));
|
||||
cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64,
|
||||
0, N_("Load 64-bit XNU image."));
|
||||
- cmd_mkext = grub_register_command ("xnu_mkext", grub_cmd_xnu_mkext, 0,
|
||||
- N_("Load XNU extension package."));
|
||||
- cmd_kext = grub_register_command ("xnu_kext", grub_cmd_xnu_kext, 0,
|
||||
- N_("Load XNU extension."));
|
||||
- cmd_kextdir = grub_register_command ("xnu_kextdir", grub_cmd_xnu_kextdir,
|
||||
- /* TRANSLATORS: OSBundleRequired is a
|
||||
- variable name in xnu extensions
|
||||
- manifests. It behaves mostly like
|
||||
- GNU/Linux runlevels.
|
||||
- */
|
||||
- N_("DIRECTORY [OSBundleRequired]"),
|
||||
- /* TRANSLATORS: There are many extensions
|
||||
- in extension directory. */
|
||||
- N_("Load XNU extension directory."));
|
||||
+ cmd_mkext = grub_register_command_lockdown ("xnu_mkext", grub_cmd_xnu_mkext, 0,
|
||||
+ N_("Load XNU extension package."));
|
||||
+ cmd_kext = grub_register_command_lockdown ("xnu_kext", grub_cmd_xnu_kext, 0,
|
||||
+ N_("Load XNU extension."));
|
||||
+ cmd_kextdir = grub_register_command_lockdown ("xnu_kextdir", grub_cmd_xnu_kextdir,
|
||||
+ /*
|
||||
+ * TRANSLATORS: OSBundleRequired is
|
||||
+ * a variable name in xnu extensions
|
||||
+ * manifests. It behaves mostly like
|
||||
+ * GNU/Linux runlevels.
|
||||
+ */
|
||||
+ N_("DIRECTORY [OSBundleRequired]"),
|
||||
+ /*
|
||||
+ * TRANSLATORS: There are many extensions
|
||||
+ * in extension directory.
|
||||
+ */
|
||||
+ N_("Load XNU extension directory."));
|
||||
cmd_ramdisk = grub_register_command ("xnu_ramdisk", grub_cmd_xnu_ramdisk, 0,
|
||||
/* TRANSLATORS: ramdisk here isn't identifier. It can be translated. */
|
||||
N_("Load XNU ramdisk. "
|
||||
65
meta/recipes-bsp/grub/files/CVE-2020-27779_7.patch
Normal file
65
meta/recipes-bsp/grub/files/CVE-2020-27779_7.patch
Normal file
@@ -0,0 +1,65 @@
|
||||
From dcc5a434e59f721b03cc809db0375a24aa2ac6d0 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Sat, 7 Nov 2020 01:03:18 +0100
|
||||
Subject: [PATCH] docs: Document the cutmem command
|
||||
|
||||
The command is not present in the docs/grub.texi user documentation.
|
||||
|
||||
Reported-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=f05e79a0143beb2d9a482a3ebf4fe0ce76778122]
|
||||
CVE: CVE-2020-27779
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
docs/grub.texi | 21 +++++++++++++++++++++
|
||||
1 file changed, 21 insertions(+)
|
||||
|
||||
diff --git a/docs/grub.texi b/docs/grub.texi
|
||||
index ccf1908..ae85f55 100644
|
||||
--- a/docs/grub.texi
|
||||
+++ b/docs/grub.texi
|
||||
@@ -3892,6 +3892,7 @@ you forget a command, you can run the command @command{help}
|
||||
* cpuid:: Check for CPU features
|
||||
* crc:: Compute or check CRC32 checksums
|
||||
* cryptomount:: Mount a crypto device
|
||||
+* cutmem:: Remove memory regions
|
||||
* date:: Display or set current date and time
|
||||
* devicetree:: Load a device tree blob
|
||||
* distrust:: Remove a pubkey from trusted keys
|
||||
@@ -4051,6 +4052,8 @@ this page is to be filtered. This syntax makes it easy to represent patterns
|
||||
that are often result of memory damage, due to physical distribution of memory
|
||||
cells.
|
||||
|
||||
+The command is similar to @command{cutmem} command.
|
||||
+
|
||||
Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}).
|
||||
This prevents removing EFI memory regions to potentially subvert the
|
||||
security mechanisms provided by the UEFI secure boot.
|
||||
@@ -4214,6 +4217,24 @@ GRUB suports devices encrypted using LUKS and geli. Note that necessary modules
|
||||
be used.
|
||||
@end deffn
|
||||
|
||||
+@node cutmem
|
||||
+@subsection cutmem
|
||||
+
|
||||
+@deffn Command cutmem from[K|M|G] to[K|M|G]
|
||||
+Remove any memory regions in specified range.
|
||||
+@end deffn
|
||||
+
|
||||
+This command notifies the memory manager that specified regions of RAM ought to
|
||||
+be filtered out. This remains in effect after a payload kernel has been loaded
|
||||
+by GRUB, as long as the loaded kernel obtains its memory map from GRUB. Kernels
|
||||
+that support this include Linux, GNU Mach, the kernel of FreeBSD and Multiboot
|
||||
+kernels in general.
|
||||
+
|
||||
+The command is similar to @command{badram} command.
|
||||
+
|
||||
+Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}).
|
||||
+ This prevents removing EFI memory regions to potentially subvert the
|
||||
+ security mechanisms provided by the UEFI secure boot.
|
||||
|
||||
@node date
|
||||
@subsection date
|
||||
107
meta/recipes-bsp/grub/files/no-insmod-on-sb.patch
Normal file
107
meta/recipes-bsp/grub/files/no-insmod-on-sb.patch
Normal file
@@ -0,0 +1,107 @@
|
||||
From b5a6aa7d77439bfeb75f200abffe15c6f685c907 Mon Sep 17 00:00:00 2001
|
||||
From: Matthew Garrett <mjg@redhat.com>
|
||||
Date: Mon, 13 Jan 2014 12:13:09 +0000
|
||||
Subject: Don't permit loading modules on UEFI secure boot
|
||||
|
||||
Author: Colin Watson <cjwatson@ubuntu.com>
|
||||
Origin: vendor, http://pkgs.fedoraproject.org/cgit/grub2.git/tree/grub-2.00-no-insmod-on-sb.patch
|
||||
Forwarded: no
|
||||
Last-Update: 2013-12-25
|
||||
|
||||
Patch-Name: no-insmod-on-sb.patch
|
||||
|
||||
Upstream-Status: Inappropriate [other, https://salsa.debian.org/grub-team/grub/-/blob/debian/2.04-20/debian/patches/no-insmod-on-sb.patch]
|
||||
|
||||
Backport of a Debian (and Fedora) patch implementing a way to get secure boot status
|
||||
for CVE-2020-14372_4.patch. The upstream solution has too many dependencies to backport.
|
||||
Source: https://salsa.debian.org/grub-team/grub/-/blob/debian/2.04-20/debian/patches/no-insmod-on-sb.patch
|
||||
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/kern/dl.c | 13 +++++++++++++
|
||||
grub-core/kern/efi/efi.c | 28 ++++++++++++++++++++++++++++
|
||||
include/grub/efi/efi.h | 1 +
|
||||
3 files changed, 42 insertions(+)
|
||||
|
||||
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
|
||||
index 48eb5e7b6..074dfc3c6 100644
|
||||
--- a/grub-core/kern/dl.c
|
||||
+++ b/grub-core/kern/dl.c
|
||||
@@ -38,6 +38,10 @@
|
||||
#define GRUB_MODULES_MACHINE_READONLY
|
||||
#endif
|
||||
|
||||
+#ifdef GRUB_MACHINE_EFI
|
||||
+#include <grub/efi/efi.h>
|
||||
+#endif
|
||||
+
|
||||
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
@@ -686,6 +690,15 @@ grub_dl_load_file (const char *filename)
|
||||
void *core = 0;
|
||||
grub_dl_t mod = 0;
|
||||
|
||||
+#ifdef GRUB_MACHINE_EFI
|
||||
+ if (grub_efi_secure_boot ())
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_ACCESS_DENIED,
|
||||
+ "Secure Boot forbids loading module from %s", filename);
|
||||
+ return 0;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
grub_boot_time ("Loading module %s", filename);
|
||||
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE);
|
||||
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
|
||||
index 6e1ceb905..96204e39b 100644
|
||||
--- a/grub-core/kern/efi/efi.c
|
||||
+++ b/grub-core/kern/efi/efi.c
|
||||
@@ -273,6 +273,34 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+grub_efi_boolean_t
|
||||
+grub_efi_secure_boot (void)
|
||||
+{
|
||||
+ grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
|
||||
+ grub_size_t datasize;
|
||||
+ char *secure_boot = NULL;
|
||||
+ char *setup_mode = NULL;
|
||||
+ grub_efi_boolean_t ret = 0;
|
||||
+
|
||||
+ secure_boot = grub_efi_get_variable ("SecureBoot", &efi_var_guid, &datasize);
|
||||
+
|
||||
+ if (datasize != 1 || !secure_boot)
|
||||
+ goto out;
|
||||
+
|
||||
+ setup_mode = grub_efi_get_variable ("SetupMode", &efi_var_guid, &datasize);
|
||||
+
|
||||
+ if (datasize != 1 || !setup_mode)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (*secure_boot && !*setup_mode)
|
||||
+ ret = 1;
|
||||
+
|
||||
+ out:
|
||||
+ grub_free (secure_boot);
|
||||
+ grub_free (setup_mode);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
/* Search the mods section from the PE32/PE32+ image. This code uses
|
||||
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
|
||||
index e90e00dc4..a237952b3 100644
|
||||
--- a/include/grub/efi/efi.h
|
||||
+++ b/include/grub/efi/efi.h
|
||||
@@ -82,6 +82,7 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var,
|
||||
const grub_efi_guid_t *guid,
|
||||
void *data,
|
||||
grub_size_t datasize);
|
||||
+grub_efi_boolean_t EXPORT_FUNC (grub_efi_secure_boot) (void);
|
||||
int
|
||||
EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
|
||||
const grub_efi_device_path_t *dp2);
|
||||
@@ -31,6 +31,20 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
file://CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch \
|
||||
file://CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch \
|
||||
file://determinism.patch \
|
||||
file://no-insmod-on-sb.patch \
|
||||
file://CVE-2020-14372_1.patch \
|
||||
file://CVE-2020-14372_2.patch \
|
||||
file://CVE-2020-14372_3.patch \
|
||||
file://CVE-2020-14372_4.patch \
|
||||
file://CVE-2020-14372_5.patch \
|
||||
file://CVE-2020-14372.patch \
|
||||
file://CVE-2020-27779.patch \
|
||||
file://CVE-2020-27779_2.patch \
|
||||
file://CVE-2020-27779_3.patch \
|
||||
file://CVE-2020-27779_4.patch \
|
||||
file://CVE-2020-27779_5.patch \
|
||||
file://CVE-2020-27779_6.patch \
|
||||
file://CVE-2020-27779_7.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From ecdcf0df6c28c65ca6d1e5638726e13e373c76c5 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Wed, 11 Nov 2020 22:58:55 -0800
|
||||
Subject: [PATCH] Fix cross compilation using autoconf detected AR
|
||||
|
||||
currently its using 'ar' program from build host, which is not expected,
|
||||
we need to respect AR passed in environment
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
configure.in | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/configure.in b/configure.in
|
||||
index 4ddbe8b..b7c3c31 100644
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -84,6 +84,13 @@ AC_ARG_ENABLE(syslog,
|
||||
])
|
||||
|
||||
dnl Checks for programs.
|
||||
+m4_ifndef([AC_PROG_AR],[dnl
|
||||
+ AN_MAKEVAR([AR], [AC_PROG_AR])
|
||||
+ AN_PROGRAM([ar], [AC_PROG_AR])
|
||||
+ AC_DEFUN([AC_PROG_AR],
|
||||
+ [AC_CHECK_TOOL(AR, ar, :)])
|
||||
+])
|
||||
+AC_PROG_AR
|
||||
AC_PROG_CC
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
dnl AC_PROG_INSTALL included in AM_INIT_AUTOMAKE
|
||||
--
|
||||
2.29.2
|
||||
|
||||
@@ -19,6 +19,7 @@ SRC_URI = "http://www.ohse.de/uwe/releases/lrzsz-${PV}.tar.gz \
|
||||
file://lrzsz-check-locale.h.patch \
|
||||
file://cve-2018-10195.patch \
|
||||
file://include.patch \
|
||||
file://0001-Fix-cross-compilation-using-autoconf-detected-AR.patch \
|
||||
"
|
||||
|
||||
SRC_URI[md5sum] = "b5ce6a74abc9b9eb2af94dffdfd372a4"
|
||||
|
||||
@@ -21,7 +21,7 @@ SRC_URI = "https://ftp.isc.org/isc/bind9/${PV}/${BPN}-${PV}.tar.gz \
|
||||
file://0001-avoid-start-failure-with-bind-user.patch \
|
||||
"
|
||||
|
||||
SRC_URI[sha256sum] = "cbf8cb4b74dd1452d97c3a2a8c625ea346df8516b4b3508ef07443121a591342"
|
||||
SRC_URI[sha256sum] = "1c882705827b6aafa45d917ae3b20eccccc8d5df3c4477df44b04382e6c47562"
|
||||
|
||||
UPSTREAM_CHECK_URI = "https://ftp.isc.org/isc/bind9/"
|
||||
# stay at 9.11 until 9.16, from 9.16 follow the ESV versions divisible by 4
|
||||
@@ -52,6 +52,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
|
||||
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'file://0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch', d)} \
|
||||
file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \
|
||||
file://0001-test-gatt-Fix-hung-issue.patch \
|
||||
file://CVE-2021-0129.patch \
|
||||
file://CVE-2021-3588.patch \
|
||||
"
|
||||
S = "${WORKDIR}/bluez-${PV}"
|
||||
|
||||
109
meta/recipes-connectivity/bluez5/bluez5/CVE-2021-0129.patch
Normal file
109
meta/recipes-connectivity/bluez5/bluez5/CVE-2021-0129.patch
Normal file
@@ -0,0 +1,109 @@
|
||||
From 00da0fb4972cf59e1c075f313da81ea549cb8738 Mon Sep 17 00:00:00 2001
|
||||
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
|
||||
Date: Tue, 2 Mar 2021 11:38:33 -0800
|
||||
Subject: shared/gatt-server: Fix not properly checking for secure flags
|
||||
|
||||
When passing the mask to check_permissions all valid permissions for
|
||||
the operation must be set including BT_ATT_PERM_SECURE flags.
|
||||
|
||||
Upstream-Status: Backport [https://git.kernel.org/pub/scm/bluetooth/bluez.git/patch/?id=00da0fb4972cf59e1c075f313da81ea549cb8738]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
CVE: CVE-2021-0129
|
||||
---
|
||||
src/shared/att-types.h | 8 ++++++++
|
||||
src/shared/gatt-server.c | 25 +++++++------------------
|
||||
2 files changed, 15 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/src/shared/att-types.h b/src/shared/att-types.h
|
||||
index 7108b4e94..3adc05d9e 100644
|
||||
--- a/src/shared/att-types.h
|
||||
+++ b/src/shared/att-types.h
|
||||
@@ -129,6 +129,14 @@ struct bt_att_pdu_error_rsp {
|
||||
#define BT_ATT_PERM_WRITE_SECURE 0x0200
|
||||
#define BT_ATT_PERM_SECURE (BT_ATT_PERM_READ_SECURE | \
|
||||
BT_ATT_PERM_WRITE_SECURE)
|
||||
+#define BT_ATT_PERM_READ_MASK (BT_ATT_PERM_READ | \
|
||||
+ BT_ATT_PERM_READ_AUTHEN | \
|
||||
+ BT_ATT_PERM_READ_ENCRYPT | \
|
||||
+ BT_ATT_PERM_READ_SECURE)
|
||||
+#define BT_ATT_PERM_WRITE_MASK (BT_ATT_PERM_WRITE | \
|
||||
+ BT_ATT_PERM_WRITE_AUTHEN | \
|
||||
+ BT_ATT_PERM_WRITE_ENCRYPT | \
|
||||
+ BT_ATT_PERM_WRITE_SECURE)
|
||||
|
||||
/* GATT Characteristic Properties Bitfield values */
|
||||
#define BT_GATT_CHRC_PROP_BROADCAST 0x01
|
||||
diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
|
||||
index b5f7de7dc..970c35f94 100644
|
||||
--- a/src/shared/gatt-server.c
|
||||
+++ b/src/shared/gatt-server.c
|
||||
@@ -444,9 +444,7 @@ static void process_read_by_type(struct async_read_op *op)
|
||||
return;
|
||||
}
|
||||
|
||||
- ecode = check_permissions(server, attr, BT_ATT_PERM_READ |
|
||||
- BT_ATT_PERM_READ_AUTHEN |
|
||||
- BT_ATT_PERM_READ_ENCRYPT);
|
||||
+ ecode = check_permissions(server, attr, BT_ATT_PERM_READ_MASK);
|
||||
if (ecode)
|
||||
goto error;
|
||||
|
||||
@@ -811,9 +809,7 @@ static void write_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu,
|
||||
(opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd",
|
||||
handle);
|
||||
|
||||
- ecode = check_permissions(server, attr, BT_ATT_PERM_WRITE |
|
||||
- BT_ATT_PERM_WRITE_AUTHEN |
|
||||
- BT_ATT_PERM_WRITE_ENCRYPT);
|
||||
+ ecode = check_permissions(server, attr, BT_ATT_PERM_WRITE_MASK);
|
||||
if (ecode)
|
||||
goto error;
|
||||
|
||||
@@ -913,9 +909,7 @@ static void handle_read_req(struct bt_att_chan *chan,
|
||||
opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "",
|
||||
handle);
|
||||
|
||||
- ecode = check_permissions(server, attr, BT_ATT_PERM_READ |
|
||||
- BT_ATT_PERM_READ_AUTHEN |
|
||||
- BT_ATT_PERM_READ_ENCRYPT);
|
||||
+ ecode = check_permissions(server, attr, BT_ATT_PERM_READ_MASK);
|
||||
if (ecode)
|
||||
goto error;
|
||||
|
||||
@@ -1051,9 +1045,8 @@ static void read_multiple_complete_cb(struct gatt_db_attribute *attr, int err,
|
||||
goto error;
|
||||
}
|
||||
|
||||
- ecode = check_permissions(data->server, next_attr, BT_ATT_PERM_READ |
|
||||
- BT_ATT_PERM_READ_AUTHEN |
|
||||
- BT_ATT_PERM_READ_ENCRYPT);
|
||||
+ ecode = check_permissions(data->server, next_attr,
|
||||
+ BT_ATT_PERM_READ_MASK);
|
||||
if (ecode)
|
||||
goto error;
|
||||
|
||||
@@ -1129,9 +1122,7 @@ static void read_multiple_cb(struct bt_att_chan *chan, uint8_t opcode,
|
||||
goto error;
|
||||
}
|
||||
|
||||
- ecode = check_permissions(data->server, attr, BT_ATT_PERM_READ |
|
||||
- BT_ATT_PERM_READ_AUTHEN |
|
||||
- BT_ATT_PERM_READ_ENCRYPT);
|
||||
+ ecode = check_permissions(data->server, attr, BT_ATT_PERM_READ_MASK);
|
||||
if (ecode)
|
||||
goto error;
|
||||
|
||||
@@ -1308,9 +1299,7 @@ static void prep_write_cb(struct bt_att_chan *chan, uint8_t opcode,
|
||||
util_debug(server->debug_callback, server->debug_data,
|
||||
"Prep Write Req - handle: 0x%04x", handle);
|
||||
|
||||
- ecode = check_permissions(server, attr, BT_ATT_PERM_WRITE |
|
||||
- BT_ATT_PERM_WRITE_AUTHEN |
|
||||
- BT_ATT_PERM_WRITE_ENCRYPT);
|
||||
+ ecode = check_permissions(server, attr, BT_ATT_PERM_WRITE_MASK);
|
||||
if (ecode)
|
||||
goto error;
|
||||
|
||||
--
|
||||
cgit 1.2.3-1.el7
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
From 4e355804d57d5686defc363c70f81e6f58cd08f0 Mon Sep 17 00:00:00 2001
|
||||
From: Simon Josefsson <simon@josefsson.org>
|
||||
Date: Fri, 17 Dec 2021 21:52:18 -0800
|
||||
Subject: [PATCH] ftp: check that PASV/LSPV addresses match.
|
||||
|
||||
* NEWS: Mention change.
|
||||
* ftp/ftp.c (initconn): Validate returned addresses.
|
||||
|
||||
CVE: CVE-2021-40491
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=58cb043b190fd04effdaea7c9403416b436e50dd]
|
||||
|
||||
Signed-off-by: Minjae Kim <flowergom@gmail.com>
|
||||
---
|
||||
ftp/ftp.c | 21 +++++++++++++++++++++
|
||||
1 file changed, 21 insertions(+)
|
||||
|
||||
diff --git a/ftp/ftp.c b/ftp/ftp.c
|
||||
index 9813586..7c72cb2 100644
|
||||
--- a/ftp/ftp.c
|
||||
+++ b/ftp/ftp.c
|
||||
@@ -1344,6 +1344,13 @@ initconn (void)
|
||||
uint32_t *pu32 = (uint32_t *) &data_addr_sa4->sin_addr.s_addr;
|
||||
pu32[0] = htonl ( (h[0] << 24) | (h[1] << 16) | (h[2] << 8) | h[3]);
|
||||
}
|
||||
+ if (data_addr_sa4->sin_addr.s_addr
|
||||
+ != ((struct sockaddr_in *) &hisctladdr)->sin_addr.s_addr)
|
||||
+ {
|
||||
+ printf ("Passive mode address mismatch.\n");
|
||||
+ (void) command ("ABOR"); /* Cancel any open connection. */
|
||||
+ goto bad;
|
||||
+ }
|
||||
} /* LPSV IPv4 */
|
||||
else /* IPv6 */
|
||||
{
|
||||
@@ -1374,6 +1381,13 @@ initconn (void)
|
||||
pu32[2] = htonl ( (h[8] << 24) | (h[9] << 16) | (h[10] << 8) | h[11]);
|
||||
pu32[3] = htonl ( (h[12] << 24) | (h[13] << 16) | (h[14] << 8) | h[15]);
|
||||
}
|
||||
+ if (data_addr_sa6->sin6_addr.s6_addr
|
||||
+ != ((struct sockaddr_in6 *) &hisctladdr)->sin6_addr.s6_addr)
|
||||
+ {
|
||||
+ printf ("Passive mode address mismatch.\n");
|
||||
+ (void) command ("ABOR"); /* Cancel any open connection. */
|
||||
+ goto bad;
|
||||
+ }
|
||||
} /* LPSV IPv6 */
|
||||
}
|
||||
else /* !EPSV && !LPSV */
|
||||
@@ -1394,6 +1408,13 @@ initconn (void)
|
||||
| ((a2 & 0xff) << 8) | (a3 & 0xff) );
|
||||
data_addr_sa4->sin_port =
|
||||
htons (((p0 & 0xff) << 8) | (p1 & 0xff));
|
||||
+ if (data_addr_sa4->sin_addr.s_addr
|
||||
+ != ((struct sockaddr_in *) &hisctladdr)->sin_addr.s_addr)
|
||||
+ {
|
||||
+ printf ("Passive mode address mismatch.\n");
|
||||
+ (void) command ("ABOR"); /* Cancel any open connection. */
|
||||
+ goto bad;
|
||||
+ }
|
||||
} /* PASV */
|
||||
else
|
||||
{
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -23,6 +23,7 @@ SRC_URI = "${GNU_MIRROR}/inetutils/inetutils-${PV}.tar.gz \
|
||||
file://inetutils-only-check-pam_appl.h-when-pam-enabled.patch \
|
||||
file://0001-rcp-fix-to-work-with-large-files.patch \
|
||||
file://fix-buffer-fortify-tfpt.patch \
|
||||
file://CVE-2021-40491.patch \
|
||||
"
|
||||
|
||||
SRC_URI[md5sum] = "04852c26c47cc8c6b825f2b74f191f52"
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
From a6414400ec94a17871081f7df24f910a6ee01b8b Mon Sep 17 00:00:00 2001
|
||||
From: Ali Abdallah <aabdallah@suse.de>
|
||||
Date: Wed, 24 Nov 2021 13:33:39 +0100
|
||||
Subject: [PATCH] CVE-2021-41617 fix
|
||||
|
||||
backport of the following two upstream commits
|
||||
|
||||
f3cbe43e28fe71427d41cfe3a17125b972710455
|
||||
bf944e3794eff5413f2df1ef37cddf96918c6bde
|
||||
|
||||
CVE-2021-41617 failed to correctly initialise supplemental groups
|
||||
when executing an AuthorizedKeysCommand or AuthorizedPrincipalsCommand,
|
||||
where a AuthorizedKeysCommandUser or AuthorizedPrincipalsCommandUser
|
||||
directive has been set to run the command as a different user. Instead
|
||||
these commands would inherit the groups that sshd(8) was started with.
|
||||
---
|
||||
auth.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
CVE: CVE-2021-41617
|
||||
Upstream-Status: Backport [https://bugzilla.suse.com/attachment.cgi?id=854015]
|
||||
Comment: No change in any hunk
|
||||
Signed-off-by: Sana Kazi <Sana.Kazi@kpit.com>
|
||||
|
||||
diff --git a/auth.c b/auth.c
|
||||
index 163038f..a47b267 100644
|
||||
--- a/auth.c
|
||||
+++ b/auth.c
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <time.h>
|
||||
+#include <grp.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "match.h"
|
||||
@@ -851,6 +852,13 @@ subprocess(const char *tag, struct passwd *pw, const char *command,
|
||||
}
|
||||
closefrom(STDERR_FILENO + 1);
|
||||
|
||||
+ if (geteuid() == 0 &&
|
||||
+ initgroups(pw->pw_name, pw->pw_gid) == -1) {
|
||||
+ error("%s: initgroups(%s, %u): %s", tag,
|
||||
+ pw->pw_name, (u_int)pw->pw_gid, strerror(errno));
|
||||
+ _exit(1);
|
||||
+ }
|
||||
+
|
||||
/* Don't use permanently_set_uid() here to avoid fatal() */
|
||||
if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1) {
|
||||
error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid,
|
||||
--
|
||||
2.26.2
|
||||
@@ -5,7 +5,7 @@ Ssh (Secure Shell) is a program for logging into a remote machine \
|
||||
and for executing commands on a remote machine."
|
||||
HOMEPAGE = "http://www.openssh.com/"
|
||||
SECTION = "console/network"
|
||||
LICENSE = "BSD & ISC & MIT"
|
||||
LICENSE = "BSD-2-Clause & BSD-3-Clause & BSD-4-Clause & ISC & MIT"
|
||||
LIC_FILES_CHKSUM = "file://LICENCE;md5=18d9e5a8b3dd1790d73502f50426d4d3"
|
||||
|
||||
DEPENDS = "zlib openssl virtual/crypt"
|
||||
@@ -26,6 +26,7 @@ SRC_URI = "http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${PV}.tar
|
||||
file://add-test-support-for-busybox.patch \
|
||||
file://CVE-2020-14145.patch \
|
||||
file://CVE-2021-28041.patch \
|
||||
file://CVE-2021-41617.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "3076e6413e8dbe56d33848c1054ac091"
|
||||
SRC_URI[sha256sum] = "43925151e6cf6cee1450190c0e9af4dc36b41c12737619edff8bcebdff64e671"
|
||||
@@ -50,6 +51,15 @@ CVE_CHECK_WHITELIST += "CVE-2020-15778"
|
||||
# https://www.securityfocus.com/bid/30794
|
||||
CVE_CHECK_WHITELIST += "CVE-2008-3844"
|
||||
|
||||
# openssh-ssh1 is provided for compatibility with old devices that
|
||||
# cannot be upgraded to modern protocols. Thus they may not provide security
|
||||
# support for this package because doing so would prevent access to equipment.
|
||||
# The upstream OpenSSH developers see this as an important
|
||||
# security feature and do not intend to 'fix' it.
|
||||
# https://security-tracker.debian.org/tracker/CVE-2016-20012
|
||||
# https://ubuntu.com/security/CVE-2016-20012
|
||||
CVE_CHECK_WHITELIST += "CVE-2016-20012"
|
||||
|
||||
PAM_SRC_URI = "file://sshd"
|
||||
|
||||
inherit manpages useradd update-rc.d update-alternatives systemd
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
Using localtime() means the output can depend on the timezone of the build machine.
|
||||
Using gmtime() is safer. For complete reproducibility use SOURCE_DATE_EPOCH if set.
|
||||
|
||||
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
|
||||
Upstream-Status: Pending [should be suitable]
|
||||
|
||||
Index: openssl-3.0.1/apps/progs.pl
|
||||
===================================================================
|
||||
--- openssl-3.0.1.orig/apps/progs.pl
|
||||
+++ openssl-3.0.1/apps/progs.pl
|
||||
@@ -21,7 +21,10 @@ die "Unrecognised option, must be -C or
|
||||
my %commands = ();
|
||||
my $cmdre = qr/^\s*int\s+([a-z_][a-z0-9_]*)_main\(\s*int\s+argc\s*,/;
|
||||
my $apps_openssl = shift @ARGV;
|
||||
-my $YEAR = [localtime()]->[5] + 1900;
|
||||
+my $YEAR = [gmtime()]->[5] + 1900;
|
||||
+if (defined($ENV{SOURCE_DATE_EPOCH}) && $ENV{SOURCE_DATE_EPOCH} !~ /\D/) {
|
||||
+ $YEAR = [gmtime($ENV{SOURCE_DATE_EPOCH})]->[5] + 1900;
|
||||
+}
|
||||
|
||||
# because the program apps/openssl has object files as sources, and
|
||||
# they then have the corresponding C files as source, we need to chain
|
||||
@@ -17,6 +17,7 @@ SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
|
||||
file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \
|
||||
file://afalg.patch \
|
||||
file://reproducible.patch \
|
||||
file://reproducibility.patch \
|
||||
"
|
||||
|
||||
SRC_URI_append_class-nativesdk = " \
|
||||
|
||||
53
meta/recipes-core/busybox/busybox/CVE-2021-42374.patch
Normal file
53
meta/recipes-core/busybox/busybox/CVE-2021-42374.patch
Normal file
@@ -0,0 +1,53 @@
|
||||
From 04f052c56ded5ab6a904e3a264a73dc0412b2e78 Mon Sep 17 00:00:00 2001
|
||||
From: Denys Vlasenko <vda.linux@googlemail.com>
|
||||
Date: Tue, 15 Jun 2021 15:07:57 +0200
|
||||
Subject: [PATCH] unlzma: fix a case where we could read before beginning of
|
||||
buffer
|
||||
Cc: pavel@zhukoff.net
|
||||
|
||||
Testcase:
|
||||
|
||||
21 01 01 00 00 00 00 00 e7 01 01 01 ef 00 df b6
|
||||
00 17 02 10 11 0f ff 00 16 00 00
|
||||
|
||||
Unfortunately, the bug is not reliably causing a segfault,
|
||||
the behavior depends on what's in memory before the buffer.
|
||||
|
||||
function old new delta
|
||||
unpack_lzma_stream 2762 2768 +6
|
||||
|
||||
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
||||
|
||||
Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com>
|
||||
|
||||
CVE: CVE-2021-42374
|
||||
Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?h=1_33_stable&id=d326be2850ea2bd78fe2c22d6c45c3b861d82937]
|
||||
Comment: testdata dropped because of binary format
|
||||
|
||||
---
|
||||
archival/libarchive/decompress_unlzma.c | 5 ++++-
|
||||
testsuite/unlzma.tests | 17 +++++++++++++----
|
||||
testsuite/unlzma_issue_3.lzma | Bin 0 -> 27 bytes
|
||||
3 files changed, 17 insertions(+), 5 deletions(-)
|
||||
create mode 100644 testsuite/unlzma_issue_3.lzma
|
||||
|
||||
diff --git a/archival/libarchive/decompress_unlzma.c b/archival/libarchive/decompress_unlzma.c
|
||||
index 0744f231a1d64d92676b0cada2342f88f3b39b31..fb5aac8fe9ea0c53e0c2d7a7cbd05a753e39bc9d 100644
|
||||
--- a/archival/libarchive/decompress_unlzma.c
|
||||
+++ b/archival/libarchive/decompress_unlzma.c
|
||||
@@ -290,8 +290,11 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||
uint32_t pos;
|
||||
|
||||
pos = buffer_pos - rep0;
|
||||
- if ((int32_t)pos < 0)
|
||||
+ if ((int32_t)pos < 0) {
|
||||
pos += header.dict_size;
|
||||
+ if ((int32_t)pos < 0)
|
||||
+ goto bad;
|
||||
+ }
|
||||
match_byte = buffer[pos];
|
||||
do {
|
||||
int bit;
|
||||
--
|
||||
2.34.0
|
||||
|
||||
138
meta/recipes-core/busybox/busybox/CVE-2021-42376.patch
Normal file
138
meta/recipes-core/busybox/busybox/CVE-2021-42376.patch
Normal file
@@ -0,0 +1,138 @@
|
||||
From 56a335378ac100d51c30b21eee499a2effa37fba Mon Sep 17 00:00:00 2001
|
||||
From: Denys Vlasenko <vda.linux@googlemail.com>
|
||||
Date: Tue, 15 Jun 2021 16:05:57 +0200
|
||||
Subject: hush: fix handling of \^C and "^C"
|
||||
|
||||
function old new delta
|
||||
parse_stream 2238 2252 +14
|
||||
encode_string 243 256 +13
|
||||
------------------------------------------------------------------------------
|
||||
(add/remove: 0/0 grow/shrink: 2/0 up/down: 27/0) Total: 27 bytes
|
||||
|
||||
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
||||
(cherry picked from commit 1b7a9b68d0e9aa19147d7fda16eb9a6b54156985)
|
||||
|
||||
Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com>
|
||||
|
||||
CVE: CVE-2021-42376
|
||||
Upstream-Status: Backport [https://git.busybox.net/busybox/patch/?id=56a335378ac100d51c30b21eee499a2effa37fba]
|
||||
Comment: No changes in any hunk
|
||||
---
|
||||
shell/ash_test/ash-misc/control_char3.right | 1 +
|
||||
shell/ash_test/ash-misc/control_char3.tests | 2 ++
|
||||
shell/ash_test/ash-misc/control_char4.right | 1 +
|
||||
shell/ash_test/ash-misc/control_char4.tests | 2 ++
|
||||
shell/hush.c | 11 +++++++++++
|
||||
shell/hush_test/hush-misc/control_char3.right | 1 +
|
||||
shell/hush_test/hush-misc/control_char3.tests | 2 ++
|
||||
shell/hush_test/hush-misc/control_char4.right | 1 +
|
||||
shell/hush_test/hush-misc/control_char4.tests | 2 ++
|
||||
9 files changed, 23 insertions(+)
|
||||
create mode 100644 shell/ash_test/ash-misc/control_char3.right
|
||||
create mode 100755 shell/ash_test/ash-misc/control_char3.tests
|
||||
create mode 100644 shell/ash_test/ash-misc/control_char4.right
|
||||
create mode 100755 shell/ash_test/ash-misc/control_char4.tests
|
||||
create mode 100644 shell/hush_test/hush-misc/control_char3.right
|
||||
create mode 100755 shell/hush_test/hush-misc/control_char3.tests
|
||||
create mode 100644 shell/hush_test/hush-misc/control_char4.right
|
||||
create mode 100755 shell/hush_test/hush-misc/control_char4.tests
|
||||
|
||||
diff --git a/shell/ash_test/ash-misc/control_char3.right b/shell/ash_test/ash-misc/control_char3.right
|
||||
new file mode 100644
|
||||
index 000000000..283e02cbb
|
||||
--- /dev/null
|
||||
+++ b/shell/ash_test/ash-misc/control_char3.right
|
||||
@@ -0,0 +1 @@
|
||||
+SHELL: line 1: : not found
|
||||
diff --git a/shell/ash_test/ash-misc/control_char3.tests b/shell/ash_test/ash-misc/control_char3.tests
|
||||
new file mode 100755
|
||||
index 000000000..4359db3f3
|
||||
--- /dev/null
|
||||
+++ b/shell/ash_test/ash-misc/control_char3.tests
|
||||
@@ -0,0 +1,2 @@
|
||||
+# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
|
||||
+$THIS_SH -c '\' SHELL
|
||||
diff --git a/shell/ash_test/ash-misc/control_char4.right b/shell/ash_test/ash-misc/control_char4.right
|
||||
new file mode 100644
|
||||
index 000000000..2bf18e684
|
||||
--- /dev/null
|
||||
+++ b/shell/ash_test/ash-misc/control_char4.right
|
||||
@@ -0,0 +1 @@
|
||||
+SHELL: line 1: -: not found
|
||||
diff --git a/shell/ash_test/ash-misc/control_char4.tests b/shell/ash_test/ash-misc/control_char4.tests
|
||||
new file mode 100755
|
||||
index 000000000..48010f154
|
||||
--- /dev/null
|
||||
+++ b/shell/ash_test/ash-misc/control_char4.tests
|
||||
@@ -0,0 +1,2 @@
|
||||
+# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
|
||||
+$THIS_SH -c '"-"' SHELL
|
||||
diff --git a/shell/hush.c b/shell/hush.c
|
||||
index 9fead37da..249728b9d 100644
|
||||
--- a/shell/hush.c
|
||||
+++ b/shell/hush.c
|
||||
@@ -5235,6 +5235,11 @@ static int encode_string(o_string *as_string,
|
||||
}
|
||||
#endif
|
||||
o_addQchr(dest, ch);
|
||||
+ if (ch == SPECIAL_VAR_SYMBOL) {
|
||||
+ /* Convert "^C" to corresponding special variable reference */
|
||||
+ o_addchr(dest, SPECIAL_VAR_QUOTED_SVS);
|
||||
+ o_addchr(dest, SPECIAL_VAR_SYMBOL);
|
||||
+ }
|
||||
goto again;
|
||||
#undef as_string
|
||||
}
|
||||
@@ -5346,6 +5351,11 @@ static struct pipe *parse_stream(char **pstring,
|
||||
if (ch == '\n')
|
||||
continue; /* drop \<newline>, get next char */
|
||||
nommu_addchr(&ctx.as_string, '\\');
|
||||
+ if (ch == SPECIAL_VAR_SYMBOL) {
|
||||
+ nommu_addchr(&ctx.as_string, ch);
|
||||
+ /* Convert \^C to corresponding special variable reference */
|
||||
+ goto case_SPECIAL_VAR_SYMBOL;
|
||||
+ }
|
||||
o_addchr(&ctx.word, '\\');
|
||||
if (ch == EOF) {
|
||||
/* Testcase: eval 'echo Ok\' */
|
||||
@@ -5670,6 +5680,7 @@ static struct pipe *parse_stream(char **pstring,
|
||||
/* Note: nommu_addchr(&ctx.as_string, ch) is already done */
|
||||
|
||||
switch (ch) {
|
||||
+ case_SPECIAL_VAR_SYMBOL:
|
||||
case SPECIAL_VAR_SYMBOL:
|
||||
/* Convert raw ^C to corresponding special variable reference */
|
||||
o_addchr(&ctx.word, SPECIAL_VAR_SYMBOL);
|
||||
diff --git a/shell/hush_test/hush-misc/control_char3.right b/shell/hush_test/hush-misc/control_char3.right
|
||||
new file mode 100644
|
||||
index 000000000..94b4f8699
|
||||
--- /dev/null
|
||||
+++ b/shell/hush_test/hush-misc/control_char3.right
|
||||
@@ -0,0 +1 @@
|
||||
+hush: can't execute '': No such file or directory
|
||||
diff --git a/shell/hush_test/hush-misc/control_char3.tests b/shell/hush_test/hush-misc/control_char3.tests
|
||||
new file mode 100755
|
||||
index 000000000..4359db3f3
|
||||
--- /dev/null
|
||||
+++ b/shell/hush_test/hush-misc/control_char3.tests
|
||||
@@ -0,0 +1,2 @@
|
||||
+# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
|
||||
+$THIS_SH -c '\' SHELL
|
||||
diff --git a/shell/hush_test/hush-misc/control_char4.right b/shell/hush_test/hush-misc/control_char4.right
|
||||
new file mode 100644
|
||||
index 000000000..698e21427
|
||||
--- /dev/null
|
||||
+++ b/shell/hush_test/hush-misc/control_char4.right
|
||||
@@ -0,0 +1 @@
|
||||
+hush: can't execute '-': No such file or directory
|
||||
diff --git a/shell/hush_test/hush-misc/control_char4.tests b/shell/hush_test/hush-misc/control_char4.tests
|
||||
new file mode 100755
|
||||
index 000000000..48010f154
|
||||
--- /dev/null
|
||||
+++ b/shell/hush_test/hush-misc/control_char4.tests
|
||||
@@ -0,0 +1,2 @@
|
||||
+# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
|
||||
+$THIS_SH -c '"-"' SHELL
|
||||
--
|
||||
cgit v1.2.3
|
||||
|
||||
@@ -52,6 +52,9 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
|
||||
file://0001-hwclock-make-glibc-2.31-compatible.patch \
|
||||
file://0001-decompress_gunzip-Fix-DoS-if-gzip-is-corrupt.patch \
|
||||
file://0001-mktemp-add-tmpdir-option.patch \
|
||||
file://CVE-2021-42374.patch \
|
||||
file://CVE-2021-42376.patch \
|
||||
file://CVE-2021-423xx-awk.patch \
|
||||
"
|
||||
SRC_URI_append_libc-musl = " file://musl.cfg "
|
||||
|
||||
|
||||
215
meta/recipes-core/busybox/files/CVE-2021-423xx-awk.patch
Normal file
215
meta/recipes-core/busybox/files/CVE-2021-423xx-awk.patch
Normal file
@@ -0,0 +1,215 @@
|
||||
From a21708eb8d07b4a6dbc1d3e4ace4c5721515a84c Mon Sep 17 00:00:00 2001
|
||||
From: Sana Kazi <Sana.Kazi@kpit.com>
|
||||
Date: Wed, 8 Dec 2021 12:25:34 +0530
|
||||
Subject: [PATCH] busybox: Fix multiple security issues in awk
|
||||
|
||||
Description: fix multiple security issues in awk
|
||||
Origin: backported awk.c from busybox 1.34.1
|
||||
|
||||
CVE: CVE-2021-42378
|
||||
CVE: CVE-2021-42379
|
||||
CVE: CVE-2021-42380
|
||||
CVE: CVE-2021-42381
|
||||
CVE: CVE-2021-42382
|
||||
CVE: CVE-2021-42384
|
||||
CVE: CVE-2021-42385
|
||||
CVE: CVE-2021-42386
|
||||
|
||||
Upstream-Status: Backport [https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/busybox/1:1.30.1-6ubuntu3.1/busybox_1.30.1-6ubuntu3.1.debian.tar.xz]
|
||||
|
||||
Comment: Refreshed first hunk and removed few hunks as they are already present in source.
|
||||
|
||||
Signed-off-by: Sana Kazi <Sana.Kazi@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <Ranjitsinh.Rathod@kpit.com>
|
||||
|
||||
---
|
||||
editors/awk.c | 80 ++++++++++++++++++++++++++++++++++++++-------------
|
||||
1 file changed, 60 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/editors/awk.c b/editors/awk.c
|
||||
index d25508e..4e4f282 100644
|
||||
--- a/editors/awk.c
|
||||
+++ b/editors/awk.c
|
||||
@@ -272,7 +272,8 @@ typedef struct tsplitter_s {
|
||||
/* if previous token class is CONCAT1 and next is CONCAT2, concatenation */
|
||||
/* operator is inserted between them */
|
||||
#define TC_CONCAT1 (TC_VARIABLE | TC_ARRTERM | TC_SEQTERM \
|
||||
- | TC_STRING | TC_NUMBER | TC_UOPPOST)
|
||||
+ | TC_STRING | TC_NUMBER | TC_UOPPOST \
|
||||
+ | TC_LENGTH)
|
||||
#define TC_CONCAT2 (TC_OPERAND | TC_UOPPRE)
|
||||
|
||||
#define OF_RES1 0x010000
|
||||
@@ -404,7 +405,7 @@ static const char tokenlist[] ALIGN1 =
|
||||
|
||||
#define OC_B OC_BUILTIN
|
||||
|
||||
-static const uint32_t tokeninfo[] = {
|
||||
+static const uint32_t tokeninfo[] ALIGN4 = {
|
||||
0,
|
||||
0,
|
||||
OC_REGEXP,
|
||||
@@ -1070,8 +1071,10 @@ static uint32_t next_token(uint32_t expected)
|
||||
const uint32_t *ti;
|
||||
|
||||
if (t_rollback) {
|
||||
+ debug_printf_parse("%s: using rolled-back token\n", __func__);
|
||||
t_rollback = FALSE;
|
||||
} else if (concat_inserted) {
|
||||
+ debug_printf_parse("%s: using concat-inserted token\n", __func__);
|
||||
concat_inserted = FALSE;
|
||||
t_tclass = save_tclass;
|
||||
t_info = save_info;
|
||||
@@ -1200,7 +1203,11 @@ static uint32_t next_token(uint32_t expected)
|
||||
goto readnext;
|
||||
|
||||
/* insert concatenation operator when needed */
|
||||
- if ((ltclass & TC_CONCAT1) && (tc & TC_CONCAT2) && (expected & TC_BINOP)) {
|
||||
+ debug_printf_parse("%s: %x %x %x concat_inserted?\n", __func__,
|
||||
+ (ltclass & TC_CONCAT1), (tc & TC_CONCAT2), (expected & TC_BINOP));
|
||||
+ if ((ltclass & TC_CONCAT1) && (tc & TC_CONCAT2) && (expected & TC_BINOP)
|
||||
+ && !(ltclass == TC_LENGTH && tc == TC_SEQSTART) /* but not for "length(..." */
|
||||
+ ) {
|
||||
concat_inserted = TRUE;
|
||||
save_tclass = tc;
|
||||
save_info = t_info;
|
||||
@@ -1208,6 +1215,7 @@ static uint32_t next_token(uint32_t expected)
|
||||
t_info = OC_CONCAT | SS | P(35);
|
||||
}
|
||||
|
||||
+ debug_printf_parse("%s: t_tclass=tc=%x\n", __func__, t_tclass);
|
||||
t_tclass = tc;
|
||||
}
|
||||
ltclass = t_tclass;
|
||||
@@ -1218,6 +1226,7 @@ static uint32_t next_token(uint32_t expected)
|
||||
EMSG_UNEXP_EOS : EMSG_UNEXP_TOKEN);
|
||||
}
|
||||
|
||||
+ debug_printf_parse("%s: returning, ltclass:%x t_double:%f\n", __func__, ltclass, t_double);
|
||||
return ltclass;
|
||||
#undef concat_inserted
|
||||
#undef save_tclass
|
||||
@@ -1282,7 +1291,7 @@ static node *parse_expr(uint32_t iexp)
|
||||
glptr = NULL;
|
||||
|
||||
} else if (tc & (TC_BINOP | TC_UOPPOST)) {
|
||||
- debug_printf_parse("%s: TC_BINOP | TC_UOPPOST\n", __func__);
|
||||
+ debug_printf_parse("%s: TC_BINOP | TC_UOPPOST tc:%x\n", __func__, tc);
|
||||
/* for binary and postfix-unary operators, jump back over
|
||||
* previous operators with higher priority */
|
||||
vn = cn;
|
||||
@@ -1350,8 +1359,10 @@ static node *parse_expr(uint32_t iexp)
|
||||
v = cn->l.v = xzalloc(sizeof(var));
|
||||
if (tc & TC_NUMBER)
|
||||
setvar_i(v, t_double);
|
||||
- else
|
||||
+ else {
|
||||
setvar_s(v, t_string);
|
||||
+ xtc &= ~TC_UOPPOST; /* "str"++ is not allowed */
|
||||
+ }
|
||||
break;
|
||||
|
||||
case TC_REGEXP:
|
||||
@@ -1387,7 +1398,12 @@ static node *parse_expr(uint32_t iexp)
|
||||
|
||||
case TC_LENGTH:
|
||||
debug_printf_parse("%s: TC_LENGTH\n", __func__);
|
||||
- next_token(TC_SEQSTART | TC_OPTERM | TC_GRPTERM);
|
||||
+ next_token(TC_SEQSTART /* length(...) */
|
||||
+ | TC_OPTERM /* length; (or newline)*/
|
||||
+ | TC_GRPTERM /* length } */
|
||||
+ | TC_BINOPX /* length <op> NUM */
|
||||
+ | TC_COMMA /* print length, 1 */
|
||||
+ );
|
||||
rollback_token();
|
||||
if (t_tclass & TC_SEQSTART) {
|
||||
/* It was a "(" token. Handle just like TC_BUILTIN */
|
||||
@@ -1747,12 +1763,34 @@ static void fsrealloc(int size)
|
||||
nfields = size;
|
||||
}
|
||||
|
||||
+static int regexec1_nonempty(const regex_t *preg, const char *s, regmatch_t pmatch[])
|
||||
+{
|
||||
+ int r = regexec(preg, s, 1, pmatch, 0);
|
||||
+ if (r == 0 && pmatch[0].rm_eo == 0) {
|
||||
+ /* For example, happens when FS can match
|
||||
+ * an empty string (awk -F ' *'). Logically,
|
||||
+ * this should split into one-char fields.
|
||||
+ * However, gawk 5.0.1 searches for first
|
||||
+ * _non-empty_ separator string match:
|
||||
+ */
|
||||
+ size_t ofs = 0;
|
||||
+ do {
|
||||
+ ofs++;
|
||||
+ if (!s[ofs])
|
||||
+ return REG_NOMATCH;
|
||||
+ regexec(preg, s + ofs, 1, pmatch, 0);
|
||||
+ } while (pmatch[0].rm_eo == 0);
|
||||
+ pmatch[0].rm_so += ofs;
|
||||
+ pmatch[0].rm_eo += ofs;
|
||||
+ }
|
||||
+ return r;
|
||||
+}
|
||||
+
|
||||
static int awk_split(const char *s, node *spl, char **slist)
|
||||
{
|
||||
- int l, n;
|
||||
+ int n;
|
||||
char c[4];
|
||||
char *s1;
|
||||
- regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough...
|
||||
|
||||
/* in worst case, each char would be a separate field */
|
||||
*slist = s1 = xzalloc(strlen(s) * 2 + 3);
|
||||
@@ -1769,29 +1807,31 @@ static int awk_split(const char *s, node *spl, char **slist)
|
||||
return n; /* "": zero fields */
|
||||
n++; /* at least one field will be there */
|
||||
do {
|
||||
+ int l;
|
||||
+ regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough...
|
||||
+
|
||||
l = strcspn(s, c+2); /* len till next NUL or \n */
|
||||
- if (regexec(icase ? spl->r.ire : spl->l.re, s, 1, pmatch, 0) == 0
|
||||
+ if (regexec1_nonempty(icase ? spl->r.ire : spl->l.re, s, pmatch) == 0
|
||||
&& pmatch[0].rm_so <= l
|
||||
) {
|
||||
+ /* if (pmatch[0].rm_eo == 0) ... - impossible */
|
||||
l = pmatch[0].rm_so;
|
||||
- if (pmatch[0].rm_eo == 0) {
|
||||
- l++;
|
||||
- pmatch[0].rm_eo++;
|
||||
- }
|
||||
n++; /* we saw yet another delimiter */
|
||||
} else {
|
||||
pmatch[0].rm_eo = l;
|
||||
if (s[l])
|
||||
pmatch[0].rm_eo++;
|
||||
}
|
||||
- memcpy(s1, s, l);
|
||||
- /* make sure we remove *all* of the separator chars */
|
||||
- do {
|
||||
- s1[l] = '\0';
|
||||
- } while (++l < pmatch[0].rm_eo);
|
||||
- nextword(&s1);
|
||||
+ s1 = mempcpy(s1, s, l);
|
||||
+ *s1++ = '\0';
|
||||
s += pmatch[0].rm_eo;
|
||||
} while (*s);
|
||||
+
|
||||
+ /* echo a-- | awk -F-- '{ print NF, length($NF), $NF }'
|
||||
+ * should print "2 0 ":
|
||||
+ */
|
||||
+ *s1 = '\0';
|
||||
+
|
||||
return n;
|
||||
}
|
||||
if (c[0] == '\0') { /* null split */
|
||||
@@ -1995,7 +2035,7 @@ static int ptest(node *pattern)
|
||||
static int awk_getline(rstream *rsm, var *v)
|
||||
{
|
||||
char *b;
|
||||
- regmatch_t pmatch[2];
|
||||
+ regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough...
|
||||
int size, a, p, pp = 0;
|
||||
int fd, so, eo, r, rp;
|
||||
char c, *m, *s;
|
||||
@@ -22,7 +22,9 @@ SRC_URI = "http://matt.ucc.asn.au/dropbear/releases/dropbear-${PV}.tar.bz2 \
|
||||
file://dropbear.socket \
|
||||
file://dropbear.default \
|
||||
${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} \
|
||||
${@bb.utils.contains('PACKAGECONFIG', 'disable-weak-ciphers', 'file://dropbear-disable-weak-ciphers.patch', '', d)} "
|
||||
${@bb.utils.contains('PACKAGECONFIG', 'disable-weak-ciphers', 'file://dropbear-disable-weak-ciphers.patch', '', d)} \
|
||||
file://CVE-2020-36254.patch \
|
||||
"
|
||||
|
||||
PAM_SRC_URI = "file://0005-dropbear-enable-pam.patch \
|
||||
file://0006-dropbear-configuration-file.patch \
|
||||
|
||||
29
meta/recipes-core/dropbear/dropbear/CVE-2020-36254.patch
Normal file
29
meta/recipes-core/dropbear/dropbear/CVE-2020-36254.patch
Normal file
@@ -0,0 +1,29 @@
|
||||
From c96c48d62aefc372f2105293ddf8cff2d116dc3a Mon Sep 17 00:00:00 2001
|
||||
From: Haelwenn Monnier <contact+github.com@hacktivis.me>
|
||||
Date: Mon, 25 May 2020 14:54:29 +0200
|
||||
Subject: [PATCH] scp.c: Port OpenSSH CVE-2018-20685 fix (#80)
|
||||
|
||||
Reference:
|
||||
https://github.com/mkj/dropbear/commit/8f8a3dff705fad774a10864a2e3dbcfa9779ceff
|
||||
|
||||
CVE: CVE-2020-36254
|
||||
Upstream-Status: Backport
|
||||
|
||||
---
|
||||
scp.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/scp.c b/scp.c
|
||||
index 742ae00..7b8e7d2 100644
|
||||
--- a/scp.c
|
||||
+++ b/scp.c
|
||||
@@ -935,7 +935,8 @@ sink(int argc, char **argv)
|
||||
size = size * 10 + (*cp++ - '0');
|
||||
if (*cp++ != ' ')
|
||||
SCREWUP("size not delimited");
|
||||
- if ((strchr(cp, '/') != NULL) || (strcmp(cp, "..") == 0)) {
|
||||
+ if (*cp == '\0' || strchr(cp, '/') != NULL ||
|
||||
+ strcmp(cp, ".") == 0 || strcmp(cp, "..") == 0) {
|
||||
run_err("error: unexpected filename: %s", cp);
|
||||
exit(1);
|
||||
}
|
||||
65
meta/recipes-core/expat/expat/CVE-2021-45960.patch
Normal file
65
meta/recipes-core/expat/expat/CVE-2021-45960.patch
Normal file
@@ -0,0 +1,65 @@
|
||||
From 0adcb34c49bee5b19bd29b16a578c510c23597ea Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Mon, 27 Dec 2021 20:15:02 +0100
|
||||
Subject: [PATCH] lib: Detect and prevent troublesome left shifts in function
|
||||
storeAtts (CVE-2021-45960)
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://github.com/libexpat/libexpat/pull/534/commits/0adcb34c49bee5b19bd29b16a578c510c23597ea
|
||||
|
||||
CVE: CVE-2021-45960
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
expat/lib/xmlparse.c | 31 +++++++++++++++++++++++++++++--
|
||||
1 file changed, 29 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
|
||||
index d730f41c3..b47c31b05 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -3414,7 +3414,13 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
|
||||
if (nPrefixes) {
|
||||
int j; /* hash table index */
|
||||
unsigned long version = parser->m_nsAttsVersion;
|
||||
- int nsAttsSize = (int)1 << parser->m_nsAttsPower;
|
||||
+
|
||||
+ /* Detect and prevent invalid shift */
|
||||
+ if (parser->m_nsAttsPower >= sizeof(unsigned int) * 8 /* bits per byte */) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
+ unsigned int nsAttsSize = 1u << parser->m_nsAttsPower;
|
||||
unsigned char oldNsAttsPower = parser->m_nsAttsPower;
|
||||
/* size of hash table must be at least 2 * (# of prefixed attributes) */
|
||||
if ((nPrefixes << 1)
|
||||
@@ -3425,7 +3431,28 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
|
||||
;
|
||||
if (parser->m_nsAttsPower < 3)
|
||||
parser->m_nsAttsPower = 3;
|
||||
- nsAttsSize = (int)1 << parser->m_nsAttsPower;
|
||||
+
|
||||
+ /* Detect and prevent invalid shift */
|
||||
+ if (parser->m_nsAttsPower >= sizeof(nsAttsSize) * 8 /* bits per byte */) {
|
||||
+ /* Restore actual size of memory in m_nsAtts */
|
||||
+ parser->m_nsAttsPower = oldNsAttsPower;
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
+ nsAttsSize = 1u << parser->m_nsAttsPower;
|
||||
+
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if (nsAttsSize > (size_t)(-1) / sizeof(NS_ATT)) {
|
||||
+ /* Restore actual size of memory in m_nsAtts */
|
||||
+ parser->m_nsAttsPower = oldNsAttsPower;
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
temp = (NS_ATT *)REALLOC(parser, parser->m_nsAtts,
|
||||
nsAttsSize * sizeof(NS_ATT));
|
||||
if (! temp) {
|
||||
43
meta/recipes-core/expat/expat/CVE-2021-46143.patch
Normal file
43
meta/recipes-core/expat/expat/CVE-2021-46143.patch
Normal file
@@ -0,0 +1,43 @@
|
||||
From 85ae9a2d7d0e9358f356b33977b842df8ebaec2b Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Sat, 25 Dec 2021 20:52:08 +0100
|
||||
Subject: [PATCH] lib: Prevent integer overflow on m_groupSize in function
|
||||
doProlog (CVE-2021-46143)
|
||||
|
||||
---
|
||||
expat/lib/xmlparse.c | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
|
||||
index b47c31b0..8f243126 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -5046,6 +5046,11 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
|
||||
if (parser->m_prologState.level >= parser->m_groupSize) {
|
||||
if (parser->m_groupSize) {
|
||||
{
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (parser->m_groupSize > (unsigned int)(-1) / 2u) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
char *const new_connector = (char *)REALLOC(
|
||||
parser, parser->m_groupConnector, parser->m_groupSize *= 2);
|
||||
if (new_connector == NULL) {
|
||||
@@ -5056,6 +5061,16 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
|
||||
}
|
||||
|
||||
if (dtd->scaffIndex) {
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if (parser->m_groupSize > (size_t)(-1) / sizeof(int)) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
int *const new_scaff_index = (int *)REALLOC(
|
||||
parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int));
|
||||
if (new_scaff_index == NULL)
|
||||
257
meta/recipes-core/expat/expat/CVE-2022-22822-27.patch
Normal file
257
meta/recipes-core/expat/expat/CVE-2022-22822-27.patch
Normal file
@@ -0,0 +1,257 @@
|
||||
From 9f93e8036e842329863bf20395b8fb8f73834d9e Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Thu, 30 Dec 2021 22:46:03 +0100
|
||||
Subject: [PATCH] lib: Prevent integer overflow at multiple places
|
||||
(CVE-2022-22822 to CVE-2022-22827)
|
||||
|
||||
The involved functions are:
|
||||
- addBinding (CVE-2022-22822)
|
||||
- build_model (CVE-2022-22823)
|
||||
- defineAttribute (CVE-2022-22824)
|
||||
- lookup (CVE-2022-22825)
|
||||
- nextScaffoldPart (CVE-2022-22826)
|
||||
- storeAtts (CVE-2022-22827)
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://github.com/libexpat/libexpat/pull/539/commits/9f93e8036e842329863bf20395b8fb8f73834d9e
|
||||
|
||||
CVE: CVE-2022-22822 CVE-2022-22823 CVE-2022-22824 CVE-2022-22825 CVE-2022-22826 CVE-2022-22827
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
expat/lib/xmlparse.c | 153 ++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 151 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
|
||||
index 8f243126..575e73ee 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -3261,13 +3261,38 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
|
||||
|
||||
/* get the attributes from the tokenizer */
|
||||
n = XmlGetAttributes(enc, attStr, parser->m_attsSize, parser->m_atts);
|
||||
+
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (n > INT_MAX - nDefaultAtts) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
if (n + nDefaultAtts > parser->m_attsSize) {
|
||||
int oldAttsSize = parser->m_attsSize;
|
||||
ATTRIBUTE *temp;
|
||||
#ifdef XML_ATTR_INFO
|
||||
XML_AttrInfo *temp2;
|
||||
#endif
|
||||
+
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if ((nDefaultAtts > INT_MAX - INIT_ATTS_SIZE)
|
||||
+ || (n > INT_MAX - (nDefaultAtts + INIT_ATTS_SIZE))) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
parser->m_attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
|
||||
+
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if ((unsigned)parser->m_attsSize > (size_t)(-1) / sizeof(ATTRIBUTE)) {
|
||||
+ parser->m_attsSize = oldAttsSize;
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
temp = (ATTRIBUTE *)REALLOC(parser, (void *)parser->m_atts,
|
||||
parser->m_attsSize * sizeof(ATTRIBUTE));
|
||||
if (temp == NULL) {
|
||||
@@ -3276,6 +3301,17 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
|
||||
}
|
||||
parser->m_atts = temp;
|
||||
#ifdef XML_ATTR_INFO
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+# if UINT_MAX >= SIZE_MAX
|
||||
+ if ((unsigned)parser->m_attsSize > (size_t)(-1) / sizeof(XML_AttrInfo)) {
|
||||
+ parser->m_attsSize = oldAttsSize;
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+# endif
|
||||
+
|
||||
temp2 = (XML_AttrInfo *)REALLOC(parser, (void *)parser->m_attInfo,
|
||||
parser->m_attsSize * sizeof(XML_AttrInfo));
|
||||
if (temp2 == NULL) {
|
||||
@@ -3610,9 +3646,31 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
|
||||
tagNamePtr->prefixLen = prefixLen;
|
||||
for (i = 0; localPart[i++];)
|
||||
; /* i includes null terminator */
|
||||
+
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (binding->uriLen > INT_MAX - prefixLen
|
||||
+ || i > INT_MAX - (binding->uriLen + prefixLen)) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
n = i + binding->uriLen + prefixLen;
|
||||
if (n > binding->uriAlloc) {
|
||||
TAG *p;
|
||||
+
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (n > INT_MAX - EXPAND_SPARE) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if ((unsigned)(n + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
uri = (XML_Char *)MALLOC(parser, (n + EXPAND_SPARE) * sizeof(XML_Char));
|
||||
if (! uri)
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
@@ -3708,6 +3766,21 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
|
||||
if (parser->m_freeBindingList) {
|
||||
b = parser->m_freeBindingList;
|
||||
if (len > b->uriAlloc) {
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (len > INT_MAX - EXPAND_SPARE) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
XML_Char *temp = (XML_Char *)REALLOC(
|
||||
parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE));
|
||||
if (temp == NULL)
|
||||
@@ -3720,6 +3793,21 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
|
||||
b = (BINDING *)MALLOC(parser, sizeof(BINDING));
|
||||
if (! b)
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
+
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (len > INT_MAX - EXPAND_SPARE) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
b->uri
|
||||
= (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE));
|
||||
if (! b->uri) {
|
||||
@@ -6141,7 +6229,24 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata,
|
||||
}
|
||||
} else {
|
||||
DEFAULT_ATTRIBUTE *temp;
|
||||
+
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (type->allocDefaultAtts > INT_MAX / 2) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
int count = type->allocDefaultAtts * 2;
|
||||
+
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if ((unsigned)count > (size_t)(-1) / sizeof(DEFAULT_ATTRIBUTE)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
temp = (DEFAULT_ATTRIBUTE *)REALLOC(parser, type->defaultAtts,
|
||||
(count * sizeof(DEFAULT_ATTRIBUTE)));
|
||||
if (temp == NULL)
|
||||
@@ -6792,8 +6897,20 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) {
|
||||
/* check for overflow (table is half full) */
|
||||
if (table->used >> (table->power - 1)) {
|
||||
unsigned char newPower = table->power + 1;
|
||||
+
|
||||
+ /* Detect and prevent invalid shift */
|
||||
+ if (newPower >= sizeof(unsigned long) * 8 /* bits per byte */) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
size_t newSize = (size_t)1 << newPower;
|
||||
unsigned long newMask = (unsigned long)newSize - 1;
|
||||
+
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (newSize > (size_t)(-1) / sizeof(NAMED *)) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
size_t tsize = newSize * sizeof(NAMED *);
|
||||
NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize);
|
||||
if (! newV)
|
||||
@@ -7143,6 +7260,20 @@ nextScaffoldPart(XML_Parser parser) {
|
||||
if (dtd->scaffCount >= dtd->scaffSize) {
|
||||
CONTENT_SCAFFOLD *temp;
|
||||
if (dtd->scaffold) {
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (dtd->scaffSize > UINT_MAX / 2u) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if (dtd->scaffSize > (size_t)(-1) / 2u / sizeof(CONTENT_SCAFFOLD)) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
temp = (CONTENT_SCAFFOLD *)REALLOC(
|
||||
parser, dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD));
|
||||
if (temp == NULL)
|
||||
@@ -7212,8 +7343,26 @@ build_model(XML_Parser parser) {
|
||||
XML_Content *ret;
|
||||
XML_Content *cpos;
|
||||
XML_Char *str;
|
||||
- int allocsize = (dtd->scaffCount * sizeof(XML_Content)
|
||||
- + (dtd->contentStringLen * sizeof(XML_Char)));
|
||||
+
|
||||
+ /* Detect and prevent integer overflow.
|
||||
+ * The preprocessor guard addresses the "always false" warning
|
||||
+ * from -Wtype-limits on platforms where
|
||||
+ * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
|
||||
+#if UINT_MAX >= SIZE_MAX
|
||||
+ if (dtd->scaffCount > (size_t)(-1) / sizeof(XML_Content)) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ if (dtd->contentStringLen > (size_t)(-1) / sizeof(XML_Char)) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+#endif
|
||||
+ if (dtd->scaffCount * sizeof(XML_Content)
|
||||
+ > (size_t)(-1) - dtd->contentStringLen * sizeof(XML_Char)) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ const size_t allocsize = (dtd->scaffCount * sizeof(XML_Content)
|
||||
+ + (dtd->contentStringLen * sizeof(XML_Char)));
|
||||
|
||||
ret = (XML_Content *)MALLOC(parser, allocsize);
|
||||
if (! ret)
|
||||
@@ -1,6 +1,6 @@
|
||||
SUMMARY = "A stream-oriented XML parser library"
|
||||
DESCRIPTION = "Expat is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers for things the parser might find in the XML document (like start tags)"
|
||||
HOMEPAGE = "http://expat.sourceforge.net/"
|
||||
HOMEPAGE = "https://github.com/libexpat/libexpat"
|
||||
SECTION = "libs"
|
||||
LICENSE = "MIT"
|
||||
|
||||
@@ -8,6 +8,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=5b8620d98e49772d95fc1d291c26aa79"
|
||||
|
||||
SRC_URI = "git://github.com/libexpat/libexpat.git;protocol=https;branch=master \
|
||||
file://CVE-2013-0340.patch \
|
||||
file://CVE-2021-45960.patch \
|
||||
file://CVE-2021-46143.patch \
|
||||
file://CVE-2022-22822-27.patch \
|
||||
file://libtool-tag.patch \
|
||||
"
|
||||
|
||||
|
||||
129
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27218.patch
Normal file
129
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27218.patch
Normal file
@@ -0,0 +1,129 @@
|
||||
Backport of:
|
||||
|
||||
From 0f384c88a241bbbd884487b1c40b7b75f1e638d3 Mon Sep 17 00:00:00 2001
|
||||
From: Krzesimir Nowak <qdlacz@gmail.com>
|
||||
Date: Wed, 10 Feb 2021 23:51:07 +0100
|
||||
Subject: [PATCH] gbytearray: Do not accept too large byte arrays
|
||||
|
||||
GByteArray uses guint for storing the length of the byte array, but it
|
||||
also has a constructor (g_byte_array_new_take) that takes length as a
|
||||
gsize. gsize may be larger than guint (64 bits for gsize vs 32 bits
|
||||
for guint). It is possible to call the function with a value greater
|
||||
than G_MAXUINT, which will result in silent length truncation. This
|
||||
may happen as a result of unreffing GBytes into GByteArray, so rather
|
||||
be loud about it.
|
||||
|
||||
(Test case tweaked by Philip Withnall.)
|
||||
|
||||
(Backport 2.66: Add #include gstrfuncsprivate.h in the test case for
|
||||
`g_memdup2()`.)
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27218
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
glib/garray.c | 6 ++++++
|
||||
glib/gbytes.c | 4 ++++
|
||||
glib/tests/bytes.c | 35 ++++++++++++++++++++++++++++++++++-
|
||||
3 files changed, 44 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/glib/garray.c
|
||||
+++ b/glib/garray.c
|
||||
@@ -2234,6 +2234,10 @@ g_byte_array_steal (GByteArray *array,
|
||||
* Create byte array containing the data. The data will be owned by the array
|
||||
* and will be freed with g_free(), i.e. it could be allocated using g_strdup().
|
||||
*
|
||||
+ * Do not use it if @len is greater than %G_MAXUINT. #GByteArray
|
||||
+ * stores the length of its data in #guint, which may be shorter than
|
||||
+ * #gsize.
|
||||
+ *
|
||||
* Since: 2.32
|
||||
*
|
||||
* Returns: (transfer full): a new #GByteArray
|
||||
@@ -2245,6 +2249,8 @@ g_byte_array_new_take (guint8 *data,
|
||||
GByteArray *array;
|
||||
GRealArray *real;
|
||||
|
||||
+ g_return_val_if_fail (len <= G_MAXUINT, NULL);
|
||||
+
|
||||
array = g_byte_array_new ();
|
||||
real = (GRealArray *)array;
|
||||
g_assert (real->data == NULL);
|
||||
--- a/glib/gbytes.c
|
||||
+++ b/glib/gbytes.c
|
||||
@@ -519,6 +519,10 @@ g_bytes_unref_to_data (GBytes *bytes,
|
||||
* g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all
|
||||
* other cases the data is copied.
|
||||
*
|
||||
+ * Do not use it if @bytes contains more than %G_MAXUINT
|
||||
+ * bytes. #GByteArray stores the length of its data in #guint, which
|
||||
+ * may be shorter than #gsize, that @bytes is using.
|
||||
+ *
|
||||
* Returns: (transfer full): a new mutable #GByteArray containing the same byte data
|
||||
*
|
||||
* Since: 2.32
|
||||
--- a/glib/tests/bytes.c
|
||||
+++ b/glib/tests/bytes.c
|
||||
@@ -10,12 +10,12 @@
|
||||
*/
|
||||
|
||||
#undef G_DISABLE_ASSERT
|
||||
-#undef G_LOG_DOMAIN
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "glib.h"
|
||||
+#include "glib/gstrfuncsprivate.h"
|
||||
|
||||
/* Keep in sync with glib/gbytes.c */
|
||||
struct _GBytes
|
||||
@@ -334,6 +334,38 @@ test_to_array_transferred (void)
|
||||
}
|
||||
|
||||
static void
|
||||
+test_to_array_transferred_oversize (void)
|
||||
+{
|
||||
+ g_test_message ("g_bytes_unref_to_array() can only take GBytes up to "
|
||||
+ "G_MAXUINT in length; test that longer ones are rejected");
|
||||
+
|
||||
+ if (sizeof (guint) >= sizeof (gsize))
|
||||
+ {
|
||||
+ g_test_skip ("Skipping test as guint is not smaller than gsize");
|
||||
+ }
|
||||
+ else if (g_test_undefined ())
|
||||
+ {
|
||||
+ GByteArray *array = NULL;
|
||||
+ GBytes *bytes = NULL;
|
||||
+ gpointer data = g_memdup2 (NYAN, N_NYAN);
|
||||
+ gsize len = ((gsize) G_MAXUINT) + 1;
|
||||
+
|
||||
+ bytes = g_bytes_new_take (data, len);
|
||||
+ g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||
+ "g_byte_array_new_take: assertion 'len <= G_MAXUINT' failed");
|
||||
+ array = g_bytes_unref_to_array (g_steal_pointer (&bytes));
|
||||
+ g_test_assert_expected_messages ();
|
||||
+ g_assert_null (array);
|
||||
+
|
||||
+ g_free (data);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ g_test_skip ("Skipping test as testing undefined behaviour is disabled");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
test_to_array_two_refs (void)
|
||||
{
|
||||
gconstpointer memory;
|
||||
@@ -410,6 +442,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/bytes/to-array/transfered", test_to_array_transferred);
|
||||
g_test_add_func ("/bytes/to-array/two-refs", test_to_array_two_refs);
|
||||
g_test_add_func ("/bytes/to-array/non-malloc", test_to_array_non_malloc);
|
||||
+ g_test_add_func ("/bytes/to-array/transferred/oversize", test_to_array_transferred_oversize);
|
||||
g_test_add_func ("/bytes/null", test_null);
|
||||
|
||||
return g_test_run ();
|
||||
170
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-01.patch
Normal file
170
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-01.patch
Normal file
@@ -0,0 +1,170 @@
|
||||
Backport of:
|
||||
|
||||
From 5e5f75a77e399c638be66d74e5daa8caeb433e00 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 13:30:52 +0000
|
||||
Subject: [PATCH 01/11] gstrfuncs: Add internal g_memdup2() function
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This will replace the existing `g_memdup()` function for use within
|
||||
GLib. It has an unavoidable security flaw of taking its `byte_size`
|
||||
argument as a `guint` rather than as a `gsize`. Most callers will
|
||||
expect it to be a `gsize`, and may pass in large values which could
|
||||
silently be truncated, resulting in an undersize allocation compared
|
||||
to what the caller expects.
|
||||
|
||||
This could lead to a classic buffer overflow vulnerability for many
|
||||
callers of `g_memdup()`.
|
||||
|
||||
`g_memdup2()`, in comparison, takes its `byte_size` as a `gsize`.
|
||||
|
||||
Spotted by Kevin Backhouse of GHSL.
|
||||
|
||||
In GLib 2.68, `g_memdup2()` will be a new public API. In this version
|
||||
for backport to older stable releases, it’s a new `static inline` API
|
||||
in a private header, so that use of `g_memdup()` within GLib can be
|
||||
fixed without adding a new API in a stable release series.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: GHSL-2021-045
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
docs/reference/glib/meson.build | 1 +
|
||||
glib/gstrfuncsprivate.h | 55 +++++++++++++++++++++++++++++++++
|
||||
glib/meson.build | 1 +
|
||||
glib/tests/strfuncs.c | 23 ++++++++++++++
|
||||
4 files changed, 80 insertions(+)
|
||||
create mode 100644 glib/gstrfuncsprivate.h
|
||||
|
||||
--- a/docs/reference/glib/meson.build
|
||||
+++ b/docs/reference/glib/meson.build
|
||||
@@ -22,6 +22,7 @@ if get_option('gtk_doc')
|
||||
'gprintfint.h',
|
||||
'gmirroringtable.h',
|
||||
'gscripttable.h',
|
||||
+ 'gstrfuncsprivate.h',
|
||||
'glib-mirroring-tab',
|
||||
'gnulib',
|
||||
'pcre',
|
||||
--- /dev/null
|
||||
+++ b/glib/gstrfuncsprivate.h
|
||||
@@ -0,0 +1,55 @@
|
||||
+/* GLIB - Library of useful routines for C programming
|
||||
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+#include <glib.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+/*
|
||||
+ * g_memdup2:
|
||||
+ * @mem: (nullable): the memory to copy.
|
||||
+ * @byte_size: the number of bytes to copy.
|
||||
+ *
|
||||
+ * Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
|
||||
+ * from @mem. If @mem is %NULL it returns %NULL.
|
||||
+ *
|
||||
+ * This replaces g_memdup(), which was prone to integer overflows when
|
||||
+ * converting the argument from a #gsize to a #guint.
|
||||
+ *
|
||||
+ * This static inline version is a backport of the new public API from
|
||||
+ * GLib 2.68, kept internal to GLib for backport to older stable releases.
|
||||
+ * See https://gitlab.gnome.org/GNOME/glib/-/issues/2319.
|
||||
+ *
|
||||
+ * Returns: (nullable): a pointer to the newly-allocated copy of the memory,
|
||||
+ * or %NULL if @mem is %NULL.
|
||||
+ * Since: 2.68
|
||||
+ */
|
||||
+static inline gpointer
|
||||
+g_memdup2 (gconstpointer mem,
|
||||
+ gsize byte_size)
|
||||
+{
|
||||
+ gpointer new_mem;
|
||||
+
|
||||
+ if (mem && byte_size != 0)
|
||||
+ {
|
||||
+ new_mem = g_malloc (byte_size);
|
||||
+ memcpy (new_mem, mem, byte_size);
|
||||
+ }
|
||||
+ else
|
||||
+ new_mem = NULL;
|
||||
+
|
||||
+ return new_mem;
|
||||
+}
|
||||
--- a/glib/meson.build
|
||||
+++ b/glib/meson.build
|
||||
@@ -268,6 +268,7 @@ glib_sources = files(
|
||||
'gslist.c',
|
||||
'gstdio.c',
|
||||
'gstrfuncs.c',
|
||||
+ 'gstrfuncsprivate.h',
|
||||
'gstring.c',
|
||||
'gstringchunk.c',
|
||||
'gtestutils.c',
|
||||
--- a/glib/tests/strfuncs.c
|
||||
+++ b/glib/tests/strfuncs.c
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <string.h>
|
||||
#include "glib.h"
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
+
|
||||
#if defined (_MSC_VER) && (_MSC_VER <= 1800)
|
||||
#define isnan(x) _isnan(x)
|
||||
|
||||
@@ -219,6 +221,26 @@ test_memdup (void)
|
||||
g_free (str_dup);
|
||||
}
|
||||
|
||||
+/* Testing g_memdup2() function with various positive and negative cases */
|
||||
+static void
|
||||
+test_memdup2 (void)
|
||||
+{
|
||||
+ gchar *str_dup = NULL;
|
||||
+ const gchar *str = "The quick brown fox jumps over the lazy dog";
|
||||
+
|
||||
+ /* Testing negative cases */
|
||||
+ g_assert_null (g_memdup2 (NULL, 1024));
|
||||
+ g_assert_null (g_memdup2 (str, 0));
|
||||
+ g_assert_null (g_memdup2 (NULL, 0));
|
||||
+
|
||||
+ /* Testing normal usage cases */
|
||||
+ str_dup = g_memdup2 (str, strlen (str) + 1);
|
||||
+ g_assert_nonnull (str_dup);
|
||||
+ g_assert_cmpstr (str, ==, str_dup);
|
||||
+
|
||||
+ g_free (str_dup);
|
||||
+}
|
||||
+
|
||||
/* Testing g_strpcpy() function with various positive and negative cases */
|
||||
static void
|
||||
test_stpcpy (void)
|
||||
@@ -2523,6 +2545,7 @@ main (int argc,
|
||||
g_test_add_func ("/strfuncs/has-prefix", test_has_prefix);
|
||||
g_test_add_func ("/strfuncs/has-suffix", test_has_suffix);
|
||||
g_test_add_func ("/strfuncs/memdup", test_memdup);
|
||||
+ g_test_add_func ("/strfuncs/memdup2", test_memdup2);
|
||||
g_test_add_func ("/strfuncs/stpcpy", test_stpcpy);
|
||||
g_test_add_func ("/strfuncs/str_match_string", test_str_match_string);
|
||||
g_test_add_func ("/strfuncs/str_tokenize_and_fold", test_str_tokenize_and_fold);
|
||||
249
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-02.patch
Normal file
249
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-02.patch
Normal file
@@ -0,0 +1,249 @@
|
||||
From be8834340a2d928ece82025463ae23dee2c333d0 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 13:37:56 +0000
|
||||
Subject: [PATCH 02/11] gio: Use g_memdup2() instead of g_memdup() in obvious
|
||||
places
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Convert all the call sites which use `g_memdup()`’s length argument
|
||||
trivially (for example, by passing a `sizeof()`), so that they use
|
||||
`g_memdup2()` instead.
|
||||
|
||||
In almost all of these cases the use of `g_memdup()` would not have
|
||||
caused problems, but it will soon be deprecated, so best port away from
|
||||
it.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gdbusconnection.c | 5 +++--
|
||||
gio/gdbusinterfaceskeleton.c | 3 ++-
|
||||
gio/gfile.c | 7 ++++---
|
||||
gio/gsettingsschema.c | 5 +++--
|
||||
gio/gwin32registrykey.c | 8 +++++---
|
||||
gio/tests/async-close-output-stream.c | 6 ++++--
|
||||
gio/tests/gdbus-export.c | 5 +++--
|
||||
gio/win32/gwinhttpfile.c | 9 +++++----
|
||||
8 files changed, 29 insertions(+), 19 deletions(-)
|
||||
|
||||
--- a/gio/gdbusconnection.c
|
||||
+++ b/gio/gdbusconnection.c
|
||||
@@ -110,6 +110,7 @@
|
||||
#include "gasyncinitable.h"
|
||||
#include "giostream.h"
|
||||
#include "gasyncresult.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gtask.h"
|
||||
#include "gmarshal-internal.h"
|
||||
|
||||
@@ -4007,7 +4008,7 @@ _g_dbus_interface_vtable_copy (const GDB
|
||||
/* Don't waste memory by copying padding - remember to update this
|
||||
* when changing struct _GDBusInterfaceVTable in gdbusconnection.h
|
||||
*/
|
||||
- return g_memdup ((gconstpointer) vtable, 3 * sizeof (gpointer));
|
||||
+ return g_memdup2 ((gconstpointer) vtable, 3 * sizeof (gpointer));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -4024,7 +4025,7 @@ _g_dbus_subtree_vtable_copy (const GDBus
|
||||
/* Don't waste memory by copying padding - remember to update this
|
||||
* when changing struct _GDBusSubtreeVTable in gdbusconnection.h
|
||||
*/
|
||||
- return g_memdup ((gconstpointer) vtable, 3 * sizeof (gpointer));
|
||||
+ return g_memdup2 ((gconstpointer) vtable, 3 * sizeof (gpointer));
|
||||
}
|
||||
|
||||
static void
|
||||
--- a/gio/gdbusinterfaceskeleton.c
|
||||
+++ b/gio/gdbusinterfaceskeleton.c
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "gdbusmethodinvocation.h"
|
||||
#include "gdbusconnection.h"
|
||||
#include "gmarshal-internal.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gtask.h"
|
||||
#include "gioerror.h"
|
||||
|
||||
@@ -701,7 +702,7 @@ add_connection_locked (GDBusInterfaceSke
|
||||
* properly before building the hooked_vtable, so we create it
|
||||
* once at the last minute.
|
||||
*/
|
||||
- interface_->priv->hooked_vtable = g_memdup (g_dbus_interface_skeleton_get_vtable (interface_), sizeof (GDBusInterfaceVTable));
|
||||
+ interface_->priv->hooked_vtable = g_memdup2 (g_dbus_interface_skeleton_get_vtable (interface_), sizeof (GDBusInterfaceVTable));
|
||||
interface_->priv->hooked_vtable->method_call = skeleton_intercept_handle_method_call;
|
||||
}
|
||||
|
||||
--- a/gio/gfile.c
|
||||
+++ b/gio/gfile.c
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "gasyncresult.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -7854,7 +7855,7 @@ measure_disk_usage_progress (gboolean re
|
||||
g_main_context_invoke_full (g_task_get_context (task),
|
||||
g_task_get_priority (task),
|
||||
measure_disk_usage_invoke_progress,
|
||||
- g_memdup (&progress, sizeof progress),
|
||||
+ g_memdup2 (&progress, sizeof progress),
|
||||
g_free);
|
||||
}
|
||||
|
||||
@@ -7872,7 +7873,7 @@ measure_disk_usage_thread (GTask
|
||||
data->progress_callback ? measure_disk_usage_progress : NULL, task,
|
||||
&result.disk_usage, &result.num_dirs, &result.num_files,
|
||||
&error))
|
||||
- g_task_return_pointer (task, g_memdup (&result, sizeof result), g_free);
|
||||
+ g_task_return_pointer (task, g_memdup2 (&result, sizeof result), g_free);
|
||||
else
|
||||
g_task_return_error (task, error);
|
||||
}
|
||||
@@ -7896,7 +7897,7 @@ g_file_real_measure_disk_usage_async (GF
|
||||
|
||||
task = g_task_new (file, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, g_file_real_measure_disk_usage_async);
|
||||
- g_task_set_task_data (task, g_memdup (&data, sizeof data), g_free);
|
||||
+ g_task_set_task_data (task, g_memdup2 (&data, sizeof data), g_free);
|
||||
g_task_set_priority (task, io_priority);
|
||||
|
||||
g_task_run_in_thread (task, measure_disk_usage_thread);
|
||||
--- a/gio/gsettingsschema.c
|
||||
+++ b/gio/gsettingsschema.c
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "gsettingsschema-internal.h"
|
||||
#include "gsettings.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
|
||||
#include "gvdb/gvdb-reader.h"
|
||||
#include "strinfo.c"
|
||||
@@ -1067,9 +1068,9 @@ g_settings_schema_list_children (GSettin
|
||||
|
||||
if (g_str_has_suffix (key, "/"))
|
||||
{
|
||||
- gint length = strlen (key);
|
||||
+ gsize length = strlen (key);
|
||||
|
||||
- strv[j] = g_memdup (key, length);
|
||||
+ strv[j] = g_memdup2 (key, length);
|
||||
strv[j][length - 1] = '\0';
|
||||
j++;
|
||||
}
|
||||
--- a/gio/gwin32registrykey.c
|
||||
+++ b/gio/gwin32registrykey.c
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <ntstatus.h>
|
||||
#include <winternl.h>
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
+
|
||||
#ifndef _WDMDDK_
|
||||
typedef enum _KEY_INFORMATION_CLASS {
|
||||
KeyBasicInformation,
|
||||
@@ -247,7 +249,7 @@ g_win32_registry_value_iter_copy (const
|
||||
new_iter->value_name_size = iter->value_name_size;
|
||||
|
||||
if (iter->value_data != NULL)
|
||||
- new_iter->value_data = g_memdup (iter->value_data, iter->value_data_size);
|
||||
+ new_iter->value_data = g_memdup2 (iter->value_data, iter->value_data_size);
|
||||
|
||||
new_iter->value_data_size = iter->value_data_size;
|
||||
|
||||
@@ -268,8 +270,8 @@ g_win32_registry_value_iter_copy (const
|
||||
new_iter->value_data_expanded_charsize = iter->value_data_expanded_charsize;
|
||||
|
||||
if (iter->value_data_expanded_u8 != NULL)
|
||||
- new_iter->value_data_expanded_u8 = g_memdup (iter->value_data_expanded_u8,
|
||||
- iter->value_data_expanded_charsize);
|
||||
+ new_iter->value_data_expanded_u8 = g_memdup2 (iter->value_data_expanded_u8,
|
||||
+ iter->value_data_expanded_charsize);
|
||||
|
||||
new_iter->value_data_expanded_u8_size = iter->value_data_expanded_charsize;
|
||||
|
||||
--- a/gio/tests/async-close-output-stream.c
|
||||
+++ b/gio/tests/async-close-output-stream.c
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
+
|
||||
#define DATA_TO_WRITE "Hello world\n"
|
||||
|
||||
typedef struct
|
||||
@@ -147,9 +149,9 @@ prepare_data (SetupData *data,
|
||||
|
||||
data->expected_size = g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (data->data_stream));
|
||||
|
||||
- g_assert_cmpint (data->expected_size, >, 0);
|
||||
+ g_assert_cmpuint (data->expected_size, >, 0);
|
||||
|
||||
- data->expected_output = g_memdup (written, (guint)data->expected_size);
|
||||
+ data->expected_output = g_memdup2 (written, data->expected_size);
|
||||
|
||||
/* then recreate the streams and prepare them for the asynchronous close */
|
||||
destroy_streams (data);
|
||||
--- a/gio/tests/gdbus-export.c
|
||||
+++ b/gio/tests/gdbus-export.c
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gdbus-tests.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
|
||||
/* all tests rely on a shared mainloop */
|
||||
static GMainLoop *loop = NULL;
|
||||
@@ -671,7 +672,7 @@ subtree_introspect (GDBusConnection
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
- return g_memdup (interfaces, 2 * sizeof (void *));
|
||||
+ return g_memdup2 (interfaces, 2 * sizeof (void *));
|
||||
}
|
||||
|
||||
static const GDBusInterfaceVTable *
|
||||
@@ -727,7 +728,7 @@ dynamic_subtree_introspect (GDBusConnect
|
||||
{
|
||||
const GDBusInterfaceInfo *interfaces[2] = { &dyna_interface_info, NULL };
|
||||
|
||||
- return g_memdup (interfaces, 2 * sizeof (void *));
|
||||
+ return g_memdup2 (interfaces, 2 * sizeof (void *));
|
||||
}
|
||||
|
||||
static const GDBusInterfaceVTable *
|
||||
--- a/gio/win32/gwinhttpfile.c
|
||||
+++ b/gio/win32/gwinhttpfile.c
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "gio/gfile.h"
|
||||
#include "gio/gfileattribute.h"
|
||||
#include "gio/gfileinfo.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gwinhttpfile.h"
|
||||
#include "gwinhttpfileinputstream.h"
|
||||
#include "gwinhttpfileoutputstream.h"
|
||||
@@ -393,10 +394,10 @@
|
||||
child = g_object_new (G_TYPE_WINHTTP_FILE, NULL);
|
||||
child->vfs = winhttp_file->vfs;
|
||||
child->url = winhttp_file->url;
|
||||
- child->url.lpszScheme = g_memdup (winhttp_file->url.lpszScheme, (winhttp_file->url.dwSchemeLength+1)*2);
|
||||
- child->url.lpszHostName = g_memdup (winhttp_file->url.lpszHostName, (winhttp_file->url.dwHostNameLength+1)*2);
|
||||
- child->url.lpszUserName = g_memdup (winhttp_file->url.lpszUserName, (winhttp_file->url.dwUserNameLength+1)*2);
|
||||
- child->url.lpszPassword = g_memdup (winhttp_file->url.lpszPassword, (winhttp_file->url.dwPasswordLength+1)*2);
|
||||
+ child->url.lpszScheme = g_memdup2 (winhttp_file->url.lpszScheme, (winhttp_file->url.dwSchemeLength+1)*2);
|
||||
+ child->url.lpszHostName = g_memdup2 (winhttp_file->url.lpszHostName, (winhttp_file->url.dwHostNameLength+1)*2);
|
||||
+ child->url.lpszUserName = g_memdup2 (winhttp_file->url.lpszUserName, (winhttp_file->url.dwUserNameLength+1)*2);
|
||||
+ child->url.lpszPassword = g_memdup2 (winhttp_file->url.lpszPassword, (winhttp_file->url.dwPasswordLength+1)*2);
|
||||
child->url.lpszUrlPath = wnew_path;
|
||||
child->url.dwUrlPathLength = wcslen (wnew_path);
|
||||
child->url.lpszExtraInfo = NULL;
|
||||
131
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-03.patch
Normal file
131
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-03.patch
Normal file
@@ -0,0 +1,131 @@
|
||||
From 6110caea45b235420b98cd41d845cc92238f6781 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 13:39:25 +0000
|
||||
Subject: [PATCH 03/11] gobject: Use g_memdup2() instead of g_memdup() in
|
||||
obvious places
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Convert all the call sites which use `g_memdup()`’s length argument
|
||||
trivially (for example, by passing a `sizeof()`), so that they use
|
||||
`g_memdup2()` instead.
|
||||
|
||||
In almost all of these cases the use of `g_memdup()` would not have
|
||||
caused problems, but it will soon be deprecated, so best port away from
|
||||
it.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gobject/gsignal.c | 3 ++-
|
||||
gobject/gtype.c | 9 +++++----
|
||||
gobject/gtypemodule.c | 3 ++-
|
||||
gobject/tests/param.c | 4 +++-
|
||||
4 files changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/gobject/gsignal.c
|
||||
+++ b/gobject/gsignal.c
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "gsignal.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gtype-private.h"
|
||||
#include "gbsearcharray.h"
|
||||
#include "gvaluecollector.h"
|
||||
@@ -1809,7 +1810,7 @@ g_signal_newv (const gchar *signal
|
||||
node->single_va_closure_is_valid = FALSE;
|
||||
node->flags = signal_flags & G_SIGNAL_FLAGS_MASK;
|
||||
node->n_params = n_params;
|
||||
- node->param_types = g_memdup (param_types, sizeof (GType) * n_params);
|
||||
+ node->param_types = g_memdup2 (param_types, sizeof (GType) * n_params);
|
||||
node->return_type = return_type;
|
||||
node->class_closure_bsa = NULL;
|
||||
if (accumulator)
|
||||
--- a/gobject/gtype.c
|
||||
+++ b/gobject/gtype.c
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "glib-private.h"
|
||||
#include "gconstructor.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <windows.h>
|
||||
@@ -1470,7 +1471,7 @@ type_add_interface_Wm (TypeNode
|
||||
iholder->next = iface_node_get_holders_L (iface);
|
||||
iface_node_set_holders_W (iface, iholder);
|
||||
iholder->instance_type = NODE_TYPE (node);
|
||||
- iholder->info = info ? g_memdup (info, sizeof (*info)) : NULL;
|
||||
+ iholder->info = info ? g_memdup2 (info, sizeof (*info)) : NULL;
|
||||
iholder->plugin = plugin;
|
||||
|
||||
/* create an iface entry for this type */
|
||||
@@ -1731,7 +1732,7 @@ type_iface_retrieve_holder_info_Wm (Type
|
||||
INVALID_RECURSION ("g_type_plugin_*", iholder->plugin, NODE_NAME (iface));
|
||||
|
||||
check_interface_info_I (iface, instance_type, &tmp_info);
|
||||
- iholder->info = g_memdup (&tmp_info, sizeof (tmp_info));
|
||||
+ iholder->info = g_memdup2 (&tmp_info, sizeof (tmp_info));
|
||||
}
|
||||
|
||||
return iholder; /* we don't modify write lock upon returning NULL */
|
||||
@@ -2016,10 +2017,10 @@ type_iface_vtable_base_init_Wm (TypeNode
|
||||
IFaceEntry *pentry = type_lookup_iface_entry_L (pnode, iface);
|
||||
|
||||
if (pentry)
|
||||
- vtable = g_memdup (pentry->vtable, iface->data->iface.vtable_size);
|
||||
+ vtable = g_memdup2 (pentry->vtable, iface->data->iface.vtable_size);
|
||||
}
|
||||
if (!vtable)
|
||||
- vtable = g_memdup (iface->data->iface.dflt_vtable, iface->data->iface.vtable_size);
|
||||
+ vtable = g_memdup2 (iface->data->iface.dflt_vtable, iface->data->iface.vtable_size);
|
||||
entry->vtable = vtable;
|
||||
vtable->g_type = NODE_TYPE (iface);
|
||||
vtable->g_instance_type = NODE_TYPE (node);
|
||||
--- a/gobject/gtypemodule.c
|
||||
+++ b/gobject/gtypemodule.c
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gtypeplugin.h"
|
||||
#include "gtypemodule.h"
|
||||
|
||||
@@ -436,7 +437,7 @@ g_type_module_register_type (GTypeModule
|
||||
module_type_info->loaded = TRUE;
|
||||
module_type_info->info = *type_info;
|
||||
if (type_info->value_table)
|
||||
- module_type_info->info.value_table = g_memdup (type_info->value_table,
|
||||
+ module_type_info->info.value_table = g_memdup2 (type_info->value_table,
|
||||
sizeof (GTypeValueTable));
|
||||
|
||||
return module_type_info->type;
|
||||
--- a/gobject/tests/param.c
|
||||
+++ b/gobject/tests/param.c
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <glib-object.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
+
|
||||
static void
|
||||
test_param_value (void)
|
||||
{
|
||||
@@ -874,7 +876,7 @@ main (int argc, char *argv[])
|
||||
test_path = g_strdup_printf ("/param/implement/subprocess/%d-%d-%d-%d",
|
||||
data.change_this_flag, data.change_this_type,
|
||||
data.use_this_flag, data.use_this_type);
|
||||
- test_data = g_memdup (&data, sizeof (TestParamImplementData));
|
||||
+ test_data = g_memdup2 (&data, sizeof (TestParamImplementData));
|
||||
g_test_add_data_func_full (test_path, test_data, test_param_implement_child, g_free);
|
||||
g_free (test_path);
|
||||
}
|
||||
298
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-04.patch
Normal file
298
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-04.patch
Normal file
@@ -0,0 +1,298 @@
|
||||
Backport of:
|
||||
|
||||
From 0736b7c1e7cf4232c5d7eb2b0fbfe9be81bd3baa Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 13:41:21 +0000
|
||||
Subject: [PATCH 04/11] glib: Use g_memdup2() instead of g_memdup() in obvious
|
||||
places
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Convert all the call sites which use `g_memdup()`’s length argument
|
||||
trivially (for example, by passing a `sizeof()` or an existing `gsize`
|
||||
variable), so that they use `g_memdup2()` instead.
|
||||
|
||||
In almost all of these cases the use of `g_memdup()` would not have
|
||||
caused problems, but it will soon be deprecated, so best port away from
|
||||
it
|
||||
|
||||
In particular, this fixes an overflow within `g_bytes_new()`, identified
|
||||
as GHSL-2021-045 by GHSL team member Kevin Backhouse.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Fixes: GHSL-2021-045
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
glib/gbytes.c | 6 ++++--
|
||||
glib/gdir.c | 3 ++-
|
||||
glib/ghash.c | 7 ++++---
|
||||
glib/giochannel.c | 5 +++--
|
||||
glib/gslice.c | 3 ++-
|
||||
glib/gtestutils.c | 3 ++-
|
||||
glib/gvariant.c | 7 ++++---
|
||||
glib/gvarianttype.c | 3 ++-
|
||||
glib/tests/array-test.c | 4 +++-
|
||||
glib/tests/option-context.c | 6 ++++--
|
||||
glib/tests/uri.c | 8 +++++---
|
||||
11 files changed, 35 insertions(+), 20 deletions(-)
|
||||
|
||||
--- a/glib/gbytes.c
|
||||
+++ b/glib/gbytes.c
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
+
|
||||
/**
|
||||
* GBytes:
|
||||
*
|
||||
@@ -95,7 +97,7 @@ g_bytes_new (gconstpointer data,
|
||||
{
|
||||
g_return_val_if_fail (data != NULL || size == 0, NULL);
|
||||
|
||||
- return g_bytes_new_take (g_memdup (data, size), size);
|
||||
+ return g_bytes_new_take (g_memdup2 (data, size), size);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,7 +501,7 @@ g_bytes_unref_to_data (GBytes *bytes,
|
||||
* Copy: Non g_malloc (or compatible) allocator, or static memory,
|
||||
* so we have to copy, and then unref.
|
||||
*/
|
||||
- result = g_memdup (bytes->data, bytes->size);
|
||||
+ result = g_memdup2 (bytes->data, bytes->size);
|
||||
*size = bytes->size;
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
--- a/glib/gdir.c
|
||||
+++ b/glib/gdir.c
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "gconvert.h"
|
||||
#include "gfileutils.h"
|
||||
#include "gstrfuncs.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gtestutils.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
@@ -112,7 +113,7 @@ g_dir_open_with_errno (const gchar *path
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
- return g_memdup (&dir, sizeof dir);
|
||||
+ return g_memdup2 (&dir, sizeof dir);
|
||||
}
|
||||
|
||||
/**
|
||||
--- a/glib/ghash.c
|
||||
+++ b/glib/ghash.c
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "gmacros.h"
|
||||
#include "glib-private.h"
|
||||
#include "gstrfuncs.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gatomic.h"
|
||||
#include "gtestutils.h"
|
||||
#include "gslice.h"
|
||||
@@ -962,7 +963,7 @@ g_hash_table_ensure_keyval_fits (GHashTa
|
||||
if (hash_table->have_big_keys)
|
||||
{
|
||||
if (key != value)
|
||||
- hash_table->values = g_memdup (hash_table->keys, sizeof (gpointer) * hash_table->size);
|
||||
+ hash_table->values = g_memdup2 (hash_table->keys, sizeof (gpointer) * hash_table->size);
|
||||
/* Keys and values are both big now, so no need for further checks */
|
||||
return;
|
||||
}
|
||||
@@ -970,7 +971,7 @@ g_hash_table_ensure_keyval_fits (GHashTa
|
||||
{
|
||||
if (key != value)
|
||||
{
|
||||
- hash_table->values = g_memdup (hash_table->keys, sizeof (guint) * hash_table->size);
|
||||
+ hash_table->values = g_memdup2 (hash_table->keys, sizeof (guint) * hash_table->size);
|
||||
is_a_set = FALSE;
|
||||
}
|
||||
}
|
||||
@@ -998,7 +999,7 @@ g_hash_table_ensure_keyval_fits (GHashTa
|
||||
|
||||
/* Just split if necessary */
|
||||
if (is_a_set && key != value)
|
||||
- hash_table->values = g_memdup (hash_table->keys, sizeof (gpointer) * hash_table->size);
|
||||
+ hash_table->values = g_memdup2 (hash_table->keys, sizeof (gpointer) * hash_table->size);
|
||||
|
||||
#endif
|
||||
}
|
||||
--- a/glib/giochannel.c
|
||||
+++ b/glib/giochannel.c
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "giochannel.h"
|
||||
-
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gstrfuncs.h"
|
||||
#include "gtestutils.h"
|
||||
#include "glibintl.h"
|
||||
|
||||
@@ -1673,10 +1674,10 @@ g_io_channel_read_line (GIOChannel *cha
|
||||
|
||||
/* Copy the read bytes (including any embedded nuls) and nul-terminate.
|
||||
* `USE_BUF (channel)->str` is guaranteed to be nul-terminated as it’s a
|
||||
- * #GString, so it’s safe to call g_memdup() with +1 length to allocate
|
||||
+ * #GString, so it’s safe to call g_memdup2() with +1 length to allocate
|
||||
* a nul-terminator. */
|
||||
g_assert (USE_BUF (channel));
|
||||
- line = g_memdup (USE_BUF (channel)->str, got_length + 1);
|
||||
+ line = g_memdup2 (USE_BUF (channel)->str, got_length + 1);
|
||||
line[got_length] = '\0';
|
||||
*str_return = g_steal_pointer (&line);
|
||||
g_string_erase (USE_BUF (channel), 0, got_length);
|
||||
--- a/glib/gslice.c
|
||||
+++ b/glib/gslice.c
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "gmain.h"
|
||||
#include "gmem.h" /* gslice.h */
|
||||
#include "gstrfuncs.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gutils.h"
|
||||
#include "gtrashstack.h"
|
||||
#include "gtestutils.h"
|
||||
@@ -350,7 +351,7 @@ g_slice_get_config_state (GSliceConfig c
|
||||
array[i++] = allocator->contention_counters[address];
|
||||
array[i++] = allocator_get_magazine_threshold (allocator, address);
|
||||
*n_values = i;
|
||||
- return g_memdup (array, sizeof (array[0]) * *n_values);
|
||||
+ return g_memdup2 (array, sizeof (array[0]) * *n_values);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
--- a/glib/gtestutils.c
|
||||
+++ b/glib/gtestutils.c
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "gpattern.h"
|
||||
#include "grand.h"
|
||||
#include "gstrfuncs.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gtimer.h"
|
||||
#include "gslice.h"
|
||||
#include "gspawn.h"
|
||||
@@ -3803,7 +3804,7 @@ g_test_log_extract (GTestLogBuffer *tbuf
|
||||
if (p <= tbuffer->data->str + mlength)
|
||||
{
|
||||
g_string_erase (tbuffer->data, 0, mlength);
|
||||
- tbuffer->msgs = g_slist_prepend (tbuffer->msgs, g_memdup (&msg, sizeof (msg)));
|
||||
+ tbuffer->msgs = g_slist_prepend (tbuffer->msgs, g_memdup2 (&msg, sizeof (msg)));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
--- a/glib/gvariant.c
|
||||
+++ b/glib/gvariant.c
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gvariant
|
||||
@@ -725,7 +726,7 @@ g_variant_new_variant (GVariant *value)
|
||||
g_variant_ref_sink (value);
|
||||
|
||||
return g_variant_new_from_children (G_VARIANT_TYPE_VARIANT,
|
||||
- g_memdup (&value, sizeof value),
|
||||
+ g_memdup2 (&value, sizeof value),
|
||||
1, g_variant_is_trusted (value));
|
||||
}
|
||||
|
||||
@@ -1229,7 +1230,7 @@ g_variant_new_fixed_array (const GVarian
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- data = g_memdup (elements, n_elements * element_size);
|
||||
+ data = g_memdup2 (elements, n_elements * element_size);
|
||||
value = g_variant_new_from_data (array_type, data,
|
||||
n_elements * element_size,
|
||||
FALSE, g_free, data);
|
||||
@@ -1908,7 +1909,7 @@ g_variant_dup_bytestring (GVariant *valu
|
||||
if (length)
|
||||
*length = size;
|
||||
|
||||
- return g_memdup (original, size + 1);
|
||||
+ return g_memdup2 (original, size + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
--- a/glib/gvarianttype.c
|
||||
+++ b/glib/gvarianttype.c
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gvarianttype
|
||||
@@ -1181,7 +1182,7 @@ g_variant_type_new_tuple (const GVariant
|
||||
g_assert (offset < sizeof buffer);
|
||||
buffer[offset++] = ')';
|
||||
|
||||
- return (GVariantType *) g_memdup (buffer, offset);
|
||||
+ return (GVariantType *) g_memdup2 (buffer, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
--- a/glib/tests/array-test.c
|
||||
+++ b/glib/tests/array-test.c
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <string.h>
|
||||
#include "glib.h"
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
+
|
||||
/* Test data to be passed to any function which calls g_array_new(), providing
|
||||
* the parameters for that call. Most #GArray tests should be repeated for all
|
||||
* possible values of #ArrayTestData. */
|
||||
@@ -1917,7 +1919,7 @@ byte_array_new_take (void)
|
||||
GByteArray *gbarray;
|
||||
guint8 *data;
|
||||
|
||||
- data = g_memdup ("woooweeewow", 11);
|
||||
+ data = g_memdup2 ("woooweeewow", 11);
|
||||
gbarray = g_byte_array_new_take (data, 11);
|
||||
g_assert (gbarray->data == data);
|
||||
g_assert_cmpuint (gbarray->len, ==, 11);
|
||||
--- a/glib/tests/option-context.c
|
||||
+++ b/glib/tests/option-context.c
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
+#include "gstrfuncsprivate.h"
|
||||
+
|
||||
static GOptionEntry main_entries[] = {
|
||||
{ "main-switch", 0, 0,
|
||||
G_OPTION_ARG_NONE, NULL,
|
||||
@@ -256,7 +258,7 @@ join_stringv (int argc, char **argv)
|
||||
static char **
|
||||
copy_stringv (char **argv, int argc)
|
||||
{
|
||||
- return g_memdup (argv, sizeof (char *) * (argc + 1));
|
||||
+ return g_memdup2 (argv, sizeof (char *) * (argc + 1));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2323,7 +2325,7 @@ test_group_parse (void)
|
||||
g_option_context_add_group (context, group);
|
||||
|
||||
argv = split_string ("program --test arg1 -f arg2 --group-test arg3 --frob arg4 -z arg5", &argc);
|
||||
- orig_argv = g_memdup (argv, (argc + 1) * sizeof (char *));
|
||||
+ orig_argv = g_memdup2 (argv, (argc + 1) * sizeof (char *));
|
||||
|
||||
retval = g_option_context_parse (context, &argc, &argv, &error);
|
||||
|
||||
54
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-05.patch
Normal file
54
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-05.patch
Normal file
@@ -0,0 +1,54 @@
|
||||
From 0cbad673215ec8a049b7fe2ff44b0beed31b376e Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 16:12:24 +0000
|
||||
Subject: [PATCH 05/11] gwinhttpfile: Avoid arithmetic overflow when
|
||||
calculating a size
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The members of `URL_COMPONENTS` (`winhttp_file->url`) are `DWORD`s, i.e.
|
||||
32-bit unsigned integers. Adding to and multiplying them may cause them
|
||||
to overflow the unsigned integer bounds, even if the result is passed to
|
||||
`g_memdup2()` which accepts a `gsize`.
|
||||
|
||||
Cast the `URL_COMPONENTS` members to `gsize` first to ensure that the
|
||||
arithmetic is done in terms of `gsize`s rather than unsigned integers.
|
||||
|
||||
Spotted by Sebastian Dröge.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/win32/gwinhttpfile.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/gio/win32/gwinhttpfile.c b/gio/win32/gwinhttpfile.c
|
||||
index 3f8fbd838..e0340e247 100644
|
||||
--- a/gio/win32/gwinhttpfile.c
|
||||
+++ b/gio/win32/gwinhttpfile.c
|
||||
@@ -410,10 +410,10 @@ g_winhttp_file_resolve_relative_path (GFile *file,
|
||||
child = g_object_new (G_TYPE_WINHTTP_FILE, NULL);
|
||||
child->vfs = winhttp_file->vfs;
|
||||
child->url = winhttp_file->url;
|
||||
- child->url.lpszScheme = g_memdup2 (winhttp_file->url.lpszScheme, (winhttp_file->url.dwSchemeLength+1)*2);
|
||||
- child->url.lpszHostName = g_memdup2 (winhttp_file->url.lpszHostName, (winhttp_file->url.dwHostNameLength+1)*2);
|
||||
- child->url.lpszUserName = g_memdup2 (winhttp_file->url.lpszUserName, (winhttp_file->url.dwUserNameLength+1)*2);
|
||||
- child->url.lpszPassword = g_memdup2 (winhttp_file->url.lpszPassword, (winhttp_file->url.dwPasswordLength+1)*2);
|
||||
+ child->url.lpszScheme = g_memdup2 (winhttp_file->url.lpszScheme, ((gsize) winhttp_file->url.dwSchemeLength + 1) * 2);
|
||||
+ child->url.lpszHostName = g_memdup2 (winhttp_file->url.lpszHostName, ((gsize) winhttp_file->url.dwHostNameLength + 1) * 2);
|
||||
+ child->url.lpszUserName = g_memdup2 (winhttp_file->url.lpszUserName, ((gsize) winhttp_file->url.dwUserNameLength + 1) * 2);
|
||||
+ child->url.lpszPassword = g_memdup2 (winhttp_file->url.lpszPassword, ((gsize) winhttp_file->url.dwPasswordLength + 1) * 2);
|
||||
child->url.lpszUrlPath = wnew_path;
|
||||
child->url.dwUrlPathLength = wcslen (wnew_path);
|
||||
child->url.lpszExtraInfo = NULL;
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
101
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-06.patch
Normal file
101
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-06.patch
Normal file
@@ -0,0 +1,101 @@
|
||||
From f9ee2275cbc312c0b4cdbc338a4fbb76eb36fb9a Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 13:49:00 +0000
|
||||
Subject: [PATCH 06/11] gdatainputstream: Handle stop_chars_len internally as
|
||||
gsize
|
||||
|
||||
Previously it was handled as a `gssize`, which meant that if the
|
||||
`stop_chars` string was longer than `G_MAXSSIZE` there would be an
|
||||
overflow.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gdatainputstream.c | 25 +++++++++++++++++--------
|
||||
1 file changed, 17 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/gio/gdatainputstream.c b/gio/gdatainputstream.c
|
||||
index 2e7750cb5..2cdcbda19 100644
|
||||
--- a/gio/gdatainputstream.c
|
||||
+++ b/gio/gdatainputstream.c
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "gioenumtypes.h"
|
||||
#include "gioerror.h"
|
||||
#include "glibintl.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -856,7 +857,7 @@ static gssize
|
||||
scan_for_chars (GDataInputStream *stream,
|
||||
gsize *checked_out,
|
||||
const char *stop_chars,
|
||||
- gssize stop_chars_len)
|
||||
+ gsize stop_chars_len)
|
||||
{
|
||||
GBufferedInputStream *bstream;
|
||||
const char *buffer;
|
||||
@@ -952,7 +953,7 @@ typedef struct
|
||||
gsize checked;
|
||||
|
||||
gchar *stop_chars;
|
||||
- gssize stop_chars_len;
|
||||
+ gsize stop_chars_len;
|
||||
gsize length;
|
||||
} GDataInputStreamReadData;
|
||||
|
||||
@@ -1078,12 +1079,17 @@ g_data_input_stream_read_async (GDataInputStream *stream,
|
||||
{
|
||||
GDataInputStreamReadData *data;
|
||||
GTask *task;
|
||||
+ gsize stop_chars_len_unsigned;
|
||||
|
||||
data = g_slice_new0 (GDataInputStreamReadData);
|
||||
- if (stop_chars_len == -1)
|
||||
- stop_chars_len = strlen (stop_chars);
|
||||
- data->stop_chars = g_memdup (stop_chars, stop_chars_len);
|
||||
- data->stop_chars_len = stop_chars_len;
|
||||
+
|
||||
+ if (stop_chars_len < 0)
|
||||
+ stop_chars_len_unsigned = strlen (stop_chars);
|
||||
+ else
|
||||
+ stop_chars_len_unsigned = (gsize) stop_chars_len;
|
||||
+
|
||||
+ data->stop_chars = g_memdup2 (stop_chars, stop_chars_len_unsigned);
|
||||
+ data->stop_chars_len = stop_chars_len_unsigned;
|
||||
data->last_saw_cr = FALSE;
|
||||
|
||||
task = g_task_new (stream, cancellable, callback, user_data);
|
||||
@@ -1338,17 +1344,20 @@ g_data_input_stream_read_upto (GDataInputStream *stream,
|
||||
gssize found_pos;
|
||||
gssize res;
|
||||
char *data_until;
|
||||
+ gsize stop_chars_len_unsigned;
|
||||
|
||||
g_return_val_if_fail (G_IS_DATA_INPUT_STREAM (stream), NULL);
|
||||
|
||||
if (stop_chars_len < 0)
|
||||
- stop_chars_len = strlen (stop_chars);
|
||||
+ stop_chars_len_unsigned = strlen (stop_chars);
|
||||
+ else
|
||||
+ stop_chars_len_unsigned = (gsize) stop_chars_len;
|
||||
|
||||
bstream = G_BUFFERED_INPUT_STREAM (stream);
|
||||
|
||||
checked = 0;
|
||||
|
||||
- while ((found_pos = scan_for_chars (stream, &checked, stop_chars, stop_chars_len)) == -1)
|
||||
+ while ((found_pos = scan_for_chars (stream, &checked, stop_chars, stop_chars_len_unsigned)) == -1)
|
||||
{
|
||||
if (g_buffered_input_stream_get_available (bstream) ==
|
||||
g_buffered_input_stream_get_buffer_size (bstream))
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
76
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-07.patch
Normal file
76
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-07.patch
Normal file
@@ -0,0 +1,76 @@
|
||||
From 2aaf593a9eb96d84fe3be740aca2810a97d95592 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 13:50:37 +0000
|
||||
Subject: [PATCH 07/11] gwin32: Use gsize internally in g_wcsdup()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This allows it to handle strings up to length `G_MAXSIZE` — previously
|
||||
it would overflow with such strings.
|
||||
|
||||
Update the several copies of it identically.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gwin32registrykey.c | 34 ++++++++++++++++++++++++++--------
|
||||
2 files changed, 38 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/gio/gwin32registrykey.c b/gio/gwin32registrykey.c
|
||||
index 548a94188..2eb67daf8 100644
|
||||
--- a/gio/gwin32registrykey.c
|
||||
+++ b/gio/gwin32registrykey.c
|
||||
@@ -127,16 +127,34 @@ typedef enum
|
||||
G_WIN32_REGISTRY_UPDATED_PATH = 1,
|
||||
} GWin32RegistryKeyUpdateFlag;
|
||||
|
||||
+static gsize
|
||||
+g_utf16_len (const gunichar2 *str)
|
||||
+{
|
||||
+ gsize result;
|
||||
+
|
||||
+ for (result = 0; str[0] != 0; str++, result++)
|
||||
+ ;
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
static gunichar2 *
|
||||
-g_wcsdup (const gunichar2 *str,
|
||||
- gssize str_size)
|
||||
+g_wcsdup (const gunichar2 *str, gssize str_len)
|
||||
{
|
||||
- if (str_size == -1)
|
||||
- {
|
||||
- str_size = wcslen (str) + 1;
|
||||
- str_size *= sizeof (gunichar2);
|
||||
- }
|
||||
- return g_memdup (str, str_size);
|
||||
+ gsize str_len_unsigned;
|
||||
+ gsize str_size;
|
||||
+
|
||||
+ g_return_val_if_fail (str != NULL, NULL);
|
||||
+
|
||||
+ if (str_len < 0)
|
||||
+ str_len_unsigned = g_utf16_len (str);
|
||||
+ else
|
||||
+ str_len_unsigned = (gsize) str_len;
|
||||
+
|
||||
+ g_assert (str_len_unsigned <= G_MAXSIZE / sizeof (gunichar2) - 1);
|
||||
+ str_size = (str_len_unsigned + 1) * sizeof (gunichar2);
|
||||
+
|
||||
+ return g_memdup2 (str, str_size);
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
101
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-08.patch
Normal file
101
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-08.patch
Normal file
@@ -0,0 +1,101 @@
|
||||
From ba8ca443051f93a74c0d03d62e70402036f967a5 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 13:58:32 +0000
|
||||
Subject: [PATCH 08/11] gkeyfilesettingsbackend: Handle long keys when
|
||||
converting paths
|
||||
|
||||
Previously, the code in `convert_path()` could not handle keys longer
|
||||
than `G_MAXINT`, and would overflow if that was exceeded.
|
||||
|
||||
Convert the code to use `gsize` and `g_memdup2()` throughout, and
|
||||
change from identifying the position of the final slash in the string
|
||||
using a signed offset `i`, to using a pointer to the character (and
|
||||
`strrchr()`). This allows the slash to be at any position in a
|
||||
`G_MAXSIZE`-long string, without sacrificing a bit of the offset for
|
||||
indicating whether a slash was found.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gkeyfilesettingsbackend.c | 21 ++++++++++-----------
|
||||
1 file changed, 10 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c
|
||||
index cd5765afd..25b057672 100644
|
||||
--- a/gio/gkeyfilesettingsbackend.c
|
||||
+++ b/gio/gkeyfilesettingsbackend.c
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "gfilemonitor.h"
|
||||
#include "gsimplepermission.h"
|
||||
#include "gsettingsbackendinternal.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "giomodule-priv.h"
|
||||
#include "gportalsupport.h"
|
||||
|
||||
@@ -145,8 +146,8 @@ convert_path (GKeyfileSettingsBackend *kfsb,
|
||||
gchar **group,
|
||||
gchar **basename)
|
||||
{
|
||||
- gint key_len = strlen (key);
|
||||
- gint i;
|
||||
+ gsize key_len = strlen (key);
|
||||
+ const gchar *last_slash;
|
||||
|
||||
if (key_len < kfsb->prefix_len ||
|
||||
memcmp (key, kfsb->prefix, kfsb->prefix_len) != 0)
|
||||
@@ -155,38 +156,36 @@ convert_path (GKeyfileSettingsBackend *kfsb,
|
||||
key_len -= kfsb->prefix_len;
|
||||
key += kfsb->prefix_len;
|
||||
|
||||
- for (i = key_len; i >= 0; i--)
|
||||
- if (key[i] == '/')
|
||||
- break;
|
||||
+ last_slash = strrchr (key, '/');
|
||||
|
||||
if (kfsb->root_group)
|
||||
{
|
||||
/* if a root_group was specified, make sure the user hasn't given
|
||||
* a path that ghosts that group name
|
||||
*/
|
||||
- if (i == kfsb->root_group_len && memcmp (key, kfsb->root_group, i) == 0)
|
||||
+ if (last_slash != NULL && (last_slash - key) == kfsb->root_group_len && memcmp (key, kfsb->root_group, last_slash - key) == 0)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if no root_group was given, ensure that the user gave a path */
|
||||
- if (i == -1)
|
||||
+ if (last_slash == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (group)
|
||||
{
|
||||
- if (i >= 0)
|
||||
+ if (last_slash != NULL)
|
||||
{
|
||||
- *group = g_memdup (key, i + 1);
|
||||
- (*group)[i] = '\0';
|
||||
+ *group = g_memdup2 (key, (last_slash - key) + 1);
|
||||
+ (*group)[(last_slash - key)] = '\0';
|
||||
}
|
||||
else
|
||||
*group = g_strdup (kfsb->root_group);
|
||||
}
|
||||
|
||||
if (basename)
|
||||
- *basename = g_memdup (key + i + 1, key_len - i);
|
||||
+ *basename = g_memdup2 (last_slash + 1, key_len - (last_slash - key));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
100
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-09.patch
Normal file
100
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-09.patch
Normal file
@@ -0,0 +1,100 @@
|
||||
From 65ec7f4d6e8832c481f6e00e2eb007b9a60024ce Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 14:00:53 +0000
|
||||
Subject: [PATCH 09/11] =?UTF-8?q?gsocket:=20Use=20gsize=20to=20track=20nat?=
|
||||
=?UTF-8?q?ive=20sockaddr=E2=80=99s=20size?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Don’t use an `int`, that’s potentially too small. In practical terms,
|
||||
this is not a problem, since no socket address is going to be that big.
|
||||
|
||||
By making these changes we can use `g_memdup2()` without warnings,
|
||||
though. Fewer warnings is good.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gsocket.c | 16 ++++++++++------
|
||||
1 file changed, 10 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/gio/gsocket.c
|
||||
+++ b/gio/gsocket.c
|
||||
@@ -75,6 +75,7 @@
|
||||
#include "gcredentialsprivate.h"
|
||||
#include "glibintl.h"
|
||||
#include "gioprivate.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* For Windows XP runtime compatibility, but use the system's if_nametoindex() if available */
|
||||
@@ -174,7 +175,7 @@ static gboolean g_socket_datagram_ba
|
||||
GError **error);
|
||||
|
||||
static GSocketAddress *
|
||||
-cache_recv_address (GSocket *socket, struct sockaddr *native, int native_len);
|
||||
+cache_recv_address (GSocket *socket, struct sockaddr *native, size_t native_len);
|
||||
|
||||
static gssize
|
||||
g_socket_receive_message_with_timeout (GSocket *socket,
|
||||
@@ -260,7 +261,7 @@ struct _GSocketPrivate
|
||||
struct {
|
||||
GSocketAddress *addr;
|
||||
struct sockaddr *native;
|
||||
- gint native_len;
|
||||
+ gsize native_len;
|
||||
guint64 last_used;
|
||||
} recv_addr_cache[RECV_ADDR_CACHE_SIZE];
|
||||
};
|
||||
@@ -5259,14 +5260,14 @@ g_socket_send_messages_with_timeout (GSo
|
||||
}
|
||||
|
||||
static GSocketAddress *
|
||||
-cache_recv_address (GSocket *socket, struct sockaddr *native, int native_len)
|
||||
+cache_recv_address (GSocket *socket, struct sockaddr *native, size_t native_len)
|
||||
{
|
||||
GSocketAddress *saddr;
|
||||
gint i;
|
||||
guint64 oldest_time = G_MAXUINT64;
|
||||
gint oldest_index = 0;
|
||||
|
||||
- if (native_len <= 0)
|
||||
+ if (native_len == 0)
|
||||
return NULL;
|
||||
|
||||
saddr = NULL;
|
||||
@@ -5274,7 +5275,7 @@ cache_recv_address (GSocket *socket, str
|
||||
{
|
||||
GSocketAddress *tmp = socket->priv->recv_addr_cache[i].addr;
|
||||
gpointer tmp_native = socket->priv->recv_addr_cache[i].native;
|
||||
- gint tmp_native_len = socket->priv->recv_addr_cache[i].native_len;
|
||||
+ gsize tmp_native_len = socket->priv->recv_addr_cache[i].native_len;
|
||||
|
||||
if (!tmp)
|
||||
continue;
|
||||
@@ -5304,7 +5305,7 @@ cache_recv_address (GSocket *socket, str
|
||||
g_free (socket->priv->recv_addr_cache[oldest_index].native);
|
||||
}
|
||||
|
||||
- socket->priv->recv_addr_cache[oldest_index].native = g_memdup (native, native_len);
|
||||
+ socket->priv->recv_addr_cache[oldest_index].native = g_memdup2 (native, native_len);
|
||||
socket->priv->recv_addr_cache[oldest_index].native_len = native_len;
|
||||
socket->priv->recv_addr_cache[oldest_index].addr = g_object_ref (saddr);
|
||||
socket->priv->recv_addr_cache[oldest_index].last_used = g_get_monotonic_time ();
|
||||
@@ -5452,6 +5453,9 @@ g_socket_receive_message_with_timeout (G
|
||||
/* do it */
|
||||
while (1)
|
||||
{
|
||||
+ /* addrlen has to be of type int because that’s how WSARecvFrom() is defined */
|
||||
+ G_STATIC_ASSERT (sizeof addr <= G_MAXINT);
|
||||
+
|
||||
addrlen = sizeof addr;
|
||||
if (address)
|
||||
result = WSARecvFrom (socket->priv->fd,
|
||||
59
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-10.patch
Normal file
59
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-10.patch
Normal file
@@ -0,0 +1,59 @@
|
||||
From 777b95a88f006d39d9fe6d3321db17e7b0d4b9a4 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 14:07:39 +0000
|
||||
Subject: [PATCH 10/11] gtlspassword: Forbid very long TLS passwords
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The public API `g_tls_password_set_value_full()` (and the vfunc it
|
||||
invokes) can only accept a `gssize` length. Ensure that nul-terminated
|
||||
strings passed to `g_tls_password_set_value()` can’t exceed that length.
|
||||
Use `g_memdup2()` to avoid an overflow if they’re longer than
|
||||
`G_MAXUINT` similarly.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gtlspassword.c | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gio/gtlspassword.c b/gio/gtlspassword.c
|
||||
index 1e437a7b6..dbcec41a8 100644
|
||||
--- a/gio/gtlspassword.c
|
||||
+++ b/gio/gtlspassword.c
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "glibintl.h"
|
||||
|
||||
#include "gioenumtypes.h"
|
||||
+#include "gstrfuncsprivate.h"
|
||||
#include "gtlspassword.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -287,9 +288,14 @@ g_tls_password_set_value (GTlsPassword *password,
|
||||
g_return_if_fail (G_IS_TLS_PASSWORD (password));
|
||||
|
||||
if (length < 0)
|
||||
- length = strlen ((gchar *)value);
|
||||
+ {
|
||||
+ /* FIXME: g_tls_password_set_value_full() doesn’t support unsigned gsize */
|
||||
+ gsize length_unsigned = strlen ((gchar *) value);
|
||||
+ g_return_if_fail (length_unsigned > G_MAXSSIZE);
|
||||
+ length = (gssize) length_unsigned;
|
||||
+ }
|
||||
|
||||
- g_tls_password_set_value_full (password, g_memdup (value, length), length, g_free);
|
||||
+ g_tls_password_set_value_full (password, g_memdup2 (value, (gsize) length), length, g_free);
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
63
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-11.patch
Normal file
63
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-11.patch
Normal file
@@ -0,0 +1,63 @@
|
||||
From ecdf91400e9a538695a0895b95ad7e8abcdf1749 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Thu, 4 Feb 2021 14:09:40 +0000
|
||||
Subject: [PATCH 11/11] giochannel: Forbid very long line terminator strings
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The public API `GIOChannel.line_term_len` is only a `guint`. Ensure that
|
||||
nul-terminated strings passed to `g_io_channel_set_line_term()` can’t
|
||||
exceed that length. Use `g_memdup2()` to avoid a warning (`g_memdup()`
|
||||
is due to be deprecated), but not to avoid a bug, since it’s also
|
||||
limited to `G_MAXUINT`.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
Helps: #2319
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
glib/giochannel.c | 17 +++++++++++++----
|
||||
1 file changed, 13 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/glib/giochannel.c b/glib/giochannel.c
|
||||
index c6a89d6e0..4dec20f77 100644
|
||||
--- a/glib/giochannel.c
|
||||
+++ b/glib/giochannel.c
|
||||
@@ -887,16 +887,25 @@ g_io_channel_set_line_term (GIOChannel *channel,
|
||||
const gchar *line_term,
|
||||
gint length)
|
||||
{
|
||||
+ guint length_unsigned;
|
||||
+
|
||||
g_return_if_fail (channel != NULL);
|
||||
g_return_if_fail (line_term == NULL || length != 0); /* Disallow "" */
|
||||
|
||||
if (line_term == NULL)
|
||||
- length = 0;
|
||||
- else if (length < 0)
|
||||
- length = strlen (line_term);
|
||||
+ length_unsigned = 0;
|
||||
+ else if (length >= 0)
|
||||
+ length_unsigned = (guint) length;
|
||||
+ else
|
||||
+ {
|
||||
+ /* FIXME: We’re constrained by line_term_len being a guint here */
|
||||
+ gsize length_size = strlen (line_term);
|
||||
+ g_return_if_fail (length_size > G_MAXUINT);
|
||||
+ length_unsigned = (guint) length_size;
|
||||
+ }
|
||||
|
||||
g_free (channel->line_term);
|
||||
- channel->line_term = line_term ? g_memdup (line_term, length) : NULL;
|
||||
+ channel->line_term = line_term ? g_memdup2 (line_term, length_unsigned) : NULL;
|
||||
channel->line_term_len = length;
|
||||
}
|
||||
|
||||
--
|
||||
GitLab
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From f8273b9aded135fe07094faebd527e43851aaf6e Mon Sep 17 00:00:00 2001
|
||||
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
|
||||
Date: Sun, 7 Feb 2021 23:32:40 +0100
|
||||
Subject: [PATCH 1/5] giochannel: Fix length_size bounds check
|
||||
|
||||
The inverted condition is an obvious error introduced by ecdf91400e9a.
|
||||
|
||||
Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2323
|
||||
|
||||
(cherry picked from commit a149bf2f9030168051942124536e303af8ba6176)
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
glib/giochannel.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/glib/giochannel.c b/glib/giochannel.c
|
||||
index 4dec20f77..c3f3102ff 100644
|
||||
--- a/glib/giochannel.c
|
||||
+++ b/glib/giochannel.c
|
||||
@@ -896,7 +896,7 @@ g_io_channel_set_line_term (GIOChannel *channel,
|
||||
{
|
||||
/* FIXME: We’re constrained by line_term_len being a guint here */
|
||||
gsize length_size = strlen (line_term);
|
||||
- g_return_if_fail (length_size > G_MAXUINT);
|
||||
+ g_return_if_fail (length_size <= G_MAXUINT);
|
||||
length_unsigned = (guint) length_size;
|
||||
}
|
||||
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
From e069c50467712e6d607822afd6b6c15c2c343dff Mon Sep 17 00:00:00 2001
|
||||
From: Simon McVittie <smcv@collabora.com>
|
||||
Date: Mon, 8 Feb 2021 10:34:50 +0000
|
||||
Subject: [PATCH 2/5] giochannel: Don't store negative line_term_len in
|
||||
GIOChannel struct
|
||||
|
||||
Adding test coverage indicated that this was another bug in 0cc11f74.
|
||||
|
||||
Fixes: 0cc11f74 "giochannel: Forbid very long line terminator strings"
|
||||
Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2323
|
||||
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
||||
(cherry picked from commit 5dc8b0014c03e7491d93b90275ab442e888a9628)
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
glib/giochannel.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/glib/giochannel.c b/glib/giochannel.c
|
||||
index c3f3102ff..19bb06ba6 100644
|
||||
--- a/glib/giochannel.c
|
||||
+++ b/glib/giochannel.c
|
||||
@@ -902,7 +902,7 @@ g_io_channel_set_line_term (GIOChannel *channel,
|
||||
|
||||
g_free (channel->line_term);
|
||||
channel->line_term = line_term ? g_memdup2 (line_term, length_unsigned) : NULL;
|
||||
- channel->line_term_len = length;
|
||||
+ channel->line_term_len = length_unsigned;
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
From 4506d1859a863087598c8d122740bae25b65b099 Mon Sep 17 00:00:00 2001
|
||||
From: Simon McVittie <smcv@collabora.com>
|
||||
Date: Mon, 8 Feb 2021 10:04:48 +0000
|
||||
Subject: [PATCH 4/5] gtlspassword: Fix inverted assertion
|
||||
|
||||
The intention here was to assert that the length of the password fits
|
||||
in a gssize. Passwords more than half the size of virtual memory are
|
||||
probably excessive.
|
||||
|
||||
Fixes: a8b204ff "gtlspassword: Forbid very long TLS passwords"
|
||||
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
||||
(cherry picked from commit 61bb52ec42de1082bfb06ce1c737fc295bfe60b8)
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gtlspassword.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gio/gtlspassword.c b/gio/gtlspassword.c
|
||||
index dbcec41a8..bd86a6dfe 100644
|
||||
--- a/gio/gtlspassword.c
|
||||
+++ b/gio/gtlspassword.c
|
||||
@@ -291,7 +291,7 @@ g_tls_password_set_value (GTlsPassword *password,
|
||||
{
|
||||
/* FIXME: g_tls_password_set_value_full() doesn’t support unsigned gsize */
|
||||
gsize length_unsigned = strlen ((gchar *) value);
|
||||
- g_return_if_fail (length_unsigned > G_MAXSSIZE);
|
||||
+ g_return_if_fail (length_unsigned <= G_MAXSSIZE);
|
||||
length = (gssize) length_unsigned;
|
||||
}
|
||||
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
100
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-reg1-5.patch
Normal file
100
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-reg1-5.patch
Normal file
@@ -0,0 +1,100 @@
|
||||
From 3d1550354c3c6a8491c39881752d51cb7515f2c2 Mon Sep 17 00:00:00 2001
|
||||
From: Simon McVittie <smcv@collabora.com>
|
||||
Date: Mon, 8 Feb 2021 10:22:39 +0000
|
||||
Subject: [PATCH 5/5] tls-interaction: Add test coverage for various ways to
|
||||
set the password
|
||||
|
||||
Signed-off-by: Simon McVittie <smcv@collabora.com>
|
||||
(cherry picked from commit df4501316ca3903072400504a5ea76498db19538)
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/tests/tls-interaction.c | 55 +++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 55 insertions(+)
|
||||
|
||||
diff --git a/gio/tests/tls-interaction.c b/gio/tests/tls-interaction.c
|
||||
index 4f0737d7e..5661e8e0d 100644
|
||||
--- a/gio/tests/tls-interaction.c
|
||||
+++ b/gio/tests/tls-interaction.c
|
||||
@@ -174,6 +174,38 @@ test_interaction_ask_password_finish_failure (GTlsInteraction *interaction,
|
||||
}
|
||||
|
||||
|
||||
+/* Return a copy of @str that is allocated in a silly way, to exercise
|
||||
+ * custom free-functions. The returned pointer points to a copy of @str
|
||||
+ * in a buffer of the form "BEFORE \0 str \0 AFTER". */
|
||||
+static guchar *
|
||||
+special_dup (const char *str)
|
||||
+{
|
||||
+ GString *buf = g_string_new ("BEFORE");
|
||||
+ guchar *ret;
|
||||
+
|
||||
+ g_string_append_c (buf, '\0');
|
||||
+ g_string_append (buf, str);
|
||||
+ g_string_append_c (buf, '\0');
|
||||
+ g_string_append (buf, "AFTER");
|
||||
+ ret = (guchar *) g_string_free (buf, FALSE);
|
||||
+ return ret + strlen ("BEFORE") + 1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* Free a copy of @str that was made with special_dup(), after asserting
|
||||
+ * that it has not been corrupted. */
|
||||
+static void
|
||||
+special_free (gpointer p)
|
||||
+{
|
||||
+ gchar *s = p;
|
||||
+ gchar *buf = s - strlen ("BEFORE") - 1;
|
||||
+
|
||||
+ g_assert_cmpstr (buf, ==, "BEFORE");
|
||||
+ g_assert_cmpstr (s + strlen (s) + 1, ==, "AFTER");
|
||||
+ g_free (buf);
|
||||
+}
|
||||
+
|
||||
+
|
||||
static GTlsInteractionResult
|
||||
test_interaction_ask_password_sync_success (GTlsInteraction *interaction,
|
||||
GTlsPassword *password,
|
||||
@@ -181,6 +213,8 @@ test_interaction_ask_password_sync_success (GTlsInteraction *interaction,
|
||||
GError **error)
|
||||
{
|
||||
TestInteraction *self;
|
||||
+ const guchar *value;
|
||||
+ gsize len;
|
||||
|
||||
g_assert (TEST_IS_INTERACTION (interaction));
|
||||
self = TEST_INTERACTION (interaction);
|
||||
@@ -192,6 +226,27 @@ test_interaction_ask_password_sync_success (GTlsInteraction *interaction,
|
||||
g_assert (error != NULL);
|
||||
g_assert (*error == NULL);
|
||||
|
||||
+ /* Exercise different ways to set the value */
|
||||
+ g_tls_password_set_value (password, (const guchar *) "foo", 4);
|
||||
+ len = 0;
|
||||
+ value = g_tls_password_get_value (password, &len);
|
||||
+ g_assert_cmpmem (value, len, "foo", 4);
|
||||
+
|
||||
+ g_tls_password_set_value (password, (const guchar *) "bar", -1);
|
||||
+ len = 0;
|
||||
+ value = g_tls_password_get_value (password, &len);
|
||||
+ g_assert_cmpmem (value, len, "bar", 3);
|
||||
+
|
||||
+ g_tls_password_set_value_full (password, special_dup ("baa"), 4, special_free);
|
||||
+ len = 0;
|
||||
+ value = g_tls_password_get_value (password, &len);
|
||||
+ g_assert_cmpmem (value, len, "baa", 4);
|
||||
+
|
||||
+ g_tls_password_set_value_full (password, special_dup ("baz"), -1, special_free);
|
||||
+ len = 0;
|
||||
+ value = g_tls_password_get_value (password, &len);
|
||||
+ g_assert_cmpmem (value, len, "baz", 3);
|
||||
+
|
||||
/* Don't do this in real life. Include a null terminator for testing */
|
||||
g_tls_password_set_value (password, (const guchar *)"the password", 13);
|
||||
return G_TLS_INTERACTION_HANDLED;
|
||||
--
|
||||
GitLab
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
From cb9ee701ef46c1819eed4e2a4dc181682bdfc176 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Wed, 10 Feb 2021 21:16:39 +0000
|
||||
Subject: [PATCH 1/3] gkeyfilesettingsbackend: Fix basename handling when group
|
||||
is unset
|
||||
|
||||
Fix an effective regression in commit
|
||||
7781a9cbd2fd0aa84bee0f4eee88470640ff6706, which happens when
|
||||
`convert_path()` is called with a `key` which contains no slashes. In
|
||||
that case, the `key` is entirely the `basename`.
|
||||
|
||||
Prior to commit 7781a9cb, the code worked through a fluke of `i == -1`
|
||||
cancelling out with the various additions in the `g_memdup()` call, and
|
||||
effectively resulting in `g_strdup (key)`.
|
||||
|
||||
Spotted by Guido Berhoerster.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gkeyfilesettingsbackend.c | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c
|
||||
index 25b057672..861c3a661 100644
|
||||
--- a/gio/gkeyfilesettingsbackend.c
|
||||
+++ b/gio/gkeyfilesettingsbackend.c
|
||||
@@ -185,7 +185,12 @@ convert_path (GKeyfileSettingsBackend *kfsb,
|
||||
}
|
||||
|
||||
if (basename)
|
||||
- *basename = g_memdup2 (last_slash + 1, key_len - (last_slash - key));
|
||||
+ {
|
||||
+ if (last_slash != NULL)
|
||||
+ *basename = g_memdup2 (last_slash + 1, key_len - (last_slash - key));
|
||||
+ else
|
||||
+ *basename = g_strdup (key);
|
||||
+ }
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
From 31e0d403ba635dbbacbfbff74295e5db02558d76 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Wed, 10 Feb 2021 21:19:30 +0000
|
||||
Subject: [PATCH 2/3] gkeyfilesettingsbackend: Disallow empty key or group
|
||||
names
|
||||
|
||||
These should never have been allowed; they will result in precondition
|
||||
failures from the `GKeyFile` later on in the code.
|
||||
|
||||
A test will be added for this shortly.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/gkeyfilesettingsbackend.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c
|
||||
index 861c3a661..de216e615 100644
|
||||
--- a/gio/gkeyfilesettingsbackend.c
|
||||
+++ b/gio/gkeyfilesettingsbackend.c
|
||||
@@ -158,6 +158,13 @@ convert_path (GKeyfileSettingsBackend *kfsb,
|
||||
|
||||
last_slash = strrchr (key, '/');
|
||||
|
||||
+ /* Disallow empty group names or key names */
|
||||
+ if (key_len == 0 ||
|
||||
+ (last_slash != NULL &&
|
||||
+ (*(last_slash + 1) == '\0' ||
|
||||
+ last_slash == key)))
|
||||
+ return FALSE;
|
||||
+
|
||||
if (kfsb->root_group)
|
||||
{
|
||||
/* if a root_group was specified, make sure the user hasn't given
|
||||
--
|
||||
GitLab
|
||||
|
||||
|
||||
232
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-reg2-3.patch
Normal file
232
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-reg2-3.patch
Normal file
@@ -0,0 +1,232 @@
|
||||
Backport of:
|
||||
|
||||
From 221c26685354dea2b2732df94404e8e5e77a1591 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Wed, 10 Feb 2021 21:21:36 +0000
|
||||
Subject: [PATCH 3/3] tests: Add tests for key name handling in the keyfile
|
||||
backend
|
||||
|
||||
This tests the two recent commits.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-27219
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/tests/gsettings.c | 170 +++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 169 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/gio/tests/gsettings.c
|
||||
+++ b/gio/tests/gsettings.c
|
||||
@@ -1,3 +1,4 @@
|
||||
+#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
@@ -1740,6 +1741,14 @@ key_changed_cb (GSettings *settings, con
|
||||
(*b) = TRUE;
|
||||
}
|
||||
|
||||
+typedef struct
|
||||
+{
|
||||
+ const gchar *path;
|
||||
+ const gchar *root_group;
|
||||
+ const gchar *keyfile_group;
|
||||
+ const gchar *root_path;
|
||||
+} KeyfileTestData;
|
||||
+
|
||||
/*
|
||||
* Test that using a keyfile works
|
||||
*/
|
||||
@@ -1834,7 +1843,11 @@ test_keyfile (Fixture *fixture,
|
||||
g_free (str);
|
||||
|
||||
g_settings_set (settings, "farewell", "s", "cheerio");
|
||||
-
|
||||
+
|
||||
+ /* Check that empty keys/groups are not allowed. */
|
||||
+ g_assert_false (g_settings_is_writable (settings, ""));
|
||||
+ g_assert_false (g_settings_is_writable (settings, "/"));
|
||||
+
|
||||
/* When executing as root, changing the mode of the keyfile will have
|
||||
* no effect on the writability of the settings.
|
||||
*/
|
||||
@@ -1866,6 +1879,149 @@ test_keyfile (Fixture *fixture,
|
||||
g_free (keyfile_path);
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Test that using a keyfile works with a schema with no path set.
|
||||
+ */
|
||||
+static void
|
||||
+test_keyfile_no_path (Fixture *fixture,
|
||||
+ gconstpointer user_data)
|
||||
+{
|
||||
+ const KeyfileTestData *test_data = user_data;
|
||||
+ GSettingsBackend *kf_backend;
|
||||
+ GSettings *settings;
|
||||
+ GKeyFile *keyfile;
|
||||
+ gboolean writable;
|
||||
+ gchar *key = NULL;
|
||||
+ GError *error = NULL;
|
||||
+ gchar *keyfile_path = NULL, *store_path = NULL;
|
||||
+
|
||||
+ keyfile_path = g_build_filename (fixture->tmp_dir, "keyfile", NULL);
|
||||
+ store_path = g_build_filename (keyfile_path, "gsettings.store", NULL);
|
||||
+ kf_backend = g_keyfile_settings_backend_new (store_path, test_data->root_path, test_data->root_group);
|
||||
+ settings = g_settings_new_with_backend_and_path ("org.gtk.test.no-path", kf_backend, test_data->path);
|
||||
+ g_object_unref (kf_backend);
|
||||
+
|
||||
+ g_settings_reset (settings, "test-boolean");
|
||||
+ g_assert_true (g_settings_get_boolean (settings, "test-boolean"));
|
||||
+
|
||||
+ writable = g_settings_is_writable (settings, "test-boolean");
|
||||
+ g_assert_true (writable);
|
||||
+ g_settings_set (settings, "test-boolean", "b", FALSE);
|
||||
+
|
||||
+ g_assert_false (g_settings_get_boolean (settings, "test-boolean"));
|
||||
+
|
||||
+ g_settings_delay (settings);
|
||||
+ g_settings_set (settings, "test-boolean", "b", TRUE);
|
||||
+ g_settings_apply (settings);
|
||||
+
|
||||
+ keyfile = g_key_file_new ();
|
||||
+ g_assert_true (g_key_file_load_from_file (keyfile, store_path, 0, NULL));
|
||||
+
|
||||
+ g_assert_true (g_key_file_get_boolean (keyfile, test_data->keyfile_group, "test-boolean", NULL));
|
||||
+
|
||||
+ g_key_file_free (keyfile);
|
||||
+
|
||||
+ g_settings_reset (settings, "test-boolean");
|
||||
+ g_settings_apply (settings);
|
||||
+ keyfile = g_key_file_new ();
|
||||
+ g_assert_true (g_key_file_load_from_file (keyfile, store_path, 0, NULL));
|
||||
+
|
||||
+ g_assert_false (g_key_file_get_string (keyfile, test_data->keyfile_group, "test-boolean", &error));
|
||||
+ g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND);
|
||||
+ g_clear_error (&error);
|
||||
+
|
||||
+ /* Check that empty keys/groups are not allowed. */
|
||||
+ g_assert_false (g_settings_is_writable (settings, ""));
|
||||
+ g_assert_false (g_settings_is_writable (settings, "/"));
|
||||
+
|
||||
+ /* Keys which ghost the root group name are not allowed. This can only be
|
||||
+ * tested when the path is `/` as otherwise it acts as a prefix and prevents
|
||||
+ * any ghosting. */
|
||||
+ if (g_str_equal (test_data->path, "/"))
|
||||
+ {
|
||||
+ key = g_strdup_printf ("%s/%s", test_data->root_group, "");
|
||||
+ g_assert_false (g_settings_is_writable (settings, key));
|
||||
+ g_free (key);
|
||||
+
|
||||
+ key = g_strdup_printf ("%s/%s", test_data->root_group, "/");
|
||||
+ g_assert_false (g_settings_is_writable (settings, key));
|
||||
+ g_free (key);
|
||||
+
|
||||
+ key = g_strdup_printf ("%s/%s", test_data->root_group, "test-boolean");
|
||||
+ g_assert_false (g_settings_is_writable (settings, key));
|
||||
+ g_free (key);
|
||||
+ }
|
||||
+
|
||||
+ g_key_file_free (keyfile);
|
||||
+ g_object_unref (settings);
|
||||
+
|
||||
+ /* Clean up the temporary directory. */
|
||||
+ g_assert_cmpint (g_chmod (keyfile_path, 0777) == 0 ? 0 : errno, ==, 0);
|
||||
+ g_assert_cmpint (g_remove (store_path) == 0 ? 0 : errno, ==, 0);
|
||||
+ g_assert_cmpint (g_rmdir (keyfile_path) == 0 ? 0 : errno, ==, 0);
|
||||
+ g_free (store_path);
|
||||
+ g_free (keyfile_path);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Test that a keyfile rejects writes to keys outside its root path.
|
||||
+ */
|
||||
+static void
|
||||
+test_keyfile_outside_root_path (Fixture *fixture,
|
||||
+ gconstpointer user_data)
|
||||
+{
|
||||
+ GSettingsBackend *kf_backend;
|
||||
+ GSettings *settings;
|
||||
+ gchar *keyfile_path = NULL, *store_path = NULL;
|
||||
+
|
||||
+ keyfile_path = g_build_filename (fixture->tmp_dir, "keyfile", NULL);
|
||||
+ store_path = g_build_filename (keyfile_path, "gsettings.store", NULL);
|
||||
+ kf_backend = g_keyfile_settings_backend_new (store_path, "/tests/basic-types/", "root");
|
||||
+ settings = g_settings_new_with_backend_and_path ("org.gtk.test.no-path", kf_backend, "/tests/");
|
||||
+ g_object_unref (kf_backend);
|
||||
+
|
||||
+ g_assert_false (g_settings_is_writable (settings, "test-boolean"));
|
||||
+
|
||||
+ g_object_unref (settings);
|
||||
+
|
||||
+ /* Clean up the temporary directory. The keyfile probably doesn’t exist, so
|
||||
+ * don’t error on failure. */
|
||||
+ g_remove (store_path);
|
||||
+ g_assert_cmpint (g_rmdir (keyfile_path) == 0 ? 0 : errno, ==, 0);
|
||||
+ g_free (store_path);
|
||||
+ g_free (keyfile_path);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Test that a keyfile rejects writes to keys in the root if no root group is set.
|
||||
+ */
|
||||
+static void
|
||||
+test_keyfile_no_root_group (Fixture *fixture,
|
||||
+ gconstpointer user_data)
|
||||
+{
|
||||
+ GSettingsBackend *kf_backend;
|
||||
+ GSettings *settings;
|
||||
+ gchar *keyfile_path = NULL, *store_path = NULL;
|
||||
+
|
||||
+ keyfile_path = g_build_filename (fixture->tmp_dir, "keyfile", NULL);
|
||||
+ store_path = g_build_filename (keyfile_path, "gsettings.store", NULL);
|
||||
+ kf_backend = g_keyfile_settings_backend_new (store_path, "/", NULL);
|
||||
+ settings = g_settings_new_with_backend_and_path ("org.gtk.test.no-path", kf_backend, "/");
|
||||
+ g_object_unref (kf_backend);
|
||||
+
|
||||
+ g_assert_false (g_settings_is_writable (settings, "test-boolean"));
|
||||
+ g_assert_true (g_settings_is_writable (settings, "child/test-boolean"));
|
||||
+
|
||||
+ g_object_unref (settings);
|
||||
+
|
||||
+ /* Clean up the temporary directory. The keyfile probably doesn’t exist, so
|
||||
+ * don’t error on failure. */
|
||||
+ g_remove (store_path);
|
||||
+ g_assert_cmpint (g_rmdir (keyfile_path) == 0 ? 0 : errno, ==, 0);
|
||||
+ g_free (store_path);
|
||||
+ g_free (keyfile_path);
|
||||
+}
|
||||
+
|
||||
/* Test that getting child schemas works
|
||||
*/
|
||||
static void
|
||||
@@ -2844,6 +3000,14 @@ main (int argc, char *argv[])
|
||||
gchar *override_text;
|
||||
gchar *enums;
|
||||
gint result;
|
||||
+ const KeyfileTestData keyfile_test_data_explicit_path = { "/tests/", "root", "tests", "/" };
|
||||
+ const KeyfileTestData keyfile_test_data_empty_path = { "/", "root", "root", "/" };
|
||||
+ const KeyfileTestData keyfile_test_data_long_path = {
|
||||
+ "/tests/path/is/very/long/and/this/makes/some/comparisons/take/a/different/branch/",
|
||||
+ "root",
|
||||
+ "tests/path/is/very/long/and/this/makes/some/comparisons/take/a/different/branch",
|
||||
+ "/"
|
||||
+ };
|
||||
|
||||
/* Meson build sets this */
|
||||
#ifdef TEST_LOCALE_PATH
|
||||
@@ -2967,6 +3131,11 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
g_test_add ("/gsettings/keyfile", Fixture, NULL, setup, test_keyfile, teardown);
|
||||
+ g_test_add ("/gsettings/keyfile/explicit-path", Fixture, &keyfile_test_data_explicit_path, setup, test_keyfile_no_path, teardown);
|
||||
+ g_test_add ("/gsettings/keyfile/empty-path", Fixture, &keyfile_test_data_empty_path, setup, test_keyfile_no_path, teardown);
|
||||
+ g_test_add ("/gsettings/keyfile/long-path", Fixture, &keyfile_test_data_long_path, setup, test_keyfile_no_path, teardown);
|
||||
+ g_test_add ("/gsettings/keyfile/outside-root-path", Fixture, NULL, setup, test_keyfile_outside_root_path, teardown);
|
||||
+ g_test_add ("/gsettings/keyfile/no-root-group", Fixture, NULL, setup, test_keyfile_no_root_group, teardown);
|
||||
g_test_add_func ("/gsettings/child-schema", test_child_schema);
|
||||
g_test_add_func ("/gsettings/strinfo", test_strinfo);
|
||||
g_test_add_func ("/gsettings/enums", test_enums);
|
||||
27
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-1.patch
Normal file
27
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-1.patch
Normal file
@@ -0,0 +1,27 @@
|
||||
From 78420a75aeb70569a8cd79fa0fea7b786b6f785f Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Wed, 24 Feb 2021 17:33:38 +0000
|
||||
Subject: [PATCH 1/5] glocalfileoutputstream: Fix a typo in a comment
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-28153
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/glocalfileoutputstream.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/gio/glocalfileoutputstream.c
|
||||
+++ b/gio/glocalfileoutputstream.c
|
||||
@@ -851,7 +851,7 @@ handle_overwrite_open (const char *fi
|
||||
mode = mode_from_flags_or_info (flags, reference_info);
|
||||
|
||||
/* We only need read access to the original file if we are creating a backup.
|
||||
- * We also add O_CREATE to avoid a race if the file was just removed */
|
||||
+ * We also add O_CREAT to avoid a race if the file was just removed */
|
||||
if (create_backup || readable)
|
||||
open_flags = O_RDWR | O_CREAT | O_BINARY;
|
||||
else
|
||||
42
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-2.patch
Normal file
42
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-2.patch
Normal file
@@ -0,0 +1,42 @@
|
||||
From 32d3d02a50e7dcec5f4cf7908e7ac88d575d8fc5 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Wed, 24 Feb 2021 17:34:32 +0000
|
||||
Subject: [PATCH 2/5] tests: Stop using g_test_bug_base() in file tests
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Since a following commit is going to add a new test which references
|
||||
Gitlab, so it’s best to move the URI bases inside the test cases.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-28153
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/tests/file.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
--- a/gio/tests/file.c
|
||||
+++ b/gio/tests/file.c
|
||||
@@ -685,7 +685,7 @@ test_replace_cancel (void)
|
||||
guint count;
|
||||
GError *error = NULL;
|
||||
|
||||
- g_test_bug ("629301");
|
||||
+ g_test_bug ("https://bugzilla.gnome.org/629301");
|
||||
|
||||
path = g_dir_make_tmp ("g_file_replace_cancel_XXXXXX", &error);
|
||||
g_assert_no_error (error);
|
||||
@@ -1784,8 +1784,6 @@ main (int argc, char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
- g_test_bug_base ("http://bugzilla.gnome.org/");
|
||||
-
|
||||
g_test_add_func ("/file/basic", test_basic);
|
||||
g_test_add_func ("/file/build-filename", test_build_filename);
|
||||
g_test_add_func ("/file/parent", test_parent);
|
||||
57
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-3.patch
Normal file
57
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-3.patch
Normal file
@@ -0,0 +1,57 @@
|
||||
Backport of:
|
||||
|
||||
From ce0eb088a68171eed3ac217cb92a72e36eb57d1b Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Wed, 10 Mar 2021 16:05:55 +0000
|
||||
Subject: [PATCH 3/5] glocalfileoutputstream: Factor out a flag check
|
||||
|
||||
This clarifies the code a little. It introduces no functional changes.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-28153
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/glocalfileoutputstream.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/gio/glocalfileoutputstream.c
|
||||
+++ b/gio/glocalfileoutputstream.c
|
||||
@@ -847,6 +847,7 @@ handle_overwrite_open (const char *fi
|
||||
int res;
|
||||
int mode;
|
||||
int errsv;
|
||||
+ gboolean replace_destination_set = (flags & G_FILE_CREATE_REPLACE_DESTINATION);
|
||||
|
||||
mode = mode_from_flags_or_info (flags, reference_info);
|
||||
|
||||
@@ -954,7 +955,7 @@ handle_overwrite_open (const char *fi
|
||||
* to a backup file and rewrite the contents of the file.
|
||||
*/
|
||||
|
||||
- if ((flags & G_FILE_CREATE_REPLACE_DESTINATION) ||
|
||||
+ if (replace_destination_set ||
|
||||
(!(original_stat.st_nlink > 1) && !is_symlink))
|
||||
{
|
||||
char *dirname, *tmp_filename;
|
||||
@@ -973,7 +974,7 @@ handle_overwrite_open (const char *fi
|
||||
|
||||
/* try to keep permissions (unless replacing) */
|
||||
|
||||
- if ( ! (flags & G_FILE_CREATE_REPLACE_DESTINATION) &&
|
||||
+ if (!replace_destination_set &&
|
||||
(
|
||||
#ifdef HAVE_FCHOWN
|
||||
fchown (tmpfd, original_stat.st_uid, original_stat.st_gid) == -1 ||
|
||||
@@ -1112,7 +1113,7 @@ handle_overwrite_open (const char *fi
|
||||
}
|
||||
}
|
||||
|
||||
- if (flags & G_FILE_CREATE_REPLACE_DESTINATION)
|
||||
+ if (replace_destination_set)
|
||||
{
|
||||
g_close (fd, NULL);
|
||||
|
||||
265
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-4.patch
Normal file
265
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-4.patch
Normal file
@@ -0,0 +1,265 @@
|
||||
Backport of:
|
||||
|
||||
From 317b3b587058a05dca95d56dac26568c5b098d33 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Wed, 24 Feb 2021 17:36:07 +0000
|
||||
Subject: [PATCH 4/5] glocalfileoutputstream: Fix CREATE_REPLACE_DESTINATION
|
||||
with symlinks
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The `G_FILE_CREATE_REPLACE_DESTINATION` flag is equivalent to unlinking
|
||||
the destination file and re-creating it from scratch. That did
|
||||
previously work, but in the process the code would call `open(O_CREAT)`
|
||||
on the file. If the file was a dangling symlink, this would create the
|
||||
destination file (empty). That’s not an intended side-effect, and has
|
||||
security implications if the symlink is controlled by a lower-privileged
|
||||
process.
|
||||
|
||||
Fix that by not opening the destination file if it’s a symlink, and
|
||||
adjusting the rest of the code to cope with
|
||||
- the fact that `fd == -1` is not an error iff `is_symlink` is true,
|
||||
- and that `original_stat` will contain the `lstat()` results for the
|
||||
symlink now, rather than the `stat()` results for its target (again,
|
||||
iff `is_symlink` is true).
|
||||
|
||||
This means that the target of the dangling symlink is no longer created,
|
||||
which was the bug. The symlink itself continues to be replaced (as
|
||||
before) with the new file — this is the intended behaviour of
|
||||
`g_file_replace()`.
|
||||
|
||||
The behaviour for non-symlink cases, or cases where the symlink was not
|
||||
dangling, should be unchanged.
|
||||
|
||||
Includes a unit test.
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
Fixes: #2325
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-28153
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/glocalfileoutputstream.c | 77 ++++++++++++++++++-------
|
||||
gio/tests/file.c | 108 +++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 163 insertions(+), 22 deletions(-)
|
||||
|
||||
--- a/gio/glocalfileoutputstream.c
|
||||
+++ b/gio/glocalfileoutputstream.c
|
||||
@@ -875,16 +875,22 @@ handle_overwrite_open (const char *fi
|
||||
/* Could be a symlink, or it could be a regular ELOOP error,
|
||||
* but then the next open will fail too. */
|
||||
is_symlink = TRUE;
|
||||
- fd = g_open (filename, open_flags, mode);
|
||||
+ if (!replace_destination_set)
|
||||
+ fd = g_open (filename, open_flags, mode);
|
||||
}
|
||||
-#else
|
||||
- fd = g_open (filename, open_flags, mode);
|
||||
- errsv = errno;
|
||||
+#else /* if !O_NOFOLLOW */
|
||||
/* This is racy, but we do it as soon as possible to minimize the race */
|
||||
is_symlink = g_file_test (filename, G_FILE_TEST_IS_SYMLINK);
|
||||
+
|
||||
+ if (!is_symlink || !replace_destination_set)
|
||||
+ {
|
||||
+ fd = g_open (filename, open_flags, mode);
|
||||
+ errsv = errno;
|
||||
+ }
|
||||
#endif
|
||||
|
||||
- if (fd == -1)
|
||||
+ if (fd == -1 &&
|
||||
+ (!is_symlink || !replace_destination_set))
|
||||
{
|
||||
char *display_name = g_filename_display_name (filename);
|
||||
g_set_error (error, G_IO_ERROR,
|
||||
@@ -898,7 +904,14 @@ handle_overwrite_open (const char *fi
|
||||
#ifdef G_OS_WIN32
|
||||
res = GLIB_PRIVATE_CALL (g_win32_fstat) (fd, &original_stat);
|
||||
#else
|
||||
- res = fstat (fd, &original_stat);
|
||||
+ if (!is_symlink)
|
||||
+ {
|
||||
+ res = fstat (fd, &original_stat);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ res = lstat (filename, &original_stat);
|
||||
+ }
|
||||
#endif
|
||||
errsv = errno;
|
||||
|
||||
@@ -917,16 +930,27 @@ handle_overwrite_open (const char *fi
|
||||
if (!S_ISREG (original_stat.st_mode))
|
||||
{
|
||||
if (S_ISDIR (original_stat.st_mode))
|
||||
- g_set_error_literal (error,
|
||||
- G_IO_ERROR,
|
||||
- G_IO_ERROR_IS_DIRECTORY,
|
||||
- _("Target file is a directory"));
|
||||
- else
|
||||
- g_set_error_literal (error,
|
||||
+ {
|
||||
+ g_set_error_literal (error,
|
||||
+ G_IO_ERROR,
|
||||
+ G_IO_ERROR_IS_DIRECTORY,
|
||||
+ _("Target file is a directory"));
|
||||
+ goto err_out;
|
||||
+ }
|
||||
+ else if (!is_symlink ||
|
||||
+#ifdef S_ISLNK
|
||||
+ !S_ISLNK (original_stat.st_mode)
|
||||
+#else
|
||||
+ FALSE
|
||||
+#endif
|
||||
+ )
|
||||
+ {
|
||||
+ g_set_error_literal (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_NOT_REGULAR_FILE,
|
||||
_("Target file is not a regular file"));
|
||||
- goto err_out;
|
||||
+ goto err_out;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (etag != NULL)
|
||||
@@ -1007,7 +1031,8 @@ handle_overwrite_open (const char *fi
|
||||
}
|
||||
}
|
||||
|
||||
- g_close (fd, NULL);
|
||||
+ if (fd >= 0)
|
||||
+ g_close (fd, NULL);
|
||||
*temp_filename = tmp_filename;
|
||||
return tmpfd;
|
||||
}
|
||||
--- a/gio/tests/file.c
|
||||
+++ b/gio/tests/file.c
|
||||
@@ -804,6 +804,113 @@ test_replace_cancel (void)
|
||||
g_object_unref (tmpdir);
|
||||
}
|
||||
|
||||
+static void
|
||||
+test_replace_symlink (void)
|
||||
+{
|
||||
+#ifdef G_OS_UNIX
|
||||
+ gchar *tmpdir_path = NULL;
|
||||
+ GFile *tmpdir = NULL, *source_file = NULL, *target_file = NULL;
|
||||
+ GFileOutputStream *stream = NULL;
|
||||
+ const gchar *new_contents = "this is a test message which should be written to source and not target";
|
||||
+ gsize n_written;
|
||||
+ GFileEnumerator *enumerator = NULL;
|
||||
+ GFileInfo *info = NULL;
|
||||
+ gchar *contents = NULL;
|
||||
+ gsize length = 0;
|
||||
+ GError *local_error = NULL;
|
||||
+
|
||||
+ g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/2325");
|
||||
+ g_test_summary ("Test that G_FILE_CREATE_REPLACE_DESTINATION doesn’t follow symlinks");
|
||||
+
|
||||
+ /* Create a fresh, empty working directory. */
|
||||
+ tmpdir_path = g_dir_make_tmp ("g_file_replace_symlink_XXXXXX", &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+ tmpdir = g_file_new_for_path (tmpdir_path);
|
||||
+
|
||||
+ g_test_message ("Using temporary directory %s", tmpdir_path);
|
||||
+ g_free (tmpdir_path);
|
||||
+
|
||||
+ /* Create symlink `source` which points to `target`. */
|
||||
+ source_file = g_file_get_child (tmpdir, "source");
|
||||
+ target_file = g_file_get_child (tmpdir, "target");
|
||||
+ g_file_make_symbolic_link (source_file, "target", NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+
|
||||
+ /* Ensure that `target` doesn’t exist */
|
||||
+ g_assert_false (g_file_query_exists (target_file, NULL));
|
||||
+
|
||||
+ /* Replace the `source` symlink with a regular file using
|
||||
+ * %G_FILE_CREATE_REPLACE_DESTINATION, which should replace it *without*
|
||||
+ * following the symlink */
|
||||
+ stream = g_file_replace (source_file, NULL, FALSE /* no backup */,
|
||||
+ G_FILE_CREATE_REPLACE_DESTINATION, NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+
|
||||
+ g_output_stream_write_all (G_OUTPUT_STREAM (stream), new_contents, strlen (new_contents),
|
||||
+ &n_written, NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+ g_assert_cmpint (n_written, ==, strlen (new_contents));
|
||||
+
|
||||
+ g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+
|
||||
+ g_clear_object (&stream);
|
||||
+
|
||||
+ /* At this point, there should still only be one file: `source`. It should
|
||||
+ * now be a regular file. `target` should not exist. */
|
||||
+ enumerator = g_file_enumerate_children (tmpdir,
|
||||
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
|
||||
+ G_FILE_ATTRIBUTE_STANDARD_TYPE,
|
||||
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+
|
||||
+ info = g_file_enumerator_next_file (enumerator, NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+ g_assert_nonnull (info);
|
||||
+
|
||||
+ g_assert_cmpstr (g_file_info_get_name (info), ==, "source");
|
||||
+ g_assert_cmpint (g_file_info_get_file_type (info), ==, G_FILE_TYPE_REGULAR);
|
||||
+
|
||||
+ g_clear_object (&info);
|
||||
+
|
||||
+ info = g_file_enumerator_next_file (enumerator, NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+ g_assert_null (info);
|
||||
+
|
||||
+ g_file_enumerator_close (enumerator, NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+ g_clear_object (&enumerator);
|
||||
+
|
||||
+ /* Double-check that `target` doesn’t exist */
|
||||
+ g_assert_false (g_file_query_exists (target_file, NULL));
|
||||
+
|
||||
+ /* Check the content of `source`. */
|
||||
+ g_file_load_contents (source_file,
|
||||
+ NULL,
|
||||
+ &contents,
|
||||
+ &length,
|
||||
+ NULL,
|
||||
+ &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+ g_assert_cmpstr (contents, ==, new_contents);
|
||||
+ g_assert_cmpuint (length, ==, strlen (new_contents));
|
||||
+ g_free (contents);
|
||||
+
|
||||
+ /* Tidy up. */
|
||||
+ g_file_delete (source_file, NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+
|
||||
+ g_file_delete (tmpdir, NULL, &local_error);
|
||||
+ g_assert_no_error (local_error);
|
||||
+
|
||||
+ g_clear_object (&target_file);
|
||||
+ g_clear_object (&source_file);
|
||||
+ g_clear_object (&tmpdir);
|
||||
+#else /* if !G_OS_UNIX */
|
||||
+ g_test_skip ("Symlink replacement tests can only be run on Unix")
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
static void
|
||||
on_file_deleted (GObject *object,
|
||||
GAsyncResult *result,
|
||||
@@ -1752,6 +1859,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_data_func ("/file/async-create-delete/4096", GINT_TO_POINTER (4096), test_create_delete);
|
||||
g_test_add_func ("/file/replace-load", test_replace_load);
|
||||
g_test_add_func ("/file/replace-cancel", test_replace_cancel);
|
||||
+ g_test_add_func ("/file/replace-symlink", test_replace_symlink);
|
||||
g_test_add_func ("/file/async-delete", test_async_delete);
|
||||
#ifdef G_OS_UNIX
|
||||
g_test_add_func ("/file/copy-preserve-mode", test_copy_preserve_mode);
|
||||
55
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-5.patch
Normal file
55
meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-28153-5.patch
Normal file
@@ -0,0 +1,55 @@
|
||||
From 6c6439261bc7a8a0627519848a7222b3e1bd4ffe Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <pwithnall@endlessos.org>
|
||||
Date: Wed, 24 Feb 2021 17:42:24 +0000
|
||||
Subject: [PATCH 5/5] glocalfileoutputstream: Add a missing O_CLOEXEC flag to
|
||||
replace()
|
||||
|
||||
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz]
|
||||
CVE: CVE-2021-28153
|
||||
Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com>
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
gio/glocalfileoutputstream.c | 15 ++++++++++++---
|
||||
1 file changed, 12 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/gio/glocalfileoutputstream.c
|
||||
+++ b/gio/glocalfileoutputstream.c
|
||||
@@ -58,6 +58,12 @@
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
+#ifndef O_CLOEXEC
|
||||
+#define O_CLOEXEC 0
|
||||
+#else
|
||||
+#define HAVE_O_CLOEXEC 1
|
||||
+#endif
|
||||
+
|
||||
struct _GLocalFileOutputStreamPrivate {
|
||||
char *tmp_filename;
|
||||
char *original_filename;
|
||||
@@ -1223,7 +1229,7 @@ _g_local_file_output_stream_replace (con
|
||||
sync_on_close = FALSE;
|
||||
|
||||
/* If the file doesn't exist, create it */
|
||||
- open_flags = O_CREAT | O_EXCL | O_BINARY;
|
||||
+ open_flags = O_CREAT | O_EXCL | O_BINARY | O_CLOEXEC;
|
||||
if (readable)
|
||||
open_flags |= O_RDWR;
|
||||
else
|
||||
@@ -1253,8 +1259,11 @@ _g_local_file_output_stream_replace (con
|
||||
set_error_from_open_errno (filename, error);
|
||||
return NULL;
|
||||
}
|
||||
-
|
||||
-
|
||||
+#if !defined(HAVE_O_CLOEXEC) && defined(F_SETFD)
|
||||
+ else
|
||||
+ fcntl (fd, F_SETFD, FD_CLOEXEC);
|
||||
+#endif
|
||||
+
|
||||
stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL);
|
||||
stream->priv->fd = fd;
|
||||
stream->priv->sync_on_close = sync_on_close;
|
||||
@@ -18,6 +18,30 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
|
||||
file://0001-gio-tests-resources.c-comment-out-a-build-host-only-.patch \
|
||||
file://tzdata-update.patch \
|
||||
file://CVE-2020-35457.patch \
|
||||
file://CVE-2021-27218.patch \
|
||||
file://CVE-2021-27219-01.patch \
|
||||
file://CVE-2021-27219-02.patch \
|
||||
file://CVE-2021-27219-03.patch \
|
||||
file://CVE-2021-27219-04.patch \
|
||||
file://CVE-2021-27219-05.patch \
|
||||
file://CVE-2021-27219-06.patch \
|
||||
file://CVE-2021-27219-07.patch \
|
||||
file://CVE-2021-27219-08.patch \
|
||||
file://CVE-2021-27219-09.patch \
|
||||
file://CVE-2021-27219-10.patch \
|
||||
file://CVE-2021-27219-11.patch \
|
||||
file://CVE-2021-27219-reg1-1.patch \
|
||||
file://CVE-2021-27219-reg1-2.patch \
|
||||
file://CVE-2021-27219-reg1-4.patch \
|
||||
file://CVE-2021-27219-reg1-5.patch \
|
||||
file://CVE-2021-27219-reg2-1.patch \
|
||||
file://CVE-2021-27219-reg2-2.patch \
|
||||
file://CVE-2021-27219-reg2-3.patch \
|
||||
file://CVE-2021-28153-1.patch \
|
||||
file://CVE-2021-28153-2.patch \
|
||||
file://CVE-2021-28153-3.patch \
|
||||
file://CVE-2021-28153-4.patch \
|
||||
file://CVE-2021-28153-5.patch \
|
||||
"
|
||||
|
||||
SRC_URI_append_class-native = " file://relocate-modules.patch"
|
||||
|
||||
@@ -3,6 +3,6 @@ PV = "2.31+git${SRCPV}"
|
||||
SRCREV_glibc ?= "4f0a61f75385c9a5879cbe7202042e88f692a3c8"
|
||||
SRCREV_localedef ?= "cd9f958c4c94a638fa7b2b4e21627364f1a1a655"
|
||||
|
||||
GLIBC_GIT_URI ?= "git://sourceware.org/git/glibc.git;branch=master"
|
||||
GLIBC_GIT_URI ?= "git://sourceware.org/git/glibc.git"
|
||||
|
||||
UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+\.\d+(\.(?!90)\d+)*)"
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
From c0669ae1a629e16b536bf11cdd0865e0dbcf4bee Mon Sep 17 00:00:00 2001
|
||||
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Date: Wed, 30 Dec 2020 21:52:38 +0000
|
||||
Subject: [PATCH] elf: Refactor _dl_update_slotinfo to avoid use after free
|
||||
|
||||
map is not valid to access here because it can be freed by a concurrent
|
||||
dlclose: during tls access (via __tls_get_addr) _dl_update_slotinfo is
|
||||
called without holding dlopen locks. So don't check the modid of map.
|
||||
|
||||
The map == 0 and map != 0 code paths can be shared (avoiding the dtv
|
||||
resize in case of map == 0 is just an optimization: larger dtv than
|
||||
necessary would be fine too).
|
||||
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
---
|
||||
elf/dl-tls.c | 21 +++++----------------
|
||||
1 file changed, 5 insertions(+), 16 deletions(-)
|
||||
---
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=patch;h=c0669ae1a629e16b536bf11cdd0865e0dbcf4bee]
|
||||
Signed-off-by: Akash Hadke <akash.hadke@kpit.com>
|
||||
Signed-off-by: Akash Hadke <hadkeakash4@gmail.com>
|
||||
---
|
||||
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
|
||||
index 24d00c14ef..f8b32b3ecb 100644
|
||||
--- a/elf/dl-tls.c
|
||||
+++ b/elf/dl-tls.c
|
||||
@@ -743,6 +743,8 @@ _dl_update_slotinfo (unsigned long int req_modid)
|
||||
{
|
||||
for (size_t cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
|
||||
{
|
||||
+ size_t modid = total + cnt;
|
||||
+
|
||||
size_t gen = listp->slotinfo[cnt].gen;
|
||||
|
||||
if (gen > new_gen)
|
||||
@@ -758,25 +760,12 @@ _dl_update_slotinfo (unsigned long int req_modid)
|
||||
|
||||
/* If there is no map this means the entry is empty. */
|
||||
struct link_map *map = listp->slotinfo[cnt].map;
|
||||
- if (map == NULL)
|
||||
- {
|
||||
- if (dtv[-1].counter >= total + cnt)
|
||||
- {
|
||||
- /* If this modid was used at some point the memory
|
||||
- might still be allocated. */
|
||||
- free (dtv[total + cnt].pointer.to_free);
|
||||
- dtv[total + cnt].pointer.val = TLS_DTV_UNALLOCATED;
|
||||
- dtv[total + cnt].pointer.to_free = NULL;
|
||||
- }
|
||||
-
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
/* Check whether the current dtv array is large enough. */
|
||||
- size_t modid = map->l_tls_modid;
|
||||
- assert (total + cnt == modid);
|
||||
if (dtv[-1].counter < modid)
|
||||
{
|
||||
+ if (map == NULL)
|
||||
+ continue;
|
||||
+
|
||||
/* Resize the dtv. */
|
||||
dtv = _dl_resize_dtv (dtv);
|
||||
|
||||
--
|
||||
2.27.0
|
||||
@@ -0,0 +1,191 @@
|
||||
From 1387ad6225c2222f027790e3f460e31aa5dd2c54 Mon Sep 17 00:00:00 2001
|
||||
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Date: Wed, 30 Dec 2020 19:19:37 +0000
|
||||
Subject: [PATCH] elf: Fix data races in pthread_create and TLS access [BZ
|
||||
#19329]
|
||||
|
||||
DTV setup at thread creation (_dl_allocate_tls_init) is changed
|
||||
to take the dlopen lock, GL(dl_load_lock). Avoiding data races
|
||||
here without locks would require design changes: the map that is
|
||||
accessed for static TLS initialization here may be concurrently
|
||||
freed by dlclose. That use after free may be solved by only
|
||||
locking around static TLS setup or by ensuring dlclose does not
|
||||
free modules with static TLS, however currently every link map
|
||||
with TLS has to be accessed at least to see if it needs static
|
||||
TLS. And even if that's solved, still a lot of atomics would be
|
||||
needed to synchronize DTV related globals without a lock. So fix
|
||||
both bug 19329 and bug 27111 with a lock that prevents DTV setup
|
||||
running concurrently with dlopen or dlclose.
|
||||
|
||||
_dl_update_slotinfo at TLS access still does not use any locks
|
||||
so CONCURRENCY NOTES are added to explain the synchronization.
|
||||
The early exit from the slotinfo walk when max_modid is reached
|
||||
is not strictly necessary, but does not hurt either.
|
||||
|
||||
An incorrect acquire load was removed from _dl_resize_dtv: it
|
||||
did not synchronize with any release store or fence and
|
||||
synchronization is now handled separately at thread creation
|
||||
and TLS access time.
|
||||
|
||||
There are still a number of racy read accesses to globals that
|
||||
will be changed to relaxed MO atomics in a followup patch. This
|
||||
should not introduce regressions compared to existing behaviour
|
||||
and avoid cluttering the main part of the fix.
|
||||
|
||||
Not all TLS access related data races got fixed here: there are
|
||||
additional races at lazy tlsdesc relocations see bug 27137.
|
||||
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
---
|
||||
elf/dl-tls.c | 63 +++++++++++++++++++++++++++++++++++++++-------------
|
||||
1 file changed, 47 insertions(+), 16 deletions(-)
|
||||
---
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=patch;h=1387ad6225c2222f027790e3f460e31aa5dd2c54]
|
||||
Signed-off-by: Akash Hadke <akash.hadke@kpit.com>
|
||||
Signed-off-by: Akash Hadke <hadkeakash4@gmail.com>
|
||||
---
|
||||
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
|
||||
index 6baff0c1ea..94f3cdbae0 100644
|
||||
--- a/elf/dl-tls.c
|
||||
+++ b/elf/dl-tls.c
|
||||
@@ -475,14 +475,11 @@ extern dtv_t _dl_static_dtv[];
|
||||
#endif
|
||||
|
||||
static dtv_t *
|
||||
-_dl_resize_dtv (dtv_t *dtv)
|
||||
+_dl_resize_dtv (dtv_t *dtv, size_t max_modid)
|
||||
{
|
||||
/* Resize the dtv. */
|
||||
dtv_t *newp;
|
||||
- /* Load GL(dl_tls_max_dtv_idx) atomically since it may be written to by
|
||||
- other threads concurrently. */
|
||||
- size_t newsize
|
||||
- = atomic_load_acquire (&GL(dl_tls_max_dtv_idx)) + DTV_SURPLUS;
|
||||
+ size_t newsize = max_modid + DTV_SURPLUS;
|
||||
size_t oldsize = dtv[-1].counter;
|
||||
|
||||
if (dtv == GL(dl_initial_dtv))
|
||||
@@ -528,11 +525,14 @@ _dl_allocate_tls_init (void *result)
|
||||
size_t total = 0;
|
||||
size_t maxgen = 0;
|
||||
|
||||
+ /* Protects global dynamic TLS related state. */
|
||||
+ __rtld_lock_lock_recursive (GL(dl_load_lock));
|
||||
+
|
||||
/* Check if the current dtv is big enough. */
|
||||
if (dtv[-1].counter < GL(dl_tls_max_dtv_idx))
|
||||
{
|
||||
/* Resize the dtv. */
|
||||
- dtv = _dl_resize_dtv (dtv);
|
||||
+ dtv = _dl_resize_dtv (dtv, GL(dl_tls_max_dtv_idx));
|
||||
|
||||
/* Install this new dtv in the thread data structures. */
|
||||
INSTALL_DTV (result, &dtv[-1]);
|
||||
@@ -600,6 +600,7 @@ _dl_allocate_tls_init (void *result)
|
||||
listp = listp->next;
|
||||
assert (listp != NULL);
|
||||
}
|
||||
+ __rtld_lock_unlock_recursive (GL(dl_load_lock));
|
||||
|
||||
/* The DTV version is up-to-date now. */
|
||||
dtv[0].counter = maxgen;
|
||||
@@ -734,12 +735,29 @@ _dl_update_slotinfo (unsigned long int req_modid)
|
||||
|
||||
if (dtv[0].counter < listp->slotinfo[idx].gen)
|
||||
{
|
||||
- /* The generation counter for the slot is higher than what the
|
||||
- current dtv implements. We have to update the whole dtv but
|
||||
- only those entries with a generation counter <= the one for
|
||||
- the entry we need. */
|
||||
+ /* CONCURRENCY NOTES:
|
||||
+
|
||||
+ Here the dtv needs to be updated to new_gen generation count.
|
||||
+
|
||||
+ This code may be called during TLS access when GL(dl_load_lock)
|
||||
+ is not held. In that case the user code has to synchronize with
|
||||
+ dlopen and dlclose calls of relevant modules. A module m is
|
||||
+ relevant if the generation of m <= new_gen and dlclose of m is
|
||||
+ synchronized: a memory access here happens after the dlopen and
|
||||
+ before the dlclose of relevant modules. The dtv entries for
|
||||
+ relevant modules need to be updated, other entries can be
|
||||
+ arbitrary.
|
||||
+
|
||||
+ This e.g. means that the first part of the slotinfo list can be
|
||||
+ accessed race free, but the tail may be concurrently extended.
|
||||
+ Similarly relevant slotinfo entries can be read race free, but
|
||||
+ other entries are racy. However updating a non-relevant dtv
|
||||
+ entry does not affect correctness. For a relevant module m,
|
||||
+ max_modid >= modid of m. */
|
||||
size_t new_gen = listp->slotinfo[idx].gen;
|
||||
size_t total = 0;
|
||||
+ size_t max_modid = atomic_load_relaxed (&GL(dl_tls_max_dtv_idx));
|
||||
+ assert (max_modid >= req_modid);
|
||||
|
||||
/* We have to look through the entire dtv slotinfo list. */
|
||||
listp = GL(dl_tls_dtv_slotinfo_list);
|
||||
@@ -749,12 +767,14 @@ _dl_update_slotinfo (unsigned long int req_modid)
|
||||
{
|
||||
size_t modid = total + cnt;
|
||||
|
||||
+ /* Later entries are not relevant. */
|
||||
+ if (modid > max_modid)
|
||||
+ break;
|
||||
+
|
||||
size_t gen = listp->slotinfo[cnt].gen;
|
||||
|
||||
if (gen > new_gen)
|
||||
- /* This is a slot for a generation younger than the
|
||||
- one we are handling now. It might be incompletely
|
||||
- set up so ignore it. */
|
||||
+ /* Not relevant. */
|
||||
continue;
|
||||
|
||||
/* If the entry is older than the current dtv layout we
|
||||
@@ -771,7 +791,7 @@ _dl_update_slotinfo (unsigned long int req_modid)
|
||||
continue;
|
||||
|
||||
/* Resize the dtv. */
|
||||
- dtv = _dl_resize_dtv (dtv);
|
||||
+ dtv = _dl_resize_dtv (dtv, max_modid);
|
||||
|
||||
assert (modid <= dtv[-1].counter);
|
||||
|
||||
@@ -793,8 +813,17 @@ _dl_update_slotinfo (unsigned long int req_modid)
|
||||
}
|
||||
|
||||
total += listp->len;
|
||||
+ if (total > max_modid)
|
||||
+ break;
|
||||
+
|
||||
+ /* Synchronize with _dl_add_to_slotinfo. Ideally this would
|
||||
+ be consume MO since we only need to order the accesses to
|
||||
+ the next node after the read of the address and on most
|
||||
+ hardware (other than alpha) a normal load would do that
|
||||
+ because of the address dependency. */
|
||||
+ listp = atomic_load_acquire (&listp->next);
|
||||
}
|
||||
- while ((listp = listp->next) != NULL);
|
||||
+ while (listp != NULL);
|
||||
|
||||
/* This will be the new maximum generation counter. */
|
||||
dtv[0].counter = new_gen;
|
||||
@@ -986,7 +1015,7 @@ _dl_add_to_slotinfo (struct link_map *l, bool do_add)
|
||||
the first slot. */
|
||||
assert (idx == 0);
|
||||
|
||||
- listp = prevp->next = (struct dtv_slotinfo_list *)
|
||||
+ listp = (struct dtv_slotinfo_list *)
|
||||
malloc (sizeof (struct dtv_slotinfo_list)
|
||||
+ TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
|
||||
if (listp == NULL)
|
||||
@@ -1000,6 +1029,8 @@ cannot create TLS data structures"));
|
||||
listp->next = NULL;
|
||||
memset (listp->slotinfo, '\0',
|
||||
TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
|
||||
+ /* Synchronize with _dl_update_slotinfo. */
|
||||
+ atomic_store_release (&prevp->next, listp);
|
||||
}
|
||||
|
||||
/* Add the information into the slotinfo data structure. */
|
||||
--
|
||||
2.27.0
|
||||
@@ -0,0 +1,206 @@
|
||||
From f4f8f4d4e0f92488431b268c8cd9555730b9afe9 Mon Sep 17 00:00:00 2001
|
||||
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Date: Wed, 30 Dec 2020 19:19:37 +0000
|
||||
Subject: [PATCH] elf: Use relaxed atomics for racy accesses [BZ #19329]
|
||||
|
||||
This is a follow up patch to the fix for bug 19329. This adds relaxed
|
||||
MO atomics to accesses that were previously data races but are now
|
||||
race conditions, and where relaxed MO is sufficient.
|
||||
|
||||
The race conditions all follow the pattern that the write is behind the
|
||||
dlopen lock, but a read can happen concurrently (e.g. during tls access)
|
||||
without holding the lock. For slotinfo entries the read value only
|
||||
matters if it reads from a synchronized write in dlopen or dlclose,
|
||||
otherwise the related dtv entry is not valid to access so it is fine
|
||||
to leave it in an inconsistent state. The same applies for
|
||||
GL(dl_tls_max_dtv_idx) and GL(dl_tls_generation), but there the
|
||||
algorithm relies on the fact that the read of the last synchronized
|
||||
write is an increasing value.
|
||||
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
---
|
||||
elf/dl-close.c | 20 +++++++++++++-------
|
||||
elf/dl-open.c | 5 ++++-
|
||||
elf/dl-tls.c | 31 +++++++++++++++++++++++--------
|
||||
sysdeps/x86_64/dl-tls.c | 3 ++-
|
||||
4 files changed, 42 insertions(+), 17 deletions(-)
|
||||
---
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=patch;h=f4f8f4d4e0f92488431b268c8cd9555730b9afe9]
|
||||
Comment: Hunks from elf/dl-open.c and elf/dl-tls.c are refreshed due to offset change.
|
||||
Signed-off-by: Akash Hadke <akash.hadke@kpit.com>
|
||||
Signed-off-by: Akash Hadke <hadkeakash4@gmail.com>
|
||||
---
|
||||
diff --git a/elf/dl-close.c b/elf/dl-close.c
|
||||
index c51becd06b..3720e47dd1 100644
|
||||
--- a/elf/dl-close.c
|
||||
+++ b/elf/dl-close.c
|
||||
@@ -79,9 +79,10 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp,
|
||||
{
|
||||
assert (old_map->l_tls_modid == idx);
|
||||
|
||||
- /* Mark the entry as unused. */
|
||||
- listp->slotinfo[idx - disp].gen = GL(dl_tls_generation) + 1;
|
||||
- listp->slotinfo[idx - disp].map = NULL;
|
||||
+ /* Mark the entry as unused. These can be read concurrently. */
|
||||
+ atomic_store_relaxed (&listp->slotinfo[idx - disp].gen,
|
||||
+ GL(dl_tls_generation) + 1);
|
||||
+ atomic_store_relaxed (&listp->slotinfo[idx - disp].map, NULL);
|
||||
}
|
||||
|
||||
/* If this is not the last currently used entry no need to look
|
||||
@@ -96,8 +97,8 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp,
|
||||
|
||||
if (listp->slotinfo[idx - disp].map != NULL)
|
||||
{
|
||||
- /* Found a new last used index. */
|
||||
- GL(dl_tls_max_dtv_idx) = idx;
|
||||
+ /* Found a new last used index. This can be read concurrently. */
|
||||
+ atomic_store_relaxed (&GL(dl_tls_max_dtv_idx), idx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -571,7 +572,9 @@ _dl_close_worker (struct link_map *map, bool force)
|
||||
GL(dl_tls_dtv_slotinfo_list), 0,
|
||||
imap->l_init_called))
|
||||
/* All dynamically loaded modules with TLS are unloaded. */
|
||||
- GL(dl_tls_max_dtv_idx) = GL(dl_tls_static_nelem);
|
||||
+ /* Can be read concurrently. */
|
||||
+ atomic_store_relaxed (&GL(dl_tls_max_dtv_idx),
|
||||
+ GL(dl_tls_static_nelem));
|
||||
|
||||
if (imap->l_tls_offset != NO_TLS_OFFSET
|
||||
&& imap->l_tls_offset != FORCED_DYNAMIC_TLS_OFFSET)
|
||||
@@ -769,8 +772,11 @@ _dl_close_worker (struct link_map *map, bool force)
|
||||
/* If we removed any object which uses TLS bump the generation counter. */
|
||||
if (any_tls)
|
||||
{
|
||||
- if (__glibc_unlikely (++GL(dl_tls_generation) == 0))
|
||||
+ size_t newgen = GL(dl_tls_generation) + 1;
|
||||
+ if (__glibc_unlikely (newgen == 0))
|
||||
_dl_fatal_printf ("TLS generation counter wrapped! Please report as described in "REPORT_BUGS_TO".\n");
|
||||
+ /* Can be read concurrently. */
|
||||
+ atomic_store_relaxed (&GL(dl_tls_generation), newgen);
|
||||
|
||||
if (tls_free_end == GL(dl_tls_static_used))
|
||||
GL(dl_tls_static_used) = tls_free_start;
|
||||
diff --git a/elf/dl-open.c b/elf/dl-open.c
|
||||
index 09f0df7d38..bb79ef00f1 100644
|
||||
--- a/elf/dl-open.c
|
||||
+++ b/elf/dl-open.c
|
||||
@@ -387,9 +387,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (__builtin_expect (++GL(dl_tls_generation) == 0, 0))
|
||||
+ size_t newgen = GL(dl_tls_generation) + 1;
|
||||
+ if (__glibc_unlikely (newgen == 0))
|
||||
_dl_fatal_printf (N_("\
|
||||
TLS generation counter wrapped! Please report this."));
|
||||
+ /* Can be read concurrently. */
|
||||
+ atomic_store_relaxed (&GL(dl_tls_generation), newgen);
|
||||
|
||||
/* We need a second pass for static tls data, because
|
||||
_dl_update_slotinfo must not be run while calls to
|
||||
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
|
||||
index 94f3cdbae0..dc69cd984e 100644
|
||||
--- a/elf/dl-tls.c
|
||||
+++ b/elf/dl-tls.c
|
||||
@@ -96,7 +96,9 @@
|
||||
/* No gaps, allocate a new entry. */
|
||||
nogaps:
|
||||
|
||||
- result = ++GL(dl_tls_max_dtv_idx);
|
||||
+ result = GL(dl_tls_max_dtv_idx) + 1;
|
||||
+ /* Can be read concurrently. */
|
||||
+ atomic_store_relaxed (&GL(dl_tls_max_dtv_idx), result);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -279,10 +281,12 @@
|
||||
dtv_t *dtv;
|
||||
size_t dtv_length;
|
||||
|
||||
+ /* Relaxed MO, because the dtv size is later rechecked, not relied on. */
|
||||
+ size_t max_modid = atomic_load_relaxed (&GL(dl_tls_max_dtv_idx));
|
||||
/* We allocate a few more elements in the dtv than are needed for the
|
||||
initial set of modules. This should avoid in most cases expansions
|
||||
of the dtv. */
|
||||
- dtv_length = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS;
|
||||
+ dtv_length = max_modid + DTV_SURPLUS;
|
||||
dtv = calloc (dtv_length + 2, sizeof (dtv_t));
|
||||
if (dtv != NULL)
|
||||
{
|
||||
@@ -687,7 +691,7 @@
|
||||
if (modid > max_modid)
|
||||
break;
|
||||
|
||||
- size_t gen = listp->slotinfo[cnt].gen;
|
||||
+ size_t gen = atomic_load_relaxed (&listp->slotinfo[cnt].gen);
|
||||
|
||||
if (gen > new_gen)
|
||||
/* Not relevant. */
|
||||
@@ -699,7 +703,8 @@
|
||||
continue;
|
||||
|
||||
/* If there is no map this means the entry is empty. */
|
||||
- struct link_map *map = listp->slotinfo[cnt].map;
|
||||
+ struct link_map *map
|
||||
+ = atomic_load_relaxed (&listp->slotinfo[cnt].map);
|
||||
/* Check whether the current dtv array is large enough. */
|
||||
if (dtv[-1].counter < modid)
|
||||
{
|
||||
@@ -843,7 +848,12 @@
|
||||
{
|
||||
dtv_t *dtv = THREAD_DTV ();
|
||||
|
||||
- if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation)))
|
||||
+ /* Update is needed if dtv[0].counter < the generation of the accessed
|
||||
+ module. The global generation counter is used here as it is easier
|
||||
+ to check. Synchronization for the relaxed MO access is guaranteed
|
||||
+ by user code, see CONCURRENCY NOTES in _dl_update_slotinfo. */
|
||||
+ size_t gen = atomic_load_relaxed (&GL(dl_tls_generation));
|
||||
+ if (__glibc_unlikely (dtv[0].counter != gen))
|
||||
return update_get_addr (GET_ADDR_PARAM);
|
||||
|
||||
void *p = dtv[GET_ADDR_MODULE].pointer.val;
|
||||
@@ -866,7 +876,10 @@
|
||||
return NULL;
|
||||
|
||||
dtv_t *dtv = THREAD_DTV ();
|
||||
- if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation)))
|
||||
+ /* This may be called without holding the GL(dl_load_lock). Reading
|
||||
+ arbitrary gen value is fine since this is best effort code. */
|
||||
+ size_t gen = atomic_load_relaxed (&GL(dl_tls_generation));
|
||||
+ if (__glibc_unlikely (dtv[0].counter != gen))
|
||||
{
|
||||
/* This thread's DTV is not completely current,
|
||||
but it might already cover this module. */
|
||||
@@ -961,7 +974,9 @@
|
||||
/* Add the information into the slotinfo data structure. */
|
||||
if (do_add)
|
||||
{
|
||||
- listp->slotinfo[idx].map = l;
|
||||
- listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1;
|
||||
+ /* Can be read concurrently. See _dl_update_slotinfo. */
|
||||
+ atomic_store_relaxed (&listp->slotinfo[idx].map, l);
|
||||
+ atomic_store_relaxed (&listp->slotinfo[idx].gen,
|
||||
+ GL(dl_tls_generation) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/sysdeps/x86_64/dl-tls.c b/sysdeps/x86_64/dl-tls.c
|
||||
index 6595f6615b..24ef560b71 100644
|
||||
--- a/sysdeps/x86_64/dl-tls.c
|
||||
+++ b/sysdeps/x86_64/dl-tls.c
|
||||
@@ -40,7 +40,8 @@ __tls_get_addr_slow (GET_ADDR_ARGS)
|
||||
{
|
||||
dtv_t *dtv = THREAD_DTV ();
|
||||
|
||||
- if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation)))
|
||||
+ size_t gen = atomic_load_relaxed (&GL(dl_tls_generation));
|
||||
+ if (__glibc_unlikely (dtv[0].counter != gen))
|
||||
return update_get_addr (GET_ADDR_PARAM);
|
||||
|
||||
return tls_get_addr_tail (GET_ADDR_PARAM, dtv, NULL);
|
||||
--
|
||||
2.27.0
|
||||
@@ -0,0 +1,144 @@
|
||||
From 9d0e30329c23b5ad736fda3f174208c25970dbce Mon Sep 17 00:00:00 2001
|
||||
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Date: Tue, 13 Dec 2016 12:28:41 +0000
|
||||
Subject: [PATCH] elf: Add test case for [BZ #19329]
|
||||
|
||||
Test concurrent dlopen and pthread_create when the loaded modules have
|
||||
TLS. This triggers dl-tls assertion failures more reliably than the
|
||||
nptl/tst-stack4 test.
|
||||
|
||||
The dlopened module has 100 DT_NEEDED dependencies with TLS, they were
|
||||
reused from an existing TLS test. The number of created threads during
|
||||
dlopen depends on filesystem speed and hardware, but at most 3 threads
|
||||
are alive at a time to limit resource usage.
|
||||
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
---
|
||||
elf/Makefile | 9 ++++--
|
||||
elf/tst-tls21.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
elf/tst-tls21mod.c | 1 +
|
||||
3 files changed, 76 insertions(+), 2 deletions(-)
|
||||
create mode 100644 elf/tst-tls21.c
|
||||
create mode 100644 elf/tst-tls21mod.c
|
||||
---
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=patch;h=9d0e30329c23b5ad736fda3f174208c25970dbce]
|
||||
Comment: Hunks from elf/Makefile are refreshed as per glibc 2.31 codebase.
|
||||
Signed-off-by: Akash Hadke <akash.hadke@kpit.com>
|
||||
Signed-off-by: Akash Hadke <hadkeakash4@gmail.com>
|
||||
---
|
||||
diff --git a/elf/Makefile b/elf/Makefile
|
||||
index d3e909637a..3241cb6046 100644
|
||||
--- a/elf/Makefile
|
||||
+++ b/elf/Makefile
|
||||
@@ -201,7 +201,7 @@
|
||||
tst-unwind-ctor tst-unwind-main tst-audit13 \
|
||||
tst-sonamemove-link tst-sonamemove-dlopen tst-dlopen-tlsmodid \
|
||||
tst-dlopen-self tst-auditmany tst-initfinilazyfail tst-dlopenfail \
|
||||
- tst-dlopenfail-2
|
||||
+ tst-dlopenfail-2 tst-tls21
|
||||
# reldep9
|
||||
tests-internal += loadtest unload unload2 circleload1 \
|
||||
neededtest neededtest2 neededtest3 neededtest4 \
|
||||
@@ -312,7 +312,7 @@
|
||||
tst-auditmanymod7 tst-auditmanymod8 tst-auditmanymod9 \
|
||||
tst-initlazyfailmod tst-finilazyfailmod \
|
||||
tst-dlopenfailmod1 tst-dlopenfaillinkmod tst-dlopenfailmod2 \
|
||||
- tst-dlopenfailmod3 tst-ldconfig-ld-mod
|
||||
+ tst-dlopenfailmod3 tst-ldconfig-ld-mod tst-tls21mod
|
||||
# Most modules build with _ISOMAC defined, but those filtered out
|
||||
# depend on internal headers.
|
||||
modules-names-tests = $(filter-out ifuncmod% tst-libc_dlvsym-dso tst-tlsmod%,\
|
||||
@@ -1697,5 +1697,10 @@
|
||||
$(objpfx)tst-dlopen-nodelete-reloc-mod16.so
|
||||
LDFLAGS-tst-dlopen-nodelete-reloc-mod17.so = -Wl,--no-as-needed
|
||||
|
||||
+# Reuses tst-tls-many-dynamic-modules
|
||||
+$(objpfx)tst-tls21: $(libdl) $(shared-thread-library)
|
||||
+$(objpfx)tst-tls21.out: $(objpfx)tst-tls21mod.so
|
||||
+$(objpfx)tst-tls21mod.so: $(tst-tls-many-dynamic-modules:%=$(objpfx)%.so)
|
||||
+
|
||||
$(objpfx)tst-ldconfig-ld_so_conf-update.out: $(objpfx)tst-ldconfig-ld-mod.so
|
||||
$(objpfx)tst-ldconfig-ld_so_conf-update: $(libdl)
|
||||
diff --git a/elf/tst-tls21.c b/elf/tst-tls21.c
|
||||
new file mode 100644
|
||||
index 0000000000..560bf5813a
|
||||
--- /dev/null
|
||||
+++ b/elf/tst-tls21.c
|
||||
@@ -0,0 +1,68 @@
|
||||
+/* Test concurrent dlopen and pthread_create: BZ 19329.
|
||||
+ Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <http://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+#include <dlfcn.h>
|
||||
+#include <pthread.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdatomic.h>
|
||||
+#include <support/xdlfcn.h>
|
||||
+#include <support/xthread.h>
|
||||
+
|
||||
+#define THREADS 10000
|
||||
+
|
||||
+static atomic_int done;
|
||||
+
|
||||
+static void *
|
||||
+start (void *a)
|
||||
+{
|
||||
+ /* Load a module with many dependencies that each have TLS. */
|
||||
+ xdlopen ("tst-tls21mod.so", RTLD_LAZY);
|
||||
+ atomic_store_explicit (&done, 1, memory_order_release);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void *
|
||||
+nop (void *a)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+do_test (void)
|
||||
+{
|
||||
+ pthread_t t1, t2;
|
||||
+ int i;
|
||||
+
|
||||
+ /* Load a module with lots of dependencies and TLS. */
|
||||
+ t1 = xpthread_create (0, start, 0);
|
||||
+
|
||||
+ /* Concurrently create lots of threads until dlopen is observably done. */
|
||||
+ for (i = 0; i < THREADS; i++)
|
||||
+ {
|
||||
+ if (atomic_load_explicit (&done, memory_order_acquire) != 0)
|
||||
+ break;
|
||||
+ t2 = xpthread_create (0, nop, 0);
|
||||
+ xpthread_join (t2);
|
||||
+ }
|
||||
+
|
||||
+ xpthread_join (t1);
|
||||
+ printf ("threads created during dlopen: %d\n", i);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#include <support/test-driver.c>
|
||||
diff --git a/elf/tst-tls21mod.c b/elf/tst-tls21mod.c
|
||||
new file mode 100644
|
||||
index 0000000000..206ece4fb3
|
||||
--- /dev/null
|
||||
+++ b/elf/tst-tls21mod.c
|
||||
@@ -0,0 +1 @@
|
||||
+int __thread x;
|
||||
--
|
||||
2.27.0
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user