mirror of
https://git.yoctoproject.org/poky
synced 2026-02-21 08:59:41 +01:00
Compare commits
58 Commits
yocto-3.1.
...
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 |
@@ -624,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
|
||||
|
||||
@@ -1019,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)
|
||||
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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,7 @@ import os
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
current_version = "3.1.12"
|
||||
current_version = "3.1.13"
|
||||
bitbake_version = "1.46"
|
||||
|
||||
# String used in sidebar
|
||||
|
||||
@@ -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 : "3.1.13"
|
||||
YOCTO_DOC_VERSION_MINUS_ONE : "3.0.4"
|
||||
DISTRO_REL_TAG : "yocto-3.1.12"
|
||||
POKYVERSION : "23.0.12"
|
||||
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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,6 +38,7 @@ Release Series 3.1 (dunfell)
|
||||
- :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>`
|
||||
|
||||
==========================
|
||||
Outdated Release Manuals
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'3.4.1': '3.4.1',
|
||||
'3.3.4': '3.3.4',
|
||||
'3.2.4': '3.2.4',
|
||||
'3.1.12': '3.1.12',
|
||||
'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.13"
|
||||
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"
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -181,6 +181,10 @@ class TestImage(OESelftestTestCase):
|
||||
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"
|
||||
|
||||
@@ -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
|
||||
@@ -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 = " \
|
||||
|
||||
@@ -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 \
|
||||
"
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,180 @@
|
||||
From ba33937be210da5d07f7f01709323743f66011ce Mon Sep 17 00:00:00 2001
|
||||
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
Date: Fri, 25 Jun 2021 10:54:12 -0300
|
||||
Subject: [PATCH] elf: Fix DTV gap reuse logic (BZ #27135)
|
||||
|
||||
This is updated version of the 572bd547d57a (reverted by 40ebfd016ad2)
|
||||
that fixes the _dl_next_tls_modid issues.
|
||||
|
||||
This issue with 572bd547d57a patch is the DTV entry will be only
|
||||
update on dl_open_worker() with the update_tls_slotinfo() call after
|
||||
all dependencies are being processed by _dl_map_object_deps(). However
|
||||
_dl_map_object_deps() itself might call _dl_next_tls_modid(), and since
|
||||
the _dl_tls_dtv_slotinfo_list::map is not yet set the entry will be
|
||||
wrongly reused.
|
||||
|
||||
This patch fixes by renaming the _dl_next_tls_modid() function to
|
||||
_dl_assign_tls_modid() and by passing the link_map so it can set
|
||||
the slotinfo value so a subsequente _dl_next_tls_modid() call will
|
||||
see the entry as allocated.
|
||||
|
||||
The intermediary value is cleared up on remove_slotinfo() for the case
|
||||
a library fails to load with RTLD_NOW.
|
||||
|
||||
This patch fixes BZ #27135.
|
||||
|
||||
Checked on x86_64-linux-gnu.
|
||||
|
||||
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
---
|
||||
elf/dl-close.c | 8 +-
|
||||
elf/dl-load.c | 2 +-
|
||||
elf/dl-open.c | 10 --
|
||||
elf/dl-tls.c | 17 +--
|
||||
elf/rtld.c | 2 +-
|
||||
sysdeps/generic/ldsodefs.h | 4 +-
|
||||
6 files changed, 349 insertions(+), 33 deletions(-)
|
||||
---
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=patch;h=ba33937be210da5d07f7f01709323743f66011ce]
|
||||
Comment: Removed hunks those were related to test. Hunk from elf/rtld.c is refreshed.
|
||||
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 3720e47dd1..f39001cab9 100644
|
||||
--- a/elf/dl-close.c
|
||||
+++ b/elf/dl-close.c
|
||||
@@ -77,8 +77,6 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp,
|
||||
object that wasn't fully set up. */
|
||||
if (__glibc_likely (old_map != NULL))
|
||||
{
|
||||
- assert (old_map->l_tls_modid == idx);
|
||||
-
|
||||
/* Mark the entry as unused. These can be read concurrently. */
|
||||
atomic_store_relaxed (&listp->slotinfo[idx - disp].gen,
|
||||
GL(dl_tls_generation) + 1);
|
||||
@@ -88,7 +86,11 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp,
|
||||
/* If this is not the last currently used entry no need to look
|
||||
further. */
|
||||
if (idx != GL(dl_tls_max_dtv_idx))
|
||||
- return true;
|
||||
+ {
|
||||
+ /* There is an unused dtv entry in the middle. */
|
||||
+ GL(dl_tls_dtv_gaps) = true;
|
||||
+ return true;
|
||||
+ }
|
||||
}
|
||||
|
||||
while (idx - disp > (disp == 0 ? 1 + GL(dl_tls_static_nelem) : 0))
|
||||
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
||||
index a08df001af..650e4edc35 100644
|
||||
--- a/elf/dl-load.c
|
||||
+++ b/elf/dl-load.c
|
||||
@@ -1498,7 +1498,7 @@ cannot enable executable stack as shared object requires");
|
||||
not set up TLS data structures, so don't use them now. */
|
||||
|| __glibc_likely (GL(dl_tls_dtv_slotinfo_list) != NULL)))
|
||||
/* Assign the next available module ID. */
|
||||
- l->l_tls_modid = _dl_next_tls_modid ();
|
||||
+ _dl_assign_tls_modid (l);
|
||||
|
||||
#ifdef DL_AFTER_LOAD
|
||||
DL_AFTER_LOAD (l);
|
||||
diff --git a/elf/dl-open.c b/elf/dl-open.c
|
||||
index a066f39bd0..d2240d8747 100644
|
||||
--- a/elf/dl-open.c
|
||||
+++ b/elf/dl-open.c
|
||||
@@ -899,16 +899,6 @@ no more namespaces available for dlmopen()"));
|
||||
state if relocation failed, for example. */
|
||||
if (args.map)
|
||||
{
|
||||
- /* Maybe some of the modules which were loaded use TLS.
|
||||
- Since it will be removed in the following _dl_close call
|
||||
- we have to mark the dtv array as having gaps to fill the
|
||||
- holes. This is a pessimistic assumption which won't hurt
|
||||
- if not true. There is no need to do this when we are
|
||||
- loading the auditing DSOs since TLS has not yet been set
|
||||
- up. */
|
||||
- if ((mode & __RTLD_AUDIT) == 0)
|
||||
- GL(dl_tls_dtv_gaps) = true;
|
||||
-
|
||||
_dl_close_worker (args.map, true);
|
||||
|
||||
/* All l_nodelete_pending objects should have been deleted
|
||||
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
|
||||
index 2b5161d10a..423e380f7c 100644
|
||||
--- a/elf/dl-tls.c
|
||||
+++ b/elf/dl-tls.c
|
||||
@@ -126,8 +126,8 @@ oom (void)
|
||||
}
|
||||
|
||||
|
||||
-size_t
|
||||
-_dl_next_tls_modid (void)
|
||||
+void
|
||||
+_dl_assign_tls_modid (struct link_map *l)
|
||||
{
|
||||
size_t result;
|
||||
|
||||
@@ -157,7 +157,11 @@ _dl_next_tls_modid (void)
|
||||
}
|
||||
|
||||
if (result - disp < runp->len)
|
||||
- break;
|
||||
+ {
|
||||
+ /* Mark the entry as used, so any dependency see it. */
|
||||
+ atomic_store_relaxed (&runp->slotinfo[result - disp].map, l);
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
disp += runp->len;
|
||||
}
|
||||
@@ -184,17 +188,14 @@ _dl_next_tls_modid (void)
|
||||
atomic_store_relaxed (&GL(dl_tls_max_dtv_idx), result);
|
||||
}
|
||||
|
||||
- return result;
|
||||
+ l->l_tls_modid = result;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
_dl_count_modids (void)
|
||||
{
|
||||
- /* It is rare that we have gaps; see elf/dl-open.c (_dl_open) where
|
||||
- we fail to load a module and unload it leaving a gap. If we don't
|
||||
- have gaps then the number of modids is the current maximum so
|
||||
- return that. */
|
||||
+ /* The count is the max unless dlclose or failed dlopen created gaps. */
|
||||
if (__glibc_likely (!GL(dl_tls_dtv_gaps)))
|
||||
return GL(dl_tls_max_dtv_idx);
|
||||
|
||||
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||
index e3fb2a5b2a..d733359eaf 100644
|
||||
--- a/elf/rtld.c
|
||||
+++ b/elf/rtld.c
|
||||
@@ -1612,7 +1612,7 @@
|
||||
/* Add the dynamic linker to the TLS list if it also uses TLS. */
|
||||
if (GL(dl_rtld_map).l_tls_blocksize != 0)
|
||||
/* Assign a module ID. Do this before loading any audit modules. */
|
||||
- GL(dl_rtld_map).l_tls_modid = _dl_next_tls_modid ();
|
||||
+ _dl_assign_tls_modid (&GL(dl_rtld_map));
|
||||
|
||||
/* If we have auditing DSOs to load, do it now. */
|
||||
bool need_security_init = true;
|
||||
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||
index 176394de4d..9c15259236 100644
|
||||
--- a/sysdeps/generic/ldsodefs.h
|
||||
+++ b/sysdeps/generic/ldsodefs.h
|
||||
@@ -1171,8 +1171,8 @@ extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
|
||||
extern void _dl_sysdep_start_cleanup (void) attribute_hidden;
|
||||
|
||||
|
||||
-/* Determine next available module ID. */
|
||||
-extern size_t _dl_next_tls_modid (void) attribute_hidden;
|
||||
+/* Determine next available module ID and set the L l_tls_modid. */
|
||||
+extern void _dl_assign_tls_modid (struct link_map *l) attribute_hidden;
|
||||
|
||||
/* Count the modules with TLS segments. */
|
||||
extern size_t _dl_count_modids (void) attribute_hidden;
|
||||
--
|
||||
2.27.0
|
||||
@@ -0,0 +1,56 @@
|
||||
From 8f7e09f4dbdb5c815a18b8285fbc5d5d7bc17d86 Mon Sep 17 00:00:00 2001
|
||||
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Date: Thu, 11 Feb 2021 11:29:23 +0000
|
||||
Subject: [PATCH] x86_64: Avoid lazy relocation of tlsdesc [BZ #27137]
|
||||
|
||||
Lazy tlsdesc relocation is racy because the static tls optimization and
|
||||
tlsdesc management operations are done without holding the dlopen lock.
|
||||
|
||||
This similar to the commit b7cf203b5c17dd6d9878537d41e0c7cc3d270a67
|
||||
for aarch64, but it fixes a different race: bug 27137.
|
||||
|
||||
Another issue is that ld auditing ignores DT_BIND_NOW and thus tries to
|
||||
relocate tlsdesc lazily, but that does not work in a BIND_NOW module
|
||||
due to missing DT_TLSDESC_PLT. Unconditionally relocating tlsdesc at
|
||||
load time fixes this bug 27721 too.
|
||||
---
|
||||
sysdeps/x86_64/dl-machine.h | 19 ++++++++++++++-----
|
||||
1 file changed, 14 insertions(+), 5 deletions(-)
|
||||
---
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=patch;h=8f7e09f4dbdb5c815a18b8285fbc5d5d7bc17d86]
|
||||
Signed-off-by: Akash Hadke <akash.hadke@kpit.com>
|
||||
Signed-off-by: Akash Hadke <hadkeakash4@gmail.com>
|
||||
---
|
||||
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
|
||||
index 103eee6c3f..9a876a371e 100644
|
||||
--- a/sysdeps/x86_64/dl-machine.h
|
||||
+++ b/sysdeps/x86_64/dl-machine.h
|
||||
@@ -570,12 +570,21 @@ elf_machine_lazy_rel (struct link_map *map,
|
||||
}
|
||||
else if (__glibc_likely (r_type == R_X86_64_TLSDESC))
|
||||
{
|
||||
- struct tlsdesc volatile * __attribute__((__unused__)) td =
|
||||
- (struct tlsdesc volatile *)reloc_addr;
|
||||
+ const Elf_Symndx symndx = ELFW (R_SYM) (reloc->r_info);
|
||||
+ const ElfW (Sym) *symtab = (const void *)D_PTR (map, l_info[DT_SYMTAB]);
|
||||
+ const ElfW (Sym) *sym = &symtab[symndx];
|
||||
+ const struct r_found_version *version = NULL;
|
||||
|
||||
- td->arg = (void*)reloc;
|
||||
- td->entry = (void*)(D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_PLT)])
|
||||
- + map->l_addr);
|
||||
+ if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
|
||||
+ {
|
||||
+ const ElfW (Half) *vernum =
|
||||
+ (const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
|
||||
+ version = &map->l_versions[vernum[symndx] & 0x7fff];
|
||||
+ }
|
||||
+
|
||||
+ /* Always initialize TLS descriptors completely at load time, in
|
||||
+ case static TLS is allocated for it that requires locking. */
|
||||
+ elf_machine_rela (map, reloc, sym, version, reloc_addr, skip_ifunc);
|
||||
}
|
||||
else if (__glibc_unlikely (r_type == R_X86_64_IRELATIVE))
|
||||
{
|
||||
--
|
||||
2.27.0
|
||||
@@ -0,0 +1,124 @@
|
||||
From ddcacd91cc10ff92d6201eda87047d029c14158d Mon Sep 17 00:00:00 2001
|
||||
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Date: Thu, 11 Feb 2021 11:40:11 +0000
|
||||
Subject: [PATCH] i386: Avoid lazy relocation of tlsdesc [BZ #27137]
|
||||
|
||||
Lazy tlsdesc relocation is racy because the static tls optimization and
|
||||
tlsdesc management operations are done without holding the dlopen lock.
|
||||
|
||||
This similar to the commit b7cf203b5c17dd6d9878537d41e0c7cc3d270a67
|
||||
for aarch64, but it fixes a different race: bug 27137.
|
||||
|
||||
On i386 the code is a bit more complicated than on x86_64 because both
|
||||
rel and rela relocs are supported.
|
||||
---
|
||||
sysdeps/i386/dl-machine.h | 76 ++++++++++++++++++---------------------
|
||||
1 file changed, 34 insertions(+), 42 deletions(-)
|
||||
---
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=patch;h=ddcacd91cc10ff92d6201eda87047d029c14158d]
|
||||
Signed-off-by: Akash Hadke <akash.hadke@kpit.com>
|
||||
Signed-off-by: Akash Hadke <hadkeakash4@gmail.com>
|
||||
---
|
||||
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
|
||||
index 23e9cc3bfb..590b41d8d7 100644
|
||||
--- a/sysdeps/i386/dl-machine.h
|
||||
+++ b/sysdeps/i386/dl-machine.h
|
||||
@@ -688,50 +688,32 @@ elf_machine_lazy_rel (struct link_map *map,
|
||||
}
|
||||
else if (__glibc_likely (r_type == R_386_TLS_DESC))
|
||||
{
|
||||
- struct tlsdesc volatile * __attribute__((__unused__)) td =
|
||||
- (struct tlsdesc volatile *)reloc_addr;
|
||||
-
|
||||
- /* Handle relocations that reference the local *ABS* in a simple
|
||||
- way, so as to preserve a potential addend. */
|
||||
- if (ELF32_R_SYM (reloc->r_info) == 0)
|
||||
- td->entry = _dl_tlsdesc_resolve_abs_plus_addend;
|
||||
- /* Given a known-zero addend, we can store a pointer to the
|
||||
- reloc in the arg position. */
|
||||
- else if (td->arg == 0)
|
||||
- {
|
||||
- td->arg = (void*)reloc;
|
||||
- td->entry = _dl_tlsdesc_resolve_rel;
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- /* We could handle non-*ABS* relocations with non-zero addends
|
||||
- by allocating dynamically an arg to hold a pointer to the
|
||||
- reloc, but that sounds pointless. */
|
||||
- const Elf32_Rel *const r = reloc;
|
||||
- /* The code below was borrowed from elf_dynamic_do_rel(). */
|
||||
- const ElfW(Sym) *const symtab =
|
||||
- (const void *) D_PTR (map, l_info[DT_SYMTAB]);
|
||||
+ const Elf32_Rel *const r = reloc;
|
||||
+ /* The code below was borrowed from elf_dynamic_do_rel(). */
|
||||
+ const ElfW(Sym) *const symtab =
|
||||
+ (const void *) D_PTR (map, l_info[DT_SYMTAB]);
|
||||
|
||||
+ /* Always initialize TLS descriptors completely at load time, in
|
||||
+ case static TLS is allocated for it that requires locking. */
|
||||
# ifdef RTLD_BOOTSTRAP
|
||||
- /* The dynamic linker always uses versioning. */
|
||||
- assert (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL);
|
||||
+ /* The dynamic linker always uses versioning. */
|
||||
+ assert (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL);
|
||||
# else
|
||||
- if (map->l_info[VERSYMIDX (DT_VERSYM)])
|
||||
+ if (map->l_info[VERSYMIDX (DT_VERSYM)])
|
||||
# endif
|
||||
- {
|
||||
- const ElfW(Half) *const version =
|
||||
- (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
|
||||
- ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)] & 0x7fff;
|
||||
- elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)],
|
||||
- &map->l_versions[ndx],
|
||||
- (void *) (l_addr + r->r_offset), skip_ifunc);
|
||||
- }
|
||||
+ {
|
||||
+ const ElfW(Half) *const version =
|
||||
+ (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
|
||||
+ ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)] & 0x7fff;
|
||||
+ elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)],
|
||||
+ &map->l_versions[ndx],
|
||||
+ (void *) (l_addr + r->r_offset), skip_ifunc);
|
||||
+ }
|
||||
# ifndef RTLD_BOOTSTRAP
|
||||
- else
|
||||
- elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
|
||||
- (void *) (l_addr + r->r_offset), skip_ifunc);
|
||||
+ else
|
||||
+ elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
|
||||
+ (void *) (l_addr + r->r_offset), skip_ifunc);
|
||||
# endif
|
||||
- }
|
||||
}
|
||||
else if (__glibc_unlikely (r_type == R_386_IRELATIVE))
|
||||
{
|
||||
@@ -758,11 +740,21 @@ elf_machine_lazy_rela (struct link_map *map,
|
||||
;
|
||||
else if (__glibc_likely (r_type == R_386_TLS_DESC))
|
||||
{
|
||||
- struct tlsdesc volatile * __attribute__((__unused__)) td =
|
||||
- (struct tlsdesc volatile *)reloc_addr;
|
||||
+ const Elf_Symndx symndx = ELFW (R_SYM) (reloc->r_info);
|
||||
+ const ElfW (Sym) *symtab = (const void *)D_PTR (map, l_info[DT_SYMTAB]);
|
||||
+ const ElfW (Sym) *sym = &symtab[symndx];
|
||||
+ const struct r_found_version *version = NULL;
|
||||
+
|
||||
+ if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
|
||||
+ {
|
||||
+ const ElfW (Half) *vernum =
|
||||
+ (const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
|
||||
+ version = &map->l_versions[vernum[symndx] & 0x7fff];
|
||||
+ }
|
||||
|
||||
- td->arg = (void*)reloc;
|
||||
- td->entry = _dl_tlsdesc_resolve_rela;
|
||||
+ /* Always initialize TLS descriptors completely at load time, in
|
||||
+ case static TLS is allocated for it that requires locking. */
|
||||
+ elf_machine_rela (map, reloc, sym, version, reloc_addr, skip_ifunc);
|
||||
}
|
||||
else if (__glibc_unlikely (r_type == R_386_IRELATIVE))
|
||||
{
|
||||
--
|
||||
2.27.0
|
||||
@@ -0,0 +1,276 @@
|
||||
From 83b5323261bb72313bffcf37476c1b8f0847c736 Mon Sep 17 00:00:00 2001
|
||||
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Date: Wed, 15 Sep 2021 15:16:19 +0100
|
||||
Subject: [PATCH] elf: Avoid deadlock between pthread_create and ctors [BZ
|
||||
#28357]
|
||||
|
||||
The fix for bug 19329 caused a regression such that pthread_create can
|
||||
deadlock when concurrent ctors from dlopen are waiting for it to finish.
|
||||
Use a new GL(dl_load_tls_lock) in pthread_create that is not taken
|
||||
around ctors in dlopen.
|
||||
|
||||
The new lock is also used in __tls_get_addr instead of GL(dl_load_lock).
|
||||
|
||||
The new lock is held in _dl_open_worker and _dl_close_worker around
|
||||
most of the logic before/after the init/fini routines. When init/fini
|
||||
routines are running then TLS is in a consistent, usable state.
|
||||
In _dl_open_worker the new lock requires catching and reraising dlopen
|
||||
failures that happen in the critical section.
|
||||
|
||||
The new lock is reinitialized in a fork child, to keep the existing
|
||||
behaviour and it is kept recursive in case malloc interposition or TLS
|
||||
access from signal handlers can retake it. It is not obvious if this
|
||||
is necessary or helps, but avoids changing the preexisting behaviour.
|
||||
|
||||
The new lock may be more appropriate for dl_iterate_phdr too than
|
||||
GL(dl_load_write_lock), since TLS state of an incompletely loaded
|
||||
module may be accessed. If the new lock can replace the old one,
|
||||
that can be a separate change.
|
||||
|
||||
Fixes bug 28357.
|
||||
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
---
|
||||
elf/dl-close.c | 6 ++
|
||||
elf/dl-open.c | 35 ++++++++-
|
||||
elf/dl-support.c | 7 ++
|
||||
elf/dl-tls.c | 16 ++---
|
||||
elf/rtld.c | 1 +
|
||||
sysdeps/nptl/fork.c | 3 +
|
||||
sysdeps/generic/ldsodefs.h | 9 ++-
|
||||
10 files changed, 235 insertions(+), 12 deletions(-)
|
||||
---
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=patch;h=024a7640ab9ecea80e527f4e4d7f7a1868e952c5]
|
||||
Comment: This patch is refreshed for glibc 2.31. In upstream glibc 2.34 multiple src files are shuffled, updated this patch as per the code present in glibc 2.31. Removed test case.
|
||||
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 93ff5c96e9..cfe0f1c0c9 100644
|
||||
--- a/elf/dl-close.c
|
||||
+++ b/elf/dl-close.c
|
||||
@@ -551,6 +551,9 @@
|
||||
size_t tls_free_end;
|
||||
tls_free_start = tls_free_end = NO_TLS_OFFSET;
|
||||
|
||||
+ /* Protects global and module specitic TLS state. */
|
||||
+ __rtld_lock_lock_recursive (GL(dl_load_tls_lock));
|
||||
+
|
||||
/* We modify the list of loaded objects. */
|
||||
__rtld_lock_lock_recursive (GL(dl_load_write_lock));
|
||||
|
||||
@@ -786,6 +789,9 @@
|
||||
GL(dl_tls_static_used) = tls_free_start;
|
||||
}
|
||||
|
||||
+ /* TLS is cleaned up for the unloaded modules. */
|
||||
+ __rtld_lock_unlock_recursive (GL(dl_load_tls_lock));
|
||||
+
|
||||
#ifdef SHARED
|
||||
/* Auditing checkpoint: we have deleted all objects. */
|
||||
if (__glibc_unlikely (do_audit))
|
||||
diff --git a/elf/dl-open.c b/elf/dl-open.c
|
||||
index 5295e931b0..6ea5dd2457 100644
|
||||
--- a/elf/dl-open.c
|
||||
+++ b/elf/dl-open.c
|
||||
@@ -57,6 +57,9 @@
|
||||
(non-negative). */
|
||||
unsigned int original_global_scope_pending_adds;
|
||||
|
||||
+ /* Set to true if the end of dl_open_worker_begin was reached. */
|
||||
+ bool worker_continue;
|
||||
+
|
||||
/* Original parameters to the program and the current environment. */
|
||||
int argc;
|
||||
char **argv;
|
||||
@@ -473,7 +473,7 @@
|
||||
}
|
||||
|
||||
static void
|
||||
-dl_open_worker (void *a)
|
||||
+dl_open_worker_begin (void *a)
|
||||
{
|
||||
struct dl_open_args *args = a;
|
||||
const char *file = args->file;
|
||||
@@ -747,6 +747,36 @@
|
||||
if (mode & RTLD_GLOBAL)
|
||||
add_to_global_resize (new);
|
||||
|
||||
+ args->worker_continue = true;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+dl_open_worker (void *a)
|
||||
+{
|
||||
+ struct dl_open_args *args = a;
|
||||
+
|
||||
+ args->worker_continue = false;
|
||||
+
|
||||
+ {
|
||||
+ /* Protects global and module specific TLS state. */
|
||||
+ __rtld_lock_lock_recursive (GL(dl_load_tls_lock));
|
||||
+
|
||||
+ struct dl_exception ex;
|
||||
+ int err = _dl_catch_exception (&ex, dl_open_worker_begin, args);
|
||||
+
|
||||
+ __rtld_lock_unlock_recursive (GL(dl_load_tls_lock));
|
||||
+
|
||||
+ if (__glibc_unlikely (ex.errstring != NULL))
|
||||
+ /* Reraise the error. */
|
||||
+ _dl_signal_exception (err, &ex, NULL);
|
||||
+ }
|
||||
+
|
||||
+ if (!args->worker_continue)
|
||||
+ return;
|
||||
+
|
||||
+ int mode = args->mode;
|
||||
+ struct link_map *new = args->map;
|
||||
+
|
||||
/* Run the initializer functions of new objects. Temporarily
|
||||
disable the exception handler, so that lazy binding failures are
|
||||
fatal. */
|
||||
diff --git a/elf/dl-support.c b/elf/dl-support.c
|
||||
index 02e2ed72f5..d99c1f1d62 100644
|
||||
--- a/elf/dl-support.c
|
||||
+++ b/elf/dl-support.c
|
||||
@@ -219,6 +219,13 @@
|
||||
list of loaded objects while an object is added to or removed from
|
||||
that list. */
|
||||
__rtld_lock_define_initialized_recursive (, _dl_load_write_lock)
|
||||
+/* This lock protects global and module specific TLS related data.
|
||||
+ E.g. it is held in dlopen and dlclose when GL(dl_tls_generation),
|
||||
+ GL(dl_tls_max_dtv_idx) or GL(dl_tls_dtv_slotinfo_list) are
|
||||
+ accessed and when TLS related relocations are processed for a
|
||||
+ module. It was introduced to keep pthread_create accessing TLS
|
||||
+ state that is being set up. */
|
||||
+__rtld_lock_define_initialized_recursive (, _dl_load_tls_lock)
|
||||
|
||||
|
||||
#ifdef HAVE_AUX_VECTOR
|
||||
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
|
||||
index d554ae4497..9260d2d696 100644
|
||||
--- a/elf/dl-tls.c
|
||||
+++ b/elf/dl-tls.c
|
||||
@@ -443,7 +443,7 @@
|
||||
size_t maxgen = 0;
|
||||
|
||||
/* Protects global dynamic TLS related state. */
|
||||
- __rtld_lock_lock_recursive (GL(dl_load_lock));
|
||||
+ __rtld_lock_lock_recursive (GL(dl_load_tls_lock));
|
||||
|
||||
/* Check if the current dtv is big enough. */
|
||||
if (dtv[-1].counter < GL(dl_tls_max_dtv_idx))
|
||||
@@ -517,7 +517,7 @@
|
||||
listp = listp->next;
|
||||
assert (listp != NULL);
|
||||
}
|
||||
- __rtld_lock_unlock_recursive (GL(dl_load_lock));
|
||||
+ __rtld_lock_unlock_recursive (GL(dl_load_tls_lock));
|
||||
|
||||
/* The DTV version is up-to-date now. */
|
||||
dtv[0].counter = maxgen;
|
||||
@@ -656,7 +656,7 @@
|
||||
|
||||
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)
|
||||
+ This code may be called during TLS access when GL(dl_load_tls_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
|
||||
@@ -778,11 +778,11 @@
|
||||
if (__glibc_unlikely (the_map->l_tls_offset
|
||||
!= FORCED_DYNAMIC_TLS_OFFSET))
|
||||
{
|
||||
- __rtld_lock_lock_recursive (GL(dl_load_lock));
|
||||
+ __rtld_lock_lock_recursive (GL(dl_load_tls_lock));
|
||||
if (__glibc_likely (the_map->l_tls_offset == NO_TLS_OFFSET))
|
||||
{
|
||||
the_map->l_tls_offset = FORCED_DYNAMIC_TLS_OFFSET;
|
||||
- __rtld_lock_unlock_recursive (GL(dl_load_lock));
|
||||
+ __rtld_lock_unlock_recursive (GL(dl_load_tls_lock));
|
||||
}
|
||||
else if (__glibc_likely (the_map->l_tls_offset
|
||||
!= FORCED_DYNAMIC_TLS_OFFSET))
|
||||
@@ -794,7 +794,7 @@
|
||||
#else
|
||||
# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
|
||||
#endif
|
||||
- __rtld_lock_unlock_recursive (GL(dl_load_lock));
|
||||
+ __rtld_lock_unlock_recursive (GL(dl_load_tls_lock));
|
||||
|
||||
dtv[GET_ADDR_MODULE].pointer.to_free = NULL;
|
||||
dtv[GET_ADDR_MODULE].pointer.val = p;
|
||||
@@ -802,7 +802,7 @@
|
||||
return (char *) p + GET_ADDR_OFFSET;
|
||||
}
|
||||
else
|
||||
- __rtld_lock_unlock_recursive (GL(dl_load_lock));
|
||||
+ __rtld_lock_unlock_recursive (GL(dl_load_tls_lock));
|
||||
}
|
||||
struct dtv_pointer result = allocate_and_init (the_map);
|
||||
dtv[GET_ADDR_MODULE].pointer = result;
|
||||
@@ -873,7 +873,7 @@
|
||||
return NULL;
|
||||
|
||||
dtv_t *dtv = THREAD_DTV ();
|
||||
- /* This may be called without holding the GL(dl_load_lock). Reading
|
||||
+ /* This may be called without holding the GL(dl_load_tls_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))
|
||||
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||
index 8d2bba3d43..9642eb9c92 100644
|
||||
--- a/elf/rtld.c
|
||||
+++ b/elf/rtld.c
|
||||
@@ -283,6 +283,7 @@
|
||||
#ifdef _LIBC_REENTRANT
|
||||
._dl_load_lock = _RTLD_LOCK_RECURSIVE_INITIALIZER,
|
||||
._dl_load_write_lock = _RTLD_LOCK_RECURSIVE_INITIALIZER,
|
||||
+ ._dl_load_tls_lock = _RTLD_LOCK_RECURSIVE_INITIALIZER,
|
||||
#endif
|
||||
._dl_nns = 1,
|
||||
._dl_ns =
|
||||
diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
|
||||
index c471f7b15f..021691b9b7 100644
|
||||
--- a/sysdeps/nptl/fork.c
|
||||
+++ b/sysdeps/nptl/fork.c
|
||||
@@ -125,6 +125,9 @@
|
||||
/* Reset the lock the dynamic loader uses to protect its data. */
|
||||
__rtld_lock_initialize (GL(dl_load_lock));
|
||||
|
||||
+ /* Reset the lock protecting dynamic TLS related data. */
|
||||
+ __rtld_lock_initialize (GL(dl_load_tls_lock));
|
||||
+
|
||||
/* Run the handlers registered for the child. */
|
||||
__run_fork_handlers (atfork_run_child, multiple_threads);
|
||||
}
|
||||
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
|
||||
index d49529da0d..9ec1511bb0 100644
|
||||
--- a/sysdeps/generic/ldsodefs.h
|
||||
+++ b/sysdeps/generic/ldsodefs.h
|
||||
@@ -369,6 +369,13 @@
|
||||
list of loaded objects while an object is added to or removed
|
||||
from that list. */
|
||||
__rtld_lock_define_recursive (EXTERN, _dl_load_write_lock)
|
||||
+ /* This lock protects global and module specific TLS related data.
|
||||
+ E.g. it is held in dlopen and dlclose when GL(dl_tls_generation),
|
||||
+ GL(dl_tls_max_dtv_idx) or GL(dl_tls_dtv_slotinfo_list) are
|
||||
+ accessed and when TLS related relocations are processed for a
|
||||
+ module. It was introduced to keep pthread_create accessing TLS
|
||||
+ state that is being set up. */
|
||||
+ __rtld_lock_define_recursive (EXTERN, _dl_load_tls_lock)
|
||||
|
||||
/* Incremented whenever something may have been added to dl_loaded. */
|
||||
EXTERN unsigned long long _dl_load_adds;
|
||||
@@ -1153,7 +1160,7 @@
|
||||
|
||||
/* Add module to slot information data. If DO_ADD is false, only the
|
||||
required memory is allocated. Must be called with GL
|
||||
- (dl_load_lock) acquired. If the function has already been called
|
||||
+ (dl_load_tls_lock) acquired. If the function has already been called
|
||||
for the link map L with !do_add, then this function will not raise
|
||||
an exception, otherwise it is possible that it encounters a memory
|
||||
allocation failure. */
|
||||
--
|
||||
2.27.0
|
||||
@@ -70,6 +70,14 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
|
||||
file://CVE-2021-33574_1.patch \
|
||||
file://CVE-2021-33574_2.patch \
|
||||
file://CVE-2021-38604.patch \
|
||||
file://0030-elf-Refactor_dl_update-slotinfo-to-avoid-use-after-free.patch \
|
||||
file://0031-elf-Fix-data-races-in-pthread_create-and-TLS-access-BZ-19329.patch \
|
||||
file://0032-elf-Use-relaxed-atomics-for-racy-accesses-BZ-19329.patch \
|
||||
file://0033-elf-Add-test-case-for-BZ-19329.patch \
|
||||
file://0034-elf-Fix-DTV-gap-reuse-logic-BZ-27135.patch \
|
||||
file://0035-x86_64-Avoid-lazy-relocation-of-tlsdesc-BZ-27137.patch \
|
||||
file://0036-i386-Avoid-lazy-relocation-of-tlsdesc-BZ-27137.patch \
|
||||
file://0037-Avoid-deadlock-between-pthread_create-and-ctors.patch \
|
||||
"
|
||||
S = "${WORKDIR}/git"
|
||||
B = "${WORKDIR}/build-${TARGET_SYS}"
|
||||
|
||||
@@ -24,7 +24,7 @@ IMAGE_FSTYPES = "wic.vmdk"
|
||||
|
||||
inherit core-image setuptools3
|
||||
|
||||
SRCREV ?= "38793eecdadd86343e1bc95281efa1f1ecba1876"
|
||||
SRCREV ?= "d752cbcbbeeea9adbcc9aa74def1761f34a9de54"
|
||||
SRC_URI = "git://git.yoctoproject.org/poky;branch=dunfell \
|
||||
file://Yocto_Build_Appliance.vmx \
|
||||
file://Yocto_Build_Appliance.vmxf \
|
||||
|
||||
@@ -17,7 +17,7 @@ python () {
|
||||
raise bb.parse.SkipRecipe("Skip recipe when cve-check class is not loaded.")
|
||||
}
|
||||
|
||||
python do_populate_cve_db() {
|
||||
python do_fetch() {
|
||||
"""
|
||||
Update NVD database with json data feed
|
||||
"""
|
||||
@@ -110,7 +110,9 @@ python do_populate_cve_db() {
|
||||
conn.close()
|
||||
}
|
||||
|
||||
do_populate_cve_db[lockfiles] += "${CVE_CHECK_DB_FILE_LOCK}"
|
||||
do_fetch[lockfiles] += "${CVE_CHECK_DB_FILE_LOCK}"
|
||||
do_fetch[file-checksums] = ""
|
||||
do_fetch[vardeps] = ""
|
||||
|
||||
def initialize_db(c):
|
||||
c.execute("CREATE TABLE IF NOT EXISTS META (YEAR INTEGER UNIQUE, DATE TEXT)")
|
||||
@@ -217,7 +219,6 @@ def update_db(c, jsondata):
|
||||
parse_node_and_insert(c, config, cveId)
|
||||
|
||||
|
||||
addtask do_populate_cve_db before do_fetch
|
||||
do_populate_cve_db[nostamp] = "1"
|
||||
do_fetch[nostamp] = "1"
|
||||
|
||||
EXCLUDE_FROM_WORLD = "1"
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
From 988ca784d4840c87509e770a21d5d22105af8668 Mon Sep 17 00:00:00 2001
|
||||
From: Mingli Yu <mingli.yu@windriver.com>
|
||||
Date: Fri, 5 Nov 2021 11:18:07 +0800
|
||||
Subject: [PATCH] bootchartd.in: make sure only one bootchartd process
|
||||
|
||||
When boot with "init=/sbin/bootchartd" as below:
|
||||
# runqemu qemux86 bootparams="init=/sbin/bootchartd"
|
||||
|
||||
There are two bootchartd process after boot [1].
|
||||
# ps -ef | grep bootchart
|
||||
root 101 1 0 03:27 ? 00:00:00 /bin/sh /sbin/bootchartd
|
||||
root 103 101 8 03:27 ? 00:00:02 /lib64/bootchart/bootchart-collector 50
|
||||
root 106 1 0 03:27 ? 00:00:00 /bin/sh /sbin/bootchartd
|
||||
root 792 106 0 03:27 ? 00:00:00 /lib64/bootchart/bootchart-collector --usleep 1000000
|
||||
root 794 725 0 03:27 ttyS0 00:00:00 grep bootchart
|
||||
|
||||
# /sbin/bootchartd stop
|
||||
[bootchart] bootchart-collector started as pid 596 with 2 args:
|
||||
[bootchart] '--dump'
|
||||
[bootchart] '/tmp/bootchart.3lXpVDAq3v'
|
||||
[bootchart] Extracting profile data from pid 204
|
||||
[bootchart] map 0xbed9a000 -> 0xbedbb000 size: 132k from 'bed9a000' 'bedbb000'
|
||||
[bootchart] read 135168 bytes of 135168
|
||||
[bootchart] reading 150 chunks (of 150) ...
|
||||
[bootchart] wrote 18760 kbB
|
||||
[bootchart] bootchart-collector pid: 596 unmounted proc / clean exit
|
||||
|
||||
But there still one process exist after the above stop command finish.
|
||||
# ps -ef | grep bootchartd
|
||||
root 202 1 0 09:09 ? 00:00:00 /bin/sh /sbin/bootchartd
|
||||
root 629 516 0 09:10 ? 00:00:00 grep bootchartd
|
||||
|
||||
Remove the wait_boot which used to wait the boot process to finish to
|
||||
make sure only one bootchartd process and meanwhile we don't need the
|
||||
wait_boot logic because we either use "/sbin/bootchartd stop" to stop
|
||||
the bootchartd manually or install package bootchartd-stop-initscript
|
||||
altogether with bootchart2 to stop bootchartd automatically after boot.
|
||||
|
||||
After patch:
|
||||
# ps -ef | grep bootchart
|
||||
root 101 1 0 03:36 ? 00:00:00 /bin/sh /sbin/bootchartd
|
||||
root 103 101 6 03:36 ? 00:00:04 /lib64/bootchart/bootchart-collector 50
|
||||
root 596 592 0 03:37 ttyS0 00:00:00 grep bootchart
|
||||
|
||||
[1] https://github.com/xrmx/bootchart/issues/94
|
||||
|
||||
Upstream-Status: Submitted [https://github.com/xrmx/bootchart/pull/95]
|
||||
|
||||
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
|
||||
---
|
||||
bootchartd.in | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/bootchartd.in b/bootchartd.in
|
||||
index 7979ef9..f0e466d 100755
|
||||
--- a/bootchartd.in
|
||||
+++ b/bootchartd.in
|
||||
@@ -183,7 +183,6 @@ if [ $$ -eq 1 ]; then
|
||||
else # running inside the main system
|
||||
echo "bootchart: no initrd used; starting"
|
||||
start &
|
||||
- wait_boot &
|
||||
# wait a little, until the collector is going, before allowing
|
||||
# the rest of the system to charge ahead, so we catch it
|
||||
$USLEEP 250000
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -94,6 +94,7 @@ SRC_URI = "git://github.com/xrmx/bootchart.git;branch=master;protocol=https \
|
||||
file://bootchartd_stop.sh \
|
||||
file://0001-collector-Allocate-space-on-heap-for-chunks.patch \
|
||||
file://0001-bootchart2-support-usrmerge.patch \
|
||||
file://0001-bootchartd.in-make-sure-only-one-bootchartd-process.patch \
|
||||
"
|
||||
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
@@ -120,6 +120,7 @@ drd/tests/tc19_shadowmem
|
||||
drd/tests/tc21_pthonce
|
||||
drd/tests/tc22_exit_w_lock
|
||||
drd/tests/tc23_bogus_condwait
|
||||
gdbserver_tests/hginfo
|
||||
helgrind/tests/annotate_rwlock
|
||||
helgrind/tests/annotate_smart_pointer
|
||||
helgrind/tests/bar_bad
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
drd/tests/bar_bad
|
||||
drd/tests/bar_bad_xml
|
||||
gdbserver_tests/hginfo
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
From 44d2d6095246124c024230f89c1029794491839f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||
Date: Fri, 30 Oct 2020 15:10:35 +0100
|
||||
Subject: [PATCH] Properly detect and compare Python version 3.10+ (#151)
|
||||
|
||||
Upstream commit: https://github.com/asciidoc-py/asciidoc-py/commit/44d2d6095246124c024230f89c1029794491839f
|
||||
|
||||
Slightly modified to cleanly apply to asciidoc 8.6.9:
|
||||
- VERSION and MIN_PYTHON_VERSION changed to reflect values in 8.6.9
|
||||
- line numbers corrected to eliminate offset warnings
|
||||
|
||||
Upstream-Status: Backport
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
asciidoc.py | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/asciidoc.py b/asciidoc.py
|
||||
index f960e7d8..42868c4b 100755
|
||||
--- a/asciidoc.py
|
||||
+++ b/asciidoc.py
|
||||
@@ -30,7 +30,7 @@
|
||||
# Used by asciidocapi.py #
|
||||
VERSION = '8.6.10' # See CHANGELOG file for version history.
|
||||
|
||||
-MIN_PYTHON_VERSION = '3.4' # Require this version of Python or better.
|
||||
+MIN_PYTHON_VERSION = (3, 4) # Require this version of Python or better.
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Program constants.
|
||||
@@ -4704,8 +4704,8 @@ def init(self, cmd):
|
||||
directory.
|
||||
cmd is the asciidoc command or asciidoc.py path.
|
||||
"""
|
||||
- if float(sys.version[:3]) < float(MIN_PYTHON_VERSION):
|
||||
- message.stderr('FAILED: Python %s or better required' % MIN_PYTHON_VERSION)
|
||||
+ if sys.version_info[:2] < MIN_PYTHON_VERSION:
|
||||
+ message.stderr('FAILED: Python %d.%d or better required' % MIN_PYTHON_VERSION)
|
||||
sys.exit(1)
|
||||
if not os.path.exists(cmd):
|
||||
message.stderr('FAILED: Missing asciidoc command: %s' % cmd)
|
||||
@@ -9,7 +9,8 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \
|
||||
file://COPYRIGHT;md5=029ad5428ba5efa20176b396222d4069"
|
||||
|
||||
SRC_URI = "git://github.com/asciidoc/asciidoc-py3;protocol=https;branch=main \
|
||||
file://auto-catalogs.patch"
|
||||
file://auto-catalogs.patch \
|
||||
file://detect-python-version.patch"
|
||||
SRCREV = "618f6e6f6b558ed1e5f2588cd60a5a6b4f881ca0"
|
||||
PV .= "+py3-git${SRCPV}"
|
||||
|
||||
|
||||
@@ -23,15 +23,6 @@ add_openvt_argument() {
|
||||
openvt_args="$openvt_args $1"
|
||||
}
|
||||
|
||||
## Add module to --modules argument
|
||||
add_weston_module() {
|
||||
if [ -z "${weston_modules}" ]; then
|
||||
weston_modules="--modules "
|
||||
fi;
|
||||
weston_modules="${weston_modules}${1},"
|
||||
}
|
||||
|
||||
|
||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||
echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet."
|
||||
exit 1
|
||||
@@ -74,9 +65,6 @@ if [ -d "$modules_dir" ]; then
|
||||
# process module
|
||||
. $m
|
||||
done
|
||||
if [ -n "${weston_modules}" ]; then
|
||||
add_weston_argument "${weston_modules} "
|
||||
fi;
|
||||
fi
|
||||
|
||||
if test -z "$XDG_RUNTIME_DIR"; then
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# SPDX-FileCopyrightText: Huawei Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
[Unit]
|
||||
Description=Weston Wayland Compositor
|
||||
RequiresMountsFor=/run
|
||||
@@ -9,8 +5,6 @@ Conflicts=plymouth-quit.service
|
||||
After=systemd-user-sessions.service plymouth-quit-wait.service
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
NotifyAccess=all
|
||||
User=%i
|
||||
PAMName=login
|
||||
EnvironmentFile=-/etc/default/weston
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
From 5c74a0640e873694bf60a88eceb21f664cb4b8f7 Mon Sep 17 00:00:00 2001
|
||||
From: Marius Vlad <marius.vlad@collabora.com>
|
||||
Date: Fri, 5 Mar 2021 20:03:49 +0200
|
||||
Subject: [PATCH 2/5] desktop-shell: Remove no-op de-activation of the xdg
|
||||
top-level surface
|
||||
|
||||
The shsurf is calloc'ed so the surface count is always 0. Not only
|
||||
that but the surface is not set as active by default, so there's no
|
||||
need to de-activate it.
|
||||
|
||||
Upstream-Status: Backport [05bef4c18a3e82376a46a4a28d978389c4c0fd0f]
|
||||
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
|
||||
---
|
||||
desktop-shell/shell.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
|
||||
index 442a625f..3791be25 100644
|
||||
--- a/desktop-shell/shell.c
|
||||
+++ b/desktop-shell/shell.c
|
||||
@@ -2427,8 +2427,6 @@ desktop_surface_added(struct weston_desktop_surface *desktop_surface,
|
||||
wl_list_init(&shsurf->children_link);
|
||||
|
||||
weston_desktop_surface_set_user_data(desktop_surface, shsurf);
|
||||
- weston_desktop_surface_set_activated(desktop_surface,
|
||||
- shsurf->focus_count > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
From edb31c456ae3da7ffffefb668a37ab88075c4b67 Mon Sep 17 00:00:00 2001
|
||||
From: Marius Vlad <marius.vlad@collabora.com>
|
||||
Date: Fri, 5 Mar 2021 21:40:22 +0200
|
||||
Subject: [PATCH 3/5] desktop-shell: Rename gain/lose keyboard focus to
|
||||
activate/de-activate
|
||||
|
||||
This way it better reflects that it handles activation rather that input
|
||||
focus.
|
||||
|
||||
Upstream-Status: Backport [ab39e1d76d4f6715cb300bc37f5c2a0e2d426208]
|
||||
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
|
||||
---
|
||||
desktop-shell/shell.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
|
||||
index 3791be25..c4669f11 100644
|
||||
--- a/desktop-shell/shell.c
|
||||
+++ b/desktop-shell/shell.c
|
||||
@@ -1869,14 +1869,14 @@ handle_pointer_focus(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
static void
|
||||
-shell_surface_lose_keyboard_focus(struct shell_surface *shsurf)
|
||||
+shell_surface_deactivate(struct shell_surface *shsurf)
|
||||
{
|
||||
if (--shsurf->focus_count == 0)
|
||||
weston_desktop_surface_set_activated(shsurf->desktop_surface, false);
|
||||
}
|
||||
|
||||
static void
|
||||
-shell_surface_gain_keyboard_focus(struct shell_surface *shsurf)
|
||||
+shell_surface_activate(struct shell_surface *shsurf)
|
||||
{
|
||||
if (shsurf->focus_count++ == 0)
|
||||
weston_desktop_surface_set_activated(shsurf->desktop_surface, true);
|
||||
@@ -1891,7 +1891,7 @@ handle_keyboard_focus(struct wl_listener *listener, void *data)
|
||||
if (seat->focused_surface) {
|
||||
struct shell_surface *shsurf = get_shell_surface(seat->focused_surface);
|
||||
if (shsurf)
|
||||
- shell_surface_lose_keyboard_focus(shsurf);
|
||||
+ shell_surface_deactivate(shsurf);
|
||||
}
|
||||
|
||||
seat->focused_surface = weston_surface_get_main_surface(keyboard->focus);
|
||||
@@ -1899,7 +1899,7 @@ handle_keyboard_focus(struct wl_listener *listener, void *data)
|
||||
if (seat->focused_surface) {
|
||||
struct shell_surface *shsurf = get_shell_surface(seat->focused_surface);
|
||||
if (shsurf)
|
||||
- shell_surface_gain_keyboard_focus(shsurf);
|
||||
+ shell_surface_activate(shsurf);
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
From 899ad5a6a8a92f2c10e0694a45c982b7d878aed6 Mon Sep 17 00:00:00 2001
|
||||
From: Marius Vlad <marius.vlad@collabora.com>
|
||||
Date: Fri, 5 Mar 2021 21:44:26 +0200
|
||||
Subject: [PATCH 4/5] desktop-shell: Embed keyboard focus handle code when
|
||||
activating
|
||||
|
||||
We shouldn't be constrained by having a keyboard plugged-in, so avoid
|
||||
activating/de-activating the window/surface in the keyboard focus
|
||||
handler and embed it straight into the window activation part.
|
||||
|
||||
Upstream-Status: Backport [f12697bb3e4c6eb85437ed905e7de44ae2a0ba69]
|
||||
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
|
||||
---
|
||||
desktop-shell/shell.c | 41 +++++++++++++++++++++++++----------------
|
||||
1 file changed, 25 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
|
||||
index c4669f11..c6a4fe91 100644
|
||||
--- a/desktop-shell/shell.c
|
||||
+++ b/desktop-shell/shell.c
|
||||
@@ -1885,22 +1885,7 @@ shell_surface_activate(struct shell_surface *shsurf)
|
||||
static void
|
||||
handle_keyboard_focus(struct wl_listener *listener, void *data)
|
||||
{
|
||||
- struct weston_keyboard *keyboard = data;
|
||||
- struct shell_seat *seat = get_shell_seat(keyboard->seat);
|
||||
-
|
||||
- if (seat->focused_surface) {
|
||||
- struct shell_surface *shsurf = get_shell_surface(seat->focused_surface);
|
||||
- if (shsurf)
|
||||
- shell_surface_deactivate(shsurf);
|
||||
- }
|
||||
-
|
||||
- seat->focused_surface = weston_surface_get_main_surface(keyboard->focus);
|
||||
-
|
||||
- if (seat->focused_surface) {
|
||||
- struct shell_surface *shsurf = get_shell_surface(seat->focused_surface);
|
||||
- if (shsurf)
|
||||
- shell_surface_activate(shsurf);
|
||||
- }
|
||||
+ /* FIXME: To be removed later. */
|
||||
}
|
||||
|
||||
/* The surface will be inserted into the list immediately after the link
|
||||
@@ -2438,6 +2423,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
|
||||
struct shell_surface *shsurf_child, *tmp;
|
||||
struct weston_surface *surface =
|
||||
weston_desktop_surface_get_surface(desktop_surface);
|
||||
+ struct weston_seat *seat;
|
||||
|
||||
if (!shsurf)
|
||||
return;
|
||||
@@ -2448,6 +2434,18 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
|
||||
}
|
||||
wl_list_remove(&shsurf->children_link);
|
||||
|
||||
+ wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {
|
||||
+ struct shell_seat *shseat = get_shell_seat(seat);
|
||||
+ /* activate() controls the focused surface activation and
|
||||
+ * removal of a surface requires invalidating the
|
||||
+ * focused_surface to avoid activate() use a stale (and just
|
||||
+ * removed) surface when attempting to de-activate it. It will
|
||||
+ * also update the focused_surface once it has a chance to run.
|
||||
+ */
|
||||
+ if (surface == shseat->focused_surface)
|
||||
+ shseat->focused_surface = NULL;
|
||||
+ }
|
||||
+
|
||||
wl_signal_emit(&shsurf->destroy_signal, shsurf);
|
||||
|
||||
if (shsurf->fullscreen.black_view)
|
||||
@@ -3836,6 +3834,7 @@ activate(struct desktop_shell *shell, struct weston_view *view,
|
||||
struct workspace *ws;
|
||||
struct weston_surface *old_es;
|
||||
struct shell_surface *shsurf, *shsurf_child;
|
||||
+ struct shell_seat *shseat = get_shell_seat(seat);
|
||||
|
||||
main_surface = weston_surface_get_main_surface(es);
|
||||
shsurf = get_shell_surface(main_surface);
|
||||
@@ -3855,6 +3854,16 @@ activate(struct desktop_shell *shell, struct weston_view *view,
|
||||
|
||||
weston_view_activate(view, seat, flags);
|
||||
|
||||
+ if (shseat->focused_surface) {
|
||||
+ struct shell_surface *current_focus =
|
||||
+ get_shell_surface(shseat->focused_surface);
|
||||
+ assert(current_focus);
|
||||
+ shell_surface_deactivate(current_focus);
|
||||
+ }
|
||||
+
|
||||
+ shseat->focused_surface = main_surface;
|
||||
+ shell_surface_activate(shsurf);
|
||||
+
|
||||
state = ensure_focus_state(shell, seat);
|
||||
if (state == NULL)
|
||||
return;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-FileCopyrightText: Huawei Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
||||
if [[ -x "/usr/lib/weston/systemd-notify.so" ]]; then
|
||||
add_weston_module "systemd-notify.so"
|
||||
fi
|
||||
@@ -2,5 +2,6 @@
|
||||
|
||||
if type Xwayland >/dev/null 2>/dev/null; then
|
||||
mkdir -p /tmp/.X11-unix
|
||||
add_weston_module "xwayland.so"
|
||||
|
||||
add_weston_argument "--modules=xwayland.so"
|
||||
fi
|
||||
|
||||
@@ -5,13 +5,14 @@ LICENSE = "MIT"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=d79ee9e66bb0f95d3386a7acae780b70 \
|
||||
file://libweston/compositor.c;endline=27;md5=6c53bbbd99273f4f7c4affa855c33c0a"
|
||||
|
||||
|
||||
SRC_URI = "https://wayland.freedesktop.org/releases/${BPN}-${PV}.tar.xz \
|
||||
file://weston.png \
|
||||
file://weston.desktop \
|
||||
file://systemd-notify.weston-start \
|
||||
file://xwayland.weston-start \
|
||||
file://0001-weston-launch-Provide-a-default-version-that-doesn-t.patch \
|
||||
file://0002-desktop-shell-Remove-no-op-de-activation-of-the-xdg-.patch \
|
||||
file://0003-desktop-shell-Rename-gain-lose-keyboard-focus-to-act.patch \
|
||||
file://0004-desktop-shell-Embed-keyboard-focus-handle-code-when-.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "53e4810d852df0601d01fd986a5b22b3"
|
||||
SRC_URI[sha256sum] = "7518b49b2eaa1c3091f24671bdcc124fd49fc8f1af51161927afa4329c027848"
|
||||
@@ -103,10 +104,6 @@ do_install_append() {
|
||||
install -Dm 644 ${WORKDIR}/xwayland.weston-start ${D}${datadir}/weston-start/xwayland
|
||||
fi
|
||||
|
||||
if [ "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'yes', 'no', d)}" = "yes" ]; then
|
||||
install -Dm 644 ${WORKDIR}/systemd-notify.weston-start ${D}${datadir}/weston-start/systemd-notify
|
||||
fi
|
||||
|
||||
if [ "${@bb.utils.contains('PACKAGECONFIG', 'launch', 'yes', 'no', d)}" = "yes" ]; then
|
||||
chmod u+s ${D}${bindir}/weston-launch
|
||||
fi
|
||||
|
||||
@@ -18,7 +18,15 @@ INC_PR = "r8"
|
||||
XORG_PN = "xorg-server"
|
||||
SRC_URI = "${XORG_MIRROR}/individual/xserver/${XORG_PN}-${PV}.tar.bz2"
|
||||
|
||||
CVE_PRODUCT = "xorg-server"
|
||||
CVE_PRODUCT = "xorg-server x_server"
|
||||
# This is specific to Debian's xserver-wrapper.c
|
||||
CVE_CHECK_WHITELIST += "CVE-2011-4613"
|
||||
# As per upstream, exploiting this flaw is non-trivial and it requires exact
|
||||
# timing on the behalf of the attacker. Many graphical applications exit if their
|
||||
# connection to the X server is lost, so a typical desktop session is either
|
||||
# impossible or difficult to exploit. There is currently no upstream patch
|
||||
# available for this flaw.
|
||||
CVE_CHECK_WHITELIST += "CVE-2020-25697"
|
||||
|
||||
S = "${WORKDIR}/${XORG_PN}-${PV}"
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# dt-doc-validate wrapper to allow kernel dt-validation to pass
|
||||
#
|
||||
# Copyright (C) 2021 Bruce Ashfield <bruce.ashfield@gmail.com>
|
||||
# License: MIT (see COPYING.MIT at the root of the repository for terms)
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
--version)
|
||||
echo "v2021.10"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# TBD: left for future consideration
|
||||
# exec dt-doc-validate.real "$@"
|
||||
|
||||
# we always succeed
|
||||
exit 0
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# dt-mk-schema wrapper to allow kernel dt-validation to pass
|
||||
#
|
||||
# Copyright (C) 2021 Bruce Ashfield <bruce.ashfield@gmail.com>
|
||||
# License: MIT (see COPYING.MIT at the root of the repository for terms)
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
--version)
|
||||
echo "v2021.10"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# TBD: left for future consideration
|
||||
# exec dt-mk-schema.real "$@"
|
||||
|
||||
# we always succeed
|
||||
exit 0
|
||||
|
||||
20
meta/recipes-kernel/dtc/python3-dtschema-wrapper/dt-validate
Normal file
20
meta/recipes-kernel/dtc/python3-dtschema-wrapper/dt-validate
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# dt-validate wrapper to allow kernel dt-validation to pass
|
||||
#
|
||||
# Copyright (C) 2021 Bruce Ashfield <bruce.ashfield@gmail.com>
|
||||
# License: MIT (see COPYING.MIT at the root of the repository for terms)
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
--version)
|
||||
echo "v2021.10"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# TBD: left for future consideration
|
||||
# exec dt-validate.real "$@"
|
||||
|
||||
# we always succeed
|
||||
exit 0
|
||||
|
||||
17
meta/recipes-kernel/dtc/python3-dtschema-wrapper_2021.10.bb
Normal file
17
meta/recipes-kernel/dtc/python3-dtschema-wrapper_2021.10.bb
Normal file
@@ -0,0 +1,17 @@
|
||||
DESCRIPTION = "Wrapper for tooling for devicetree validation using YAML and jsonschema"
|
||||
HOMEPAGE = "https://yoctoproject.org"
|
||||
LICENSE = "MIT"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
|
||||
|
||||
SRC_URI = "file://dt-doc-validate \
|
||||
file://dt-mk-schema \
|
||||
file://dt-validate"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${bindir}/
|
||||
install -m 755 ${WORKDIR}/dt-doc-validate ${D}${bindir}/
|
||||
install -m 755 ${WORKDIR}/dt-mk-schema ${D}${bindir}/
|
||||
install -m 755 ${WORKDIR}/dt-validate ${D}${bindir}/
|
||||
}
|
||||
|
||||
BBCLASSEXTEND = "native nativesdk"
|
||||
@@ -132,7 +132,7 @@ LIC_FILES_CHKSUM = "file://LICENCE.Abilis;md5=b5ee3f410780e56711ad48eadc22b8bc \
|
||||
file://LICENCE.xc4000;md5=0ff51d2dc49fce04814c9155081092f0 \
|
||||
file://LICENCE.xc5000;md5=1e170c13175323c32c7f4d0998d53f66 \
|
||||
file://LICENCE.xc5000c;md5=12b02efa3049db65d524aeb418dd87ca \
|
||||
file://WHENCE;md5=d627873bd934d7c52b2c8191304a8eb7 \
|
||||
file://WHENCE;md5=79f477f9d53eedee5a65b45193785963 \
|
||||
"
|
||||
|
||||
# These are not common licenses, set NO_GENERIC_LICENSE for them
|
||||
@@ -205,7 +205,7 @@ PE = "1"
|
||||
|
||||
SRC_URI = "${KERNELORG_MIRROR}/linux/kernel/firmware/${BPN}-${PV}.tar.xz"
|
||||
|
||||
SRC_URI[sha256sum] = "bc2657dd8eb82386a9a7ec6df9ccf31c32c7e9073c05d37786c1edc273f9440a"
|
||||
SRC_URI[sha256sum] = "eeddb4e6bef31fd1a3757f12ccc324929bbad97855c0b9ec5ed780f74de1837d"
|
||||
|
||||
inherit allarch
|
||||
|
||||
@@ -11,13 +11,13 @@ python () {
|
||||
raise bb.parse.SkipRecipe("Set PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
|
||||
}
|
||||
|
||||
SRCREV_machine ?= "1a91fd560dcf8fa9e49fc2f17cb37483201a2b89"
|
||||
SRCREV_meta ?= "db8bfc3a107db2a059fb8efa442f7daa17e8d55c"
|
||||
SRCREV_machine ?= "e92d76afe6d8592917c0e7b948912c085e661df2"
|
||||
SRCREV_meta ?= "98cce1c95fcc9a26965cbc5f038fd71d53c387c8"
|
||||
|
||||
SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;branch=${KBRANCH};name=machine \
|
||||
git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.4;destsuffix=${KMETA}"
|
||||
|
||||
LINUX_VERSION ?= "5.4.158"
|
||||
LINUX_VERSION ?= "5.4.172"
|
||||
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ KCONFIG_MODE = "--allnoconfig"
|
||||
|
||||
require recipes-kernel/linux/linux-yocto.inc
|
||||
|
||||
LINUX_VERSION ?= "5.4.158"
|
||||
LINUX_VERSION ?= "5.4.172"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"
|
||||
|
||||
DEPENDS += "${@bb.utils.contains('ARCH', 'x86', 'elfutils-native', '', d)}"
|
||||
@@ -15,9 +15,9 @@ DEPENDS += "openssl-native util-linux-native"
|
||||
KMETA = "kernel-meta"
|
||||
KCONF_BSP_AUDIT_LEVEL = "2"
|
||||
|
||||
SRCREV_machine_qemuarm ?= "9b7cd001c33ea463bbb23fda6a79900ffc88c484"
|
||||
SRCREV_machine ?= "80849cd7ef3a77895f8651cec85648578bef9135"
|
||||
SRCREV_meta ?= "db8bfc3a107db2a059fb8efa442f7daa17e8d55c"
|
||||
SRCREV_machine_qemuarm ?= "10b4756eee78aa43ff9ed64da700ec6e8d97ff22"
|
||||
SRCREV_machine ?= "6ab93fdc53b64e146e4f16363375c1beb37b82e4"
|
||||
SRCREV_meta ?= "98cce1c95fcc9a26965cbc5f038fd71d53c387c8"
|
||||
|
||||
PV = "${LINUX_VERSION}+git${SRCPV}"
|
||||
|
||||
|
||||
@@ -12,16 +12,16 @@ KBRANCH_qemux86 ?= "v5.4/standard/base"
|
||||
KBRANCH_qemux86-64 ?= "v5.4/standard/base"
|
||||
KBRANCH_qemumips64 ?= "v5.4/standard/mti-malta64"
|
||||
|
||||
SRCREV_machine_qemuarm ?= "414c50525aea1ec953cca6d050d5c23db04de269"
|
||||
SRCREV_machine_qemuarm64 ?= "ba5e3380aa8a3789907c031beac2ce81d1eb5d50"
|
||||
SRCREV_machine_qemumips ?= "177841cfef0bd71b7b4f0e2e8e2ea3100ee4ea7a"
|
||||
SRCREV_machine_qemuppc ?= "c3b4b69caef59344d4a59a2327f9f0130db9ccbe"
|
||||
SRCREV_machine_qemuriscv64 ?= "76404f1ae59698b6a446dba29c885ca78c69c330"
|
||||
SRCREV_machine_qemux86 ?= "76404f1ae59698b6a446dba29c885ca78c69c330"
|
||||
SRCREV_machine_qemux86-64 ?= "76404f1ae59698b6a446dba29c885ca78c69c330"
|
||||
SRCREV_machine_qemumips64 ?= "75a3c9aeedd5a8070079d96d0301a303ca3351a8"
|
||||
SRCREV_machine ?= "76404f1ae59698b6a446dba29c885ca78c69c330"
|
||||
SRCREV_meta ?= "db8bfc3a107db2a059fb8efa442f7daa17e8d55c"
|
||||
SRCREV_machine_qemuarm ?= "8de1da3dc354dedef2e435e694eec6d6e72c9822"
|
||||
SRCREV_machine_qemuarm64 ?= "eed7c0a64f3a7a91a130bc2e507304dc8b446a31"
|
||||
SRCREV_machine_qemumips ?= "996a9660e4fab70db5cecec9c831141cd03c3d36"
|
||||
SRCREV_machine_qemuppc ?= "0197cf5754b1bd4eb035c342af9cc27e8c3339ca"
|
||||
SRCREV_machine_qemuriscv64 ?= "c6b015510134942076c0e111e56357656acf3dd5"
|
||||
SRCREV_machine_qemux86 ?= "c6b015510134942076c0e111e56357656acf3dd5"
|
||||
SRCREV_machine_qemux86-64 ?= "c6b015510134942076c0e111e56357656acf3dd5"
|
||||
SRCREV_machine_qemumips64 ?= "fe2769a7c268ed224ec70fd2aaab850e4eef70dc"
|
||||
SRCREV_machine ?= "c6b015510134942076c0e111e56357656acf3dd5"
|
||||
SRCREV_meta ?= "98cce1c95fcc9a26965cbc5f038fd71d53c387c8"
|
||||
|
||||
# remap qemuarm to qemuarma15 for the 5.4 kernel
|
||||
# KMACHINE_qemuarm ?= "qemuarma15"
|
||||
@@ -30,7 +30,7 @@ SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRA
|
||||
git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.4;destsuffix=${KMETA}"
|
||||
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"
|
||||
LINUX_VERSION ?= "5.4.158"
|
||||
LINUX_VERSION ?= "5.4.172"
|
||||
|
||||
DEPENDS += "${@bb.utils.contains('ARCH', 'x86', 'elfutils-native', '', d)}"
|
||||
DEPENDS += "openssl-native util-linux-native"
|
||||
|
||||
@@ -10,7 +10,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=01d7fc4496aacf37d90df90b90b0cac1 \
|
||||
file://gpl-2.0.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
|
||||
file://lgpl-2.1.txt;md5=0f0d71500e6a57fd24d825f33242b9ca"
|
||||
|
||||
DEPENDS = "liburcu popt libxml2 util-linux"
|
||||
DEPENDS = "liburcu popt libxml2 util-linux bison-native"
|
||||
RDEPENDS_${PN} = "libgcc"
|
||||
RDEPENDS_${PN}-ptest += "make perl bash gawk babeltrace procps perl-module-overloading coreutils util-linux kmod lttng-modules sed python3-core"
|
||||
RDEPENDS_${PN}-ptest_append_libc-glibc = " glibc-utils"
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
From 1db36347d05d88835519368442e9aa89c64091ad Mon Sep 17 00:00:00 2001
|
||||
From: Seungha Yang <seungha@centricular.com>
|
||||
Date: Tue, 15 Sep 2020 00:54:58 +0900
|
||||
Subject: [PATCH] tests: seek: Don't use too strict timeout for validation
|
||||
|
||||
Expected segment-done message might not be seen within expected
|
||||
time if system is not powerful enough.
|
||||
|
||||
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/625>
|
||||
|
||||
Upstream-Status: Backport [https://cgit.freedesktop.org/gstreamer/gstreamer/commit?id=f44312ae5d831438fcf8041162079c65321c588c]
|
||||
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
|
||||
Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
|
||||
---
|
||||
tests/check/pipelines/seek.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/check/pipelines/seek.c b/tests/check/pipelines/seek.c
|
||||
index 28bb8846d..5f7447bc5 100644
|
||||
--- a/tests/check/pipelines/seek.c
|
||||
+++ b/tests/check/pipelines/seek.c
|
||||
@@ -521,7 +521,7 @@ GST_START_TEST (test_loopback_2)
|
||||
|
||||
GST_INFO ("wait for segment done message");
|
||||
|
||||
- msg = gst_bus_timed_pop_filtered (bus, (GstClockTime) 2 * GST_SECOND,
|
||||
+ msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
|
||||
GST_MESSAGE_SEGMENT_DONE | GST_MESSAGE_ERROR);
|
||||
fail_unless (msg, "no message within the timed window");
|
||||
fail_unless_equals_string (GST_MESSAGE_TYPE_NAME (msg), "segment-done");
|
||||
--
|
||||
2.29.2
|
||||
|
||||
@@ -22,6 +22,7 @@ SRC_URI = " \
|
||||
file://0003-meson-Add-valgrind-feature.patch \
|
||||
file://0004-meson-Add-option-for-installed-tests.patch \
|
||||
file://0005-bufferpool-only-resize-in-reset-when-maxsize-is-larger.patch \
|
||||
file://0006-tests-seek-Don-t-use-too-strict-timeout-for-validati.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "beecf6965a17fb17fa3b262fd36df70a"
|
||||
SRC_URI[sha256sum] = "692f037968e454e508b0f71d9674e2e26c78475021407fcf8193b1c7e59543c7"
|
||||
|
||||
30
meta/recipes-multimedia/speex/speex/CVE-2020-23903.patch
Normal file
30
meta/recipes-multimedia/speex/speex/CVE-2020-23903.patch
Normal file
@@ -0,0 +1,30 @@
|
||||
Backport patch to fix CVE-2020-23903.
|
||||
|
||||
CVE: CVE-2020-23903
|
||||
Upstream-Status: Backport [https://github.com/xiph/speex/commit/870ff84]
|
||||
|
||||
Signed-off-by: Kai Kang <kai.kang@windriver.com>
|
||||
|
||||
From 870ff845b32f314aec0036641ffe18aba4916887 Mon Sep 17 00:00:00 2001
|
||||
From: Tristan Matthews <tmatth@videolan.org>
|
||||
Date: Mon, 13 Jul 2020 23:25:03 -0400
|
||||
Subject: [PATCH] wav_io: guard against invalid channel numbers
|
||||
|
||||
Fixes #13
|
||||
---
|
||||
src/wav_io.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/wav_io.c b/src/wav_io.c
|
||||
index b5183015..09d62eb0 100644
|
||||
--- a/src/wav_io.c
|
||||
+++ b/src/wav_io.c
|
||||
@@ -111,7 +111,7 @@ int read_wav_header(FILE *file, int *rate, int *channels, int *format, spx_int32
|
||||
stmp = le_short(stmp);
|
||||
*channels = stmp;
|
||||
|
||||
- if (stmp>2)
|
||||
+ if (stmp>2 || stmp<1)
|
||||
{
|
||||
fprintf (stderr, "Only mono and (intensity) stereo supported\n");
|
||||
return -1;
|
||||
@@ -7,7 +7,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=314649d8ba9dd7045dfb6683f298d0a8 \
|
||||
file://include/speex/speex.h;beginline=1;endline=34;md5=ef8c8ea4f7198d71cf3509c6ed05ea50"
|
||||
DEPENDS = "libogg speexdsp"
|
||||
|
||||
SRC_URI = "http://downloads.xiph.org/releases/speex/speex-${PV}.tar.gz"
|
||||
SRC_URI = "http://downloads.xiph.org/releases/speex/speex-${PV}.tar.gz \
|
||||
file://CVE-2020-23903.patch \
|
||||
"
|
||||
UPSTREAM_CHECK_REGEX = "speex-(?P<pver>\d+(\.\d+)+)\.tar"
|
||||
|
||||
SRC_URI[md5sum] = "8ab7bb2589110dfaf0ed7fa7757dc49c"
|
||||
|
||||
@@ -10,7 +10,7 @@ SECTION = "devel"
|
||||
LICENSE = "BSD-3-Clause"
|
||||
LIC_FILES_CHKSUM = "file://LICENCE;md5=b1588d3bb4cb0e1f5a597d908f8c5b37"
|
||||
|
||||
SRC_URI = "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-${PV}/pcre2-${PV}.tar.bz2 \
|
||||
SRC_URI = "http://downloads.yoctoproject.org/mirror/sources/pcre2-${PV}.tar.bz2 \
|
||||
file://pcre-cross.patch \
|
||||
"
|
||||
|
||||
|
||||
43
meta/recipes-support/vim/files/CVE-2021-4069.patch
Normal file
43
meta/recipes-support/vim/files/CVE-2021-4069.patch
Normal file
@@ -0,0 +1,43 @@
|
||||
From cd2422ee2dab3f33b2dbd1271e17cdaf8762b6d1 Mon Sep 17 00:00:00 2001
|
||||
From: Minjae Kim <flowergom@gmail.com>
|
||||
Date: Fri, 17 Dec 2021 20:32:02 -0800
|
||||
Subject: [PATCH] using freed memory in open command
|
||||
|
||||
Problem: Using freed memory in open command.
|
||||
Solution: Make a copy of the current line.
|
||||
|
||||
Upstream-Status: Backported [https://github.com/vim/vim/commit/e031fe90cf2e375ce861ff5e5e281e4ad229ebb9]
|
||||
CVE: CVE-2021-4069
|
||||
Signed-off-by: Minjae Kim <flowergom@gmail.com>
|
||||
---
|
||||
src/ex_docmd.c | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
|
||||
index 59e245bee..ccd9e8bed 100644
|
||||
--- a/src/ex_docmd.c
|
||||
+++ b/src/ex_docmd.c
|
||||
@@ -6029,13 +6029,17 @@ ex_open(exarg_T *eap)
|
||||
regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0);
|
||||
if (regmatch.regprog != NULL)
|
||||
{
|
||||
+ // make a copy of the line, when searching for a mark it might be
|
||||
+ // flushed
|
||||
+ char_u *line = vim_strsave(ml_get_curline());
|
||||
+
|
||||
regmatch.rm_ic = p_ic;
|
||||
- p = ml_get_curline();
|
||||
- if (vim_regexec(®match, p, (colnr_T)0))
|
||||
- curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p);
|
||||
+ if (vim_regexec(®match, line, (colnr_T)0))
|
||||
+ curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - line);
|
||||
else
|
||||
emsg(_(e_nomatch));
|
||||
vim_regfree(regmatch.regprog);
|
||||
+ vim_free(line);
|
||||
}
|
||||
// Move to the NUL, ignore any other arguments.
|
||||
eap->arg += STRLEN(eap->arg);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -26,6 +26,7 @@ SRC_URI = "git://github.com/vim/vim.git;branch=master;protocol=https \
|
||||
file://0001-patch-8.2.3581-reading-character-past-end-of-line.patch \
|
||||
file://0002-patch-8.2.3582-reading-uninitialized-memory-when-giv.patch \
|
||||
file://0002-patch-8.2.3611-crash-when-using-CTRL-W-f-without-fin.patch \
|
||||
file://CVE-2021-4069.patch \
|
||||
"
|
||||
|
||||
SRCREV = "98056533b96b6b5d8849641de93185dd7bcadc44"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
# Ensure PythonGit is installed (buildhistory_analysis needs it)
|
||||
try:
|
||||
@@ -71,10 +70,6 @@ def main():
|
||||
parser = get_args_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
if LooseVersion(git.__version__) < '0.3.1':
|
||||
sys.stderr.write("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script\n")
|
||||
sys.exit(1)
|
||||
|
||||
if len(args.revisions) > 2:
|
||||
sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args.revisions[2:]))
|
||||
parser.print_help()
|
||||
|
||||
@@ -18,7 +18,8 @@ import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import importlib
|
||||
from importlib import machinery
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
|
||||
class KeepAliveStreamHandler(logging.StreamHandler):
|
||||
def __init__(self, keepalive=True, **kwargs):
|
||||
@@ -82,7 +83,9 @@ def load_plugins(logger, plugins, pluginpath):
|
||||
logger.debug('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
|
||||
|
||||
def plugin_name(filename):
|
||||
return os.path.splitext(os.path.basename(filename))[0]
|
||||
|
||||
@@ -19,10 +19,10 @@ import os
|
||||
import tempfile
|
||||
import json
|
||||
import subprocess
|
||||
import shutil
|
||||
import re
|
||||
|
||||
from collections import namedtuple, OrderedDict
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
from wic import WicError
|
||||
from wic.filemap import sparse_copy
|
||||
@@ -245,7 +245,7 @@ class Disk:
|
||||
for path in pathlist.split(':'):
|
||||
self.paths = "%s%s:%s" % (native_sysroot, path, self.paths)
|
||||
|
||||
self.parted = find_executable("parted", self.paths)
|
||||
self.parted = shutil.which("parted", path=self.paths)
|
||||
if not self.parted:
|
||||
raise WicError("Can't find executable parted")
|
||||
|
||||
@@ -283,7 +283,7 @@ class Disk:
|
||||
"resize2fs", "mkswap", "mkdosfs", "debugfs"):
|
||||
aname = "_%s" % name
|
||||
if aname not in self.__dict__:
|
||||
setattr(self, aname, find_executable(name, self.paths))
|
||||
setattr(self, aname, shutil.which(name, path=self.paths))
|
||||
if aname not in self.__dict__ or self.__dict__[aname] is None:
|
||||
raise WicError("Can't find executable '{}'".format(name))
|
||||
return self.__dict__[aname]
|
||||
|
||||
@@ -16,9 +16,9 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
from collections import defaultdict
|
||||
from distutils import spawn
|
||||
|
||||
from wic import WicError
|
||||
|
||||
@@ -46,7 +46,8 @@ NATIVE_RECIPES = {"bmaptool": "bmap-tools",
|
||||
"parted": "parted",
|
||||
"sfdisk": "util-linux",
|
||||
"sgdisk": "gptfdisk",
|
||||
"syslinux": "syslinux"
|
||||
"syslinux": "syslinux",
|
||||
"tar": "tar"
|
||||
}
|
||||
|
||||
def runtool(cmdln_or_args):
|
||||
@@ -113,6 +114,15 @@ def exec_cmd(cmd_and_args, as_shell=False):
|
||||
"""
|
||||
return _exec_cmd(cmd_and_args, as_shell)[1]
|
||||
|
||||
def find_executable(cmd, paths):
|
||||
recipe = cmd
|
||||
if recipe in NATIVE_RECIPES:
|
||||
recipe = NATIVE_RECIPES[recipe]
|
||||
provided = get_bitbake_var("ASSUME_PROVIDED")
|
||||
if provided and "%s-native" % recipe in provided:
|
||||
return True
|
||||
|
||||
return shutil.which(cmd, path=paths)
|
||||
|
||||
def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""):
|
||||
"""
|
||||
@@ -141,7 +151,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""):
|
||||
logger.debug("exec_native_cmd: %s", native_cmd_and_args)
|
||||
|
||||
# If the command isn't in the native sysroot say we failed.
|
||||
if spawn.find_executable(args[0], native_paths):
|
||||
if find_executable(args[0], native_paths):
|
||||
ret, out = _exec_cmd(native_cmd_and_args, True)
|
||||
else:
|
||||
ret = 127
|
||||
|
||||
@@ -9,9 +9,11 @@ __all__ = ['ImagerPlugin', 'SourcePlugin']
|
||||
|
||||
import os
|
||||
import logging
|
||||
import types
|
||||
|
||||
from collections import defaultdict
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import importlib
|
||||
import importlib.util
|
||||
|
||||
from wic import WicError
|
||||
from wic.misc import get_bitbake_var
|
||||
@@ -54,7 +56,9 @@ class PluginMgr:
|
||||
mname = fname[:-3]
|
||||
mpath = os.path.join(ppath, fname)
|
||||
logger.debug("loading plugin module %s", mpath)
|
||||
SourceFileLoader(mname, mpath).load_module()
|
||||
spec = importlib.util.spec_from_file_location(mname, mpath)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
return PLUGINS.get(ptype)
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ import sys
|
||||
import argparse
|
||||
import logging
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
from collections import namedtuple
|
||||
from distutils import spawn
|
||||
|
||||
# External modules
|
||||
scripts_path = os.path.dirname(os.path.realpath(__file__))
|
||||
@@ -47,7 +47,7 @@ if os.environ.get('SDKTARGETSYSROOT'):
|
||||
break
|
||||
sdkroot = os.path.dirname(sdkroot)
|
||||
|
||||
bitbake_exe = spawn.find_executable('bitbake')
|
||||
bitbake_exe = shutil.which('bitbake')
|
||||
if bitbake_exe:
|
||||
bitbake_path = scriptpath.add_bitbake_lib_path()
|
||||
import bb
|
||||
|
||||
Reference in New Issue
Block a user