mirror of
https://git.yoctoproject.org/poky
synced 2026-02-21 17:09:42 +01:00
Compare commits
69 Commits
yocto-3.1.
...
yocto-3.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f14992950e | ||
|
|
8a7fd5f633 | ||
|
|
65d3f419d4 | ||
|
|
41cd7b5e3b | ||
|
|
31766c908e | ||
|
|
a14b11c500 | ||
|
|
b82a9877d5 | ||
|
|
8fdcbd703b | ||
|
|
f62b028452 | ||
|
|
57e1d6d9a6 | ||
|
|
ef1323fbb7 | ||
|
|
0ab1adc2fc | ||
|
|
1a14b4f693 | ||
|
|
076d50da2e | ||
|
|
39ba556a2e | ||
|
|
aee507fe6c | ||
|
|
ba9b4222e1 | ||
|
|
112973ae37 | ||
|
|
507183f4b0 | ||
|
|
62aefd3864 | ||
|
|
f36e87ec4f | ||
|
|
170ce893e7 | ||
|
|
08a3ac8403 | ||
|
|
b6ce93d565 | ||
|
|
ce50594d70 | ||
|
|
38c55bd388 | ||
|
|
86285152bd | ||
|
|
6b6d412f59 | ||
|
|
331a9f9068 | ||
|
|
7e0d217559 | ||
|
|
64205bf3ec | ||
|
|
048094bcf9 | ||
|
|
f80b5868fa | ||
|
|
ab03f130e4 | ||
|
|
a743227d81 | ||
|
|
f0240a36a3 | ||
|
|
a5f13b762b | ||
|
|
884024d1d8 | ||
|
|
e2ecbb13db | ||
|
|
14127d25e7 | ||
|
|
67f1490197 | ||
|
|
631df12969 | ||
|
|
5a05390de1 | ||
|
|
b6e2a1acd4 | ||
|
|
82abf31270 | ||
|
|
a27aa2316f | ||
|
|
4391ddecb2 | ||
|
|
92b8b18ca9 | ||
|
|
d69c49f33a | ||
|
|
513cfaa43d | ||
|
|
e779ccdf4e | ||
|
|
d084cd4388 | ||
|
|
8b09f50d1a | ||
|
|
7616c49355 | ||
|
|
8183149d3e | ||
|
|
22be09c708 | ||
|
|
4c3d1b0120 | ||
|
|
08b8cd174d | ||
|
|
c740a0b5a3 | ||
|
|
c1f606809d | ||
|
|
c625f6524d | ||
|
|
95bdd2e6f8 | ||
|
|
8b369ca021 | ||
|
|
094a9a9a23 | ||
|
|
9d155cbf95 | ||
|
|
cb78d34faf | ||
|
|
0c0b8487c9 | ||
|
|
3ec873af83 | ||
|
|
52b59e8841 |
@@ -562,6 +562,9 @@ def verify_checksum(ud, d, precomputed={}):
|
||||
|
||||
checksum_expected = getattr(ud, "%s_expected" % checksum_id)
|
||||
|
||||
if checksum_expected == '':
|
||||
checksum_expected = None
|
||||
|
||||
return {
|
||||
"id": checksum_id,
|
||||
"name": checksum_name,
|
||||
@@ -612,7 +615,7 @@ def verify_checksum(ud, d, precomputed={}):
|
||||
|
||||
for ci in checksum_infos:
|
||||
if ci["expected"] and ci["expected"] != ci["data"]:
|
||||
messages.append("File: '%s' has %s checksum %s when %s was " \
|
||||
messages.append("File: '%s' has %s checksum '%s' when '%s' was " \
|
||||
"expected" % (ud.localpath, ci["id"], ci["data"], ci["expected"]))
|
||||
bad_checksum = ci["data"]
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import subprocess
|
||||
import errno
|
||||
import re
|
||||
import datetime
|
||||
import gc
|
||||
import bb.server.xmlrpcserver
|
||||
from bb import daemonize
|
||||
from multiprocessing import queues
|
||||
@@ -221,6 +222,7 @@ class ProcessServer(multiprocessing.Process):
|
||||
try:
|
||||
print("Running command %s" % command)
|
||||
self.command_channel_reply.send(self.cooker.command.runCommand(command))
|
||||
print("Command Completed")
|
||||
except Exception as e:
|
||||
logger.exception('Exception in server main event loop running command %s (%s)' % (command, str(e)))
|
||||
|
||||
@@ -670,8 +672,10 @@ class ConnectionWriter(object):
|
||||
|
||||
def send(self, obj):
|
||||
obj = multiprocessing.reduction.ForkingPickler.dumps(obj)
|
||||
gc.disable()
|
||||
with self.wlock:
|
||||
self.writer.send_bytes(obj)
|
||||
gc.enable()
|
||||
|
||||
def fileno(self):
|
||||
return self.writer.fileno()
|
||||
|
||||
@@ -448,7 +448,7 @@ class Tinfoil:
|
||||
self.run_actions(config_params)
|
||||
self.recipes_parsed = True
|
||||
|
||||
def run_command(self, command, *params):
|
||||
def run_command(self, command, *params, handle_events=True):
|
||||
"""
|
||||
Run a command on the server (as implemented in bb.command).
|
||||
Note that there are two types of command - synchronous and
|
||||
@@ -468,7 +468,7 @@ class Tinfoil:
|
||||
try:
|
||||
result = self.server_connection.connection.runCommand(commandline)
|
||||
finally:
|
||||
while True:
|
||||
while handle_events:
|
||||
event = self.wait_event()
|
||||
if not event:
|
||||
break
|
||||
|
||||
@@ -15,9 +15,27 @@
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
sys.stderr.write("The Yocto Project Sphinx documentation requires PyYAML.\
|
||||
\nPlease make sure to install pyyaml python package.\n")
|
||||
sys.exit(1)
|
||||
|
||||
current_version = "3.1.14"
|
||||
bitbake_version = "1.46"
|
||||
# current_version = "dev"
|
||||
# bitbake_version = "" # Leave empty for development branch
|
||||
# Obtain versions from poky.yaml instead
|
||||
with open("poky.yaml") as data:
|
||||
buff = data.read()
|
||||
subst_vars = yaml.safe_load(buff)
|
||||
if "DOCCONF_VERSION" not in subst_vars:
|
||||
sys.stderr.write("Please set DOCCONF_VERSION in poky.yaml")
|
||||
sys.exit(1)
|
||||
current_version = subst_vars["DOCCONF_VERSION"]
|
||||
if "BITBAKE_SERIES" not in subst_vars:
|
||||
sys.stderr.write("Please set BITBAKE_SERIES in poky.yaml")
|
||||
sys.exit(1)
|
||||
bitbake_version = subst_vars["BITBAKE_SERIES"]
|
||||
|
||||
# String used in sidebar
|
||||
version = 'Version: ' + current_version
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
DISTRO : "3.1.14"
|
||||
DISTRO : "3.1.16"
|
||||
DISTRO_NAME_NO_CAP : "dunfell"
|
||||
DISTRO_NAME : "Dunfell"
|
||||
DISTRO_NAME_NO_CAP_MINUS_ONE : "zeus"
|
||||
YOCTO_DOC_VERSION : "3.1.14"
|
||||
YOCTO_DOC_VERSION : "3.1.16"
|
||||
YOCTO_DOC_VERSION_MINUS_ONE : "3.0.4"
|
||||
DISTRO_REL_TAG : "yocto-3.1.14"
|
||||
POKYVERSION : "23.0.14"
|
||||
DISTRO_REL_TAG : "yocto-3.1.16"
|
||||
DOCCONF_VERSION : "3.1.16"
|
||||
BITBAKE_SERIES : "1.46"
|
||||
POKYVERSION : "23.0.16"
|
||||
YOCTO_POKY : "poky-&DISTRO_NAME_NO_CAP;-&POKYVERSION;"
|
||||
YOCTO_DL_URL : "https://downloads.yoctoproject.org"
|
||||
YOCTO_AB_URL : "https://autobuilder.yoctoproject.org"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
DISTRO = "poky"
|
||||
DISTRO_NAME = "Poky (Yocto Project Reference Distro)"
|
||||
DISTRO_VERSION = "3.1.15"
|
||||
DISTRO_VERSION = "3.1.16"
|
||||
DISTRO_CODENAME = "dunfell"
|
||||
SDK_VENDOR = "-pokysdk"
|
||||
SDK_VERSION = "${@d.getVar('DISTRO_VERSION').replace('snapshot-${DATE}', 'snapshot')}"
|
||||
@@ -39,16 +39,6 @@ DISTRO_EXTRA_RDEPENDS_append_qemux86-64 = " ${POKYQEMUDEPS}"
|
||||
|
||||
TCLIBCAPPEND = ""
|
||||
|
||||
PREMIRRORS ??= "\
|
||||
bzr://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
cvs://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
git://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
gitsm://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
hg://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
osc://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
p4://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
svn://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n"
|
||||
|
||||
SANITY_TESTED_DISTROS ?= " \
|
||||
poky-2.7 \n \
|
||||
poky-3.0 \n \
|
||||
|
||||
@@ -2,7 +2,7 @@ SUMMARY = "Test recipe for recipeutils.patch_recipe()"
|
||||
|
||||
require recipeutils-test.inc
|
||||
|
||||
LICENSE = "Proprietary"
|
||||
LICENSE = "HPND"
|
||||
LIC_FILES_CHKSUM = "file://${WORKDIR}/somefile;md5=d41d8cd98f00b204e9800998ecf8427e"
|
||||
DEPENDS += "zlib"
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ python write_package_manifest() {
|
||||
|
||||
pkgs = image_list_installed_packages(d)
|
||||
output = format_pkg_list(pkgs)
|
||||
open(os.path.join(license_image_dir, 'package.manifest'),
|
||||
'w+').write(output)
|
||||
with open(os.path.join(license_image_dir, 'package.manifest'), "w+") as package_manifest:
|
||||
package_manifest.write(output)
|
||||
}
|
||||
|
||||
python license_create_manifest() {
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
METADATA_BRANCH ?= "${@base_detect_branch(d)}"
|
||||
METADATA_BRANCH[vardepvalue] = "${METADATA_BRANCH}"
|
||||
METADATA_REVISION ?= "${@base_detect_revision(d)}"
|
||||
METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}"
|
||||
|
||||
def base_detect_revision(d):
|
||||
path = base_get_scmbasepath(d)
|
||||
return base_get_metadata_git_revision(path, d)
|
||||
@@ -42,3 +37,8 @@ def base_get_metadata_git_revision(path, d):
|
||||
except bb.process.ExecutionError:
|
||||
rev = '<unknown>'
|
||||
return rev.strip()
|
||||
|
||||
METADATA_BRANCH := "${@base_detect_branch(d)}"
|
||||
METADATA_BRANCH[vardepvalue] = "${METADATA_BRANCH}"
|
||||
METADATA_REVISION := "${@base_detect_revision(d)}"
|
||||
METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}"
|
||||
|
||||
@@ -42,6 +42,7 @@ ftp://sourceware.org/pub http://ftp.gwdg.de/pub/linux/sources.redhat.com/sourcew
|
||||
cvs://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
svn://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
git://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
gitsm://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
hg://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
bzr://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
p4://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
@@ -52,6 +53,7 @@ npm://.*/?.* http://downloads.yoctoproject.org/mirror/sources/ \n \
|
||||
cvs://.*/.* http://sources.openembedded.org/ \n \
|
||||
svn://.*/.* http://sources.openembedded.org/ \n \
|
||||
git://.*/.* http://sources.openembedded.org/ \n \
|
||||
gitsm://.*/.* http://sources.openembedded.org/ \n \
|
||||
hg://.*/.* http://sources.openembedded.org/ \n \
|
||||
bzr://.*/.* http://sources.openembedded.org/ \n \
|
||||
p4://.*/.* http://sources.openembedded.org/ \n \
|
||||
|
||||
@@ -15,3 +15,15 @@ do_compile_prepend_class-target() {
|
||||
do_install_prepend_class-target() {
|
||||
export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
|
||||
}
|
||||
|
||||
do_configure:prepend:class-nativesdk() {
|
||||
export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
|
||||
}
|
||||
|
||||
do_compile:prepend:class-nativesdk() {
|
||||
export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
|
||||
}
|
||||
|
||||
do_install:prepend:class-nativesdk() {
|
||||
export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ from subprocess import Popen, PIPE
|
||||
|
||||
from oeqa.runtime.case import OERuntimeTestCase
|
||||
from oeqa.core.decorator.oetimeout import OETimeout
|
||||
from oeqa.core.exception import OEQATimeoutError
|
||||
|
||||
class PingTest(OERuntimeTestCase):
|
||||
|
||||
@@ -13,14 +14,17 @@ class PingTest(OERuntimeTestCase):
|
||||
def test_ping(self):
|
||||
output = ''
|
||||
count = 0
|
||||
while count < 5:
|
||||
cmd = 'ping -c 1 %s' % self.target.ip
|
||||
proc = Popen(cmd, shell=True, stdout=PIPE)
|
||||
output += proc.communicate()[0].decode('utf-8')
|
||||
if proc.poll() == 0:
|
||||
count += 1
|
||||
else:
|
||||
count = 0
|
||||
try:
|
||||
while count < 5:
|
||||
cmd = 'ping -c 1 %s' % self.target.ip
|
||||
proc = Popen(cmd, shell=True, stdout=PIPE)
|
||||
output += proc.communicate()[0].decode('utf-8')
|
||||
if proc.poll() == 0:
|
||||
count += 1
|
||||
else:
|
||||
count = 0
|
||||
except OEQATimeoutError:
|
||||
self.fail("Ping timeout error for address %s, count %s, output: %s" % (self.target.ip, count, output))
|
||||
msg = ('Expected 5 consecutive, got %d.\n'
|
||||
'ping output is:\n%s' % (count,output))
|
||||
self.assertEqual(count, 5, msg = msg)
|
||||
|
||||
@@ -87,14 +87,14 @@ class TinfoilTests(OESelftestTestCase):
|
||||
with bb.tinfoil.Tinfoil() as tinfoil:
|
||||
tinfoil.prepare(config_only=True)
|
||||
|
||||
tinfoil.set_event_mask(['bb.event.FilesMatchingFound', 'bb.command.CommandCompleted'])
|
||||
tinfoil.set_event_mask(['bb.event.FilesMatchingFound', 'bb.command.CommandCompleted', 'bb.command.CommandFailed', 'bb.command.CommandExit'])
|
||||
|
||||
# Need to drain events otherwise events that were masked may still be in the queue
|
||||
while tinfoil.wait_event():
|
||||
pass
|
||||
|
||||
pattern = 'conf'
|
||||
res = tinfoil.run_command('testCookerCommandEvent', pattern)
|
||||
res = tinfoil.run_command('testCookerCommandEvent', pattern, handle_events=False)
|
||||
self.assertTrue(res)
|
||||
|
||||
eventreceived = False
|
||||
@@ -118,7 +118,7 @@ class TinfoilTests(OESelftestTestCase):
|
||||
else:
|
||||
self.fail('Unexpected event: %s' % event)
|
||||
|
||||
self.assertTrue(commandcomplete, 'Timed out waiting for CommandCompleted event from bitbake server')
|
||||
self.assertTrue(commandcomplete, 'Timed out waiting for CommandCompleted event from bitbake server (Matching event received: %s)' % str(eventreceived))
|
||||
self.assertTrue(eventreceived, 'Did not receive FilesMatchingFound event from bitbake server')
|
||||
|
||||
def test_setvariable_clean(self):
|
||||
|
||||
@@ -15,6 +15,8 @@ CVE_PRODUCT = "grub2"
|
||||
|
||||
# Applies only to RHEL
|
||||
CVE_CHECK_WHITELIST += "CVE-2019-14865"
|
||||
# Applies only to SUSE
|
||||
CVE_CHECK_WHITELIST += "CVE-2021-46705"
|
||||
|
||||
SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
file://0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch \
|
||||
|
||||
@@ -14,13 +14,13 @@ PE = "1"
|
||||
# repo during parse
|
||||
SRCREV = "303f8fed261020c1cb7da32dad63b610bf6873dd"
|
||||
|
||||
SRC_URI = "git://git.denx.de/u-boot.git;branch=master \
|
||||
SRC_URI = "git://source.denx.de/u-boot/u-boot.git;protocol=https;branch=master \
|
||||
file://remove-redundant-yyloc-global.patch \
|
||||
file://CVE-2020-8432.patch \
|
||||
file://CVE-2020-10648-1.patch \
|
||||
file://CVE-2020-10648-2.patch \
|
||||
"
|
||||
|
||||
|
||||
S = "${WORKDIR}/git"
|
||||
B = "${WORKDIR}/build"
|
||||
do_configure[cleandirs] = "${B}"
|
||||
|
||||
@@ -4,7 +4,7 @@ DESCRIPTION = "BIND 9 provides a full-featured Domain Name Server system"
|
||||
SECTION = "console/network"
|
||||
|
||||
LICENSE = "ISC & BSD"
|
||||
LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=b88e7ca5f21908e1b2720169f6807cf6"
|
||||
LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=89a97ebbf713f7125fe5c02223d3ae95"
|
||||
|
||||
DEPENDS = "openssl libcap zlib"
|
||||
|
||||
@@ -21,7 +21,7 @@ SRC_URI = "https://ftp.isc.org/isc/bind9/${PV}/${BPN}-${PV}.tar.gz \
|
||||
file://0001-avoid-start-failure-with-bind-user.patch \
|
||||
"
|
||||
|
||||
SRC_URI[sha256sum] = "c953fcb6703b395aaa53e65ff8b2869b69a5303dd60507cba2201305e1811681"
|
||||
SRC_URI[sha256sum] = "0d8efbe7ec166ada90e46add4267b7e7c934790cba9bd5af6b8380a4fbfb5aff"
|
||||
|
||||
UPSTREAM_CHECK_URI = "https://ftp.isc.org/isc/bind9/"
|
||||
# stay at 9.11 until 9.16, from 9.16 follow the ESV versions divisible by 4
|
||||
@@ -54,6 +54,8 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
|
||||
file://0001-test-gatt-Fix-hung-issue.patch \
|
||||
file://CVE-2021-0129.patch \
|
||||
file://CVE-2021-3588.patch \
|
||||
file://CVE-2021-3658.patch \
|
||||
file://CVE-2022-0204.patch \
|
||||
"
|
||||
S = "${WORKDIR}/bluez-${PV}"
|
||||
|
||||
|
||||
95
meta/recipes-connectivity/bluez5/bluez5/CVE-2021-3658.patch
Normal file
95
meta/recipes-connectivity/bluez5/bluez5/CVE-2021-3658.patch
Normal file
@@ -0,0 +1,95 @@
|
||||
From b497b5942a8beb8f89ca1c359c54ad67ec843055 Mon Sep 17 00:00:00 2001
|
||||
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
|
||||
Date: Thu, 24 Jun 2021 16:32:04 -0700
|
||||
Subject: [PATCH] adapter: Fix storing discoverable setting
|
||||
|
||||
discoverable setting shall only be store when changed via Discoverable
|
||||
property and not when discovery client set it as that be considered
|
||||
temporary just for the lifetime of the discovery.
|
||||
|
||||
Upstream-Status: Backport [https://github.com/bluez/bluez/commit/b497b5942a8beb8f89ca1c359c54ad67ec843055]
|
||||
Signed-off-by:Minjae Kim <flowergom@gmail.com>
|
||||
---
|
||||
src/adapter.c | 35 ++++++++++++++++++++++-------------
|
||||
1 file changed, 22 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/adapter.c b/src/adapter.c
|
||||
index 12e4ff5c0..663b778e4 100644
|
||||
--- a/src/adapter.c
|
||||
+++ b/src/adapter.c
|
||||
@@ -560,7 +560,11 @@ static void settings_changed(struct btd_adapter *adapter, uint32_t settings)
|
||||
if (changed_mask & MGMT_SETTING_DISCOVERABLE) {
|
||||
g_dbus_emit_property_changed(dbus_conn, adapter->path,
|
||||
ADAPTER_INTERFACE, "Discoverable");
|
||||
- store_adapter_info(adapter);
|
||||
+ /* Only persist discoverable setting if it was not set
|
||||
+ * temporarily by discovery.
|
||||
+ */
|
||||
+ if (!adapter->discovery_discoverable)
|
||||
+ store_adapter_info(adapter);
|
||||
btd_adv_manager_refresh(adapter->adv_manager);
|
||||
}
|
||||
|
||||
@@ -2162,8 +2166,6 @@ static bool filters_equal(struct mgmt_cp_start_service_discovery *a,
|
||||
static int update_discovery_filter(struct btd_adapter *adapter)
|
||||
{
|
||||
struct mgmt_cp_start_service_discovery *sd_cp;
|
||||
- GSList *l;
|
||||
-
|
||||
|
||||
DBG("");
|
||||
|
||||
@@ -2173,17 +2175,24 @@ static int update_discovery_filter(struct btd_adapter *adapter)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
- for (l = adapter->discovery_list; l; l = g_slist_next(l)) {
|
||||
- struct discovery_client *client = l->data;
|
||||
+ /* Only attempt to overwrite current discoverable setting when not
|
||||
+ * discoverable.
|
||||
+ */
|
||||
+ if (!(adapter->current_settings & MGMT_OP_SET_DISCOVERABLE)) {
|
||||
+ GSList *l;
|
||||
|
||||
- if (!client->discovery_filter)
|
||||
- continue;
|
||||
+ for (l = adapter->discovery_list; l; l = g_slist_next(l)) {
|
||||
+ struct discovery_client *client = l->data;
|
||||
|
||||
- if (client->discovery_filter->discoverable)
|
||||
- break;
|
||||
- }
|
||||
+ if (!client->discovery_filter)
|
||||
+ continue;
|
||||
|
||||
- set_discovery_discoverable(adapter, l ? true : false);
|
||||
+ if (client->discovery_filter->discoverable) {
|
||||
+ set_discovery_discoverable(adapter, true);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
/*
|
||||
* If filters are equal, then don't update scan, except for when
|
||||
@@ -2216,8 +2225,7 @@ static int discovery_stop(struct discovery_client *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (adapter->discovery_discoverable)
|
||||
- set_discovery_discoverable(adapter, false);
|
||||
+ set_discovery_discoverable(adapter, false);
|
||||
|
||||
/*
|
||||
* In the idle phase of a discovery, there is no need to stop it
|
||||
@@ -6913,6 +6921,7 @@ static void adapter_stop(struct btd_adapter *adapter)
|
||||
g_free(adapter->current_discovery_filter);
|
||||
adapter->current_discovery_filter = NULL;
|
||||
|
||||
+ set_discovery_discoverable(adapter, false);
|
||||
adapter->discovering = false;
|
||||
|
||||
while (adapter->connections) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
66
meta/recipes-connectivity/bluez5/bluez5/CVE-2022-0204.patch
Normal file
66
meta/recipes-connectivity/bluez5/bluez5/CVE-2022-0204.patch
Normal file
@@ -0,0 +1,66 @@
|
||||
From 0d328fdf6564b67fc2ec3533e3da201ebabcc9e3 Mon Sep 17 00:00:00 2001
|
||||
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
|
||||
Date: Tue, 8 Jun 2021 16:46:49 -0700
|
||||
Subject: [PATCH] shared/gatt-server: Fix heap overflow when appending prepare
|
||||
writes
|
||||
|
||||
The code shall check if the prepare writes would append more the
|
||||
allowed maximum attribute length.
|
||||
|
||||
Fixes https://github.com/bluez/bluez/security/advisories/GHSA-479m-xcq5-9g2q
|
||||
|
||||
Upstream-Status: Backport [https://github.com/bluez/bluez/commit/591c546c536b42bef696d027f64aa22434f8c3f0]
|
||||
Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
|
||||
CVE: CVE-2022-0204
|
||||
|
||||
---
|
||||
src/shared/gatt-server.c | 22 ++++++++++++++++++++++
|
||||
1 file changed, 22 insertions(+)
|
||||
|
||||
diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
|
||||
index 0c25a97..20e14bc 100644
|
||||
--- a/src/shared/gatt-server.c
|
||||
+++ b/src/shared/gatt-server.c
|
||||
@@ -816,6 +816,20 @@ static uint8_t authorize_req(struct bt_gatt_server *server,
|
||||
server->authorize_data);
|
||||
}
|
||||
|
||||
+static uint8_t check_length(uint16_t length, uint16_t offset)
|
||||
+{
|
||||
+ if (length > BT_ATT_MAX_VALUE_LEN)
|
||||
+ return BT_ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LEN;
|
||||
+
|
||||
+ if (offset > BT_ATT_MAX_VALUE_LEN)
|
||||
+ return BT_ATT_ERROR_INVALID_OFFSET;
|
||||
+
|
||||
+ if (length + offset > BT_ATT_MAX_VALUE_LEN)
|
||||
+ return BT_ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LEN;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void write_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu,
|
||||
uint16_t length, void *user_data)
|
||||
{
|
||||
@@ -846,6 +860,10 @@ 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_length(length, 0);
|
||||
+ if (ecode)
|
||||
+ goto error;
|
||||
+
|
||||
ecode = check_permissions(server, attr, BT_ATT_PERM_WRITE_MASK);
|
||||
if (ecode)
|
||||
goto error;
|
||||
@@ -1353,6 +1371,10 @@ 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_length(length, offset);
|
||||
+ if (ecode)
|
||||
+ goto error;
|
||||
+
|
||||
ecode = check_permissions(server, attr, BT_ATT_PERM_WRITE_MASK);
|
||||
if (ecode)
|
||||
goto error;
|
||||
@@ -4,11 +4,12 @@ DESCRIPTION = "Mobile Broadband Service Provider Database stores service provide
|
||||
SECTION = "network"
|
||||
LICENSE = "PD"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=87964579b2a8ece4bc6744d2dc9a8b04"
|
||||
SRCREV = "90f3fe28aa25135b7e4a54a7816388913bfd4a2a"
|
||||
PV = "20201225"
|
||||
|
||||
SRCREV = "4cbb44a9fe26aa6f0b28beb79f9488b37c097b5e"
|
||||
PV = "20220315"
|
||||
PE = "1"
|
||||
|
||||
SRC_URI = "git://gitlab.gnome.org/GNOME/mobile-broadband-provider-info.git;protocol=https;branch=master"
|
||||
SRC_URI = "git://gitlab.gnome.org/GNOME/mobile-broadband-provider-info.git;protocol=https;branch=main"
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
inherit autotools
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
From e9e726506cd2a3fd9c0f12daf8cc1fe934c7dddb Mon Sep 17 00:00:00 2001
|
||||
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
Date: Sat, 11 Dec 2021 20:28:11 +0100
|
||||
Subject: [PATCH] Fix a carry overflow bug in bn_sqr_comba4/8 for mips 32-bit
|
||||
targets
|
||||
|
||||
bn_sqr_comba8 does for instance compute a wrong result for the value:
|
||||
a=0x4aaac919 62056c84 fba7334e 1a6be678 022181ba fd3aa878 899b2346 ee210f45
|
||||
|
||||
The correct result is:
|
||||
r=0x15c72e32 605a3061 d11b1012 3c187483 6df96999 bd0c22ba d3e7d437 4724a82f
|
||||
912c5e61 6a187efe 8f7c47fc f6945fe5 75be8e3d 97ed17d4 7950b465 3cb32899
|
||||
|
||||
but the actual result was:
|
||||
r=0x15c72e32 605a3061 d11b1012 3c187483 6df96999 bd0c22ba d3e7d437 4724a82f
|
||||
912c5e61 6a187efe 8f7c47fc f6945fe5 75be8e3c 97ed17d4 7950b465 3cb32899
|
||||
|
||||
so the forth word of the result was 0x75be8e3c but should have been
|
||||
0x75be8e3d instead.
|
||||
|
||||
Likewise bn_sqr_comba4 has an identical bug for the same value as well:
|
||||
a=0x022181ba fd3aa878 899b2346 ee210f45
|
||||
|
||||
correct result:
|
||||
r=0x00048a69 9fe82f8b 62bd2ed1 88781335 75be8e3d 97ed17d4 7950b465 3cb32899
|
||||
|
||||
wrong result:
|
||||
r=0x00048a69 9fe82f8b 62bd2ed1 88781335 75be8e3c 97ed17d4 7950b465 3cb32899
|
||||
|
||||
Fortunately the bn_mul_comba4/8 code paths are not affected.
|
||||
|
||||
Also the mips64 target does in fact not handle the carry propagation
|
||||
correctly.
|
||||
|
||||
Example:
|
||||
a=0x4aaac91900000000 62056c8400000000 fba7334e00000000 1a6be67800000000
|
||||
022181ba00000000 fd3aa87800000000 899b234635dad283 ee210f4500000001
|
||||
|
||||
correct result:
|
||||
r=0x15c72e32272c4471 392debf018c679c8 b85496496bf8254c d0204f36611e2be1
|
||||
0cdb3db8f3c081d8 c94ba0e1bacc5061 191b83d47ff929f6 5be0aebfc13ae68d
|
||||
3eea7a7fdf2f5758 42f7ec656cab3cb5 6a28095be34756f2 64f24687bf37de06
|
||||
2822309cd1d292f9 6fa698c972372f09 771e97d3a868cda0 dc421e8a00000001
|
||||
|
||||
wrong result:
|
||||
r=0x15c72e32272c4471 392debf018c679c8 b85496496bf8254c d0204f36611e2be1
|
||||
0cdb3db8f3c081d8 c94ba0e1bacc5061 191b83d47ff929f6 5be0aebfc13ae68d
|
||||
3eea7a7fdf2f5758 42f7ec656cab3cb5 6a28095be34756f2 64f24687bf37de06
|
||||
2822309cd1d292f8 6fa698c972372f09 771e97d3a868cda0 dc421e8a00000001
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/17258)
|
||||
|
||||
(cherry picked from commit 336923c0c8d705cb8af5216b29a205662db0d590)
|
||||
|
||||
Upstream-Status: Backport [https://git.openssl.org/gitweb/?p=openssl.git;a=patch;h=e9e726506cd2a3fd9c0f12daf8cc1fe934c7dddb]
|
||||
CVE: CVE-2021-4160
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
crypto/bn/asm/mips.pl | 4 ++++
|
||||
test/bntest.c | 45 +++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 49 insertions(+)
|
||||
|
||||
diff --git a/crypto/bn/asm/mips.pl b/crypto/bn/asm/mips.pl
|
||||
index 8ad715bda4..74101030f2 100644
|
||||
--- a/crypto/bn/asm/mips.pl
|
||||
+++ b/crypto/bn/asm/mips.pl
|
||||
@@ -1984,6 +1984,8 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
+ sltu $at,$c_3,$t_2
|
||||
+ $ADDU $c_1,$at
|
||||
mflo ($t_1,$a_2,$a_0)
|
||||
mfhi ($t_2,$a_2,$a_0)
|
||||
___
|
||||
@@ -2194,6 +2196,8 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
+ sltu $at,$c_3,$t_2
|
||||
+ $ADDU $c_1,$at
|
||||
mflo ($t_1,$a_2,$a_0)
|
||||
mfhi ($t_2,$a_2,$a_0)
|
||||
___
|
||||
diff --git a/test/bntest.c b/test/bntest.c
|
||||
index b58028a301..bab34ba54b 100644
|
||||
--- a/test/bntest.c
|
||||
+++ b/test/bntest.c
|
||||
@@ -627,6 +627,51 @@ static int test_modexp_mont5(void)
|
||||
if (!TEST_BN_eq(c, d))
|
||||
goto err;
|
||||
|
||||
+ /*
|
||||
+ * Regression test for overflow bug in bn_sqr_comba4/8 for
|
||||
+ * mips-linux-gnu and mipsel-linux-gnu 32bit targets.
|
||||
+ */
|
||||
+ {
|
||||
+ static const char *ehex[] = {
|
||||
+ "95564994a96c45954227b845a1e99cb939d5a1da99ee91acc962396ae999a9ee",
|
||||
+ "38603790448f2f7694c242a875f0cad0aae658eba085f312d2febbbd128dd2b5",
|
||||
+ "8f7d1149f03724215d704344d0d62c587ae3c5939cba4b9b5f3dc5e8e911ef9a",
|
||||
+ "5ce1a5a749a4989d0d8368f6e1f8cdf3a362a6c97fb02047ff152b480a4ad985",
|
||||
+ "2d45efdf0770542992afca6a0590d52930434bba96017afbc9f99e112950a8b1",
|
||||
+ "a359473ec376f329bdae6a19f503be6d4be7393c4e43468831234e27e3838680",
|
||||
+ "b949390d2e416a3f9759e5349ab4c253f6f29f819a6fe4cbfd27ada34903300e",
|
||||
+ "da021f62839f5878a36f1bc3085375b00fd5fa3e68d316c0fdace87a97558465",
|
||||
+ NULL};
|
||||
+ static const char *phex[] = {
|
||||
+ "f95dc0f980fbd22e90caa5a387cc4a369f3f830d50dd321c40db8c09a7e1a241",
|
||||
+ "a536e096622d3280c0c1ba849c1f4a79bf490f60006d081e8cf69960189f0d31",
|
||||
+ "2cd9e17073a3fba7881b21474a13b334116cb2f5dbf3189a6de3515d0840f053",
|
||||
+ "c776d3982d391b6d04d642dda5cc6d1640174c09875addb70595658f89efb439",
|
||||
+ "dc6fbd55f903aadd307982d3f659207f265e1ec6271b274521b7a5e28e8fd7a5",
|
||||
+ "5df089292820477802a43cf5b6b94e999e8c9944ddebb0d0e95a60f88cb7e813",
|
||||
+ "ba110d20e1024774107dd02949031864923b3cb8c3f7250d6d1287b0a40db6a4",
|
||||
+ "7bd5a469518eb65aa207ddc47d8c6e5fc8e0c105be8fc1d4b57b2e27540471d5",
|
||||
+ NULL};
|
||||
+ static const char *mhex[] = {
|
||||
+ "fef15d5ce4625f1bccfbba49fc8439c72bf8202af039a2259678941b60bb4a8f",
|
||||
+ "2987e965d58fd8cf86a856674d519763d0e1211cc9f8596971050d56d9b35db3",
|
||||
+ "785866cfbca17cfdbed6060be3629d894f924a89fdc1efc624f80d41a22f1900",
|
||||
+ "9503fcc3824ef62ccb9208430c26f2d8ceb2c63488ec4c07437aa4c96c43dd8b",
|
||||
+ "9289ed00a712ff66ee195dc71f5e4ead02172b63c543d69baf495f5fd63ba7bc",
|
||||
+ "c633bd309c016e37736da92129d0b053d4ab28d21ad7d8b6fab2a8bbdc8ee647",
|
||||
+ "d2fbcf2cf426cf892e6f5639e0252993965dfb73ccd277407014ea784aaa280c",
|
||||
+ "b7b03972bc8b0baa72360bdb44b82415b86b2f260f877791cd33ba8f2d65229b",
|
||||
+ NULL};
|
||||
+
|
||||
+ if (!TEST_true(parse_bigBN(&e, ehex))
|
||||
+ || !TEST_true(parse_bigBN(&p, phex))
|
||||
+ || !TEST_true(parse_bigBN(&m, mhex))
|
||||
+ || !TEST_true(BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))
|
||||
+ || !TEST_true(BN_mod_exp_simple(a, e, p, m, ctx))
|
||||
+ || !TEST_BN_eq(a, d))
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
/* Zero input */
|
||||
if (!TEST_true(BN_bntest_rand(p, 1024, 0, 0)))
|
||||
goto err;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -18,14 +18,13 @@ SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
|
||||
file://afalg.patch \
|
||||
file://reproducible.patch \
|
||||
file://reproducibility.patch \
|
||||
file://CVE-2021-4160.patch \
|
||||
"
|
||||
|
||||
SRC_URI_append_class-nativesdk = " \
|
||||
file://environment.d-openssl.sh \
|
||||
"
|
||||
|
||||
SRC_URI[sha256sum] = "0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1"
|
||||
SRC_URI[sha256sum] = "40dceb51a4f6a5275bde0e6bf20ef4b91bfc32ed57c0552e2e8e15463372b17a"
|
||||
|
||||
inherit lib_package multilib_header multilib_script ptest
|
||||
MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash"
|
||||
@@ -181,6 +180,7 @@ do_install_ptest () {
|
||||
install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps
|
||||
|
||||
install -d ${D}${PTEST_PATH}/engines
|
||||
install -m755 ${B}/engines/dasync.so ${D}${PTEST_PATH}/engines
|
||||
install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ IMAGE_FSTYPES = "wic.vmdk"
|
||||
|
||||
inherit core-image setuptools3
|
||||
|
||||
SRCREV ?= "d752cbcbbeeea9adbcc9aa74def1761f34a9de54"
|
||||
SRCREV ?= "8a7fd5f633a2b72185501d4c4a8a51ed1fc7cea1"
|
||||
SRC_URI = "git://git.yoctoproject.org/poky;branch=dunfell \
|
||||
file://Yocto_Build_Appliance.vmx \
|
||||
file://Yocto_Build_Appliance.vmxf \
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
From 646fe48d1c8a74310c409ddf81fe7df6700052af Mon Sep 17 00:00:00 2001
|
||||
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
||||
Date: Tue, 22 Feb 2022 11:51:08 +0100
|
||||
Subject: [PATCH] Fix --without-valid build
|
||||
|
||||
Regressed in commit 652dd12a.
|
||||
---
|
||||
valid.c | 58 ++++++++++++++++++++++++++++-----------------------------
|
||||
1 file changed, 29 insertions(+), 29 deletions(-)
|
||||
---
|
||||
|
||||
From https://github.com/GNOME/libxml2.git
|
||||
commit 646fe48d1c8a74310c409ddf81fe7df6700052af
|
||||
|
||||
CVE: CVE-2022-23308
|
||||
Upstream-Status: Backport
|
||||
|
||||
Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
|
||||
|
||||
diff --git a/valid.c b/valid.c
|
||||
index 8e596f1d..9684683a 100644
|
||||
--- a/valid.c
|
||||
+++ b/valid.c
|
||||
@@ -479,35 +479,6 @@ nodeVPop(xmlValidCtxtPtr ctxt)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
-/**
|
||||
- * xmlValidNormalizeString:
|
||||
- * @str: a string
|
||||
- *
|
||||
- * Normalize a string in-place.
|
||||
- */
|
||||
-static void
|
||||
-xmlValidNormalizeString(xmlChar *str) {
|
||||
- xmlChar *dst;
|
||||
- const xmlChar *src;
|
||||
-
|
||||
- if (str == NULL)
|
||||
- return;
|
||||
- src = str;
|
||||
- dst = str;
|
||||
-
|
||||
- while (*src == 0x20) src++;
|
||||
- while (*src != 0) {
|
||||
- if (*src == 0x20) {
|
||||
- while (*src == 0x20) src++;
|
||||
- if (*src != 0)
|
||||
- *dst++ = 0x20;
|
||||
- } else {
|
||||
- *dst++ = *src++;
|
||||
- }
|
||||
- }
|
||||
- *dst = 0;
|
||||
-}
|
||||
-
|
||||
#ifdef DEBUG_VALID_ALGO
|
||||
static void
|
||||
xmlValidPrintNode(xmlNodePtr cur) {
|
||||
@@ -2636,6 +2607,35 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
|
||||
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
|
||||
xmlFree((char *)(str));
|
||||
|
||||
+/**
|
||||
+ * xmlValidNormalizeString:
|
||||
+ * @str: a string
|
||||
+ *
|
||||
+ * Normalize a string in-place.
|
||||
+ */
|
||||
+static void
|
||||
+xmlValidNormalizeString(xmlChar *str) {
|
||||
+ xmlChar *dst;
|
||||
+ const xmlChar *src;
|
||||
+
|
||||
+ if (str == NULL)
|
||||
+ return;
|
||||
+ src = str;
|
||||
+ dst = str;
|
||||
+
|
||||
+ while (*src == 0x20) src++;
|
||||
+ while (*src != 0) {
|
||||
+ if (*src == 0x20) {
|
||||
+ while (*src == 0x20) src++;
|
||||
+ if (*src != 0)
|
||||
+ *dst++ = 0x20;
|
||||
+ } else {
|
||||
+ *dst++ = *src++;
|
||||
+ }
|
||||
+ }
|
||||
+ *dst = 0;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
xmlIsStreaming(xmlValidCtxtPtr ctxt) {
|
||||
xmlParserCtxtPtr pctxt;
|
||||
--
|
||||
2.35.1
|
||||
|
||||
204
meta/recipes-core/libxml/libxml2/CVE-2022-23308.patch
Normal file
204
meta/recipes-core/libxml/libxml2/CVE-2022-23308.patch
Normal file
@@ -0,0 +1,204 @@
|
||||
From 8b66850de350f0fcd786ae776a65ba15a5999e50 Mon Sep 17 00:00:00 2001
|
||||
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
||||
Date: Tue, 8 Feb 2022 03:29:24 +0100
|
||||
Subject: [PATCH] Use-after-free of ID and IDREF attributes
|
||||
|
||||
If a document is parsed with XML_PARSE_DTDVALID and without
|
||||
XML_PARSE_NOENT, the value of ID attributes has to be normalized after
|
||||
potentially expanding entities in xmlRemoveID. Otherwise, later calls
|
||||
to xmlGetID can return a pointer to previously freed memory.
|
||||
|
||||
ID attributes which are empty or contain only whitespace after
|
||||
entity expansion are affected in a similar way. This is fixed by
|
||||
not storing such attributes in the ID table.
|
||||
|
||||
The test to detect streaming mode when validating against a DTD was
|
||||
broken. In connection with the defects above, this could result in a
|
||||
use-after-free when using the xmlReader interface with validation.
|
||||
Fix detection of streaming mode to avoid similar issues. (This changes
|
||||
the expected result of a test case. But as far as I can tell, using the
|
||||
XML reader with XIncludes referencing the root document never worked
|
||||
properly, anyway.)
|
||||
|
||||
All of these issues can result in denial of service. Using xmlReader
|
||||
with validation could result in disclosure of memory via the error
|
||||
channel, typically stderr. The security impact of xmlGetID returning
|
||||
a pointer to freed memory depends on the application. The typical use
|
||||
case of calling xmlGetID on an unmodified document is not affected.
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://gitlab.gnome.org/GNOME/libxml2/-/commit/652dd12a858989b14eed4e84e453059cd3ba340e]
|
||||
|
||||
The upstream patch 652dd12a858989b14eed4e84e453059cd3ba340e has been modified
|
||||
to skip the patch to the testsuite result (result/XInclude/ns1.xml.rdr), as
|
||||
this particular test does not exist in v2.9.10 (it was added later).
|
||||
|
||||
CVE: CVE-2022-23308
|
||||
Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
|
||||
|
||||
---
|
||||
valid.c | 88 +++++++++++++++++++++++++++++++++++----------------------
|
||||
1 file changed, 55 insertions(+), 33 deletions(-)
|
||||
|
||||
diff --git a/valid.c b/valid.c
|
||||
index 07963e7..ee75311 100644
|
||||
--- a/valid.c
|
||||
+++ b/valid.c
|
||||
@@ -479,6 +479,35 @@ nodeVPop(xmlValidCtxtPtr ctxt)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * xmlValidNormalizeString:
|
||||
+ * @str: a string
|
||||
+ *
|
||||
+ * Normalize a string in-place.
|
||||
+ */
|
||||
+static void
|
||||
+xmlValidNormalizeString(xmlChar *str) {
|
||||
+ xmlChar *dst;
|
||||
+ const xmlChar *src;
|
||||
+
|
||||
+ if (str == NULL)
|
||||
+ return;
|
||||
+ src = str;
|
||||
+ dst = str;
|
||||
+
|
||||
+ while (*src == 0x20) src++;
|
||||
+ while (*src != 0) {
|
||||
+ if (*src == 0x20) {
|
||||
+ while (*src == 0x20) src++;
|
||||
+ if (*src != 0)
|
||||
+ *dst++ = 0x20;
|
||||
+ } else {
|
||||
+ *dst++ = *src++;
|
||||
+ }
|
||||
+ }
|
||||
+ *dst = 0;
|
||||
+}
|
||||
+
|
||||
#ifdef DEBUG_VALID_ALGO
|
||||
static void
|
||||
xmlValidPrintNode(xmlNodePtr cur) {
|
||||
@@ -2607,6 +2636,24 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
|
||||
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
|
||||
xmlFree((char *)(str));
|
||||
|
||||
+static int
|
||||
+xmlIsStreaming(xmlValidCtxtPtr ctxt) {
|
||||
+ xmlParserCtxtPtr pctxt;
|
||||
+
|
||||
+ if (ctxt == NULL)
|
||||
+ return(0);
|
||||
+ /*
|
||||
+ * These magic values are also abused to detect whether we're validating
|
||||
+ * while parsing a document. In this case, userData points to the parser
|
||||
+ * context.
|
||||
+ */
|
||||
+ if ((ctxt->finishDtd != XML_CTXT_FINISH_DTD_0) &&
|
||||
+ (ctxt->finishDtd != XML_CTXT_FINISH_DTD_1))
|
||||
+ return(0);
|
||||
+ pctxt = ctxt->userData;
|
||||
+ return(pctxt->parseMode == XML_PARSE_READER);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* xmlFreeID:
|
||||
* @not: A id
|
||||
@@ -2650,7 +2697,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
||||
if (doc == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
- if (value == NULL) {
|
||||
+ if ((value == NULL) || (value[0] == 0)) {
|
||||
return(NULL);
|
||||
}
|
||||
if (attr == NULL) {
|
||||
@@ -2681,7 +2728,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
||||
*/
|
||||
ret->value = xmlStrdup(value);
|
||||
ret->doc = doc;
|
||||
- if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
|
||||
+ if (xmlIsStreaming(ctxt)) {
|
||||
/*
|
||||
* Operating in streaming mode, attr is gonna disappear
|
||||
*/
|
||||
@@ -2820,6 +2867,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
|
||||
ID = xmlNodeListGetString(doc, attr->children, 1);
|
||||
if (ID == NULL)
|
||||
return(-1);
|
||||
+ xmlValidNormalizeString(ID);
|
||||
|
||||
id = xmlHashLookup(table, ID);
|
||||
if (id == NULL || id->attr != attr) {
|
||||
@@ -3009,7 +3057,7 @@ xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
||||
* fill the structure.
|
||||
*/
|
||||
ret->value = xmlStrdup(value);
|
||||
- if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
|
||||
+ if (xmlIsStreaming(ctxt)) {
|
||||
/*
|
||||
* Operating in streaming mode, attr is gonna disappear
|
||||
*/
|
||||
@@ -4028,8 +4076,7 @@ xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
xmlChar *
|
||||
xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
xmlNodePtr elem, const xmlChar *name, const xmlChar *value) {
|
||||
- xmlChar *ret, *dst;
|
||||
- const xmlChar *src;
|
||||
+ xmlChar *ret;
|
||||
xmlAttributePtr attrDecl = NULL;
|
||||
int extsubset = 0;
|
||||
|
||||
@@ -4070,19 +4117,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
ret = xmlStrdup(value);
|
||||
if (ret == NULL)
|
||||
return(NULL);
|
||||
- src = value;
|
||||
- dst = ret;
|
||||
- while (*src == 0x20) src++;
|
||||
- while (*src != 0) {
|
||||
- if (*src == 0x20) {
|
||||
- while (*src == 0x20) src++;
|
||||
- if (*src != 0)
|
||||
- *dst++ = 0x20;
|
||||
- } else {
|
||||
- *dst++ = *src++;
|
||||
- }
|
||||
- }
|
||||
- *dst = 0;
|
||||
+ xmlValidNormalizeString(ret);
|
||||
if ((doc->standalone) && (extsubset == 1) && (!xmlStrEqual(value, ret))) {
|
||||
xmlErrValidNode(ctxt, elem, XML_DTD_NOT_STANDALONE,
|
||||
"standalone: %s on %s value had to be normalized based on external subset declaration\n",
|
||||
@@ -4114,8 +4149,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
xmlChar *
|
||||
xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
|
||||
const xmlChar *name, const xmlChar *value) {
|
||||
- xmlChar *ret, *dst;
|
||||
- const xmlChar *src;
|
||||
+ xmlChar *ret;
|
||||
xmlAttributePtr attrDecl = NULL;
|
||||
|
||||
if (doc == NULL) return(NULL);
|
||||
@@ -4145,19 +4179,7 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
|
||||
ret = xmlStrdup(value);
|
||||
if (ret == NULL)
|
||||
return(NULL);
|
||||
- src = value;
|
||||
- dst = ret;
|
||||
- while (*src == 0x20) src++;
|
||||
- while (*src != 0) {
|
||||
- if (*src == 0x20) {
|
||||
- while (*src == 0x20) src++;
|
||||
- if (*src != 0)
|
||||
- *dst++ = 0x20;
|
||||
- } else {
|
||||
- *dst++ = *src++;
|
||||
- }
|
||||
- }
|
||||
- *dst = 0;
|
||||
+ xmlValidNormalizeString(ret);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
SUMMARY = "XML C Parser Library and Toolkit"
|
||||
DESCRIPTION = "The XML Parser Library allows for manipulation of XML files. Libxml2 exports Push and Pull type parser interfaces for both XML and HTML. It can do DTD validation at parse time, on a parsed document instance or with an arbitrary DTD. Libxml2 includes complete XPath, XPointer and Xinclude implementations. It also has a SAX like interface, which is designed to be compatible with Expat."
|
||||
HOMEPAGE = "http://www.xmlsoft.org/"
|
||||
HOMEPAGE = "https://gitlab.gnome.org/GNOME/libxml2"
|
||||
BUGTRACKER = "http://bugzilla.gnome.org/buglist.cgi?product=libxml2"
|
||||
SECTION = "libs"
|
||||
LICENSE = "MIT"
|
||||
@@ -11,8 +11,9 @@ LIC_FILES_CHKSUM = "file://Copyright;md5=2044417e2e5006b65a8b9067b683fcf1 \
|
||||
|
||||
DEPENDS = "zlib virtual/libiconv"
|
||||
|
||||
SRC_URI = "http://www.xmlsoft.org/sources/libxml2-${PV}.tar.gz;name=libtar \
|
||||
http://www.w3.org/XML/Test/xmlts20080827.tar.gz;subdir=${BP};name=testtar \
|
||||
inherit gnomebase
|
||||
|
||||
SRC_URI += "http://www.w3.org/XML/Test/xmlts20080827.tar.gz;subdir=${BP};name=testtar \
|
||||
file://libxml-64bit.patch \
|
||||
file://runtest.patch \
|
||||
file://run-ptest \
|
||||
@@ -27,10 +28,11 @@ SRC_URI = "http://www.xmlsoft.org/sources/libxml2-${PV}.tar.gz;name=libtar \
|
||||
file://CVE-2021-3537.patch \
|
||||
file://CVE-2021-3518.patch \
|
||||
file://CVE-2021-3541.patch \
|
||||
file://CVE-2022-23308.patch \
|
||||
file://CVE-2022-23308-fix-regression.patch \
|
||||
"
|
||||
|
||||
SRC_URI[libtar.md5sum] = "10942a1dc23137a8aa07f0639cbfece5"
|
||||
SRC_URI[libtar.sha256sum] = "aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f"
|
||||
SRC_URI[archive.sha256sum] = "593b7b751dd18c2d6abcd0c4bcb29efc203d0b4373a6df98e3a455ea74ae2813"
|
||||
SRC_URI[testtar.md5sum] = "ae3d1ebe000a3972afa104ca7f0e1b4a"
|
||||
SRC_URI[testtar.sha256sum] = "96151685cec997e1f9f3387e3626d61e6284d4d6e66e0e440c209286c03e9cc7"
|
||||
|
||||
|
||||
161
meta/recipes-core/util-linux/util-linux/CVE-2022-0563.patch
Normal file
161
meta/recipes-core/util-linux/util-linux/CVE-2022-0563.patch
Normal file
@@ -0,0 +1,161 @@
|
||||
From faa5a3a83ad0cb5e2c303edbfd8cd823c9d94c17 Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Thu, 10 Feb 2022 12:03:17 +0100
|
||||
Subject: [PATCH] chsh, chfn: remove readline support [CVE-2022-0563]
|
||||
|
||||
The readline library uses INPUTRC= environment variable to get a path
|
||||
to the library config file. When the library cannot parse the
|
||||
specified file, it prints an error message containing data from the
|
||||
file.
|
||||
|
||||
Unfortunately, the library does not use secure_getenv() (or a similar
|
||||
concept) to avoid vulnerabilities that could occur if set-user-ID or
|
||||
set-group-ID programs.
|
||||
|
||||
Reported-by: Rory Mackie <rory.mackie@trailofbits.com>
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
|
||||
Upstream-status: Backport
|
||||
https://github.com/util-linux/util-linux/commit/faa5a3a83ad0cb5e2c303edbfd8cd823c9d94c17
|
||||
|
||||
CVE: CVE-2022-0563
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
login-utils/Makemodule.am | 2 +-
|
||||
login-utils/chfn.c | 16 +++------------
|
||||
login-utils/chsh.c | 42 ++-------------------------------------
|
||||
3 files changed, 6 insertions(+), 54 deletions(-)
|
||||
|
||||
diff --git a/login-utils/Makemodule.am b/login-utils/Makemodule.am
|
||||
index fac5bfc..73636af 100644
|
||||
--- a/login-utils/Makemodule.am
|
||||
+++ b/login-utils/Makemodule.am
|
||||
@@ -82,7 +82,7 @@ chfn_chsh_sources = \
|
||||
login-utils/ch-common.c
|
||||
chfn_chsh_cflags = $(SUID_CFLAGS) $(AM_CFLAGS)
|
||||
chfn_chsh_ldflags = $(SUID_LDFLAGS) $(AM_LDFLAGS)
|
||||
-chfn_chsh_ldadd = libcommon.la $(READLINE_LIBS)
|
||||
+chfn_chsh_ldadd = libcommon.la
|
||||
|
||||
if CHFN_CHSH_PASSWORD
|
||||
chfn_chsh_ldadd += -lpam
|
||||
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
|
||||
index b739555..2f8e44a 100644
|
||||
--- a/login-utils/chfn.c
|
||||
+++ b/login-utils/chfn.c
|
||||
@@ -56,11 +56,6 @@
|
||||
# include "auth.h"
|
||||
#endif
|
||||
|
||||
-#ifdef HAVE_LIBREADLINE
|
||||
-# define _FUNCTION_DEF
|
||||
-# include <readline/readline.h>
|
||||
-#endif
|
||||
-
|
||||
struct finfo {
|
||||
char *full_name;
|
||||
char *office;
|
||||
@@ -229,22 +224,17 @@ static char *ask_new_field(struct chfn_control *ctl, const char *question,
|
||||
{
|
||||
int len;
|
||||
char *buf;
|
||||
-#ifndef HAVE_LIBREADLINE
|
||||
- size_t dummy = 0;
|
||||
-#endif
|
||||
|
||||
if (!def_val)
|
||||
def_val = "";
|
||||
+
|
||||
while (true) {
|
||||
printf("%s [%s]: ", question, def_val);
|
||||
__fpurge(stdin);
|
||||
-#ifdef HAVE_LIBREADLINE
|
||||
- rl_bind_key('\t', rl_insert);
|
||||
- if ((buf = readline(NULL)) == NULL)
|
||||
-#else
|
||||
+
|
||||
if (getline(&buf, &dummy, stdin) < 0)
|
||||
-#endif
|
||||
errx(EXIT_FAILURE, _("Aborted."));
|
||||
+
|
||||
/* remove white spaces from string end */
|
||||
ltrim_whitespace((unsigned char *) buf);
|
||||
len = rtrim_whitespace((unsigned char *) buf);
|
||||
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
|
||||
index a9ebec8..ee6ff87 100644
|
||||
--- a/login-utils/chsh.c
|
||||
+++ b/login-utils/chsh.c
|
||||
@@ -58,11 +58,6 @@
|
||||
# include "auth.h"
|
||||
#endif
|
||||
|
||||
-#ifdef HAVE_LIBREADLINE
|
||||
-# define _FUNCTION_DEF
|
||||
-# include <readline/readline.h>
|
||||
-#endif
|
||||
-
|
||||
struct sinfo {
|
||||
char *username;
|
||||
char *shell;
|
||||
@@ -121,33 +116,6 @@ static void print_shells(void)
|
||||
endusershell();
|
||||
}
|
||||
|
||||
-#ifdef HAVE_LIBREADLINE
|
||||
-static char *shell_name_generator(const char *text, int state)
|
||||
-{
|
||||
- static size_t len;
|
||||
- char *s;
|
||||
-
|
||||
- if (!state) {
|
||||
- setusershell();
|
||||
- len = strlen(text);
|
||||
- }
|
||||
-
|
||||
- while ((s = getusershell())) {
|
||||
- if (strncmp(s, text, len) == 0)
|
||||
- return xstrdup(s);
|
||||
- }
|
||||
- return NULL;
|
||||
-}
|
||||
-
|
||||
-static char **shell_name_completion(const char *text,
|
||||
- int start __attribute__((__unused__)),
|
||||
- int end __attribute__((__unused__)))
|
||||
-{
|
||||
- rl_attempted_completion_over = 1;
|
||||
- return rl_completion_matches(text, shell_name_generator);
|
||||
-}
|
||||
-#endif
|
||||
-
|
||||
/*
|
||||
* parse_argv () --
|
||||
* parse the command line arguments, and fill in "pinfo" with any
|
||||
@@ -198,20 +166,14 @@ static char *ask_new_shell(char *question, char *oldshell)
|
||||
{
|
||||
int len;
|
||||
char *ans = NULL;
|
||||
-#ifdef HAVE_LIBREADLINE
|
||||
- rl_attempted_completion_function = shell_name_completion;
|
||||
-#else
|
||||
size_t dummy = 0;
|
||||
-#endif
|
||||
+
|
||||
if (!oldshell)
|
||||
oldshell = "";
|
||||
printf("%s [%s]\n", question, oldshell);
|
||||
-#ifdef HAVE_LIBREADLINE
|
||||
- if ((ans = readline("> ")) == NULL)
|
||||
-#else
|
||||
if (getline(&ans, &dummy, stdin) < 0)
|
||||
-#endif
|
||||
return NULL;
|
||||
+
|
||||
/* remove the newline at the end of ans. */
|
||||
ltrim_whitespace((unsigned char *) ans);
|
||||
len = rtrim_whitespace((unsigned char *) ans);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -15,6 +15,7 @@ SRC_URI += "file://configure-sbindir.patch \
|
||||
file://include-strutils-cleanup-strto-functions.patch \
|
||||
file://CVE-2021-3995.patch \
|
||||
file://CVE-2021-3996.patch \
|
||||
file://CVE-2022-0563.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "7f64882f631225f0295ca05080cee1bf"
|
||||
SRC_URI[sha256sum] = "d9de3edd287366cd908e77677514b9387b22bc7b88f45b83e1922c3597f1d7f9"
|
||||
|
||||
347
meta/recipes-core/zlib/zlib/CVE-2018-25032.patch
Normal file
347
meta/recipes-core/zlib/zlib/CVE-2018-25032.patch
Normal file
@@ -0,0 +1,347 @@
|
||||
CVE: CVE-2018-25032
|
||||
Upstream-Status: Backport
|
||||
Signed-off-by: Ross Burton <ross.burton@arm.com>
|
||||
|
||||
From 5c44459c3b28a9bd3283aaceab7c615f8020c531 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Adler <madler@alumni.caltech.edu>
|
||||
Date: Tue, 17 Apr 2018 22:09:22 -0700
|
||||
Subject: [PATCH] Fix a bug that can crash deflate on some input when using
|
||||
Z_FIXED.
|
||||
|
||||
This bug was reported by Danilo Ramos of Eideticom, Inc. It has
|
||||
lain in wait 13 years before being found! The bug was introduced
|
||||
in zlib 1.2.2.2, with the addition of the Z_FIXED option. That
|
||||
option forces the use of fixed Huffman codes. For rare inputs with
|
||||
a large number of distant matches, the pending buffer into which
|
||||
the compressed data is written can overwrite the distance symbol
|
||||
table which it overlays. That results in corrupted output due to
|
||||
invalid distances, and can result in out-of-bound accesses,
|
||||
crashing the application.
|
||||
|
||||
The fix here combines the distance buffer and literal/length
|
||||
buffers into a single symbol buffer. Now three bytes of pending
|
||||
buffer space are opened up for each literal or length/distance
|
||||
pair consumed, instead of the previous two bytes. This assures
|
||||
that the pending buffer cannot overwrite the symbol table, since
|
||||
the maximum fixed code compressed length/distance is 31 bits, and
|
||||
since there are four bytes of pending space for every three bytes
|
||||
of symbol space.
|
||||
---
|
||||
deflate.c | 74 ++++++++++++++++++++++++++++++++++++++++---------------
|
||||
deflate.h | 25 +++++++++----------
|
||||
trees.c | 50 +++++++++++--------------------------
|
||||
3 files changed, 79 insertions(+), 70 deletions(-)
|
||||
|
||||
diff --git a/deflate.c b/deflate.c
|
||||
index 425babc00..19cba873a 100644
|
||||
--- a/deflate.c
|
||||
+++ b/deflate.c
|
||||
@@ -255,11 +255,6 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||
int wrap = 1;
|
||||
static const char my_version[] = ZLIB_VERSION;
|
||||
|
||||
- ushf *overlay;
|
||||
- /* We overlay pending_buf and d_buf+l_buf. This works since the average
|
||||
- * output size for (length,distance) codes is <= 24 bits.
|
||||
- */
|
||||
-
|
||||
if (version == Z_NULL || version[0] != my_version[0] ||
|
||||
stream_size != sizeof(z_stream)) {
|
||||
return Z_VERSION_ERROR;
|
||||
@@ -329,9 +324,47 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||
|
||||
s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
|
||||
|
||||
- overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
|
||||
- s->pending_buf = (uchf *) overlay;
|
||||
- s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
|
||||
+ /* We overlay pending_buf and sym_buf. This works since the average size
|
||||
+ * for length/distance pairs over any compressed block is assured to be 31
|
||||
+ * bits or less.
|
||||
+ *
|
||||
+ * Analysis: The longest fixed codes are a length code of 8 bits plus 5
|
||||
+ * extra bits, for lengths 131 to 257. The longest fixed distance codes are
|
||||
+ * 5 bits plus 13 extra bits, for distances 16385 to 32768. The longest
|
||||
+ * possible fixed-codes length/distance pair is then 31 bits total.
|
||||
+ *
|
||||
+ * sym_buf starts one-fourth of the way into pending_buf. So there are
|
||||
+ * three bytes in sym_buf for every four bytes in pending_buf. Each symbol
|
||||
+ * in sym_buf is three bytes -- two for the distance and one for the
|
||||
+ * literal/length. As each symbol is consumed, the pointer to the next
|
||||
+ * sym_buf value to read moves forward three bytes. From that symbol, up to
|
||||
+ * 31 bits are written to pending_buf. The closest the written pending_buf
|
||||
+ * bits gets to the next sym_buf symbol to read is just before the last
|
||||
+ * code is written. At that time, 31*(n-2) bits have been written, just
|
||||
+ * after 24*(n-2) bits have been consumed from sym_buf. sym_buf starts at
|
||||
+ * 8*n bits into pending_buf. (Note that the symbol buffer fills when n-1
|
||||
+ * symbols are written.) The closest the writing gets to what is unread is
|
||||
+ * then n+14 bits. Here n is lit_bufsize, which is 16384 by default, and
|
||||
+ * can range from 128 to 32768.
|
||||
+ *
|
||||
+ * Therefore, at a minimum, there are 142 bits of space between what is
|
||||
+ * written and what is read in the overlain buffers, so the symbols cannot
|
||||
+ * be overwritten by the compressed data. That space is actually 139 bits,
|
||||
+ * due to the three-bit fixed-code block header.
|
||||
+ *
|
||||
+ * That covers the case where either Z_FIXED is specified, forcing fixed
|
||||
+ * codes, or when the use of fixed codes is chosen, because that choice
|
||||
+ * results in a smaller compressed block than dynamic codes. That latter
|
||||
+ * condition then assures that the above analysis also covers all dynamic
|
||||
+ * blocks. A dynamic-code block will only be chosen to be emitted if it has
|
||||
+ * fewer bits than a fixed-code block would for the same set of symbols.
|
||||
+ * Therefore its average symbol length is assured to be less than 31. So
|
||||
+ * the compressed data for a dynamic block also cannot overwrite the
|
||||
+ * symbols from which it is being constructed.
|
||||
+ */
|
||||
+
|
||||
+ s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4);
|
||||
+ s->pending_buf_size = (ulg)s->lit_bufsize * 4;
|
||||
|
||||
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
|
||||
s->pending_buf == Z_NULL) {
|
||||
@@ -340,8 +373,12 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||
deflateEnd (strm);
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
- s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
|
||||
- s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
|
||||
+ s->sym_buf = s->pending_buf + s->lit_bufsize;
|
||||
+ s->sym_end = (s->lit_bufsize - 1) * 3;
|
||||
+ /* We avoid equality with lit_bufsize*3 because of wraparound at 64K
|
||||
+ * on 16 bit machines and because stored blocks are restricted to
|
||||
+ * 64K-1 bytes.
|
||||
+ */
|
||||
|
||||
s->level = level;
|
||||
s->strategy = strategy;
|
||||
@@ -552,7 +589,7 @@ int ZEXPORT deflatePrime (strm, bits, value)
|
||||
|
||||
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
s = strm->state;
|
||||
- if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
|
||||
+ if (s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
|
||||
return Z_BUF_ERROR;
|
||||
do {
|
||||
put = Buf_size - s->bi_valid;
|
||||
@@ -1113,7 +1150,6 @@ int ZEXPORT deflateCopy (dest, source)
|
||||
#else
|
||||
deflate_state *ds;
|
||||
deflate_state *ss;
|
||||
- ushf *overlay;
|
||||
|
||||
|
||||
if (deflateStateCheck(source) || dest == Z_NULL) {
|
||||
@@ -1133,8 +1169,7 @@ int ZEXPORT deflateCopy (dest, source)
|
||||
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
|
||||
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
|
||||
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
|
||||
- overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
|
||||
- ds->pending_buf = (uchf *) overlay;
|
||||
+ ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
|
||||
|
||||
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
|
||||
ds->pending_buf == Z_NULL) {
|
||||
@@ -1148,8 +1183,7 @@ int ZEXPORT deflateCopy (dest, source)
|
||||
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
|
||||
|
||||
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
|
||||
- ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
|
||||
- ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
|
||||
+ ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
|
||||
|
||||
ds->l_desc.dyn_tree = ds->dyn_ltree;
|
||||
ds->d_desc.dyn_tree = ds->dyn_dtree;
|
||||
@@ -1925,7 +1959,7 @@ local block_state deflate_fast(s, flush)
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
- if (s->last_lit)
|
||||
+ if (s->sym_next)
|
||||
FLUSH_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
@@ -2056,7 +2090,7 @@ local block_state deflate_slow(s, flush)
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
- if (s->last_lit)
|
||||
+ if (s->sym_next)
|
||||
FLUSH_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
@@ -2131,7 +2165,7 @@ local block_state deflate_rle(s, flush)
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
- if (s->last_lit)
|
||||
+ if (s->sym_next)
|
||||
FLUSH_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
@@ -2170,7 +2204,7 @@ local block_state deflate_huff(s, flush)
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
- if (s->last_lit)
|
||||
+ if (s->sym_next)
|
||||
FLUSH_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
diff --git a/deflate.h b/deflate.h
|
||||
index 23ecdd312..d4cf1a98b 100644
|
||||
--- a/deflate.h
|
||||
+++ b/deflate.h
|
||||
@@ -217,7 +217,7 @@ typedef struct internal_state {
|
||||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||
*/
|
||||
|
||||
- uchf *l_buf; /* buffer for literals or lengths */
|
||||
+ uchf *sym_buf; /* buffer for distances and literals/lengths */
|
||||
|
||||
uInt lit_bufsize;
|
||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||
@@ -239,13 +239,8 @@ typedef struct internal_state {
|
||||
* - I can't count above 4
|
||||
*/
|
||||
|
||||
- uInt last_lit; /* running index in l_buf */
|
||||
-
|
||||
- ushf *d_buf;
|
||||
- /* Buffer for distances. To simplify the code, d_buf and l_buf have
|
||||
- * the same number of elements. To use different lengths, an extra flag
|
||||
- * array would be necessary.
|
||||
- */
|
||||
+ uInt sym_next; /* running index in sym_buf */
|
||||
+ uInt sym_end; /* symbol table full when sym_next reaches this */
|
||||
|
||||
ulg opt_len; /* bit length of current block with optimal trees */
|
||||
ulg static_len; /* bit length of current block with static trees */
|
||||
@@ -325,20 +320,22 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
||||
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
- s->d_buf[s->last_lit] = 0; \
|
||||
- s->l_buf[s->last_lit++] = cc; \
|
||||
+ s->sym_buf[s->sym_next++] = 0; \
|
||||
+ s->sym_buf[s->sym_next++] = 0; \
|
||||
+ s->sym_buf[s->sym_next++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
- flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
+ flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (uch)(length); \
|
||||
ush dist = (ush)(distance); \
|
||||
- s->d_buf[s->last_lit] = dist; \
|
||||
- s->l_buf[s->last_lit++] = len; \
|
||||
+ s->sym_buf[s->sym_next++] = dist; \
|
||||
+ s->sym_buf[s->sym_next++] = dist >> 8; \
|
||||
+ s->sym_buf[s->sym_next++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
- flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
+ flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||
diff --git a/trees.c b/trees.c
|
||||
index 4f4a65011..decaeb7c3 100644
|
||||
--- a/trees.c
|
||||
+++ b/trees.c
|
||||
@@ -416,7 +416,7 @@ local void init_block(s)
|
||||
|
||||
s->dyn_ltree[END_BLOCK].Freq = 1;
|
||||
s->opt_len = s->static_len = 0L;
|
||||
- s->last_lit = s->matches = 0;
|
||||
+ s->sym_next = s->matches = 0;
|
||||
}
|
||||
|
||||
#define SMALLEST 1
|
||||
@@ -948,7 +948,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||
|
||||
Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
|
||||
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
||||
- s->last_lit));
|
||||
+ s->sym_next / 3));
|
||||
|
||||
if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
|
||||
|
||||
@@ -1017,8 +1017,9 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
||||
unsigned dist; /* distance of matched string */
|
||||
unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
||||
{
|
||||
- s->d_buf[s->last_lit] = (ush)dist;
|
||||
- s->l_buf[s->last_lit++] = (uch)lc;
|
||||
+ s->sym_buf[s->sym_next++] = dist;
|
||||
+ s->sym_buf[s->sym_next++] = dist >> 8;
|
||||
+ s->sym_buf[s->sym_next++] = lc;
|
||||
if (dist == 0) {
|
||||
/* lc is the unmatched char */
|
||||
s->dyn_ltree[lc].Freq++;
|
||||
@@ -1033,30 +1034,7 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
||||
s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
|
||||
s->dyn_dtree[d_code(dist)].Freq++;
|
||||
}
|
||||
-
|
||||
-#ifdef TRUNCATE_BLOCK
|
||||
- /* Try to guess if it is profitable to stop the current block here */
|
||||
- if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
|
||||
- /* Compute an upper bound for the compressed length */
|
||||
- ulg out_length = (ulg)s->last_lit*8L;
|
||||
- ulg in_length = (ulg)((long)s->strstart - s->block_start);
|
||||
- int dcode;
|
||||
- for (dcode = 0; dcode < D_CODES; dcode++) {
|
||||
- out_length += (ulg)s->dyn_dtree[dcode].Freq *
|
||||
- (5L+extra_dbits[dcode]);
|
||||
- }
|
||||
- out_length >>= 3;
|
||||
- Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
|
||||
- s->last_lit, in_length, out_length,
|
||||
- 100L - out_length*100L/in_length));
|
||||
- if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
|
||||
- }
|
||||
-#endif
|
||||
- return (s->last_lit == s->lit_bufsize-1);
|
||||
- /* We avoid equality with lit_bufsize because of wraparound at 64K
|
||||
- * on 16 bit machines and because stored blocks are restricted to
|
||||
- * 64K-1 bytes.
|
||||
- */
|
||||
+ return (s->sym_next == s->sym_end);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
@@ -1069,13 +1047,14 @@ local void compress_block(s, ltree, dtree)
|
||||
{
|
||||
unsigned dist; /* distance of matched string */
|
||||
int lc; /* match length or unmatched char (if dist == 0) */
|
||||
- unsigned lx = 0; /* running index in l_buf */
|
||||
+ unsigned sx = 0; /* running index in sym_buf */
|
||||
unsigned code; /* the code to send */
|
||||
int extra; /* number of extra bits to send */
|
||||
|
||||
- if (s->last_lit != 0) do {
|
||||
- dist = s->d_buf[lx];
|
||||
- lc = s->l_buf[lx++];
|
||||
+ if (s->sym_next != 0) do {
|
||||
+ dist = s->sym_buf[sx++] & 0xff;
|
||||
+ dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
|
||||
+ lc = s->sym_buf[sx++];
|
||||
if (dist == 0) {
|
||||
send_code(s, lc, ltree); /* send a literal byte */
|
||||
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
||||
@@ -1100,11 +1079,10 @@ local void compress_block(s, ltree, dtree)
|
||||
}
|
||||
} /* literal or match pair ? */
|
||||
|
||||
- /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
|
||||
- Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
|
||||
- "pendingBuf overflow");
|
||||
+ /* Check that the overlay between pending_buf and sym_buf is ok: */
|
||||
+ Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
|
||||
|
||||
- } while (lx < s->last_lit);
|
||||
+ } while (sx < s->sym_next);
|
||||
|
||||
send_code(s, END_BLOCK, ltree);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ LIC_FILES_CHKSUM = "file://zlib.h;beginline=6;endline=23;md5=5377232268e952e9ef6
|
||||
|
||||
SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/${BPN}/${PV}/${BPN}-${PV}.tar.xz \
|
||||
file://ldflags-tests.patch \
|
||||
file://CVE-2018-25032.patch \
|
||||
file://run-ptest \
|
||||
"
|
||||
UPSTREAM_CHECK_URI = "http://zlib.net/"
|
||||
|
||||
@@ -18,6 +18,7 @@ SRC_URI = "https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/${BPN}/${P
|
||||
file://0001-environment.mak-musl-based-systems-can-generate-shar.patch \
|
||||
file://0001-apt-1.2.12-Fix-musl-build.patch \
|
||||
file://0001-Include-array.h-for-std-array.patch \
|
||||
file://CVE-2020-3810.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "d30eed9304e82ea8238c854b5c5a34d9"
|
||||
SRC_URI[sha256sum] = "03ded4f5e9b8d43ecec083704b2dcabf20c182ed382db9ac7251da0b0b038059"
|
||||
@@ -36,5 +37,9 @@ do_configure_prepend() {
|
||||
rm -rf ${S}/buildlib/config.guess
|
||||
}
|
||||
|
||||
# there are code generation issues with some compilers in the SHA256 implementation
|
||||
# turn off strict-aliasing to avoid these issues
|
||||
CXXFLAGS:append = " -fno-strict-aliasing"
|
||||
|
||||
USERADD_PACKAGES = "${PN}"
|
||||
USERADD_PARAM_${PN} = "--system --no-create-home --home-dir /nonexistent --shell /bin/false --user-group _apt"
|
||||
|
||||
174
meta/recipes-devtools/apt/apt/CVE-2020-3810.patch
Normal file
174
meta/recipes-devtools/apt/apt/CVE-2020-3810.patch
Normal file
@@ -0,0 +1,174 @@
|
||||
From dceb1e49e4b8e4dadaf056be34088b415939cda6 Mon Sep 17 00:00:00 2001
|
||||
From: Julian Andres Klode <julian.klode@canonical.com>
|
||||
Date: Tue, 12 May 2020 11:49:09 +0200
|
||||
Subject: [PATCH] SECURITY UPDATE: Fix out of bounds read in .ar and .tar
|
||||
implementation (CVE-2020-3810)
|
||||
|
||||
When normalizing ar member names by removing trailing whitespace
|
||||
and slashes, an out-out-bound read can be caused if the ar member
|
||||
name consists only of such characters, because the code did not
|
||||
stop at 0, but would wrap around and continue reading from the
|
||||
stack, without any limit.
|
||||
|
||||
Add a check to abort if we reached the first character in the
|
||||
name, effectively rejecting the use of names consisting just
|
||||
of slashes and spaces.
|
||||
|
||||
Furthermore, certain error cases in arfile.cc and extracttar.cc have
|
||||
included member names in the output that were not checked at all and
|
||||
might hence not be nul terminated, leading to further out of bound reads.
|
||||
|
||||
Fixes Debian/apt#111
|
||||
LP: #1878177
|
||||
|
||||
CVE: CVE-2020-3810
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://salsa.debian.org/apt-team/apt/-/commit/dceb1e49e4b8e4dadaf056be34088b415939cda6
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
apt-inst/contrib/arfile.cc | 11 ++-
|
||||
apt-inst/contrib/extracttar.cc | 2 +-
|
||||
.../test-github-111-invalid-armember | 88 +++++++++++++++++++
|
||||
3 files changed, 98 insertions(+), 3 deletions(-)
|
||||
create mode 100755 test/integration/test-github-111-invalid-armember
|
||||
|
||||
diff --git a/apt-inst/contrib/arfile.cc b/st/contrib/arfile.cc
|
||||
index 3fc3afedb..5cb43c690 100644
|
||||
--- a/apt-inst/contrib/arfile.cc
|
||||
+++ b/apt-inst/contrib/arfile.cc
|
||||
@@ -92,7 +92,7 @@ bool ARArchive::LoadHeaders()
|
||||
StrToNum(Head.Size,Memb->Size,sizeof(Head.Size)) == false)
|
||||
{
|
||||
delete Memb;
|
||||
- return _error->Error(_("Invalid archive member header %s"), Head.Name);
|
||||
+ return _error->Error(_("Invalid archive member header"));
|
||||
}
|
||||
|
||||
// Check for an extra long name string
|
||||
@@ -119,7 +119,14 @@ bool ARArchive::LoadHeaders()
|
||||
else
|
||||
{
|
||||
unsigned int I = sizeof(Head.Name) - 1;
|
||||
- for (; Head.Name[I] == ' ' || Head.Name[I] == '/'; I--);
|
||||
+ for (; Head.Name[I] == ' ' || Head.Name[I] == '/'; I--)
|
||||
+ {
|
||||
+ if (I == 0)
|
||||
+ {
|
||||
+ delete Memb;
|
||||
+ return _error->Error(_("Invalid archive member header"));
|
||||
+ }
|
||||
+ }
|
||||
Memb->Name = std::string(Head.Name,I+1);
|
||||
}
|
||||
|
||||
diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc
|
||||
index 9bb0a55c0..b22f59dbc 100644
|
||||
--- a/apt-inst/contrib/extracttar.cc
|
||||
+++ b/apt-inst/contrib/extracttar.cc
|
||||
@@ -254,7 +254,7 @@ bool ExtractTar::Go(pkgDirStream &Stream)
|
||||
|
||||
default:
|
||||
BadRecord = true;
|
||||
- _error->Warning(_("Unknown TAR header type %u, member %s"),(unsigned)Tar->LinkFlag,Tar->Name);
|
||||
+ _error->Warning(_("Unknown TAR header type %u"), (unsigned)Tar->LinkFlag);
|
||||
break;
|
||||
}
|
||||
|
||||
diff --git a/test/integration/test-github-111-invalid-armember b/test/integration/test-github-111-invalid-armember
|
||||
new file mode 100755
|
||||
index 000000000..ec2163bf6
|
||||
--- /dev/null
|
||||
+++ b/test/integration/test-github-111-invalid-armember
|
||||
@@ -0,0 +1,88 @@
|
||||
+#!/bin/sh
|
||||
+set -e
|
||||
+
|
||||
+TESTDIR="$(readlink -f "$(dirname "$0")")"
|
||||
+. "$TESTDIR/framework"
|
||||
+setupenvironment
|
||||
+configarchitecture "amd64"
|
||||
+setupaptarchive
|
||||
+
|
||||
+# this used to crash, but it should treat it as an invalid member header
|
||||
+touch ' '
|
||||
+ar -q test.deb ' '
|
||||
+testsuccessequal "E: Invalid archive member header" ${BUILDDIRECTORY}/../test/interactive-helper/testdeb test.deb
|
||||
+
|
||||
+
|
||||
+rm test.deb
|
||||
+touch 'x'
|
||||
+ar -q test.deb 'x'
|
||||
+testsuccessequal "E: This is not a valid DEB archive, missing 'debian-binary' member" ${BUILDDIRECTORY}/../test/interactive-helper/testdeb test.deb
|
||||
+
|
||||
+
|
||||
+# <name><size> [ other fields] - name is not nul terminated here, it ends in .
|
||||
+msgmsg "Unterminated ar member name"
|
||||
+printf '!<arch>\0120123456789ABCDE.A123456789A.01234.01234.0123456.012345678.0.' > test.deb
|
||||
+testsuccessequal "E: Invalid archive member header" ${BUILDDIRECTORY}/../test/interactive-helper/testdeb test.deb
|
||||
+
|
||||
+
|
||||
+# unused source code for generating $tar below
|
||||
+maketar() {
|
||||
+ cat > maketar.c << EOF
|
||||
+ #include <stdio.h>
|
||||
+ #include <string.h>
|
||||
+ struct tar {
|
||||
+ char Name[100];
|
||||
+ char Mode[8];
|
||||
+ char UserID[8];
|
||||
+ char GroupID[8];
|
||||
+ char Size[12];
|
||||
+ char MTime[12];
|
||||
+ char Checksum[8];
|
||||
+ char LinkFlag;
|
||||
+ char LinkName[100];
|
||||
+ char MagicNumber[8];
|
||||
+ char UserName[32];
|
||||
+ char GroupName[32];
|
||||
+ char Major[8];
|
||||
+ char Minor[8];
|
||||
+ };
|
||||
+
|
||||
+ int main(void)
|
||||
+ {
|
||||
+ union {
|
||||
+ struct tar t;
|
||||
+ char buf[512];
|
||||
+ } t;
|
||||
+ for (int i = 0; i < sizeof(t.buf); i++)
|
||||
+ t.buf[i] = '7';
|
||||
+ memcpy(t.t.Name, "unterminatedName", 16);
|
||||
+ memcpy(t.t.UserName, "userName", 8);
|
||||
+ memcpy(t.t.GroupName, "thisIsAGroupNamethisIsAGroupName", 32);
|
||||
+ t.t.LinkFlag = 'X'; // I AM BROKEN
|
||||
+ memcpy(t.t.Size, "000000000000", sizeof(t.t.Size));
|
||||
+ memset(t.t.Checksum,' ',sizeof(t.t.Checksum));
|
||||
+
|
||||
+ unsigned long sum = 0;
|
||||
+ for (int i = 0; i < sizeof(t.buf); i++)
|
||||
+ sum += t.buf[i];
|
||||
+
|
||||
+ int written = sprintf(t.t.Checksum, "%lo", sum);
|
||||
+ for (int i = written; i < sizeof(t.t.Checksum); i++)
|
||||
+ t.t.Checksum[i] = ' ';
|
||||
+ fwrite(t.buf, sizeof(t.buf), 1, stdout);
|
||||
+ }
|
||||
+EOF
|
||||
+
|
||||
+ gcc maketar.c -o maketar -Wall
|
||||
+ ./maketar
|
||||
+}
|
||||
+
|
||||
+
|
||||
+#
|
||||
+tar="unterminatedName77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777700000000000077777777777773544 X777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777userName777777777777777777777777thisIsAGroupNamethisIsAGroupName777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777"
|
||||
+printf '%s' "$tar" | gzip > control.tar.gz
|
||||
+cp control.tar.gz data.tar.gz
|
||||
+touch debian-binary
|
||||
+rm test.deb
|
||||
+ar -q test.deb debian-binary control.tar.gz data.tar.gz
|
||||
+testsuccessequal "W: Unknown TAR header type 88" ${BUILDDIRECTORY}/../test/interactive-helper/testdeb test.deb
|
||||
--
|
||||
GitLab
|
||||
@@ -1,305 +0,0 @@
|
||||
From 0e9cef2414f0df3fa5b9b56ff9072aa122bef29c Mon Sep 17 00:00:00 2001
|
||||
From: Minjae Kim <flowrgom@gmail.com>
|
||||
Date: Sat, 27 Mar 2021 15:18:46 +0900
|
||||
Subject: [PATCH] checkout: fix bug that makes checkout follow symlinks in
|
||||
leading path
|
||||
|
||||
Before checking out a file, we have to confirm that all of its leading
|
||||
components are real existing directories. And to reduce the number of
|
||||
lstat() calls in this process, we cache the last leading path known to
|
||||
contain only directories. However, when a path collision occurs (e.g.
|
||||
when checking out case-sensitive files in case-insensitive file
|
||||
systems), a cached path might have its file type changed on disk,
|
||||
leaving the cache on an invalid state. Normally, this doesn't bring
|
||||
any bad consequences as we usually check out files in index order, and
|
||||
therefore, by the time the cached path becomes outdated, we no longer
|
||||
need it anyway (because all files in that directory would have already
|
||||
been written).
|
||||
|
||||
But, there are some users of the checkout machinery that do not always
|
||||
follow the index order. In particular: checkout-index writes the paths
|
||||
in the same order that they appear on the CLI (or stdin); and the
|
||||
delayed checkout feature -- used when a long-running filter process
|
||||
replies with "status=delayed" -- postpones the checkout of some entries,
|
||||
thus modifying the checkout order.
|
||||
|
||||
When we have to check out an out-of-order entry and the lstat() cache is
|
||||
invalid (due to a previous path collision), checkout_entry() may end up
|
||||
using the invalid data and thrusting that the leading components are
|
||||
real directories when, in reality, they are not. In the best case
|
||||
scenario, where the directory was replaced by a regular file, the user
|
||||
will get an error: "fatal: unable to create file 'foo/bar': Not a
|
||||
directory". But if the directory was replaced by a symlink, checkout
|
||||
could actually end up following the symlink and writing the file at a
|
||||
wrong place, even outside the repository. Since delayed checkout is
|
||||
affected by this bug, it could be used by an attacker to write
|
||||
arbitrary files during the clone of a maliciously crafted repository.
|
||||
|
||||
Some candidate solutions considered were to disable the lstat() cache
|
||||
during unordered checkouts or sort the entries before passing them to
|
||||
the checkout machinery. But both ideas include some performance penalty
|
||||
and they don't future-proof the code against new unordered use cases.
|
||||
|
||||
Instead, we now manually reset the lstat cache whenever we successfully
|
||||
remove a directory. Note: We are not even checking whether the directory
|
||||
was the same as the lstat cache points to because we might face a
|
||||
scenario where the paths refer to the same location but differ due to
|
||||
case folding, precomposed UTF-8 issues, or the presence of `..`
|
||||
components in the path. Two regression tests, with case-collisions and
|
||||
utf8-collisions, are also added for both checkout-index and delayed
|
||||
checkout.
|
||||
|
||||
Note: to make the previously mentioned clone attack unfeasible, it would
|
||||
be sufficient to reset the lstat cache only after the remove_subtree()
|
||||
call inside checkout_entry(). This is the place where we would remove a
|
||||
directory whose path collides with the path of another entry that we are
|
||||
currently trying to check out (possibly a symlink). However, in the
|
||||
interest of a thorough fix that does not leave Git open to
|
||||
similar-but-not-identical attack vectors, we decided to intercept
|
||||
all `rmdir()` calls in one fell swoop.
|
||||
|
||||
This addresses CVE-2021-21300.
|
||||
|
||||
Co-authored-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
||||
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
|
||||
|
||||
Upstream-Status: Acepted [https://github.com/git/git/commit/684dd4c2b414bcf648505e74498a608f28de4592]
|
||||
CVE: CVE-2021-21300
|
||||
Signed-off-by: Minjae Kim <flowergom@gmail.com>
|
||||
---
|
||||
cache.h | 1 +
|
||||
compat/mingw.c | 2 ++
|
||||
git-compat-util.h | 5 +++++
|
||||
symlinks.c | 25 +++++++++++++++++++++
|
||||
t/t0021-conversion.sh | 39 ++++++++++++++++++++++++++++++++
|
||||
t/t0021/rot13-filter.pl | 21 ++++++++++++++---
|
||||
t/t2006-checkout-index-basic.sh | 40 +++++++++++++++++++++++++++++++++
|
||||
7 files changed, 130 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/cache.h b/cache.h
|
||||
index 04cabaa..dda373f 100644
|
||||
--- a/cache.h
|
||||
+++ b/cache.h
|
||||
@@ -1675,6 +1675,7 @@ int has_symlink_leading_path(const char *name, int len);
|
||||
int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
|
||||
int check_leading_path(const char *name, int len);
|
||||
int has_dirs_only_path(const char *name, int len, int prefix_len);
|
||||
+extern void invalidate_lstat_cache(void);
|
||||
void schedule_dir_for_removal(const char *name, int len);
|
||||
void remove_scheduled_dirs(void);
|
||||
|
||||
diff --git a/compat/mingw.c b/compat/mingw.c
|
||||
index bd24d91..cea9c72 100644
|
||||
--- a/compat/mingw.c
|
||||
+++ b/compat/mingw.c
|
||||
@@ -340,6 +340,8 @@ int mingw_rmdir(const char *pathname)
|
||||
ask_yes_no_if_possible("Deletion of directory '%s' failed. "
|
||||
"Should I try again?", pathname))
|
||||
ret = _wrmdir(wpathname);
|
||||
+ if (!ret)
|
||||
+ invalidate_lstat_cache();
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/git-compat-util.h b/git-compat-util.h
|
||||
index d0dd9c0..a1ecfd3 100644
|
||||
--- a/git-compat-util.h
|
||||
+++ b/git-compat-util.h
|
||||
@@ -365,6 +365,11 @@ static inline int noop_core_config(const char *var, const char *value, void *cb)
|
||||
#define platform_core_config noop_core_config
|
||||
#endif
|
||||
|
||||
+int lstat_cache_aware_rmdir(const char *path);
|
||||
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||
+#define rmdir lstat_cache_aware_rmdir
|
||||
+#endif
|
||||
+
|
||||
#ifndef has_dos_drive_prefix
|
||||
static inline int git_has_dos_drive_prefix(const char *path)
|
||||
{
|
||||
diff --git a/symlinks.c b/symlinks.c
|
||||
index 69d458a..ae3c665 100644
|
||||
--- a/symlinks.c
|
||||
+++ b/symlinks.c
|
||||
@@ -267,6 +267,13 @@ int has_dirs_only_path(const char *name, int len, int prefix_len)
|
||||
*/
|
||||
static int threaded_has_dirs_only_path(struct cache_def *cache, const char *name, int len, int prefix_len)
|
||||
{
|
||||
+ /*
|
||||
+ * Note: this function is used by the checkout machinery, which also
|
||||
+ * takes care to properly reset the cache when it performs an operation
|
||||
+ * that would leave the cache outdated. If this function starts caching
|
||||
+ * anything else besides FL_DIR, remember to also invalidate the cache
|
||||
+ * when creating or deleting paths that might be in the cache.
|
||||
+ */
|
||||
return lstat_cache(cache, name, len,
|
||||
FL_DIR|FL_FULLPATH, prefix_len) &
|
||||
FL_DIR;
|
||||
@@ -321,3 +328,21 @@ void remove_scheduled_dirs(void)
|
||||
{
|
||||
do_remove_scheduled_dirs(0);
|
||||
}
|
||||
+
|
||||
+
|
||||
+void invalidate_lstat_cache(void)
|
||||
+{
|
||||
+ reset_lstat_cache(&default_cache);
|
||||
+}
|
||||
+
|
||||
+#undef rmdir
|
||||
+int lstat_cache_aware_rmdir(const char *path)
|
||||
+{
|
||||
+ /* Any change in this function must be made also in `mingw_rmdir()` */
|
||||
+ int ret = rmdir(path);
|
||||
+
|
||||
+ if (!ret)
|
||||
+ invalidate_lstat_cache();
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
|
||||
index c954c70..6a1d5f6 100755
|
||||
--- a/t/t0021-conversion.sh
|
||||
+++ b/t/t0021-conversion.sh
|
||||
@@ -820,4 +820,43 @@ test_expect_success PERL 'invalid file in delayed checkout' '
|
||||
grep "error: external filter .* signaled that .unfiltered. is now available although it has not been delayed earlier" git-stderr.log
|
||||
'
|
||||
|
||||
+for mode in 'case' 'utf-8'
|
||||
+do
|
||||
+ case "$mode" in
|
||||
+ case) dir='A' symlink='a' mode_prereq='CASE_INSENSITIVE_FS' ;;
|
||||
+ utf-8)
|
||||
+ dir=$(printf "\141\314\210") symlink=$(printf "\303\244")
|
||||
+ mode_prereq='UTF8_NFD_TO_NFC' ;;
|
||||
+ esac
|
||||
+
|
||||
+ test_expect_success PERL,SYMLINKS,$mode_prereq \
|
||||
+ "delayed checkout with $mode-collision don't write to the wrong place" '
|
||||
+ test_config_global filter.delay.process \
|
||||
+ "\"$TEST_ROOT/rot13-filter.pl\" --always-delay delayed.log clean smudge delay" &&
|
||||
+ test_config_global filter.delay.required true &&
|
||||
+ git init $mode-collision &&
|
||||
+ (
|
||||
+ cd $mode-collision &&
|
||||
+ mkdir target-dir &&
|
||||
+ empty_oid=$(printf "" | git hash-object -w --stdin) &&
|
||||
+ symlink_oid=$(printf "%s" "$PWD/target-dir" | git hash-object -w --stdin) &&
|
||||
+ attr_oid=$(echo "$dir/z filter=delay" | git hash-object -w --stdin) &&
|
||||
+ cat >objs <<-EOF &&
|
||||
+ 100644 blob $empty_oid $dir/x
|
||||
+ 100644 blob $empty_oid $dir/y
|
||||
+ 100644 blob $empty_oid $dir/z
|
||||
+ 120000 blob $symlink_oid $symlink
|
||||
+ 100644 blob $attr_oid .gitattributes
|
||||
+ EOF
|
||||
+ git update-index --index-info <objs &&
|
||||
+ git commit -m "test commit"
|
||||
+ ) &&
|
||||
+ git clone $mode-collision $mode-collision-cloned &&
|
||||
+ # Make sure z was really delayed
|
||||
+ grep "IN: smudge $dir/z .* \\[DELAYED\\]" $mode-collision-cloned/delayed.log &&
|
||||
+ # Should not create $dir/z at $symlink/z
|
||||
+ test_path_is_missing $mode-collision/target-dir/z
|
||||
+ '
|
||||
+done
|
||||
+
|
||||
test_done
|
||||
diff --git a/t/t0021/rot13-filter.pl b/t/t0021/rot13-filter.pl
|
||||
index 4701072..007f2d7 100644
|
||||
--- a/t/t0021/rot13-filter.pl
|
||||
+++ b/t/t0021/rot13-filter.pl
|
||||
@@ -2,9 +2,15 @@
|
||||
# Example implementation for the Git filter protocol version 2
|
||||
# See Documentation/gitattributes.txt, section "Filter Protocol"
|
||||
#
|
||||
-# The first argument defines a debug log file that the script write to.
|
||||
-# All remaining arguments define a list of supported protocol
|
||||
-# capabilities ("clean", "smudge", etc).
|
||||
+# Usage: rot13-filter.pl [--always-delay] <log path> <capabilities>
|
||||
+#
|
||||
+# Log path defines a debug log file that the script writes to. The
|
||||
+# subsequent arguments define a list of supported protocol capabilities
|
||||
+# ("clean", "smudge", etc).
|
||||
+#
|
||||
+# When --always-delay is given all pathnames with the "can-delay" flag
|
||||
+# that don't appear on the list bellow are delayed with a count of 1
|
||||
+# (see more below).
|
||||
#
|
||||
# This implementation supports special test cases:
|
||||
# (1) If data with the pathname "clean-write-fail.r" is processed with
|
||||
@@ -53,6 +59,13 @@ sub gitperllib {
|
||||
use Git::Packet;
|
||||
|
||||
my $MAX_PACKET_CONTENT_SIZE = 65516;
|
||||
+
|
||||
+my $always_delay = 0;
|
||||
+if ( $ARGV[0] eq '--always-delay' ) {
|
||||
+ $always_delay = 1;
|
||||
+ shift @ARGV;
|
||||
+}
|
||||
+
|
||||
my $log_file = shift @ARGV;
|
||||
my @capabilities = @ARGV;
|
||||
|
||||
@@ -134,6 +147,8 @@ sub rot13 {
|
||||
if ( $buffer eq "can-delay=1" ) {
|
||||
if ( exists $DELAY{$pathname} and $DELAY{$pathname}{"requested"} == 0 ) {
|
||||
$DELAY{$pathname}{"requested"} = 1;
|
||||
+ } elsif ( !exists $DELAY{$pathname} and $always_delay ) {
|
||||
+ $DELAY{$pathname} = { "requested" => 1, "count" => 1 };
|
||||
}
|
||||
} else {
|
||||
die "Unknown message '$buffer'";
|
||||
diff --git a/t/t2006-checkout-index-basic.sh b/t/t2006-checkout-index-basic.sh
|
||||
index 57cbdfe..f223a02 100755
|
||||
--- a/t/t2006-checkout-index-basic.sh
|
||||
+++ b/t/t2006-checkout-index-basic.sh
|
||||
@@ -21,4 +21,44 @@ test_expect_success 'checkout-index -h in broken repository' '
|
||||
test_i18ngrep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
+for mode in 'case' 'utf-8'
|
||||
+do
|
||||
+ case "$mode" in
|
||||
+ case) dir='A' symlink='a' mode_prereq='CASE_INSENSITIVE_FS' ;;
|
||||
+ utf-8)
|
||||
+ dir=$(printf "\141\314\210") symlink=$(printf "\303\244")
|
||||
+ mode_prereq='UTF8_NFD_TO_NFC' ;;
|
||||
+ esac
|
||||
+
|
||||
+ test_expect_success SYMLINKS,$mode_prereq \
|
||||
+ "checkout-index with $mode-collision don't write to the wrong place" '
|
||||
+ git init $mode-collision &&
|
||||
+ (
|
||||
+ cd $mode-collision &&
|
||||
+ mkdir target-dir &&
|
||||
+ empty_obj_hex=$(git hash-object -w --stdin </dev/null) &&
|
||||
+ symlink_hex=$(printf "%s" "$PWD/target-dir" | git hash-object -w --stdin) &&
|
||||
+ cat >objs <<-EOF &&
|
||||
+ 100644 blob ${empty_obj_hex} ${dir}/x
|
||||
+ 100644 blob ${empty_obj_hex} ${dir}/y
|
||||
+ 100644 blob ${empty_obj_hex} ${dir}/z
|
||||
+ 120000 blob ${symlink_hex} ${symlink}
|
||||
+ EOF
|
||||
+ git update-index --index-info <objs &&
|
||||
+ # Note: the order is important here to exercise the
|
||||
+ # case where the file at ${dir} has its type changed by
|
||||
+ # the time Git tries to check out ${dir}/z.
|
||||
+ #
|
||||
+ # Also, we use core.precomposeUnicode=false because we
|
||||
+ # want Git to treat the UTF-8 paths transparently on
|
||||
+ # Mac OS, matching what is in the index.
|
||||
+ #
|
||||
+ git -c core.precomposeUnicode=false checkout-index -f \
|
||||
+ ${dir}/x ${dir}/y ${symlink} ${dir}/z &&
|
||||
+ # Should not create ${dir}/z at ${symlink}/z
|
||||
+ test_path_is_missing target-dir/z
|
||||
+ )
|
||||
+ '
|
||||
+done
|
||||
+
|
||||
test_done
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -9,7 +9,6 @@ PROVIDES_append_class-native = " git-replacement-native"
|
||||
|
||||
SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \
|
||||
${KERNELORG_MIRROR}/software/scm/git/git-manpages-${PV}.tar.gz;name=manpages \
|
||||
file://CVE-2021-21300.patch \
|
||||
file://fixsort.patch \
|
||||
file://CVE-2021-40330.patch \
|
||||
"
|
||||
@@ -20,6 +19,11 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=7c0d7ef03a7eb04ce795b0f60e68e7e1"
|
||||
|
||||
CVE_PRODUCT = "git-scm:git"
|
||||
|
||||
# This is about a manpage not mentioning --mirror may "leak" information
|
||||
# in mirrored git repos. Most OE users wouldn't build the docs and
|
||||
# we don't see this as a major issue for our general users/usecases.
|
||||
CVE_CHECK_IGNORE += "CVE-2022-24975"
|
||||
|
||||
PACKAGECONFIG ??= ""
|
||||
PACKAGECONFIG[cvsserver] = ""
|
||||
PACKAGECONFIG[svn] = ""
|
||||
|
||||
@@ -5,5 +5,5 @@ EXTRA_OECONF += "ac_cv_snprintf_returns_bogus=no \
|
||||
"
|
||||
EXTRA_OEMAKE += "NO_GETTEXT=1"
|
||||
|
||||
SRC_URI[tarball.sha256sum] = "ef6d1d1de1d7921a54d23d07479bd2766f050d6435cea5d3b5322aa4897cb3d7"
|
||||
SRC_URI[manpages.sha256sum] = "325795ba33c0be02370de79636f32ad3b447665c1f2b5b4de65181fa804bed31"
|
||||
SRC_URI[tarball.sha256sum] = "6e119e70d3762f28e1dc9928c526eb4d7519fd3870f862775cd10186653eb85a"
|
||||
SRC_URI[manpages.sha256sum] = "e687bcc91a6fd9cb74243f91a9c2d77c50ce202a09b35931021ecc521a373ed5"
|
||||
@@ -12,7 +12,7 @@ INHIBIT_DEFAULT_DEPS = "1"
|
||||
SRCREV = "5256817ace8493502ec88501a19e4051c2e220b0"
|
||||
PV = "20200117+git${SRCPV}"
|
||||
|
||||
SRC_URI = "git://git.savannah.gnu.org/config.git;branch=master \
|
||||
SRC_URI = "git://git.savannah.gnu.org/git/config.git;protocol=https;branch=master \
|
||||
file://gnu-configize.in"
|
||||
S = "${WORKDIR}/git"
|
||||
UPSTREAM_CHECK_COMMITS = "1"
|
||||
|
||||
@@ -19,9 +19,11 @@ SRC_URI += "\
|
||||
file://CVE-2021-34558.patch \
|
||||
file://CVE-2021-33196.patch \
|
||||
file://CVE-2021-33197.patch \
|
||||
file://CVE-2021-38297.patch \
|
||||
file://CVE-2022-23806.patch \
|
||||
file://CVE-2022-23772.patch \
|
||||
"
|
||||
|
||||
SRC_URI_append_libc-musl = " file://0009-ld-replace-glibc-dynamic-linker-with-musl.patch"
|
||||
SRC_URI[main.sha256sum] = "7ed13b2209e54a451835997f78035530b331c5b6943cdcd68a3d815fdc009149"
|
||||
|
||||
|
||||
97
meta/recipes-devtools/go/go-1.14/CVE-2021-38297.patch
Normal file
97
meta/recipes-devtools/go/go-1.14/CVE-2021-38297.patch
Normal file
@@ -0,0 +1,97 @@
|
||||
From 4548fcc8dfd933c237f29bba6f90040a85922564 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Knyszek <mknyszek@google.com>
|
||||
Date: Thu, 2 Sep 2021 16:51:59 -0400
|
||||
Subject: [PATCH] [release-branch.go1.16] misc/wasm, cmd/link: do not let
|
||||
command line args overwrite global data
|
||||
|
||||
On Wasm, wasm_exec.js puts command line arguments at the beginning
|
||||
of the linear memory (following the "zero page"). Currently there
|
||||
is no limit for this, and a very long command line can overwrite
|
||||
the program's data section. Prevent this by limiting the command
|
||||
line to 4096 bytes, and in the linker ensuring the data section
|
||||
starts at a high enough address (8192).
|
||||
|
||||
(Arguably our address assignment on Wasm is a bit confusing. This
|
||||
is the minimum fix I can come up with.)
|
||||
|
||||
Thanks to Ben Lubar for reporting this issue.
|
||||
|
||||
Change by Cherry Mui <cherryyz@google.com>.
|
||||
|
||||
For #48797
|
||||
Fixes #48799
|
||||
Fixes CVE-2021-38297
|
||||
|
||||
Change-Id: I0f50fbb2a5b6d0d047e3c134a88988d9133e4ab3
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1205933
|
||||
Reviewed-by: Roland Shoemaker <bracewell@google.com>
|
||||
Reviewed-by: Than McIntosh <thanm@google.com>
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/354591
|
||||
Trust: Michael Knyszek <mknyszek@google.com>
|
||||
Reviewed-by: Heschi Kreinick <heschi@google.com>
|
||||
|
||||
CVE: CVE-2021-38297
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://github.com/golang/go/commit/4548fcc8dfd933c237f29bba6f90040a85922564
|
||||
|
||||
Inline of ctxt.isWAsm followin this implemetation:
|
||||
https://github.com/golang/go/blob/4548fcc8dfd933c237f29bba6f90040a85922564/src/cmd/link/internal/ld/target.go#L127
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
misc/wasm/wasm_exec.js | 7 +++++++
|
||||
src/cmd/link/internal/ld/data.go | 11 ++++++++++-
|
||||
2 files changed, 17 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
|
||||
index 82041e6bb901..a0a264278b1b 100644
|
||||
--- a/misc/wasm/wasm_exec.js
|
||||
+++ b/misc/wasm/wasm_exec.js
|
||||
@@ -564,6 +564,13 @@
|
||||
offset += 8;
|
||||
});
|
||||
|
||||
+ // The linker guarantees global data starts from at least wasmMinDataAddr.
|
||||
+ // Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr.
|
||||
+ const wasmMinDataAddr = 4096 + 4096;
|
||||
+ if (offset >= wasmMinDataAddr) {
|
||||
+ throw new Error("command line too long");
|
||||
+ }
|
||||
+
|
||||
this._inst.exports.run(argc, argv);
|
||||
if (this.exited) {
|
||||
this._resolveExitPromise();
|
||||
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go
|
||||
index 52035e96301c..54a1d188cdb9 100644
|
||||
--- a/src/cmd/link/internal/ld/data.go
|
||||
+++ b/src/cmd/link/internal/ld/data.go
|
||||
@@ -2330,6 +2330,11 @@ func assignAddress(ctxt *Link, sect *sym.Section, n int, s loader.Sym, va uint64
|
||||
return sect, n, va
|
||||
}
|
||||
|
||||
+// On Wasm, we reserve 4096 bytes for zero page, then 4096 bytes for wasm_exec.js
|
||||
+// to store command line args. Data sections starts from at least address 8192.
|
||||
+// Keep in sync with wasm_exec.js.
|
||||
+const wasmMinDataAddr = 4096 + 4096
|
||||
+
|
||||
// address assigns virtual addresses to all segments and sections and
|
||||
// returns all segments in file order.
|
||||
func (ctxt *Link) address() []*sym.Segment {
|
||||
@@ -2339,10 +2344,14 @@ func (ctxt *Link) address() []*sym.Segment {
|
||||
order = append(order, &Segtext)
|
||||
Segtext.Rwx = 05
|
||||
Segtext.Vaddr = va
|
||||
- for _, s := range Segtext.Sections {
|
||||
+ for i, s := range Segtext.Sections {
|
||||
va = uint64(Rnd(int64(va), int64(s.Align)))
|
||||
s.Vaddr = va
|
||||
va += s.Length
|
||||
+
|
||||
+ if ctxt.Arch.Family == sys.Wasm && i == 0 && va < wasmMinDataAddr {
|
||||
+ va = wasmMinDataAddr
|
||||
+ }
|
||||
}
|
||||
|
||||
Segtext.Length = va - uint64(*FlagTextAddr)
|
||||
|
||||
@@ -13,7 +13,7 @@ SRC_URI:append:class-nativesdk = " \
|
||||
file://older-glibc-symbols.patch"
|
||||
SRC_URI[prebuilt.sha256sum] = "ed9f456856e9d86359f169f46a70ad7be4190d6040282b84c8d97b99072485aa"
|
||||
|
||||
SRCREV = "d34f2f6cedccf8488730001bcbde6bb7499f8814"
|
||||
SRCREV = "2b4b88eb513335b0ece55fe51854693d9b20de35"
|
||||
S = "${WORKDIR}/git"
|
||||
PV = "1.9.0+git${SRCPV}"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
DESCRIPTION = "Python Jinja2: A small but fast and easy to use stand-alone template engine written in pure python."
|
||||
HOMEPAGE = "https://pypi.org/project/Jinja/"
|
||||
HOMEPAGE = "https://pypi.org/project/Jinja2/"
|
||||
|
||||
LICENSE = "BSD-3-Clause"
|
||||
LIC_FILES_CHKSUM = "file://LICENSE.rst;md5=5dc88300786f1c214c1e9827a5229462"
|
||||
|
||||
@@ -14,17 +14,21 @@ Upstream-Status: Submitted [https://github.com/python/cpython/pull/13196]
|
||||
Signed-off-by: Matthias Schoepfer <matthias.schoepfer@ithinx.io>
|
||||
|
||||
%% original patch: 0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch
|
||||
|
||||
Updated to apply after dea270a2a80214de22afadaaca2043d0d782eb7d
|
||||
|
||||
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
|
||||
---
|
||||
configure.ac | 175 +++++++--------------------------------------------
|
||||
1 file changed, 21 insertions(+), 154 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index ede710e..bc81b0b 100644
|
||||
index de83332dd3..16b02d0798 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -710,160 +710,27 @@ fi
|
||||
MULTIARCH=$($CC --print-multiarch 2>/dev/null)
|
||||
AC_SUBST(MULTIARCH)
|
||||
@@ -719,160 +719,27 @@ then
|
||||
fi
|
||||
|
||||
|
||||
-AC_MSG_CHECKING([for the platform triplet based on compiler characteristics])
|
||||
-cat >> conftest.c <<EOF
|
||||
@@ -185,25 +189,25 @@ index ede710e..bc81b0b 100644
|
||||
+## Need to handle macos, vxworks and hurd special (?) :-/
|
||||
+case ${target_os} in
|
||||
+ darwin*)
|
||||
+ PLATFORM_TRIPLET=darwin
|
||||
+ ;;
|
||||
+ PLATFORM_TRIPLET=darwin
|
||||
+ ;;
|
||||
+ hurd*)
|
||||
+ PLATFORM_TRIPLET=i386-gnu
|
||||
+ ;;
|
||||
+ PLATFORM_TRIPLET=i386-gnu
|
||||
+ ;;
|
||||
+ vxworks*)
|
||||
+ PLATFORM_TRIPLET=vxworks
|
||||
+ ;;
|
||||
+ PLATFORM_TRIPLET=vxworks
|
||||
+ ;;
|
||||
+ *)
|
||||
+ if test "${target_cpu}" != "i686"; then
|
||||
+ PLATFORM_TRIPLET=${target_cpu}-${target_os}
|
||||
+ else
|
||||
+ PLATFORM_TRIPLET=i386-${target_os}
|
||||
+ fi
|
||||
+ ;;
|
||||
+esac
|
||||
+ PLATFORM_TRIPLET=${target_cpu}-${target_os}
|
||||
+ else
|
||||
+ PLATFORM_TRIPLET=i386-${target_os}
|
||||
+ fi
|
||||
+ ;;
|
||||
+esac
|
||||
|
||||
if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
|
||||
if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
|
||||
if test x$PLATFORM_TRIPLET != xdarwin; then
|
||||
MULTIARCH=$($CC --print-multiarch 2>/dev/null)
|
||||
--
|
||||
2.24.1
|
||||
2.32.0
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ DESCRIPTION = "Python is a programming language that lets you work more quickly
|
||||
LICENSE = "PSF-2.0 & BSD-0-Clause"
|
||||
SECTION = "devel/python"
|
||||
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=c22d2438294c784731bf9dd224a467b7"
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=c84eccf626bb6fde43e6ea5e28d8feb5"
|
||||
|
||||
SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
|
||||
file://run-ptest \
|
||||
@@ -42,8 +42,8 @@ SRC_URI_append_class-native = " \
|
||||
file://0001-Don-t-search-system-for-headers-libraries.patch \
|
||||
"
|
||||
|
||||
SRC_URI[md5sum] = "9dd8f82e586b776383c82e27923f8795"
|
||||
SRC_URI[sha256sum] = "b1d3a76420375343b5e8a22fceb1ac65b77193e9ed27146524f0a9db058728ea"
|
||||
SRC_URI[md5sum] = "c4b7100dcaace9d33ab1fda9a3a038d6"
|
||||
SRC_URI[sha256sum] = "6f309077012040aa39fe8f0c61db8c0fa1c45136763299d375c9e5756f09cf57"
|
||||
|
||||
# exclude pre-releases for both python 2.x and 3.x
|
||||
UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar"
|
||||
@@ -56,7 +56,7 @@ CVE_CHECK_WHITELIST += "CVE-2007-4559"
|
||||
CVE_CHECK_WHITELIST += "CVE-2019-18348"
|
||||
|
||||
# This is windows only issue.
|
||||
CVE_CHECK_WHITELIST += "CVE-2020-15523"
|
||||
CVE_CHECK_WHITELIST += "CVE-2020-15523 CVE-2022-26488"
|
||||
|
||||
PYTHON_MAJMIN = "3.8"
|
||||
|
||||
@@ -92,6 +92,12 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
|
||||
file://CVE-2020-27617.patch \
|
||||
file://CVE-2020-28916.patch \
|
||||
file://CVE-2021-3682.patch \
|
||||
file://CVE-2020-13253_1.patch \
|
||||
file://CVE-2020-13253_2.patch \
|
||||
file://CVE-2020-13253_3.patch \
|
||||
file://CVE-2020-13253_4.patch \
|
||||
file://CVE-2020-13253_5.patch \
|
||||
file://CVE-2020-13791.patch \
|
||||
"
|
||||
UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
|
||||
|
||||
|
||||
50
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_1.patch
Normal file
50
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_1.patch
Normal file
@@ -0,0 +1,50 @@
|
||||
From 6dd3a164f5b31c703c7d8372841ad3bd6a57de6d Mon Sep 17 00:00:00 2001
|
||||
From: =?utf8?q?Philippe=20Mathieu-Daud=C3=A9?= <f4bug@amsat.org>
|
||||
Date: Tue, 5 Jun 2018 22:28:51 -0300
|
||||
Subject: [PATCH 1/1] hw/sd/sdcard: Simplify realize() a bit
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
We don't need to check if sd->blk is set twice.
|
||||
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
||||
Message-Id: <20200630133912.9428-18-f4bug@amsat.org>
|
||||
|
||||
Upstram-Status: Backport:
|
||||
https://git.qemu.org/?p=qemu.git;a=commit;f=hw/sd/sd.c;h=6dd3a164f5b31c703c7d8372841ad3bd6a57de6d
|
||||
|
||||
CVE: CVE-2020-13253
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
hw/sd/sd.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
|
||||
index 1cc16bf..edd60a0 100644
|
||||
--- a/hw/sd/sd.c
|
||||
+++ b/hw/sd/sd.c
|
||||
@@ -2105,12 +2105,12 @@ static void sd_realize(DeviceState *dev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
- if (sd->blk && blk_is_read_only(sd->blk)) {
|
||||
- error_setg(errp, "Cannot use read-only drive as SD card");
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
if (sd->blk) {
|
||||
+ if (blk_is_read_only(sd->blk)) {
|
||||
+ error_setg(errp, "Cannot use read-only drive as SD card");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
|
||||
BLK_PERM_ALL, errp);
|
||||
if (ret < 0) {
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
112
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_2.patch
Normal file
112
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_2.patch
Normal file
@@ -0,0 +1,112 @@
|
||||
From a9bcedd15a5834ca9ae6c3a97933e85ac7edbd36 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <f4bug@amsat.org>
|
||||
Date: Tue, 7 Jul 2020 13:02:34 +0200
|
||||
Subject: [PATCH] hw/sd/sdcard: Do not allow invalid SD card sizes
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
QEMU allows to create SD card with unrealistic sizes. This could
|
||||
work, but some guests (at least Linux) consider sizes that are not
|
||||
a power of 2 as a firmware bug and fix the card size to the next
|
||||
power of 2.
|
||||
|
||||
While the possibility to use small SD card images has been seen as
|
||||
a feature, it became a bug with CVE-2020-13253, where the guest is
|
||||
able to do OOB read/write accesses past the image size end.
|
||||
|
||||
In a pair of commits we will fix CVE-2020-13253 as:
|
||||
|
||||
Read command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR
|
||||
occurred and no data transfer is performed.
|
||||
|
||||
Write command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR
|
||||
occurred and no data transfer is performed.
|
||||
|
||||
WP_VIOLATION errors are not modified: the error bit is set, we
|
||||
stay in receive-data state, wait for a stop command. All further
|
||||
data transfer is ignored. See the check on sd->card_status at the
|
||||
beginning of sd_read_data() and sd_write_data().
|
||||
|
||||
While this is the correct behavior, in case QEMU create smaller SD
|
||||
cards, guests still try to access past the image size end, and QEMU
|
||||
considers this is an invalid address, thus "all further data transfer
|
||||
is ignored". This is wrong and make the guest looping until
|
||||
eventually timeouts.
|
||||
|
||||
Fix by not allowing invalid SD card sizes (suggesting the expected
|
||||
size as a hint):
|
||||
|
||||
$ qemu-system-arm -M orangepi-pc -drive file=rootfs.ext2,if=sd,format=raw
|
||||
qemu-system-arm: Invalid SD card size: 60 MiB
|
||||
SD card size has to be a power of 2, e.g. 64 MiB.
|
||||
You can resize disk images with 'qemu-img resize <imagefile> <new-size>'
|
||||
(note that this will lose data if you make the image smaller than it currently is).
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Message-Id: <20200713183209.26308-8-f4bug@amsat.org>
|
||||
|
||||
Upstram-Status: Backport:
|
||||
https://git.qemu.org/?p=qemu.git;a=commit;h=a9bcedd15a5834ca9ae6c3a97933e85ac7edbd36
|
||||
|
||||
CVE: CVE-2020-13253
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
hw/sd/sd.c | 25 +++++++++++++++++++++++++
|
||||
1 file changed, 25 insertions(+)
|
||||
|
||||
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
|
||||
index edd60a09c0..76d68359a4 100644
|
||||
--- a/hw/sd/sd.c
|
||||
+++ b/hw/sd/sd.c
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/units.h"
|
||||
+#include "qemu/cutils.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/registerfields.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
@@ -2106,11 +2107,35 @@ static void sd_realize(DeviceState *dev, Error **errp)
|
||||
}
|
||||
|
||||
if (sd->blk) {
|
||||
+ int64_t blk_size;
|
||||
+
|
||||
if (blk_is_read_only(sd->blk)) {
|
||||
error_setg(errp, "Cannot use read-only drive as SD card");
|
||||
return;
|
||||
}
|
||||
|
||||
+ blk_size = blk_getlength(sd->blk);
|
||||
+ if (blk_size > 0 && !is_power_of_2(blk_size)) {
|
||||
+ int64_t blk_size_aligned = pow2ceil(blk_size);
|
||||
+ char *blk_size_str;
|
||||
+
|
||||
+ blk_size_str = size_to_str(blk_size);
|
||||
+ error_setg(errp, "Invalid SD card size: %s", blk_size_str);
|
||||
+ g_free(blk_size_str);
|
||||
+
|
||||
+ blk_size_str = size_to_str(blk_size_aligned);
|
||||
+ error_append_hint(errp,
|
||||
+ "SD card size has to be a power of 2, e.g. %s.\n"
|
||||
+ "You can resize disk images with"
|
||||
+ " 'qemu-img resize <imagefile> <new-size>'\n"
|
||||
+ "(note that this will lose data if you make the"
|
||||
+ " image smaller than it currently is).\n",
|
||||
+ blk_size_str);
|
||||
+ g_free(blk_size_str);
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
ret = blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
|
||||
BLK_PERM_ALL, errp);
|
||||
if (ret < 0) {
|
||||
--
|
||||
2.32.0
|
||||
|
||||
86
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_3.patch
Normal file
86
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_3.patch
Normal file
@@ -0,0 +1,86 @@
|
||||
From 794d68de2f021a6d3874df41d6bbe8590ec05207 Mon Sep 17 00:00:00 2001
|
||||
From: =?utf8?q?Philippe=20Mathieu-Daud=C3=A9?= <f4bug@amsat.org>
|
||||
Date: Mon, 13 Jul 2020 09:27:35 +0200
|
||||
Subject: [PATCH] hw/sd/sdcard: Update coding style to make checkpatch.pl happy
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
To make the next commit easier to review, clean this code first.
|
||||
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
||||
Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Message-Id: <20200630133912.9428-3-f4bug@amsat.org>
|
||||
|
||||
Upstram-Status: Backport:
|
||||
https://git.qemu.org/?p=qemu.git;a=commit;f=hw/sd/sd.c;h=794d68de2f021a6d3874df41d6bbe8590ec05207
|
||||
|
||||
CVE: CVE-2020-13253
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
|
||||
--- a/hw/sd/sd.c (revision b0ca999a43a22b38158a222233d3f5881648bb4f)
|
||||
+++ b/hw/sd/sd.c (date 1647514442924)
|
||||
@@ -1154,8 +1154,9 @@
|
||||
sd->data_start = addr;
|
||||
sd->data_offset = 0;
|
||||
|
||||
- if (sd->data_start + sd->blk_len > sd->size)
|
||||
+ if (sd->data_start + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
+ }
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -1170,8 +1171,9 @@
|
||||
sd->data_start = addr;
|
||||
sd->data_offset = 0;
|
||||
|
||||
- if (sd->data_start + sd->blk_len > sd->size)
|
||||
+ if (sd->data_start + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
+ }
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -1216,12 +1218,15 @@
|
||||
sd->data_offset = 0;
|
||||
sd->blk_written = 0;
|
||||
|
||||
- if (sd->data_start + sd->blk_len > sd->size)
|
||||
+ if (sd->data_start + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
- if (sd_wp_addr(sd, sd->data_start))
|
||||
+ }
|
||||
+ if (sd_wp_addr(sd, sd->data_start)) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
- if (sd->csd[14] & 0x30)
|
||||
+ }
|
||||
+ if (sd->csd[14] & 0x30) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
+ }
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -1240,12 +1245,15 @@
|
||||
sd->data_offset = 0;
|
||||
sd->blk_written = 0;
|
||||
|
||||
- if (sd->data_start + sd->blk_len > sd->size)
|
||||
+ if (sd->data_start + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
- if (sd_wp_addr(sd, sd->data_start))
|
||||
+ }
|
||||
+ if (sd_wp_addr(sd, sd->data_start)) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
- if (sd->csd[14] & 0x30)
|
||||
+ }
|
||||
+ if (sd->csd[14] & 0x30) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
+ }
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
139
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_4.patch
Normal file
139
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_4.patch
Normal file
@@ -0,0 +1,139 @@
|
||||
From 790762e5487114341cccc5bffcec4cb3c022c3cd Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <f4bug@amsat.org>
|
||||
Date: Thu, 4 Jun 2020 19:22:29 +0200
|
||||
Subject: [PATCH] hw/sd/sdcard: Do not switch to ReceivingData if address is
|
||||
invalid
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Only move the state machine to ReceivingData if there is no
|
||||
pending error. This avoids later OOB access while processing
|
||||
commands queued.
|
||||
|
||||
"SD Specifications Part 1 Physical Layer Simplified Spec. v3.01"
|
||||
|
||||
4.3.3 Data Read
|
||||
|
||||
Read command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR
|
||||
occurred and no data transfer is performed.
|
||||
|
||||
4.3.4 Data Write
|
||||
|
||||
Write command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR
|
||||
occurred and no data transfer is performed.
|
||||
|
||||
WP_VIOLATION errors are not modified: the error bit is set, we
|
||||
stay in receive-data state, wait for a stop command. All further
|
||||
data transfer is ignored. See the check on sd->card_status at the
|
||||
beginning of sd_read_data() and sd_write_data().
|
||||
|
||||
Fixes: CVE-2020-13253
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Reported-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1880822
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
||||
Message-Id: <20200630133912.9428-6-f4bug@amsat.org>
|
||||
|
||||
Upstram-Status: Backport:
|
||||
https://git.qemu.org/?p=qemu.git;a=commit;h=790762e5487114341cccc5bffcec4cb3c022c3cd
|
||||
|
||||
CVE: CVE-2020-13253
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
hw/sd/sd.c | 38 ++++++++++++++++++++++++--------------
|
||||
1 file changed, 24 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
|
||||
index f4f76f8fd2..fad9cf1ee7 100644
|
||||
--- a/hw/sd/sd.c
|
||||
+++ b/hw/sd/sd.c
|
||||
@@ -1171,13 +1171,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
case 17: /* CMD17: READ_SINGLE_BLOCK */
|
||||
switch (sd->state) {
|
||||
case sd_transfer_state:
|
||||
- sd->state = sd_sendingdata_state;
|
||||
- sd->data_start = addr;
|
||||
- sd->data_offset = 0;
|
||||
|
||||
- if (sd->data_start + sd->blk_len > sd->size) {
|
||||
+ if (addr + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
+ return sd_r1;
|
||||
}
|
||||
+
|
||||
+ sd->state = sd_sendingdata_state;
|
||||
+ sd->data_start = addr;
|
||||
+ sd->data_offset = 0;
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -1188,13 +1190,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
case 18: /* CMD18: READ_MULTIPLE_BLOCK */
|
||||
switch (sd->state) {
|
||||
case sd_transfer_state:
|
||||
- sd->state = sd_sendingdata_state;
|
||||
- sd->data_start = addr;
|
||||
- sd->data_offset = 0;
|
||||
|
||||
- if (sd->data_start + sd->blk_len > sd->size) {
|
||||
+ if (addr + sd->blk_len > sd->size) {
|
||||
sd->card_status |= ADDRESS_ERROR;
|
||||
+ return sd_r1;
|
||||
}
|
||||
+
|
||||
+ sd->state = sd_sendingdata_state;
|
||||
+ sd->data_start = addr;
|
||||
+ sd->data_offset = 0;
|
||||
return sd_r1;
|
||||
|
||||
default:
|
||||
@@ -1234,14 +1238,17 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
/* Writing in SPI mode not implemented. */
|
||||
if (sd->spi)
|
||||
break;
|
||||
+
|
||||
+ if (addr + sd->blk_len > sd->size) {
|
||||
+ sd->card_status |= ADDRESS_ERROR;
|
||||
+ return sd_r1;
|
||||
+ }
|
||||
+
|
||||
sd->state = sd_receivingdata_state;
|
||||
sd->data_start = addr;
|
||||
sd->data_offset = 0;
|
||||
sd->blk_written = 0;
|
||||
|
||||
- if (sd->data_start + sd->blk_len > sd->size) {
|
||||
- sd->card_status |= ADDRESS_ERROR;
|
||||
- }
|
||||
if (sd_wp_addr(sd, sd->data_start)) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
}
|
||||
@@ -1261,14 +1268,17 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
/* Writing in SPI mode not implemented. */
|
||||
if (sd->spi)
|
||||
break;
|
||||
+
|
||||
+ if (addr + sd->blk_len > sd->size) {
|
||||
+ sd->card_status |= ADDRESS_ERROR;
|
||||
+ return sd_r1;
|
||||
+ }
|
||||
+
|
||||
sd->state = sd_receivingdata_state;
|
||||
sd->data_start = addr;
|
||||
sd->data_offset = 0;
|
||||
sd->blk_written = 0;
|
||||
|
||||
- if (sd->data_start + sd->blk_len > sd->size) {
|
||||
- sd->card_status |= ADDRESS_ERROR;
|
||||
- }
|
||||
if (sd_wp_addr(sd, sd->data_start)) {
|
||||
sd->card_status |= WP_VIOLATION;
|
||||
}
|
||||
--
|
||||
2.32.0
|
||||
|
||||
54
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_5.patch
Normal file
54
meta/recipes-devtools/qemu/qemu/CVE-2020-13253_5.patch
Normal file
@@ -0,0 +1,54 @@
|
||||
From 9157dd597d293ab7f599f4d96c3fe8a6e07c633d Mon Sep 17 00:00:00 2001
|
||||
From: =?utf8?q?Philippe=20Mathieu-Daud=C3=A9?= <f4bug@amsat.org>
|
||||
Date: Wed, 3 Jun 2020 19:59:16 +0200
|
||||
Subject: [PATCH] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Only SCSD cards support Class 6 (Block Oriented Write Protection)
|
||||
commands.
|
||||
|
||||
"SD Specifications Part 1 Physical Layer Simplified Spec. v3.01"
|
||||
|
||||
4.3.14 Command Functional Difference in Card Capacity Types
|
||||
|
||||
* Write Protected Group
|
||||
|
||||
SDHC and SDXC do not support write-protected groups. Issuing
|
||||
CMD28, CMD29 and CMD30 generates the ILLEGAL_COMMAND error.
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
||||
Message-Id: <20200630133912.9428-7-f4bug@amsat.org>
|
||||
|
||||
Upstram-Status: Backport:
|
||||
https://git.qemu.org/?p=qemu.git;a=commit;h=9157dd597d293ab7f599f4d96c3fe8a6e07c633d
|
||||
|
||||
CVE: CVE-2020-13253
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
hw/sd/sd.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
|
||||
index 5137168..1cc16bf 100644
|
||||
--- a/hw/sd/sd.c
|
||||
+++ b/hw/sd/sd.c
|
||||
@@ -920,6 +920,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
|
||||
sd->multi_blk_cnt = 0;
|
||||
}
|
||||
|
||||
+ if (sd_cmd_class[req.cmd] == 6 && FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) {
|
||||
+ /* Only Standard Capacity cards support class 6 commands */
|
||||
+ return sd_illegal;
|
||||
+ }
|
||||
+
|
||||
switch (req.cmd) {
|
||||
/* Basic commands (Class 0 and Class 1) */
|
||||
case 0: /* CMD0: GO_IDLE_STATE */
|
||||
--
|
||||
1.8.3.1
|
||||
44
meta/recipes-devtools/qemu/qemu/CVE-2020-13791.patch
Normal file
44
meta/recipes-devtools/qemu/qemu/CVE-2020-13791.patch
Normal file
@@ -0,0 +1,44 @@
|
||||
Date: Thu, 4 Jun 2020 16:25:24 +0530
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Subject: [PATCH v3] ati-vga: check address before reading configuration bytes (CVE-2020-13791)
|
||||
|
||||
While reading PCI configuration bytes, a guest may send an
|
||||
address towards the end of the configuration space. It may lead
|
||||
to an OOB access issue. Add check to ensure 'address + size' is
|
||||
within PCI configuration space.
|
||||
|
||||
CVE: CVE-2020-13791
|
||||
|
||||
Upstream-Status: Submitted
|
||||
https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00979.html
|
||||
|
||||
Reported-by: Ren Ding <rding@gatech.edu>
|
||||
Reported-by: Hanqing Zhao <hanqing@gatech.edu>
|
||||
Reported-by: Yi Ren <c4tren@gmail.com>
|
||||
Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
hw/display/ati.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
Update v3: avoid modifying 'addr' variable
|
||||
-> https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00834.html
|
||||
|
||||
diff --git a/hw/display/ati.c b/hw/display/ati.c
|
||||
index 67604e68de..b4d0fd88b7 100644
|
||||
--- a/hw/display/ati.c
|
||||
+++ b/hw/display/ati.c
|
||||
@@ -387,7 +387,9 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, unsigned int size)
|
||||
val = s->regs.crtc_pitch;
|
||||
break;
|
||||
case 0xf00 ... 0xfff:
|
||||
- val = pci_default_read_config(&s->dev, addr - 0xf00, size);
|
||||
+ if ((addr - 0xf00) + size <= pci_config_size(&s->dev)) {
|
||||
+ val = pci_default_read_config(&s->dev, addr - 0xf00, size);
|
||||
+ }
|
||||
break;
|
||||
case CUR_OFFSET:
|
||||
val = s->regs.cur_offset;
|
||||
--
|
||||
2.26.2
|
||||
@@ -0,0 +1,121 @@
|
||||
From 3920a727fb19e19f597e518610ce2416d08cb75f Mon Sep 17 00:00:00 2001
|
||||
From: Chris Liddell <chris.liddell@artifex.com>
|
||||
Date: Thu, 20 Aug 2020 17:19:09 +0100
|
||||
Subject: [PATCH] Fix pdfwrite "%d" mode with file permissions
|
||||
|
||||
Firstly, in gx_device_delete_output_file the iodev pointer was being passed
|
||||
to the delete_method incorrectly (passing a pointer to that pointer). Thus
|
||||
when we attempted to use that to confirm permission to delete the file, it
|
||||
crashed. Credit to Ken for finding that.
|
||||
|
||||
Secondly, due to the way pdfwrite works, when running with an output file per
|
||||
page, it creates the current output file immediately it has completed writing
|
||||
the previous one. Thus, it has to delete that partial file on exit.
|
||||
|
||||
Previously, the output file was not added to the "control" permission list,
|
||||
so an attempt to delete it would result in an error. So add the output file
|
||||
to the "control" as well as "write" list.
|
||||
|
||||
CVE: CVE-2021-3781
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;f=base/gslibctx.c;h=3920a727fb19e19f597e518610ce2416d08cb75f
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
base/gsdevice.c | 2 +-
|
||||
base/gslibctx.c | 20 ++++++++++++++------
|
||||
2 files changed, 15 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/base/gsdevice.c b/base/gsdevice.c
|
||||
index 913119495..ac78af93f 100644
|
||||
--- a/base/gsdevice.c
|
||||
+++ b/base/gsdevice.c
|
||||
@@ -1185,7 +1185,7 @@ int gx_device_delete_output_file(const gx_device * dev, const char *fname)
|
||||
parsed.len = strlen(parsed.fname);
|
||||
}
|
||||
if (parsed.iodev)
|
||||
- code = parsed.iodev->procs.delete_file((gx_io_device *)(&parsed.iodev), (const char *)parsed.fname);
|
||||
+ code = parsed.iodev->procs.delete_file((gx_io_device *)(parsed.iodev), (const char *)parsed.fname);
|
||||
else
|
||||
code = gs_note_error(gs_error_invalidfileaccess);
|
||||
|
||||
diff --git a/base/gslibctx.c b/base/gslibctx.c
|
||||
index d726c58b5..ff8fc895e 100644
|
||||
--- a/base/gslibctx.c
|
||||
+++ b/base/gslibctx.c
|
||||
@@ -647,7 +647,7 @@ gs_add_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
char *fp, f[gp_file_name_sizeof];
|
||||
const int pipe = 124; /* ASCII code for '|' */
|
||||
const int len = strlen(fname);
|
||||
- int i;
|
||||
+ int i, code;
|
||||
|
||||
/* Be sure the string copy will fit */
|
||||
if (len >= gp_file_name_sizeof)
|
||||
@@ -658,8 +658,6 @@ gs_add_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
rewrite_percent_specifiers(f);
|
||||
for (i = 0; i < len; i++) {
|
||||
if (f[i] == pipe) {
|
||||
- int code;
|
||||
-
|
||||
fp = &f[i + 1];
|
||||
/* Because we potentially have to check file permissions at two levels
|
||||
for the output file (gx_device_open_output_file and the low level
|
||||
@@ -671,10 +669,16 @@ gs_add_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
if (code < 0)
|
||||
return code;
|
||||
break;
|
||||
+ code = gs_add_control_path(mem, gs_permit_file_control, f);
|
||||
+ if (code < 0)
|
||||
+ return code;
|
||||
}
|
||||
if (!IS_WHITESPACE(f[i]))
|
||||
break;
|
||||
}
|
||||
+ code = gs_add_control_path(mem, gs_permit_file_control, fp);
|
||||
+ if (code < 0)
|
||||
+ return code;
|
||||
return gs_add_control_path(mem, gs_permit_file_writing, fp);
|
||||
}
|
||||
|
||||
@@ -684,7 +688,7 @@ gs_remove_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
char *fp, f[gp_file_name_sizeof];
|
||||
const int pipe = 124; /* ASCII code for '|' */
|
||||
const int len = strlen(fname);
|
||||
- int i;
|
||||
+ int i, code;
|
||||
|
||||
/* Be sure the string copy will fit */
|
||||
if (len >= gp_file_name_sizeof)
|
||||
@@ -694,8 +698,6 @@ gs_remove_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
/* Try to rewrite any %d (or similar) in the string */
|
||||
for (i = 0; i < len; i++) {
|
||||
if (f[i] == pipe) {
|
||||
- int code;
|
||||
-
|
||||
fp = &f[i + 1];
|
||||
/* Because we potentially have to check file permissions at two levels
|
||||
for the output file (gx_device_open_output_file and the low level
|
||||
@@ -704,6 +706,9 @@ gs_remove_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
the pipe_fopen(), the leading '|' has been stripped.
|
||||
*/
|
||||
code = gs_remove_control_path(mem, gs_permit_file_writing, f);
|
||||
+ if (code < 0)
|
||||
+ return code;
|
||||
+ code = gs_remove_control_path(mem, gs_permit_file_control, f);
|
||||
if (code < 0)
|
||||
return code;
|
||||
break;
|
||||
@@ -711,6 +716,9 @@ gs_remove_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
if (!IS_WHITESPACE(f[i]))
|
||||
break;
|
||||
}
|
||||
+ code = gs_remove_control_path(mem, gs_permit_file_control, fp);
|
||||
+ if (code < 0)
|
||||
+ return code;
|
||||
return gs_remove_control_path(mem, gs_permit_file_writing, fp);
|
||||
}
|
||||
|
||||
--
|
||||
2.25.1
|
||||
@@ -0,0 +1,37 @@
|
||||
From 9daf042fd7bb19e93388d89d9686a2fa4496f382 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Liddell <chris.liddell@artifex.com>
|
||||
Date: Mon, 24 Aug 2020 09:24:31 +0100
|
||||
Subject: [PATCH] Coverity 361429: move "break" to correct place.
|
||||
|
||||
We had to add the outputfile to the "control" file permission list (as well
|
||||
as write), but for the "pipe" case, I accidentally added the call after the
|
||||
break out of loop that checks for a pipe.
|
||||
|
||||
CVE: CVE-2021-3781
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;f=base/gslibctx.c;h=9daf042fd7bb19e93388d89d9686a2fa4496f382
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
base/gslibctx.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/base/gslibctx.c b/base/gslibctx.c
|
||||
index ff8fc895e..63dfbe2e0 100644
|
||||
--- a/base/gslibctx.c
|
||||
+++ b/base/gslibctx.c
|
||||
@@ -668,10 +668,10 @@ gs_add_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
code = gs_add_control_path(mem, gs_permit_file_writing, f);
|
||||
if (code < 0)
|
||||
return code;
|
||||
- break;
|
||||
code = gs_add_control_path(mem, gs_permit_file_control, f);
|
||||
if (code < 0)
|
||||
return code;
|
||||
+ break;
|
||||
}
|
||||
if (!IS_WHITESPACE(f[i]))
|
||||
break;
|
||||
--
|
||||
2.25.1
|
||||
@@ -0,0 +1,238 @@
|
||||
From a9bd3dec9fde03327a4a2c69dad1036bf9632e20 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Liddell <chris.liddell@artifex.com>
|
||||
Date: Tue, 7 Sep 2021 20:36:12 +0100
|
||||
Subject: [PATCH] Bug 704342: Include device specifier strings in access
|
||||
validation
|
||||
|
||||
for the "%pipe%", %handle%" and %printer% io devices.
|
||||
|
||||
We previously validated only the part after the "%pipe%" Postscript device
|
||||
specifier, but this proved insufficient.
|
||||
|
||||
This rebuilds the original file name string, and validates it complete. The
|
||||
slight complication for "%pipe%" is it can be reached implicitly using
|
||||
"|" so we have to check both prefixes.
|
||||
|
||||
Addresses CVE-2021-3781
|
||||
|
||||
CVE: CVE-2021-3781
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=a9bd3dec9fde
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
base/gdevpipe.c | 22 +++++++++++++++-
|
||||
base/gp_mshdl.c | 11 +++++++-
|
||||
base/gp_msprn.c | 10 ++++++-
|
||||
base/gp_os2pr.c | 13 +++++++++-
|
||||
base/gslibctx.c | 69 ++++++++++---------------------------------------
|
||||
5 files changed, 65 insertions(+), 60 deletions(-)
|
||||
|
||||
diff --git a/base/gdevpipe.c b/base/gdevpipe.c
|
||||
index 96d71f5d8..5bdc485be 100644
|
||||
--- a/base/gdevpipe.c
|
||||
+++ b/base/gdevpipe.c
|
||||
@@ -72,8 +72,28 @@ pipe_fopen(gx_io_device * iodev, const char *fname, const char *access,
|
||||
#else
|
||||
gs_lib_ctx_t *ctx = mem->gs_lib_ctx;
|
||||
gs_fs_list_t *fs = ctx->core->fs;
|
||||
+ /* The pipe device can be reached in two ways, explicltly with %pipe%
|
||||
+ or implicitly with "|", so we have to check for both
|
||||
+ */
|
||||
+ char f[gp_file_name_sizeof];
|
||||
+ const char *pipestr = "|";
|
||||
+ const size_t pipestrlen = strlen(pipestr);
|
||||
+ const size_t preflen = strlen(iodev->dname);
|
||||
+ const size_t nlen = strlen(fname);
|
||||
+ int code1;
|
||||
+
|
||||
+ if (preflen + nlen >= gp_file_name_sizeof)
|
||||
+ return_error(gs_error_invalidaccess);
|
||||
+
|
||||
+ memcpy(f, iodev->dname, preflen);
|
||||
+ memcpy(f + preflen, fname, nlen + 1);
|
||||
+
|
||||
+ code1 = gp_validate_path(mem, f, access);
|
||||
+
|
||||
+ memcpy(f, pipestr, pipestrlen);
|
||||
+ memcpy(f + pipestrlen, fname, nlen + 1);
|
||||
|
||||
- if (gp_validate_path(mem, fname, access) != 0)
|
||||
+ if (code1 != 0 && gp_validate_path(mem, f, access) != 0 )
|
||||
return gs_error_invalidfileaccess;
|
||||
|
||||
/*
|
||||
diff --git a/base/gp_mshdl.c b/base/gp_mshdl.c
|
||||
index 2b964ed74..8d87ceadc 100644
|
||||
--- a/base/gp_mshdl.c
|
||||
+++ b/base/gp_mshdl.c
|
||||
@@ -95,8 +95,17 @@ mswin_handle_fopen(gx_io_device * iodev, const char *fname, const char *access,
|
||||
long hfile; /* Correct for Win32, may be wrong for Win64 */
|
||||
gs_lib_ctx_t *ctx = mem->gs_lib_ctx;
|
||||
gs_fs_list_t *fs = ctx->core->fs;
|
||||
+ char f[gp_file_name_sizeof];
|
||||
+ const size_t preflen = strlen(iodev->dname);
|
||||
+ const size_t nlen = strlen(fname);
|
||||
|
||||
- if (gp_validate_path(mem, fname, access) != 0)
|
||||
+ if (preflen + nlen >= gp_file_name_sizeof)
|
||||
+ return_error(gs_error_invalidaccess);
|
||||
+
|
||||
+ memcpy(f, iodev->dname, preflen);
|
||||
+ memcpy(f + preflen, fname, nlen + 1);
|
||||
+
|
||||
+ if (gp_validate_path(mem, f, access) != 0)
|
||||
return gs_error_invalidfileaccess;
|
||||
|
||||
/* First we try the open_handle method. */
|
||||
diff --git a/base/gp_msprn.c b/base/gp_msprn.c
|
||||
index ed4827968..746a974f7 100644
|
||||
--- a/base/gp_msprn.c
|
||||
+++ b/base/gp_msprn.c
|
||||
@@ -168,8 +168,16 @@ mswin_printer_fopen(gx_io_device * iodev, const char *fname, const char *access,
|
||||
unsigned long *ptid = &((tid_t *)(iodev->state))->tid;
|
||||
gs_lib_ctx_t *ctx = mem->gs_lib_ctx;
|
||||
gs_fs_list_t *fs = ctx->core->fs;
|
||||
+ const size_t preflen = strlen(iodev->dname);
|
||||
+ const size_t nlen = strlen(fname);
|
||||
|
||||
- if (gp_validate_path(mem, fname, access) != 0)
|
||||
+ if (preflen + nlen >= gp_file_name_sizeof)
|
||||
+ return_error(gs_error_invalidaccess);
|
||||
+
|
||||
+ memcpy(pname, iodev->dname, preflen);
|
||||
+ memcpy(pname + preflen, fname, nlen + 1);
|
||||
+
|
||||
+ if (gp_validate_path(mem, pname, access) != 0)
|
||||
return gs_error_invalidfileaccess;
|
||||
|
||||
/* First we try the open_printer method. */
|
||||
diff --git a/base/gp_os2pr.c b/base/gp_os2pr.c
|
||||
index f852c71fc..ba54cde66 100644
|
||||
--- a/base/gp_os2pr.c
|
||||
+++ b/base/gp_os2pr.c
|
||||
@@ -107,9 +107,20 @@ os2_printer_fopen(gx_io_device * iodev, const char *fname, const char *access,
|
||||
FILE ** pfile, char *rfname, uint rnamelen)
|
||||
{
|
||||
os2_printer_t *pr = (os2_printer_t *)iodev->state;
|
||||
- char driver_name[256];
|
||||
+ char driver_name[gp_file_name_sizeof];
|
||||
gs_lib_ctx_t *ctx = mem->gs_lib_ctx;
|
||||
gs_fs_list_t *fs = ctx->core->fs;
|
||||
+ const size_t preflen = strlen(iodev->dname);
|
||||
+ const int size_t = strlen(fname);
|
||||
+
|
||||
+ if (preflen + nlen >= gp_file_name_sizeof)
|
||||
+ return_error(gs_error_invalidaccess);
|
||||
+
|
||||
+ memcpy(driver_name, iodev->dname, preflen);
|
||||
+ memcpy(driver_name + preflen, fname, nlen + 1);
|
||||
+
|
||||
+ if (gp_validate_path(mem, driver_name, access) != 0)
|
||||
+ return gs_error_invalidfileaccess;
|
||||
|
||||
/* First we try the open_printer method. */
|
||||
/* Note that the loop condition here ensures we don't
|
||||
diff --git a/base/gslibctx.c b/base/gslibctx.c
|
||||
index 6dfed6cd5..318039fad 100644
|
||||
--- a/base/gslibctx.c
|
||||
+++ b/base/gslibctx.c
|
||||
@@ -655,82 +655,39 @@ rewrite_percent_specifiers(char *s)
|
||||
int
|
||||
gs_add_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
{
|
||||
- char *fp, f[gp_file_name_sizeof];
|
||||
- const int pipe = 124; /* ASCII code for '|' */
|
||||
- const int len = strlen(fname);
|
||||
- int i, code;
|
||||
+ char f[gp_file_name_sizeof];
|
||||
+ int code;
|
||||
|
||||
/* Be sure the string copy will fit */
|
||||
- if (len >= gp_file_name_sizeof)
|
||||
+ if (strlen(fname) >= gp_file_name_sizeof)
|
||||
return gs_error_rangecheck;
|
||||
strcpy(f, fname);
|
||||
- fp = f;
|
||||
/* Try to rewrite any %d (or similar) in the string */
|
||||
rewrite_percent_specifiers(f);
|
||||
- for (i = 0; i < len; i++) {
|
||||
- if (f[i] == pipe) {
|
||||
- fp = &f[i + 1];
|
||||
- /* Because we potentially have to check file permissions at two levels
|
||||
- for the output file (gx_device_open_output_file and the low level
|
||||
- fopen API, if we're using a pipe, we have to add both the full string,
|
||||
- (including the '|', and just the command to which we pipe - since at
|
||||
- the pipe_fopen(), the leading '|' has been stripped.
|
||||
- */
|
||||
- code = gs_add_control_path(mem, gs_permit_file_writing, f);
|
||||
- if (code < 0)
|
||||
- return code;
|
||||
- code = gs_add_control_path(mem, gs_permit_file_control, f);
|
||||
- if (code < 0)
|
||||
- return code;
|
||||
- break;
|
||||
- }
|
||||
- if (!IS_WHITESPACE(f[i]))
|
||||
- break;
|
||||
- }
|
||||
- code = gs_add_control_path(mem, gs_permit_file_control, fp);
|
||||
+
|
||||
+ code = gs_add_control_path(mem, gs_permit_file_control, f);
|
||||
if (code < 0)
|
||||
return code;
|
||||
- return gs_add_control_path(mem, gs_permit_file_writing, fp);
|
||||
+ return gs_add_control_path(mem, gs_permit_file_writing, f);
|
||||
}
|
||||
|
||||
int
|
||||
gs_remove_outputfile_control_path(gs_memory_t *mem, const char *fname)
|
||||
{
|
||||
- char *fp, f[gp_file_name_sizeof];
|
||||
- const int pipe = 124; /* ASCII code for '|' */
|
||||
- const int len = strlen(fname);
|
||||
- int i, code;
|
||||
+ char f[gp_file_name_sizeof];
|
||||
+ int code;
|
||||
|
||||
/* Be sure the string copy will fit */
|
||||
- if (len >= gp_file_name_sizeof)
|
||||
+ if (strlen(fname) >= gp_file_name_sizeof)
|
||||
return gs_error_rangecheck;
|
||||
strcpy(f, fname);
|
||||
- fp = f;
|
||||
/* Try to rewrite any %d (or similar) in the string */
|
||||
- for (i = 0; i < len; i++) {
|
||||
- if (f[i] == pipe) {
|
||||
- fp = &f[i + 1];
|
||||
- /* Because we potentially have to check file permissions at two levels
|
||||
- for the output file (gx_device_open_output_file and the low level
|
||||
- fopen API, if we're using a pipe, we have to add both the full string,
|
||||
- (including the '|', and just the command to which we pipe - since at
|
||||
- the pipe_fopen(), the leading '|' has been stripped.
|
||||
- */
|
||||
- code = gs_remove_control_path(mem, gs_permit_file_writing, f);
|
||||
- if (code < 0)
|
||||
- return code;
|
||||
- code = gs_remove_control_path(mem, gs_permit_file_control, f);
|
||||
- if (code < 0)
|
||||
- return code;
|
||||
- break;
|
||||
- }
|
||||
- if (!IS_WHITESPACE(f[i]))
|
||||
- break;
|
||||
- }
|
||||
- code = gs_remove_control_path(mem, gs_permit_file_control, fp);
|
||||
+ rewrite_percent_specifiers(f);
|
||||
+
|
||||
+ code = gs_remove_control_path(mem, gs_permit_file_control, f);
|
||||
if (code < 0)
|
||||
return code;
|
||||
- return gs_remove_control_path(mem, gs_permit_file_writing, fp);
|
||||
+ return gs_remove_control_path(mem, gs_permit_file_writing, f);
|
||||
}
|
||||
|
||||
int
|
||||
--
|
||||
2.25.1
|
||||
@@ -33,14 +33,17 @@ SRC_URI_BASE = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/d
|
||||
file://do-not-check-local-libpng-source.patch \
|
||||
file://avoid-host-contamination.patch \
|
||||
file://mkdir-p.patch \
|
||||
file://CVE-2020-15900.patch \
|
||||
file://check-stack-limits-after-function-evalution.patch \
|
||||
file://CVE-2021-45949.patch \
|
||||
file://CVE-2021-3781_1.patch \
|
||||
file://CVE-2021-3781_2.patch \
|
||||
file://CVE-2021-3781_3.patch \
|
||||
"
|
||||
|
||||
SRC_URI = "${SRC_URI_BASE} \
|
||||
file://ghostscript-9.21-prevent_recompiling.patch \
|
||||
file://cups-no-gcrypt.patch \
|
||||
file://CVE-2020-15900.patch \
|
||||
file://check-stack-limits-after-function-evalution.patch \
|
||||
file://CVE-2021-45949.patch \
|
||||
"
|
||||
|
||||
SRC_URI_class-native = "${SRC_URI_BASE} \
|
||||
|
||||
45
meta/recipes-extended/gzip/gzip-1.10/CVE-2022-1271.patch
Normal file
45
meta/recipes-extended/gzip/gzip-1.10/CVE-2022-1271.patch
Normal file
@@ -0,0 +1,45 @@
|
||||
From 7073a366ee71639a1902eefb7500e14acb920f64 Mon Sep 17 00:00:00 2001
|
||||
From: Lasse Collin <lasse.collin@tukaani.org>
|
||||
Date: Mon, 4 Apr 2022 23:52:49 -0700
|
||||
Subject: [PATCH] zgrep: avoid exploit via multi-newline file names
|
||||
|
||||
* zgrep.in: The issue with the old code is that with multiple
|
||||
newlines, the N-command will read the second line of input,
|
||||
then the s-commands will be skipped because it's not the end
|
||||
of the file yet, then a new sed cycle starts and the pattern
|
||||
space is printed and emptied. So only the last line or two get
|
||||
escaped. This patch makes sed read all lines into the pattern
|
||||
space and then do the escaping.
|
||||
|
||||
This vulnerability was discovered by:
|
||||
cleemy desu wayo working with Trend Micro Zero Day Initiative
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/gzip.git/commit/?id=dc9740df61e575e8c3148b7bd3c147a81ea00c7c]
|
||||
CVE: CVE-2022-1271
|
||||
|
||||
Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
|
||||
---
|
||||
zgrep.in | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/zgrep.in b/zgrep.in
|
||||
index 3efdb52..d391291 100644
|
||||
--- a/zgrep.in
|
||||
+++ b/zgrep.in
|
||||
@@ -222,9 +222,13 @@ do
|
||||
'* | *'&'* | *'\'* | *'|'*)
|
||||
i=$(printf '%s\n' "$i" |
|
||||
sed '
|
||||
- $!N
|
||||
- $s/[&\|]/\\&/g
|
||||
- $s/\n/\\n/g
|
||||
+ :start
|
||||
+ $!{
|
||||
+ N
|
||||
+ b start
|
||||
+ }
|
||||
+ s/[&\|]/\\&/g
|
||||
+ s/\n/\\n/g
|
||||
');;
|
||||
esac
|
||||
sed_script="s|^|$i:|"
|
||||
@@ -4,6 +4,7 @@ LICENSE = "GPLv3+"
|
||||
|
||||
SRC_URI = "${GNU_MIRROR}/gzip/${BP}.tar.gz \
|
||||
file://run-ptest \
|
||||
file://CVE-2022-1271.patch \
|
||||
"
|
||||
SRC_URI_append_class-target = " file://wrong-path-fix.patch"
|
||||
|
||||
|
||||
@@ -17,9 +17,19 @@ CVE: CVE-2021-33928
|
||||
CVE: CVE-2021-33929
|
||||
CVE: CVE-2021-33930
|
||||
CVE: CVE-2021-33938
|
||||
CVE: CVE-2021-44568
|
||||
CVE: CVE-2021-44569
|
||||
CVE: CVE-2021-44570
|
||||
CVE: CVE-2021-44571
|
||||
CVE: CVE-2021-44573
|
||||
CVE: CVE-2021-44574
|
||||
CVE: CVE-2021-44575
|
||||
CVE: CVE-2021-44576
|
||||
CVE: CVE-2021-44577
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
---
|
||||
ext/testcase.c | 21 +++++++++++++++++++++
|
||||
1 file changed, 21 insertions(+)
|
||||
|
||||
@@ -6,7 +6,7 @@ SECTION = "base"
|
||||
LICENSE = "PD & BSD-3-Clause"
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=c679c9d6b02bc2757b3eaf8f53c43fba"
|
||||
|
||||
PV = "2021e"
|
||||
PV = "2022a"
|
||||
|
||||
SRC_URI =" http://www.iana.org/time-zones/repository/releases/tzcode${PV}.tar.gz;name=tzcode \
|
||||
http://www.iana.org/time-zones/repository/releases/tzdata${PV}.tar.gz;name=tzdata \
|
||||
@@ -14,6 +14,6 @@ SRC_URI =" http://www.iana.org/time-zones/repository/releases/tzcode${PV}.tar.gz
|
||||
|
||||
UPSTREAM_CHECK_URI = "http://www.iana.org/time-zones"
|
||||
|
||||
SRC_URI[tzcode.sha256sum] = "584666393a5424d13d27ec01183da17703273664742e049d4f62f62dab631775"
|
||||
SRC_URI[tzdata.sha256sum] = "07ec42b737d0d3c6be9c337f8abb5f00554a0f9cc4fcf01a703d69403b6bb2b1"
|
||||
SRC_URI[tzcode.sha256sum] = "f8575e7e33be9ee265df2081092526b81c80abac3f4a04399ae9d4d91cdadac7"
|
||||
SRC_URI[tzdata.sha256sum] = "ef7fffd9f4f50f4f58328b35022a32a5a056b245c5cb3d6791dddb342f871664"
|
||||
|
||||
|
||||
96
meta/recipes-extended/xz/xz/CVE-2022-1271.patch
Normal file
96
meta/recipes-extended/xz/xz/CVE-2022-1271.patch
Normal file
@@ -0,0 +1,96 @@
|
||||
From 6bb2369742f9ff0451c245e8ca9b9dfac0cc88ba Mon Sep 17 00:00:00 2001
|
||||
From: Lasse Collin <lasse.collin@tukaani.org>
|
||||
Date: Tue, 29 Mar 2022 19:19:12 +0300
|
||||
Subject: [PATCH] xzgrep: Fix escaping of malicious filenames (ZDI-CAN-16587).
|
||||
|
||||
Malicious filenames can make xzgrep to write to arbitrary files
|
||||
or (with a GNU sed extension) lead to arbitrary code execution.
|
||||
|
||||
xzgrep from XZ Utils versions up to and including 5.2.5 are
|
||||
affected. 5.3.1alpha and 5.3.2alpha are affected as well.
|
||||
This patch works for all of them.
|
||||
|
||||
This bug was inherited from gzip's zgrep. gzip 1.12 includes
|
||||
a fix for zgrep.
|
||||
|
||||
The issue with the old sed script is that with multiple newlines,
|
||||
the N-command will read the second line of input, then the
|
||||
s-commands will be skipped because it's not the end of the
|
||||
file yet, then a new sed cycle starts and the pattern space
|
||||
is printed and emptied. So only the last line or two get escaped.
|
||||
|
||||
One way to fix this would be to read all lines into the pattern
|
||||
space first. However, the included fix is even simpler: All lines
|
||||
except the last line get a backslash appended at the end. To ensure
|
||||
that shell command substitution doesn't eat a possible trailing
|
||||
newline, a colon is appended to the filename before escaping.
|
||||
The colon is later used to separate the filename from the grep
|
||||
output so it is fine to add it here instead of a few lines later.
|
||||
|
||||
The old code also wasn't POSIX compliant as it used \n in the
|
||||
replacement section of the s-command. Using \<newline> is the
|
||||
POSIX compatible method.
|
||||
|
||||
LC_ALL=C was added to the two critical sed commands. POSIX sed
|
||||
manual recommends it when using sed to manipulate pathnames
|
||||
because in other locales invalid multibyte sequences might
|
||||
cause issues with some sed implementations. In case of GNU sed,
|
||||
these particular sed scripts wouldn't have such problems but some
|
||||
other scripts could have, see:
|
||||
|
||||
info '(sed)Locale Considerations'
|
||||
|
||||
This vulnerability was discovered by:
|
||||
cleemy desu wayo working with Trend Micro Zero Day Initiative
|
||||
|
||||
Thanks to Jim Meyering and Paul Eggert discussing the different
|
||||
ways to fix this and for coordinating the patch release schedule
|
||||
with gzip.
|
||||
|
||||
Upstream-Status: Backport [https://tukaani.org/xz/xzgrep-ZDI-CAN-16587.patch]
|
||||
CVE: CVE-2022-1271
|
||||
|
||||
Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
|
||||
---
|
||||
src/scripts/xzgrep.in | 20 ++++++++++++--------
|
||||
1 file changed, 12 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/scripts/xzgrep.in b/src/scripts/xzgrep.in
|
||||
index a1fd19c..da1e65b 100644
|
||||
--- a/src/scripts/xzgrep.in
|
||||
+++ b/src/scripts/xzgrep.in
|
||||
@@ -178,22 +178,26 @@ for i; do
|
||||
{ test $# -eq 1 || test $no_filename -eq 1; }; then
|
||||
eval "$grep"
|
||||
else
|
||||
+ # Append a colon so that the last character will never be a newline
|
||||
+ # which would otherwise get lost in shell command substitution.
|
||||
+ i="$i:"
|
||||
+
|
||||
+ # Escape & \ | and newlines only if such characters are present
|
||||
+ # (speed optimization).
|
||||
case $i in
|
||||
(*'
|
||||
'* | *'&'* | *'\'* | *'|'*)
|
||||
- i=$(printf '%s\n' "$i" |
|
||||
- sed '
|
||||
- $!N
|
||||
- $s/[&\|]/\\&/g
|
||||
- $s/\n/\\n/g
|
||||
- ');;
|
||||
+ i=$(printf '%s\n' "$i" | LC_ALL=C sed 's/[&\|]/\\&/g; $!s/$/\\/');;
|
||||
esac
|
||||
- sed_script="s|^|$i:|"
|
||||
+
|
||||
+ # $i already ends with a colon so don't add it here.
|
||||
+ sed_script="s|^|$i|"
|
||||
|
||||
# Fail if grep or sed fails.
|
||||
r=$(
|
||||
exec 4>&1
|
||||
- (eval "$grep" 4>&-; echo $? >&4) 3>&- | sed "$sed_script" >&3 4>&-
|
||||
+ (eval "$grep" 4>&-; echo $? >&4) 3>&- |
|
||||
+ LC_ALL=C sed "$sed_script" >&3 4>&-
|
||||
) || r=2
|
||||
exit $r
|
||||
fi >&3 5>&-
|
||||
@@ -23,7 +23,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=97d554a32881fee0aa283d96e47cb24a \
|
||||
file://lib/getopt.c;endline=23;md5=2069b0ee710572c03bb3114e4532cd84 \
|
||||
"
|
||||
|
||||
SRC_URI = "https://tukaani.org/xz/xz-${PV}.tar.gz"
|
||||
SRC_URI = "https://tukaani.org/xz/xz-${PV}.tar.gz \
|
||||
file://CVE-2022-1271.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ace3264bdd00c65eeec2891346f65e6"
|
||||
SRC_URI[sha256sum] = "b512f3b726d3b37b6dc4c8570e137b9311e7552e8ccbab4d39d47ce5f4177145"
|
||||
UPSTREAM_CHECK_REGEX = "xz-(?P<pver>\d+(\.\d+)+)\.tar"
|
||||
|
||||
@@ -10,7 +10,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=c81c08eeefd9418fca8f88309a76db10"
|
||||
|
||||
DEPENDS = "libdrm mesa libepoxy"
|
||||
SRCREV = "7d204f3927be65fb3365dce01dbcd04d447a4985"
|
||||
SRC_URI = "git://anongit.freedesktop.org/virglrenderer;branch=master \
|
||||
SRC_URI = "git://anongit.freedesktop.org/git/virglrenderer;branch=master \
|
||||
file://0001-gallium-Expand-libc-check-to-be-platform-OS-check.patch \
|
||||
file://0001-meson.build-use-python3-directly-for-python.patch \
|
||||
"
|
||||
|
||||
@@ -6,7 +6,7 @@ using file descriptor passing."
|
||||
|
||||
require xorg-lib-common.inc
|
||||
|
||||
LICENSE = "MIT-style"
|
||||
LICENSE = "HPND"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=47e508ca280fde97906eacb77892c3ac"
|
||||
|
||||
DEPENDS += "virtual/libx11"
|
||||
|
||||
@@ -16,7 +16,7 @@ PE = "2"
|
||||
INC_PR = "r8"
|
||||
|
||||
XORG_PN = "xorg-server"
|
||||
SRC_URI = "${XORG_MIRROR}/individual/xserver/${XORG_PN}-${PV}.tar.bz2"
|
||||
SRC_URI = "${XORG_MIRROR}/individual/xserver/${XORG_PN}-${PV}.tar.gz"
|
||||
|
||||
CVE_PRODUCT = "xorg-server x_server"
|
||||
# This is specific to Debian's xserver-wrapper.c
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
From f7cd1276bbd4fe3a9700096dec33b52b8440788d Mon Sep 17 00:00:00 2001
|
||||
From: Matthieu Herrb <matthieu@herrb.eu>
|
||||
Date: Tue, 18 Aug 2020 14:46:32 +0200
|
||||
Subject: [PATCH] Correct bounds checking in XkbSetNames()
|
||||
|
||||
CVE-2020-14345 / ZDI 11428
|
||||
|
||||
This vulnerability was discovered by:
|
||||
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
||||
|
||||
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
|
||||
|
||||
Upstream-Status: Backport
|
||||
CVE: CVE-2020-14345
|
||||
Affects < 1.20.9
|
||||
|
||||
Signed-off-by: Armin Kuster <akuster@mvista.com>
|
||||
|
||||
---
|
||||
xkb/xkb.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 48 insertions(+)
|
||||
|
||||
Index: xorg-server-1.20.8/xkb/xkb.c
|
||||
===================================================================
|
||||
--- xorg-server-1.20.8.orig/xkb/xkb.c
|
||||
+++ xorg-server-1.20.8/xkb/xkb.c
|
||||
@@ -152,6 +152,19 @@ static RESTYPE RT_XKBCLIENT;
|
||||
#define CHK_REQ_KEY_RANGE(err,first,num,r) \
|
||||
CHK_REQ_KEY_RANGE2(err,first,num,r,client->errorValue,BadValue)
|
||||
|
||||
+static Bool
|
||||
+_XkbCheckRequestBounds(ClientPtr client, void *stuff, void *from, void *to) {
|
||||
+ char *cstuff = (char *)stuff;
|
||||
+ char *cfrom = (char *)from;
|
||||
+ char *cto = (char *)to;
|
||||
+
|
||||
+ return cfrom < cto &&
|
||||
+ cfrom >= cstuff &&
|
||||
+ cfrom < cstuff + ((size_t)client->req_len << 2) &&
|
||||
+ cto >= cstuff &&
|
||||
+ cto <= cstuff + ((size_t)client->req_len << 2);
|
||||
+}
|
||||
+
|
||||
/***====================================================================***/
|
||||
|
||||
int
|
||||
@@ -4045,6 +4058,8 @@ _XkbSetNamesCheck(ClientPtr client, Devi
|
||||
client->errorValue = _XkbErrCode2(0x04, stuff->firstType);
|
||||
return BadAccess;
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + stuff->nTypes))
|
||||
+ return BadLength;
|
||||
old = tmp;
|
||||
tmp = _XkbCheckAtoms(tmp, stuff->nTypes, client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
@@ -4074,6 +4089,8 @@ _XkbSetNamesCheck(ClientPtr client, Devi
|
||||
}
|
||||
width = (CARD8 *) tmp;
|
||||
tmp = (CARD32 *) (((char *) tmp) + XkbPaddedSize(stuff->nKTLevels));
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, width, tmp))
|
||||
+ return BadLength;
|
||||
type = &xkb->map->types[stuff->firstKTLevel];
|
||||
for (i = 0; i < stuff->nKTLevels; i++, type++) {
|
||||
if (width[i] == 0)
|
||||
@@ -4083,6 +4100,8 @@ _XkbSetNamesCheck(ClientPtr client, Devi
|
||||
type->num_levels, width[i]);
|
||||
return BadMatch;
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + width[i]))
|
||||
+ return BadLength;
|
||||
tmp = _XkbCheckAtoms(tmp, width[i], client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
client->errorValue = bad;
|
||||
@@ -4095,6 +4114,9 @@ _XkbSetNamesCheck(ClientPtr client, Devi
|
||||
client->errorValue = 0x08;
|
||||
return BadMatch;
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp,
|
||||
+ tmp + Ones(stuff->indicators)))
|
||||
+ return BadLength;
|
||||
tmp = _XkbCheckMaskedAtoms(tmp, XkbNumIndicators, stuff->indicators,
|
||||
client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
@@ -4107,6 +4129,9 @@ _XkbSetNamesCheck(ClientPtr client, Devi
|
||||
client->errorValue = 0x09;
|
||||
return BadMatch;
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp,
|
||||
+ tmp + Ones(stuff->virtualMods)))
|
||||
+ return BadLength;
|
||||
tmp = _XkbCheckMaskedAtoms(tmp, XkbNumVirtualMods,
|
||||
(CARD32) stuff->virtualMods,
|
||||
client->swapped, &bad);
|
||||
@@ -4120,6 +4145,9 @@ _XkbSetNamesCheck(ClientPtr client, Devi
|
||||
client->errorValue = 0x0a;
|
||||
return BadMatch;
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp,
|
||||
+ tmp + Ones(stuff->groupNames)))
|
||||
+ return BadLength;
|
||||
tmp = _XkbCheckMaskedAtoms(tmp, XkbNumKbdGroups,
|
||||
(CARD32) stuff->groupNames,
|
||||
client->swapped, &bad);
|
||||
@@ -4141,9 +4169,14 @@ _XkbSetNamesCheck(ClientPtr client, Devi
|
||||
stuff->nKeys);
|
||||
return BadValue;
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + stuff->nKeys))
|
||||
+ return BadLength;
|
||||
tmp += stuff->nKeys;
|
||||
}
|
||||
if ((stuff->which & XkbKeyAliasesMask) && (stuff->nKeyAliases > 0)) {
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp,
|
||||
+ tmp + (stuff->nKeyAliases * 2)))
|
||||
+ return BadLength;
|
||||
tmp += stuff->nKeyAliases * 2;
|
||||
}
|
||||
if (stuff->which & XkbRGNamesMask) {
|
||||
@@ -4151,6 +4184,9 @@ _XkbSetNamesCheck(ClientPtr client, Devi
|
||||
client->errorValue = _XkbErrCode2(0x0d, stuff->nRadioGroups);
|
||||
return BadValue;
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp,
|
||||
+ tmp + stuff->nRadioGroups))
|
||||
+ return BadLength;
|
||||
tmp = _XkbCheckAtoms(tmp, stuff->nRadioGroups, client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
client->errorValue = bad;
|
||||
@@ -4344,6 +4380,8 @@ ProcXkbSetNames(ClientPtr client)
|
||||
/* check device-independent stuff */
|
||||
tmp = (CARD32 *) &stuff[1];
|
||||
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + 1))
|
||||
+ return BadLength;
|
||||
if (stuff->which & XkbKeycodesNameMask) {
|
||||
tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
@@ -4351,6 +4389,8 @@ ProcXkbSetNames(ClientPtr client)
|
||||
return BadAtom;
|
||||
}
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + 1))
|
||||
+ return BadLength;
|
||||
if (stuff->which & XkbGeometryNameMask) {
|
||||
tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
@@ -4358,6 +4398,8 @@ ProcXkbSetNames(ClientPtr client)
|
||||
return BadAtom;
|
||||
}
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + 1))
|
||||
+ return BadLength;
|
||||
if (stuff->which & XkbSymbolsNameMask) {
|
||||
tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
@@ -4365,6 +4407,8 @@ ProcXkbSetNames(ClientPtr client)
|
||||
return BadAtom;
|
||||
}
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + 1))
|
||||
+ return BadLength;
|
||||
if (stuff->which & XkbPhysSymbolsNameMask) {
|
||||
tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
@@ -4372,6 +4416,8 @@ ProcXkbSetNames(ClientPtr client)
|
||||
return BadAtom;
|
||||
}
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + 1))
|
||||
+ return BadLength;
|
||||
if (stuff->which & XkbTypesNameMask) {
|
||||
tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
@@ -4379,6 +4425,8 @@ ProcXkbSetNames(ClientPtr client)
|
||||
return BadAtom;
|
||||
}
|
||||
}
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, tmp, tmp + 1))
|
||||
+ return BadLength;
|
||||
if (stuff->which & XkbCompatNameMask) {
|
||||
tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad);
|
||||
if (!tmp) {
|
||||
@@ -1,36 +0,0 @@
|
||||
From c940cc8b6c0a2983c1ec974f1b3f019795dd4cff Mon Sep 17 00:00:00 2001
|
||||
From: Matthieu Herrb <matthieu@herrb.eu>
|
||||
Date: Tue, 18 Aug 2020 14:49:04 +0200
|
||||
Subject: [PATCH] Fix XIChangeHierarchy() integer underflow
|
||||
|
||||
CVE-2020-14346 / ZDI-CAN-11429
|
||||
|
||||
This vulnerability was discovered by:
|
||||
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
||||
|
||||
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://gitlab.freedesktop.org/xorg/xserver/-/commit/c940cc8b6c0a2983c1ec974f1b3f019795dd4cff]
|
||||
CVE: CVE-2020-14346
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
Xi/xichangehierarchy.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
|
||||
index cbdd91258..504defe56 100644
|
||||
--- a/Xi/xichangehierarchy.c
|
||||
+++ b/Xi/xichangehierarchy.c
|
||||
@@ -423,7 +423,7 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||
if (!stuff->num_changes)
|
||||
return rc;
|
||||
|
||||
- len = ((size_t)stuff->length << 2) - sizeof(xXIChangeHierarchyReq);
|
||||
+ len = ((size_t)client->req_len << 2) - sizeof(xXIChangeHierarchyReq);
|
||||
|
||||
any = (xXIAnyHierarchyChangeInfo *) &stuff[1];
|
||||
while (stuff->num_changes--) {
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
From aac28e162e5108510065ad4c323affd6deffd816 Mon Sep 17 00:00:00 2001
|
||||
From: Matthieu Herrb <matthieu@herrb.eu>
|
||||
Date: Sat, 25 Jul 2020 19:33:50 +0200
|
||||
Subject: [PATCH] fix for ZDI-11426
|
||||
|
||||
Avoid leaking un-initalized memory to clients by zeroing the
|
||||
whole pixmap on initial allocation.
|
||||
|
||||
This vulnerability was discovered by:
|
||||
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
||||
|
||||
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
|
||||
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
|
||||
|
||||
|
||||
Upstream-Status: Backport [https://gitlab.freedesktop.org/xorg/xserver/-/commit/aac28e162e5108510065ad4c323affd6deffd816]
|
||||
CVE: CVE-2020-14347
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
dix/pixmap.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dix/pixmap.c b/dix/pixmap.c
|
||||
index 1186d7dbbf..5a0146bbb6 100644
|
||||
--- a/dix/pixmap.c
|
||||
+++ b/dix/pixmap.c
|
||||
@@ -116,7 +116,7 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
|
||||
if (pScreen->totalPixmapSize > ((size_t) - 1) - pixDataSize)
|
||||
return NullPixmap;
|
||||
|
||||
- pPixmap = malloc(pScreen->totalPixmapSize + pixDataSize);
|
||||
+ pPixmap = calloc(1, pScreen->totalPixmapSize + pixDataSize);
|
||||
if (!pPixmap)
|
||||
return NullPixmap;
|
||||
|
||||
--
|
||||
GitLab
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
From 446ff2d3177087b8173fa779fa5b77a2a128988b Mon Sep 17 00:00:00 2001
|
||||
From: Matthieu Herrb <matthieu@herrb.eu>
|
||||
Date: Thu, 12 Nov 2020 19:15:07 +0100
|
||||
Subject: [PATCH] Check SetMap request length carefully.
|
||||
|
||||
Avoid out of bounds memory accesses on too short request.
|
||||
|
||||
ZDI-CAN 11572 / CVE-2020-14360
|
||||
|
||||
This vulnerability was discovered by:
|
||||
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
||||
|
||||
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://gitlab.freedesktop.org/xorg/xserver/-/commit/446ff2d3177087b8173fa779fa5b77a2a128988b
|
||||
CVE: CVE-2020-14360
|
||||
Signed-off-by: Armin Kuster <akuster@mvista.com>
|
||||
---
|
||||
xkb/xkb.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 92 insertions(+)
|
||||
|
||||
Index: xorg-server-1.20.8/xkb/xkb.c
|
||||
===================================================================
|
||||
--- xorg-server-1.20.8.orig/xkb/xkb.c
|
||||
+++ xorg-server-1.20.8/xkb/xkb.c
|
||||
@@ -2382,6 +2382,93 @@ SetVirtualModMap(XkbSrvInfoPtr xkbi,
|
||||
return (char *) wire;
|
||||
}
|
||||
|
||||
+#define _add_check_len(new) \
|
||||
+ if (len > UINT32_MAX - (new) || len > req_len - (new)) goto bad; \
|
||||
+ else len += new
|
||||
+
|
||||
+/**
|
||||
+ * Check the length of the SetMap request
|
||||
+ */
|
||||
+static int
|
||||
+_XkbSetMapCheckLength(xkbSetMapReq *req)
|
||||
+{
|
||||
+ size_t len = sz_xkbSetMapReq, req_len = req->length << 2;
|
||||
+ xkbKeyTypeWireDesc *keytype;
|
||||
+ xkbSymMapWireDesc *symmap;
|
||||
+ BOOL preserve;
|
||||
+ int i, map_count, nSyms;
|
||||
+
|
||||
+ if (req_len < len)
|
||||
+ goto bad;
|
||||
+ /* types */
|
||||
+ if (req->present & XkbKeyTypesMask) {
|
||||
+ keytype = (xkbKeyTypeWireDesc *)(req + 1);
|
||||
+ for (i = 0; i < req->nTypes; i++) {
|
||||
+ _add_check_len(XkbPaddedSize(sz_xkbKeyTypeWireDesc));
|
||||
+ if (req->flags & XkbSetMapResizeTypes) {
|
||||
+ _add_check_len(keytype->nMapEntries
|
||||
+ * sz_xkbKTSetMapEntryWireDesc);
|
||||
+ preserve = keytype->preserve;
|
||||
+ map_count = keytype->nMapEntries;
|
||||
+ if (preserve) {
|
||||
+ _add_check_len(map_count * sz_xkbModsWireDesc);
|
||||
+ }
|
||||
+ keytype += 1;
|
||||
+ keytype = (xkbKeyTypeWireDesc *)
|
||||
+ ((xkbKTSetMapEntryWireDesc *)keytype + map_count);
|
||||
+ if (preserve)
|
||||
+ keytype = (xkbKeyTypeWireDesc *)
|
||||
+ ((xkbModsWireDesc *)keytype + map_count);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ /* syms */
|
||||
+ if (req->present & XkbKeySymsMask) {
|
||||
+ symmap = (xkbSymMapWireDesc *)((char *)req + len);
|
||||
+ for (i = 0; i < req->nKeySyms; i++) {
|
||||
+ _add_check_len(sz_xkbSymMapWireDesc);
|
||||
+ nSyms = symmap->nSyms;
|
||||
+ _add_check_len(nSyms*sizeof(CARD32));
|
||||
+ symmap += 1;
|
||||
+ symmap = (xkbSymMapWireDesc *)((CARD32 *)symmap + nSyms);
|
||||
+ }
|
||||
+ }
|
||||
+ /* actions */
|
||||
+ if (req->present & XkbKeyActionsMask) {
|
||||
+ _add_check_len(req->totalActs * sz_xkbActionWireDesc
|
||||
+ + XkbPaddedSize(req->nKeyActs));
|
||||
+ }
|
||||
+ /* behaviours */
|
||||
+ if (req->present & XkbKeyBehaviorsMask) {
|
||||
+ _add_check_len(req->totalKeyBehaviors * sz_xkbBehaviorWireDesc);
|
||||
+ }
|
||||
+ /* vmods */
|
||||
+ if (req->present & XkbVirtualModsMask) {
|
||||
+ _add_check_len(XkbPaddedSize(Ones(req->virtualMods)));
|
||||
+ }
|
||||
+ /* explicit */
|
||||
+ if (req->present & XkbExplicitComponentsMask) {
|
||||
+ /* two bytes per non-zero explicit componen */
|
||||
+ _add_check_len(XkbPaddedSize(req->totalKeyExplicit * sizeof(CARD16)));
|
||||
+ }
|
||||
+ /* modmap */
|
||||
+ if (req->present & XkbModifierMapMask) {
|
||||
+ /* two bytes per non-zero modmap component */
|
||||
+ _add_check_len(XkbPaddedSize(req->totalModMapKeys * sizeof(CARD16)));
|
||||
+ }
|
||||
+ /* vmodmap */
|
||||
+ if (req->present & XkbVirtualModMapMask) {
|
||||
+ _add_check_len(req->totalVModMapKeys * sz_xkbVModMapWireDesc);
|
||||
+ }
|
||||
+ if (len == req_len)
|
||||
+ return Success;
|
||||
+bad:
|
||||
+ ErrorF("[xkb] BOGUS LENGTH in SetMap: expected %ld got %ld\n",
|
||||
+ len, req_len);
|
||||
+ return BadLength;
|
||||
+}
|
||||
+
|
||||
+
|
||||
/**
|
||||
* Check if the given request can be applied to the given device but don't
|
||||
* actually do anything..
|
||||
@@ -2639,6 +2726,11 @@ ProcXkbSetMap(ClientPtr client)
|
||||
CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess);
|
||||
CHK_MASK_LEGAL(0x01, stuff->present, XkbAllMapComponentsMask);
|
||||
|
||||
+ /* first verify the request length carefully */
|
||||
+ rc = _XkbSetMapCheckLength(stuff);
|
||||
+ if (rc != Success)
|
||||
+ return rc;
|
||||
+
|
||||
tmp = (char *) &stuff[1];
|
||||
|
||||
/* Check if we can to the SetMap on the requested device. If this
|
||||
@@ -1,36 +0,0 @@
|
||||
From 144849ea27230962227e62a943b399e2ab304787 Mon Sep 17 00:00:00 2001
|
||||
From: Matthieu Herrb <matthieu@herrb.eu>
|
||||
Date: Tue, 18 Aug 2020 14:52:29 +0200
|
||||
Subject: [PATCH] Fix XkbSelectEvents() integer underflow
|
||||
|
||||
CVE-2020-14361 ZDI-CAN 11573
|
||||
|
||||
This vulnerability was discovered by:
|
||||
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
||||
|
||||
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://gitlab.freedesktop.org/xorg/xserver/-/commit/144849ea27230962227e62a943b399e2ab304787]
|
||||
CVE: CVE-2020-14361
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
xkb/xkbSwap.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/xkb/xkbSwap.c b/xkb/xkbSwap.c
|
||||
index 1c1ed5ff4..50cabb90e 100644
|
||||
--- a/xkb/xkbSwap.c
|
||||
+++ b/xkb/xkbSwap.c
|
||||
@@ -76,7 +76,7 @@ SProcXkbSelectEvents(ClientPtr client)
|
||||
register unsigned bit, ndx, maskLeft, dataLeft, size;
|
||||
|
||||
from.c8 = (CARD8 *) &stuff[1];
|
||||
- dataLeft = (stuff->length * 4) - SIZEOF(xkbSelectEventsReq);
|
||||
+ dataLeft = (client->req_len * 4) - SIZEOF(xkbSelectEventsReq);
|
||||
maskLeft = (stuff->affectWhich & (~XkbMapNotifyMask));
|
||||
for (ndx = 0, bit = 1; (maskLeft != 0); ndx++, bit <<= 1) {
|
||||
if (((bit & maskLeft) == 0) || (ndx == XkbMapNotify))
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
From 2902b78535ecc6821cc027351818b28a5c7fdbdc Mon Sep 17 00:00:00 2001
|
||||
From: Matthieu Herrb <matthieu@herrb.eu>
|
||||
Date: Tue, 18 Aug 2020 14:55:01 +0200
|
||||
Subject: [PATCH] Fix XRecordRegisterClients() Integer underflow
|
||||
|
||||
CVE-2020-14362 ZDI-CAN-11574
|
||||
|
||||
This vulnerability was discovered by:
|
||||
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
||||
|
||||
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://gitlab.freedesktop.org/xorg/xserver/-/commit/2902b78535ecc6821cc027351818b28a5c7fdbdc]
|
||||
CVE: CVE-2020-14362
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
record/record.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/record/record.c b/record/record.c
|
||||
index f2d38c877..be154525d 100644
|
||||
--- a/record/record.c
|
||||
+++ b/record/record.c
|
||||
@@ -2500,7 +2500,7 @@ SProcRecordQueryVersion(ClientPtr client)
|
||||
} /* SProcRecordQueryVersion */
|
||||
|
||||
static int _X_COLD
|
||||
-SwapCreateRegister(xRecordRegisterClientsReq * stuff)
|
||||
+SwapCreateRegister(ClientPtr client, xRecordRegisterClientsReq * stuff)
|
||||
{
|
||||
int i;
|
||||
XID *pClientID;
|
||||
@@ -2510,13 +2510,13 @@ SwapCreateRegister(xRecordRegisterClientsReq * stuff)
|
||||
swapl(&stuff->nRanges);
|
||||
pClientID = (XID *) &stuff[1];
|
||||
if (stuff->nClients >
|
||||
- stuff->length - bytes_to_int32(sz_xRecordRegisterClientsReq))
|
||||
+ client->req_len - bytes_to_int32(sz_xRecordRegisterClientsReq))
|
||||
return BadLength;
|
||||
for (i = 0; i < stuff->nClients; i++, pClientID++) {
|
||||
swapl(pClientID);
|
||||
}
|
||||
if (stuff->nRanges >
|
||||
- stuff->length - bytes_to_int32(sz_xRecordRegisterClientsReq)
|
||||
+ client->req_len - bytes_to_int32(sz_xRecordRegisterClientsReq)
|
||||
- stuff->nClients)
|
||||
return BadLength;
|
||||
RecordSwapRanges((xRecordRange *) pClientID, stuff->nRanges);
|
||||
@@ -2531,7 +2531,7 @@ SProcRecordCreateContext(ClientPtr client)
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq);
|
||||
- if ((status = SwapCreateRegister((void *) stuff)) != Success)
|
||||
+ if ((status = SwapCreateRegister(client, (void *) stuff)) != Success)
|
||||
return status;
|
||||
return ProcRecordCreateContext(client);
|
||||
} /* SProcRecordCreateContext */
|
||||
@@ -2544,7 +2544,7 @@ SProcRecordRegisterClients(ClientPtr client)
|
||||
|
||||
swaps(&stuff->length);
|
||||
REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq);
|
||||
- if ((status = SwapCreateRegister((void *) stuff)) != Success)
|
||||
+ if ((status = SwapCreateRegister(client, (void *) stuff)) != Success)
|
||||
return status;
|
||||
return ProcRecordRegisterClients(client);
|
||||
} /* SProcRecordRegisterClients */
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
From 87c64fc5b0db9f62f4e361444f4b60501ebf67b9 Mon Sep 17 00:00:00 2001
|
||||
From: Matthieu Herrb <matthieu@herrb.eu>
|
||||
Date: Sun, 11 Oct 2020 17:05:09 +0200
|
||||
Subject: [PATCH] Fix XkbSetDeviceInfo() and SetDeviceIndicators() heap
|
||||
overflows
|
||||
|
||||
ZDI-CAN 11389 / CVE-2020-25712
|
||||
|
||||
This vulnerability was discovered by:
|
||||
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
||||
|
||||
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://gitlab.freedesktop.org/xorg/xserver/-/commit/87c64fc5b0db9f62f4e361444f4b60501ebf67b9
|
||||
CVE: CVE-2020-25712
|
||||
Signed-off-by: Armin Kuster <akuster@mvista.com>
|
||||
|
||||
---
|
||||
xkb/xkb.c | 26 +++++++++++++++++++++++---
|
||||
1 file changed, 23 insertions(+), 3 deletions(-)
|
||||
|
||||
Index: xorg-server-1.20.8/xkb/xkb.c
|
||||
===================================================================
|
||||
--- xorg-server-1.20.8.orig/xkb/xkb.c
|
||||
+++ xorg-server-1.20.8/xkb/xkb.c
|
||||
@@ -6625,7 +6625,9 @@ SetDeviceIndicators(char *wire,
|
||||
unsigned changed,
|
||||
int num,
|
||||
int *status_rtrn,
|
||||
- ClientPtr client, xkbExtensionDeviceNotify * ev)
|
||||
+ ClientPtr client,
|
||||
+ xkbExtensionDeviceNotify * ev,
|
||||
+ xkbSetDeviceInfoReq * stuff)
|
||||
{
|
||||
xkbDeviceLedsWireDesc *ledWire;
|
||||
int i;
|
||||
@@ -6646,6 +6648,11 @@ SetDeviceIndicators(char *wire,
|
||||
xkbIndicatorMapWireDesc *mapWire;
|
||||
XkbSrvLedInfoPtr sli;
|
||||
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, ledWire, ledWire + 1)) {
|
||||
+ *status_rtrn = BadLength;
|
||||
+ return (char *) ledWire;
|
||||
+ }
|
||||
+
|
||||
namec = mapc = statec = 0;
|
||||
sli = XkbFindSrvLedInfo(dev, ledWire->ledClass, ledWire->ledID,
|
||||
XkbXI_IndicatorMapsMask);
|
||||
@@ -6664,6 +6671,10 @@ SetDeviceIndicators(char *wire,
|
||||
memset((char *) sli->names, 0, XkbNumIndicators * sizeof(Atom));
|
||||
for (n = 0, bit = 1; n < XkbNumIndicators; n++, bit <<= 1) {
|
||||
if (ledWire->namesPresent & bit) {
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, atomWire, atomWire + 1)) {
|
||||
+ *status_rtrn = BadLength;
|
||||
+ return (char *) atomWire;
|
||||
+ }
|
||||
sli->names[n] = (Atom) *atomWire;
|
||||
if (sli->names[n] == None)
|
||||
ledWire->namesPresent &= ~bit;
|
||||
@@ -6681,6 +6692,10 @@ SetDeviceIndicators(char *wire,
|
||||
if (ledWire->mapsPresent) {
|
||||
for (n = 0, bit = 1; n < XkbNumIndicators; n++, bit <<= 1) {
|
||||
if (ledWire->mapsPresent & bit) {
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, mapWire, mapWire + 1)) {
|
||||
+ *status_rtrn = BadLength;
|
||||
+ return (char *) mapWire;
|
||||
+ }
|
||||
sli->maps[n].flags = mapWire->flags;
|
||||
sli->maps[n].which_groups = mapWire->whichGroups;
|
||||
sli->maps[n].groups = mapWire->groups;
|
||||
@@ -6760,7 +6775,7 @@ _XkbSetDeviceInfoCheck(ClientPtr client,
|
||||
ed.deviceID = dev->id;
|
||||
wire = (char *) &stuff[1];
|
||||
if (stuff->change & XkbXI_ButtonActionsMask) {
|
||||
- int nBtns, sz, i;
|
||||
+ int nBtns, sz, i;
|
||||
XkbAction *acts;
|
||||
DeviceIntPtr kbd;
|
||||
|
||||
@@ -6772,7 +6787,11 @@ _XkbSetDeviceInfoCheck(ClientPtr client,
|
||||
return BadAlloc;
|
||||
dev->button->xkb_acts = acts;
|
||||
}
|
||||
+ if (stuff->firstBtn + stuff->nBtns > nBtns)
|
||||
+ return BadValue;
|
||||
sz = stuff->nBtns * SIZEOF(xkbActionWireDesc);
|
||||
+ if (!_XkbCheckRequestBounds(client, stuff, wire, (char *) wire + sz))
|
||||
+ return BadLength;
|
||||
memcpy((char *) &acts[stuff->firstBtn], (char *) wire, sz);
|
||||
wire += sz;
|
||||
ed.reason |= XkbXI_ButtonActionsMask;
|
||||
@@ -6793,7 +6812,8 @@ _XkbSetDeviceInfoCheck(ClientPtr client,
|
||||
int status = Success;
|
||||
|
||||
wire = SetDeviceIndicators(wire, dev, stuff->change,
|
||||
- stuff->nDeviceLedFBs, &status, client, &ed);
|
||||
+ stuff->nDeviceLedFBs, &status, client, &ed,
|
||||
+ stuff);
|
||||
if (status != Success)
|
||||
return status;
|
||||
}
|
||||
@@ -5,16 +5,9 @@ SRC_URI += "file://0001-xf86pciBus.c-use-Intel-ddx-only-for-pre-gen4-hardwar.pat
|
||||
file://0001-test-xtest-Initialize-array-with-braces.patch \
|
||||
file://sdksyms-no-build-path.patch \
|
||||
file://0001-drmmode_display.c-add-missing-mi.h-include.patch \
|
||||
file://CVE-2020-14347.patch \
|
||||
file://CVE-2020-14346.patch \
|
||||
file://CVE-2020-14361.patch \
|
||||
file://CVE-2020-14362.patch \
|
||||
file://CVE-2020-14345.patch \
|
||||
file://CVE-2020-14360.patch \
|
||||
file://CVE-2020-25712.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "a770aec600116444a953ff632f51f839"
|
||||
SRC_URI[sha256sum] = "d17b646bee4ba0fb7850c1cc55b18e3e8513ed5c02bdf38da7e107f84e2d0146"
|
||||
SRC_URI[md5sum] = "453fc86aac8c629b3a5b77e8dcca30bf"
|
||||
SRC_URI[sha256sum] = "54b199c9280ff8bf0f73a54a759645bd0eeeda7255d1c99310d5b7595f3ac066"
|
||||
|
||||
CFLAGS += "-fcommon"
|
||||
|
||||
@@ -72,7 +72,7 @@ LICENSE = "\
|
||||
LIC_FILES_CHKSUM = "file://LICENCE.Abilis;md5=b5ee3f410780e56711ad48eadc22b8bc \
|
||||
file://LICENCE.adsp_sst;md5=615c45b91a5a4a9fe046d6ab9a2df728 \
|
||||
file://LICENCE.agere;md5=af0133de6b4a9b2522defd5f188afd31 \
|
||||
file://LICENSE.amdgpu;md5=d357524f5099e2a3db3c1838921c593f \
|
||||
file://LICENSE.amdgpu;md5=44c1166d052226cb2d6c8d7400090203 \
|
||||
file://LICENSE.amd-ucode;md5=3c5399dc9148d7f0e1f41e34b69cf14f \
|
||||
file://LICENSE.amlogic_vdec;md5=dc44f59bf64a81643e500ad3f39a468a \
|
||||
file://LICENCE.atheros_firmware;md5=30a14c7823beedac9fa39c64fdd01a13 \
|
||||
@@ -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=ed3d7426e4df06fbadcca24ebf00cc5f \
|
||||
file://WHENCE;md5=4cf67d71a21887c682c3989a4318745e \
|
||||
"
|
||||
|
||||
# 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] = "e2e46fa618414952bbf2f6920cd3abcddbef45bfb7d1352994b4bfc35394d177"
|
||||
SRC_URI[sha256sum] = "020b11f6412f4956f5a6f98de7d41867d2b30ea0ce81b1e2d206ec9840363849"
|
||||
|
||||
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 ?= "40423bc7ab2cc609f955a3dc16a0d854c1504ce3"
|
||||
SRCREV_meta ?= "e8c675c7e11fbd96cd812dfb9f4f6fb6f92b6abb"
|
||||
SRCREV_machine ?= "5b157591793811a9d226866d9f8acde817339fe9"
|
||||
SRCREV_meta ?= "6a12bea7312868626062fe8206ce3c5bcb7c9101"
|
||||
|
||||
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.178"
|
||||
LINUX_VERSION ?= "5.4.190"
|
||||
|
||||
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.178"
|
||||
LINUX_VERSION ?= "5.4.190"
|
||||
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 ?= "f6e09845d8bf3c307da395497b21c1ff17ef575c"
|
||||
SRCREV_machine ?= "a7ba52065be4401b5d73b6b020770f7d260b7bf1"
|
||||
SRCREV_meta ?= "e8c675c7e11fbd96cd812dfb9f4f6fb6f92b6abb"
|
||||
SRCREV_machine_qemuarm ?= "25567bdff9816844f3b9e09cdb490d7c7bfb4edb"
|
||||
SRCREV_machine ?= "36a8131ee4418c5f8883ff165833776746e61e84"
|
||||
SRCREV_meta ?= "6a12bea7312868626062fe8206ce3c5bcb7c9101"
|
||||
|
||||
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 ?= "b3ee7c62bf5a5ce3c7e30aff6c3dd9f70a847a28"
|
||||
SRCREV_machine_qemuarm64 ?= "bf6581eba15cb43af60fda7053edaf66990c18ac"
|
||||
SRCREV_machine_qemumips ?= "05580fff716df568dc3f737b288e0e514a908572"
|
||||
SRCREV_machine_qemuppc ?= "0a016b0775980f67d686e47cc8637adec46856dc"
|
||||
SRCREV_machine_qemuriscv64 ?= "e2020dbe2ccaef50d7e8f37a5bf08c68a006a064"
|
||||
SRCREV_machine_qemux86 ?= "e2020dbe2ccaef50d7e8f37a5bf08c68a006a064"
|
||||
SRCREV_machine_qemux86-64 ?= "e2020dbe2ccaef50d7e8f37a5bf08c68a006a064"
|
||||
SRCREV_machine_qemumips64 ?= "68f35eeca08d2a681495fd3a7b823ac34d9a97bc"
|
||||
SRCREV_machine ?= "e2020dbe2ccaef50d7e8f37a5bf08c68a006a064"
|
||||
SRCREV_meta ?= "e8c675c7e11fbd96cd812dfb9f4f6fb6f92b6abb"
|
||||
SRCREV_machine_qemuarm ?= "c4efc0b0650c3d2a7a321a6ba5fe612b7d14bd3f"
|
||||
SRCREV_machine_qemuarm64 ?= "c5b5ccb7df29d44c4e3d71d0e2ccf3e8a462a7f0"
|
||||
SRCREV_machine_qemumips ?= "addad5fd9e5c386a4b06938ae73de42292d552be"
|
||||
SRCREV_machine_qemuppc ?= "ee0f3e8a7de91b0520da532f87f8deeb91a92e27"
|
||||
SRCREV_machine_qemuriscv64 ?= "d9d6c6e0d0a9a52f9acd488036a5ed6409352f44"
|
||||
SRCREV_machine_qemux86 ?= "d9d6c6e0d0a9a52f9acd488036a5ed6409352f44"
|
||||
SRCREV_machine_qemux86-64 ?= "d9d6c6e0d0a9a52f9acd488036a5ed6409352f44"
|
||||
SRCREV_machine_qemumips64 ?= "971edcacc688c0deb078f4643125c5c5372010c5"
|
||||
SRCREV_machine ?= "d9d6c6e0d0a9a52f9acd488036a5ed6409352f44"
|
||||
SRCREV_meta ?= "6a12bea7312868626062fe8206ce3c5bcb7c9101"
|
||||
|
||||
# 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.178"
|
||||
LINUX_VERSION ?= "5.4.190"
|
||||
|
||||
DEPENDS += "${@bb.utils.contains('ARCH', 'x86', 'elfutils-native', '', d)}"
|
||||
DEPENDS += "openssl-native util-linux-native"
|
||||
|
||||
@@ -5,7 +5,7 @@ LICENSE = "ISC"
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=07c4f6dea3845b02a18dc00c8c87699c"
|
||||
|
||||
SRC_URI = "https://www.kernel.org/pub/software/network/${BPN}/${BP}.tar.xz"
|
||||
SRC_URI[sha256sum] = "8828c25a4ee25020044004f57374bb9deac852809fad70f8d3d01770bf9ac97f"
|
||||
SRC_URI[sha256sum] = "884ba2e3c1e8b98762b6dc25ff60b5ec75c8d33a39e019b3ed4aa615491460d3"
|
||||
|
||||
inherit bin_package allarch
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
From f9d0e594d43afcb4ab0043117249feb266ba4515 Mon Sep 17 00:00:00 2001
|
||||
From: Romain Geissler <romain.geissler@amadeus.com>
|
||||
Date: Tue, 10 Aug 2021 14:22:28 +0000
|
||||
Subject: [PATCH] Fix -Wsign-compare warning with glibc 2.34 on Linux
|
||||
platforms.
|
||||
|
||||
In file included from /data/mwrep/res/osp/Boost/21-0-0-0/include/boost/thread/thread_only.hpp:17,
|
||||
from /data/mwrep/res/osp/Boost/21-0-0-0/include/boost/thread/thread.hpp:12,
|
||||
from src/GetTest.cpp:12:
|
||||
/data/mwrep/res/osp/Boost/21-0-0-0/include/boost/thread/pthread/thread_data.hpp: In member function 'void boost::thread_attributes::set_stack_size(std::size_t)':
|
||||
/data/mwrep/res/osp/Boost/21-0-0-0/include/boost/thread/pthread/thread_data.hpp:61:19: error: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'long int' [-Werror=sign-compare]
|
||||
61 | if (size<PTHREAD_STACK_MIN) size=PTHREAD_STACK_MIN;
|
||||
| ^
|
||||
|
||||
Upstream-Status: Backport [1.78.0 https://github.com/boostorg/thread/commit/f9d0e594d43afcb4ab0043117249feb266ba4515]
|
||||
---
|
||||
boost/thread/pthread/thread_data.hpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/boost/thread/pthread/thread_data.hpp b/boost/thread/pthread/thread_data.hpp
|
||||
index bc9b1367..c43b276d 100644
|
||||
--- a/boost/thread/pthread/thread_data.hpp
|
||||
+++ b/boost/thread/pthread/thread_data.hpp
|
||||
@@ -58,7 +58,7 @@ namespace boost
|
||||
std::size_t page_size = ::sysconf( _SC_PAGESIZE);
|
||||
#endif
|
||||
#ifdef PTHREAD_STACK_MIN
|
||||
- if (size<PTHREAD_STACK_MIN) size=PTHREAD_STACK_MIN;
|
||||
+ if (size<static_cast<std::size_t>(PTHREAD_STACK_MIN)) size=PTHREAD_STACK_MIN;
|
||||
#endif
|
||||
size = ((size+page_size-1)/page_size)*page_size;
|
||||
int res = pthread_attr_setstacksize(&val_, size);
|
||||
@@ -0,0 +1,24 @@
|
||||
From 74fb0a26099bc51d717f5f154b37231ce7df3e98 Mon Sep 17 00:00:00 2001
|
||||
From: Rob Boehne <robb@datalogics.com>
|
||||
Date: Wed, 20 Nov 2019 11:25:20 -0600
|
||||
Subject: [PATCH] Revert change to elide a warning that caused Solaris builds
|
||||
to fail.
|
||||
|
||||
Upstream-Status: Backport [1.73.0 https://github.com/boostorg/thread/commit/74fb0a26099bc51d717f5f154b37231ce7df3e98]
|
||||
---
|
||||
boost/thread/pthread/thread_data.hpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/boost/thread/pthread/thread_data.hpp b/boost/thread/pthread/thread_data.hpp
|
||||
index aefbeb43..bc9b1367 100644
|
||||
--- a/boost/thread/pthread/thread_data.hpp
|
||||
+++ b/boost/thread/pthread/thread_data.hpp
|
||||
@@ -57,7 +57,7 @@ namespace boost
|
||||
#else
|
||||
std::size_t page_size = ::sysconf( _SC_PAGESIZE);
|
||||
#endif
|
||||
-#if PTHREAD_STACK_MIN > 0
|
||||
+#ifdef PTHREAD_STACK_MIN
|
||||
if (size<PTHREAD_STACK_MIN) size=PTHREAD_STACK_MIN;
|
||||
#endif
|
||||
size = ((size+page_size-1)/page_size)*page_size;
|
||||
@@ -9,4 +9,6 @@ SRC_URI += " \
|
||||
file://0001-dont-setup-compiler-flags-m32-m64.patch \
|
||||
file://0001-revert-cease-dependence-on-range.patch \
|
||||
file://0001-added-typedef-executor_type.patch \
|
||||
file://0001-Revert-change-to-elide-a-warning-that-caused-Solaris.patch \
|
||||
file://0001-Fix-Wsign-compare-warning-with-glibc-2.34-on-Linux-p.patch \
|
||||
"
|
||||
|
||||
347
meta/recipes-support/re2c/re2c/CVE-2018-21232-1.patch
Normal file
347
meta/recipes-support/re2c/re2c/CVE-2018-21232-1.patch
Normal file
@@ -0,0 +1,347 @@
|
||||
From fd634998f813340768c333cdad638498602856e5 Mon Sep 17 00:00:00 2001
|
||||
From: Ulya Trofimovich <skvadrik@gmail.com>
|
||||
Date: Tue, 21 Apr 2020 21:28:32 +0100
|
||||
Subject: [PATCH] Rewrite recursion into iteration (Tarjan's SCC algorithm and
|
||||
YYFILL states).
|
||||
|
||||
This is to avoid stack overflow on large RE (especially on instrumented
|
||||
builds that have larger stack frames, like AddressSanitizer).
|
||||
|
||||
Stack overflow reported by Agostino Sarubbo.
|
||||
Related to #219 "overflow-1.re test fails on system with small stack".
|
||||
|
||||
Upstram-Status: Backport:
|
||||
https://github.com/skvadrik/re2c/commit/fd634998f813340768c333cdad638498602856e5
|
||||
|
||||
CVE: CVE-2018-21232
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
diff --git a/src/dfa/fillpoints.cc b/src/dfa/fillpoints.cc
|
||||
--- a/src/dfa/fillpoints.cc (revision e58939b34bb4c37cd990f82dc286f21cb405743e)
|
||||
+++ b/src/dfa/fillpoints.cc (date 1646929180243)
|
||||
@@ -5,151 +5,186 @@
|
||||
|
||||
#include "src/dfa/dfa.h"
|
||||
|
||||
-namespace re2c
|
||||
-{
|
||||
+
|
||||
+/*
|
||||
+ * note [finding strongly connected components of DFA]
|
||||
+ *
|
||||
+ * A slight modification of Tarjan's algorithm.
|
||||
+ *
|
||||
+ * The algorithm traverses the DFA in depth-first order. It maintains a stack
|
||||
+ * of states that have already been visited but haven't been assigned to an SCC
|
||||
+ * yet. For each state the algorithm calculates 'lowlink': index of the highest
|
||||
+ * ancestor state reachable in one step from a descendant of this state.
|
||||
+ * Lowlink is used to determine when a set of states should be popped off stack
|
||||
+ * into a new SCC.
|
||||
+ *
|
||||
+ * We use lowlink to hold different kinds of information:
|
||||
+ * - values in range [0 .. stack size] mean that the state is on stack (a
|
||||
+ * link to a state with the smallest index reachable from this one)
|
||||
+ * - SCC_UND means that this state has not been visited yet
|
||||
+ * - SCC_INF means that this state has already been popped off stack
|
||||
+ *
|
||||
+ * We use stack size (rather than topological sort index) as a unique index of
|
||||
+ * the state on stack. This is safe because the indices of states on stack are
|
||||
+ * unique and less than the indices of states that have been popped off stack
|
||||
+ * (SCC_INF).
|
||||
+ */
|
||||
+
|
||||
+namespace re2c {
|
||||
+ namespace {
|
||||
|
||||
-static const size_t SCC_INF = std::numeric_limits<size_t>::max();
|
||||
-static const size_t SCC_UND = SCC_INF - 1;
|
||||
+ static const size_t SCC_INF = std::numeric_limits<size_t>::max();
|
||||
+ static const size_t SCC_UND = SCC_INF - 1;
|
||||
|
||||
-static bool loopback(size_t node, size_t narcs, const size_t *arcs)
|
||||
-{
|
||||
- for (size_t i = 0; i < narcs; ++i)
|
||||
- {
|
||||
- if (arcs[i] == node)
|
||||
- {
|
||||
- return true;
|
||||
- }
|
||||
- }
|
||||
- return false;
|
||||
-}
|
||||
+ static bool loopback(size_t state, size_t narcs, const size_t *arcs)
|
||||
+ {
|
||||
+ for (size_t i = 0; i < narcs; ++i) {
|
||||
+ if (arcs[i] == state) return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
-/*
|
||||
- * node [finding strongly connected components of DFA]
|
||||
- *
|
||||
- * A slight modification of Tarjan's algorithm.
|
||||
- *
|
||||
- * The algorithm walks graph in deep-first order. It maintains a stack
|
||||
- * of nodes that have already been visited but haven't been assigned to
|
||||
- * SCC yet. For each node the algorithm calculates 'lowlink': index of
|
||||
- * the highest ancestor node reachable in one step from a descendant of
|
||||
- * the node. Lowlink is used to determine when a set of nodes should be
|
||||
- * popped off the stack into a new SCC.
|
||||
- *
|
||||
- * We use lowlink to hold different kinds of information:
|
||||
- * - values in range [0 .. stack size] mean that this node is on stack
|
||||
- * (link to a node with the smallest index reachable from this one)
|
||||
- * - SCC_UND means that this node has not been visited yet
|
||||
- * - SCC_INF means that this node has already been popped off stack
|
||||
- *
|
||||
- * We use stack size (rather than topological sort index) as unique index
|
||||
- * of a node on stack. This is safe because indices of nodes on stack are
|
||||
- * still unique and less than indices of nodes that have been popped off
|
||||
- * stack (SCC_INF).
|
||||
- *
|
||||
- */
|
||||
-static void scc(
|
||||
- const dfa_t &dfa,
|
||||
- std::stack<size_t> &stack,
|
||||
- std::vector<size_t> &lowlink,
|
||||
- std::vector<bool> &trivial,
|
||||
- size_t i)
|
||||
-{
|
||||
- const size_t link = stack.size();
|
||||
- lowlink[i] = link;
|
||||
- stack.push(i);
|
||||
+ struct StackItem {
|
||||
+ size_t state; // current state
|
||||
+ size_t symbol; // next arc to be visited in this state
|
||||
+ size_t link; // Tarjan's "lowlink"
|
||||
+ };
|
||||
+
|
||||
+// Tarjan's algorithm
|
||||
+ static void scc(const dfa_t &dfa, std::vector<bool> &trivial,
|
||||
+ std::vector<StackItem> &stack_dfs)
|
||||
+ {
|
||||
+ std::vector<size_t> lowlink(dfa.states.size(), SCC_UND);
|
||||
+ std::stack<size_t> stack;
|
||||
+
|
||||
+ StackItem x0 = {0, 0, 0};
|
||||
+ stack_dfs.push_back(x0);
|
||||
+
|
||||
+ while (!stack_dfs.empty()) {
|
||||
+ const size_t i = stack_dfs.back().state;
|
||||
+ size_t c = stack_dfs.back().symbol;
|
||||
+ size_t link = stack_dfs.back().link;
|
||||
+ stack_dfs.pop_back();
|
||||
+
|
||||
+ const size_t *arcs = dfa.states[i]->arcs;
|
||||
+
|
||||
+ if (c == 0) {
|
||||
+ // DFS recursive enter
|
||||
+ //DASSERT(lowlink[i] == SCC_UND);
|
||||
+ link = lowlink[i] = stack.size();
|
||||
+ stack.push(i);
|
||||
+ }
|
||||
+ else {
|
||||
+ // DFS recursive return (from one of successor states)
|
||||
+ const size_t j = arcs[c - 1];
|
||||
+ //DASSERT(lowlink[j] != SCC_UND);
|
||||
+ lowlink[i] = std::min(lowlink[i], lowlink[j]);
|
||||
+ }
|
||||
|
||||
- const size_t *arcs = dfa.states[i]->arcs;
|
||||
- for (size_t c = 0; c < dfa.nchars; ++c)
|
||||
- {
|
||||
- const size_t j = arcs[c];
|
||||
- if (j != dfa_t::NIL)
|
||||
- {
|
||||
- if (lowlink[j] == SCC_UND)
|
||||
- {
|
||||
- scc(dfa, stack, lowlink, trivial, j);
|
||||
- }
|
||||
- if (lowlink[j] < lowlink[i])
|
||||
- {
|
||||
- lowlink[i] = lowlink[j];
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ // find the next successor state that hasn't been visited yet
|
||||
+ for (; c < dfa.nchars; ++c) {
|
||||
+ const size_t j = arcs[c];
|
||||
+ if (j != dfa_t::NIL) {
|
||||
+ if (lowlink[j] == SCC_UND) {
|
||||
+ break;
|
||||
+ }
|
||||
+ lowlink[i] = std::min(lowlink[i], lowlink[j]);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- if (lowlink[i] == link)
|
||||
- {
|
||||
- // SCC is non-trivial (has loops) iff it either:
|
||||
- // - consists of multiple nodes (they all must be interconnected)
|
||||
- // - consists of single node which loops back to itself
|
||||
- trivial[i] = i == stack.top()
|
||||
- && !loopback(i, dfa.nchars, arcs);
|
||||
+ if (c < dfa.nchars) {
|
||||
+ // recurse into the next successor state
|
||||
+ StackItem x1 = {i, c + 1, link};
|
||||
+ stack_dfs.push_back(x1);
|
||||
+ StackItem x2 = {arcs[c], 0, SCC_UND};
|
||||
+ stack_dfs.push_back(x2);
|
||||
+ }
|
||||
+ else if (lowlink[i] == link) {
|
||||
+ // all successors have been visited
|
||||
+ // SCC is non-trivial (has loops) if either:
|
||||
+ // - it contains multiple interconnected states
|
||||
+ // - it contains a single self-looping state
|
||||
+ trivial[i] = i == stack.top() && !loopback(i, dfa.nchars, arcs);
|
||||
|
||||
- size_t j;
|
||||
- do
|
||||
- {
|
||||
- j = stack.top();
|
||||
- stack.pop();
|
||||
- lowlink[j] = SCC_INF;
|
||||
- }
|
||||
- while (j != i);
|
||||
- }
|
||||
-}
|
||||
+ for (;;) {
|
||||
+ const size_t j = stack.top();
|
||||
+ stack.pop();
|
||||
+ lowlink[j] = SCC_INF;
|
||||
+ if (i == j) break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
-static void calc_fill(
|
||||
- const dfa_t &dfa,
|
||||
- const std::vector<bool> &trivial,
|
||||
- std::vector<size_t> &fill,
|
||||
- size_t i)
|
||||
-{
|
||||
- if (fill[i] == SCC_UND)
|
||||
- {
|
||||
- fill[i] = 0;
|
||||
- const size_t *arcs = dfa.states[i]->arcs;
|
||||
- for (size_t c = 0; c < dfa.nchars; ++c)
|
||||
- {
|
||||
- const size_t j = arcs[c];
|
||||
- if (j != dfa_t::NIL)
|
||||
- {
|
||||
- calc_fill(dfa, trivial, fill, j);
|
||||
- size_t max = 1;
|
||||
- if (trivial[j])
|
||||
- {
|
||||
- max += fill[j];
|
||||
- }
|
||||
- if (max > fill[i])
|
||||
- {
|
||||
- fill[i] = max;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-void fillpoints(const dfa_t &dfa, std::vector<size_t> &fill)
|
||||
-{
|
||||
- const size_t size = dfa.states.size();
|
||||
-
|
||||
- // find DFA states that belong to non-trivial SCC
|
||||
- std::stack<size_t> stack;
|
||||
- std::vector<size_t> lowlink(size, SCC_UND);
|
||||
- std::vector<bool> trivial(size, false);
|
||||
- scc(dfa, stack, lowlink, trivial, 0);
|
||||
-
|
||||
- // for each DFA state, calculate YYFILL argument:
|
||||
- // maximal path length to the next YYFILL state
|
||||
- fill.resize(size, SCC_UND);
|
||||
- calc_fill(dfa, trivial, fill, 0);
|
||||
+ static void calc_fill(const dfa_t &dfa, const std::vector<bool> &trivial,
|
||||
+ std::vector<StackItem> &stack_dfs, std::vector<size_t> &fill)
|
||||
+ {
|
||||
+ const size_t nstates = dfa.states.size();
|
||||
+ fill.resize(nstates, SCC_UND);
|
||||
+
|
||||
+ StackItem x0 = {0, 0, SCC_INF};
|
||||
+ stack_dfs.push_back(x0);
|
||||
+
|
||||
+ while (!stack_dfs.empty()) {
|
||||
+ const size_t i = stack_dfs.back().state;
|
||||
+ size_t c = stack_dfs.back().symbol;
|
||||
+ stack_dfs.pop_back();
|
||||
+
|
||||
+ const size_t *arcs = dfa.states[i]->arcs;
|
||||
+
|
||||
+ if (c == 0) {
|
||||
+ // DFS recursive enter
|
||||
+ if (fill[i] != SCC_UND) continue;
|
||||
+ fill[i] = 0;
|
||||
+ }
|
||||
+ else {
|
||||
+ // DFS recursive return (from one of successor states)
|
||||
+ const size_t j = arcs[c - 1];
|
||||
+ //DASSERT(fill[i] != SCC_UND && fill[j] != SCC_UND);
|
||||
+ fill[i] = std::max(fill[i], 1 + (trivial[j] ? fill[j] : 0));
|
||||
+ }
|
||||
+
|
||||
+ // find the next successor state that hasn't been visited yet
|
||||
+ for (; c < dfa.nchars; ++c) {
|
||||
+ const size_t j = arcs[c];
|
||||
+ if (j != dfa_t::NIL) break;
|
||||
+ }
|
||||
+
|
||||
+ if (c < dfa.nchars) {
|
||||
+ // recurse into the next successor state
|
||||
+ StackItem x1 = {i, c + 1, SCC_INF};
|
||||
+ stack_dfs.push_back(x1);
|
||||
+ StackItem x2 = {arcs[c], 0, SCC_INF};
|
||||
+ stack_dfs.push_back(x2);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- // The following states must trigger YYFILL:
|
||||
- // - inital state
|
||||
- // - all states in non-trivial SCCs
|
||||
- // for other states, reset YYFILL argument to zero
|
||||
- for (size_t i = 1; i < size; ++i)
|
||||
- {
|
||||
- if (trivial[i])
|
||||
- {
|
||||
- fill[i] = 0;
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
+ // The following states must trigger YYFILL:
|
||||
+ // - inital state
|
||||
+ // - all states in non-trivial SCCs
|
||||
+ // for other states, reset YYFILL argument to zero
|
||||
+ for (size_t i = 1; i < nstates; ++i) {
|
||||
+ if (trivial[i]) {
|
||||
+ fill[i] = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
+ } // anonymous namespace
|
||||
+
|
||||
+ void fillpoints(const dfa_t &dfa, std::vector<size_t> &fill)
|
||||
+ {
|
||||
+ const size_t nstates = dfa.states.size();
|
||||
+ std::vector<bool> trivial(nstates, false);
|
||||
+ std::vector<StackItem> stack_dfs;
|
||||
+ stack_dfs.reserve(nstates);
|
||||
+
|
||||
+ // find DFA states that belong to non-trivial SCC
|
||||
+ scc(dfa, trivial, stack_dfs);
|
||||
+
|
||||
+ // for each DFA state, calculate YYFILL argument:
|
||||
+ // maximal path length to the next YYFILL state
|
||||
+ calc_fill(dfa, trivial, stack_dfs, fill);
|
||||
+ }
|
||||
+
|
||||
} // namespace re2c
|
||||
243
meta/recipes-support/re2c/re2c/CVE-2018-21232-2.patch
Normal file
243
meta/recipes-support/re2c/re2c/CVE-2018-21232-2.patch
Normal file
@@ -0,0 +1,243 @@
|
||||
From 7b5643476bd99c994c4f51b8143f942982d85521 Mon Sep 17 00:00:00 2001
|
||||
From: Ulya Trofimovich <skvadrik@gmail.com>
|
||||
Date: Wed, 22 Apr 2020 22:37:24 +0100
|
||||
Subject: [PATCH] Rewrite recursion into iteration (fixed tags computation).
|
||||
|
||||
This is to avoid stack overflow on large RE (especially on instrumented
|
||||
builds that have larger stack frames, like AddressSanitizer).
|
||||
|
||||
Partial fix for #219 "overflow-1.re test fails on system with small stack".
|
||||
|
||||
Upstream-Stauts: Backport:
|
||||
https://github.com/skvadrik/re2c/commit/7b5643476bd99c994c4f51b8143f942982d85521
|
||||
|
||||
CVE: CVE-2018-21232
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
diff --git a/src/re/tag.cc b/src/re/tag.cc
|
||||
--- a/src/re/tag.cc (revision e58939b34bb4c37cd990f82dc286f21cb405743e)
|
||||
+++ b/src/re/tag.cc (date 1646986908580)
|
||||
@@ -6,7 +6,7 @@
|
||||
{
|
||||
|
||||
const size_t Tag::RIGHTMOST = std::numeric_limits<size_t>::max();
|
||||
-const size_t Tag::VARDIST = std::numeric_limits<size_t>::max();
|
||||
+const uint32_t Tag::VARDIST = std::numeric_limits<uint32_t>::max();
|
||||
const size_t Tag::FICTIVE = Tag::RIGHTMOST - 1;
|
||||
|
||||
} // namespace re2c
|
||||
|
||||
|
||||
diff --git a/src/re/tag.h b/src/re/tag.h
|
||||
--- a/src/re/tag.h (revision e58939b34bb4c37cd990f82dc286f21cb405743e)
|
||||
+++ b/src/re/tag.h (date 1646986922376)
|
||||
@@ -19,7 +19,7 @@
|
||||
struct Tag
|
||||
{
|
||||
static const size_t RIGHTMOST;
|
||||
- static const size_t VARDIST;
|
||||
+ static const uint32_t VARDIST;
|
||||
static const size_t FICTIVE;
|
||||
|
||||
const std::string *name;
|
||||
|
||||
|
||||
diff --git a/src/re/fixed_tags.cc b/src/re/fixed_tags.cc
|
||||
--- a/src/re/fixed_tags.cc (revision e58939b34bb4c37cd990f82dc286f21cb405743e)
|
||||
+++ b/src/re/fixed_tags.cc (date 1646991137317)
|
||||
@@ -7,78 +7,131 @@
|
||||
#include "src/re/tag.h"
|
||||
|
||||
namespace re2c {
|
||||
+namespace {
|
||||
|
||||
/* note [fixed and variable tags]
|
||||
*
|
||||
- * If distance between two tags is constant (equal for all strings that
|
||||
- * match the given regexp), then lexer only needs to track one of them:
|
||||
- * the second tag equals the first tag plus static offset.
|
||||
+ * If distance between two tags is constant (equal for all strings that match
|
||||
+ * the given regexp), then lexer only needs to track one of them: the second
|
||||
+ * tag equals the first tag plus static offset.
|
||||
*
|
||||
- * However, this optimization is applied only to tags in top-level
|
||||
- * concatenation, because other tags may be uninitialized and we don't
|
||||
- * want to mess with conditional calculation of fixed tags.
|
||||
- *
|
||||
+ * This optimization is applied only to tags in top-level concatenation,
|
||||
+ * because in other cases the base tag may be NULL, and the calculation of
|
||||
+ * the fixed tag value is not as simple as substracting a fixed offset.
|
||||
* Furthermore, fixed tags are fobidden with generic API because it cannot
|
||||
- * express fixed offsets.
|
||||
- *
|
||||
- * Tags with history also cannot be fixed.
|
||||
+ * express fixed offsets. M-tags (with history) also cannot be fixed.
|
||||
*
|
||||
* Another special case is fictive tags (those that exist only to impose
|
||||
- * hierarchical laws of POSIX disambiguation). We treat them as fixed
|
||||
- * in order to suppress code generation.
|
||||
+ * hierarchical laws of POSIX disambiguation). We treat them as fixed in order
|
||||
+ * to suppress code generation.
|
||||
*/
|
||||
|
||||
-static void find_fixed_tags(RE *re, std::vector<Tag> &tags,
|
||||
- size_t &dist, size_t &base, bool toplevel)
|
||||
+struct StackItem {
|
||||
+ RE *re; // current sub-RE
|
||||
+ uint32_t dist; // distance backup for alternative, unused for other RE
|
||||
+ uint8_t succ; // index of the next successor to be visited
|
||||
+ bool toplevel; // if this sub-RE is in top-level concatenation
|
||||
+};
|
||||
+
|
||||
+static void find_fixed_tags(RESpec &spec, std::vector<StackItem> &stack, RE *re0)
|
||||
{
|
||||
- switch (re->type) {
|
||||
- case RE::NIL: break;
|
||||
- case RE::SYM:
|
||||
- if (dist != Tag::VARDIST) ++dist;
|
||||
- break;
|
||||
- case RE::ALT: {
|
||||
- size_t d1 = dist, d2 = dist;
|
||||
- find_fixed_tags(re->alt.re1, tags, d1, base, false);
|
||||
- find_fixed_tags(re->alt.re2, tags, d2, base, false);
|
||||
- dist = (d1 == d2) ? d1 : Tag::VARDIST;
|
||||
- break;
|
||||
- }
|
||||
- case RE::CAT:
|
||||
- find_fixed_tags(re->cat.re2, tags, dist, base, toplevel);
|
||||
- find_fixed_tags(re->cat.re1, tags, dist, base, toplevel);
|
||||
- break;
|
||||
- case RE::ITER:
|
||||
- find_fixed_tags(re->iter.re, tags, dist, base, false);
|
||||
- dist = Tag::VARDIST;
|
||||
- break;
|
||||
- case RE::TAG: {
|
||||
- // see note [fixed and variable tags]
|
||||
- Tag &tag = tags[re->tag.idx];
|
||||
- if (fictive(tag)) {
|
||||
- tag.base = tag.dist = 0;
|
||||
- } else if (toplevel && dist != Tag::VARDIST && !history(tag)) {
|
||||
- tag.base = base;
|
||||
- tag.dist = dist;
|
||||
- } else if (toplevel) {
|
||||
- base = re->tag.idx;
|
||||
- dist = 0;
|
||||
- }
|
||||
- if (trailing(tag)) dist = 0;
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ static const uint32_t VARDIST = Tag::VARDIST;
|
||||
+ bool toplevel = spec.opts->input_api != INPUT_CUSTOM;
|
||||
+
|
||||
+ // base tag, intially the fake "rightmost tag" (the end of RE)
|
||||
+ size_t base = Tag::RIGHTMOST;
|
||||
+
|
||||
+ // the distance to the nearest top-level tag to the right (base tag)
|
||||
+ uint32_t dist = 0;
|
||||
+
|
||||
+ const StackItem i0 = {re0, VARDIST, 0, toplevel};
|
||||
+ stack.push_back(i0);
|
||||
+
|
||||
+ while (!stack.empty()) {
|
||||
+ const StackItem i = stack.back();
|
||||
+ stack.pop_back();
|
||||
+ RE *re = i.re;
|
||||
+
|
||||
+ if (re->type == RE::SYM) {
|
||||
+ if (dist != VARDIST) ++dist;
|
||||
+ }
|
||||
+ else if (re->type == RE::ALT) {
|
||||
+ if (i.succ == 0) {
|
||||
+ // save the current distance on stack (from the alternative end
|
||||
+ // to base) and recurse into the left sub-RE
|
||||
+ StackItem k = {re, dist, 1, i.toplevel};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->alt.re1, VARDIST, 0, false};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else if (i.succ == 1) {
|
||||
+ // save the current distance on stack (from the left sub-RE to
|
||||
+ // base), reset distance to the distance popped from stack (from
|
||||
+ // the alternative end to base), recurse into the right sub-RE
|
||||
+ StackItem k = {re, dist, 2, i.toplevel};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->alt.re2, VARDIST, 0, false};
|
||||
+ stack.push_back(j);
|
||||
+ dist = i.dist;
|
||||
+ }
|
||||
+ else {
|
||||
+ // both sub-RE visited, compare the distance on stack (from the
|
||||
+ // left sub-RE to base) to the current distance (from the right
|
||||
+ // sub-RE to base), if not equal set variable distance
|
||||
+ dist = (i.dist == dist) ? i.dist : VARDIST;
|
||||
+ }
|
||||
+ }
|
||||
+ else if (re->type == RE::ITER) {
|
||||
+ if (i.succ == 0) {
|
||||
+ // recurse into the sub-RE
|
||||
+ StackItem k = {re, VARDIST, 1, i.toplevel};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->iter.re, VARDIST, 0, false};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else {
|
||||
+ // sub-RE visited, assume unknown number of iterations
|
||||
+ // TODO: find precise distance for fixed repetition counter
|
||||
+ dist = VARDIST;
|
||||
+ }
|
||||
+ }
|
||||
+ else if (re->type == RE::CAT) {
|
||||
+ // the right sub-RE is pushed on stack after the left sub-RE and
|
||||
+ // visited earlier (because distance is computed from right to left)
|
||||
+ StackItem j1 = {re->cat.re1, VARDIST, 0, i.toplevel};
|
||||
+ stack.push_back(j1);
|
||||
+ StackItem j2 = {re->cat.re2, VARDIST, 0, i.toplevel};
|
||||
+ stack.push_back(j2);
|
||||
+ }
|
||||
+ else if (re->type == RE::TAG) {
|
||||
+ // see note [fixed and variable tags]
|
||||
+ Tag &tag = spec.tags[re->tag.idx];
|
||||
+ if (fictive(tag)) {
|
||||
+ tag.base = tag.dist = 0;
|
||||
+ }
|
||||
+ else if (i.toplevel && dist != VARDIST && !history(tag)) {
|
||||
+ tag.base = base;
|
||||
+ tag.dist = dist;
|
||||
+ }
|
||||
+ else if (i.toplevel) {
|
||||
+ base = re->tag.idx;
|
||||
+ dist = 0;
|
||||
+ }
|
||||
+ if (trailing(tag)) {
|
||||
+ dist = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+} // anonymous namespace
|
||||
|
||||
-void find_fixed_tags(RESpec &spec)
|
||||
-{
|
||||
- const bool generic = spec.opts->input_api == INPUT_CUSTOM;
|
||||
- std::vector<RE*>::iterator
|
||||
- i = spec.res.begin(),
|
||||
- e = spec.res.end();
|
||||
- for (; i != e; ++i) {
|
||||
- size_t base = Tag::RIGHTMOST, dist = 0;
|
||||
- find_fixed_tags(*i, spec.tags, dist, base, !generic);
|
||||
- }
|
||||
-}
|
||||
+ void find_fixed_tags(RESpec &spec)
|
||||
+ {
|
||||
+ std::vector<StackItem> stack;
|
||||
+ for (std::vector<RE*>::iterator i = spec.res.begin(); i != spec.res.end(); ++i) {
|
||||
+ find_fixed_tags(spec, stack, *i);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
-} // namespace re2c
|
||||
+} // namespace re2c
|
||||
\ No newline at end of file
|
||||
156
meta/recipes-support/re2c/re2c/CVE-2018-21232-3.patch
Normal file
156
meta/recipes-support/re2c/re2c/CVE-2018-21232-3.patch
Normal file
@@ -0,0 +1,156 @@
|
||||
From 4d9c809355b574f2a58eac119f5e076c48e4d1e2 Mon Sep 17 00:00:00 2001
|
||||
From: Ulya Trofimovich <skvadrik@gmail.com>
|
||||
Date: Thu, 23 Apr 2020 22:16:51 +0100
|
||||
Subject: [PATCH] Rewrite recursion into iteration (nullable RE).
|
||||
|
||||
This is to avoid stack overflow on large RE (especially on instrumented
|
||||
builds that have larger stack frames, like AddressSanitizer).
|
||||
|
||||
Partial fix for #219 "overflow-1.re test fails on system with small stack".
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://github.com/skvadrik/re2c/commit/4d9c809355b574f2a58eac119f5e076c48e4d1e2
|
||||
|
||||
CVE: CVE-2018-21232
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
diff --git a/src/re/nullable.cc b/src/re/nullable.cc
|
||||
--- a/src/re/nullable.cc (revision e58939b34bb4c37cd990f82dc286f21cb405743e)
|
||||
+++ b/src/re/nullable.cc (date 1647253886226)
|
||||
@@ -9,43 +9,100 @@
|
||||
#include "src/re/tag.h"
|
||||
|
||||
namespace re2c {
|
||||
+ namespace {
|
||||
+
|
||||
+ struct StackItem {
|
||||
+ const RE *re; // current sub-RE
|
||||
+ uint8_t succ; // index of the next sucessor to be visited
|
||||
+ };
|
||||
|
||||
-static bool nullable(const RESpec &spec, const RE *re, bool &trail)
|
||||
-{
|
||||
- if (trail) return true;
|
||||
+ static bool nullable(const RESpec &spec, std::vector<StackItem> &stack, const RE *re0)
|
||||
+ {
|
||||
+ // the "nullable" status of the last sub-RE visited by DFS
|
||||
+ bool null = false;
|
||||
|
||||
- switch (re->type) {
|
||||
- case RE::NIL: return true;
|
||||
- case RE::SYM: return false;
|
||||
- case RE::ITER:
|
||||
- return nullable(spec, re->iter.re, trail);
|
||||
- case RE::TAG:
|
||||
- trail |= trailing(spec.tags[re->tag.idx]);
|
||||
- return true;
|
||||
- case RE::ALT:
|
||||
- return nullable(spec, re->alt.re1, trail)
|
||||
- || nullable(spec, re->alt.re2, trail);
|
||||
- case RE::CAT:
|
||||
- return nullable(spec, re->cat.re1, trail)
|
||||
- && nullable(spec, re->cat.re2, trail);
|
||||
- }
|
||||
- return false; /* unreachable */
|
||||
-}
|
||||
+ const StackItem i0 = {re0, 0};
|
||||
+ stack.push_back(i0);
|
||||
+
|
||||
+ while (!stack.empty()) {
|
||||
+ const StackItem i = stack.back();
|
||||
+ stack.pop_back();
|
||||
+
|
||||
+ const RE *re = i.re;
|
||||
+ if (re->type == RE::NIL) {
|
||||
+ null = true;
|
||||
+ }
|
||||
+ else if (re->type == RE::SYM) {
|
||||
+ null = false;
|
||||
+ }
|
||||
+ else if (re->type == RE::TAG) {
|
||||
+ null = true;
|
||||
|
||||
-/*
|
||||
- * warn about rules that match empty string
|
||||
- * (including rules with nonempty trailing context)
|
||||
- * false positives on partially self-shadowed rules like [^]?
|
||||
- */
|
||||
-void warn_nullable(const RESpec &spec, const std::string &cond)
|
||||
-{
|
||||
- const size_t nre = spec.res.size();
|
||||
- for (size_t i = 0; i < nre; ++i) {
|
||||
- bool trail = false;
|
||||
- if (nullable(spec, spec.res[i], trail)) {
|
||||
- spec.warn.match_empty_string(spec.rules[i].code->fline, cond);
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
+ // Trailing context is always in top-level concatenation, and sub-RE
|
||||
+ // are visited from left to right. Since we are here, sub-RE to the
|
||||
+ // left of the trailing context is nullable (otherwise we would not
|
||||
+ // recurse into the right sub-RE), therefore the whole RE is nullable.
|
||||
+ if (trailing(spec.tags[re->tag.idx])) {
|
||||
+ //DASSERT(stack.size() == 1 && stack.back().re->type == RE::CAT);
|
||||
+ stack.pop_back();
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ else if (re->type == RE::ALT) {
|
||||
+ if (i.succ == 0) {
|
||||
+ // recurse into the left sub-RE
|
||||
+ StackItem k = {re, 1};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->alt.re1, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else if (!null) {
|
||||
+ // if the left sub-RE is nullable, so is alternative, so stop
|
||||
+ // recursion; otherwise recurse into the right sub-RE
|
||||
+ StackItem j = {re->alt.re2, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ }
|
||||
+ else if (re->type == RE::CAT) {
|
||||
+ if (i.succ == 0) {
|
||||
+ // recurse into the left sub-RE
|
||||
+ StackItem k = {re, 1};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->cat.re1, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else if (null) {
|
||||
+ // if the left sub-RE is not nullable, neither is concatenation,
|
||||
+ // so stop recursion; otherwise recurse into the right sub-RE
|
||||
+ StackItem j = {re->cat.re2, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ }
|
||||
+ else if (re->type == RE::ITER) {
|
||||
+ // iteration is nullable if the sub-RE is nullable
|
||||
+ // (zero repetitions is represented with alternative)
|
||||
+ StackItem j = {re->iter.re, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ //DASSERT(stack.empty());
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ } // anonymous namespace
|
||||
+
|
||||
+// Warn about rules that match empty string (including rules with nonempty
|
||||
+// trailing context). False positives on partially self-shadowed rules like [^]?
|
||||
+ void warn_nullable(const RESpec &spec, const std::string &cond)
|
||||
+ {
|
||||
+ std::vector<StackItem> stack;
|
||||
+ const size_t nre = spec.res.size();
|
||||
+ for (size_t i = 0; i < nre; ++i) {
|
||||
+ if (nullable(spec, stack, spec.res[i])) {
|
||||
+ spec.warn.match_empty_string(spec.rules[i].code->fline, cond);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
} // namespace re2c
|
||||
166
meta/recipes-support/re2c/re2c/CVE-2018-21232-4.patch
Normal file
166
meta/recipes-support/re2c/re2c/CVE-2018-21232-4.patch
Normal file
@@ -0,0 +1,166 @@
|
||||
From 89be91f3df00657261870adbc590209fdb2bc405 Mon Sep 17 00:00:00 2001
|
||||
From: Ulya Trofimovich <skvadrik@gmail.com>
|
||||
Date: Thu, 23 Apr 2020 23:02:21 +0100
|
||||
Subject: [PATCH] Rewrite recursion into iteration (estimation of NFA size for
|
||||
RE).
|
||||
|
||||
This is to avoid stack overflow on large RE (especially on instrumented
|
||||
builds that have larger stack frames, like AddressSanitizer).
|
||||
|
||||
Partial fix for #219 "overflow-1.re test fails on system with small stack".
|
||||
|
||||
Upstram-Status: Backport:
|
||||
https://github.com/skvadrik/re2c/commit/89be91f3df00657261870adbc590209fdb2bc405
|
||||
|
||||
CVE: CVE-2018-21232
|
||||
|
||||
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
|
||||
---
|
||||
diff --git a/src/nfa/estimate_size.cc b/src/nfa/estimate_size.cc
|
||||
--- a/src/nfa/estimate_size.cc (revision e58939b34bb4c37cd990f82dc286f21cb405743e)
|
||||
+++ b/src/nfa/estimate_size.cc (date 1647005399735)
|
||||
@@ -6,41 +6,113 @@
|
||||
#include "src/re/re.h"
|
||||
|
||||
namespace re2c {
|
||||
+namespace {
|
||||
+
|
||||
+struct StackItem {
|
||||
+ const RE *re; // current sub-RE
|
||||
+ uint32_t size; // size of the sub-RE (only for alternative and concatenation)
|
||||
+ uint8_t succ; // index of the next sucessor to be visited
|
||||
+};
|
||||
|
||||
-static size_t estimate(const RE *re)
|
||||
+static uint32_t estimate_re_size(const RE *re0, std::vector<StackItem> &stack)
|
||||
{
|
||||
- switch (re->type) {
|
||||
- case RE::NIL: return 0;
|
||||
- case RE::SYM: return 1;
|
||||
- case RE::TAG: return 1;
|
||||
- case RE::ALT:
|
||||
- return estimate(re->alt.re1)
|
||||
- + estimate(re->alt.re2)
|
||||
- + 1;
|
||||
- case RE::CAT:
|
||||
- return estimate(re->cat.re1)
|
||||
- + estimate(re->cat.re2);
|
||||
- case RE::ITER: {
|
||||
- const size_t
|
||||
- iter = estimate(re->iter.re),
|
||||
- min = re->iter.min,
|
||||
- max = re->iter.max;
|
||||
- return max == AST::MANY
|
||||
- ? iter * min + 1
|
||||
- : iter * max + (max - min);
|
||||
- }
|
||||
- }
|
||||
- return 0; /* unreachable */
|
||||
-}
|
||||
+ // the estimated size of the last sub-RE visited by DFS
|
||||
+ uint32_t size = 0;
|
||||
+
|
||||
+ const StackItem i0 = {re0, 0, 0};
|
||||
+ stack.push_back(i0);
|
||||
+
|
||||
+ while (!stack.empty()) {
|
||||
+ const StackItem i = stack.back();
|
||||
+ stack.pop_back();
|
||||
+
|
||||
+ const RE *re = i.re;
|
||||
+ if (re->type == RE::NIL) {
|
||||
+ size = 0;
|
||||
+ }
|
||||
+ else if (re->type == RE::SYM || re->type == RE::TAG) {
|
||||
+ size = 1;
|
||||
+ }
|
||||
+ else if (re->type == RE::ALT) {
|
||||
+ if (i.succ == 0) {
|
||||
+ // recurse into the left sub-RE
|
||||
+ StackItem k = {re, 0, 1};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->alt.re1, 0, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else if (i.succ == 1) {
|
||||
+ // recurse into the right sub-RE
|
||||
+ StackItem k = {re, size, 2};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->alt.re2, 0, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else {
|
||||
+ // both sub-RE visited, recursive return
|
||||
+ size = i.size // left sub-RE (saved on stack)
|
||||
+ + size // right sub-RE (just visited by DFS)
|
||||
+ + 1; // additional state for alternative
|
||||
+ }
|
||||
+ }
|
||||
+ else if (re->type == RE::CAT) {
|
||||
+ if (i.succ == 0) {
|
||||
+ // recurse into the left sub-RE
|
||||
+ StackItem k = {re, 0, 1};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->cat.re1, 0, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else if (i.succ == 1) {
|
||||
+ // recurse into the right sub-RE
|
||||
+ StackItem k = {re, size, 2};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->cat.re2, 0, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else {
|
||||
+ // both sub-RE visited, recursive return
|
||||
+ size = i.size // left sub-RE (saved on stack)
|
||||
+ + size; // right sub-RE (just visited by DFS)
|
||||
+ }
|
||||
+ }
|
||||
+ else if (re->type == RE::ITER) {
|
||||
+ if (i.succ == 0) {
|
||||
+ // recurse into the sub-RE
|
||||
+ StackItem k = {re, 0, 1};
|
||||
+ stack.push_back(k);
|
||||
+ StackItem j = {re->iter.re, 0, 0};
|
||||
+ stack.push_back(j);
|
||||
+ }
|
||||
+ else {
|
||||
+ // sub-RE visited, recursive return
|
||||
+ const uint32_t min = re->iter.min, max = re->iter.max;
|
||||
+ size = max == AST::MANY
|
||||
+ ? size * min + 1
|
||||
+ : size * max + (max - min);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ //DASSERT(stack.empty());
|
||||
+ return size;
|
||||
+}
|
||||
+
|
||||
+} // anonymous namespace
|
||||
|
||||
size_t estimate_size(const std::vector<RE*> &res)
|
||||
{
|
||||
- const size_t nre = res.size();
|
||||
- size_t size = nre - 1;
|
||||
- for (size_t i = 0; i < nre; ++i) {
|
||||
- size += estimate(res[i]) + 1;
|
||||
- }
|
||||
- return size;
|
||||
+ std::vector<StackItem> stack;
|
||||
+
|
||||
+ const size_t nre = res.size();
|
||||
+ //DASSERT(nre > 0);
|
||||
+ size_t size = nre - 1;
|
||||
+
|
||||
+ for (size_t i = 0; i < nre; ++i) {
|
||||
+ size += estimate_re_size(res[i], stack) + 1;
|
||||
+ }
|
||||
+
|
||||
+ return size;
|
||||
}
|
||||
|
||||
} // namespace re2c
|
||||
|
||||
@@ -7,7 +7,11 @@ SECTION = "devel"
|
||||
LICENSE = "PD"
|
||||
LIC_FILES_CHKSUM = "file://README;beginline=146;md5=881056c9add17f8019ccd8c382ba963a"
|
||||
|
||||
SRC_URI = "https://github.com/skvadrik/re2c/releases/download/${PV}/${BPN}-${PV}.tar.gz"
|
||||
SRC_URI = "https://github.com/skvadrik/re2c/releases/download/${PV}/${BPN}-${PV}.tar.gz \
|
||||
file://CVE-2018-21232-1.patch \
|
||||
file://CVE-2018-21232-2.patch \
|
||||
file://CVE-2018-21232-3.patch \
|
||||
file://CVE-2018-21232-4.patch"
|
||||
SRC_URI[md5sum] = "e2c6cf52fc6a21595f21bc82db5324f8"
|
||||
SRC_URI[sha256sum] = "605058d18a00e01bfc32aebf83af35ed5b13180b4e9f279c90843afab2c66c7c"
|
||||
UPSTREAM_CHECK_URI = "https://github.com/skvadrik/re2c/releases"
|
||||
|
||||
@@ -11,7 +11,7 @@ RSUGGESTS_${PN} = "diffutils"
|
||||
|
||||
LICENSE = "vim"
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=6b30ea4fa660c483b619924bc709ef99 \
|
||||
file://runtime/doc/uganda.txt;md5=a3f193c20c6faff93c69185d5d070535"
|
||||
file://runtime/doc/uganda.txt;md5=daf48235bb824c77fe8ae88d5f575f74"
|
||||
|
||||
SRC_URI = "git://github.com/vim/vim.git;branch=master;protocol=https \
|
||||
file://disable_acl_header_check.patch \
|
||||
@@ -21,8 +21,8 @@ SRC_URI = "git://github.com/vim/vim.git;branch=master;protocol=https \
|
||||
file://racefix.patch \
|
||||
"
|
||||
|
||||
PV .= ".4524"
|
||||
SRCREV = "d8f8629b1bf566e1dada7515e9b146c69e5d9757"
|
||||
PV .= ".4681"
|
||||
SRCREV = "15f74fab653a784548d5d966644926b47ba2cfa7"
|
||||
|
||||
# Remove when 8.3 is out
|
||||
UPSTREAM_VERSION_UNKNOWN = "1"
|
||||
|
||||
Reference in New Issue
Block a user