mirror of
https://git.yoctoproject.org/poky
synced 2026-02-21 08:59:41 +01:00
Compare commits
121 Commits
yocto-3.1.
...
yocto-3.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a631bfc3a3 | ||
|
|
ee461b4235 | ||
|
|
68801aaf80 | ||
|
|
38f85fe6dd | ||
|
|
62034cd625 | ||
|
|
87a450e222 | ||
|
|
d58a0c3239 | ||
|
|
667eb766ab | ||
|
|
56c03791cd | ||
|
|
acd638685c | ||
|
|
a4f1c6baa3 | ||
|
|
799673e3f4 | ||
|
|
6fd646cdb1 | ||
|
|
538185bd1c | ||
|
|
6dd6670429 | ||
|
|
51a1d78e2a | ||
|
|
e610a24db7 | ||
|
|
afb4425be9 | ||
|
|
20c932eb01 | ||
|
|
e0d5b78c92 | ||
|
|
00af542d30 | ||
|
|
bcb3c107d3 | ||
|
|
a526ef88ee | ||
|
|
0c1e54eee1 | ||
|
|
fcb3d9a63e | ||
|
|
79b0cf9cfa | ||
|
|
d8057ae9aa | ||
|
|
5150ad7fcb | ||
|
|
8064d53745 | ||
|
|
8ed92cf2b3 | ||
|
|
ba7aa15473 | ||
|
|
a307ef21c1 | ||
|
|
006f140687 | ||
|
|
77e8b40bae | ||
|
|
3cf950b245 | ||
|
|
7e24067f78 | ||
|
|
0ce97636c9 | ||
|
|
90adc17feb | ||
|
|
2ace3a0b1e | ||
|
|
1f1d3d2647 | ||
|
|
07f99e3dea | ||
|
|
2b2f5660b9 | ||
|
|
8c4a94a6de | ||
|
|
fd5bb826ea | ||
|
|
342bf915dc | ||
|
|
72707c04e1 | ||
|
|
f76c7b8e63 | ||
|
|
1c69728f31 | ||
|
|
048d8b8c71 | ||
|
|
afaadab7e9 | ||
|
|
f160d63cb5 | ||
|
|
9cfc1a05ba | ||
|
|
1daa0b9922 | ||
|
|
97b1bdd293 | ||
|
|
be80f805d4 | ||
|
|
0f0b0b0a9b | ||
|
|
7b2e3ff618 | ||
|
|
1351d0261b | ||
|
|
e88f47da0e | ||
|
|
51a742eab1 | ||
|
|
11f05ffddd | ||
|
|
9fbfbf002e | ||
|
|
6b2a22bc7b | ||
|
|
10108d0ebf | ||
|
|
ba90fb0f3d | ||
|
|
1982d0cc7c | ||
|
|
3acc83f91a | ||
|
|
2a1cf26ba4 | ||
|
|
9ab9e48d36 | ||
|
|
a2147d6d27 | ||
|
|
e2b5de2c77 | ||
|
|
144748fed8 | ||
|
|
507f16e1bc | ||
|
|
e0059335fb | ||
|
|
75022804d8 | ||
|
|
818ad186ae | ||
|
|
1904daa987 | ||
|
|
c86b92df02 | ||
|
|
76b5620df7 | ||
|
|
d47b9fe7c8 | ||
|
|
4c78aab891 | ||
|
|
d20a4df83b | ||
|
|
139406c025 | ||
|
|
1231009682 | ||
|
|
aa673e1427 | ||
|
|
770bb4a64a | ||
|
|
d7fa5a35aa | ||
|
|
7b9f7437ed | ||
|
|
c35692c6eb | ||
|
|
9fa2eba749 | ||
|
|
f1dbb005c8 | ||
|
|
1a96c7537f | ||
|
|
7618011039 | ||
|
|
b4802e2fdb | ||
|
|
0d3339a23a | ||
|
|
3d32267b52 | ||
|
|
9d8cb501f7 | ||
|
|
59bfcd7299 | ||
|
|
c3fb76fc72 | ||
|
|
b4675ad33f | ||
|
|
3f4da8c618 | ||
|
|
358c909fc7 | ||
|
|
1d3f2be1e6 | ||
|
|
e22da98e79 | ||
|
|
580df9b4c4 | ||
|
|
50108e2180 | ||
|
|
3c3039aac4 | ||
|
|
4853705635 | ||
|
|
c58bdcd15c | ||
|
|
ba201fc313 | ||
|
|
d160225d21 | ||
|
|
86e2430d3f | ||
|
|
bf604a8fa8 | ||
|
|
f6899f9b94 | ||
|
|
3c76d0ad71 | ||
|
|
826011d497 | ||
|
|
0922cef2f4 | ||
|
|
e5414e5962 | ||
|
|
17aad7feac | ||
|
|
b200c2d16e | ||
|
|
eb79d76099 |
@@ -13,7 +13,6 @@ import sys, os, glob, os.path, re, time
|
||||
import itertools
|
||||
import logging
|
||||
import multiprocessing
|
||||
import sre_constants
|
||||
import threading
|
||||
from io import StringIO, UnsupportedOperation
|
||||
from contextlib import closing
|
||||
@@ -1795,7 +1794,7 @@ class CookerCollectFiles(object):
|
||||
try:
|
||||
re.compile(mask)
|
||||
bbmasks.append(mask)
|
||||
except sre_constants.error:
|
||||
except re.error:
|
||||
collectlog.critical("BBMASK contains an invalid regular expression, ignoring: %s" % mask)
|
||||
|
||||
# Then validate the combined regular expressions. This should never
|
||||
@@ -1803,7 +1802,7 @@ class CookerCollectFiles(object):
|
||||
bbmask = "|".join(bbmasks)
|
||||
try:
|
||||
bbmask_compiled = re.compile(bbmask)
|
||||
except sre_constants.error:
|
||||
except re.error:
|
||||
collectlog.critical("BBMASK is not a valid regular expression, ignoring: %s" % bbmask)
|
||||
bbmask = None
|
||||
|
||||
|
||||
@@ -1975,6 +1975,12 @@ class RunQueueExecute:
|
||||
self.setbuildable(revdep)
|
||||
logger.debug(1, "Marking task %s as buildable", revdep)
|
||||
|
||||
for t in self.sq_deferred.copy():
|
||||
if self.sq_deferred[t] == task:
|
||||
logger.debug(2, "Deferred task %s now buildable" % t)
|
||||
del self.sq_deferred[t]
|
||||
update_scenequeue_data([t], self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self, summary=False)
|
||||
|
||||
def task_complete(self, task):
|
||||
self.stats.taskCompleted()
|
||||
bb.event.fire(runQueueTaskCompleted(task, self.stats, self.rq), self.cfgData)
|
||||
@@ -2084,8 +2090,6 @@ class RunQueueExecute:
|
||||
logger.debug(1, "%s didn't become valid, skipping setscene" % nexttask)
|
||||
self.sq_task_failoutright(nexttask)
|
||||
return True
|
||||
else:
|
||||
self.sqdata.outrightfail.remove(nexttask)
|
||||
if nexttask in self.sqdata.outrightfail:
|
||||
logger.debug(2, 'No package found, so skipping setscene task %s', nexttask)
|
||||
self.sq_task_failoutright(nexttask)
|
||||
@@ -2236,7 +2240,8 @@ class RunQueueExecute:
|
||||
if self.sq_deferred:
|
||||
tid = self.sq_deferred.pop(list(self.sq_deferred.keys())[0])
|
||||
logger.warning("Runqeueue deadlocked on deferred tasks, forcing task %s" % tid)
|
||||
self.sq_task_failoutright(tid)
|
||||
if tid not in self.runq_complete:
|
||||
self.sq_task_failoutright(tid)
|
||||
return True
|
||||
|
||||
if len(self.failed_tids) != 0:
|
||||
@@ -2350,10 +2355,16 @@ class RunQueueExecute:
|
||||
self.updated_taskhash_queue.remove((tid, unihash))
|
||||
|
||||
if unihash != self.rqdata.runtaskentries[tid].unihash:
|
||||
hashequiv_logger.verbose("Task %s unihash changed to %s" % (tid, unihash))
|
||||
self.rqdata.runtaskentries[tid].unihash = unihash
|
||||
bb.parse.siggen.set_unihash(tid, unihash)
|
||||
toprocess.add(tid)
|
||||
# Make sure we rehash any other tasks with the same task hash that we're deferred against.
|
||||
torehash = [tid]
|
||||
for deftid in self.sq_deferred:
|
||||
if self.sq_deferred[deftid] == tid:
|
||||
torehash.append(deftid)
|
||||
for hashtid in torehash:
|
||||
hashequiv_logger.verbose("Task %s unihash changed to %s" % (hashtid, unihash))
|
||||
self.rqdata.runtaskentries[hashtid].unihash = unihash
|
||||
bb.parse.siggen.set_unihash(hashtid, unihash)
|
||||
toprocess.add(hashtid)
|
||||
|
||||
# Work out all tasks which depend upon these
|
||||
total = set()
|
||||
@@ -2492,6 +2503,14 @@ class RunQueueExecute:
|
||||
|
||||
if update_tasks:
|
||||
self.sqdone = False
|
||||
for mc in sorted(self.sqdata.multiconfigs):
|
||||
for tid in sorted([t[0] for t in update_tasks]):
|
||||
if mc_from_tid(tid) != mc:
|
||||
continue
|
||||
h = pending_hash_index(tid, self.rqdata)
|
||||
if h in self.sqdata.hashes and tid != self.sqdata.hashes[h]:
|
||||
self.sq_deferred[tid] = self.sqdata.hashes[h]
|
||||
bb.note("Deferring %s after %s" % (tid, self.sqdata.hashes[h]))
|
||||
update_scenequeue_data([t[0] for t in update_tasks], self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self, summary=False)
|
||||
|
||||
for (tid, harddepfail, origvalid) in update_tasks:
|
||||
@@ -2832,6 +2851,19 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
|
||||
sqdata.stamppresent = set()
|
||||
sqdata.valid = set()
|
||||
|
||||
sqdata.hashes = {}
|
||||
sqrq.sq_deferred = {}
|
||||
for mc in sorted(sqdata.multiconfigs):
|
||||
for tid in sorted(sqdata.sq_revdeps):
|
||||
if mc_from_tid(tid) != mc:
|
||||
continue
|
||||
h = pending_hash_index(tid, rqdata)
|
||||
if h not in sqdata.hashes:
|
||||
sqdata.hashes[h] = tid
|
||||
else:
|
||||
sqrq.sq_deferred[tid] = sqdata.hashes[h]
|
||||
bb.note("Deferring %s after %s" % (tid, sqdata.hashes[h]))
|
||||
|
||||
update_scenequeue_data(sqdata.sq_revdeps, sqdata, rqdata, rq, cooker, stampcache, sqrq, summary=True)
|
||||
|
||||
def update_scenequeue_data(tids, sqdata, rqdata, rq, cooker, stampcache, sqrq, summary=True):
|
||||
@@ -2843,6 +2875,8 @@ def update_scenequeue_data(tids, sqdata, rqdata, rq, cooker, stampcache, sqrq, s
|
||||
sqdata.stamppresent.remove(tid)
|
||||
if tid in sqdata.valid:
|
||||
sqdata.valid.remove(tid)
|
||||
if tid in sqdata.outrightfail:
|
||||
sqdata.outrightfail.remove(tid)
|
||||
|
||||
(mc, fn, taskname, taskfn) = split_tid_mcfn(tid)
|
||||
|
||||
@@ -2870,32 +2904,20 @@ def update_scenequeue_data(tids, sqdata, rqdata, rq, cooker, stampcache, sqrq, s
|
||||
|
||||
sqdata.valid |= rq.validate_hashes(tocheck, cooker.data, len(sqdata.stamppresent), False, summary=summary)
|
||||
|
||||
sqdata.hashes = {}
|
||||
sqrq.sq_deferred = {}
|
||||
for mc in sorted(sqdata.multiconfigs):
|
||||
for tid in sorted(sqdata.sq_revdeps):
|
||||
if mc_from_tid(tid) != mc:
|
||||
continue
|
||||
if tid in sqdata.stamppresent:
|
||||
continue
|
||||
if tid in sqdata.valid:
|
||||
continue
|
||||
if tid in sqdata.noexec:
|
||||
continue
|
||||
if tid in sqrq.scenequeue_notcovered:
|
||||
continue
|
||||
if tid in sqrq.scenequeue_covered:
|
||||
continue
|
||||
|
||||
sqdata.outrightfail.add(tid)
|
||||
|
||||
h = pending_hash_index(tid, rqdata)
|
||||
if h not in sqdata.hashes:
|
||||
sqdata.hashes[h] = tid
|
||||
else:
|
||||
sqrq.sq_deferred[tid] = sqdata.hashes[h]
|
||||
bb.note("Deferring %s after %s" % (tid, sqdata.hashes[h]))
|
||||
|
||||
for tid in tids:
|
||||
if tid in sqdata.stamppresent:
|
||||
continue
|
||||
if tid in sqdata.valid:
|
||||
continue
|
||||
if tid in sqdata.noexec:
|
||||
continue
|
||||
if tid in sqrq.scenequeue_covered:
|
||||
continue
|
||||
if tid in sqrq.scenequeue_notcovered:
|
||||
continue
|
||||
if tid in sqrq.sq_deferred:
|
||||
continue
|
||||
sqdata.outrightfail.add(tid)
|
||||
|
||||
class TaskFailure(Exception):
|
||||
"""
|
||||
|
||||
@@ -1338,7 +1338,7 @@ class FetchCheckStatusTest(FetcherTest):
|
||||
"http://downloads.yoctoproject.org/releases/sato/sato-engine-0.2.tar.gz",
|
||||
"http://downloads.yoctoproject.org/releases/sato/sato-engine-0.3.tar.gz",
|
||||
"https://yoctoproject.org/",
|
||||
"https://yoctoproject.org/documentation",
|
||||
"https://docs.yoctoproject.org/",
|
||||
"http://downloads.yoctoproject.org/releases/opkg/opkg-0.1.7.tar.gz",
|
||||
"http://downloads.yoctoproject.org/releases/opkg/opkg-0.3.0.tar.gz",
|
||||
"ftp://sourceware.org/pub/libffi/libffi-1.20.tar.gz",
|
||||
|
||||
@@ -97,6 +97,7 @@ extlinks = {
|
||||
'yocto_git': ('https://git.yoctoproject.org%s', None),
|
||||
'oe_home': ('https://www.openembedded.org%s', None),
|
||||
'oe_lists': ('https://lists.openembedded.org%s', None),
|
||||
'oe_git': ('https://git.openembedded.org%s', None),
|
||||
}
|
||||
|
||||
# Intersphinx config to use cross reference with Bitbake user manual
|
||||
|
||||
@@ -377,7 +377,7 @@ activities using the Yocto Project:
|
||||
Index <http://layers.openembedded.org/layerindex/layers/>`__, which
|
||||
is a website that indexes OpenEmbedded-Core layers.
|
||||
|
||||
- *Patchwork:* `Patchwork <http://jk.ozlabs.org/projects/patchwork/>`__
|
||||
- *Patchwork:* `Patchwork <https://patchwork.yoctoproject.org/>`__
|
||||
is a fork of a project originally started by
|
||||
`OzLabs <http://ozlabs.org/>`__. The project is a web-based tracking
|
||||
system designed to streamline the process of bringing contributions
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
DISTRO : "3.1.23"
|
||||
DISTRO : "3.1.25"
|
||||
DISTRO_NAME_NO_CAP : "dunfell"
|
||||
DISTRO_NAME : "Dunfell"
|
||||
DISTRO_NAME_NO_CAP_MINUS_ONE : "zeus"
|
||||
YOCTO_DOC_VERSION : "3.1.23"
|
||||
YOCTO_DOC_VERSION : "3.1.25"
|
||||
YOCTO_DOC_VERSION_MINUS_ONE : "3.0.4"
|
||||
DISTRO_REL_TAG : "yocto-3.1.23"
|
||||
DOCCONF_VERSION : "3.1.23"
|
||||
DISTRO_REL_TAG : "yocto-3.1.25"
|
||||
DOCCONF_VERSION : "3.1.25"
|
||||
BITBAKE_SERIES : "1.46"
|
||||
POKYVERSION : "23.0.23"
|
||||
POKYVERSION : "23.0.25"
|
||||
YOCTO_POKY : "poky-&DISTRO_NAME_NO_CAP;-&POKYVERSION;"
|
||||
YOCTO_DL_URL : "https://downloads.yoctoproject.org"
|
||||
YOCTO_AB_URL : "https://autobuilder.yoctoproject.org"
|
||||
|
||||
@@ -1734,7 +1734,7 @@ events':
|
||||
|
||||
The tool is pretty self-explanatory, but for more detailed information
|
||||
on navigating through the data, see the `kernelshark
|
||||
website <http://rostedt.homelinux.com/kernelshark/>`__.
|
||||
website <https://kernelshark.org/Documentation.html>`__.
|
||||
|
||||
.. _ftrace-documentation:
|
||||
|
||||
@@ -1765,8 +1765,8 @@ There is a nice series of articles on using ftrace and trace-cmd at LWN:
|
||||
- `trace-cmd: A front-end for
|
||||
Ftrace <https://lwn.net/Articles/410200/>`__
|
||||
|
||||
There's more detailed documentation kernelshark usage here:
|
||||
`KernelShark <http://rostedt.homelinux.com/kernelshark/>`__
|
||||
See also `KernelShark's documentation <https://kernelshark.org/Documentation.html>`__
|
||||
for further usage details.
|
||||
|
||||
An amusing yet useful README (a tracing mini-HOWTO) can be found in
|
||||
``/sys/kernel/debug/tracing/README``.
|
||||
|
||||
@@ -45,6 +45,8 @@ distributions:
|
||||
|
||||
- Ubuntu 20.04
|
||||
|
||||
- Ubuntu 22.04
|
||||
|
||||
- Fedora 28
|
||||
|
||||
- Fedora 29
|
||||
@@ -61,6 +63,8 @@ distributions:
|
||||
|
||||
- Fedora 35
|
||||
|
||||
- Fedora 36
|
||||
|
||||
- CentOS 7.x
|
||||
|
||||
- Debian GNU/Linux 8.x (Jessie)
|
||||
@@ -79,6 +83,8 @@ distributions:
|
||||
|
||||
- AlmaLinux 8.5
|
||||
|
||||
- AlmaLinux 8.7
|
||||
|
||||
.. note::
|
||||
|
||||
- While the Yocto Project Team attempts to ensure all Yocto Project
|
||||
|
||||
@@ -7147,6 +7147,32 @@ system and gives an overview of their function and contents.
|
||||
:term:`SSTATE_DIR`
|
||||
The directory for the shared state cache.
|
||||
|
||||
:term:`SSTATE_EXCLUDEDEPS_SYSROOT`
|
||||
This variable allows to specify indirect dependencies to exclude
|
||||
from sysroots, for example to avoid the situations when a dependency on
|
||||
any ``-native`` recipe will pull in all dependencies of that recipe
|
||||
in the recipe sysroot. This behaviour might not always be wanted,
|
||||
for example when that ``-native`` recipe depends on build tools
|
||||
that are not relevant for the current recipe.
|
||||
|
||||
This way, irrelevant dependencies are ignored, which could have
|
||||
prevented the reuse of prebuilt artifacts stored in the Shared
|
||||
State Cache.
|
||||
|
||||
:term:`SSTATE_EXCLUDEDEPS_SYSROOT` is evaluated as two regular
|
||||
expressions of recipe and dependency to ignore. An example
|
||||
is the rule in :oe_git:`meta/conf/layer.conf </openembedded-core/tree/meta/conf/layer.conf>`::
|
||||
|
||||
# Nothing needs to depend on libc-initial
|
||||
# base-passwd/shadow-sysroot don't need their dependencies
|
||||
SSTATE_EXCLUDEDEPS_SYSROOT += "\
|
||||
.*->.*-initial.* \
|
||||
.*(base-passwd|shadow-sysroot)->.* \
|
||||
"
|
||||
|
||||
The ``->`` substring represents the dependency between
|
||||
the two regular expressions.
|
||||
|
||||
:term:`SSTATE_MIRROR_ALLOW_NETWORK`
|
||||
If set to "1", allows fetches from mirrors that are specified in
|
||||
:term:`SSTATE_MIRRORS` to work even when
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
DISTRO = "poky"
|
||||
DISTRO_NAME = "Poky (Yocto Project Reference Distro)"
|
||||
DISTRO_VERSION = "3.1.23"
|
||||
DISTRO_VERSION = "3.1.25"
|
||||
DISTRO_CODENAME = "dunfell"
|
||||
SDK_VENDOR = "-pokysdk"
|
||||
SDK_VERSION = "${@d.getVar('DISTRO_VERSION').replace('snapshot-${DATE}', 'snapshot')}"
|
||||
@@ -47,12 +47,14 @@ SANITY_TESTED_DISTROS ?= " \
|
||||
ubuntu-18.04 \n \
|
||||
ubuntu-19.04 \n \
|
||||
ubuntu-20.04 \n \
|
||||
ubuntu-22.04 \n \
|
||||
fedora-30 \n \
|
||||
fedora-31 \n \
|
||||
fedora-32 \n \
|
||||
fedora-33 \n \
|
||||
fedora-34 \n \
|
||||
fedora-35 \n \
|
||||
fedora-36 \n \
|
||||
centos-7 \n \
|
||||
centos-8 \n \
|
||||
debian-8 \n \
|
||||
@@ -63,6 +65,7 @@ SANITY_TESTED_DISTROS ?= " \
|
||||
opensuseleap-15.2 \n \
|
||||
opensuseleap-15.3 \n \
|
||||
almalinux-8.5 \n \
|
||||
almalinux-8.7 \n \
|
||||
"
|
||||
# add poky sanity bbclass
|
||||
INHERIT += "poky-sanity"
|
||||
|
||||
1067
meta/classes/create-spdx-2.2.bbclass
Normal file
1067
meta/classes/create-spdx-2.2.bbclass
Normal file
File diff suppressed because it is too large
Load Diff
8
meta/classes/create-spdx.bbclass
Normal file
8
meta/classes/create-spdx.bbclass
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Include this class when you don't care what version of SPDX you get; it will
|
||||
# be updated to the latest stable version that is supported
|
||||
inherit create-spdx-2.2
|
||||
@@ -253,7 +253,7 @@ def check_cves(d, patched_cves):
|
||||
"""
|
||||
Connect to the NVD database and find unpatched cves.
|
||||
"""
|
||||
from oe.cve_check import Version
|
||||
from oe.cve_check import Version, convert_cve_version
|
||||
|
||||
pn = d.getVar("PN")
|
||||
real_pv = d.getVar("PV")
|
||||
@@ -317,6 +317,9 @@ def check_cves(d, patched_cves):
|
||||
if cve in cve_whitelist:
|
||||
ignored = True
|
||||
|
||||
version_start = convert_cve_version(version_start)
|
||||
version_end = convert_cve_version(version_end)
|
||||
|
||||
if (operator_start == '=' and pv == version_start) or version_start == '-':
|
||||
vulnerable = True
|
||||
else:
|
||||
|
||||
@@ -2,8 +2,6 @@ inherit terminal
|
||||
|
||||
DEVSHELL = "${SHELL}"
|
||||
|
||||
PATH:prepend:task-devshell = "${COREBASE}/scripts/git-intercept:"
|
||||
|
||||
python do_devshell () {
|
||||
if d.getVarFlag("do_devshell", "manualfakeroot"):
|
||||
d.prependVar("DEVSHELL", "pseudo ")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
def get_rootfs_uuid(d):
|
||||
import subprocess
|
||||
rootfs = d.getVar('ROOTFS')
|
||||
output = subprocess.check_output(['tune2fs', '-l', rootfs])
|
||||
output = subprocess.check_output(['tune2fs', '-l', rootfs], text=True)
|
||||
for line in output.split('\n'):
|
||||
if line.startswith('Filesystem UUID:'):
|
||||
uuid = line.split()[-1]
|
||||
|
||||
@@ -311,7 +311,7 @@ fakeroot python do_image_qa () {
|
||||
except oe.utils.ImageQAFailed as e:
|
||||
qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
|
||||
except Exception as e:
|
||||
qamsg = qamsg + '\tImage QA function %s failed\n' % cmd
|
||||
qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (cmd, e)
|
||||
|
||||
if qamsg:
|
||||
imgname = d.getVar('IMAGE_NAME')
|
||||
@@ -437,7 +437,7 @@ python () {
|
||||
localdata.delVar('DATETIME')
|
||||
localdata.delVar('DATE')
|
||||
localdata.delVar('TMPDIR')
|
||||
vardepsexclude = (d.getVarFlag('IMAGE_CMD_' + realt, 'vardepsexclude', True) or '').split()
|
||||
vardepsexclude = (d.getVarFlag('IMAGE_CMD_' + realt, 'vardepsexclude') or '').split()
|
||||
for dep in vardepsexclude:
|
||||
localdata.delVar(dep)
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ do_kernel_metadata() {
|
||||
# SRC_URI. If they were supplied, we convert them into include directives
|
||||
# for the update part of the process
|
||||
for f in ${feat_dirs}; do
|
||||
if [ -d "${WORKDIR}/$f/meta" ]; then
|
||||
if [ -d "${WORKDIR}/$f/kernel-meta" ]; then
|
||||
includes="$includes -I${WORKDIR}/$f/kernel-meta"
|
||||
elif [ -d "${WORKDIR}/../oe-local-files/$f" ]; then
|
||||
includes="$includes -I${WORKDIR}/../oe-local-files/$f"
|
||||
|
||||
@@ -595,7 +595,7 @@ do_savedefconfig() {
|
||||
do_savedefconfig[nostamp] = "1"
|
||||
addtask savedefconfig after do_configure
|
||||
|
||||
inherit cml1
|
||||
inherit cml1 pkgconfig
|
||||
|
||||
KCONFIG_CONFIG_COMMAND_append = " LD='${KERNEL_LD}' HOSTLDFLAGS='${BUILD_LDFLAGS}'"
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ PACKAGE_NO_GCONV ?= "0"
|
||||
OVERRIDES_append = ":${TARGET_ARCH}-${TARGET_OS}"
|
||||
|
||||
locale_base_postinst_ontarget() {
|
||||
mkdir ${libdir}/locale
|
||||
localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s %s
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ def get_deployed_dependencies(d):
|
||||
deploy = {}
|
||||
# Get all the dependencies for the current task (rootfs).
|
||||
taskdata = d.getVar("BB_TASKDEPDATA", False)
|
||||
pn = d.getVar("PN", True)
|
||||
pn = d.getVar("PN")
|
||||
depends = list(set([dep[0] for dep
|
||||
in list(taskdata.values())
|
||||
if not dep[0].endswith("-native") and not dep[0] == pn]))
|
||||
|
||||
@@ -45,6 +45,7 @@ python multilib_virtclass_handler () {
|
||||
e.data.setVar("RECIPE_SYSROOT", "${WORKDIR}/recipe-sysroot")
|
||||
e.data.setVar("STAGING_DIR_TARGET", "${WORKDIR}/recipe-sysroot")
|
||||
e.data.setVar("STAGING_DIR_HOST", "${WORKDIR}/recipe-sysroot")
|
||||
e.data.setVar("RECIPE_SYSROOT_MANIFEST_SUBDIR", "nativesdk-" + variant)
|
||||
e.data.setVar("MLPREFIX", variant + "-")
|
||||
override = ":virtclass-multilib-" + variant
|
||||
e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
|
||||
|
||||
@@ -113,3 +113,5 @@ do_packagedata[stamp-extra-info] = ""
|
||||
USE_NLS = "${SDKUSE_NLS}"
|
||||
|
||||
OLDEST_KERNEL = "${SDK_OLDEST_KERNEL}"
|
||||
|
||||
PATH_prepend = "${COREBASE}/scripts/nativesdk-intercept:"
|
||||
|
||||
@@ -1140,6 +1140,14 @@ python split_and_strip_files () {
|
||||
# Modified the file so clear the cache
|
||||
cpath.updatecache(file)
|
||||
|
||||
def strip_pkgd_prefix(f):
|
||||
nonlocal dvar
|
||||
|
||||
if f.startswith(dvar):
|
||||
return f[len(dvar):]
|
||||
|
||||
return f
|
||||
|
||||
#
|
||||
# First lets process debug splitting
|
||||
#
|
||||
@@ -1153,6 +1161,8 @@ python split_and_strip_files () {
|
||||
for file in staticlibs:
|
||||
results.append( (file,source_info(file, d)) )
|
||||
|
||||
d.setVar("PKGDEBUGSOURCES", {strip_pkgd_prefix(f): sorted(s) for f, s in results})
|
||||
|
||||
sources = set()
|
||||
for r in results:
|
||||
sources.update(r[1])
|
||||
@@ -1460,6 +1470,7 @@ PKGDATA_VARS = "PN PE PV PR PKGE PKGV PKGR LICENSE DESCRIPTION SUMMARY RDEPENDS
|
||||
python emit_pkgdata() {
|
||||
from glob import glob
|
||||
import json
|
||||
import gzip
|
||||
|
||||
def process_postinst_on_target(pkg, mlprefix):
|
||||
pkgval = d.getVar('PKG_%s' % pkg)
|
||||
@@ -1532,6 +1543,8 @@ fi
|
||||
with open(data_file, 'w') as fd:
|
||||
fd.write("PACKAGES: %s\n" % packages)
|
||||
|
||||
pkgdebugsource = d.getVar("PKGDEBUGSOURCES") or []
|
||||
|
||||
pn = d.getVar('PN')
|
||||
global_variants = (d.getVar('MULTILIB_GLOBAL_VARIANTS') or "").split()
|
||||
variants = (d.getVar('MULTILIB_VARIANTS') or "").split()
|
||||
@@ -1551,17 +1564,32 @@ fi
|
||||
pkgval = pkg
|
||||
d.setVar('PKG_%s' % pkg, pkg)
|
||||
|
||||
extended_data = {
|
||||
"files_info": {}
|
||||
}
|
||||
|
||||
pkgdestpkg = os.path.join(pkgdest, pkg)
|
||||
files = {}
|
||||
files_extra = {}
|
||||
total_size = 0
|
||||
seen = set()
|
||||
for f in pkgfiles[pkg]:
|
||||
relpth = os.path.relpath(f, pkgdestpkg)
|
||||
fpath = os.sep + os.path.relpath(f, pkgdestpkg)
|
||||
|
||||
fstat = os.lstat(f)
|
||||
files[os.sep + relpth] = fstat.st_size
|
||||
files[fpath] = fstat.st_size
|
||||
|
||||
extended_data["files_info"].setdefault(fpath, {})
|
||||
extended_data["files_info"][fpath]['size'] = fstat.st_size
|
||||
|
||||
if fstat.st_ino not in seen:
|
||||
seen.add(fstat.st_ino)
|
||||
total_size += fstat.st_size
|
||||
|
||||
if fpath in pkgdebugsource:
|
||||
extended_data["files_info"][fpath]['debugsrc'] = pkgdebugsource[fpath]
|
||||
del pkgdebugsource[fpath]
|
||||
|
||||
d.setVar('FILES_INFO', json.dumps(files, sort_keys=True))
|
||||
|
||||
process_postinst_on_target(pkg, d.getVar("MLPREFIX"))
|
||||
@@ -1582,6 +1610,10 @@ fi
|
||||
|
||||
sf.write('%s_%s: %d\n' % ('PKGSIZE', pkg, total_size))
|
||||
|
||||
subdata_extended_file = pkgdatadir + "/extended/%s.json.gz" % pkg
|
||||
with gzip.open(subdata_extended_file, "wt", encoding="utf-8") as f:
|
||||
json.dump(extended_data, f, sort_keys=True, separators=(",", ":"))
|
||||
|
||||
# Symlinks needed for rprovides lookup
|
||||
rprov = d.getVar('RPROVIDES_%s' % pkg) or d.getVar('RPROVIDES')
|
||||
if rprov:
|
||||
@@ -1612,7 +1644,8 @@ fi
|
||||
write_extra_runtime_pkgs(global_variants, packages, pkgdatadir)
|
||||
|
||||
}
|
||||
emit_pkgdata[dirs] = "${PKGDESTWORK}/runtime ${PKGDESTWORK}/runtime-reverse ${PKGDESTWORK}/runtime-rprovides"
|
||||
emit_pkgdata[dirs] = "${PKGDESTWORK}/runtime ${PKGDESTWORK}/runtime-reverse ${PKGDESTWORK}/runtime-rprovides ${PKGDESTWORK}/extended"
|
||||
emit_pkgdata[vardepsexclude] = "BB_NUMBER_THREADS"
|
||||
|
||||
ldconfig_postinst_fragment() {
|
||||
if [ x"$D" = "x" ]; then
|
||||
|
||||
@@ -51,6 +51,8 @@ TOOLCHAIN_OUTPUTNAME ?= "${SDK_NAME}-toolchain-${SDK_VERSION}"
|
||||
SDK_ARCHIVE_TYPE ?= "tar.xz"
|
||||
SDK_XZ_COMPRESSION_LEVEL ?= "-9"
|
||||
SDK_XZ_OPTIONS ?= "${XZ_DEFAULTS} ${SDK_XZ_COMPRESSION_LEVEL}"
|
||||
SDK_ZIP_OPTIONS ?= "-y"
|
||||
|
||||
|
||||
# To support different sdk type according to SDK_ARCHIVE_TYPE, now support zip and tar.xz
|
||||
python () {
|
||||
@@ -58,7 +60,7 @@ python () {
|
||||
d.setVar('SDK_ARCHIVE_DEPENDS', 'zip-native')
|
||||
# SDK_ARCHIVE_CMD used to generate archived sdk ${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} from input dir ${SDK_OUTPUT}/${SDKPATH} to output dir ${SDKDEPLOYDIR}
|
||||
# recommand to cd into input dir first to avoid archive with buildpath
|
||||
d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; zip -r -y ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} .')
|
||||
d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; zip -r ${SDK_ZIP_OPTIONS} ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} .')
|
||||
else:
|
||||
d.setVar('SDK_ARCHIVE_DEPENDS', 'xz-native')
|
||||
d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; tar ${SDKTAROPTS} -cf - . | xz ${SDK_XZ_OPTIONS} > ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE}')
|
||||
|
||||
@@ -669,7 +669,7 @@ sdk_ext_postinst() {
|
||||
|
||||
# A bit of another hack, but we need this in the path only for devtool
|
||||
# so put it at the end of $PATH.
|
||||
echo "export PATH=$target_sdk_dir/sysroots/${SDK_SYS}${bindir_nativesdk}:\$PATH" >> $env_setup_script
|
||||
echo "export PATH=\"$target_sdk_dir/sysroots/${SDK_SYS}${bindir_nativesdk}:\$PATH\"" >> $env_setup_script
|
||||
|
||||
echo "printf 'SDK environment now set up; additionally you may now run devtool to perform development tasks.\nRun devtool --help for further details.\n'" >> $env_setup_script
|
||||
|
||||
|
||||
@@ -267,6 +267,10 @@ python extend_recipe_sysroot() {
|
||||
pn = d.getVar("PN")
|
||||
stagingdir = d.getVar("STAGING_DIR")
|
||||
sharedmanifests = d.getVar("COMPONENTS_DIR") + "/manifests"
|
||||
# only needed by multilib cross-canadian since it redefines RECIPE_SYSROOT
|
||||
manifestprefix = d.getVar("RECIPE_SYSROOT_MANIFEST_SUBDIR")
|
||||
if manifestprefix:
|
||||
sharedmanifests = sharedmanifests + "/" + manifestprefix
|
||||
recipesysroot = d.getVar("RECIPE_SYSROOT")
|
||||
recipesysrootnative = d.getVar("RECIPE_SYSROOT_NATIVE")
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ toolchain_create_sdk_env_script () {
|
||||
for i in ${CANADIANEXTRAOS}; do
|
||||
EXTRAPATH="$EXTRAPATH:$sdkpathnative$bindir/${TARGET_ARCH}${TARGET_VENDOR}-$i"
|
||||
done
|
||||
echo "export PATH=$sdkpathnative$bindir:$sdkpathnative$sbindir:$sdkpathnative$base_bindir:$sdkpathnative$base_sbindir:$sdkpathnative$bindir/../${HOST_SYS}/bin:$sdkpathnative$bindir/${TARGET_SYS}"$EXTRAPATH':$PATH' >> $script
|
||||
echo "export PATH=$sdkpathnative$bindir:$sdkpathnative$sbindir:$sdkpathnative$base_bindir:$sdkpathnative$base_sbindir:$sdkpathnative$bindir/../${HOST_SYS}/bin:$sdkpathnative$bindir/${TARGET_SYS}"$EXTRAPATH':"$PATH"' >> $script
|
||||
echo 'export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT' >> $script
|
||||
echo 'export PKG_CONFIG_PATH=$SDKTARGETSYSROOT'"$libdir"'/pkgconfig:$SDKTARGETSYSROOT'"$prefix"'/share/pkgconfig' >> $script
|
||||
echo 'export CONFIG_SITE=${SDKPATH}/site-config-'"${multimach_target_sys}" >> $script
|
||||
|
||||
@@ -22,21 +22,28 @@ SPDXLICENSEMAP[GPLv1.0] = "GPL-1.0"
|
||||
SPDXLICENSEMAP[GPL-1.0-only] = "GPL-1.0"
|
||||
SPDXLICENSEMAP[GPL-2] = "GPL-2.0"
|
||||
SPDXLICENSEMAP[GPLv2] = "GPL-2.0"
|
||||
SPDXLICENSEMAP[GPLv2+] = "GPL-2.0+"
|
||||
SPDXLICENSEMAP[GPLv2.0] = "GPL-2.0"
|
||||
SPDXLICENSEMAP[GPLv2.0+] = "GPL-2.0+"
|
||||
SPDXLICENSEMAP[GPL-2.0-only] = "GPL-2.0"
|
||||
SPDXLICENSEMAP[GPL-3] = "GPL-3.0"
|
||||
SPDXLICENSEMAP[GPLv3] = "GPL-3.0"
|
||||
SPDXLICENSEMAP[GPLv3+] = "GPL-3.0+"
|
||||
SPDXLICENSEMAP[GPLv3.0] = "GPL-3.0"
|
||||
SPDXLICENSEMAP[GPLv3.0+] = "GPL-3.0+"
|
||||
SPDXLICENSEMAP[GPL-3.0-only] = "GPL-3.0"
|
||||
|
||||
#LGPL variations
|
||||
SPDXLICENSEMAP[LGPLv2] = "LGPL-2.0"
|
||||
SPDXLICENSEMAP[LGPLv2+] = "LGPL-2.0+"
|
||||
SPDXLICENSEMAP[LGPLv2.0] = "LGPL-2.0"
|
||||
SPDXLICENSEMAP[LGPL-2.0-only] = "LGPL-2.0"
|
||||
SPDXLICENSEMAP[LGPL2.1] = "LGPL-2.1"
|
||||
SPDXLICENSEMAP[LGPLv2.1] = "LGPL-2.1"
|
||||
SPDXLICENSEMAP[LGPLv2.1+] = "LGPL-2.1+"
|
||||
SPDXLICENSEMAP[LGPL-2.1-only] = "LGPL-2.1"
|
||||
SPDXLICENSEMAP[LGPLv3] = "LGPL-3.0"
|
||||
SPDXLICENSEMAP[LGPLv3+] = "LGPL-3.0+"
|
||||
SPDXLICENSEMAP[LGPL-3.0-only] = "LGPL-3.0"
|
||||
|
||||
#MPL variations
|
||||
|
||||
5937
meta/files/spdx-licenses.json
Normal file
5937
meta/files/spdx-licenses.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -172,3 +172,40 @@ def get_cpe_ids(cve_product, version):
|
||||
cpe_ids.append(cpe_id)
|
||||
|
||||
return cpe_ids
|
||||
|
||||
def convert_cve_version(version):
|
||||
"""
|
||||
This function converts from CVE format to Yocto version format.
|
||||
eg 8.3_p1 -> 8.3p1, 6.2_rc1 -> 6.2-rc1
|
||||
|
||||
Unless it is redefined using CVE_VERSION in the recipe,
|
||||
cve_check uses the version in the name of the recipe (${PV})
|
||||
to check vulnerabilities against a CVE in the database downloaded from NVD.
|
||||
|
||||
When the version has an update, i.e.
|
||||
"p1" in OpenSSH 8.3p1,
|
||||
"-rc1" in linux kernel 6.2-rc1,
|
||||
the database stores the version as version_update (8.3_p1, 6.2_rc1).
|
||||
Therefore, we must transform this version before comparing to the
|
||||
recipe version.
|
||||
|
||||
In this case, the parameter of the function is 8.3_p1.
|
||||
If the version uses the Release Candidate format, "rc",
|
||||
this function replaces the '_' by '-'.
|
||||
If the version uses the Update format, "p",
|
||||
this function removes the '_' completely.
|
||||
"""
|
||||
import re
|
||||
|
||||
matches = re.match('^([0-9.]+)_((p|rc)[0-9]+)$', version)
|
||||
|
||||
if not matches:
|
||||
return version
|
||||
|
||||
version = matches.group(1)
|
||||
update = matches.group(2)
|
||||
|
||||
if matches.group(3) == "rc":
|
||||
return version + '-' + update
|
||||
|
||||
return version + update
|
||||
|
||||
@@ -57,6 +57,17 @@ def read_subpkgdata_dict(pkg, d):
|
||||
ret[newvar] = subd[var]
|
||||
return ret
|
||||
|
||||
def read_subpkgdata_extended(pkg, d):
|
||||
import json
|
||||
import gzip
|
||||
|
||||
fn = d.expand("${PKGDATA_DIR}/extended/%s.json.gz" % pkg)
|
||||
try:
|
||||
with gzip.open(fn, "rt", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
def _pkgmap(d):
|
||||
"""Return a dictionary mapping package to recipe name."""
|
||||
|
||||
|
||||
84
meta/lib/oe/sbom.py
Normal file
84
meta/lib/oe/sbom.py
Normal file
@@ -0,0 +1,84 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
|
||||
import collections
|
||||
|
||||
DepRecipe = collections.namedtuple("DepRecipe", ("doc", "doc_sha1", "recipe"))
|
||||
DepSource = collections.namedtuple("DepSource", ("doc", "doc_sha1", "recipe", "file"))
|
||||
|
||||
|
||||
def get_recipe_spdxid(d):
|
||||
return "SPDXRef-%s-%s" % ("Recipe", d.getVar("PN"))
|
||||
|
||||
|
||||
def get_download_spdxid(d, idx):
|
||||
return "SPDXRef-Download-%s-%d" % (d.getVar("PN"), idx)
|
||||
|
||||
|
||||
def get_package_spdxid(pkg):
|
||||
return "SPDXRef-Package-%s" % pkg
|
||||
|
||||
|
||||
def get_source_file_spdxid(d, idx):
|
||||
return "SPDXRef-SourceFile-%s-%d" % (d.getVar("PN"), idx)
|
||||
|
||||
|
||||
def get_packaged_file_spdxid(pkg, idx):
|
||||
return "SPDXRef-PackagedFile-%s-%d" % (pkg, idx)
|
||||
|
||||
|
||||
def get_image_spdxid(img):
|
||||
return "SPDXRef-Image-%s" % img
|
||||
|
||||
|
||||
def get_sdk_spdxid(sdk):
|
||||
return "SPDXRef-SDK-%s" % sdk
|
||||
|
||||
|
||||
def write_doc(d, spdx_doc, subdir, spdx_deploy=None, indent=None):
|
||||
from pathlib import Path
|
||||
|
||||
if spdx_deploy is None:
|
||||
spdx_deploy = Path(d.getVar("SPDXDEPLOY"))
|
||||
|
||||
dest = spdx_deploy / subdir / (spdx_doc.name + ".spdx.json")
|
||||
dest.parent.mkdir(exist_ok=True, parents=True)
|
||||
with dest.open("wb") as f:
|
||||
doc_sha1 = spdx_doc.to_json(f, sort_keys=True, indent=indent)
|
||||
|
||||
l = spdx_deploy / "by-namespace" / spdx_doc.documentNamespace.replace("/", "_")
|
||||
l.parent.mkdir(exist_ok=True, parents=True)
|
||||
l.symlink_to(os.path.relpath(dest, l.parent))
|
||||
|
||||
return doc_sha1
|
||||
|
||||
|
||||
def read_doc(fn):
|
||||
import hashlib
|
||||
import oe.spdx
|
||||
import io
|
||||
import contextlib
|
||||
|
||||
@contextlib.contextmanager
|
||||
def get_file():
|
||||
if isinstance(fn, io.IOBase):
|
||||
yield fn
|
||||
else:
|
||||
with fn.open("rb") as f:
|
||||
yield f
|
||||
|
||||
with get_file() as f:
|
||||
sha1 = hashlib.sha1()
|
||||
while True:
|
||||
chunk = f.read(4096)
|
||||
if not chunk:
|
||||
break
|
||||
sha1.update(chunk)
|
||||
|
||||
f.seek(0)
|
||||
doc = oe.spdx.SPDXDocument.from_json(f)
|
||||
|
||||
return (doc, sha1.hexdigest())
|
||||
357
meta/lib/oe/spdx.py
Normal file
357
meta/lib/oe/spdx.py
Normal file
@@ -0,0 +1,357 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
|
||||
#
|
||||
# This library is intended to capture the JSON SPDX specification in a type
|
||||
# safe manner. It is not intended to encode any particular OE specific
|
||||
# behaviors, see the sbom.py for that.
|
||||
#
|
||||
# The documented SPDX spec document doesn't cover the JSON syntax for
|
||||
# particular configuration, which can make it hard to determine what the JSON
|
||||
# syntax should be. I've found it is actually much simpler to read the official
|
||||
# SPDX JSON schema which can be found here: https://github.com/spdx/spdx-spec
|
||||
# in schemas/spdx-schema.json
|
||||
#
|
||||
|
||||
import hashlib
|
||||
import itertools
|
||||
import json
|
||||
|
||||
SPDX_VERSION = "2.2"
|
||||
|
||||
|
||||
#
|
||||
# The following are the support classes that are used to implement SPDX object
|
||||
#
|
||||
|
||||
class _Property(object):
|
||||
"""
|
||||
A generic SPDX object property. The different types will derive from this
|
||||
class
|
||||
"""
|
||||
|
||||
def __init__(self, *, default=None):
|
||||
self.default = default
|
||||
|
||||
def setdefault(self, dest, name):
|
||||
if self.default is not None:
|
||||
dest.setdefault(name, self.default)
|
||||
|
||||
|
||||
class _String(_Property):
|
||||
"""
|
||||
A scalar string property for an SPDX object
|
||||
"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def set_property(self, attrs, name):
|
||||
def get_helper(obj):
|
||||
return obj._spdx[name]
|
||||
|
||||
def set_helper(obj, value):
|
||||
obj._spdx[name] = value
|
||||
|
||||
def del_helper(obj):
|
||||
del obj._spdx[name]
|
||||
|
||||
attrs[name] = property(get_helper, set_helper, del_helper)
|
||||
|
||||
def init(self, source):
|
||||
return source
|
||||
|
||||
|
||||
class _Object(_Property):
|
||||
"""
|
||||
A scalar SPDX object property of a SPDX object
|
||||
"""
|
||||
|
||||
def __init__(self, cls, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.cls = cls
|
||||
|
||||
def set_property(self, attrs, name):
|
||||
def get_helper(obj):
|
||||
if not name in obj._spdx:
|
||||
obj._spdx[name] = self.cls()
|
||||
return obj._spdx[name]
|
||||
|
||||
def set_helper(obj, value):
|
||||
obj._spdx[name] = value
|
||||
|
||||
def del_helper(obj):
|
||||
del obj._spdx[name]
|
||||
|
||||
attrs[name] = property(get_helper, set_helper)
|
||||
|
||||
def init(self, source):
|
||||
return self.cls(**source)
|
||||
|
||||
|
||||
class _ListProperty(_Property):
|
||||
"""
|
||||
A list of SPDX properties
|
||||
"""
|
||||
|
||||
def __init__(self, prop, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.prop = prop
|
||||
|
||||
def set_property(self, attrs, name):
|
||||
def get_helper(obj):
|
||||
if not name in obj._spdx:
|
||||
obj._spdx[name] = []
|
||||
return obj._spdx[name]
|
||||
|
||||
def set_helper(obj, value):
|
||||
obj._spdx[name] = list(value)
|
||||
|
||||
def del_helper(obj):
|
||||
del obj._spdx[name]
|
||||
|
||||
attrs[name] = property(get_helper, set_helper, del_helper)
|
||||
|
||||
def init(self, source):
|
||||
return [self.prop.init(o) for o in source]
|
||||
|
||||
|
||||
class _StringList(_ListProperty):
|
||||
"""
|
||||
A list of strings as a property for an SPDX object
|
||||
"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(_String(), **kwargs)
|
||||
|
||||
|
||||
class _ObjectList(_ListProperty):
|
||||
"""
|
||||
A list of SPDX objects as a property for an SPDX object
|
||||
"""
|
||||
|
||||
def __init__(self, cls, **kwargs):
|
||||
super().__init__(_Object(cls), **kwargs)
|
||||
|
||||
|
||||
class MetaSPDXObject(type):
|
||||
"""
|
||||
A metaclass that allows properties (anything derived from a _Property
|
||||
class) to be defined for a SPDX object
|
||||
"""
|
||||
def __new__(mcls, name, bases, attrs):
|
||||
attrs["_properties"] = {}
|
||||
|
||||
for key in attrs.keys():
|
||||
if isinstance(attrs[key], _Property):
|
||||
prop = attrs[key]
|
||||
attrs["_properties"][key] = prop
|
||||
prop.set_property(attrs, key)
|
||||
|
||||
return super().__new__(mcls, name, bases, attrs)
|
||||
|
||||
|
||||
class SPDXObject(metaclass=MetaSPDXObject):
|
||||
"""
|
||||
The base SPDX object; all SPDX spec classes must derive from this class
|
||||
"""
|
||||
def __init__(self, **d):
|
||||
self._spdx = {}
|
||||
|
||||
for name, prop in self._properties.items():
|
||||
prop.setdefault(self._spdx, name)
|
||||
if name in d:
|
||||
self._spdx[name] = prop.init(d[name])
|
||||
|
||||
def serializer(self):
|
||||
return self._spdx
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name in self._properties or name == "_spdx":
|
||||
super().__setattr__(name, value)
|
||||
return
|
||||
raise KeyError("%r is not a valid SPDX property" % name)
|
||||
|
||||
#
|
||||
# These are the SPDX objects implemented from the spec. The *only* properties
|
||||
# that can be added to these objects are ones directly specified in the SPDX
|
||||
# spec, however you may add helper functions to make operations easier.
|
||||
#
|
||||
# Defaults should *only* be specified if the SPDX spec says there is a certain
|
||||
# required value for a field (e.g. dataLicense), or if the field is mandatory
|
||||
# and has some sane "this field is unknown" (e.g. "NOASSERTION")
|
||||
#
|
||||
|
||||
class SPDXAnnotation(SPDXObject):
|
||||
annotationDate = _String()
|
||||
annotationType = _String()
|
||||
annotator = _String()
|
||||
comment = _String()
|
||||
|
||||
class SPDXChecksum(SPDXObject):
|
||||
algorithm = _String()
|
||||
checksumValue = _String()
|
||||
|
||||
|
||||
class SPDXRelationship(SPDXObject):
|
||||
spdxElementId = _String()
|
||||
relatedSpdxElement = _String()
|
||||
relationshipType = _String()
|
||||
comment = _String()
|
||||
annotations = _ObjectList(SPDXAnnotation)
|
||||
|
||||
|
||||
class SPDXExternalReference(SPDXObject):
|
||||
referenceCategory = _String()
|
||||
referenceType = _String()
|
||||
referenceLocator = _String()
|
||||
|
||||
|
||||
class SPDXPackageVerificationCode(SPDXObject):
|
||||
packageVerificationCodeValue = _String()
|
||||
packageVerificationCodeExcludedFiles = _StringList()
|
||||
|
||||
|
||||
class SPDXPackage(SPDXObject):
|
||||
ALLOWED_CHECKSUMS = [
|
||||
"SHA1",
|
||||
"SHA224",
|
||||
"SHA256",
|
||||
"SHA384",
|
||||
"SHA512",
|
||||
"MD2",
|
||||
"MD4",
|
||||
"MD5",
|
||||
"MD6",
|
||||
]
|
||||
|
||||
name = _String()
|
||||
SPDXID = _String()
|
||||
versionInfo = _String()
|
||||
downloadLocation = _String(default="NOASSERTION")
|
||||
supplier = _String(default="NOASSERTION")
|
||||
homepage = _String()
|
||||
licenseConcluded = _String(default="NOASSERTION")
|
||||
licenseDeclared = _String(default="NOASSERTION")
|
||||
summary = _String()
|
||||
description = _String()
|
||||
sourceInfo = _String()
|
||||
copyrightText = _String(default="NOASSERTION")
|
||||
licenseInfoFromFiles = _StringList(default=["NOASSERTION"])
|
||||
externalRefs = _ObjectList(SPDXExternalReference)
|
||||
packageVerificationCode = _Object(SPDXPackageVerificationCode)
|
||||
hasFiles = _StringList()
|
||||
packageFileName = _String()
|
||||
annotations = _ObjectList(SPDXAnnotation)
|
||||
checksums = _ObjectList(SPDXChecksum)
|
||||
|
||||
|
||||
class SPDXFile(SPDXObject):
|
||||
SPDXID = _String()
|
||||
fileName = _String()
|
||||
licenseConcluded = _String(default="NOASSERTION")
|
||||
copyrightText = _String(default="NOASSERTION")
|
||||
licenseInfoInFiles = _StringList(default=["NOASSERTION"])
|
||||
checksums = _ObjectList(SPDXChecksum)
|
||||
fileTypes = _StringList()
|
||||
|
||||
|
||||
class SPDXCreationInfo(SPDXObject):
|
||||
created = _String()
|
||||
licenseListVersion = _String()
|
||||
comment = _String()
|
||||
creators = _StringList()
|
||||
|
||||
|
||||
class SPDXExternalDocumentRef(SPDXObject):
|
||||
externalDocumentId = _String()
|
||||
spdxDocument = _String()
|
||||
checksum = _Object(SPDXChecksum)
|
||||
|
||||
|
||||
class SPDXExtractedLicensingInfo(SPDXObject):
|
||||
name = _String()
|
||||
comment = _String()
|
||||
licenseId = _String()
|
||||
extractedText = _String()
|
||||
|
||||
|
||||
class SPDXDocument(SPDXObject):
|
||||
spdxVersion = _String(default="SPDX-" + SPDX_VERSION)
|
||||
dataLicense = _String(default="CC0-1.0")
|
||||
SPDXID = _String(default="SPDXRef-DOCUMENT")
|
||||
name = _String()
|
||||
documentNamespace = _String()
|
||||
creationInfo = _Object(SPDXCreationInfo)
|
||||
packages = _ObjectList(SPDXPackage)
|
||||
files = _ObjectList(SPDXFile)
|
||||
relationships = _ObjectList(SPDXRelationship)
|
||||
externalDocumentRefs = _ObjectList(SPDXExternalDocumentRef)
|
||||
hasExtractedLicensingInfos = _ObjectList(SPDXExtractedLicensingInfo)
|
||||
|
||||
def __init__(self, **d):
|
||||
super().__init__(**d)
|
||||
|
||||
def to_json(self, f, *, sort_keys=False, indent=None, separators=None):
|
||||
class Encoder(json.JSONEncoder):
|
||||
def default(self, o):
|
||||
if isinstance(o, SPDXObject):
|
||||
return o.serializer()
|
||||
|
||||
return super().default(o)
|
||||
|
||||
sha1 = hashlib.sha1()
|
||||
for chunk in Encoder(
|
||||
sort_keys=sort_keys,
|
||||
indent=indent,
|
||||
separators=separators,
|
||||
).iterencode(self):
|
||||
chunk = chunk.encode("utf-8")
|
||||
f.write(chunk)
|
||||
sha1.update(chunk)
|
||||
|
||||
return sha1.hexdigest()
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, f):
|
||||
return cls(**json.load(f))
|
||||
|
||||
def add_relationship(self, _from, relationship, _to, *, comment=None, annotation=None):
|
||||
if isinstance(_from, SPDXObject):
|
||||
from_spdxid = _from.SPDXID
|
||||
else:
|
||||
from_spdxid = _from
|
||||
|
||||
if isinstance(_to, SPDXObject):
|
||||
to_spdxid = _to.SPDXID
|
||||
else:
|
||||
to_spdxid = _to
|
||||
|
||||
r = SPDXRelationship(
|
||||
spdxElementId=from_spdxid,
|
||||
relatedSpdxElement=to_spdxid,
|
||||
relationshipType=relationship,
|
||||
)
|
||||
|
||||
if comment is not None:
|
||||
r.comment = comment
|
||||
|
||||
if annotation is not None:
|
||||
r.annotations.append(annotation)
|
||||
|
||||
self.relationships.append(r)
|
||||
|
||||
def find_by_spdxid(self, spdxid):
|
||||
for o in itertools.chain(self.packages, self.files):
|
||||
if o.SPDXID == spdxid:
|
||||
return o
|
||||
return None
|
||||
|
||||
def find_external_document_ref(self, namespace):
|
||||
for r in self.externalDocumentRefs:
|
||||
if r.spdxDocument == namespace:
|
||||
return r
|
||||
return None
|
||||
@@ -1,5 +1,6 @@
|
||||
from oeqa.runtime.case import OERuntimeTestCase
|
||||
from oeqa.core.decorator.depends import OETestDepends
|
||||
from oeqa.core.decorator.data import skipIfFeature
|
||||
from oeqa.runtime.decorator.package import OEHasPackage
|
||||
|
||||
import re
|
||||
@@ -16,12 +17,14 @@ class RTCTest(OERuntimeTestCase):
|
||||
self.logger.debug('Starting systemd-timesyncd daemon')
|
||||
self.target.run('systemctl enable --now --runtime systemd-timesyncd')
|
||||
|
||||
@skipIfFeature('read-only-rootfs',
|
||||
'Test does not work with read-only-rootfs in IMAGE_FEATURES')
|
||||
@OETestDepends(['ssh.SSHTest.test_ssh'])
|
||||
@OEHasPackage(['coreutils', 'busybox'])
|
||||
def test_rtc(self):
|
||||
(status, output) = self.target.run('hwclock -r')
|
||||
self.assertEqual(status, 0, msg='Failed to get RTC time, output: %s' % output)
|
||||
|
||||
|
||||
(status, current_datetime) = self.target.run('date +"%m%d%H%M%Y"')
|
||||
self.assertEqual(status, 0, msg='Failed to get system current date & time, output: %s' % current_datetime)
|
||||
|
||||
@@ -32,7 +35,6 @@ class RTCTest(OERuntimeTestCase):
|
||||
|
||||
(status, output) = self.target.run('date %s' % current_datetime)
|
||||
self.assertEqual(status, 0, msg='Failed to reset system date & time, output: %s' % output)
|
||||
|
||||
|
||||
(status, output) = self.target.run('hwclock -w')
|
||||
self.assertEqual(status, 0, msg='Failed to reset RTC time, output: %s' % output)
|
||||
|
||||
|
||||
@@ -67,11 +67,11 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
|
||||
% self.default_target_type)
|
||||
runtime_group.add_argument('--target-ip', action='store',
|
||||
default=self.default_target_ip,
|
||||
help="IP address of device under test, default: %s" \
|
||||
help="IP address and optionally ssh port (default 22) of device under test, for example '192.168.0.7:22'. Default: %s" \
|
||||
% self.default_target_ip)
|
||||
runtime_group.add_argument('--server-ip', action='store',
|
||||
default=self.default_target_ip,
|
||||
help="IP address of device under test, default: %s" \
|
||||
help="IP address of the test host from test target machine, default: %s" \
|
||||
% self.default_server_ip)
|
||||
|
||||
runtime_group.add_argument('--host-dumper-dir', action='store',
|
||||
|
||||
@@ -48,6 +48,25 @@ class CVECheck(OESelftestTestCase):
|
||||
self.assertTrue( result ,msg="Failed to compare version with suffix '1.0_patch2' < '1.0_patch3'")
|
||||
|
||||
|
||||
def test_convert_cve_version(self):
|
||||
from oe.cve_check import convert_cve_version
|
||||
|
||||
# Default format
|
||||
self.assertEqual(convert_cve_version("8.3"), "8.3")
|
||||
self.assertEqual(convert_cve_version(""), "")
|
||||
|
||||
# OpenSSL format version
|
||||
self.assertEqual(convert_cve_version("1.1.1t"), "1.1.1t")
|
||||
|
||||
# OpenSSH format
|
||||
self.assertEqual(convert_cve_version("8.3_p1"), "8.3p1")
|
||||
self.assertEqual(convert_cve_version("8.3_p22"), "8.3p22")
|
||||
|
||||
# Linux kernel format
|
||||
self.assertEqual(convert_cve_version("6.2_rc8"), "6.2-rc8")
|
||||
self.assertEqual(convert_cve_version("6.2_rc31"), "6.2-rc31")
|
||||
|
||||
|
||||
def test_recipe_report_json(self):
|
||||
config = """
|
||||
INHERIT += "cve-check"
|
||||
|
||||
@@ -75,7 +75,7 @@ class BitbakePrTests(OESelftestTestCase):
|
||||
exported_db_path = os.path.join(self.builddir, 'export.inc')
|
||||
export_result = runCmd("bitbake-prserv-tool export %s" % exported_db_path, ignore_status=True)
|
||||
self.assertEqual(export_result.status, 0, msg="PR Service database export failed: %s" % export_result.output)
|
||||
self.assertTrue(os.path.exists(exported_db_path))
|
||||
self.assertTrue(os.path.exists(exported_db_path), msg="%s didn't exist, tool output %s" % (exported_db_path, export_result.output))
|
||||
|
||||
if replace_current_db:
|
||||
current_db_path = os.path.join(get_bb_var('PERSISTENT_DIR'), 'prserv.sqlite3')
|
||||
|
||||
@@ -39,7 +39,6 @@ exclude_packages = [
|
||||
'gstreamer1.0-python',
|
||||
'hwlatdetect',
|
||||
'kernel-devsrc',
|
||||
'libaprutil',
|
||||
'libcap-ng',
|
||||
'libjson',
|
||||
'libproxy',
|
||||
|
||||
@@ -432,10 +432,13 @@ class QemuRunner:
|
||||
except OSError as e:
|
||||
if e.errno != errno.ESRCH:
|
||||
raise
|
||||
endtime = time.time() + self.runqemutime
|
||||
while self.runqemu.poll() is None and time.time() < endtime:
|
||||
time.sleep(1)
|
||||
if self.runqemu.poll() is None:
|
||||
try:
|
||||
outs, errs = self.runqemu.communicate(timeout = self.runqemutime)
|
||||
if outs:
|
||||
self.logger.info("Output from runqemu:\n%s", outs.decode("utf-8"))
|
||||
if errs:
|
||||
self.logger.info("Stderr from runqemu:\n%s", errs.decode("utf-8"))
|
||||
except TimeoutExpired:
|
||||
self.logger.debug("Sending SIGKILL to runqemu")
|
||||
os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL)
|
||||
if not self.runqemu.stdout.closed:
|
||||
|
||||
@@ -6,6 +6,13 @@ SRC_URI[sha256sum] = "8863717113c4897e2ad3271fc808ea245319e6fd95eed2e934fae8e089
|
||||
# These issues have kernel fixes rather than bluez fixes so exclude here
|
||||
CVE_CHECK_WHITELIST += "CVE-2020-12352 CVE-2020-24490"
|
||||
|
||||
# Commit 7a80d2096f1b7125085e21448112aa02f49f5e9a, e2b0f0d8d63e1223bb714a9efb37e2257818268b
|
||||
# and 0388794dc5fdb73a4ea88bcf148de0a12b4364d4 to fix CVE-2022-39177
|
||||
# already backport in CVE-2022-39176.patch
|
||||
# https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/1977968
|
||||
|
||||
CVE_CHECK_WHITELIST += "CVE-2022-39177"
|
||||
|
||||
# noinst programs in Makefile.tools that are conditional on READLINE
|
||||
# support
|
||||
NOINST_TOOLS_READLINE ?= " \
|
||||
|
||||
226
meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch
Normal file
226
meta/recipes-connectivity/openssl/openssl/CVE-2023-0464.patch
Normal file
@@ -0,0 +1,226 @@
|
||||
From 879f7080d7e141f415c79eaa3a8ac4a3dad0348b Mon Sep 17 00:00:00 2001
|
||||
From: Pauli <pauli@openssl.org>
|
||||
Date: Wed, 8 Mar 2023 15:28:20 +1100
|
||||
Subject: [PATCH] x509: excessive resource use verifying policy constraints
|
||||
|
||||
A security vulnerability has been identified in all supported versions
|
||||
of OpenSSL related to the verification of X.509 certificate chains
|
||||
that include policy constraints. Attackers may be able to exploit this
|
||||
vulnerability by creating a malicious certificate chain that triggers
|
||||
exponential use of computational resources, leading to a denial-of-service
|
||||
(DoS) attack on affected systems.
|
||||
|
||||
Fixes CVE-2023-0464
|
||||
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20569)
|
||||
|
||||
CVE: CVE-2023-0464
|
||||
Upstream-Status: Backport [https://git.openssl.org/gitweb/?p=openssl.git;a=patch;h=879f7080d7e141f415c79eaa3a8ac4a3dad0348b]
|
||||
Signed-off-by: Nikhil R <nikhil.r@kpit.com>
|
||||
|
||||
---
|
||||
crypto/x509v3/pcy_local.h | 8 +++++++-
|
||||
crypto/x509v3/pcy_node.c | 12 +++++++++---
|
||||
crypto/x509v3/pcy_tree.c | 37 +++++++++++++++++++++++++++----------
|
||||
3 files changed, 43 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/crypto/x509v3/pcy_local.h b/crypto/x509v3/pcy_local.h
|
||||
index 5daf78de45..344aa06765 100644
|
||||
--- a/crypto/x509v3/pcy_local.h
|
||||
+++ b/crypto/x509v3/pcy_local.h
|
||||
@@ -111,6 +111,11 @@ struct X509_POLICY_LEVEL_st {
|
||||
};
|
||||
|
||||
struct X509_POLICY_TREE_st {
|
||||
+ /* The number of nodes in the tree */
|
||||
+ size_t node_count;
|
||||
+ /* The maximum number of nodes in the tree */
|
||||
+ size_t node_maximum;
|
||||
+
|
||||
/* This is the tree 'level' data */
|
||||
X509_POLICY_LEVEL *levels;
|
||||
int nlevel;
|
||||
@@ -159,7 +164,8 @@ X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk,
|
||||
X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_DATA *data,
|
||||
X509_POLICY_NODE *parent,
|
||||
- X509_POLICY_TREE *tree);
|
||||
+ X509_POLICY_TREE *tree,
|
||||
+ int extra_data);
|
||||
void policy_node_free(X509_POLICY_NODE *node);
|
||||
int policy_node_match(const X509_POLICY_LEVEL *lvl,
|
||||
const X509_POLICY_NODE *node, const ASN1_OBJECT *oid);
|
||||
diff --git a/crypto/x509v3/pcy_node.c b/crypto/x509v3/pcy_node.c
|
||||
index e2d7b15322..d574fb9d66 100644
|
||||
--- a/crypto/x509v3/pcy_node.c
|
||||
+++ b/crypto/x509v3/pcy_node.c
|
||||
@@ -59,10 +59,15 @@ X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_DATA *data,
|
||||
X509_POLICY_NODE *parent,
|
||||
- X509_POLICY_TREE *tree)
|
||||
+ X509_POLICY_TREE *tree,
|
||||
+ int extra_data)
|
||||
{
|
||||
X509_POLICY_NODE *node;
|
||||
|
||||
+ /* Verify that the tree isn't too large. This mitigates CVE-2023-0464 */
|
||||
+ if (tree->node_maximum > 0 && tree->node_count >= tree->node_maximum)
|
||||
+ return NULL;
|
||||
+
|
||||
node = OPENSSL_zalloc(sizeof(*node));
|
||||
if (node == NULL) {
|
||||
X509V3err(X509V3_F_LEVEL_ADD_NODE, ERR_R_MALLOC_FAILURE);
|
||||
@@ -70,7 +75,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
node->data = data;
|
||||
node->parent = parent;
|
||||
- if (level) {
|
||||
+ if (level != NULL) {
|
||||
if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) {
|
||||
if (level->anyPolicy)
|
||||
goto node_error;
|
||||
@@ -90,7 +95,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
}
|
||||
|
||||
- if (tree) {
|
||||
+ if (extra_data) {
|
||||
if (tree->extra_data == NULL)
|
||||
tree->extra_data = sk_X509_POLICY_DATA_new_null();
|
||||
if (tree->extra_data == NULL){
|
||||
@@ -103,6 +108,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
}
|
||||
|
||||
+ tree->node_count++;
|
||||
if (parent)
|
||||
parent->nchild++;
|
||||
|
||||
diff --git a/crypto/x509v3/pcy_tree.c b/crypto/x509v3/pcy_tree.c
|
||||
index 6e8322cbc5..6c7fd35405 100644
|
||||
--- a/crypto/x509v3/pcy_tree.c
|
||||
+++ b/crypto/x509v3/pcy_tree.c
|
||||
@@ -13,6 +13,18 @@
|
||||
|
||||
#include "pcy_local.h"
|
||||
|
||||
+/*
|
||||
+ * If the maximum number of nodes in the policy tree isn't defined, set it to
|
||||
+ * a generous default of 1000 nodes.
|
||||
+ *
|
||||
+ * Defining this to be zero means unlimited policy tree growth which opens the
|
||||
+ * door on CVE-2023-0464.
|
||||
+ */
|
||||
+
|
||||
+#ifndef OPENSSL_POLICY_TREE_NODES_MAX
|
||||
+# define OPENSSL_POLICY_TREE_NODES_MAX 1000
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* Enable this to print out the complete policy tree at various point during
|
||||
* evaluation.
|
||||
@@ -168,6 +180,9 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
return X509_PCY_TREE_INTERNAL;
|
||||
}
|
||||
|
||||
+ /* Limit the growth of the tree to mitigate CVE-2023-0464 */
|
||||
+ tree->node_maximum = OPENSSL_POLICY_TREE_NODES_MAX;
|
||||
+
|
||||
/*
|
||||
* http://tools.ietf.org/html/rfc5280#section-6.1.2, figure 3.
|
||||
*
|
||||
@@ -184,7 +199,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
level = tree->levels;
|
||||
if ((data = policy_data_new(NULL, OBJ_nid2obj(NID_any_policy), 0)) == NULL)
|
||||
goto bad_tree;
|
||||
- if (level_add_node(level, data, NULL, tree) == NULL) {
|
||||
+ if (level_add_node(level, data, NULL, tree, 1) == NULL) {
|
||||
policy_data_free(data);
|
||||
goto bad_tree;
|
||||
}
|
||||
@@ -243,7 +258,8 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
* Return value: 1 on success, 0 otherwise
|
||||
*/
|
||||
static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
- X509_POLICY_DATA *data)
|
||||
+ X509_POLICY_DATA *data,
|
||||
+ X509_POLICY_TREE *tree)
|
||||
{
|
||||
X509_POLICY_LEVEL *last = curr - 1;
|
||||
int i, matched = 0;
|
||||
@@ -253,13 +269,13 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
X509_POLICY_NODE *node = sk_X509_POLICY_NODE_value(last->nodes, i);
|
||||
|
||||
if (policy_node_match(last, node, data->valid_policy)) {
|
||||
- if (level_add_node(curr, data, node, NULL) == NULL)
|
||||
+ if (level_add_node(curr, data, node, tree, 0) == NULL)
|
||||
return 0;
|
||||
matched = 1;
|
||||
}
|
||||
}
|
||||
if (!matched && last->anyPolicy) {
|
||||
- if (level_add_node(curr, data, last->anyPolicy, NULL) == NULL)
|
||||
+ if (level_add_node(curr, data, last->anyPolicy, tree, 0) == NULL)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -272,7 +288,8 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
* Return value: 1 on success, 0 otherwise.
|
||||
*/
|
||||
static int tree_link_nodes(X509_POLICY_LEVEL *curr,
|
||||
- const X509_POLICY_CACHE *cache)
|
||||
+ const X509_POLICY_CACHE *cache,
|
||||
+ X509_POLICY_TREE *tree)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -280,7 +297,7 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr,
|
||||
X509_POLICY_DATA *data = sk_X509_POLICY_DATA_value(cache->data, i);
|
||||
|
||||
/* Look for matching nodes in previous level */
|
||||
- if (!tree_link_matching_nodes(curr, data))
|
||||
+ if (!tree_link_matching_nodes(curr, data, tree))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -311,7 +328,7 @@ static int tree_add_unmatched(X509_POLICY_LEVEL *curr,
|
||||
/* Curr may not have anyPolicy */
|
||||
data->qualifier_set = cache->anyPolicy->qualifier_set;
|
||||
data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
|
||||
- if (level_add_node(curr, data, node, tree) == NULL) {
|
||||
+ if (level_add_node(curr, data, node, tree, 1) == NULL) {
|
||||
policy_data_free(data);
|
||||
return 0;
|
||||
}
|
||||
@@ -373,7 +390,7 @@ static int tree_link_any(X509_POLICY_LEVEL *curr,
|
||||
}
|
||||
/* Finally add link to anyPolicy */
|
||||
if (last->anyPolicy &&
|
||||
- level_add_node(curr, cache->anyPolicy, last->anyPolicy, NULL) == NULL)
|
||||
+ level_add_node(curr, cache->anyPolicy, last->anyPolicy, tree, 0) == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -555,7 +572,7 @@ static int tree_calculate_user_set(X509_POLICY_TREE *tree,
|
||||
extra->qualifier_set = anyPolicy->data->qualifier_set;
|
||||
extra->flags = POLICY_DATA_FLAG_SHARED_QUALIFIERS
|
||||
| POLICY_DATA_FLAG_EXTRA_NODE;
|
||||
- node = level_add_node(NULL, extra, anyPolicy->parent, tree);
|
||||
+ node = level_add_node(NULL, extra, anyPolicy->parent, tree, 1);
|
||||
}
|
||||
if (!tree->user_policies) {
|
||||
tree->user_policies = sk_X509_POLICY_NODE_new_null();
|
||||
@@ -582,7 +599,7 @@ static int tree_evaluate(X509_POLICY_TREE *tree)
|
||||
|
||||
for (i = 1; i < tree->nlevel; i++, curr++) {
|
||||
cache = policy_cache_set(curr->cert);
|
||||
- if (!tree_link_nodes(curr, cache))
|
||||
+ if (!tree_link_nodes(curr, cache, tree))
|
||||
return X509_PCY_TREE_INTERNAL;
|
||||
|
||||
if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY)
|
||||
--
|
||||
2.34.1
|
||||
@@ -0,0 +1,60 @@
|
||||
From b013765abfa80036dc779dd0e50602c57bb3bf95 Mon Sep 17 00:00:00 2001
|
||||
From: Matt Caswell <matt@openssl.org>
|
||||
Date: Tue, 7 Mar 2023 16:52:55 +0000
|
||||
Subject: [PATCH] Ensure that EXFLAG_INVALID_POLICY is checked even in leaf
|
||||
certs
|
||||
|
||||
Even though we check the leaf cert to confirm it is valid, we
|
||||
later ignored the invalid flag and did not notice that the leaf
|
||||
cert was bad.
|
||||
|
||||
Fixes: CVE-2023-0465
|
||||
|
||||
Reviewed-by: Hugo Landau <hlandau@openssl.org>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20588)
|
||||
|
||||
CVE: CVE-2023-0465
|
||||
Upstream-Status: Backport [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=b013765abfa80036dc779dd0e50602c57bb3bf95]
|
||||
Comment: Refreshed first hunk
|
||||
Signed-off-by: Omkar Patil <omkar.patil@kpit.com>
|
||||
|
||||
---
|
||||
crypto/x509/x509_vfy.c | 11 +++++++++--
|
||||
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
|
||||
index 925fbb5412..1dfe4f9f31 100644
|
||||
--- a/crypto/x509/x509_vfy.c
|
||||
+++ b/crypto/x509/x509_vfy.c
|
||||
@@ -1649,18 +1649,25 @@
|
||||
}
|
||||
/* Invalid or inconsistent extensions */
|
||||
if (ret == X509_PCY_TREE_INVALID) {
|
||||
- int i;
|
||||
+ int i, cbcalled = 0;
|
||||
|
||||
/* Locate certificates with bad extensions and notify callback. */
|
||||
- for (i = 1; i < sk_X509_num(ctx->chain); i++) {
|
||||
+ for (i = 0; i < sk_X509_num(ctx->chain); i++) {
|
||||
X509 *x = sk_X509_value(ctx->chain, i);
|
||||
|
||||
if (!(x->ex_flags & EXFLAG_INVALID_POLICY))
|
||||
continue;
|
||||
+ cbcalled = 1;
|
||||
if (!verify_cb_cert(ctx, x, i,
|
||||
X509_V_ERR_INVALID_POLICY_EXTENSION))
|
||||
return 0;
|
||||
}
|
||||
+ if (!cbcalled) {
|
||||
+ /* Should not be able to get here */
|
||||
+ X509err(X509_F_CHECK_POLICY, ERR_R_INTERNAL_ERROR);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ /* The callback ignored the error so we return success */
|
||||
return 1;
|
||||
}
|
||||
if (ret == X509_PCY_TREE_FAILURE) {
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
From 0d16b7e99aafc0b4a6d729eec65a411a7e025f0a Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Mraz <tomas@openssl.org>
|
||||
Date: Tue, 21 Mar 2023 16:15:47 +0100
|
||||
Subject: [PATCH] Fix documentation of X509_VERIFY_PARAM_add0_policy()
|
||||
|
||||
The function was incorrectly documented as enabling policy checking.
|
||||
|
||||
Fixes: CVE-2023-0466
|
||||
|
||||
Reviewed-by: Matt Caswell <matt@openssl.org>
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20564)
|
||||
|
||||
CVE: CVE-2023-0466
|
||||
Upstream-Status: Backport [https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=0d16b7e99aafc0b4a6d729eec65a411a7e025f0a]
|
||||
Comment: Refreshed first hunk from CHANGE and NEWS
|
||||
Signed-off-by: Omkar Patil <omkar.patil@kpit.com>
|
||||
|
||||
---
|
||||
CHANGES | 5 +++++
|
||||
NEWS | 1 +
|
||||
doc/man3/X509_VERIFY_PARAM_set_flags.pod | 9 +++++++--
|
||||
3 files changed, 13 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/CHANGES b/CHANGES
|
||||
index efccf7838e..b19f1429bb 100644
|
||||
--- a/CHANGES
|
||||
+++ b/CHANGES
|
||||
@@ -9,6 +9,11 @@
|
||||
|
||||
Changes between 1.1.1s and 1.1.1t [7 Feb 2023]
|
||||
|
||||
+ *) Corrected documentation of X509_VERIFY_PARAM_add0_policy() to mention
|
||||
+ that it does not enable policy checking. Thanks to
|
||||
+ David Benjamin for discovering this issue. (CVE-2023-0466)
|
||||
+ [Tomas Mraz]
|
||||
+
|
||||
*) Fixed X.400 address type confusion in X.509 GeneralName.
|
||||
|
||||
There is a type confusion vulnerability relating to X.400 address processing
|
||||
diff --git a/NEWS b/NEWS
|
||||
index 36a9bb6890..62615693fa 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
Major changes between OpenSSL 1.1.1s and OpenSSL 1.1.1t [7 Feb 2023]
|
||||
|
||||
+ o Fixed documentation of X509_VERIFY_PARAM_add0_policy() (CVE-2023-0466)
|
||||
o Fixed X.400 address type confusion in X.509 GeneralName (CVE-2023-0286)
|
||||
o Fixed Use-after-free following BIO_new_NDEF (CVE-2023-0215)
|
||||
o Fixed Double free after calling PEM_read_bio_ex (CVE-2022-4450)
|
||||
diff --git a/doc/man3/X509_VERIFY_PARAM_set_flags.pod b/doc/man3/X509_VERIFY_PARAM_set_flags.pod
|
||||
index f6f304bf7b..aa292f9336 100644
|
||||
--- a/doc/man3/X509_VERIFY_PARAM_set_flags.pod
|
||||
+++ b/doc/man3/X509_VERIFY_PARAM_set_flags.pod
|
||||
@@ -92,8 +92,9 @@ B<trust>.
|
||||
X509_VERIFY_PARAM_set_time() sets the verification time in B<param> to
|
||||
B<t>. Normally the current time is used.
|
||||
|
||||
-X509_VERIFY_PARAM_add0_policy() enables policy checking (it is disabled
|
||||
-by default) and adds B<policy> to the acceptable policy set.
|
||||
+X509_VERIFY_PARAM_add0_policy() adds B<policy> to the acceptable policy set.
|
||||
+Contrary to preexisting documentation of this function it does not enable
|
||||
+policy checking.
|
||||
|
||||
X509_VERIFY_PARAM_set1_policies() enables policy checking (it is disabled
|
||||
by default) and sets the acceptable policy set to B<policies>. Any existing
|
||||
@@ -377,6 +378,10 @@ and has no effect.
|
||||
|
||||
The X509_VERIFY_PARAM_get_hostflags() function was added in OpenSSL 1.1.0i.
|
||||
|
||||
+The function X509_VERIFY_PARAM_add0_policy() was historically documented as
|
||||
+enabling policy checking however the implementation has never done this.
|
||||
+The documentation was changed to align with the implementation.
|
||||
+
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2009-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -18,13 +18,16 @@ SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
|
||||
file://afalg.patch \
|
||||
file://reproducible.patch \
|
||||
file://reproducibility.patch \
|
||||
file://CVE-2023-0464.patch \
|
||||
file://CVE-2023-0465.patch \
|
||||
file://CVE-2023-0466.patch \
|
||||
"
|
||||
|
||||
SRC_URI_append_class-nativesdk = " \
|
||||
file://environment.d-openssl.sh \
|
||||
"
|
||||
|
||||
SRC_URI[sha256sum] = "c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa"
|
||||
SRC_URI[sha256sum] = "8dee9b24bdb1dcbf0c3d1e9b02fb8f6bf22165e807f45adeb7c9677536859d3b"
|
||||
|
||||
inherit lib_package multilib_header multilib_script ptest
|
||||
MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash"
|
||||
@@ -1,4 +1,4 @@
|
||||
127.0.0.1 localhost.localdomain localhost
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
|
||||
@@ -139,6 +139,10 @@ do_configure () {
|
||||
do_prepare_config
|
||||
merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
|
||||
cml1_do_configure
|
||||
|
||||
# Save a copy of .config and autoconf.h.
|
||||
cp .config .config.orig
|
||||
cp include/autoconf.h include/autoconf.h.orig
|
||||
}
|
||||
|
||||
do_compile() {
|
||||
@@ -146,13 +150,17 @@ do_compile() {
|
||||
if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
|
||||
export KCONFIG_NOTIMESTAMP=1
|
||||
fi
|
||||
|
||||
# Ensure we start do_compile with the original .config and autoconf.h.
|
||||
# These files should always have matching timestamps.
|
||||
cp .config.orig .config
|
||||
cp include/autoconf.h.orig include/autoconf.h
|
||||
|
||||
if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
|
||||
# Guard againt interrupted do_compile: clean temporary files.
|
||||
rm -f .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps
|
||||
|
||||
# split the .config into two parts, and make two busybox binaries
|
||||
if [ -e .config.orig ]; then
|
||||
# Need to guard again an interrupted do_compile - restore any backup
|
||||
cp .config.orig .config
|
||||
fi
|
||||
cp .config .config.orig
|
||||
oe_runmake busybox.cfg.suid
|
||||
oe_runmake busybox.cfg.nosuid
|
||||
|
||||
@@ -189,15 +197,18 @@ do_compile() {
|
||||
bbfatal "busybox suid binary incorrectly provides /bin/sh"
|
||||
fi
|
||||
|
||||
# copy .config.orig back to .config, because the install process may check this file
|
||||
cp .config.orig .config
|
||||
# cleanup
|
||||
rm .config.orig .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps
|
||||
rm .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps
|
||||
else
|
||||
oe_runmake busybox_unstripped
|
||||
cp busybox_unstripped busybox
|
||||
oe_runmake busybox.links
|
||||
fi
|
||||
|
||||
# restore original .config and autoconf.h, because the install process
|
||||
# may check these files
|
||||
cp .config.orig .config
|
||||
cp include/autoconf.h.orig include/autoconf.h
|
||||
}
|
||||
|
||||
do_install () {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
require glibc-common.inc
|
||||
require glibc-ld.inc
|
||||
|
||||
DEPENDS = "virtual/${TARGET_PREFIX}gcc libgcc-initial linux-libc-headers"
|
||||
DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}binutils${BUSUFFIX} libgcc-initial linux-libc-headers"
|
||||
BUSUFFIX= ""
|
||||
BUSUFFIX:class-nativesdk = "-crosssdk"
|
||||
|
||||
PROVIDES = "virtual/libc"
|
||||
PROVIDES += "virtual/libintl virtual/libiconv"
|
||||
|
||||
82
meta/recipes-core/glibc/glibc/CVE-2023-0687.patch
Normal file
82
meta/recipes-core/glibc/glibc/CVE-2023-0687.patch
Normal file
@@ -0,0 +1,82 @@
|
||||
From 952aff5c00ad7c6b83c3f310f2643939538827f8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?=
|
||||
=?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= <leo@yuriev.ru>
|
||||
Date: Sat, 4 Feb 2023 14:41:38 +0300
|
||||
Subject: [PATCH] gmon: Fix allocated buffer overflow (bug 29444)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The `__monstartup()` allocates a buffer used to store all the data
|
||||
accumulated by the monitor.
|
||||
|
||||
The size of this buffer depends on the size of the internal structures
|
||||
used and the address range for which the monitor is activated, as well
|
||||
as on the maximum density of call instructions and/or callable functions
|
||||
that could be potentially on a segment of executable code.
|
||||
|
||||
In particular a hash table of arcs is placed at the end of this buffer.
|
||||
The size of this hash table is calculated in bytes as
|
||||
p->fromssize = p->textsize / HASHFRACTION;
|
||||
|
||||
but actually should be
|
||||
p->fromssize = ROUNDUP(p->textsize / HASHFRACTION, sizeof(*p->froms));
|
||||
|
||||
This results in writing beyond the end of the allocated buffer when an
|
||||
added arc corresponds to a call near from the end of the monitored
|
||||
address range, since `_mcount()` check the incoming caller address for
|
||||
monitored range but not the intermediate result hash-like index that
|
||||
uses to write into the table.
|
||||
|
||||
It should be noted that when the results are output to `gmon.out`, the
|
||||
table is read to the last element calculated from the allocated size in
|
||||
bytes, so the arcs stored outside the buffer boundary did not fall into
|
||||
`gprof` for analysis. Thus this "feature" help me to found this bug
|
||||
during working with https://sourceware.org/bugzilla/show_bug.cgi?id=29438
|
||||
|
||||
Just in case, I will explicitly note that the problem breaks the
|
||||
`make test t=gmon/tst-gmon-dso` added for Bug 29438.
|
||||
There, the arc of the `f3()` call disappears from the output, since in
|
||||
the DSO case, the call to `f3` is located close to the end of the
|
||||
monitored range.
|
||||
|
||||
Signed-off-by: Леонид Юрьев (Leonid Yuriev) <leo@yuriev.ru>
|
||||
|
||||
Another minor error seems a related typo in the calculation of
|
||||
`kcountsize`, but since kcounts are smaller than froms, this is
|
||||
actually to align the p->froms data.
|
||||
|
||||
Co-authored-by: DJ Delorie <dj@redhat.com>
|
||||
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
||||
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=801af9fafd4689337ebf27260aa115335a0cb2bc]
|
||||
CVE: CVE-2023-0687
|
||||
Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com>
|
||||
---
|
||||
gmon/gmon.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gmon/gmon.c b/gmon/gmon.c
|
||||
index dee6480..bf76358 100644
|
||||
--- a/gmon/gmon.c
|
||||
+++ b/gmon/gmon.c
|
||||
@@ -132,6 +132,8 @@ __monstartup (u_long lowpc, u_long highpc)
|
||||
p->lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
p->textsize = p->highpc - p->lowpc;
|
||||
+ /* This looks like a typo, but it's here to align the p->froms
|
||||
+ section. */
|
||||
p->kcountsize = ROUNDUP(p->textsize / HISTFRACTION, sizeof(*p->froms));
|
||||
p->hashfraction = HASHFRACTION;
|
||||
p->log_hashfraction = -1;
|
||||
@@ -142,7 +144,7 @@ __monstartup (u_long lowpc, u_long highpc)
|
||||
instead of integer division. Precompute shift amount. */
|
||||
p->log_hashfraction = ffs(p->hashfraction * sizeof(*p->froms)) - 1;
|
||||
}
|
||||
- p->fromssize = p->textsize / HASHFRACTION;
|
||||
+ p->fromssize = ROUNDUP(p->textsize / HASHFRACTION, sizeof(*p->froms));
|
||||
p->tolimit = p->textsize * ARCDENSITY / 100;
|
||||
if (p->tolimit < MINARCS)
|
||||
p->tolimit = MINARCS;
|
||||
--
|
||||
2.7.4
|
||||
@@ -79,6 +79,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
|
||||
file://0035-x86_64-Avoid-lazy-relocation-of-tlsdesc-BZ-27137.patch \
|
||||
file://0036-i386-Avoid-lazy-relocation-of-tlsdesc-BZ-27137.patch \
|
||||
file://0037-Avoid-deadlock-between-pthread_create-and-ctors.patch \
|
||||
file://CVE-2023-0687.patch \
|
||||
"
|
||||
S = "${WORKDIR}/git"
|
||||
B = "${WORKDIR}/build-${TARGET_SYS}"
|
||||
|
||||
@@ -24,7 +24,7 @@ IMAGE_FSTYPES = "wic.vmdk"
|
||||
|
||||
inherit core-image setuptools3
|
||||
|
||||
SRCREV ?= "f5e8301b203715404d18215d7d914499555b3425"
|
||||
SRCREV ?= "ee461b42358db458f39e558b8667fbcffb6d8044"
|
||||
SRC_URI = "git://git.yoctoproject.org/poky;branch=dunfell \
|
||||
file://Yocto_Build_Appliance.vmx \
|
||||
file://Yocto_Build_Appliance.vmxf \
|
||||
|
||||
@@ -66,7 +66,7 @@ create_sdk_files_append () {
|
||||
# Generate new (mini) sdk-environment-setup file
|
||||
script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-${SDK_SYS}}
|
||||
touch $script
|
||||
echo 'export PATH=${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${sbindir_nativesdk}:${SDKPATHNATIVE}${base_bindir_nativesdk}:${SDKPATHNATIVE}${base_sbindir_nativesdk}:$PATH' >> $script
|
||||
echo 'export PATH="${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${sbindir_nativesdk}:${SDKPATHNATIVE}${base_bindir_nativesdk}:${SDKPATHNATIVE}${base_sbindir_nativesdk}:$PATH"' >> $script
|
||||
echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
|
||||
echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script
|
||||
echo 'export SSL_CERT_FILE="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script
|
||||
|
||||
115
meta/recipes-core/systemd/systemd/CVE-2023-26604-1.patch
Normal file
115
meta/recipes-core/systemd/systemd/CVE-2023-26604-1.patch
Normal file
@@ -0,0 +1,115 @@
|
||||
From 612ebf6c913dd0e4197c44909cb3157f5c51a2f0 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 31 Aug 2020 19:37:13 +0200
|
||||
Subject: [PATCH] pager: set $LESSSECURE whenver we invoke a pager
|
||||
|
||||
Some extra safety when invoked via "sudo". With this we address a
|
||||
genuine design flaw of sudo, and we shouldn't need to deal with this.
|
||||
But it's still a good idea to disable this surface given how exotic it
|
||||
is.
|
||||
|
||||
Prompted by #5666
|
||||
|
||||
CVE: CVE-2023-26604
|
||||
Upstream-Status: Backport [https://github.com/systemd/systemd/pull/17270/commits/612ebf6c913dd0e4197c44909cb3157f5c51a2f0]
|
||||
Comments: Hunk not refreshed
|
||||
Signed-off-by: rajmohan r <rajmohan.r@kpit.com>
|
||||
---
|
||||
man/less-variables.xml | 9 +++++++++
|
||||
man/systemctl.xml | 1 +
|
||||
man/systemd.xml | 1 +
|
||||
src/shared/pager.c | 23 +++++++++++++++++++++--
|
||||
4 files changed, 32 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/man/less-variables.xml b/man/less-variables.xml
|
||||
index 08e513c99f8e..c52511ca8e18 100644
|
||||
--- a/man/less-variables.xml
|
||||
+++ b/man/less-variables.xml
|
||||
@@ -64,6 +64,15 @@
|
||||
the invoking terminal is determined to be UTF-8 compatible).</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
+ <varlistentry id='lesssecure'>
|
||||
+ <term><varname>$SYSTEMD_LESSSECURE</varname></term>
|
||||
+
|
||||
+ <listitem><para>Takes a boolean argument. Overrides the <varname>$LESSSECURE</varname> environment
|
||||
+ variable when invoking the pager, which controls the "secure" mode of less (which disables commands
|
||||
+ such as <literal>|</literal> which allow to easily shell out to external command lines). By default
|
||||
+ less secure mode is enabled, with this setting it may be disabled.</para></listitem>
|
||||
+ </varlistentry>
|
||||
+
|
||||
<varlistentry id='colors'>
|
||||
<term><varname>$SYSTEMD_COLORS</varname></term>
|
||||
|
||||
diff --git a/man/systemctl.xml b/man/systemctl.xml
|
||||
index 1c5502883700..a3f0c3041a57 100644
|
||||
--- a/man/systemctl.xml
|
||||
+++ b/man/systemctl.xml
|
||||
@@ -2240,6 +2240,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
|
||||
<xi:include href="less-variables.xml" xpointer="pager"/>
|
||||
<xi:include href="less-variables.xml" xpointer="less"/>
|
||||
<xi:include href="less-variables.xml" xpointer="lesscharset"/>
|
||||
+ <xi:include href="less-variables.xml" xpointer="lesssecure"/>
|
||||
<xi:include href="less-variables.xml" xpointer="colors"/>
|
||||
<xi:include href="less-variables.xml" xpointer="urlify"/>
|
||||
</refsect1>
|
||||
diff --git a/man/systemd.xml b/man/systemd.xml
|
||||
index a9040545c2ab..c92cfef77689 100644
|
||||
--- a/man/systemd.xml
|
||||
+++ b/man/systemd.xml
|
||||
@@ -692,6 +692,7 @@
|
||||
<xi:include href="less-variables.xml" xpointer="pager"/>
|
||||
<xi:include href="less-variables.xml" xpointer="less"/>
|
||||
<xi:include href="less-variables.xml" xpointer="lesscharset"/>
|
||||
+ <xi:include href="less-variables.xml" xpointer="lesssecure"/>
|
||||
<xi:include href="less-variables.xml" xpointer="colors"/>
|
||||
<xi:include href="less-variables.xml" xpointer="urlify"/>
|
||||
|
||||
diff --git a/src/shared/pager.c b/src/shared/pager.c
|
||||
index e03be6d23b2d..9c21881241f5 100644
|
||||
--- a/src/shared/pager.c
|
||||
+++ b/src/shared/pager.c
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "copy.h"
|
||||
+#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "io-util.h"
|
||||
@@ -152,8 +153,7 @@ int pager_open(PagerFlags flags) {
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
- /* Initialize a good charset for less. This is
|
||||
- * particularly important if we output UTF-8
|
||||
+ /* Initialize a good charset for less. This is particularly important if we output UTF-8
|
||||
* characters. */
|
||||
less_charset = getenv("SYSTEMD_LESSCHARSET");
|
||||
if (!less_charset && is_locale_utf8())
|
||||
@@ -164,6 +164,25 @@ int pager_open(PagerFlags flags) {
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
+ /* People might invoke us from sudo, don't needlessly allow less to be a way to shell out
|
||||
+ * privileged stuff. */
|
||||
+ r = getenv_bool("SYSTEMD_LESSSECURE");
|
||||
+ if (r == 0) { /* Remove env var if off */
|
||||
+ if (unsetenv("LESSSECURE") < 0) {
|
||||
+ log_error_errno(errno, "Failed to uset environment variable LESSSECURE: %m");
|
||||
+ _exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* Set env var otherwise */
|
||||
+ if (r < 0)
|
||||
+ log_warning_errno(r, "Unable to parse $SYSTEMD_LESSSECURE, ignoring: %m");
|
||||
+
|
||||
+ if (setenv("LESSSECURE", "1", 1) < 0) {
|
||||
+ log_error_errno(errno, "Failed to set environment variable LESSSECURE: %m");
|
||||
+ _exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (pager_args) {
|
||||
r = loop_write(exe_name_pipe[1], pager_args[0], strlen(pager_args[0]) + 1, false);
|
||||
if (r < 0) {
|
||||
264
meta/recipes-core/systemd/systemd/CVE-2023-26604-2.patch
Normal file
264
meta/recipes-core/systemd/systemd/CVE-2023-26604-2.patch
Normal file
@@ -0,0 +1,264 @@
|
||||
From 1b5b507cd2d1d7a2b053151abb548475ad9c5c3b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Mon, 12 Oct 2020 18:57:32 +0200
|
||||
Subject: [PATCH] test-login: always test sd_pid_get_owner_uid(), modernize
|
||||
|
||||
A long time some function only worked when in a session, and the test
|
||||
didn't execute them when sd_pid_get_session() failed. Let's always call
|
||||
them to increase coverage.
|
||||
|
||||
While at it, let's test for ==0 not >=0 where we don't expect the function
|
||||
to return anything except 0 or error.
|
||||
|
||||
CVE: CVE-2023-26604
|
||||
Upstream-Status: Backport [https://github.com/systemd/systemd/pull/17270/commits/1b5b507cd2d1d7a2b053151abb548475ad9c5c3b.patch]
|
||||
Comments: Hunk not refreshed
|
||||
Signed-off-by: rajmohan r <rajmohan.r@kpit.com>
|
||||
---
|
||||
src/libsystemd/sd-login/test-login.c | 131 ++++++++++++++-------------
|
||||
1 file changed, 70 insertions(+), 61 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c
|
||||
index c0c77e04714b..0494fc77ba18 100644
|
||||
--- a/src/libsystemd/sd-login/test-login.c
|
||||
+++ b/src/libsystemd/sd-login/test-login.c
|
||||
@@ -5,21 +5,22 @@
|
||||
#include "sd-login.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
+#include "errno-list.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "log.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "time-util.h"
|
||||
-#include "util.h"
|
||||
+#include "user-util.h"
|
||||
|
||||
static char* format_uids(char **buf, uid_t* uids, int count) {
|
||||
- int pos = 0, k, inc;
|
||||
+ int pos = 0, inc;
|
||||
size_t size = (DECIMAL_STR_MAX(uid_t) + 1) * count + 1;
|
||||
|
||||
assert_se(*buf = malloc(size));
|
||||
|
||||
- for (k = 0; k < count; k++) {
|
||||
+ for (int k = 0; k < count; k++) {
|
||||
sprintf(*buf + pos, "%s"UID_FMT"%n", k > 0 ? " " : "", uids[k], &inc);
|
||||
pos += inc;
|
||||
}
|
||||
@@ -30,6 +31,10 @@ static char* format_uids(char **buf, uid_t* uids, int count) {
|
||||
return *buf;
|
||||
}
|
||||
|
||||
+static const char *e(int r) {
|
||||
+ return r == 0 ? "OK" : errno_to_name(r);
|
||||
+}
|
||||
+
|
||||
static void test_login(void) {
|
||||
_cleanup_close_pair_ int pair[2] = { -1, -1 };
|
||||
_cleanup_free_ char *pp = NULL, *qq = NULL,
|
||||
@@ -39,65 +44,71 @@ static void test_login(void) {
|
||||
*seat = NULL, *session = NULL,
|
||||
*unit = NULL, *user_unit = NULL, *slice = NULL;
|
||||
int r;
|
||||
- uid_t u, u2;
|
||||
- char *t, **seats, **sessions;
|
||||
+ uid_t u, u2 = UID_INVALID;
|
||||
+ char *t, **seats = NULL, **sessions = NULL;
|
||||
|
||||
r = sd_pid_get_unit(0, &unit);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
- log_info("sd_pid_get_unit(0, …) → \"%s\"", strna(unit));
|
||||
+ log_info("sd_pid_get_unit(0, …) → %s / \"%s\"", e(r), strnull(unit));
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
|
||||
r = sd_pid_get_user_unit(0, &user_unit);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
- log_info("sd_pid_get_user_unit(0, …) → \"%s\"", strna(user_unit));
|
||||
+ log_info("sd_pid_get_user_unit(0, …) → %s / \"%s\"", e(r), strnull(user_unit));
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
|
||||
r = sd_pid_get_slice(0, &slice);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
- log_info("sd_pid_get_slice(0, …) → \"%s\"", strna(slice));
|
||||
+ log_info("sd_pid_get_slice(0, …) → %s / \"%s\"", e(r), strnull(slice));
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
+
|
||||
+ r = sd_pid_get_owner_uid(0, &u2);
|
||||
+ log_info("sd_pid_get_owner_uid(0, …) → %s / "UID_FMT, e(r), u2);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
|
||||
r = sd_pid_get_session(0, &session);
|
||||
- if (r < 0) {
|
||||
- log_warning_errno(r, "sd_pid_get_session(0, …): %m");
|
||||
- if (r == -ENODATA)
|
||||
- log_info("Seems we are not running in a session, skipping some tests.");
|
||||
- } else {
|
||||
- log_info("sd_pid_get_session(0, …) → \"%s\"", session);
|
||||
-
|
||||
- assert_se(sd_pid_get_owner_uid(0, &u2) == 0);
|
||||
- log_info("sd_pid_get_owner_uid(0, …) → "UID_FMT, u2);
|
||||
-
|
||||
- assert_se(sd_pid_get_cgroup(0, &cgroup) == 0);
|
||||
- log_info("sd_pid_get_cgroup(0, …) → \"%s\"", cgroup);
|
||||
-
|
||||
- r = sd_uid_get_display(u2, &display_session);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
- log_info("sd_uid_get_display("UID_FMT", …) → \"%s\"",
|
||||
- u2, strnull(display_session));
|
||||
-
|
||||
- assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0);
|
||||
- sd_peer_get_session(pair[0], &pp);
|
||||
- sd_peer_get_session(pair[1], &qq);
|
||||
- assert_se(streq_ptr(pp, qq));
|
||||
-
|
||||
- r = sd_uid_get_sessions(u2, false, &sessions);
|
||||
+ log_info("sd_pid_get_session(0, …) → %s / \"%s\"", e(r), strnull(session));
|
||||
+
|
||||
+ r = sd_pid_get_cgroup(0, &cgroup);
|
||||
+ log_info("sd_pid_get_cgroup(0, …) → %s / \"%s\"", e(r), strnull(cgroup));
|
||||
+ assert_se(r == 0);
|
||||
+
|
||||
+ r = sd_uid_get_display(u2, &display_session);
|
||||
+ log_info("sd_uid_get_display("UID_FMT", …) → %s / \"%s\"", u2, e(r), strnull(display_session));
|
||||
+ if (u2 == UID_INVALID)
|
||||
+ assert_se(r == -EINVAL);
|
||||
+ else
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
+
|
||||
+ assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0);
|
||||
+ sd_peer_get_session(pair[0], &pp);
|
||||
+ sd_peer_get_session(pair[1], &qq);
|
||||
+ assert_se(streq_ptr(pp, qq));
|
||||
+
|
||||
+ r = sd_uid_get_sessions(u2, false, &sessions);
|
||||
+ assert_se(t = strv_join(sessions, " "));
|
||||
+ log_info("sd_uid_get_sessions("UID_FMT", …) → %s \"%s\"", u2, e(r), t);
|
||||
+ if (u2 == UID_INVALID)
|
||||
+ assert_se(r == -EINVAL);
|
||||
+ else {
|
||||
assert_se(r >= 0);
|
||||
assert_se(r == (int) strv_length(sessions));
|
||||
- assert_se(t = strv_join(sessions, " "));
|
||||
- strv_free(sessions);
|
||||
- log_info("sd_uid_get_sessions("UID_FMT", …) → [%i] \"%s\"", u2, r, t);
|
||||
- free(t);
|
||||
+ }
|
||||
+ sessions = strv_free(sessions);
|
||||
+ free(t);
|
||||
|
||||
- assert_se(r == sd_uid_get_sessions(u2, false, NULL));
|
||||
+ assert_se(r == sd_uid_get_sessions(u2, false, NULL));
|
||||
|
||||
- r = sd_uid_get_seats(u2, false, &seats);
|
||||
+ r = sd_uid_get_seats(u2, false, &seats);
|
||||
+ assert_se(t = strv_join(seats, " "));
|
||||
+ log_info("sd_uid_get_seats("UID_FMT", …) → %s \"%s\"", u2, e(r), t);
|
||||
+ if (u2 == UID_INVALID)
|
||||
+ assert_se(r == -EINVAL);
|
||||
+ else {
|
||||
assert_se(r >= 0);
|
||||
assert_se(r == (int) strv_length(seats));
|
||||
- assert_se(t = strv_join(seats, " "));
|
||||
- strv_free(seats);
|
||||
- log_info("sd_uid_get_seats("UID_FMT", …) → [%i] \"%s\"", u2, r, t);
|
||||
- free(t);
|
||||
-
|
||||
- assert_se(r == sd_uid_get_seats(u2, false, NULL));
|
||||
}
|
||||
+ seats = strv_free(seats);
|
||||
+ free(t);
|
||||
+
|
||||
+ assert_se(r == sd_uid_get_seats(u2, false, NULL));
|
||||
|
||||
if (session) {
|
||||
r = sd_session_is_active(session);
|
||||
@@ -109,7 +120,7 @@ static void test_login(void) {
|
||||
log_info("sd_session_is_remote(\"%s\") → %s", session, yes_no(r));
|
||||
|
||||
r = sd_session_get_state(session, &state);
|
||||
- assert_se(r >= 0);
|
||||
+ assert_se(r == 0);
|
||||
log_info("sd_session_get_state(\"%s\") → \"%s\"", session, state);
|
||||
|
||||
assert_se(sd_session_get_uid(session, &u) >= 0);
|
||||
@@ -123,16 +134,16 @@ static void test_login(void) {
|
||||
log_info("sd_session_get_class(\"%s\") → \"%s\"", session, class);
|
||||
|
||||
r = sd_session_get_display(session, &display);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
log_info("sd_session_get_display(\"%s\") → \"%s\"", session, strna(display));
|
||||
|
||||
r = sd_session_get_remote_user(session, &remote_user);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
log_info("sd_session_get_remote_user(\"%s\") → \"%s\"",
|
||||
session, strna(remote_user));
|
||||
|
||||
r = sd_session_get_remote_host(session, &remote_host);
|
||||
- assert_se(r >= 0 || r == -ENODATA);
|
||||
+ assert_se(IN_SET(r, 0, -ENODATA));
|
||||
log_info("sd_session_get_remote_host(\"%s\") → \"%s\"",
|
||||
session, strna(remote_host));
|
||||
|
||||
@@ -161,7 +172,7 @@ static void test_login(void) {
|
||||
assert_se(r == -ENODATA);
|
||||
}
|
||||
|
||||
- assert_se(sd_uid_get_state(u, &state2) >= 0);
|
||||
+ assert_se(sd_uid_get_state(u, &state2) == 0);
|
||||
log_info("sd_uid_get_state("UID_FMT", …) → %s", u, state2);
|
||||
}
|
||||
|
||||
@@ -173,11 +184,11 @@ static void test_login(void) {
|
||||
assert_se(sd_uid_is_on_seat(u, 0, seat) > 0);
|
||||
|
||||
r = sd_seat_get_active(seat, &session2, &u2);
|
||||
- assert_se(r >= 0);
|
||||
+ assert_se(r == 0);
|
||||
log_info("sd_seat_get_active(\"%s\", …) → \"%s\", "UID_FMT, seat, session2, u2);
|
||||
|
||||
r = sd_uid_is_on_seat(u, 1, seat);
|
||||
- assert_se(r >= 0);
|
||||
+ assert_se(IN_SET(r, 0, 1));
|
||||
assert_se(!!r == streq(session, session2));
|
||||
|
||||
r = sd_seat_get_sessions(seat, &sessions, &uids, &n);
|
||||
@@ -185,8 +196,8 @@ static void test_login(void) {
|
||||
assert_se(r == (int) strv_length(sessions));
|
||||
assert_se(t = strv_join(sessions, " "));
|
||||
strv_free(sessions);
|
||||
- log_info("sd_seat_get_sessions(\"%s\", …) → %i, \"%s\", [%i] {%s}",
|
||||
- seat, r, t, n, format_uids(&buf, uids, n));
|
||||
+ log_info("sd_seat_get_sessions(\"%s\", …) → %s, \"%s\", [%u] {%s}",
|
||||
+ seat, e(r), t, n, format_uids(&buf, uids, n));
|
||||
free(t);
|
||||
|
||||
assert_se(sd_seat_get_sessions(seat, NULL, NULL, NULL) == r);
|
||||
@@ -204,7 +215,7 @@ static void test_login(void) {
|
||||
|
||||
r = sd_seat_get_active(NULL, &t, NULL);
|
||||
assert_se(IN_SET(r, 0, -ENODATA));
|
||||
- log_info("sd_seat_get_active(NULL, …) (active session on current seat) → %s", strnull(t));
|
||||
+ log_info("sd_seat_get_active(NULL, …) (active session on current seat) → %s / \"%s\"", e(r), strnull(t));
|
||||
free(t);
|
||||
|
||||
r = sd_get_sessions(&sessions);
|
||||
@@ -244,13 +255,11 @@ static void test_login(void) {
|
||||
|
||||
static void test_monitor(void) {
|
||||
sd_login_monitor *m = NULL;
|
||||
- unsigned n;
|
||||
int r;
|
||||
|
||||
- r = sd_login_monitor_new("session", &m);
|
||||
- assert_se(r >= 0);
|
||||
+ assert_se(sd_login_monitor_new("session", &m) == 0);
|
||||
|
||||
- for (n = 0; n < 5; n++) {
|
||||
+ for (unsigned n = 0; n < 5; n++) {
|
||||
struct pollfd pollfd = {};
|
||||
usec_t timeout, nw;
|
||||
182
meta/recipes-core/systemd/systemd/CVE-2023-26604-3.patch
Normal file
182
meta/recipes-core/systemd/systemd/CVE-2023-26604-3.patch
Normal file
@@ -0,0 +1,182 @@
|
||||
From 0a42426d797406b4b01a0d9c13bb759c2629d108 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Wed, 7 Oct 2020 11:15:05 +0200
|
||||
Subject: [PATCH] pager: make pager secure when under euid is changed or
|
||||
explicitly requested
|
||||
|
||||
The variable is renamed to SYSTEMD_PAGERSECURE (because it's not just about
|
||||
less now), and we automatically enable secure mode in certain cases, but not
|
||||
otherwise.
|
||||
|
||||
This approach is more nuanced, but should provide a better experience for
|
||||
users:
|
||||
|
||||
- Previusly we would set LESSSECURE=1 and trust the pager to make use of
|
||||
it. But this has an effect only on less. We need to not start pagers which
|
||||
are insecure when in secure mode. In particular more is like that and is a
|
||||
very popular pager.
|
||||
|
||||
- We don't enable secure mode always, which means that those other pagers can
|
||||
reasonably used.
|
||||
|
||||
- We do the right thing by default, but the user has ultimate control by
|
||||
setting SYSTEMD_PAGERSECURE.
|
||||
|
||||
Fixes #5666.
|
||||
|
||||
v2:
|
||||
- also check $PKEXEC_UID
|
||||
|
||||
v3:
|
||||
- use 'sd_pid_get_owner_uid() != geteuid()' as the condition
|
||||
|
||||
CVE: CVE-2023-26604
|
||||
Upstream-Status: Backport [https://github.com/systemd/systemd/pull/17270/commits/0a42426d797406b4b01a0d9c13bb759c2629d108]
|
||||
Comments: Hunk refreshed
|
||||
Signed-off-by: rajmohan r <rajmohan.r@kpit.com>
|
||||
---
|
||||
man/less-variables.xml | 30 +++++++++++++++----
|
||||
src/shared/pager.c | 63 ++++++++++++++++++++++++++-------------
|
||||
2 files changed, 66 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/man/less-variables.xml b/man/less-variables.xml
|
||||
index c52511c..049e9f7 100644
|
||||
--- a/man/less-variables.xml
|
||||
+++ b/man/less-variables.xml
|
||||
@@ -65,12 +65,30 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='lesssecure'>
|
||||
- <term><varname>$SYSTEMD_LESSSECURE</varname></term>
|
||||
-
|
||||
- <listitem><para>Takes a boolean argument. Overrides the <varname>$LESSSECURE</varname> environment
|
||||
- variable when invoking the pager, which controls the "secure" mode of less (which disables commands
|
||||
- such as <literal>|</literal> which allow to easily shell out to external command lines). By default
|
||||
- less secure mode is enabled, with this setting it may be disabled.</para></listitem>
|
||||
+ <term><varname>$SYSTEMD_PAGERSECURE</varname></term>
|
||||
+
|
||||
+ <listitem><para>Takes a boolean argument. When true, the "secure" mode of the pager is enabled; if
|
||||
+ false, disabled. If <varname>$SYSTEMD_PAGERSECURE</varname> is not set at all, secure mode is enabled
|
||||
+ if the effective UID is not the same as the owner of the login session, see <citerefentry
|
||||
+ project='man-pages'><refentrytitle>geteuid</refentrytitle><manvolnum>2</manvolnum></citerefentry> and
|
||||
+ <citerefentry><refentrytitle>sd_pid_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
|
||||
+ In secure mode, <option>LESSSECURE=1</option> will be set when invoking the pager, and the pager shall
|
||||
+ disable commands that open or create new files or start new subprocesses. When
|
||||
+ <varname>$SYSTEMD_PAGERSECURE</varname> is not set at all, pagers which are not known to implement
|
||||
+ secure mode will not be used. (Currently only
|
||||
+ <citerefentry><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry> implements
|
||||
+ secure mode.)</para>
|
||||
+
|
||||
+ <para>Note: when commands are invoked with elevated privileges, for example under <citerefentry
|
||||
+ project='man-pages'><refentrytitle>sudo</refentrytitle><manvolnum>8</manvolnum></citerefentry> or
|
||||
+ <citerefentry
|
||||
+ project='die-net'><refentrytitle>pkexec</refentrytitle><manvolnum>1</manvolnum></citerefentry>, care
|
||||
+ must be taken to ensure that unintended interactive features are not enabled. "Secure" mode for the
|
||||
+ pager may be enabled automatically as describe above. Setting <varname>SYSTEMD_PAGERSECURE=0</varname>
|
||||
+ or not removing it from the inherited environment allows the user to invoke arbitrary commands. Note
|
||||
+ that if the <varname>$SYSTEMD_PAGER</varname> or <varname>$PAGER</varname> variables are to be
|
||||
+ honoured, <varname>$SYSTEMD_PAGERSECURE</varname> must be set too. It might be reasonable to completly
|
||||
+ disable the pager using <option>--no-pager</option> instead.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='colors'>
|
||||
diff --git a/src/shared/pager.c b/src/shared/pager.c
|
||||
index a3b6576..a72d9ea 100644
|
||||
--- a/src/shared/pager.c
|
||||
+++ b/src/shared/pager.c
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <sys/prctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
+#include "sd-login.h"
|
||||
+
|
||||
#include "copy.h"
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
@@ -164,25 +166,42 @@ int pager_open(PagerFlags flags) {
|
||||
}
|
||||
|
||||
/* People might invoke us from sudo, don't needlessly allow less to be a way to shell out
|
||||
- * privileged stuff. */
|
||||
- r = getenv_bool("SYSTEMD_LESSSECURE");
|
||||
- if (r == 0) { /* Remove env var if off */
|
||||
- if (unsetenv("LESSSECURE") < 0) {
|
||||
- log_error_errno(errno, "Failed to uset environment variable LESSSECURE: %m");
|
||||
- _exit(EXIT_FAILURE);
|
||||
- }
|
||||
- } else {
|
||||
- /* Set env var otherwise */
|
||||
+ * privileged stuff. If the user set $SYSTEMD_PAGERSECURE, trust their configuration of the
|
||||
+ * pager. If they didn't, use secure mode when under euid is changed. If $SYSTEMD_PAGERSECURE
|
||||
+ * wasn't explicitly set, and we autodetect the need for secure mode, only use the pager we
|
||||
+ * know to be good. */
|
||||
+ int use_secure_mode = getenv_bool("SYSTEMD_PAGERSECURE");
|
||||
+ bool trust_pager = use_secure_mode >= 0;
|
||||
+ if (use_secure_mode == -ENXIO) {
|
||||
+ uid_t uid;
|
||||
+
|
||||
+ r = sd_pid_get_owner_uid(0, &uid);
|
||||
if (r < 0)
|
||||
- log_warning_errno(r, "Unable to parse $SYSTEMD_LESSSECURE, ignoring: %m");
|
||||
+ log_debug_errno(r, "sd_pid_get_owner_uid() failed, enabling pager secure mode: %m");
|
||||
|
||||
- if (setenv("LESSSECURE", "1", 1) < 0) {
|
||||
- log_error_errno(errno, "Failed to set environment variable LESSSECURE: %m");
|
||||
- _exit(EXIT_FAILURE);
|
||||
- }
|
||||
+ use_secure_mode = r < 0 || uid != geteuid();
|
||||
+
|
||||
+ } else if (use_secure_mode < 0) {
|
||||
+ log_warning_errno(use_secure_mode, "Unable to parse $SYSTEMD_PAGERSECURE, assuming true: %m");
|
||||
+ use_secure_mode = true;
|
||||
}
|
||||
|
||||
- if (pager_args) {
|
||||
+ /* We generally always set variables used by less, even if we end up using a different pager.
|
||||
+ * They shouldn't hurt in any case, and ideally other pagers would look at them too. */
|
||||
+ if (use_secure_mode)
|
||||
+ r = setenv("LESSSECURE", "1", 1);
|
||||
+ else
|
||||
+ r = unsetenv("LESSSECURE");
|
||||
+ if (r < 0) {
|
||||
+ log_error_errno(errno, "Failed to adjust environment variable LESSSECURE: %m");
|
||||
+ _exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ if (trust_pager && pager_args) { /* The pager config might be set globally, and we cannot
|
||||
+ * know if the user adjusted it to be appropriate for the
|
||||
+ * secure mode. Thus, start the pager specified through
|
||||
+ * envvars only when $SYSTEMD_PAGERSECURE was explicitly set
|
||||
+ * as well. */
|
||||
r = loop_write(exe_name_pipe[1], pager_args[0], strlen(pager_args[0]) + 1, false);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to write pager name to socket: %m");
|
||||
@@ -194,13 +213,14 @@ int pager_open(PagerFlags flags) {
|
||||
"Failed to execute '%s', using fallback pagers: %m", pager_args[0]);
|
||||
}
|
||||
|
||||
- /* Debian's alternatives command for pagers is
|
||||
- * called 'pager'. Note that we do not call
|
||||
- * sensible-pagers here, since that is just a
|
||||
- * shell script that implements a logic that
|
||||
- * is similar to this one anyway, but is
|
||||
- * Debian-specific. */
|
||||
+ /* Debian's alternatives command for pagers is called 'pager'. Note that we do not call
|
||||
+ * sensible-pagers here, since that is just a shell script that implements a logic that is
|
||||
+ * similar to this one anyway, but is Debian-specific. */
|
||||
FOREACH_STRING(exe, "pager", "less", "more") {
|
||||
+ /* Only less implements secure mode right now. */
|
||||
+ if (use_secure_mode && !streq(exe, "less"))
|
||||
+ continue;
|
||||
+
|
||||
r = loop_write(exe_name_pipe[1], exe, strlen(exe) + 1, false);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to write pager name to socket: %m");
|
||||
@@ -211,6 +231,7 @@ int pager_open(PagerFlags flags) {
|
||||
"Failed to execute '%s', using next fallback pager: %m", exe);
|
||||
}
|
||||
|
||||
+ /* Our builtin is also very secure. */
|
||||
r = loop_write(exe_name_pipe[1], "(built-in)", strlen("(built-in)") + 1, false);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to write pager name to socket: %m");
|
||||
32
meta/recipes-core/systemd/systemd/CVE-2023-26604-4.patch
Normal file
32
meta/recipes-core/systemd/systemd/CVE-2023-26604-4.patch
Normal file
@@ -0,0 +1,32 @@
|
||||
From b8f736b30e20a2b44e7c34bb4e43b0d97ae77e3c Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Thu, 15 Oct 2020 10:54:48 +0200
|
||||
Subject: [PATCH] pager: lets check SYSTEMD_PAGERSECURE with secure_getenv()
|
||||
|
||||
I can't think of any real vulnerability about this, but it still feels
|
||||
better to check a variable with "secure" in its name with
|
||||
secure_getenv() rather than plain getenv().
|
||||
|
||||
Paranoia FTW!
|
||||
|
||||
CVE: CVE-2023-26604
|
||||
Upstream-Status: Backport [https://github.com/systemd/systemd/pull/17359/commits/b8f736b30e20a2b44e7c34bb4e43b0d97ae77e3c]
|
||||
Comments: Hunk refreshed
|
||||
Signed-off-by: rajmohan r <rajmohan.r@kpit.com>
|
||||
---
|
||||
src/shared/pager.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/shared/pager.c b/src/shared/pager.c
|
||||
index a72d9ea..250519c 100644
|
||||
--- a/src/shared/pager.c
|
||||
+++ b/src/shared/pager.c
|
||||
@@ -170,7 +170,7 @@ int pager_open(PagerFlags flags) {
|
||||
* pager. If they didn't, use secure mode when under euid is changed. If $SYSTEMD_PAGERSECURE
|
||||
* wasn't explicitly set, and we autodetect the need for secure mode, only use the pager we
|
||||
* know to be good. */
|
||||
- int use_secure_mode = getenv_bool("SYSTEMD_PAGERSECURE");
|
||||
+ int use_secure_mode = getenv_bool_secure("SYSTEMD_PAGERSECURE");
|
||||
bool trust_pager = use_secure_mode >= 0;
|
||||
if (use_secure_mode == -ENXIO) {
|
||||
uid_t uid;
|
||||
7
meta/recipes-core/systemd/systemd/systemd-pager.sh
Normal file
7
meta/recipes-core/systemd/systemd/systemd-pager.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
# Systemd expect a color capable pager, however the less provided
|
||||
# by busybox is not. This make many interaction with systemd pretty
|
||||
# annoying. As a workaround we disable the systemd pager if less
|
||||
# is not the GNU version.
|
||||
if ! less -V > /dev/null 2>&1 ; then
|
||||
export SYSTEMD_PAGER=
|
||||
fi
|
||||
@@ -18,6 +18,7 @@ SRC_URI += "file://touchscreen.rules \
|
||||
file://00-create-volatile.conf \
|
||||
file://init \
|
||||
file://99-default.preset \
|
||||
file://systemd-pager.sh \
|
||||
file://0001-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
|
||||
file://0003-implment-systemd-sysv-install-for-OE.patch \
|
||||
file://CVE-2021-33910.patch \
|
||||
@@ -34,6 +35,10 @@ SRC_URI += "file://touchscreen.rules \
|
||||
file://CVE-2021-3997-2.patch \
|
||||
file://CVE-2021-3997-3.patch \
|
||||
file://CVE-2022-3821.patch \
|
||||
file://CVE-2023-26604-1.patch \
|
||||
file://CVE-2023-26604-2.patch \
|
||||
file://CVE-2023-26604-3.patch \
|
||||
file://CVE-2023-26604-4.patch \
|
||||
"
|
||||
|
||||
# patches needed by musl
|
||||
@@ -214,7 +219,7 @@ rootlibexecdir = "${rootprefix}/lib"
|
||||
EXTRA_OEMESON += "-Dlink-udev-shared=false"
|
||||
|
||||
EXTRA_OEMESON += "-Dnobody-user=nobody \
|
||||
-Dnobody-group=nobody \
|
||||
-Dnobody-group=nogroup \
|
||||
-Drootlibdir=${rootlibdir} \
|
||||
-Drootprefix=${rootprefix} \
|
||||
-Ddefault-locale=C \
|
||||
@@ -317,6 +322,9 @@ do_install() {
|
||||
# install default policy for presets
|
||||
# https://www.freedesktop.org/wiki/Software/systemd/Preset/#howto
|
||||
install -Dm 0644 ${WORKDIR}/99-default.preset ${D}${systemd_unitdir}/system-preset/99-default.preset
|
||||
|
||||
# add a profile fragment to disable systemd pager with busybox less
|
||||
install -Dm 0644 ${WORKDIR}/systemd-pager.sh ${D}${sysconfdir}/profile.d/systemd-pager.sh
|
||||
}
|
||||
|
||||
python populate_packages_prepend (){
|
||||
@@ -539,6 +547,7 @@ FILES_${PN} = " ${base_bindir}/* \
|
||||
${sysconfdir}/dbus-1/ \
|
||||
${sysconfdir}/modules-load.d/ \
|
||||
${sysconfdir}/pam.d/ \
|
||||
${sysconfdir}/profile.d/ \
|
||||
${sysconfdir}/sysctl.d/ \
|
||||
${sysconfdir}/systemd/ \
|
||||
${sysconfdir}/tmpfiles.d/ \
|
||||
|
||||
@@ -69,6 +69,7 @@ SRC_URI = "\
|
||||
file://0037-CVE-2019-14250-Check-zero-value-in-simple_object_elf.patch \
|
||||
file://0038-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \
|
||||
file://0039-process_alt_operands-Don-t-match-user-defined-regs-o.patch \
|
||||
file://0002-libstdc-Fix-inconsistent-noexcept-specific-for-valar.patch \
|
||||
"
|
||||
S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}"
|
||||
SRC_URI[sha256sum] = "27769f64ef1d4cd5e2be8682c0c93f9887983e6cfd1a927ce5a0a2915a95cf8f"
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
From 60d966708d7cf105dccf128d2b7a38b0b2580a1a Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Wakely <jwakely@redhat.com>
|
||||
Date: Fri, 5 Nov 2021 21:42:20 +0000
|
||||
Subject: [PATCH] libstdc++: Fix inconsistent noexcept-specific for valarray
|
||||
begin/end
|
||||
|
||||
These declarations should be noexcept after I added it to the
|
||||
definitions in <valarray>.
|
||||
|
||||
libstdc++-v3/ChangeLog:
|
||||
|
||||
* include/bits/range_access.h (begin(valarray), end(valarray)):
|
||||
Add noexcept.
|
||||
|
||||
(cherry picked from commit 2b2d97fc545635a0f6aa9c9ee3b017394bc494bf)
|
||||
|
||||
Upstream-Status: Backport [https://github.com/hkaelber/gcc/commit/2b2d97fc545635a0f6aa9c9ee3b017394bc494bf]
|
||||
Signed-off-by: Virendra Thakur <virendrak@kpit.com>
|
||||
|
||||
---
|
||||
libstdc++-v3/include/bits/range_access.h | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h
|
||||
index 3d99ea92027..4736e75fda1 100644
|
||||
--- a/libstdc++-v3/include/bits/range_access.h
|
||||
+++ b/libstdc++-v3/include/bits/range_access.h
|
||||
@@ -101,10 +101,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
template<typename _Tp> class valarray;
|
||||
// These overloads must be declared for cbegin and cend to use them.
|
||||
- template<typename _Tp> _Tp* begin(valarray<_Tp>&);
|
||||
- template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
|
||||
- template<typename _Tp> _Tp* end(valarray<_Tp>&);
|
||||
- template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
|
||||
+ template<typename _Tp> _Tp* begin(valarray<_Tp>&) noexcept;
|
||||
+ template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
|
||||
+ template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
|
||||
+ template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Return an iterator pointing to the first element of
|
||||
--
|
||||
2.25.1
|
||||
367
meta/recipes-devtools/git/files/CVE-2022-23521.patch
Normal file
367
meta/recipes-devtools/git/files/CVE-2022-23521.patch
Normal file
@@ -0,0 +1,367 @@
|
||||
From eb22e7dfa23da6bd9aed9bd1dad69e1e8e167d24 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:45:15 +0100
|
||||
Subject: [PATCH] CVE-2022-23521
|
||||
|
||||
attr: fix overflow when upserting attribute with overly long name
|
||||
|
||||
The function `git_attr_internal()` is called to upsert attributes into
|
||||
the global map. And while all callers pass a `size_t`, the function
|
||||
itself accepts an `int` as the attribute name's length. This can lead to
|
||||
an integer overflow in case the attribute name is longer than `INT_MAX`.
|
||||
|
||||
Now this overflow seems harmless as the first thing we do is to call
|
||||
`attr_name_valid()`, and that function only succeeds in case all chars
|
||||
in the range of `namelen` match a certain small set of chars. We thus
|
||||
can't do an out-of-bounds read as NUL is not part of that set and all
|
||||
strings passed to this function are NUL-terminated. And furthermore, we
|
||||
wouldn't ever read past the current attribute name anyway due to the
|
||||
same reason. And if validation fails we will return early.
|
||||
|
||||
On the other hand it feels fragile to rely on this behaviour, even more
|
||||
so given that we pass `namelen` to `FLEX_ALLOC_MEM()`. So let's instead
|
||||
just do the correct thing here and accept a `size_t` as line length.
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/eb22e7dfa23da6bd9aed9bd1dad69e1e8e167d24 &https://github.com/git/git/commit/8d0d48cf2157cfb914db1f53b3fe40785b86f3aa & https://github.com/git/git/commit/24557209500e6ed618f04a8795a111a0c491a29c & https://github.com/git/git/commit/34ace8bad02bb14ecc5b631f7e3daaa7a9bba7d9 & https://github.com/git/git/commit/447ac906e189535e77dcb1f4bbe3f1bc917d4c12 & https://github.com/git/git/commit/e1e12e97ac73ded85f7d000da1063a774b3cc14f & https://github.com/git/git/commit/a60a66e409c265b2944f18bf43581c146812586d & https://github.com/git/git/commit/d74b1fd54fdbc45966d12ea907dece11e072fb2b & https://github.com/git/git/commit/dfa6b32b5e599d97448337ed4fc18dd50c90758f & https://github.com/git/git/commit/3c50032ff5289cc45659f21949c8d09e52164579
|
||||
|
||||
CVE: CVE-2022-23521
|
||||
|
||||
Reviewed-by: Sylvain Beucler <beuc@debian.org>
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
|
||||
---
|
||||
attr.c | 97 +++++++++++++++++++++++++++----------------
|
||||
attr.h | 12 ++++++
|
||||
t/t0003-attributes.sh | 59 ++++++++++++++++++++++++++
|
||||
3 files changed, 132 insertions(+), 36 deletions(-)
|
||||
|
||||
diff --git a/attr.c b/attr.c
|
||||
index 11f19b5..63484ab 100644
|
||||
--- a/attr.c
|
||||
+++ b/attr.c
|
||||
@@ -29,7 +29,7 @@ static const char git_attr__unknown[] = "(builtin)unknown";
|
||||
#endif
|
||||
|
||||
struct git_attr {
|
||||
- int attr_nr; /* unique attribute number */
|
||||
+ unsigned int attr_nr; /* unique attribute number */
|
||||
char name[FLEX_ARRAY]; /* attribute name */
|
||||
};
|
||||
|
||||
@@ -221,7 +221,7 @@ static void report_invalid_attr(const char *name, size_t len,
|
||||
* dictionary. If no entry is found, create a new attribute and store it in
|
||||
* the dictionary.
|
||||
*/
|
||||
-static const struct git_attr *git_attr_internal(const char *name, int namelen)
|
||||
+static const struct git_attr *git_attr_internal(const char *name, size_t namelen)
|
||||
{
|
||||
struct git_attr *a;
|
||||
|
||||
@@ -237,8 +237,8 @@ static const struct git_attr *git_attr_internal(const char *name, int namelen)
|
||||
a->attr_nr = hashmap_get_size(&g_attr_hashmap.map);
|
||||
|
||||
attr_hashmap_add(&g_attr_hashmap, a->name, namelen, a);
|
||||
- assert(a->attr_nr ==
|
||||
- (hashmap_get_size(&g_attr_hashmap.map) - 1));
|
||||
+ if (a->attr_nr != hashmap_get_size(&g_attr_hashmap.map) - 1)
|
||||
+ die(_("unable to add additional attribute"));
|
||||
}
|
||||
|
||||
hashmap_unlock(&g_attr_hashmap);
|
||||
@@ -283,7 +283,7 @@ struct match_attr {
|
||||
const struct git_attr *attr;
|
||||
} u;
|
||||
char is_macro;
|
||||
- unsigned num_attr;
|
||||
+ size_t num_attr;
|
||||
struct attr_state state[FLEX_ARRAY];
|
||||
};
|
||||
|
||||
@@ -300,7 +300,7 @@ static const char *parse_attr(const char *src, int lineno, const char *cp,
|
||||
struct attr_state *e)
|
||||
{
|
||||
const char *ep, *equals;
|
||||
- int len;
|
||||
+ size_t len;
|
||||
|
||||
ep = cp + strcspn(cp, blank);
|
||||
equals = strchr(cp, '=');
|
||||
@@ -344,8 +344,7 @@ static const char *parse_attr(const char *src, int lineno, const char *cp,
|
||||
static struct match_attr *parse_attr_line(const char *line, const char *src,
|
||||
int lineno, int macro_ok)
|
||||
{
|
||||
- int namelen;
|
||||
- int num_attr, i;
|
||||
+ size_t namelen, num_attr, i;
|
||||
const char *cp, *name, *states;
|
||||
struct match_attr *res = NULL;
|
||||
int is_macro;
|
||||
@@ -356,6 +355,11 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
|
||||
return NULL;
|
||||
name = cp;
|
||||
|
||||
+ if (strlen(line) >= ATTR_MAX_LINE_LENGTH) {
|
||||
+ warning(_("ignoring overly long attributes line %d"), lineno);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
if (*cp == '"' && !unquote_c_style(&pattern, name, &states)) {
|
||||
name = pattern.buf;
|
||||
namelen = pattern.len;
|
||||
@@ -392,10 +396,9 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
|
||||
goto fail_return;
|
||||
}
|
||||
|
||||
- res = xcalloc(1,
|
||||
- sizeof(*res) +
|
||||
- sizeof(struct attr_state) * num_attr +
|
||||
- (is_macro ? 0 : namelen + 1));
|
||||
+ res = xcalloc(1, st_add3(sizeof(*res),
|
||||
+ st_mult(sizeof(struct attr_state), num_attr),
|
||||
+ is_macro ? 0 : namelen + 1));
|
||||
if (is_macro) {
|
||||
res->u.attr = git_attr_internal(name, namelen);
|
||||
} else {
|
||||
@@ -458,11 +461,12 @@ struct attr_stack {
|
||||
|
||||
static void attr_stack_free(struct attr_stack *e)
|
||||
{
|
||||
- int i;
|
||||
+ unsigned i;
|
||||
free(e->origin);
|
||||
for (i = 0; i < e->num_matches; i++) {
|
||||
struct match_attr *a = e->attrs[i];
|
||||
- int j;
|
||||
+ size_t j;
|
||||
+
|
||||
for (j = 0; j < a->num_attr; j++) {
|
||||
const char *setto = a->state[j].setto;
|
||||
if (setto == ATTR__TRUE ||
|
||||
@@ -671,8 +675,8 @@ static void handle_attr_line(struct attr_stack *res,
|
||||
a = parse_attr_line(line, src, lineno, macro_ok);
|
||||
if (!a)
|
||||
return;
|
||||
- ALLOC_GROW(res->attrs, res->num_matches + 1, res->alloc);
|
||||
- res->attrs[res->num_matches++] = a;
|
||||
+ ALLOC_GROW_BY(res->attrs, res->num_matches, 1, res->alloc);
|
||||
+ res->attrs[res->num_matches - 1] = a;
|
||||
}
|
||||
|
||||
static struct attr_stack *read_attr_from_array(const char **list)
|
||||
@@ -711,21 +715,37 @@ void git_attr_set_direction(enum git_attr_direction new_direction)
|
||||
|
||||
static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
|
||||
{
|
||||
+ struct strbuf buf = STRBUF_INIT;
|
||||
FILE *fp = fopen_or_warn(path, "r");
|
||||
struct attr_stack *res;
|
||||
- char buf[2048];
|
||||
int lineno = 0;
|
||||
+ int fd;
|
||||
+ struct stat st;
|
||||
|
||||
if (!fp)
|
||||
return NULL;
|
||||
- res = xcalloc(1, sizeof(*res));
|
||||
- while (fgets(buf, sizeof(buf), fp)) {
|
||||
- char *bufp = buf;
|
||||
- if (!lineno)
|
||||
- skip_utf8_bom(&bufp, strlen(bufp));
|
||||
- handle_attr_line(res, bufp, path, ++lineno, macro_ok);
|
||||
+
|
||||
+ fd = fileno(fp);
|
||||
+ if (fstat(fd, &st)) {
|
||||
+ warning_errno(_("cannot fstat gitattributes file '%s'"), path);
|
||||
+ fclose(fp);
|
||||
+ return NULL;
|
||||
}
|
||||
+ if (st.st_size >= ATTR_MAX_FILE_SIZE) {
|
||||
+ warning(_("ignoring overly large gitattributes file '%s'"), path);
|
||||
+ fclose(fp);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ CALLOC_ARRAY(res, 1);
|
||||
+ while (strbuf_getline(&buf, fp) != EOF) {
|
||||
+ if (!lineno && starts_with(buf.buf, utf8_bom))
|
||||
+ strbuf_remove(&buf, 0, strlen(utf8_bom));
|
||||
+ handle_attr_line(res, buf.buf, path, ++lineno, macro_ok);
|
||||
+ }
|
||||
+
|
||||
fclose(fp);
|
||||
+ strbuf_release(&buf);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -736,13 +756,18 @@ static struct attr_stack *read_attr_from_index(const struct index_state *istate,
|
||||
struct attr_stack *res;
|
||||
char *buf, *sp;
|
||||
int lineno = 0;
|
||||
+ size_t size;
|
||||
|
||||
if (!istate)
|
||||
return NULL;
|
||||
|
||||
- buf = read_blob_data_from_index(istate, path, NULL);
|
||||
+ buf = read_blob_data_from_index(istate, path, &size);
|
||||
if (!buf)
|
||||
return NULL;
|
||||
+ if (size >= ATTR_MAX_FILE_SIZE) {
|
||||
+ warning(_("ignoring overly large gitattributes blob '%s'"), path);
|
||||
+ return NULL;
|
||||
+ }
|
||||
|
||||
res = xcalloc(1, sizeof(*res));
|
||||
for (sp = buf; *sp; ) {
|
||||
@@ -1012,12 +1037,12 @@ static int macroexpand_one(struct all_attrs_item *all_attrs, int nr, int rem);
|
||||
static int fill_one(const char *what, struct all_attrs_item *all_attrs,
|
||||
const struct match_attr *a, int rem)
|
||||
{
|
||||
- int i;
|
||||
+ size_t i;
|
||||
|
||||
- for (i = a->num_attr - 1; rem > 0 && i >= 0; i--) {
|
||||
- const struct git_attr *attr = a->state[i].attr;
|
||||
+ for (i = a->num_attr; rem > 0 && i > 0; i--) {
|
||||
+ const struct git_attr *attr = a->state[i - 1].attr;
|
||||
const char **n = &(all_attrs[attr->attr_nr].value);
|
||||
- const char *v = a->state[i].setto;
|
||||
+ const char *v = a->state[i - 1].setto;
|
||||
|
||||
if (*n == ATTR__UNKNOWN) {
|
||||
debug_set(what,
|
||||
@@ -1036,11 +1061,11 @@ static int fill(const char *path, int pathlen, int basename_offset,
|
||||
struct all_attrs_item *all_attrs, int rem)
|
||||
{
|
||||
for (; rem > 0 && stack; stack = stack->prev) {
|
||||
- int i;
|
||||
+ unsigned i;
|
||||
const char *base = stack->origin ? stack->origin : "";
|
||||
|
||||
- for (i = stack->num_matches - 1; 0 < rem && 0 <= i; i--) {
|
||||
- const struct match_attr *a = stack->attrs[i];
|
||||
+ for (i = stack->num_matches; 0 < rem && 0 < i; i--) {
|
||||
+ const struct match_attr *a = stack->attrs[i - 1];
|
||||
if (a->is_macro)
|
||||
continue;
|
||||
if (path_matches(path, pathlen, basename_offset,
|
||||
@@ -1071,11 +1096,11 @@ static void determine_macros(struct all_attrs_item *all_attrs,
|
||||
const struct attr_stack *stack)
|
||||
{
|
||||
for (; stack; stack = stack->prev) {
|
||||
- int i;
|
||||
- for (i = stack->num_matches - 1; i >= 0; i--) {
|
||||
- const struct match_attr *ma = stack->attrs[i];
|
||||
+ unsigned i;
|
||||
+ for (i = stack->num_matches; i > 0; i--) {
|
||||
+ const struct match_attr *ma = stack->attrs[i - 1];
|
||||
if (ma->is_macro) {
|
||||
- int n = ma->u.attr->attr_nr;
|
||||
+ unsigned int n = ma->u.attr->attr_nr;
|
||||
if (!all_attrs[n].macro) {
|
||||
all_attrs[n].macro = ma;
|
||||
}
|
||||
@@ -1127,7 +1152,7 @@ void git_check_attr(const struct index_state *istate,
|
||||
collect_some_attrs(istate, path, check);
|
||||
|
||||
for (i = 0; i < check->nr; i++) {
|
||||
- size_t n = check->items[i].attr->attr_nr;
|
||||
+ unsigned int n = check->items[i].attr->attr_nr;
|
||||
const char *value = check->all_attrs[n].value;
|
||||
if (value == ATTR__UNKNOWN)
|
||||
value = ATTR__UNSET;
|
||||
diff --git a/attr.h b/attr.h
|
||||
index b0378bf..f424285 100644
|
||||
--- a/attr.h
|
||||
+++ b/attr.h
|
||||
@@ -1,6 +1,18 @@
|
||||
#ifndef ATTR_H
|
||||
#define ATTR_H
|
||||
|
||||
+/**
|
||||
+ * The maximum line length for a gitattributes file. If the line exceeds this
|
||||
+ * length we will ignore it.
|
||||
+ */
|
||||
+#define ATTR_MAX_LINE_LENGTH 2048
|
||||
+
|
||||
+ /**
|
||||
+ * The maximum size of the giattributes file. If the file exceeds this size we
|
||||
+ * will ignore it.
|
||||
+ */
|
||||
+#define ATTR_MAX_FILE_SIZE (100 * 1024 * 1024)
|
||||
+
|
||||
struct index_state;
|
||||
|
||||
/* An attribute is a pointer to this opaque structure */
|
||||
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
|
||||
index 71e63d8..556245b 100755
|
||||
--- a/t/t0003-attributes.sh
|
||||
+++ b/t/t0003-attributes.sh
|
||||
@@ -342,4 +342,63 @@ test_expect_success 'query binary macro directly' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
+test_expect_success 'large attributes line ignored in tree' '
|
||||
+ test_when_finished "rm .gitattributes" &&
|
||||
+ printf "path %02043d" 1 >.gitattributes &&
|
||||
+ git check-attr --all path >actual 2>err &&
|
||||
+ echo "warning: ignoring overly long attributes line 1" >expect &&
|
||||
+ test_cmp expect err &&
|
||||
+ test_must_be_empty actual
|
||||
+'
|
||||
+
|
||||
+test_expect_success 'large attributes line ignores trailing content in tree' '
|
||||
+ test_when_finished "rm .gitattributes" &&
|
||||
+ # older versions of Git broke lines at 2048 bytes; the 2045 bytes
|
||||
+ # of 0-padding here is accounting for the three bytes of "a 1", which
|
||||
+ # would knock "trailing" to the "next" line, where it would be
|
||||
+ # erroneously parsed.
|
||||
+ printf "a %02045dtrailing attribute\n" 1 >.gitattributes &&
|
||||
+ git check-attr --all trailing >actual 2>err &&
|
||||
+ echo "warning: ignoring overly long attributes line 1" >expect &&
|
||||
+ test_cmp expect err &&
|
||||
+ test_must_be_empty actual
|
||||
+'
|
||||
+
|
||||
+test_expect_success EXPENSIVE 'large attributes file ignored in tree' '
|
||||
+ test_when_finished "rm .gitattributes" &&
|
||||
+ dd if=/dev/zero of=.gitattributes bs=101M count=1 2>/dev/null &&
|
||||
+ git check-attr --all path >/dev/null 2>err &&
|
||||
+ echo "warning: ignoring overly large gitattributes file ${SQ}.gitattributes${SQ}" >expect &&
|
||||
+ test_cmp expect err
|
||||
+'
|
||||
+
|
||||
+test_expect_success 'large attributes line ignored in index' '
|
||||
+ test_when_finished "git update-index --remove .gitattributes" &&
|
||||
+ blob=$(printf "path %02043d" 1 | git hash-object -w --stdin) &&
|
||||
+ git update-index --add --cacheinfo 100644,$blob,.gitattributes &&
|
||||
+ git check-attr --cached --all path >actual 2>err &&
|
||||
+ echo "warning: ignoring overly long attributes line 1" >expect &&
|
||||
+ test_cmp expect err &&
|
||||
+ test_must_be_empty actual
|
||||
+'
|
||||
+
|
||||
+test_expect_success 'large attributes line ignores trailing content in index' '
|
||||
+ test_when_finished "git update-index --remove .gitattributes" &&
|
||||
+ blob=$(printf "a %02045dtrailing attribute\n" 1 | git hash-object -w --stdin) &&
|
||||
+ git update-index --add --cacheinfo 100644,$blob,.gitattributes &&
|
||||
+ git check-attr --cached --all trailing >actual 2>err &&
|
||||
+ echo "warning: ignoring overly long attributes line 1" >expect &&
|
||||
+ test_cmp expect err &&
|
||||
+ test_must_be_empty actual
|
||||
+'
|
||||
+
|
||||
+test_expect_success EXPENSIVE 'large attributes file ignored in index' '
|
||||
+ test_when_finished "git update-index --remove .gitattributes" &&
|
||||
+ blob=$(dd if=/dev/zero bs=101M count=1 2>/dev/null | git hash-object -w --stdin) &&
|
||||
+ git update-index --add --cacheinfo 100644,$blob,.gitattributes &&
|
||||
+ git check-attr --cached --all path >/dev/null 2>err &&
|
||||
+ echo "warning: ignoring overly large gitattributes blob ${SQ}.gitattributes${SQ}" >expect &&
|
||||
+ test_cmp expect err
|
||||
+'
|
||||
+
|
||||
test_done
|
||||
--
|
||||
2.25.1
|
||||
|
||||
39
meta/recipes-devtools/git/files/CVE-2022-41903-01.patch
Normal file
39
meta/recipes-devtools/git/files/CVE-2022-41903-01.patch
Normal file
@@ -0,0 +1,39 @@
|
||||
From a244dc5b0a629290881641467c7a545de7508ab2 Mon Sep 17 00:00:00 2001
|
||||
From: Carlo Marcelo Arenas Belón <carenas@gmail.com>
|
||||
Date: Tue, 2 Nov 2021 15:46:06 +0000
|
||||
Subject: [PATCH 01/12] test-lib: add prerequisite for 64-bit platforms
|
||||
|
||||
Allow tests that assume a 64-bit `size_t` to be skipped in 32-bit
|
||||
platforms and regardless of the size of `long`.
|
||||
|
||||
This imitates the `LONG_IS_64BIT` prerequisite.
|
||||
|
||||
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
|
||||
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/a244dc5b0a629290881641467c7a545de7508ab2]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
t/test-lib.sh | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/t/test-lib.sh b/t/test-lib.sh
|
||||
index e06fa02..db5ec2f 100644
|
||||
--- a/t/test-lib.sh
|
||||
+++ b/t/test-lib.sh
|
||||
@@ -1613,6 +1613,10 @@ build_option () {
|
||||
sed -ne "s/^$1: //p"
|
||||
}
|
||||
|
||||
+test_lazy_prereq SIZE_T_IS_64BIT '
|
||||
+ test 8 -eq "$(build_option sizeof-size_t)"
|
||||
+'
|
||||
+
|
||||
test_lazy_prereq LONG_IS_64BIT '
|
||||
test 8 -le "$(build_option sizeof-long)"
|
||||
'
|
||||
--
|
||||
2.25.1
|
||||
|
||||
187
meta/recipes-devtools/git/files/CVE-2022-41903-02.patch
Normal file
187
meta/recipes-devtools/git/files/CVE-2022-41903-02.patch
Normal file
@@ -0,0 +1,187 @@
|
||||
From 81dc898df9b4b4035534a927f3234a3839b698bf Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:46:25 +0100
|
||||
Subject: [PATCH 02/12] pretty: fix out-of-bounds write caused by integer overflow
|
||||
|
||||
When using a padding specifier in the pretty format passed to git-log(1)
|
||||
we need to calculate the string length in several places. These string
|
||||
lengths are stored in `int`s though, which means that these can easily
|
||||
overflow when the input lengths exceeds 2GB. This can ultimately lead to
|
||||
an out-of-bounds write when these are used in a call to memcpy(3P):
|
||||
|
||||
==8340==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f1ec62f97fe at pc 0x7f2127e5f427 bp 0x7ffd3bd63de0 sp 0x7ffd3bd63588
|
||||
WRITE of size 1 at 0x7f1ec62f97fe thread T0
|
||||
#0 0x7f2127e5f426 in __interceptor_memcpy /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
|
||||
#1 0x5628e96aa605 in format_and_pad_commit pretty.c:1762
|
||||
#2 0x5628e96aa7f4 in format_commit_item pretty.c:1801
|
||||
#3 0x5628e97cdb24 in strbuf_expand strbuf.c:429
|
||||
#4 0x5628e96ab060 in repo_format_commit_message pretty.c:1869
|
||||
#5 0x5628e96acd0f in pretty_print_commit pretty.c:2161
|
||||
#6 0x5628e95a44c8 in show_log log-tree.c:781
|
||||
#7 0x5628e95a76ba in log_tree_commit log-tree.c:1117
|
||||
#8 0x5628e922bed5 in cmd_log_walk_no_free builtin/log.c:508
|
||||
#9 0x5628e922c35b in cmd_log_walk builtin/log.c:549
|
||||
#10 0x5628e922f1a2 in cmd_log builtin/log.c:883
|
||||
#11 0x5628e9106993 in run_builtin git.c:466
|
||||
#12 0x5628e9107397 in handle_builtin git.c:721
|
||||
#13 0x5628e9107b07 in run_argv git.c:788
|
||||
#14 0x5628e91088a7 in cmd_main git.c:923
|
||||
#15 0x5628e939d682 in main common-main.c:57
|
||||
#16 0x7f2127c3c28f (/usr/lib/libc.so.6+0x2328f)
|
||||
#17 0x7f2127c3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
|
||||
#18 0x5628e91020e4 in _start ../sysdeps/x86_64/start.S:115
|
||||
|
||||
0x7f1ec62f97fe is located 2 bytes to the left of 4831838265-byte region [0x7f1ec62f9800,0x7f1fe62f9839)
|
||||
allocated by thread T0 here:
|
||||
#0 0x7f2127ebe7ea in __interceptor_realloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
|
||||
#1 0x5628e98774d4 in xrealloc wrapper.c:136
|
||||
#2 0x5628e97cb01c in strbuf_grow strbuf.c:99
|
||||
#3 0x5628e97ccd42 in strbuf_addchars strbuf.c:327
|
||||
#4 0x5628e96aa55c in format_and_pad_commit pretty.c:1761
|
||||
#5 0x5628e96aa7f4 in format_commit_item pretty.c:1801
|
||||
#6 0x5628e97cdb24 in strbuf_expand strbuf.c:429
|
||||
#7 0x5628e96ab060 in repo_format_commit_message pretty.c:1869
|
||||
#8 0x5628e96acd0f in pretty_print_commit pretty.c:2161
|
||||
#9 0x5628e95a44c8 in show_log log-tree.c:781
|
||||
#10 0x5628e95a76ba in log_tree_commit log-tree.c:1117
|
||||
#11 0x5628e922bed5 in cmd_log_walk_no_free builtin/log.c:508
|
||||
#12 0x5628e922c35b in cmd_log_walk builtin/log.c:549
|
||||
#13 0x5628e922f1a2 in cmd_log builtin/log.c:883
|
||||
#14 0x5628e9106993 in run_builtin git.c:466
|
||||
#15 0x5628e9107397 in handle_builtin git.c:721
|
||||
#16 0x5628e9107b07 in run_argv git.c:788
|
||||
#17 0x5628e91088a7 in cmd_main git.c:923
|
||||
#18 0x5628e939d682 in main common-main.c:57
|
||||
#19 0x7f2127c3c28f (/usr/lib/libc.so.6+0x2328f)
|
||||
#20 0x7f2127c3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
|
||||
#21 0x5628e91020e4 in _start ../sysdeps/x86_64/start.S:115
|
||||
|
||||
SUMMARY: AddressSanitizer: heap-buffer-overflow /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827 in __interceptor_memcpy
|
||||
Shadow bytes around the buggy address:
|
||||
0x0fe458c572a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0fe458c572b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0fe458c572c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0fe458c572d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0fe458c572e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
=>0x0fe458c572f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
|
||||
0x0fe458c57300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
0x0fe458c57310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
0x0fe458c57320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
0x0fe458c57330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
0x0fe458c57340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
Shadow byte legend (one shadow byte represents 8 application bytes):
|
||||
Addressable: 00
|
||||
Partially addressable: 01 02 03 04 05 06 07
|
||||
Heap left redzone: fa
|
||||
Freed heap region: fd
|
||||
Stack left redzone: f1
|
||||
Stack mid redzone: f2
|
||||
Stack right redzone: f3
|
||||
Stack after return: f5
|
||||
Stack use after scope: f8
|
||||
Global redzone: f9
|
||||
Global init order: f6
|
||||
Poisoned by user: f7
|
||||
Container overflow: fc
|
||||
Array cookie: ac
|
||||
Intra object redzone: bb
|
||||
ASan internal: fe
|
||||
Left alloca redzone: ca
|
||||
Right alloca redzone: cb
|
||||
==8340==ABORTING
|
||||
|
||||
The pretty format can also be used in `git archive` operations via the
|
||||
`export-subst` attribute. So this is what in our opinion makes this a
|
||||
critical issue in the context of Git forges which allow to download an
|
||||
archive of user supplied Git repositories.
|
||||
|
||||
Fix this vulnerability by using `size_t` instead of `int` to track the
|
||||
string lengths. Add tests which detect this vulnerability when Git is
|
||||
compiled with the address sanitizer.
|
||||
|
||||
Reported-by: Joern Schneeweisz <jschneeweisz@gitlab.com>
|
||||
Original-patch-by: Joern Schneeweisz <jschneeweisz@gitlab.com>
|
||||
Modified-by: Taylor Blau <me@ttalorr.com>
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/81dc898df9b4b4035534a927f3234a3839b698bf]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
pretty.c | 11 ++++++-----
|
||||
t/t4205-log-pretty-formats.sh | 17 +++++++++++++++++
|
||||
2 files changed, 23 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/pretty.c b/pretty.c
|
||||
index b32f036..637e344 100644
|
||||
--- a/pretty.c
|
||||
+++ b/pretty.c
|
||||
@@ -1427,7 +1427,9 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
|
||||
struct format_commit_context *c)
|
||||
{
|
||||
struct strbuf local_sb = STRBUF_INIT;
|
||||
- int total_consumed = 0, len, padding = c->padding;
|
||||
+ size_t total_consumed = 0;
|
||||
+ int len, padding = c->padding;
|
||||
+
|
||||
if (padding < 0) {
|
||||
const char *start = strrchr(sb->buf, '\n');
|
||||
int occupied;
|
||||
@@ -1439,7 +1441,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
|
||||
}
|
||||
while (1) {
|
||||
int modifier = *placeholder == 'C';
|
||||
- int consumed = format_commit_one(&local_sb, placeholder, c);
|
||||
+ size_t consumed = format_commit_one(&local_sb, placeholder, c);
|
||||
total_consumed += consumed;
|
||||
|
||||
if (!modifier)
|
||||
@@ -1505,7 +1507,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
|
||||
}
|
||||
strbuf_addbuf(sb, &local_sb);
|
||||
} else {
|
||||
- int sb_len = sb->len, offset = 0;
|
||||
+ size_t sb_len = sb->len, offset = 0;
|
||||
if (c->flush_type == flush_left)
|
||||
offset = padding - len;
|
||||
else if (c->flush_type == flush_both)
|
||||
@@ -1528,8 +1530,7 @@ static size_t format_commit_item(struct strbuf *sb, /* in UTF-8 */
|
||||
const char *placeholder,
|
||||
void *context)
|
||||
{
|
||||
- int consumed;
|
||||
- size_t orig_len;
|
||||
+ size_t consumed, orig_len;
|
||||
enum {
|
||||
NO_MAGIC,
|
||||
ADD_LF_BEFORE_NON_EMPTY,
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index f42a69f..a2acee1 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -788,4 +788,21 @@ test_expect_success '%S in git log --format works with other placeholders (part
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
+test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' '
|
||||
+ # We only assert that this command does not crash. This needs to be
|
||||
+ # executed with the address sanitizer to demonstrate failure.
|
||||
+ git log -1 --pretty="format:%>(2147483646)%x41%41%>(2147483646)%x41" >/dev/null
|
||||
+'
|
||||
+
|
||||
+test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'set up huge commit' '
|
||||
+ test-tool genzeros 2147483649 | tr "\000" "1" >expect &&
|
||||
+ huge_commit=$(git commit-tree -F expect HEAD^{tree})
|
||||
+'
|
||||
+
|
||||
+test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' '
|
||||
+ git log -1 --format="%B%<(1)%x30" $huge_commit >actual &&
|
||||
+ echo 0 >>expect &&
|
||||
+ test_cmp expect actual
|
||||
+'
|
||||
+
|
||||
test_done
|
||||
--
|
||||
2.25.1
|
||||
|
||||
146
meta/recipes-devtools/git/files/CVE-2022-41903-03.patch
Normal file
146
meta/recipes-devtools/git/files/CVE-2022-41903-03.patch
Normal file
@@ -0,0 +1,146 @@
|
||||
From b49f309aa16febeddb65e82526640a91bbba3be3 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:46:30 +0100
|
||||
Subject: [PATCH 03/12] pretty: fix out-of-bounds read when left-flushing with stealing
|
||||
|
||||
With the `%>>(<N>)` pretty formatter, you can ask git-log(1) et al to
|
||||
steal spaces. To do so we need to look ahead of the next token to see
|
||||
whether there are spaces there. This loop takes into account ANSI
|
||||
sequences that end with an `m`, and if it finds any it will skip them
|
||||
until it finds the first space. While doing so it does not take into
|
||||
account the buffer's limits though and easily does an out-of-bounds
|
||||
read.
|
||||
|
||||
Add a test that hits this behaviour. While we don't have an easy way to
|
||||
verify this, the test causes the following failure when run with
|
||||
`SANITIZE=address`:
|
||||
|
||||
==37941==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000000baf at pc 0x55ba6f88e0d0 bp 0x7ffc84c50d20 sp 0x7ffc84c50d10
|
||||
READ of size 1 at 0x603000000baf thread T0
|
||||
#0 0x55ba6f88e0cf in format_and_pad_commit pretty.c:1712
|
||||
#1 0x55ba6f88e7b4 in format_commit_item pretty.c:1801
|
||||
#2 0x55ba6f9b1ae4 in strbuf_expand strbuf.c:429
|
||||
#3 0x55ba6f88f020 in repo_format_commit_message pretty.c:1869
|
||||
#4 0x55ba6f890ccf in pretty_print_commit pretty.c:2161
|
||||
#5 0x55ba6f7884c8 in show_log log-tree.c:781
|
||||
#6 0x55ba6f78b6ba in log_tree_commit log-tree.c:1117
|
||||
#7 0x55ba6f40fed5 in cmd_log_walk_no_free builtin/log.c:508
|
||||
#8 0x55ba6f41035b in cmd_log_walk builtin/log.c:549
|
||||
#9 0x55ba6f4131a2 in cmd_log builtin/log.c:883
|
||||
#10 0x55ba6f2ea993 in run_builtin git.c:466
|
||||
#11 0x55ba6f2eb397 in handle_builtin git.c:721
|
||||
#12 0x55ba6f2ebb07 in run_argv git.c:788
|
||||
#13 0x55ba6f2ec8a7 in cmd_main git.c:923
|
||||
#14 0x55ba6f581682 in main common-main.c:57
|
||||
#15 0x7f2d08c3c28f (/usr/lib/libc.so.6+0x2328f)
|
||||
#16 0x7f2d08c3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
|
||||
#17 0x55ba6f2e60e4 in _start ../sysdeps/x86_64/start.S:115
|
||||
|
||||
0x603000000baf is located 1 bytes to the left of 24-byte region [0x603000000bb0,0x603000000bc8)
|
||||
allocated by thread T0 here:
|
||||
#0 0x7f2d08ebe7ea in __interceptor_realloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
|
||||
#1 0x55ba6fa5b494 in xrealloc wrapper.c:136
|
||||
#2 0x55ba6f9aefdc in strbuf_grow strbuf.c:99
|
||||
#3 0x55ba6f9b0a06 in strbuf_add strbuf.c:298
|
||||
#4 0x55ba6f9b1a25 in strbuf_expand strbuf.c:418
|
||||
#5 0x55ba6f88f020 in repo_format_commit_message pretty.c:1869
|
||||
#6 0x55ba6f890ccf in pretty_print_commit pretty.c:2161
|
||||
#7 0x55ba6f7884c8 in show_log log-tree.c:781
|
||||
#8 0x55ba6f78b6ba in log_tree_commit log-tree.c:1117
|
||||
#9 0x55ba6f40fed5 in cmd_log_walk_no_free builtin/log.c:508
|
||||
#10 0x55ba6f41035b in cmd_log_walk builtin/log.c:549
|
||||
#11 0x55ba6f4131a2 in cmd_log builtin/log.c:883
|
||||
#12 0x55ba6f2ea993 in run_builtin git.c:466
|
||||
#13 0x55ba6f2eb397 in handle_builtin git.c:721
|
||||
#14 0x55ba6f2ebb07 in run_argv git.c:788
|
||||
#15 0x55ba6f2ec8a7 in cmd_main git.c:923
|
||||
#16 0x55ba6f581682 in main common-main.c:57
|
||||
#17 0x7f2d08c3c28f (/usr/lib/libc.so.6+0x2328f)
|
||||
#18 0x7f2d08c3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
|
||||
#19 0x55ba6f2e60e4 in _start ../sysdeps/x86_64/start.S:115
|
||||
|
||||
SUMMARY: AddressSanitizer: heap-buffer-overflow pretty.c:1712 in format_and_pad_commit
|
||||
Shadow bytes around the buggy address:
|
||||
0x0c067fff8120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
|
||||
0x0c067fff8130: fd fd fa fa fd fd fd fd fa fa fd fd fd fa fa fa
|
||||
0x0c067fff8140: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
|
||||
0x0c067fff8150: fa fa fd fd fd fd fa fa 00 00 00 fa fa fa fd fd
|
||||
0x0c067fff8160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
|
||||
=>0x0c067fff8170: fd fd fd fa fa[fa]00 00 00 fa fa fa 00 00 00 fa
|
||||
0x0c067fff8180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c067fff8190: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c067fff81a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c067fff81b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c067fff81c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
Shadow byte legend (one shadow byte represents 8 application bytes):
|
||||
Addressable: 00
|
||||
Partially addressable: 01 02 03 04 05 06 07
|
||||
Heap left redzone: fa
|
||||
Freed heap region: fd
|
||||
Stack left redzone: f1
|
||||
Stack mid redzone: f2
|
||||
Stack right redzone: f3
|
||||
Stack after return: f5
|
||||
Stack use after scope: f8
|
||||
Global redzone: f9
|
||||
Global init order: f6
|
||||
Poisoned by user: f7
|
||||
Container overflow: fc
|
||||
Array cookie: ac
|
||||
Intra object redzone: bb
|
||||
ASan internal: fe
|
||||
Left alloca redzone: ca
|
||||
Right alloca redzone: cb
|
||||
|
||||
Luckily enough, this would only cause us to copy the out-of-bounds data
|
||||
into the formatted commit in case we really had an ANSI sequence
|
||||
preceding our buffer. So this bug likely has no security consequences.
|
||||
|
||||
Fix it regardless by not traversing past the buffer's start.
|
||||
|
||||
Reported-by: Patrick Steinhardt <ps@pks.im>
|
||||
Reported-by: Eric Sesterhenn <eric.sesterhenn@x41-dsec.de>
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/b49f309aa16febeddb65e82526640a91bbba3be3]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
pretty.c | 2 +-
|
||||
t/t4205-log-pretty-formats.sh | 6 ++++++
|
||||
2 files changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pretty.c b/pretty.c
|
||||
index 637e344..4348a82 100644
|
||||
--- a/pretty.c
|
||||
+++ b/pretty.c
|
||||
@@ -1468,7 +1468,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
|
||||
if (*ch != 'm')
|
||||
break;
|
||||
p = ch - 1;
|
||||
- while (ch - p < 10 && *p != '\033')
|
||||
+ while (p > sb->buf && ch - p < 10 && *p != '\033')
|
||||
p--;
|
||||
if (*p != '\033' ||
|
||||
ch + 1 - p != display_mode_esc_sequence_len(p))
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index a2acee1..e69caba 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -788,6 +788,12 @@ test_expect_success '%S in git log --format works with other placeholders (part
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
+test_expect_success 'log --pretty with space stealing' '
|
||||
+ printf mm0 >expect &&
|
||||
+ git log -1 --pretty="format:mm%>>|(1)%x30" >actual &&
|
||||
+ test_cmp expect actual
|
||||
+'
|
||||
+
|
||||
test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' '
|
||||
# We only assert that this command does not crash. This needs to be
|
||||
# executed with the address sanitizer to demonstrate failure.
|
||||
--
|
||||
2.25.1
|
||||
|
||||
150
meta/recipes-devtools/git/files/CVE-2022-41903-04.patch
Normal file
150
meta/recipes-devtools/git/files/CVE-2022-41903-04.patch
Normal file
@@ -0,0 +1,150 @@
|
||||
From f6e0b9f38987ad5e47bab551f8760b70689a5905 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:46:34 +0100
|
||||
Subject: [PATCH 04/12] pretty: fix out-of-bounds read when parsing invalid padding format
|
||||
|
||||
An out-of-bounds read can be triggered when parsing an incomplete
|
||||
padding format string passed via `--pretty=format` or in Git archives
|
||||
when files are marked with the `export-subst` gitattribute.
|
||||
|
||||
This bug exists since we have introduced support for truncating output
|
||||
via the `trunc` keyword a7f01c6 (pretty: support truncating in %>, %<
|
||||
and %><, 2013-04-19). Before this commit, we used to find the end of the
|
||||
formatting string by using strchr(3P). This function returns a `NULL`
|
||||
pointer in case the character in question wasn't found. The subsequent
|
||||
check whether any character was found thus simply checked the returned
|
||||
pointer. After the commit we switched to strcspn(3P) though, which only
|
||||
returns the offset to the first found character or to the trailing NUL
|
||||
byte. As the end pointer is now computed by adding the offset to the
|
||||
start pointer it won't be `NULL` anymore, and as a consequence the check
|
||||
doesn't do anything anymore.
|
||||
|
||||
The out-of-bounds data that is being read can in fact end up in the
|
||||
formatted string. As a consequence, it is possible to leak memory
|
||||
contents either by calling git-log(1) or via git-archive(1) when any of
|
||||
the archived files is marked with the `export-subst` gitattribute.
|
||||
|
||||
==10888==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000398 at pc 0x7f0356047cb2 bp 0x7fff3ffb95d0 sp 0x7fff3ffb8d78
|
||||
READ of size 1 at 0x602000000398 thread T0
|
||||
#0 0x7f0356047cb1 in __interceptor_strchrnul /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:725
|
||||
#1 0x563b7cec9a43 in strbuf_expand strbuf.c:417
|
||||
#2 0x563b7cda7060 in repo_format_commit_message pretty.c:1869
|
||||
#3 0x563b7cda8d0f in pretty_print_commit pretty.c:2161
|
||||
#4 0x563b7cca04c8 in show_log log-tree.c:781
|
||||
#5 0x563b7cca36ba in log_tree_commit log-tree.c:1117
|
||||
#6 0x563b7c927ed5 in cmd_log_walk_no_free builtin/log.c:508
|
||||
#7 0x563b7c92835b in cmd_log_walk builtin/log.c:549
|
||||
#8 0x563b7c92b1a2 in cmd_log builtin/log.c:883
|
||||
#9 0x563b7c802993 in run_builtin git.c:466
|
||||
#10 0x563b7c803397 in handle_builtin git.c:721
|
||||
#11 0x563b7c803b07 in run_argv git.c:788
|
||||
#12 0x563b7c8048a7 in cmd_main git.c:923
|
||||
#13 0x563b7ca99682 in main common-main.c:57
|
||||
#14 0x7f0355e3c28f (/usr/lib/libc.so.6+0x2328f)
|
||||
#15 0x7f0355e3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
|
||||
#16 0x563b7c7fe0e4 in _start ../sysdeps/x86_64/start.S:115
|
||||
|
||||
0x602000000398 is located 0 bytes to the right of 8-byte region [0x602000000390,0x602000000398)
|
||||
allocated by thread T0 here:
|
||||
#0 0x7f0356072faa in __interceptor_strdup /usr/src/debug/gcc/libsanitizer/asan/asan_interceptors.cpp:439
|
||||
#1 0x563b7cf7317c in xstrdup wrapper.c:39
|
||||
#2 0x563b7cd9a06a in save_user_format pretty.c:40
|
||||
#3 0x563b7cd9b3e5 in get_commit_format pretty.c:173
|
||||
#4 0x563b7ce54ea0 in handle_revision_opt revision.c:2456
|
||||
#5 0x563b7ce597c9 in setup_revisions revision.c:2850
|
||||
#6 0x563b7c9269e0 in cmd_log_init_finish builtin/log.c:269
|
||||
#7 0x563b7c927362 in cmd_log_init builtin/log.c:348
|
||||
#8 0x563b7c92b193 in cmd_log builtin/log.c:882
|
||||
#9 0x563b7c802993 in run_builtin git.c:466
|
||||
#10 0x563b7c803397 in handle_builtin git.c:721
|
||||
#11 0x563b7c803b07 in run_argv git.c:788
|
||||
#12 0x563b7c8048a7 in cmd_main git.c:923
|
||||
#13 0x563b7ca99682 in main common-main.c:57
|
||||
#14 0x7f0355e3c28f (/usr/lib/libc.so.6+0x2328f)
|
||||
#15 0x7f0355e3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
|
||||
#16 0x563b7c7fe0e4 in _start ../sysdeps/x86_64/start.S:115
|
||||
|
||||
SUMMARY: AddressSanitizer: heap-buffer-overflow /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:725 in __interceptor_strchrnul
|
||||
Shadow bytes around the buggy address:
|
||||
0x0c047fff8020: fa fa fd fd fa fa 00 06 fa fa 05 fa fa fa fd fd
|
||||
0x0c047fff8030: fa fa 00 02 fa fa 06 fa fa fa 05 fa fa fa fd fd
|
||||
0x0c047fff8040: fa fa 00 07 fa fa 03 fa fa fa fd fd fa fa 00 00
|
||||
0x0c047fff8050: fa fa 00 01 fa fa fd fd fa fa 00 00 fa fa 00 01
|
||||
0x0c047fff8060: fa fa 00 06 fa fa 00 06 fa fa 05 fa fa fa 05 fa
|
||||
=>0x0c047fff8070: fa fa 00[fa]fa fa fd fa fa fa fd fd fa fa fd fd
|
||||
0x0c047fff8080: fa fa fd fd fa fa 00 00 fa fa 00 fa fa fa fd fa
|
||||
0x0c047fff8090: fa fa fd fd fa fa 00 00 fa fa fa fa fa fa fa fa
|
||||
0x0c047fff80a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c047fff80b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c047fff80c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
Shadow byte legend (one shadow byte represents 8 application bytes):
|
||||
Addressable: 00
|
||||
Partially addressable: 01 02 03 04 05 06 07
|
||||
Heap left redzone: fa
|
||||
Freed heap region: fd
|
||||
Stack left redzone: f1
|
||||
Stack mid redzone: f2
|
||||
Stack right redzone: f3
|
||||
Stack after return: f5
|
||||
Stack use after scope: f8
|
||||
Global redzone: f9
|
||||
Global init order: f6
|
||||
Poisoned by user: f7
|
||||
Container overflow: fc
|
||||
Array cookie: ac
|
||||
Intra object redzone: bb
|
||||
ASan internal: fe
|
||||
Left alloca redzone: ca
|
||||
Right alloca redzone: cb
|
||||
==10888==ABORTING
|
||||
|
||||
Fix this bug by checking whether `end` points at the trailing NUL byte.
|
||||
Add a test which catches this out-of-bounds read and which demonstrates
|
||||
that we used to write out-of-bounds data into the formatted message.
|
||||
|
||||
Reported-by: Markus Vervier <markus.vervier@x41-dsec.de>
|
||||
Original-patch-by: Markus Vervier <markus.vervier@x41-dsec.de>
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/f6e0b9f38987ad5e47bab551f8760b70689a5905]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
pretty.c | 2 +-
|
||||
t/t4205-log-pretty-formats.sh | 6 ++++++
|
||||
2 files changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pretty.c b/pretty.c
|
||||
index 4348a82..c49e818 100644
|
||||
--- a/pretty.c
|
||||
+++ b/pretty.c
|
||||
@@ -1024,7 +1024,7 @@ static size_t parse_padding_placeholder(const char *placeholder,
|
||||
const char *end = start + strcspn(start, ",)");
|
||||
char *next;
|
||||
int width;
|
||||
- if (!end || end == start)
|
||||
+ if (!*end || end == start)
|
||||
return 0;
|
||||
width = strtol(start, &next, 10);
|
||||
if (next == start || width == 0)
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index e69caba..8a349df 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -794,6 +794,12 @@ test_expect_success 'log --pretty with space stealing' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
+test_expect_success 'log --pretty with invalid padding format' '
|
||||
+ printf "%s%%<(20" "$(git rev-parse HEAD)" >expect &&
|
||||
+ git log -1 --pretty="format:%H%<(20" >actual &&
|
||||
+ test_cmp expect actual
|
||||
+'
|
||||
+
|
||||
test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' '
|
||||
# We only assert that this command does not crash. This needs to be
|
||||
# executed with the address sanitizer to demonstrate failure.
|
||||
--
|
||||
2.25.1
|
||||
|
||||
98
meta/recipes-devtools/git/files/CVE-2022-41903-05.patch
Normal file
98
meta/recipes-devtools/git/files/CVE-2022-41903-05.patch
Normal file
@@ -0,0 +1,98 @@
|
||||
From 1de69c0cdd388b0a5b7bdde0bfa0bda514a354b0 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:46:39 +0100
|
||||
Subject: [PATCH 05/12] pretty: fix adding linefeed when placeholder is not expanded
|
||||
|
||||
When a formatting directive has a `+` or ` ` after the `%`, then we add
|
||||
either a line feed or space if the placeholder expands to a non-empty
|
||||
string. In specific cases though this logic doesn't work as expected,
|
||||
and we try to add the character even in the case where the formatting
|
||||
directive is empty.
|
||||
|
||||
One such pattern is `%w(1)%+d%+w(2)`. `%+d` expands to reference names
|
||||
pointing to a certain commit, like in `git log --decorate`. For a tagged
|
||||
commit this would for example expand to `\n (tag: v1.0.0)`, which has a
|
||||
leading newline due to the `+` modifier and a space added by `%d`. Now
|
||||
the second wrapping directive will cause us to rewrap the text to
|
||||
`\n(tag:\nv1.0.0)`, which is one byte shorter due to the missing leading
|
||||
space. The code that handles the `+` magic now notices that the length
|
||||
has changed and will thus try to insert a leading line feed at the
|
||||
original posititon. But as the string was shortened, the original
|
||||
position is past the buffer's boundary and thus we die with an error.
|
||||
|
||||
Now there are two issues here:
|
||||
|
||||
1. We check whether the buffer length has changed, not whether it
|
||||
has been extended. This causes us to try and add the character
|
||||
past the string boundary.
|
||||
|
||||
2. The current logic does not make any sense whatsoever. When the
|
||||
string got expanded due to the rewrap, putting the separator into
|
||||
the original position is likely to put it somewhere into the
|
||||
middle of the rewrapped contents.
|
||||
|
||||
It is debatable whether `%+w()` makes any sense in the first place.
|
||||
Strictly speaking, the placeholder never expands to a non-empty string,
|
||||
and consequentially we shouldn't ever accept this combination. We thus
|
||||
fix the bug by simply refusing `%+w()`.
|
||||
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/1de69c0cdd388b0a5b7bdde0bfa0bda514a354b0]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
pretty.c | 14 +++++++++++++-
|
||||
t/t4205-log-pretty-formats.sh | 8 ++++++++
|
||||
2 files changed, 21 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pretty.c b/pretty.c
|
||||
index c49e818..195d005 100644
|
||||
--- a/pretty.c
|
||||
+++ b/pretty.c
|
||||
@@ -1551,9 +1551,21 @@ static size_t format_commit_item(struct strbuf *sb, /* in UTF-8 */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
- if (magic != NO_MAGIC)
|
||||
+ if (magic != NO_MAGIC) {
|
||||
placeholder++;
|
||||
|
||||
+ switch (placeholder[0]) {
|
||||
+ case 'w':
|
||||
+ /*
|
||||
+ * `%+w()` cannot ever expand to a non-empty string,
|
||||
+ * and it potentially changes the layout of preceding
|
||||
+ * contents. We're thus not able to handle the magic in
|
||||
+ * this combination and refuse the pattern.
|
||||
+ */
|
||||
+ return 0;
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
orig_len = sb->len;
|
||||
if (((struct format_commit_context *)context)->flush_type != no_flush)
|
||||
consumed = format_and_pad_commit(sb, placeholder, context);
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index 8a349df..fa1bc2b 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -800,6 +800,14 @@ test_expect_success 'log --pretty with invalid padding format' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
+test_expect_success 'log --pretty with magical wrapping directives' '
|
||||
+ commit_id=$(git commit-tree HEAD^{tree} -m "describe me") &&
|
||||
+ git tag describe-me $commit_id &&
|
||||
+ printf "\n(tag:\ndescribe-me)%%+w(2)" >expect &&
|
||||
+ git log -1 --pretty="format:%w(1)%+d%+w(2)" $commit_id >actual &&
|
||||
+ test_cmp expect actual
|
||||
+'
|
||||
+
|
||||
test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' '
|
||||
# We only assert that this command does not crash. This needs to be
|
||||
# executed with the address sanitizer to demonstrate failure.
|
||||
--
|
||||
2.25.1
|
||||
|
||||
90
meta/recipes-devtools/git/files/CVE-2022-41903-06.patch
Normal file
90
meta/recipes-devtools/git/files/CVE-2022-41903-06.patch
Normal file
@@ -0,0 +1,90 @@
|
||||
From 48050c42c73c28b0c001d63d11dffac7e116847b Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:46:49 +0100
|
||||
Subject: [PATCH 06/12] pretty: fix integer overflow in wrapping format
|
||||
|
||||
The `%w(width,indent1,indent2)` formatting directive can be used to
|
||||
rewrap text to a specific width and is designed after git-shortlog(1)'s
|
||||
`-w` parameter. While the three parameters are all stored as `size_t`
|
||||
internally, `strbuf_add_wrapped_text()` accepts integers as input. As a
|
||||
result, the casted integers may overflow. As these now-negative integers
|
||||
are later on passed to `strbuf_addchars()`, we will ultimately run into
|
||||
implementation-defined behaviour due to casting a negative number back
|
||||
to `size_t` again. On my platform, this results in trying to allocate
|
||||
9000 petabyte of memory.
|
||||
|
||||
Fix this overflow by using `cast_size_t_to_int()` so that we reject
|
||||
inputs that cannot be represented as an integer.
|
||||
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/48050c42c73c28b0c001d63d11dffac7e116847b]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
git-compat-util.h | 8 ++++++++
|
||||
pretty.c | 4 +++-
|
||||
t/t4205-log-pretty-formats.sh | 12 ++++++++++++
|
||||
3 files changed, 23 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/git-compat-util.h b/git-compat-util.h
|
||||
index a1ecfd3..b0f3890 100644
|
||||
--- a/git-compat-util.h
|
||||
+++ b/git-compat-util.h
|
||||
@@ -854,6 +854,14 @@ static inline size_t st_sub(size_t a, size_t b)
|
||||
return a - b;
|
||||
}
|
||||
|
||||
+static inline int cast_size_t_to_int(size_t a)
|
||||
+{
|
||||
+ if (a > INT_MAX)
|
||||
+ die("number too large to represent as int on this platform: %"PRIuMAX,
|
||||
+ (uintmax_t)a);
|
||||
+ return (int)a;
|
||||
+}
|
||||
+
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# define xalloca(size) (alloca(size))
|
||||
diff --git a/pretty.c b/pretty.c
|
||||
index 195d005..ff9fc97 100644
|
||||
--- a/pretty.c
|
||||
+++ b/pretty.c
|
||||
@@ -898,7 +898,9 @@ static void strbuf_wrap(struct strbuf *sb, size_t pos,
|
||||
if (pos)
|
||||
strbuf_add(&tmp, sb->buf, pos);
|
||||
strbuf_add_wrapped_text(&tmp, sb->buf + pos,
|
||||
- (int) indent1, (int) indent2, (int) width);
|
||||
+ cast_size_t_to_int(indent1),
|
||||
+ cast_size_t_to_int(indent2),
|
||||
+ cast_size_t_to_int(width));
|
||||
strbuf_swap(&tmp, sb);
|
||||
strbuf_release(&tmp);
|
||||
}
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index fa1bc2b..23ac508 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -808,6 +808,18 @@ test_expect_success 'log --pretty with magical wrapping directives' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
+test_expect_success SIZE_T_IS_64BIT 'log --pretty with overflowing wrapping directive' '
|
||||
+ cat >expect <<-EOF &&
|
||||
+ fatal: number too large to represent as int on this platform: 2147483649
|
||||
+ EOF
|
||||
+ test_must_fail git log -1 --pretty="format:%w(2147483649,1,1)%d" 2>error &&
|
||||
+ test_cmp expect error &&
|
||||
+ test_must_fail git log -1 --pretty="format:%w(1,2147483649,1)%d" 2>error &&
|
||||
+ test_cmp expect error &&
|
||||
+ test_must_fail git log -1 --pretty="format:%w(1,1,2147483649)%d" 2>error &&
|
||||
+ test_cmp expect error
|
||||
+'
|
||||
+
|
||||
test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' '
|
||||
# We only assert that this command does not crash. This needs to be
|
||||
# executed with the address sanitizer to demonstrate failure.
|
||||
--
|
||||
2.25.1
|
||||
|
||||
123
meta/recipes-devtools/git/files/CVE-2022-41903-07.patch
Normal file
123
meta/recipes-devtools/git/files/CVE-2022-41903-07.patch
Normal file
@@ -0,0 +1,123 @@
|
||||
From 522cc87fdc25449222a5894a428eebf4b8d5eaa9 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:46:53 +0100
|
||||
Subject: [PATCH 07/12] utf8: fix truncated string lengths in utf8_strnwidth()
|
||||
|
||||
The `utf8_strnwidth()` function accepts an optional string length as
|
||||
input parameter. This parameter can either be set to `-1`, in which case
|
||||
we call `strlen()` on the input. Or it can be set to a positive integer
|
||||
that indicates a precomputed length, which callers typically compute by
|
||||
calling `strlen()` at some point themselves.
|
||||
|
||||
The input parameter is an `int` though, whereas `strlen()` returns a
|
||||
`size_t`. This can lead to implementation-defined behaviour though when
|
||||
the `size_t` cannot be represented by the `int`. In the general case
|
||||
though this leads to wrap-around and thus to negative string sizes,
|
||||
which is sure enough to not lead to well-defined behaviour.
|
||||
|
||||
Fix this by accepting a `size_t` instead of an `int` as string length.
|
||||
While this takes away the ability of callers to simply pass in `-1` as
|
||||
string length, it really is trivial enough to convert them to instead
|
||||
pass in `strlen()` instead.
|
||||
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/522cc87fdc25449222a5894a428eebf4b8d5eaa9]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
column.c | 2 +-
|
||||
pretty.c | 4 ++--
|
||||
utf8.c | 8 +++-----
|
||||
utf8.h | 2 +-
|
||||
4 files changed, 7 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/column.c b/column.c
|
||||
index 4a38eed..0c79850 100644
|
||||
--- a/column.c
|
||||
+++ b/column.c
|
||||
@@ -23,7 +23,7 @@ struct column_data {
|
||||
/* return length of 's' in letters, ANSI escapes stripped */
|
||||
static int item_length(const char *s)
|
||||
{
|
||||
- return utf8_strnwidth(s, -1, 1);
|
||||
+ return utf8_strnwidth(s, strlen(s), 1);
|
||||
}
|
||||
|
||||
/*
|
||||
diff --git a/pretty.c b/pretty.c
|
||||
index ff9fc97..c3c1443 100644
|
||||
--- a/pretty.c
|
||||
+++ b/pretty.c
|
||||
@@ -1437,7 +1437,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
|
||||
int occupied;
|
||||
if (!start)
|
||||
start = sb->buf;
|
||||
- occupied = utf8_strnwidth(start, -1, 1);
|
||||
+ occupied = utf8_strnwidth(start, strlen(start), 1);
|
||||
occupied += c->pretty_ctx->graph_width;
|
||||
padding = (-padding) - occupied;
|
||||
}
|
||||
@@ -1455,7 +1455,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
|
||||
placeholder++;
|
||||
total_consumed++;
|
||||
}
|
||||
- len = utf8_strnwidth(local_sb.buf, -1, 1);
|
||||
+ len = utf8_strnwidth(local_sb.buf, local_sb.len, 1);
|
||||
|
||||
if (c->flush_type == flush_left_and_steal) {
|
||||
const char *ch = sb->buf + sb->len - 1;
|
||||
diff --git a/utf8.c b/utf8.c
|
||||
index 5c8f151..a66984b 100644
|
||||
--- a/utf8.c
|
||||
+++ b/utf8.c
|
||||
@@ -206,13 +206,11 @@ int utf8_width(const char **start, size_t *remainder_p)
|
||||
* string, assuming that the string is utf8. Returns strlen() instead
|
||||
* if the string does not look like a valid utf8 string.
|
||||
*/
|
||||
-int utf8_strnwidth(const char *string, int len, int skip_ansi)
|
||||
+int utf8_strnwidth(const char *string, size_t len, int skip_ansi)
|
||||
{
|
||||
int width = 0;
|
||||
const char *orig = string;
|
||||
|
||||
- if (len == -1)
|
||||
- len = strlen(string);
|
||||
while (string && string < orig + len) {
|
||||
int skip;
|
||||
while (skip_ansi &&
|
||||
@@ -225,7 +223,7 @@ int utf8_strnwidth(const char *string, int len, int skip_ansi)
|
||||
|
||||
int utf8_strwidth(const char *string)
|
||||
{
|
||||
- return utf8_strnwidth(string, -1, 0);
|
||||
+ return utf8_strnwidth(string, strlen(string), 0);
|
||||
}
|
||||
|
||||
int is_utf8(const char *text)
|
||||
@@ -792,7 +790,7 @@ int skip_utf8_bom(char **text, size_t len)
|
||||
void strbuf_utf8_align(struct strbuf *buf, align_type position, unsigned int width,
|
||||
const char *s)
|
||||
{
|
||||
- int slen = strlen(s);
|
||||
+ size_t slen = strlen(s);
|
||||
int display_len = utf8_strnwidth(s, slen, 0);
|
||||
int utf8_compensation = slen - display_len;
|
||||
|
||||
diff --git a/utf8.h b/utf8.h
|
||||
index fcd5167..6da1b6d 100644
|
||||
--- a/utf8.h
|
||||
+++ b/utf8.h
|
||||
@@ -7,7 +7,7 @@ typedef unsigned int ucs_char_t; /* assuming 32bit int */
|
||||
|
||||
size_t display_mode_esc_sequence_len(const char *s);
|
||||
int utf8_width(const char **start, size_t *remainder_p);
|
||||
-int utf8_strnwidth(const char *string, int len, int skip_ansi);
|
||||
+int utf8_strnwidth(const char *string, size_t len, int skip_ansi);
|
||||
int utf8_strwidth(const char *string);
|
||||
int is_utf8(const char *text);
|
||||
int is_encoding_utf8(const char *name);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
67
meta/recipes-devtools/git/files/CVE-2022-41903-08.patch
Normal file
67
meta/recipes-devtools/git/files/CVE-2022-41903-08.patch
Normal file
@@ -0,0 +1,67 @@
|
||||
From 17d23e8a3812a5ca3dd6564e74d5250f22e5d76d Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:47:00 +0100
|
||||
Subject: [PATCH 08/12] utf8: fix returning negative string width
|
||||
|
||||
The `utf8_strnwidth()` function calls `utf8_width()` in a loop and adds
|
||||
its returned width to the end result. `utf8_width()` can return `-1`
|
||||
though in case it reads a control character, which means that the
|
||||
computed string width is going to be wrong. In the worst case where
|
||||
there are more control characters than non-control characters, we may
|
||||
even return a negative string width.
|
||||
|
||||
Fix this bug by treating control characters as having zero width.
|
||||
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/17d23e8a3812a5ca3dd6564e74d5250f22e5d76d]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
t/t4205-log-pretty-formats.sh | 6 ++++++
|
||||
utf8.c | 8 ++++++--
|
||||
2 files changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index 23ac508..261a6f0 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -820,6 +820,12 @@ test_expect_success SIZE_T_IS_64BIT 'log --pretty with overflowing wrapping dire
|
||||
test_cmp expect error
|
||||
'
|
||||
|
||||
+test_expect_success 'log --pretty with padding and preceding control chars' '
|
||||
+ printf "\20\20 0" >expect &&
|
||||
+ git log -1 --pretty="format:%x10%x10%>|(4)%x30" >actual &&
|
||||
+ test_cmp expect actual
|
||||
+'
|
||||
+
|
||||
test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' '
|
||||
# We only assert that this command does not crash. This needs to be
|
||||
# executed with the address sanitizer to demonstrate failure.
|
||||
diff --git a/utf8.c b/utf8.c
|
||||
index a66984b..6632bd2 100644
|
||||
--- a/utf8.c
|
||||
+++ b/utf8.c
|
||||
@@ -212,11 +212,15 @@ int utf8_strnwidth(const char *string, size_t len, int skip_ansi)
|
||||
const char *orig = string;
|
||||
|
||||
while (string && string < orig + len) {
|
||||
- int skip;
|
||||
+ int glyph_width, skip;
|
||||
+
|
||||
while (skip_ansi &&
|
||||
(skip = display_mode_esc_sequence_len(string)) != 0)
|
||||
string += skip;
|
||||
- width += utf8_width(&string, NULL);
|
||||
+
|
||||
+ glyph_width = utf8_width(&string, NULL);
|
||||
+ if (glyph_width > 0)
|
||||
+ width += glyph_width;
|
||||
}
|
||||
return string ? width : len;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
162
meta/recipes-devtools/git/files/CVE-2022-41903-09.patch
Normal file
162
meta/recipes-devtools/git/files/CVE-2022-41903-09.patch
Normal file
@@ -0,0 +1,162 @@
|
||||
From 937b71cc8b5b998963a7f9a33312ba3549d55510 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:47:04 +0100
|
||||
Subject: [PATCH 09/12] utf8: fix overflow when returning string width
|
||||
|
||||
The return type of both `utf8_strwidth()` and `utf8_strnwidth()` is
|
||||
`int`, but we operate on string lengths which are typically of type
|
||||
`size_t`. This means that when the string is longer than `INT_MAX`, we
|
||||
will overflow and thus return a negative result.
|
||||
|
||||
This can lead to an out-of-bounds write with `--pretty=format:%<1)%B`
|
||||
and a commit message that is 2^31+1 bytes long:
|
||||
|
||||
=================================================================
|
||||
==26009==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000001168 at pc 0x7f95c4e5f427 bp 0x7ffd8541c900 sp 0x7ffd8541c0a8
|
||||
WRITE of size 2147483649 at 0x603000001168 thread T0
|
||||
#0 0x7f95c4e5f426 in __interceptor_memcpy /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
|
||||
#1 0x5612bbb1068c in format_and_pad_commit pretty.c:1763
|
||||
#2 0x5612bbb1087a in format_commit_item pretty.c:1801
|
||||
#3 0x5612bbc33bab in strbuf_expand strbuf.c:429
|
||||
#4 0x5612bbb110e7 in repo_format_commit_message pretty.c:1869
|
||||
#5 0x5612bbb12d96 in pretty_print_commit pretty.c:2161
|
||||
#6 0x5612bba0a4d5 in show_log log-tree.c:781
|
||||
#7 0x5612bba0d6c7 in log_tree_commit log-tree.c:1117
|
||||
#8 0x5612bb691ed5 in cmd_log_walk_no_free builtin/log.c:508
|
||||
#9 0x5612bb69235b in cmd_log_walk builtin/log.c:549
|
||||
#10 0x5612bb6951a2 in cmd_log builtin/log.c:883
|
||||
#11 0x5612bb56c993 in run_builtin git.c:466
|
||||
#12 0x5612bb56d397 in handle_builtin git.c:721
|
||||
#13 0x5612bb56db07 in run_argv git.c:788
|
||||
#14 0x5612bb56e8a7 in cmd_main git.c:923
|
||||
#15 0x5612bb803682 in main common-main.c:57
|
||||
#16 0x7f95c4c3c28f (/usr/lib/libc.so.6+0x2328f)
|
||||
#17 0x7f95c4c3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
|
||||
#18 0x5612bb5680e4 in _start ../sysdeps/x86_64/start.S:115
|
||||
|
||||
0x603000001168 is located 0 bytes to the right of 24-byte region [0x603000001150,0x603000001168)
|
||||
allocated by thread T0 here:
|
||||
#0 0x7f95c4ebe7ea in __interceptor_realloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
|
||||
#1 0x5612bbcdd556 in xrealloc wrapper.c:136
|
||||
#2 0x5612bbc310a3 in strbuf_grow strbuf.c:99
|
||||
#3 0x5612bbc32acd in strbuf_add strbuf.c:298
|
||||
#4 0x5612bbc33aec in strbuf_expand strbuf.c:418
|
||||
#5 0x5612bbb110e7 in repo_format_commit_message pretty.c:1869
|
||||
#6 0x5612bbb12d96 in pretty_print_commit pretty.c:2161
|
||||
#7 0x5612bba0a4d5 in show_log log-tree.c:781
|
||||
#8 0x5612bba0d6c7 in log_tree_commit log-tree.c:1117
|
||||
#9 0x5612bb691ed5 in cmd_log_walk_no_free builtin/log.c:508
|
||||
#10 0x5612bb69235b in cmd_log_walk builtin/log.c:549
|
||||
#11 0x5612bb6951a2 in cmd_log builtin/log.c:883
|
||||
#12 0x5612bb56c993 in run_builtin git.c:466
|
||||
#13 0x5612bb56d397 in handle_builtin git.c:721
|
||||
#14 0x5612bb56db07 in run_argv git.c:788
|
||||
#15 0x5612bb56e8a7 in cmd_main git.c:923
|
||||
#16 0x5612bb803682 in main common-main.c:57
|
||||
#17 0x7f95c4c3c28f (/usr/lib/libc.so.6+0x2328f)
|
||||
|
||||
SUMMARY: AddressSanitizer: heap-buffer-overflow /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827 in __interceptor_memcpy
|
||||
Shadow bytes around the buggy address:
|
||||
0x0c067fff81d0: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
|
||||
0x0c067fff81e0: fa fa fd fd fd fd fa fa fd fd fd fd fa fa fd fd
|
||||
0x0c067fff81f0: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
|
||||
0x0c067fff8200: fd fd fd fa fa fa fd fd fd fd fa fa 00 00 00 fa
|
||||
0x0c067fff8210: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
|
||||
=>0x0c067fff8220: fd fa fa fa fd fd fd fa fa fa 00 00 00[fa]fa fa
|
||||
0x0c067fff8230: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c067fff8240: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c067fff8250: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c067fff8260: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
0x0c067fff8270: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
||||
Shadow byte legend (one shadow byte represents 8 application bytes):
|
||||
Addressable: 00
|
||||
Partially addressable: 01 02 03 04 05 06 07
|
||||
Heap left redzone: fa
|
||||
Freed heap region: fd
|
||||
Stack left redzone: f1
|
||||
Stack mid redzone: f2
|
||||
Stack right redzone: f3
|
||||
Stack after return: f5
|
||||
Stack use after scope: f8
|
||||
Global redzone: f9
|
||||
Global init order: f6
|
||||
Poisoned by user: f7
|
||||
Container overflow: fc
|
||||
Array cookie: ac
|
||||
Intra object redzone: bb
|
||||
ASan internal: fe
|
||||
Left alloca redzone: ca
|
||||
Right alloca redzone: cb
|
||||
==26009==ABORTING
|
||||
|
||||
Now the proper fix for this would be to convert both functions to return
|
||||
an `size_t` instead of an `int`. But given that this commit may be part
|
||||
of a security release, let's instead do the minimal viable fix and die
|
||||
in case we see an overflow.
|
||||
|
||||
Add a test that would have previously caused us to crash.
|
||||
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/937b71cc8b5b998963a7f9a33312ba3549d55510]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
t/t4205-log-pretty-formats.sh | 8 ++++++++
|
||||
utf8.c | 12 +++++++++---
|
||||
2 files changed, 17 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index 261a6f0..de15007 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -843,4 +843,12 @@ test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit mes
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
+test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message does not cause allocation failure' '
|
||||
+ test_must_fail git log -1 --format="%<(1)%B" $huge_commit 2>error &&
|
||||
+ cat >expect <<-EOF &&
|
||||
+ fatal: number too large to represent as int on this platform: 2147483649
|
||||
+ EOF
|
||||
+ test_cmp expect error
|
||||
+'
|
||||
+
|
||||
test_done
|
||||
diff --git a/utf8.c b/utf8.c
|
||||
index 6632bd2..03be475 100644
|
||||
--- a/utf8.c
|
||||
+++ b/utf8.c
|
||||
@@ -208,11 +208,12 @@ int utf8_width(const char **start, size_t *remainder_p)
|
||||
*/
|
||||
int utf8_strnwidth(const char *string, size_t len, int skip_ansi)
|
||||
{
|
||||
- int width = 0;
|
||||
const char *orig = string;
|
||||
+ size_t width = 0;
|
||||
|
||||
while (string && string < orig + len) {
|
||||
- int glyph_width, skip;
|
||||
+ int glyph_width;
|
||||
+ size_t skip;
|
||||
|
||||
while (skip_ansi &&
|
||||
(skip = display_mode_esc_sequence_len(string)) != 0)
|
||||
@@ -222,7 +223,12 @@ int utf8_strnwidth(const char *string, size_t len, int skip_ansi)
|
||||
if (glyph_width > 0)
|
||||
width += glyph_width;
|
||||
}
|
||||
- return string ? width : len;
|
||||
+
|
||||
+ /*
|
||||
+ * TODO: fix the interface of this function and `utf8_strwidth()` to
|
||||
+ * return `size_t` instead of `int`.
|
||||
+ */
|
||||
+ return cast_size_t_to_int(string ? width : len);
|
||||
}
|
||||
|
||||
int utf8_strwidth(const char *string)
|
||||
--
|
||||
2.25.1
|
||||
|
||||
99
meta/recipes-devtools/git/files/CVE-2022-41903-10.patch
Normal file
99
meta/recipes-devtools/git/files/CVE-2022-41903-10.patch
Normal file
@@ -0,0 +1,99 @@
|
||||
From 81c2d4c3a5ba0e6ab8c348708441fed170e63a82 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:47:10 +0100
|
||||
Subject: [PATCH 10/12] utf8: fix checking for glyph width in strbuf_utf8_replace()
|
||||
|
||||
In `strbuf_utf8_replace()`, we call `utf8_width()` to compute the width
|
||||
of the current glyph. If the glyph is a control character though it can
|
||||
be that `utf8_width()` returns `-1`, but because we assign this value to
|
||||
a `size_t` the conversion will cause us to underflow. This bug can
|
||||
easily be triggered with the following command:
|
||||
|
||||
$ git log --pretty='format:xxx%<|(1,trunc)%x10'
|
||||
|
||||
>From all I can see though this seems to be a benign underflow that has
|
||||
no security-related consequences.
|
||||
|
||||
Fix the bug by using an `int` instead. When we see a control character,
|
||||
we now copy it into the target buffer but don't advance the current
|
||||
width of the string.
|
||||
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/81c2d4c3a5ba0e6ab8c348708441fed170e63a82]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
t/t4205-log-pretty-formats.sh | 7 +++++++
|
||||
utf8.c | 19 ++++++++++++++-----
|
||||
2 files changed, 21 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index de15007..52c8bc8 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -826,6 +826,13 @@ test_expect_success 'log --pretty with padding and preceding control chars' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
+test_expect_success 'log --pretty truncation with control chars' '
|
||||
+ test_commit "$(printf "\20\20\20\20xxxx")" file contents commit-with-control-chars &&
|
||||
+ printf "\20\20\20\20x.." >expect &&
|
||||
+ git log -1 --pretty="format:%<(3,trunc)%s" commit-with-control-chars >actual &&
|
||||
+ test_cmp expect actual
|
||||
+'
|
||||
+
|
||||
test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' '
|
||||
# We only assert that this command does not crash. This needs to be
|
||||
# executed with the address sanitizer to demonstrate failure.
|
||||
diff --git a/utf8.c b/utf8.c
|
||||
index 03be475..ec03e69 100644
|
||||
--- a/utf8.c
|
||||
+++ b/utf8.c
|
||||
@@ -377,6 +377,7 @@ void strbuf_utf8_replace(struct strbuf *sb_src, int pos, int width,
|
||||
dst = sb_dst.buf;
|
||||
|
||||
while (src < end) {
|
||||
+ int glyph_width;
|
||||
char *old;
|
||||
size_t n;
|
||||
|
||||
@@ -390,21 +391,29 @@ void strbuf_utf8_replace(struct strbuf *sb_src, int pos, int width,
|
||||
break;
|
||||
|
||||
old = src;
|
||||
- n = utf8_width((const char**)&src, NULL);
|
||||
- if (!src) /* broken utf-8, do nothing */
|
||||
+ glyph_width = utf8_width((const char**)&src, NULL);
|
||||
+ if (!src) /* broken utf-8, do nothing */
|
||||
goto out;
|
||||
- if (n && w >= pos && w < pos + width) {
|
||||
+
|
||||
+ /*
|
||||
+ * In case we see a control character we copy it into the
|
||||
+ * buffer, but don't add it to the width.
|
||||
+ */
|
||||
+ if (glyph_width < 0)
|
||||
+ glyph_width = 0;
|
||||
+
|
||||
+ if (glyph_width && w >= pos && w < pos + width) {
|
||||
if (subst) {
|
||||
memcpy(dst, subst, subst_len);
|
||||
dst += subst_len;
|
||||
subst = NULL;
|
||||
}
|
||||
- w += n;
|
||||
+ w += glyph_width;
|
||||
continue;
|
||||
}
|
||||
memcpy(dst, old, src - old);
|
||||
dst += src - old;
|
||||
- w += n;
|
||||
+ w += glyph_width;
|
||||
}
|
||||
strbuf_setlen(&sb_dst, dst - sb_dst.buf);
|
||||
strbuf_swap(sb_src, &sb_dst);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
90
meta/recipes-devtools/git/files/CVE-2022-41903-11.patch
Normal file
90
meta/recipes-devtools/git/files/CVE-2022-41903-11.patch
Normal file
@@ -0,0 +1,90 @@
|
||||
From f930a2394303b902e2973f4308f96529f736b8bc Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:47:15 +0100
|
||||
Subject: [PATCH 11/12] utf8: refactor strbuf_utf8_replace to not rely on preallocated buffer
|
||||
|
||||
In `strbuf_utf8_replace`, we preallocate the destination buffer and then
|
||||
use `memcpy` to copy bytes into it at computed offsets. This feels
|
||||
rather fragile and is hard to understand at times. Refactor the code to
|
||||
instead use `strbuf_add` and `strbuf_addstr` so that we can be sure that
|
||||
there is no possibility to perform an out-of-bounds write.
|
||||
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/f930a2394303b902e2973f4308f96529f736b8bc]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
utf8.c | 34 +++++++++++++---------------------
|
||||
1 file changed, 13 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/utf8.c b/utf8.c
|
||||
index ec03e69..a13f5e3 100644
|
||||
--- a/utf8.c
|
||||
+++ b/utf8.c
|
||||
@@ -365,26 +365,20 @@ void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
|
||||
void strbuf_utf8_replace(struct strbuf *sb_src, int pos, int width,
|
||||
const char *subst)
|
||||
{
|
||||
- struct strbuf sb_dst = STRBUF_INIT;
|
||||
- char *src = sb_src->buf;
|
||||
- char *end = src + sb_src->len;
|
||||
- char *dst;
|
||||
- int w = 0, subst_len = 0;
|
||||
+ const char *src = sb_src->buf, *end = sb_src->buf + sb_src->len;
|
||||
+ struct strbuf dst;
|
||||
+ int w = 0;
|
||||
|
||||
- if (subst)
|
||||
- subst_len = strlen(subst);
|
||||
- strbuf_grow(&sb_dst, sb_src->len + subst_len);
|
||||
- dst = sb_dst.buf;
|
||||
+ strbuf_init(&dst, sb_src->len);
|
||||
|
||||
while (src < end) {
|
||||
+ const char *old;
|
||||
int glyph_width;
|
||||
- char *old;
|
||||
size_t n;
|
||||
|
||||
while ((n = display_mode_esc_sequence_len(src))) {
|
||||
- memcpy(dst, src, n);
|
||||
+ strbuf_add(&dst, src, n);
|
||||
src += n;
|
||||
- dst += n;
|
||||
}
|
||||
|
||||
if (src >= end)
|
||||
@@ -404,21 +398,19 @@ void strbuf_utf8_replace(struct strbuf *sb_src, int pos, int width,
|
||||
|
||||
if (glyph_width && w >= pos && w < pos + width) {
|
||||
if (subst) {
|
||||
- memcpy(dst, subst, subst_len);
|
||||
- dst += subst_len;
|
||||
+ strbuf_addstr(&dst, subst);
|
||||
subst = NULL;
|
||||
}
|
||||
- w += glyph_width;
|
||||
- continue;
|
||||
+ } else {
|
||||
+ strbuf_add(&dst, old, src - old);
|
||||
}
|
||||
- memcpy(dst, old, src - old);
|
||||
- dst += src - old;
|
||||
+
|
||||
w += glyph_width;
|
||||
}
|
||||
- strbuf_setlen(&sb_dst, dst - sb_dst.buf);
|
||||
- strbuf_swap(sb_src, &sb_dst);
|
||||
+
|
||||
+ strbuf_swap(sb_src, &dst);
|
||||
out:
|
||||
- strbuf_release(&sb_dst);
|
||||
+ strbuf_release(&dst);
|
||||
}
|
||||
|
||||
/*
|
||||
--
|
||||
2.25.1
|
||||
|
||||
124
meta/recipes-devtools/git/files/CVE-2022-41903-12.patch
Normal file
124
meta/recipes-devtools/git/files/CVE-2022-41903-12.patch
Normal file
@@ -0,0 +1,124 @@
|
||||
From 304a50adff6480ede46b68f7545baab542cbfb46 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 1 Dec 2022 15:47:23 +0100
|
||||
Subject: [PATCH 12/12] pretty: restrict input lengths for padding and wrapping formats
|
||||
|
||||
Both the padding and wrapping formatting directives allow the caller to
|
||||
specify an integer that ultimately leads to us adding this many chars to
|
||||
the result buffer. As a consequence, it is trivial to e.g. allocate 2GB
|
||||
of RAM via a single formatting directive and cause resource exhaustion
|
||||
on the machine executing this logic. Furthermore, it is debatable
|
||||
whether there are any sane usecases that require the user to pad data to
|
||||
2GB boundaries or to indent wrapped data by 2GB.
|
||||
|
||||
Restrict the input sizes to 16 kilobytes at a maximum to limit the
|
||||
amount of bytes that can be requested by the user. This is not meant
|
||||
as a fix because there are ways to trivially amplify the amount of
|
||||
data we generate via formatting directives; the real protection is
|
||||
achieved by the changes in previous steps to catch and avoid integer
|
||||
wraparound that causes us to under-allocate and access beyond the
|
||||
end of allocated memory reagions. But having such a limit
|
||||
significantly helps fuzzing the pretty format, because the fuzzer is
|
||||
otherwise quite fast to run out-of-memory as it discovers these
|
||||
formatters.
|
||||
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/git/git/commit/304a50adff6480ede46b68f7545baab542cbfb46]
|
||||
CVE: CVE-2022-41903
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
pretty.c | 26 ++++++++++++++++++++++++++
|
||||
t/t4205-log-pretty-formats.sh | 24 +++++++++++++++---------
|
||||
2 files changed, 41 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/pretty.c b/pretty.c
|
||||
index c3c1443..e9687f0 100644
|
||||
--- a/pretty.c
|
||||
+++ b/pretty.c
|
||||
@@ -13,6 +13,13 @@
|
||||
#include "gpg-interface.h"
|
||||
#include "trailer.h"
|
||||
|
||||
+/*
|
||||
+ * The limit for formatting directives, which enable the caller to append
|
||||
+ * arbitrarily many bytes to the formatted buffer. This includes padding
|
||||
+ * and wrapping formatters.
|
||||
+ */
|
||||
+#define FORMATTING_LIMIT (16 * 1024)
|
||||
+
|
||||
static char *user_format;
|
||||
static struct cmt_fmt_map {
|
||||
const char *name;
|
||||
@@ -1029,6 +1036,15 @@ static size_t parse_padding_placeholder(const char *placeholder,
|
||||
if (!*end || end == start)
|
||||
return 0;
|
||||
width = strtol(start, &next, 10);
|
||||
+
|
||||
+ /*
|
||||
+ * We need to limit the amount of padding, or otherwise this
|
||||
+ * would allow the user to pad the buffer by arbitrarily many
|
||||
+ * bytes and thus cause resource exhaustion.
|
||||
+ */
|
||||
+ if (width < -FORMATTING_LIMIT || width > FORMATTING_LIMIT)
|
||||
+ return 0;
|
||||
+
|
||||
if (next == start || width == 0)
|
||||
return 0;
|
||||
if (width < 0) {
|
||||
@@ -1188,6 +1204,16 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
|
||||
if (*next != ')')
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+ /*
|
||||
+ * We need to limit the format here as it allows the
|
||||
+ * user to prepend arbitrarily many bytes to the buffer
|
||||
+ * when rewrapping.
|
||||
+ */
|
||||
+ if (width > FORMATTING_LIMIT ||
|
||||
+ indent1 > FORMATTING_LIMIT ||
|
||||
+ indent2 > FORMATTING_LIMIT)
|
||||
+ return 0;
|
||||
rewrap_message_tail(sb, c, width, indent1, indent2);
|
||||
return end - placeholder + 1;
|
||||
} else
|
||||
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
|
||||
index 52c8bc8..572d02f 100755
|
||||
--- a/t/t4205-log-pretty-formats.sh
|
||||
+++ b/t/t4205-log-pretty-formats.sh
|
||||
@@ -809,15 +809,21 @@ test_expect_success 'log --pretty with magical wrapping directives' '
|
||||
'
|
||||
|
||||
test_expect_success SIZE_T_IS_64BIT 'log --pretty with overflowing wrapping directive' '
|
||||
- cat >expect <<-EOF &&
|
||||
- fatal: number too large to represent as int on this platform: 2147483649
|
||||
- EOF
|
||||
- test_must_fail git log -1 --pretty="format:%w(2147483649,1,1)%d" 2>error &&
|
||||
- test_cmp expect error &&
|
||||
- test_must_fail git log -1 --pretty="format:%w(1,2147483649,1)%d" 2>error &&
|
||||
- test_cmp expect error &&
|
||||
- test_must_fail git log -1 --pretty="format:%w(1,1,2147483649)%d" 2>error &&
|
||||
- test_cmp expect error
|
||||
+ printf "%%w(2147483649,1,1)0" >expect &&
|
||||
+ git log -1 --pretty="format:%w(2147483649,1,1)%x30" >actual &&
|
||||
+ test_cmp expect actual &&
|
||||
+ printf "%%w(1,2147483649,1)0" >expect &&
|
||||
+ git log -1 --pretty="format:%w(1,2147483649,1)%x30" >actual &&
|
||||
+ test_cmp expect actual &&
|
||||
+ printf "%%w(1,1,2147483649)0" >expect &&
|
||||
+ git log -1 --pretty="format:%w(1,1,2147483649)%x30" >actual &&
|
||||
+ test_cmp expect actual
|
||||
+'
|
||||
+
|
||||
+test_expect_success SIZE_T_IS_64BIT 'log --pretty with overflowing padding directive' '
|
||||
+ printf "%%<(2147483649)0" >expect &&
|
||||
+ git log -1 --pretty="format:%<(2147483649)%x30" >actual &&
|
||||
+ test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --pretty with padding and preceding control chars' '
|
||||
--
|
||||
2.25.1
|
||||
|
||||
179
meta/recipes-devtools/git/files/CVE-2023-22490-1.patch
Normal file
179
meta/recipes-devtools/git/files/CVE-2023-22490-1.patch
Normal file
@@ -0,0 +1,179 @@
|
||||
From 58325b93c5b6212697b088371809e9948fee8052 Mon Sep 17 00:00:00 2001
|
||||
From: Taylor Blau <me@ttaylorr.com>
|
||||
Date: Tue, 24 Jan 2023 19:43:45 -0500
|
||||
Subject: [PATCH 1/3] t5619: demonstrate clone_local() with ambiguous transport
|
||||
|
||||
When cloning a repository, Git must determine (a) what transport
|
||||
mechanism to use, and (b) whether or not the clone is local.
|
||||
|
||||
Since f38aa83 (use local cloning if insteadOf makes a local URL,
|
||||
2014-07-17), the latter check happens after the remote has been
|
||||
initialized, and references the remote's URL instead of the local path.
|
||||
This is done to make it possible for a `url.<base>.insteadOf` rule to
|
||||
convert a remote URL into a local one, in which case the `clone_local()`
|
||||
mechanism should be used.
|
||||
|
||||
However, with a specially crafted repository, Git can be tricked into
|
||||
using a non-local transport while still setting `is_local` to "1" and
|
||||
using the `clone_local()` optimization. The below test case
|
||||
demonstrates such an instance, and shows that it can be used to include
|
||||
arbitrary (known) paths in the working copy of a cloned repository on a
|
||||
victim's machine[^1], even if local file clones are forbidden by
|
||||
`protocol.file.allow`.
|
||||
|
||||
This happens in a few parts:
|
||||
|
||||
1. We first call `get_repo_path()` to see if the remote is a local
|
||||
path. If it is, we replace the repo name with its absolute path.
|
||||
|
||||
2. We then call `transport_get()` on the repo name and decide how to
|
||||
access it. If it was turned into an absolute path in the previous
|
||||
step, then we should always treat it like a file.
|
||||
|
||||
3. We use `get_repo_path()` again, and set `is_local` as appropriate.
|
||||
But it's already too late to rewrite the repo name as an absolute
|
||||
path, since we've already fed it to the transport code.
|
||||
|
||||
The attack works by including a submodule whose URL corresponds to a
|
||||
path on disk. In the below example, the repository "sub" is reachable
|
||||
via the dumb HTTP protocol at (something like):
|
||||
|
||||
http://127.0.0.1:NNNN/dumb/sub.git
|
||||
|
||||
However, the path "http:/127.0.0.1:NNNN/dumb" (that is, a top-level
|
||||
directory called "http:", then nested directories "127.0.0.1:NNNN", and
|
||||
"dumb") exists within the repository, too.
|
||||
|
||||
To determine this, it first picks the appropriate transport, which is
|
||||
dumb HTTP. It then uses the remote's URL in order to determine whether
|
||||
the repository exists locally on disk. However, the malicious repository
|
||||
also contains an embedded stub repository which is the target of a
|
||||
symbolic link at the local path corresponding to the "sub" repository on
|
||||
disk (i.e., there is a symbolic link at "http:/127.0.0.1/dumb/sub.git",
|
||||
pointing to the stub repository via ".git/modules/sub/../../../repo").
|
||||
|
||||
This stub repository fools Git into thinking that a local repository
|
||||
exists at that URL and thus can be cloned locally. The affected call is
|
||||
in `get_repo_path()`, which in turn calls `get_repo_path_1()`, which
|
||||
locates a valid repository at that target.
|
||||
|
||||
This then causes Git to set the `is_local` variable to "1", and in turn
|
||||
instructs Git to clone the repository using its local clone optimization
|
||||
via the `clone_local()` function.
|
||||
|
||||
The exploit comes into play because the stub repository's top-level
|
||||
"$GIT_DIR/objects" directory is a symbolic link which can point to an
|
||||
arbitrary path on the victim's machine. `clone_local()` resolves the
|
||||
top-level "objects" directory through a `stat(2)` call, meaning that we
|
||||
read through the symbolic link and copy or hardlink the directory
|
||||
contents at the destination of the link.
|
||||
|
||||
In other words, we can get steps (1) and (3) to disagree by leveraging
|
||||
the dangling symlink to pick a non-local transport in the first step,
|
||||
and then set is_local to "1" in the third step when cloning with
|
||||
`--separate-git-dir`, which makes the symlink non-dangling.
|
||||
|
||||
This can result in data-exfiltration on the victim's machine when
|
||||
sensitive data is at a known path (e.g., "/home/$USER/.ssh").
|
||||
|
||||
The appropriate fix is two-fold:
|
||||
|
||||
- Resolve the transport later on (to avoid using the local
|
||||
clone optimization with a non-local transport).
|
||||
|
||||
- Avoid reading through the top-level "objects" directory when
|
||||
(correctly) using the clone_local() optimization.
|
||||
|
||||
This patch merely demonstrates the issue. The following two patches will
|
||||
implement each part of the above fix, respectively.
|
||||
|
||||
[^1]: Provided that any target directory does not contain symbolic
|
||||
links, in which case the changes from 6f054f9 (builtin/clone.c:
|
||||
disallow `--local` clones with symlinks, 2022-07-28) will abort the
|
||||
clone.
|
||||
|
||||
Reported-by: yvvdwf <yvvdwf@gmail.com>
|
||||
Signed-off-by: Taylor Blau <me@ttaylorr.com>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://github.com/git/git/commit/58325b93c5b6212697b088371809e9948fee8052]
|
||||
CVE: CVE-2023-22490
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
t/t5619-clone-local-ambiguous-transport.sh | 63 ++++++++++++++++++++++
|
||||
1 file changed, 63 insertions(+)
|
||||
create mode 100644 t/t5619-clone-local-ambiguous-transport.sh
|
||||
|
||||
diff --git a/t/t5619-clone-local-ambiguous-transport.sh b/t/t5619-clone-local-ambiguous-transport.sh
|
||||
new file mode 100644
|
||||
index 0000000..7ebd31a
|
||||
--- /dev/null
|
||||
+++ b/t/t5619-clone-local-ambiguous-transport.sh
|
||||
@@ -0,0 +1,63 @@
|
||||
+#!/bin/sh
|
||||
+
|
||||
+test_description='test local clone with ambiguous transport'
|
||||
+
|
||||
+. ./test-lib.sh
|
||||
+. "$TEST_DIRECTORY/lib-httpd.sh"
|
||||
+
|
||||
+if ! test_have_prereq SYMLINKS
|
||||
+then
|
||||
+ skip_all='skipping test, symlink support unavailable'
|
||||
+ test_done
|
||||
+fi
|
||||
+
|
||||
+start_httpd
|
||||
+
|
||||
+REPO="$HTTPD_DOCUMENT_ROOT_PATH/sub.git"
|
||||
+URI="$HTTPD_URL/dumb/sub.git"
|
||||
+
|
||||
+test_expect_success 'setup' '
|
||||
+ mkdir -p sensitive &&
|
||||
+ echo "secret" >sensitive/secret &&
|
||||
+
|
||||
+ git init --bare "$REPO" &&
|
||||
+ test_commit_bulk -C "$REPO" --ref=main 1 &&
|
||||
+
|
||||
+ git -C "$REPO" update-ref HEAD main &&
|
||||
+ git -C "$REPO" update-server-info &&
|
||||
+
|
||||
+ git init malicious &&
|
||||
+ (
|
||||
+ cd malicious &&
|
||||
+
|
||||
+ git submodule add "$URI" &&
|
||||
+
|
||||
+ mkdir -p repo/refs &&
|
||||
+ touch repo/refs/.gitkeep &&
|
||||
+ printf "ref: refs/heads/a" >repo/HEAD &&
|
||||
+ ln -s "$(cd .. && pwd)/sensitive" repo/objects &&
|
||||
+
|
||||
+ mkdir -p "$HTTPD_URL/dumb" &&
|
||||
+ ln -s "../../../.git/modules/sub/../../../repo/" "$URI" &&
|
||||
+
|
||||
+ git add . &&
|
||||
+ git commit -m "initial commit"
|
||||
+ ) &&
|
||||
+
|
||||
+ # Delete all of the references in our malicious submodule to
|
||||
+ # avoid the client attempting to checkout any objects (which
|
||||
+ # will be missing, and thus will cause the clone to fail before
|
||||
+ # we can trigger the exploit).
|
||||
+ git -C "$REPO" for-each-ref --format="delete %(refname)" >in &&
|
||||
+ git -C "$REPO" update-ref --stdin <in &&
|
||||
+ git -C "$REPO" update-server-info
|
||||
+'
|
||||
+
|
||||
+test_expect_failure 'ambiguous transport does not lead to arbitrary file-inclusion' '
|
||||
+ git clone malicious clone &&
|
||||
+ git -C clone submodule update --init &&
|
||||
+
|
||||
+ test_path_is_missing clone/.git/modules/sub/objects/secret
|
||||
+'
|
||||
+
|
||||
+test_done
|
||||
--
|
||||
2.25.1
|
||||
|
||||
122
meta/recipes-devtools/git/files/CVE-2023-22490-2.patch
Normal file
122
meta/recipes-devtools/git/files/CVE-2023-22490-2.patch
Normal file
@@ -0,0 +1,122 @@
|
||||
From cf8f6ce02a13f4d1979a53241afbee15a293fce9 Mon Sep 17 00:00:00 2001
|
||||
From: Taylor Blau <me@ttaylorr.com>
|
||||
Date: Tue, 24 Jan 2023 19:43:48 -0500
|
||||
Subject: [PATCH 2/3] clone: delay picking a transport until after get_repo_path()
|
||||
|
||||
In the previous commit, t5619 demonstrates an issue where two calls to
|
||||
`get_repo_path()` could trick Git into using its local clone mechanism
|
||||
in conjunction with a non-local transport.
|
||||
|
||||
That sequence is:
|
||||
|
||||
- the starting state is that the local path https:/example.com/foo is a
|
||||
symlink that points to ../../../.git/modules/foo. So it's dangling.
|
||||
|
||||
- get_repo_path() sees that no such path exists (because it's
|
||||
dangling), and thus we do not canonicalize it into an absolute path
|
||||
|
||||
- because we're using --separate-git-dir, we create .git/modules/foo.
|
||||
Now our symlink is no longer dangling!
|
||||
|
||||
- we pass the url to transport_get(), which sees it as an https URL.
|
||||
|
||||
- we call get_repo_path() again, on the url. This second call was
|
||||
introduced by f38aa83 (use local cloning if insteadOf makes a
|
||||
local URL, 2014-07-17). The idea is that we want to pull the url
|
||||
fresh from the remote.c API, because it will apply any aliases.
|
||||
|
||||
And of course now it sees that there is a local file, which is a
|
||||
mismatch with the transport we already selected.
|
||||
|
||||
The issue in the above sequence is calling `transport_get()` before
|
||||
deciding whether or not the repository is indeed local, and not passing
|
||||
in an absolute path if it is local.
|
||||
|
||||
This is reminiscent of a similar bug report in [1], where it was
|
||||
suggested to perform the `insteadOf` lookup earlier. Taking that
|
||||
approach may not be as straightforward, since the intent is to store the
|
||||
original URL in the config, but to actually fetch from the insteadOf
|
||||
one, so conflating the two early on is a non-starter.
|
||||
|
||||
Note: we pass the path returned by `get_repo_path(remote->url[0])`,
|
||||
which should be the same as `repo_name` (aside from any `insteadOf`
|
||||
rewrites).
|
||||
|
||||
We *could* pass `absolute_pathdup()` of the same argument, which
|
||||
86521ac (Bring local clone's origin URL in line with that of a remote
|
||||
clone, 2008-09-01) indicates may differ depending on the presence of
|
||||
".git/" for a non-bare repo. That matters for forming relative submodule
|
||||
paths, but doesn't matter for the second call, since we're just feeding
|
||||
it to the transport code, which is fine either way.
|
||||
|
||||
[1]: https://lore.kernel.org/git/CAMoD=Bi41mB3QRn3JdZL-FGHs4w3C2jGpnJB-CqSndO7FMtfzA@mail.gmail.com/
|
||||
|
||||
Signed-off-by: Jeff King <peff@peff.net>
|
||||
Signed-off-by: Taylor Blau <me@ttaylorr.com>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://github.com/git/git/commit/cf8f6ce02a13f4d1979a53241afbee15a293fce9]
|
||||
CVE: CVE-2023-22490
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
builtin/clone.c | 8 ++++----
|
||||
t/t5619-clone-local-ambiguous-transport.sh | 15 +++++++++++----
|
||||
2 files changed, 15 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/builtin/clone.c b/builtin/clone.c
|
||||
index 53e04b1..b57e703 100644
|
||||
--- a/builtin/clone.c
|
||||
+++ b/builtin/clone.c
|
||||
@@ -1112,10 +1112,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
branch_top.buf);
|
||||
refspec_append(&remote->fetch, default_refspec.buf);
|
||||
|
||||
- transport = transport_get(remote, remote->url[0]);
|
||||
- transport_set_verbosity(transport, option_verbosity, option_progress);
|
||||
- transport->family = family;
|
||||
-
|
||||
path = get_repo_path(remote->url[0], &is_bundle);
|
||||
is_local = option_local != 0 && path && !is_bundle;
|
||||
if (is_local) {
|
||||
@@ -1135,6 +1131,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
}
|
||||
if (option_local > 0 && !is_local)
|
||||
warning(_("--local is ignored"));
|
||||
+
|
||||
+ transport = transport_get(remote, path ? path : remote->url[0]);
|
||||
+ transport_set_verbosity(transport, option_verbosity, option_progress);
|
||||
+ transport->family = family;
|
||||
transport->cloning = 1;
|
||||
|
||||
transport_set_option(transport, TRANS_OPT_KEEP, "yes");
|
||||
diff --git a/t/t5619-clone-local-ambiguous-transport.sh b/t/t5619-clone-local-ambiguous-transport.sh
|
||||
index 7ebd31a..cce62bf 100644
|
||||
--- a/t/t5619-clone-local-ambiguous-transport.sh
|
||||
+++ b/t/t5619-clone-local-ambiguous-transport.sh
|
||||
@@ -53,11 +53,18 @@ test_expect_success 'setup' '
|
||||
git -C "$REPO" update-server-info
|
||||
'
|
||||
|
||||
-test_expect_failure 'ambiguous transport does not lead to arbitrary file-inclusion' '
|
||||
+test_expect_success 'ambiguous transport does not lead to arbitrary file-inclusion' '
|
||||
git clone malicious clone &&
|
||||
- git -C clone submodule update --init &&
|
||||
-
|
||||
- test_path_is_missing clone/.git/modules/sub/objects/secret
|
||||
+ test_must_fail git -C clone submodule update --init 2>err &&
|
||||
+
|
||||
+ test_path_is_missing clone/.git/modules/sub/objects/secret &&
|
||||
+ # We would actually expect "transport .file. not allowed" here,
|
||||
+ # but due to quirks of the URL detection in Git, we mis-parse
|
||||
+ # the absolute path as a bogus URL and die before that step.
|
||||
+ #
|
||||
+ # This works for now, and if we ever fix the URL detection, it
|
||||
+ # is OK to change this to detect the transport error.
|
||||
+ grep "protocol .* is not supported" err
|
||||
'
|
||||
|
||||
test_done
|
||||
--
|
||||
2.25.1
|
||||
|
||||
154
meta/recipes-devtools/git/files/CVE-2023-22490-3.patch
Normal file
154
meta/recipes-devtools/git/files/CVE-2023-22490-3.patch
Normal file
@@ -0,0 +1,154 @@
|
||||
From bffc762f87ae8d18c6001bf0044a76004245754c Mon Sep 17 00:00:00 2001
|
||||
From: Taylor Blau <me@ttaylorr.com>
|
||||
Date: Tue, 24 Jan 2023 19:43:51 -0500
|
||||
Subject: [PATCH 3/3] dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
|
||||
|
||||
When using the dir_iterator API, we first stat(2) the base path, and
|
||||
then use that as a starting point to enumerate the directory's contents.
|
||||
|
||||
If the directory contains symbolic links, we will immediately die() upon
|
||||
encountering them without the `FOLLOW_SYMLINKS` flag. The same is not
|
||||
true when resolving the top-level directory, though.
|
||||
|
||||
As explained in a previous commit, this oversight in 6f054f9
|
||||
(builtin/clone.c: disallow `--local` clones with symlinks, 2022-07-28)
|
||||
can be used as an attack vector to include arbitrary files on a victim's
|
||||
filesystem from outside of the repository.
|
||||
|
||||
Prevent resolving top-level symlinks unless the FOLLOW_SYMLINKS flag is
|
||||
given, which will cause clones of a repository with a symlink'd
|
||||
"$GIT_DIR/objects" directory to fail.
|
||||
|
||||
Signed-off-by: Taylor Blau <me@ttaylorr.com>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://github.com/git/git/commit/bffc762f87ae8d18c6001bf0044a76004245754c]
|
||||
CVE: CVE-2023-22490
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
dir-iterator.c | 13 +++++++++----
|
||||
dir-iterator.h | 5 +++++
|
||||
t/t0066-dir-iterator.sh | 27 ++++++++++++++++++++++++++-
|
||||
t/t5604-clone-reference.sh | 16 ++++++++++++++++
|
||||
4 files changed, 56 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dir-iterator.c b/dir-iterator.c
|
||||
index b17e9f9..3764dd8 100644
|
||||
--- a/dir-iterator.c
|
||||
+++ b/dir-iterator.c
|
||||
@@ -203,7 +203,7 @@ struct dir_iterator *dir_iterator_begin(const char *path, unsigned int flags)
|
||||
{
|
||||
struct dir_iterator_int *iter = xcalloc(1, sizeof(*iter));
|
||||
struct dir_iterator *dir_iterator = &iter->base;
|
||||
- int saved_errno;
|
||||
+ int saved_errno, err;
|
||||
|
||||
strbuf_init(&iter->base.path, PATH_MAX);
|
||||
strbuf_addstr(&iter->base.path, path);
|
||||
@@ -213,10 +213,15 @@ struct dir_iterator *dir_iterator_begin(const char *path, unsigned int flags)
|
||||
iter->flags = flags;
|
||||
|
||||
/*
|
||||
- * Note: stat already checks for NULL or empty strings and
|
||||
- * inexistent paths.
|
||||
+ * Note: stat/lstat already checks for NULL or empty strings and
|
||||
+ * nonexistent paths.
|
||||
*/
|
||||
- if (stat(iter->base.path.buf, &iter->base.st) < 0) {
|
||||
+ if (iter->flags & DIR_ITERATOR_FOLLOW_SYMLINKS)
|
||||
+ err = stat(iter->base.path.buf, &iter->base.st);
|
||||
+ else
|
||||
+ err = lstat(iter->base.path.buf, &iter->base.st);
|
||||
+
|
||||
+ if (err < 0) {
|
||||
saved_errno = errno;
|
||||
goto error_out;
|
||||
}
|
||||
diff --git a/dir-iterator.h b/dir-iterator.h
|
||||
index 0822915..e3b6ff2 100644
|
||||
--- a/dir-iterator.h
|
||||
+++ b/dir-iterator.h
|
||||
@@ -61,6 +61,11 @@
|
||||
* not the symlinks themselves, which is the default behavior. Broken
|
||||
* symlinks are ignored.
|
||||
*
|
||||
+ * Note: setting DIR_ITERATOR_FOLLOW_SYMLINKS affects resolving the
|
||||
+ * starting path as well (e.g., attempting to iterate starting at a
|
||||
+ * symbolic link pointing to a directory without FOLLOW_SYMLINKS will
|
||||
+ * result in an error).
|
||||
+ *
|
||||
* Warning: circular symlinks are also followed when
|
||||
* DIR_ITERATOR_FOLLOW_SYMLINKS is set. The iteration may end up with
|
||||
* an ELOOP if they happen and DIR_ITERATOR_PEDANTIC is set.
|
||||
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
|
||||
index 92910e4..c826f60 100755
|
||||
--- a/t/t0066-dir-iterator.sh
|
||||
+++ b/t/t0066-dir-iterator.sh
|
||||
@@ -109,7 +109,9 @@ test_expect_success SYMLINKS 'setup dirs with symlinks' '
|
||||
mkdir -p dir5/a/c &&
|
||||
ln -s ../c dir5/a/b/d &&
|
||||
ln -s ../ dir5/a/b/e &&
|
||||
- ln -s ../../ dir5/a/b/f
|
||||
+ ln -s ../../ dir5/a/b/f &&
|
||||
+
|
||||
+ ln -s dir4 dir6
|
||||
'
|
||||
|
||||
test_expect_success SYMLINKS 'dir-iterator should not follow symlinks by default' '
|
||||
@@ -145,4 +147,27 @@ test_expect_success SYMLINKS 'dir-iterator should follow symlinks w/ follow flag
|
||||
test_cmp expected-follow-sorted-output actual-follow-sorted-output
|
||||
'
|
||||
|
||||
+test_expect_success SYMLINKS 'dir-iterator does not resolve top-level symlinks' '
|
||||
+ test_must_fail test-tool dir-iterator ./dir6 >out &&
|
||||
+
|
||||
+ grep "ENOTDIR" out
|
||||
+'
|
||||
+
|
||||
+test_expect_success SYMLINKS 'dir-iterator resolves top-level symlinks w/ follow flag' '
|
||||
+ cat >expected-follow-sorted-output <<-EOF &&
|
||||
+ [d] (a) [a] ./dir6/a
|
||||
+ [d] (a/f) [f] ./dir6/a/f
|
||||
+ [d] (a/f/c) [c] ./dir6/a/f/c
|
||||
+ [d] (b) [b] ./dir6/b
|
||||
+ [d] (b/c) [c] ./dir6/b/c
|
||||
+ [f] (a/d) [d] ./dir6/a/d
|
||||
+ [f] (a/e) [e] ./dir6/a/e
|
||||
+ EOF
|
||||
+
|
||||
+ test-tool dir-iterator --follow-symlinks ./dir6 >out &&
|
||||
+ sort out >actual-follow-sorted-output &&
|
||||
+
|
||||
+ test_cmp expected-follow-sorted-output actual-follow-sorted-output
|
||||
+'
|
||||
+
|
||||
test_done
|
||||
diff --git a/t/t5604-clone-reference.sh b/t/t5604-clone-reference.sh
|
||||
index 4894237..615b981 100755
|
||||
--- a/t/t5604-clone-reference.sh
|
||||
+++ b/t/t5604-clone-reference.sh
|
||||
@@ -354,4 +354,20 @@ test_expect_success SYMLINKS 'clone repo with symlinked or unknown files at obje
|
||||
test_must_be_empty T--shared.objects-symlinks.raw
|
||||
'
|
||||
|
||||
+test_expect_success SYMLINKS 'clone repo with symlinked objects directory' '
|
||||
+ test_when_finished "rm -fr sensitive malicious" &&
|
||||
+
|
||||
+ mkdir -p sensitive &&
|
||||
+ echo "secret" >sensitive/file &&
|
||||
+
|
||||
+ git init malicious &&
|
||||
+ rm -fr malicious/.git/objects &&
|
||||
+ ln -s "$(pwd)/sensitive" ./malicious/.git/objects &&
|
||||
+
|
||||
+ test_must_fail git clone --local malicious clone 2>err &&
|
||||
+
|
||||
+ test_path_is_missing clone &&
|
||||
+ grep "failed to start iterator over" err
|
||||
+'
|
||||
+
|
||||
test_done
|
||||
--
|
||||
2.25.1
|
||||
|
||||
184
meta/recipes-devtools/git/files/CVE-2023-23946.patch
Normal file
184
meta/recipes-devtools/git/files/CVE-2023-23946.patch
Normal file
@@ -0,0 +1,184 @@
|
||||
From fade728df1221598f42d391cf377e9e84a32053f Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Steinhardt <ps@pks.im>
|
||||
Date: Thu, 2 Feb 2023 11:54:34 +0100
|
||||
Subject: [PATCH] apply: fix writing behind newly created symbolic links
|
||||
|
||||
When writing files git-apply(1) initially makes sure that none of the
|
||||
files it is about to create are behind a symlink:
|
||||
|
||||
```
|
||||
$ git init repo
|
||||
Initialized empty Git repository in /tmp/repo/.git/
|
||||
$ cd repo/
|
||||
$ ln -s dir symlink
|
||||
$ git apply - <<EOF
|
||||
diff --git a/symlink/file b/symlink/file
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
EOF
|
||||
error: affected file 'symlink/file' is beyond a symbolic link
|
||||
```
|
||||
|
||||
This safety mechanism is crucial to ensure that we don't write outside
|
||||
of the repository's working directory. It can be fooled though when the
|
||||
patch that is being applied creates the symbolic link in the first
|
||||
place, which can lead to writing files in arbitrary locations.
|
||||
|
||||
Fix this by checking whether the path we're about to create is
|
||||
beyond a symlink or not. Tightening these checks like this should be
|
||||
fine as we already have these precautions in Git as explained
|
||||
above. Ideally, we should update the check we do up-front before
|
||||
starting to reflect the computed changes to the working tree so that
|
||||
we catch this case as well, but as part of embargoed security work,
|
||||
adding an equivalent check just before we try to write out a file
|
||||
should serve us well as a reasonable first step.
|
||||
|
||||
Digging back into history shows that this vulnerability has existed
|
||||
since at least Git v2.9.0. As Git v2.8.0 and older don't build on my
|
||||
system anymore I cannot tell whether older versions are affected, as
|
||||
well.
|
||||
|
||||
Reported-by: Joern Schneeweisz <jschneeweisz@gitlab.com>
|
||||
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
|
||||
Upstream-Status: Backport
|
||||
[https://github.com/git/git/commit/fade728df1221598f42d391cf377e9e84a32053f]
|
||||
CVE: CVE-2023-23946
|
||||
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
|
||||
---
|
||||
apply.c | 27 ++++++++++++++
|
||||
t/t4115-apply-symlink.sh | 81 ++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 108 insertions(+)
|
||||
|
||||
diff --git a/apply.c b/apply.c
|
||||
index f8a046a..4f303bf 100644
|
||||
--- a/apply.c
|
||||
+++ b/apply.c
|
||||
@@ -4373,6 +4373,33 @@ static int create_one_file(struct apply_state *state,
|
||||
if (state->cached)
|
||||
return 0;
|
||||
|
||||
+ /*
|
||||
+ * We already try to detect whether files are beyond a symlink in our
|
||||
+ * up-front checks. But in the case where symlinks are created by any
|
||||
+ * of the intermediate hunks it can happen that our up-front checks
|
||||
+ * didn't yet see the symlink, but at the point of arriving here there
|
||||
+ * in fact is one. We thus repeat the check for symlinks here.
|
||||
+ *
|
||||
+ * Note that this does not make the up-front check obsolete as the
|
||||
+ * failure mode is different:
|
||||
+ *
|
||||
+ * - The up-front checks cause us to abort before we have written
|
||||
+ * anything into the working directory. So when we exit this way the
|
||||
+ * working directory remains clean.
|
||||
+ *
|
||||
+ * - The checks here happen in the middle of the action where we have
|
||||
+ * already started to apply the patch. The end result will be a dirty
|
||||
+ * working directory.
|
||||
+ *
|
||||
+ * Ideally, we should update the up-front checks to catch what would
|
||||
+ * happen when we apply the patch before we damage the working tree.
|
||||
+ * We have all the information necessary to do so. But for now, as a
|
||||
+ * part of embargoed security work, having this check would serve as a
|
||||
+ * reasonable first step.
|
||||
+ */
|
||||
+ if (path_is_beyond_symlink(state, path))
|
||||
+ return error(_("affected file '%s' is beyond a symbolic link"), path);
|
||||
+
|
||||
res = try_create_file(state, path, mode, buf, size);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
diff --git a/t/t4115-apply-symlink.sh b/t/t4115-apply-symlink.sh
|
||||
index 872fcda..1acb7b2 100755
|
||||
--- a/t/t4115-apply-symlink.sh
|
||||
+++ b/t/t4115-apply-symlink.sh
|
||||
@@ -44,4 +44,85 @@ test_expect_success 'apply --index symlink patch' '
|
||||
|
||||
'
|
||||
|
||||
+test_expect_success 'symlink setup' '
|
||||
+ ln -s .git symlink &&
|
||||
+ git add symlink &&
|
||||
+ git commit -m "add symlink"
|
||||
+'
|
||||
+
|
||||
+test_expect_success SYMLINKS 'symlink escape when creating new files' '
|
||||
+ test_when_finished "git reset --hard && git clean -dfx" &&
|
||||
+
|
||||
+ cat >patch <<-EOF &&
|
||||
+ diff --git a/symlink b/renamed-symlink
|
||||
+ similarity index 100%
|
||||
+ rename from symlink
|
||||
+ rename to renamed-symlink
|
||||
+ --
|
||||
+ diff --git /dev/null b/renamed-symlink/create-me
|
||||
+ new file mode 100644
|
||||
+ index 0000000..039727e
|
||||
+ --- /dev/null
|
||||
+ +++ b/renamed-symlink/create-me
|
||||
+ @@ -0,0 +1,1 @@
|
||||
+ +busted
|
||||
+ EOF
|
||||
+
|
||||
+ test_must_fail git apply patch 2>stderr &&
|
||||
+ cat >expected_stderr <<-EOF &&
|
||||
+ error: affected file ${SQ}renamed-symlink/create-me${SQ} is beyond a symbolic link
|
||||
+ EOF
|
||||
+ test_cmp expected_stderr stderr &&
|
||||
+ ! test_path_exists .git/create-me
|
||||
+'
|
||||
+
|
||||
+test_expect_success SYMLINKS 'symlink escape when modifying file' '
|
||||
+ test_when_finished "git reset --hard && git clean -dfx" &&
|
||||
+ touch .git/modify-me &&
|
||||
+
|
||||
+ cat >patch <<-EOF &&
|
||||
+ diff --git a/symlink b/renamed-symlink
|
||||
+ similarity index 100%
|
||||
+ rename from symlink
|
||||
+ rename to renamed-symlink
|
||||
+ --
|
||||
+ diff --git a/renamed-symlink/modify-me b/renamed-symlink/modify-me
|
||||
+ index 1111111..2222222 100644
|
||||
+ --- a/renamed-symlink/modify-me
|
||||
+ +++ b/renamed-symlink/modify-me
|
||||
+ @@ -0,0 +1,1 @@
|
||||
+ +busted
|
||||
+ EOF
|
||||
+
|
||||
+ test_must_fail git apply patch 2>stderr &&
|
||||
+ cat >expected_stderr <<-EOF &&
|
||||
+ error: renamed-symlink/modify-me: No such file or directory
|
||||
+ EOF
|
||||
+ test_cmp expected_stderr stderr &&
|
||||
+ test_must_be_empty .git/modify-me
|
||||
+'
|
||||
+
|
||||
+test_expect_success SYMLINKS 'symlink escape when deleting file' '
|
||||
+ test_when_finished "git reset --hard && git clean -dfx && rm .git/delete-me" &&
|
||||
+ touch .git/delete-me &&
|
||||
+
|
||||
+ cat >patch <<-EOF &&
|
||||
+ diff --git a/symlink b/renamed-symlink
|
||||
+ similarity index 100%
|
||||
+ rename from symlink
|
||||
+ rename to renamed-symlink
|
||||
+ --
|
||||
+ diff --git a/renamed-symlink/delete-me b/renamed-symlink/delete-me
|
||||
+ deleted file mode 100644
|
||||
+ index 1111111..0000000 100644
|
||||
+ EOF
|
||||
+
|
||||
+ test_must_fail git apply patch 2>stderr &&
|
||||
+ cat >expected_stderr <<-EOF &&
|
||||
+ error: renamed-symlink/delete-me: No such file or directory
|
||||
+ EOF
|
||||
+ test_cmp expected_stderr stderr &&
|
||||
+ test_path_is_file .git/delete-me
|
||||
+'
|
||||
+
|
||||
test_done
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -11,8 +11,24 @@ 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://fixsort.patch \
|
||||
file://CVE-2021-40330.patch \
|
||||
file://CVE-2022-23521.patch \
|
||||
file://CVE-2022-41903-01.patch \
|
||||
file://CVE-2022-41903-02.patch \
|
||||
file://CVE-2022-41903-03.patch \
|
||||
file://CVE-2022-41903-04.patch \
|
||||
file://CVE-2022-41903-05.patch \
|
||||
file://CVE-2022-41903-06.patch \
|
||||
file://CVE-2022-41903-07.patch \
|
||||
file://CVE-2022-41903-08.patch \
|
||||
file://CVE-2022-41903-09.patch \
|
||||
file://CVE-2022-41903-10.patch \
|
||||
file://CVE-2022-41903-11.patch \
|
||||
file://CVE-2022-41903-12.patch \
|
||||
file://CVE-2023-22490-1.patch \
|
||||
file://CVE-2023-22490-2.patch \
|
||||
file://CVE-2023-22490-3.patch \
|
||||
file://CVE-2023-23946.patch \
|
||||
"
|
||||
|
||||
S = "${WORKDIR}/git-${PV}"
|
||||
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=7c0d7ef03a7eb04ce795b0f60e68e7e1"
|
||||
@@ -23,6 +39,10 @@ CVE_PRODUCT = "git-scm:git"
|
||||
# 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_WHITELIST += "CVE-2022-24975"
|
||||
# This is specific to Git-for-Windows
|
||||
CVE_CHECK_WHITELIST += "CVE-2022-41953"
|
||||
# specific to Git for Windows
|
||||
CVE_CHECK_WHITELIST += "CVE-2023-22743"
|
||||
|
||||
PACKAGECONFIG ??= ""
|
||||
PACKAGECONFIG[cvsserver] = ""
|
||||
|
||||
@@ -52,6 +52,12 @@ SRC_URI += "\
|
||||
file://CVE-2022-41715.patch \
|
||||
file://CVE-2022-41717.patch \
|
||||
file://CVE-2022-1962.patch \
|
||||
file://CVE-2022-41723.patch \
|
||||
file://CVE-2022-41722-1.patch \
|
||||
file://CVE-2022-41722-2.patch \
|
||||
file://CVE-2020-29510.patch \
|
||||
file://CVE-2023-24537.patch \
|
||||
file://CVE-2023-24534.patch \
|
||||
"
|
||||
|
||||
SRC_URI_append_libc-musl = " file://0009-ld-replace-glibc-dynamic-linker-with-musl.patch"
|
||||
@@ -79,3 +85,9 @@ CVE_CHECK_WHITELIST += "CVE-2021-41772"
|
||||
|
||||
# Fixes code that was added in go1.16, does not exist in 1.14
|
||||
CVE_CHECK_WHITELIST += "CVE-2022-30630"
|
||||
|
||||
# This is specific to Microsoft Windows
|
||||
CVE_CHECK_WHITELIST += "CVE-2022-41716"
|
||||
|
||||
# Issue introduced in go1.15beta1, does not exist in 1.14
|
||||
CVE_CHECK_WHITELIST += "CVE-2022-1705"
|
||||
|
||||
65
meta/recipes-devtools/go/go-1.14/CVE-2020-29510.patch
Normal file
65
meta/recipes-devtools/go/go-1.14/CVE-2020-29510.patch
Normal file
@@ -0,0 +1,65 @@
|
||||
From a0bf4d38dc2057d28396594264bbdd43d412de22 Mon Sep 17 00:00:00 2001
|
||||
From: Filippo Valsorda <filippo@golang.org>
|
||||
Date: Tue, 27 Oct 2020 00:21:30 +0100
|
||||
Subject: [PATCH] encoding/xml: replace comments inside directives with a space
|
||||
|
||||
A Directive (like <!ENTITY xxx []>) can't have other nodes nested inside
|
||||
it (in our data structure representation), so there is no way to
|
||||
preserve comments. The previous behavior was to just elide them, which
|
||||
however might change the semantic meaning of the surrounding markup.
|
||||
Instead, replace them with a space which hopefully has the same semantic
|
||||
effect of the comment.
|
||||
|
||||
Directives are not actually a node type in the XML spec, which instead
|
||||
specifies each of them separately (<!ENTITY, <!DOCTYPE, etc.), each with
|
||||
its own grammar. The rules for where and when the comments are allowed
|
||||
are not straightforward, and can't be implemented without implementing
|
||||
custom logic for each of the directives.
|
||||
|
||||
Simply preserving the comments in the body of the directive would be
|
||||
problematic, as there can be unmatched quotes inside the comment.
|
||||
Whether those quotes are considered meaningful semantically or not,
|
||||
other parsers might disagree and interpret the output differently.
|
||||
|
||||
This issue was reported by Juho Nurminen of Mattermost as it leads to
|
||||
round-trip mismatches. See #43168. It's not being fixed in a security
|
||||
release because round-trip stability is not a currently supported
|
||||
security property of encoding/xml, and we don't believe these fixes
|
||||
would be sufficient to reliably guarantee it in the future.
|
||||
|
||||
Fixes CVE-2020-29510
|
||||
Updates #43168
|
||||
|
||||
Change-Id: Icd86c75beff3e1e0689543efebdad10ed5178ce3
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/277893
|
||||
Run-TryBot: Filippo Valsorda <filippo@golang.org>
|
||||
TryBot-Result: Go Bot <gobot@golang.org>
|
||||
Trust: Filippo Valsorda <filippo@golang.org>
|
||||
Reviewed-by: Katie Hockman <katie@golang.org>
|
||||
|
||||
Upstream-Status: Backport from https://github.com/golang/go/commit/a9cfd55e2b09735a25976d1b008a0a3c767494f8
|
||||
CVE: CVE-2020-29510
|
||||
Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com>
|
||||
---
|
||||
src/encoding/xml/xml.go | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
|
||||
index 01a1460..98647b2 100644
|
||||
--- a/src/encoding/xml/xml.go
|
||||
+++ b/src/encoding/xml/xml.go
|
||||
@@ -768,6 +768,12 @@ func (d *Decoder) rawToken() (Token, error) {
|
||||
}
|
||||
b0, b1 = b1, b
|
||||
}
|
||||
+
|
||||
+ // Replace the comment with a space in the returned Directive
|
||||
+ // body, so that markup parts that were separated by the comment
|
||||
+ // (like a "<" and a "!") don't get joined when re-encoding the
|
||||
+ // Directive, taking new semantic meaning.
|
||||
+ d.buf.WriteByte(' ')
|
||||
}
|
||||
}
|
||||
return Directive(d.buf.Bytes()), nil
|
||||
--
|
||||
2.7.4
|
||||
53
meta/recipes-devtools/go/go-1.14/CVE-2022-41722-1.patch
Normal file
53
meta/recipes-devtools/go/go-1.14/CVE-2022-41722-1.patch
Normal file
@@ -0,0 +1,53 @@
|
||||
From 94e0c36694fb044e81381d112fef3692de7cdf52 Mon Sep 17 00:00:00 2001
|
||||
From: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
Date: Fri, 22 Apr 2022 10:07:51 +0900
|
||||
Subject: [PATCH 1/2] path/filepath: do not remove prefix "." when following
|
||||
path contains ":".
|
||||
|
||||
Fixes #52476
|
||||
|
||||
Change-Id: I9eb72ac7dbccd6322d060291f31831dc389eb9bb
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/401595
|
||||
Auto-Submit: Ian Lance Taylor <iant@google.com>
|
||||
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
|
||||
Run-TryBot: Ian Lance Taylor <iant@google.com>
|
||||
Reviewed-by: Ian Lance Taylor <iant@google.com>
|
||||
Reviewed-by: Damien Neil <dneil@google.com>
|
||||
TryBot-Result: Gopher Robot <gobot@golang.org>
|
||||
|
||||
Upstream-Status: Backport from https://github.com/golang/go/commit/9cd1818a7d019c02fa4898b3e45a323e35033290
|
||||
CVE: CVE-2022-41722
|
||||
Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com>
|
||||
---
|
||||
src/path/filepath/path.go | 14 +++++++++++++-
|
||||
1 file changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
|
||||
index 26f1833..92dc090 100644
|
||||
--- a/src/path/filepath/path.go
|
||||
+++ b/src/path/filepath/path.go
|
||||
@@ -116,9 +116,21 @@ func Clean(path string) string {
|
||||
case os.IsPathSeparator(path[r]):
|
||||
// empty path element
|
||||
r++
|
||||
- case path[r] == '.' && (r+1 == n || os.IsPathSeparator(path[r+1])):
|
||||
+ case path[r] == '.' && r+1 == n:
|
||||
// . element
|
||||
r++
|
||||
+ case path[r] == '.' && os.IsPathSeparator(path[r+1]):
|
||||
+ // ./ element
|
||||
+ r++
|
||||
+
|
||||
+ for r < len(path) && os.IsPathSeparator(path[r]) {
|
||||
+ r++
|
||||
+ }
|
||||
+ if out.w == 0 && volumeNameLen(path[r:]) > 0 {
|
||||
+ // When joining prefix "." and an absolute path on Windows,
|
||||
+ // the prefix should not be removed.
|
||||
+ out.append('.')
|
||||
+ }
|
||||
case path[r] == '.' && path[r+1] == '.' && (r+2 == n || os.IsPathSeparator(path[r+2])):
|
||||
// .. element: remove to last separator
|
||||
r += 2
|
||||
--
|
||||
2.7.4
|
||||
104
meta/recipes-devtools/go/go-1.14/CVE-2022-41722-2.patch
Normal file
104
meta/recipes-devtools/go/go-1.14/CVE-2022-41722-2.patch
Normal file
@@ -0,0 +1,104 @@
|
||||
From b8803cb711ae163b8e67897deb6cf8c49702227c Mon Sep 17 00:00:00 2001
|
||||
From: Damien Neil <dneil@google.com>
|
||||
Date: Mon, 12 Dec 2022 16:43:37 -0800
|
||||
Subject: [PATCH 2/2] path/filepath: do not Clean("a/../c:/b") into c:\b on
|
||||
Windows
|
||||
|
||||
Do not permit Clean to convert a relative path into one starting
|
||||
with a drive reference. This change causes Clean to insert a .
|
||||
path element at the start of a path when the original path does not
|
||||
start with a volume name, and the first path element would contain
|
||||
a colon.
|
||||
|
||||
This may introduce a spurious but harmless . path element under
|
||||
some circumstances. For example, Clean("a/../b:/../c") becomes `.\c`.
|
||||
|
||||
This reverts CL 401595, since the change here supersedes the one
|
||||
in that CL.
|
||||
|
||||
Thanks to RyotaK (https://twitter.com/ryotkak) for reporting this issue.
|
||||
|
||||
Updates #57274
|
||||
Fixes #57276
|
||||
Fixes CVE-2022-41722
|
||||
|
||||
Change-Id: I837446285a03aa74c79d7642720e01f354c2ca17
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1675249
|
||||
Reviewed-by: Roland Shoemaker <bracewell@google.com>
|
||||
Run-TryBot: Damien Neil <dneil@google.com>
|
||||
Reviewed-by: Julie Qiu <julieqiu@google.com>
|
||||
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
|
||||
(cherry picked from commit 8ca37f4813ef2f64600c92b83f17c9f3ca6c03a5)
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1728944
|
||||
Run-TryBot: Roland Shoemaker <bracewell@google.com>
|
||||
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
|
||||
Reviewed-by: Damien Neil <dneil@google.com>
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/468119
|
||||
Reviewed-by: Than McIntosh <thanm@google.com>
|
||||
Run-TryBot: Michael Pratt <mpratt@google.com>
|
||||
TryBot-Result: Gopher Robot <gobot@golang.org>
|
||||
Auto-Submit: Michael Pratt <mpratt@google.com>
|
||||
|
||||
Upstream-Status: Backport from https://github.com/golang/go/commit/bdf07c2e168baf736e4c057279ca12a4d674f18c
|
||||
CVE: CVE-2022-41722
|
||||
Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com>
|
||||
---
|
||||
src/path/filepath/path.go | 27 ++++++++++++++-------------
|
||||
1 file changed, 14 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
|
||||
index 92dc090..f0f095e 100644
|
||||
--- a/src/path/filepath/path.go
|
||||
+++ b/src/path/filepath/path.go
|
||||
@@ -14,6 +14,7 @@ package filepath
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
+ "runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
@@ -116,21 +117,9 @@ func Clean(path string) string {
|
||||
case os.IsPathSeparator(path[r]):
|
||||
// empty path element
|
||||
r++
|
||||
- case path[r] == '.' && r+1 == n:
|
||||
+ case path[r] == '.' && (r+1 == n || os.IsPathSeparator(path[r+1])):
|
||||
// . element
|
||||
r++
|
||||
- case path[r] == '.' && os.IsPathSeparator(path[r+1]):
|
||||
- // ./ element
|
||||
- r++
|
||||
-
|
||||
- for r < len(path) && os.IsPathSeparator(path[r]) {
|
||||
- r++
|
||||
- }
|
||||
- if out.w == 0 && volumeNameLen(path[r:]) > 0 {
|
||||
- // When joining prefix "." and an absolute path on Windows,
|
||||
- // the prefix should not be removed.
|
||||
- out.append('.')
|
||||
- }
|
||||
case path[r] == '.' && path[r+1] == '.' && (r+2 == n || os.IsPathSeparator(path[r+2])):
|
||||
// .. element: remove to last separator
|
||||
r += 2
|
||||
@@ -156,6 +145,18 @@ func Clean(path string) string {
|
||||
if rooted && out.w != 1 || !rooted && out.w != 0 {
|
||||
out.append(Separator)
|
||||
}
|
||||
+ // If a ':' appears in the path element at the start of a Windows path,
|
||||
+ // insert a .\ at the beginning to avoid converting relative paths
|
||||
+ // like a/../c: into c:.
|
||||
+ if runtime.GOOS == "windows" && out.w == 0 && out.volLen == 0 && r != 0 {
|
||||
+ for i := r; i < n && !os.IsPathSeparator(path[i]); i++ {
|
||||
+ if path[i] == ':' {
|
||||
+ out.append('.')
|
||||
+ out.append(Separator)
|
||||
+ break
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
// copy element
|
||||
for ; r < n && !os.IsPathSeparator(path[r]); r++ {
|
||||
out.append(path[r])
|
||||
--
|
||||
2.7.4
|
||||
156
meta/recipes-devtools/go/go-1.14/CVE-2022-41723.patch
Normal file
156
meta/recipes-devtools/go/go-1.14/CVE-2022-41723.patch
Normal file
@@ -0,0 +1,156 @@
|
||||
From 451766789f646617157c725e20c955d4a9a70d4e Mon Sep 17 00:00:00 2001
|
||||
From: Roland Shoemaker <bracewell@google.com>
|
||||
Date: Mon, 6 Feb 2023 10:03:44 -0800
|
||||
Subject: [PATCH] net/http: update bundled golang.org/x/net/http2
|
||||
|
||||
Disable cmd/internal/moddeps test, since this update includes PRIVATE
|
||||
track fixes.
|
||||
|
||||
Fixes CVE-2022-41723
|
||||
Fixes #58355
|
||||
Updates #57855
|
||||
|
||||
Change-Id: Ie870562a6f6e44e4e8f57db6a0dde1a41a2b090c
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1728939
|
||||
Reviewed-by: Damien Neil <dneil@google.com>
|
||||
Reviewed-by: Julie Qiu <julieqiu@google.com>
|
||||
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
|
||||
Run-TryBot: Roland Shoemaker <bracewell@google.com>
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/468118
|
||||
TryBot-Result: Gopher Robot <gobot@golang.org>
|
||||
Run-TryBot: Michael Pratt <mpratt@google.com>
|
||||
Auto-Submit: Michael Pratt <mpratt@google.com>
|
||||
Reviewed-by: Than McIntosh <thanm@google.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/golang/go/commit/5c3e11bd0b5c0a86e5beffcd4339b86a902b21c3]
|
||||
CVE: CVE-2022-41723
|
||||
Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com>
|
||||
---
|
||||
src/vendor/golang.org/x/net/http2/hpack/hpack.go | 79 +++++++++++++++---------
|
||||
1 file changed, 49 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/src/vendor/golang.org/x/net/http2/hpack/hpack.go b/src/vendor/golang.org/x/net/http2/hpack/hpack.go
|
||||
index 85f18a2..02e80e3 100644
|
||||
--- a/src/vendor/golang.org/x/net/http2/hpack/hpack.go
|
||||
+++ b/src/vendor/golang.org/x/net/http2/hpack/hpack.go
|
||||
@@ -359,6 +359,7 @@ func (d *Decoder) parseFieldLiteral(n uint8, it indexType) error {
|
||||
|
||||
var hf HeaderField
|
||||
wantStr := d.emitEnabled || it.indexed()
|
||||
+ var undecodedName undecodedString
|
||||
if nameIdx > 0 {
|
||||
ihf, ok := d.at(nameIdx)
|
||||
if !ok {
|
||||
@@ -366,15 +367,27 @@ func (d *Decoder) parseFieldLiteral(n uint8, it indexType) error {
|
||||
}
|
||||
hf.Name = ihf.Name
|
||||
} else {
|
||||
- hf.Name, buf, err = d.readString(buf, wantStr)
|
||||
+ undecodedName, buf, err = d.readString(buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
- hf.Value, buf, err = d.readString(buf, wantStr)
|
||||
+ undecodedValue, buf, err := d.readString(buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
+ if wantStr {
|
||||
+ if nameIdx <= 0 {
|
||||
+ hf.Name, err = d.decodeString(undecodedName)
|
||||
+ if err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ }
|
||||
+ hf.Value, err = d.decodeString(undecodedValue)
|
||||
+ if err != nil {
|
||||
+ return err
|
||||
+ }
|
||||
+ }
|
||||
d.buf = buf
|
||||
if it.indexed() {
|
||||
d.dynTab.add(hf)
|
||||
@@ -459,46 +472,52 @@ func readVarInt(n byte, p []byte) (i uint64, remain []byte, err error) {
|
||||
return 0, origP, errNeedMore
|
||||
}
|
||||
|
||||
-// readString decodes an hpack string from p.
|
||||
+// readString reads an hpack string from p.
|
||||
//
|
||||
-// wantStr is whether s will be used. If false, decompression and
|
||||
-// []byte->string garbage are skipped if s will be ignored
|
||||
-// anyway. This does mean that huffman decoding errors for non-indexed
|
||||
-// strings past the MAX_HEADER_LIST_SIZE are ignored, but the server
|
||||
-// is returning an error anyway, and because they're not indexed, the error
|
||||
-// won't affect the decoding state.
|
||||
-func (d *Decoder) readString(p []byte, wantStr bool) (s string, remain []byte, err error) {
|
||||
+// It returns a reference to the encoded string data to permit deferring decode costs
|
||||
+// until after the caller verifies all data is present.
|
||||
+func (d *Decoder) readString(p []byte) (u undecodedString, remain []byte, err error) {
|
||||
if len(p) == 0 {
|
||||
- return "", p, errNeedMore
|
||||
+ return u, p, errNeedMore
|
||||
}
|
||||
isHuff := p[0]&128 != 0
|
||||
strLen, p, err := readVarInt(7, p)
|
||||
if err != nil {
|
||||
- return "", p, err
|
||||
+ return u, p, err
|
||||
}
|
||||
if d.maxStrLen != 0 && strLen > uint64(d.maxStrLen) {
|
||||
- return "", nil, ErrStringLength
|
||||
+ // Returning an error here means Huffman decoding errors
|
||||
+ // for non-indexed strings past the maximum string length
|
||||
+ // are ignored, but the server is returning an error anyway
|
||||
+ // and because the string is not indexed the error will not
|
||||
+ // affect the decoding state.
|
||||
+ return u, nil, ErrStringLength
|
||||
}
|
||||
if uint64(len(p)) < strLen {
|
||||
- return "", p, errNeedMore
|
||||
- }
|
||||
- if !isHuff {
|
||||
- if wantStr {
|
||||
- s = string(p[:strLen])
|
||||
- }
|
||||
- return s, p[strLen:], nil
|
||||
+ return u, p, errNeedMore
|
||||
}
|
||||
+ u.isHuff = isHuff
|
||||
+ u.b = p[:strLen]
|
||||
+ return u, p[strLen:], nil
|
||||
+}
|
||||
|
||||
- if wantStr {
|
||||
- buf := bufPool.Get().(*bytes.Buffer)
|
||||
- buf.Reset() // don't trust others
|
||||
- defer bufPool.Put(buf)
|
||||
- if err := huffmanDecode(buf, d.maxStrLen, p[:strLen]); err != nil {
|
||||
- buf.Reset()
|
||||
- return "", nil, err
|
||||
- }
|
||||
+type undecodedString struct {
|
||||
+ isHuff bool
|
||||
+ b []byte
|
||||
+}
|
||||
+
|
||||
+func (d *Decoder) decodeString(u undecodedString) (string, error) {
|
||||
+ if !u.isHuff {
|
||||
+ return string(u.b), nil
|
||||
+ }
|
||||
+ buf := bufPool.Get().(*bytes.Buffer)
|
||||
+ buf.Reset() // don't trust others
|
||||
+ var s string
|
||||
+ err := huffmanDecode(buf, d.maxStrLen, u.b)
|
||||
+ if err == nil {
|
||||
s = buf.String()
|
||||
- buf.Reset() // be nice to GC
|
||||
}
|
||||
- return s, p[strLen:], nil
|
||||
+ buf.Reset() // be nice to GC
|
||||
+ bufPool.Put(buf)
|
||||
+ return s, err
|
||||
}
|
||||
--
|
||||
2.7.4
|
||||
200
meta/recipes-devtools/go/go-1.14/CVE-2023-24534.patch
Normal file
200
meta/recipes-devtools/go/go-1.14/CVE-2023-24534.patch
Normal file
@@ -0,0 +1,200 @@
|
||||
From d6759e7a059f4208f07aa781402841d7ddaaef96 Mon Sep 17 00:00:00 2001
|
||||
From: Damien Neil <dneil@google.com>
|
||||
Date: Fri, 10 Mar 2023 14:21:05 -0800
|
||||
Subject: [PATCH] [release-branch.go1.19] net/textproto: avoid overpredicting
|
||||
the number of MIME header keys
|
||||
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802452
|
||||
Run-TryBot: Damien Neil <dneil@google.com>
|
||||
Reviewed-by: Roland Shoemaker <bracewell@google.com>
|
||||
Reviewed-by: Julie Qiu <julieqiu@google.com>
|
||||
(cherry picked from commit f739f080a72fd5b06d35c8e244165159645e2ed6)
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802393
|
||||
Reviewed-by: Damien Neil <dneil@google.com>
|
||||
Run-TryBot: Roland Shoemaker <bracewell@google.com>
|
||||
Change-Id: I675451438d619a9130360c56daf529559004903f
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/481982
|
||||
Run-TryBot: Michael Knyszek <mknyszek@google.com>
|
||||
TryBot-Result: Gopher Robot <gobot@golang.org>
|
||||
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
||||
Auto-Submit: Michael Knyszek <mknyszek@google.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/golang/go/commit/d6759e7a059f4208f07aa781402841d7ddaaef96]
|
||||
CVE: CVE-2023-24534
|
||||
Signed-off-by: Vivek Kumbhar <vkumbhar@mvista.com>
|
||||
---
|
||||
src/bytes/bytes.go | 13 +++++++
|
||||
src/net/textproto/reader.go | 31 +++++++++++------
|
||||
src/net/textproto/reader_test.go | 59 ++++++++++++++++++++++++++++++++
|
||||
3 files changed, 92 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go
|
||||
index e872cc2..1f0d760 100644
|
||||
--- a/src/bytes/bytes.go
|
||||
+++ b/src/bytes/bytes.go
|
||||
@@ -1078,6 +1078,19 @@ func Index(s, sep []byte) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
+// Cut slices s around the first instance of sep,
|
||||
+// returning the text before and after sep.
|
||||
+// The found result reports whether sep appears in s.
|
||||
+// If sep does not appear in s, cut returns s, nil, false.
|
||||
+//
|
||||
+// Cut returns slices of the original slice s, not copies.
|
||||
+func Cut(s, sep []byte) (before, after []byte, found bool) {
|
||||
+ if i := Index(s, sep); i >= 0 {
|
||||
+ return s[:i], s[i+len(sep):], true
|
||||
+ }
|
||||
+ return s, nil, false
|
||||
+}
|
||||
+
|
||||
func indexRabinKarp(s, sep []byte) int {
|
||||
// Rabin-Karp search
|
||||
hashsep, pow := hashStr(sep)
|
||||
diff --git a/src/net/textproto/reader.go b/src/net/textproto/reader.go
|
||||
index a505da9..8d547fe 100644
|
||||
--- a/src/net/textproto/reader.go
|
||||
+++ b/src/net/textproto/reader.go
|
||||
@@ -486,8 +487,11 @@ func (r *Reader) ReadMIMEHeader() (MIMEHeader, error) {
|
||||
// large one ahead of time which we'll cut up into smaller
|
||||
// slices. If this isn't big enough later, we allocate small ones.
|
||||
var strs []string
|
||||
- hint := r.upcomingHeaderNewlines()
|
||||
+ hint := r.upcomingHeaderKeys()
|
||||
if hint > 0 {
|
||||
+ if hint > 1000 {
|
||||
+ hint = 1000 // set a cap to avoid overallocation
|
||||
+ }
|
||||
strs = make([]string, hint)
|
||||
}
|
||||
|
||||
@@ -562,9 +566,11 @@ func mustHaveFieldNameColon(line []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
-// upcomingHeaderNewlines returns an approximation of the number of newlines
|
||||
+var nl = []byte("\n")
|
||||
+
|
||||
+// upcomingHeaderKeys returns an approximation of the number of keys
|
||||
// that will be in this header. If it gets confused, it returns 0.
|
||||
-func (r *Reader) upcomingHeaderNewlines() (n int) {
|
||||
+func (r *Reader) upcomingHeaderKeys() (n int) {
|
||||
// Try to determine the 'hint' size.
|
||||
r.R.Peek(1) // force a buffer load if empty
|
||||
s := r.R.Buffered()
|
||||
@@ -572,17 +578,20 @@ func (r *Reader) upcomingHeaderNewlines() (n int) {
|
||||
return
|
||||
}
|
||||
peek, _ := r.R.Peek(s)
|
||||
- for len(peek) > 0 {
|
||||
- i := bytes.IndexByte(peek, '\n')
|
||||
- if i < 3 {
|
||||
- // Not present (-1) or found within the next few bytes,
|
||||
- // implying we're at the end ("\r\n\r\n" or "\n\n")
|
||||
- return
|
||||
+ for len(peek) > 0 && n < 1000 {
|
||||
+ var line []byte
|
||||
+ line, peek, _ = bytes.Cut(peek, nl)
|
||||
+ if len(line) == 0 || (len(line) == 1 && line[0] == '\r') {
|
||||
+ // Blank line separating headers from the body.
|
||||
+ break
|
||||
+ }
|
||||
+ if line[0] == ' ' || line[0] == '\t' {
|
||||
+ // Folded continuation of the previous line.
|
||||
+ continue
|
||||
}
|
||||
n++
|
||||
- peek = peek[i+1:]
|
||||
}
|
||||
- return
|
||||
+ return n
|
||||
}
|
||||
|
||||
// CanonicalMIMEHeaderKey returns the canonical format of the
|
||||
diff --git a/src/net/textproto/reader_test.go b/src/net/textproto/reader_test.go
|
||||
index 3124d43..3ae0de1 100644
|
||||
--- a/src/net/textproto/reader_test.go
|
||||
+++ b/src/net/textproto/reader_test.go
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"reflect"
|
||||
+ "runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -127,6 +128,42 @@ func TestReadMIMEHeaderSingle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
+// TestReaderUpcomingHeaderKeys is testing an internal function, but it's very
|
||||
+// difficult to test well via the external API.
|
||||
+func TestReaderUpcomingHeaderKeys(t *testing.T) {
|
||||
+ for _, test := range []struct {
|
||||
+ input string
|
||||
+ want int
|
||||
+ }{{
|
||||
+ input: "",
|
||||
+ want: 0,
|
||||
+ }, {
|
||||
+ input: "A: v",
|
||||
+ want: 1,
|
||||
+ }, {
|
||||
+ input: "A: v\r\nB: v\r\n",
|
||||
+ want: 2,
|
||||
+ }, {
|
||||
+ input: "A: v\nB: v\n",
|
||||
+ want: 2,
|
||||
+ }, {
|
||||
+ input: "A: v\r\n continued\r\n still continued\r\nB: v\r\n\r\n",
|
||||
+ want: 2,
|
||||
+ }, {
|
||||
+ input: "A: v\r\n\r\nB: v\r\nC: v\r\n",
|
||||
+ want: 1,
|
||||
+ }, {
|
||||
+ input: "A: v" + strings.Repeat("\n", 1000),
|
||||
+ want: 1,
|
||||
+ }} {
|
||||
+ r := reader(test.input)
|
||||
+ got := r.upcomingHeaderKeys()
|
||||
+ if test.want != got {
|
||||
+ t.Fatalf("upcomingHeaderKeys(%q): %v; want %v", test.input, got, test.want)
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
func TestReadMIMEHeaderNoKey(t *testing.T) {
|
||||
r := reader(": bar\ntest-1: 1\n\n")
|
||||
m, err := r.ReadMIMEHeader()
|
||||
@@ -223,6 +260,28 @@ func TestReadMIMEHeaderTrimContinued(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
+// Test that reading a header doesn't overallocate. Issue 58975.
|
||||
+func TestReadMIMEHeaderAllocations(t *testing.T) {
|
||||
+ var totalAlloc uint64
|
||||
+ const count = 200
|
||||
+ for i := 0; i < count; i++ {
|
||||
+ r := reader("A: b\r\n\r\n" + strings.Repeat("\n", 4096))
|
||||
+ var m1, m2 runtime.MemStats
|
||||
+ runtime.ReadMemStats(&m1)
|
||||
+ _, err := r.ReadMIMEHeader()
|
||||
+ if err != nil {
|
||||
+ t.Fatalf("ReadMIMEHeader: %v", err)
|
||||
+ }
|
||||
+ runtime.ReadMemStats(&m2)
|
||||
+ totalAlloc += m2.TotalAlloc - m1.TotalAlloc
|
||||
+ }
|
||||
+ // 32k is large and we actually allocate substantially less,
|
||||
+ // but prior to the fix for #58975 we allocated ~400k in this case.
|
||||
+ if got, want := totalAlloc/count, uint64(32768); got > want {
|
||||
+ t.Fatalf("ReadMIMEHeader allocated %v bytes, want < %v", got, want)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
type readResponseTest struct {
|
||||
in string
|
||||
inCode int
|
||||
--
|
||||
2.25.1
|
||||
76
meta/recipes-devtools/go/go-1.14/CVE-2023-24537.patch
Normal file
76
meta/recipes-devtools/go/go-1.14/CVE-2023-24537.patch
Normal file
@@ -0,0 +1,76 @@
|
||||
From bf8c7c575c8a552d9d79deb29e80854dc88528d0 Mon Sep 17 00:00:00 2001
|
||||
From: Damien Neil <dneil@google.com>
|
||||
Date: Mon, 20 Mar 2023 10:43:19 -0700
|
||||
Subject: [PATCH] [release-branch.go1.20] mime/multipart: limit parsed mime
|
||||
message sizes
|
||||
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802456
|
||||
Reviewed-by: Julie Qiu <julieqiu@google.com>
|
||||
Reviewed-by: Roland Shoemaker <bracewell@google.com>
|
||||
Run-TryBot: Damien Neil <dneil@google.com>
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802611
|
||||
Reviewed-by: Damien Neil <dneil@google.com>
|
||||
Change-Id: Ifdfa192d54f722d781a4d8c5f35b5fb72d122168
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/481986
|
||||
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
||||
TryBot-Result: Gopher Robot <gobot@golang.org>
|
||||
Run-TryBot: Michael Knyszek <mknyszek@google.com>
|
||||
Auto-Submit: Michael Knyszek <mknyszek@google.com>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/golang/go/commit/126a1d02da82f93ede7ce0bd8d3c51ef627f2104]
|
||||
CVE: CVE-2023-24537
|
||||
Signed-off-by: Vivek Kumbhar <vkumbhar@mvista.com>
|
||||
---
|
||||
src/go/parser/parser_test.go | 16 ++++++++++++++++
|
||||
src/go/scanner/scanner.go | 5 ++++-
|
||||
2 files changed, 20 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/go/parser/parser_test.go b/src/go/parser/parser_test.go
|
||||
index 37a6a2b..714557c 100644
|
||||
--- a/src/go/parser/parser_test.go
|
||||
+++ b/src/go/parser/parser_test.go
|
||||
@@ -738,3 +738,19 @@ func TestScopeDepthLimit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+// TestIssue59180 tests that line number overflow doesn't cause an infinite loop.
|
||||
+func TestIssue59180(t *testing.T) {
|
||||
+ testcases := []string{
|
||||
+ "package p\n//line :9223372036854775806\n\n//",
|
||||
+ "package p\n//line :1:9223372036854775806\n\n//",
|
||||
+ "package p\n//line file:9223372036854775806\n\n//",
|
||||
+ }
|
||||
+
|
||||
+ for _, src := range testcases {
|
||||
+ _, err := ParseFile(token.NewFileSet(), "", src, ParseComments)
|
||||
+ if err == nil {
|
||||
+ t.Errorf("ParseFile(%s) succeeded unexpectedly", src)
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/go/scanner/scanner.go b/src/go/scanner/scanner.go
|
||||
index 00fe2dc..3159d25 100644
|
||||
--- a/src/go/scanner/scanner.go
|
||||
+++ b/src/go/scanner/scanner.go
|
||||
@@ -246,13 +246,16 @@ func (s *Scanner) updateLineInfo(next, offs int, text []byte) {
|
||||
return
|
||||
}
|
||||
|
||||
+ // Put a cap on the maximum size of line and column numbers.
|
||||
+ // 30 bits allows for some additional space before wrapping an int32.
|
||||
+ const maxLineCol = 1<<30 - 1
|
||||
var line, col int
|
||||
i2, n2, ok2 := trailingDigits(text[:i-1])
|
||||
if ok2 {
|
||||
//line filename:line:col
|
||||
i, i2 = i2, i
|
||||
line, col = n2, n
|
||||
- if col == 0 {
|
||||
+ if col == 0 || col > maxLineCol {
|
||||
s.error(offs+i2, "invalid column number: "+string(text[i2:]))
|
||||
return
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -7,8 +7,8 @@ export CGO_ENABLED_riscv64 = ""
|
||||
# windows/mips/riscv doesn't support -buildmode=pie, so skip the QA checking
|
||||
# for windows/mips/riscv and their variants.
|
||||
python() {
|
||||
if 'mips' in d.getVar('TARGET_ARCH',True) or 'riscv' in d.getVar('TARGET_ARCH',True) or 'windows' in d.getVar('TARGET_GOOS', True):
|
||||
d.appendVar('INSANE_SKIP_%s' % d.getVar('PN',True), " textrel")
|
||||
if 'mips' in d.getVar('TARGET_ARCH') or 'riscv' in d.getVar('TARGET_ARCH') or 'windows' in d.getVar('TARGET_GOOS'):
|
||||
d.appendVar('INSANE_SKIP_%s' % d.getVar('PN'), " textrel")
|
||||
else:
|
||||
d.setVar('GOBUILDMODE', 'pie')
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ DEPENDS = "glib-2.0-native zlib-native pixman-native qemu-native bison-native"
|
||||
|
||||
EXTRA_OECONF_append = " --target-list=${@get_qemu_system_target_list(d)}"
|
||||
|
||||
PACKAGECONFIG ??= "fdt alsa kvm"
|
||||
PACKAGECONFIG ??= "fdt alsa kvm slirp"
|
||||
|
||||
# Handle distros such as CentOS 5 32-bit that do not have kvm support
|
||||
PACKAGECONFIG_remove = "${@'kvm' if not os.path.exists('/usr/include/linux/kvm.h') else ''}"
|
||||
|
||||
@@ -112,9 +112,31 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
|
||||
file://CVE-2022-0216-1.patch \
|
||||
file://CVE-2022-0216-2.patch \
|
||||
file://CVE-2021-3750.patch \
|
||||
file://CVE-2021-3638.patch \
|
||||
file://CVE-2021-20196.patch \
|
||||
file://CVE-2021-3507.patch \
|
||||
file://CVE-2021-3638.patch \
|
||||
file://CVE-2021-20196.patch \
|
||||
file://CVE-2021-3507.patch \
|
||||
file://hw-block-nvme-refactor-nvme_addr_read.patch \
|
||||
file://hw-block-nvme-handle-dma-errors.patch \
|
||||
file://CVE-2021-3929.patch \
|
||||
file://CVE-2022-4144.patch \
|
||||
file://CVE-2020-15859.patch \
|
||||
file://CVE-2020-15469-1.patch \
|
||||
file://CVE-2020-15469-2.patch \
|
||||
file://CVE-2020-15469-3.patch \
|
||||
file://CVE-2020-15469-4.patch \
|
||||
file://CVE-2020-15469-5.patch \
|
||||
file://CVE-2020-15469-6.patch \
|
||||
file://CVE-2020-15469-7.patch \
|
||||
file://CVE-2020-15469-8.patch \
|
||||
file://CVE-2020-35504.patch \
|
||||
file://CVE-2020-35505.patch \
|
||||
file://CVE-2022-26354.patch \
|
||||
file://CVE-2021-3409-1.patch \
|
||||
file://CVE-2021-3409-2.patch \
|
||||
file://CVE-2021-3409-3.patch \
|
||||
file://CVE-2021-3409-4.patch \
|
||||
file://CVE-2021-3409-5.patch \
|
||||
file://hw-display-qxl-Pass-requested-buffer-size-to-qxl_phy.patch \
|
||||
"
|
||||
UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
|
||||
|
||||
@@ -135,6 +157,11 @@ CVE_CHECK_WHITELIST += "CVE-2018-18438"
|
||||
# the issue introduced in v5.1.0-rc0
|
||||
CVE_CHECK_WHITELIST += "CVE-2020-27661"
|
||||
|
||||
# As per https://nvd.nist.gov/vuln/detail/CVE-2023-0664
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=2167423
|
||||
# this bug related to windows specific.
|
||||
CVE_CHECK_WHITELIST += "CVE-2023-0664"
|
||||
|
||||
COMPATIBLE_HOST_mipsarchn32 = "null"
|
||||
COMPATIBLE_HOST_mipsarchn64 = "null"
|
||||
|
||||
@@ -279,6 +306,8 @@ PACKAGECONFIG[capstone] = "--enable-capstone,--disable-capstone"
|
||||
PACKAGECONFIG[libnfs] = "--enable-libnfs,--disable-libnfs,libnfs"
|
||||
PACKAGECONFIG[brlapi] = "--enable-brlapi,--disable-brlapi"
|
||||
PACKAGECONFIG[vde] = "--enable-vde,--disable-vde"
|
||||
# version 4.2.0 doesn't have an "internal" option for enable-slirp, so use "git" which uses the same configure code path
|
||||
PACKAGECONFIG[slirp] = "--enable-slirp=git,--disable-slirp"
|
||||
PACKAGECONFIG[rbd] = "--enable-rbd,--disable-rbd"
|
||||
PACKAGECONFIG[rdma] = "--enable-rdma,--disable-rdma"
|
||||
|
||||
|
||||
50
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-1.patch
Normal file
50
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-1.patch
Normal file
@@ -0,0 +1,50 @@
|
||||
From 520f26fc6d17b71a43eaf620e834b3bdf316f3d3 Mon Sep 17 00:00:00 2001
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Date: Tue, 11 Aug 2020 17:11:25 +0530
|
||||
Subject: [PATCH] hw/pci-host: add pci-intack write method
|
||||
|
||||
Add pci-intack mmio write method to avoid NULL pointer dereference
|
||||
issue.
|
||||
|
||||
Reported-by: Lei Sun <slei.casper@gmail.com>
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Message-Id: <20200811114133.672647-2-ppandit@redhat.com>
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15469
|
||||
Upstream-Status: Backport [import from ubuntu
|
||||
https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-15469-1.patch?h=ubuntu/focal-security
|
||||
Upstream commit https://github.com/qemu/qemu/commit/520f26fc6d17b71a43eaf620e834b3bdf316f3d3 ]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/pci-host/prep.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
--- a/hw/pci-host/prep.c
|
||||
+++ b/hw/pci-host/prep.c
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu-common.h"
|
||||
#include "qemu/units.h"
|
||||
+#include "qemu/log.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "hw/pci/pci_bus.h"
|
||||
@@ -119,8 +120,15 @@ static uint64_t raven_intack_read(void *
|
||||
return pic_read_irq(isa_pic);
|
||||
}
|
||||
|
||||
+static void raven_intack_write(void *opaque, hwaddr addr,
|
||||
+ uint64_t data, unsigned size)
|
||||
+{
|
||||
+ qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
|
||||
+}
|
||||
+
|
||||
static const MemoryRegionOps raven_intack_ops = {
|
||||
.read = raven_intack_read,
|
||||
+ .write = raven_intack_write,
|
||||
.valid = {
|
||||
.max_access_size = 1,
|
||||
},
|
||||
69
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-2.patch
Normal file
69
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-2.patch
Normal file
@@ -0,0 +1,69 @@
|
||||
From 4f2a5202a05fc1612954804a2482f07bff105ea2 Mon Sep 17 00:00:00 2001
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Date: Tue, 11 Aug 2020 17:11:26 +0530
|
||||
Subject: [PATCH] pci-host: designware: add pcie-msi read method
|
||||
|
||||
Add pcie-msi mmio read method to avoid NULL pointer dereference
|
||||
issue.
|
||||
|
||||
Reported-by: Lei Sun <slei.casper@gmail.com>
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Message-Id: <20200811114133.672647-3-ppandit@redhat.com>
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15469
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-15469-2.patch?h=ubuntu/focal-security Upstream Commit https://github.com/qemu/qemu/commit/4f2a5202a05fc1612954804a2482f07bff105ea2]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/pci-host/designware.c | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
|
||||
index f9fb97a..bde3a34 100644
|
||||
--- a/hw/pci-host/designware.c
|
||||
+++ b/hw/pci-host/designware.c
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/module.h"
|
||||
+#include "qemu/log.h"
|
||||
#include "hw/pci/msi.h"
|
||||
#include "hw/pci/pci_bridge.h"
|
||||
#include "hw/pci/pci_host.h"
|
||||
@@ -63,6 +64,23 @@ designware_pcie_root_to_host(DesignwarePCIERoot *root)
|
||||
return DESIGNWARE_PCIE_HOST(bus->parent);
|
||||
}
|
||||
|
||||
+static uint64_t designware_pcie_root_msi_read(void *opaque, hwaddr addr,
|
||||
+ unsigned size)
|
||||
+{
|
||||
+ /*
|
||||
+ * Attempts to read from the MSI address are undefined in
|
||||
+ * the PCI specifications. For this hardware, the datasheet
|
||||
+ * specifies that a read from the magic address is simply not
|
||||
+ * intercepted by the MSI controller, and will go out to the
|
||||
+ * AHB/AXI bus like any other PCI-device-initiated DMA read.
|
||||
+ * This is not trivial to implement in QEMU, so since
|
||||
+ * well-behaved guests won't ever ask a PCI device to DMA from
|
||||
+ * this address we just log the missing functionality.
|
||||
+ */
|
||||
+ qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void designware_pcie_root_msi_write(void *opaque, hwaddr addr,
|
||||
uint64_t val, unsigned len)
|
||||
{
|
||||
@@ -77,6 +95,7 @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr,
|
||||
}
|
||||
|
||||
static const MemoryRegionOps designware_pci_host_msi_ops = {
|
||||
+ .read = designware_pcie_root_msi_read,
|
||||
.write = designware_pcie_root_msi_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
49
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-3.patch
Normal file
49
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-3.patch
Normal file
@@ -0,0 +1,49 @@
|
||||
From 24202d2b561c3b4c48bd28383c8c34b4ac66c2bf Mon Sep 17 00:00:00 2001
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Date: Tue, 11 Aug 2020 17:11:27 +0530
|
||||
Subject: [PATCH] vfio: add quirk device write method
|
||||
|
||||
Add vfio quirk device mmio write method to avoid NULL pointer
|
||||
dereference issue.
|
||||
|
||||
Reported-by: Lei Sun <slei.casper@gmail.com>
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Acked-by: Alex Williamson <alex.williamson@redhat.com>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Message-Id: <20200811114133.672647-4-ppandit@redhat.com>
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15469
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-15469-3.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/24202d2b561c3b4c48bd28383c8c34b4ac66c2bf]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/vfio/pci-quirks.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
--- a/hw/vfio/pci-quirks.c
|
||||
+++ b/hw/vfio/pci-quirks.c
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "exec/memop.h"
|
||||
#include "qemu/units.h"
|
||||
+#include "qemu/log.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/module.h"
|
||||
@@ -278,8 +279,15 @@ static uint64_t vfio_ati_3c3_quirk_read(
|
||||
return data;
|
||||
}
|
||||
|
||||
+static void vfio_ati_3c3_quirk_write(void *opaque, hwaddr addr,
|
||||
+ uint64_t data, unsigned size)
|
||||
+{
|
||||
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid access\n", __func__);
|
||||
+}
|
||||
+
|
||||
static const MemoryRegionOps vfio_ati_3c3_quirk = {
|
||||
.read = vfio_ati_3c3_quirk_read,
|
||||
+ .write = vfio_ati_3c3_quirk_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
53
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-4.patch
Normal file
53
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-4.patch
Normal file
@@ -0,0 +1,53 @@
|
||||
From f867cebaedbc9c43189f102e4cdfdff05e88df7f Mon Sep 17 00:00:00 2001
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Date: Tue, 11 Aug 2020 17:11:28 +0530
|
||||
Subject: [PATCH] prep: add ppc-parity write method
|
||||
|
||||
Add ppc-parity mmio write method to avoid NULL pointer dereference
|
||||
issue.
|
||||
|
||||
Reported-by: Lei Sun <slei.casper@gmail.com>
|
||||
Acked-by: David Gibson <david@gibson.dropbear.id.au>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Message-Id: <20200811114133.672647-5-ppandit@redhat.com>
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15469
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-15469-4.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/f867cebaedbc9c43189f102e4cdfdff05e88df7f]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/ppc/prep_systemio.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/hw/ppc/prep_systemio.c b/hw/ppc/prep_systemio.c
|
||||
index 4e48ef2..b2bd783 100644
|
||||
--- a/hw/ppc/prep_systemio.c
|
||||
+++ b/hw/ppc/prep_systemio.c
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
+#include "qemu/log.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
@@ -235,8 +236,15 @@ static uint64_t ppc_parity_error_readl(void *opaque, hwaddr addr,
|
||||
return val;
|
||||
}
|
||||
|
||||
+static void ppc_parity_error_writel(void *opaque, hwaddr addr,
|
||||
+ uint64_t data, unsigned size)
|
||||
+{
|
||||
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid access\n", __func__);
|
||||
+}
|
||||
+
|
||||
static const MemoryRegionOps ppc_parity_error_ops = {
|
||||
.read = ppc_parity_error_readl,
|
||||
+ .write = ppc_parity_error_writel,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4,
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
53
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-5.patch
Normal file
53
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-5.patch
Normal file
@@ -0,0 +1,53 @@
|
||||
From b5bf601f364e1a14ca4c3276f88dfec024acf613 Mon Sep 17 00:00:00 2001
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Date: Tue, 11 Aug 2020 17:11:29 +0530
|
||||
Subject: [PATCH] nvram: add nrf51_soc flash read method
|
||||
|
||||
Add nrf51_soc mmio read method to avoid NULL pointer dereference
|
||||
issue.
|
||||
|
||||
Reported-by: Lei Sun <slei.casper@gmail.com>
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Message-Id: <20200811114133.672647-6-ppandit@redhat.com>
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15469
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-15469-5.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/b5bf601f364e1a14ca4c3276f88dfec024acf613 ]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/nvram/nrf51_nvm.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/hw/nvram/nrf51_nvm.c b/hw/nvram/nrf51_nvm.c
|
||||
index f2283c1..7b3460d 100644
|
||||
--- a/hw/nvram/nrf51_nvm.c
|
||||
+++ b/hw/nvram/nrf51_nvm.c
|
||||
@@ -273,6 +273,15 @@ static const MemoryRegionOps io_ops = {
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
+static uint64_t flash_read(void *opaque, hwaddr offset, unsigned size)
|
||||
+{
|
||||
+ /*
|
||||
+ * This is a rom_device MemoryRegion which is always in
|
||||
+ * romd_mode (we never put it in MMIO mode), so reads always
|
||||
+ * go directly to RAM and never come here.
|
||||
+ */
|
||||
+ g_assert_not_reached();
|
||||
+}
|
||||
|
||||
static void flash_write(void *opaque, hwaddr offset, uint64_t value,
|
||||
unsigned int size)
|
||||
@@ -300,6 +309,7 @@ static void flash_write(void *opaque, hwaddr offset, uint64_t value,
|
||||
|
||||
|
||||
static const MemoryRegionOps flash_ops = {
|
||||
+ .read = flash_read,
|
||||
.write = flash_write,
|
||||
.valid.min_access_size = 4,
|
||||
.valid.max_access_size = 4,
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
61
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-6.patch
Normal file
61
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-6.patch
Normal file
@@ -0,0 +1,61 @@
|
||||
Backport of:
|
||||
|
||||
From 921604e175b8ec06c39503310e7b3ec1e3eafe9e Mon Sep 17 00:00:00 2001
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Date: Tue, 11 Aug 2020 17:11:30 +0530
|
||||
Subject: [PATCH] spapr_pci: add spapr msi read method
|
||||
|
||||
Add spapr msi mmio read method to avoid NULL pointer dereference
|
||||
issue.
|
||||
|
||||
Reported-by: Lei Sun <slei.casper@gmail.com>
|
||||
Acked-by: David Gibson <david@gibson.dropbear.id.au>
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Message-Id: <20200811114133.672647-7-ppandit@redhat.com>
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15469
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-15469-6.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/921604e175b8ec06c39503310e7b3ec1e3eafe9e]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/ppc/spapr_pci.c | 14 ++++++++++++--
|
||||
1 file changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/hw/ppc/spapr_pci.c
|
||||
+++ b/hw/ppc/spapr_pci.c
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "sysemu/kvm.h"
|
||||
#include "sysemu/hostmem.h"
|
||||
#include "sysemu/numa.h"
|
||||
+#include "qemu/log.h"
|
||||
|
||||
/* Copied from the kernel arch/powerpc/platforms/pseries/msi.c */
|
||||
#define RTAS_QUERY_FN 0
|
||||
@@ -738,6 +739,12 @@ static PCIINTxRoute spapr_route_intx_pin
|
||||
return route;
|
||||
}
|
||||
|
||||
+static uint64_t spapr_msi_read(void *opaque, hwaddr addr, unsigned size)
|
||||
+{
|
||||
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid access\n", __func__);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* MSI/MSIX memory region implementation.
|
||||
* The handler handles both MSI and MSIX.
|
||||
@@ -755,8 +762,11 @@ static void spapr_msi_write(void *opaque
|
||||
}
|
||||
|
||||
static const MemoryRegionOps spapr_msi_ops = {
|
||||
- /* There is no .read as the read result is undefined by PCI spec */
|
||||
- .read = NULL,
|
||||
+ /*
|
||||
+ * .read result is undefined by PCI spec.
|
||||
+ * define .read method to avoid assert failure in memory_region_init_io
|
||||
+ */
|
||||
+ .read = spapr_msi_read,
|
||||
.write = spapr_msi_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN
|
||||
};
|
||||
50
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-7.patch
Normal file
50
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-7.patch
Normal file
@@ -0,0 +1,50 @@
|
||||
From 2c9fb3b784000c1df32231e1c2464bb2e3fc4620 Mon Sep 17 00:00:00 2001
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Date: Tue, 11 Aug 2020 17:11:31 +0530
|
||||
Subject: [PATCH] tz-ppc: add dummy read/write methods
|
||||
|
||||
Add tz-ppc-dummy mmio read/write methods to avoid assert failure
|
||||
during initialisation.
|
||||
|
||||
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Message-Id: <20200811114133.672647-8-ppandit@redhat.com>
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15469
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-15469-7.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/2c9fb3b784000c1df32231e1c2464bb2e3fc4620 ]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/misc/tz-ppc.c | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
diff --git a/hw/misc/tz-ppc.c b/hw/misc/tz-ppc.c
|
||||
index 6431257..36495c6 100644
|
||||
--- a/hw/misc/tz-ppc.c
|
||||
+++ b/hw/misc/tz-ppc.c
|
||||
@@ -196,7 +196,21 @@ static bool tz_ppc_dummy_accepts(void *opaque, hwaddr addr,
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
+static uint64_t tz_ppc_dummy_read(void *opaque, hwaddr addr, unsigned size)
|
||||
+{
|
||||
+ g_assert_not_reached();
|
||||
+}
|
||||
+
|
||||
+static void tz_ppc_dummy_write(void *opaque, hwaddr addr,
|
||||
+ uint64_t data, unsigned size)
|
||||
+{
|
||||
+ g_assert_not_reached();
|
||||
+}
|
||||
+
|
||||
static const MemoryRegionOps tz_ppc_dummy_ops = {
|
||||
+ /* define r/w methods to avoid assert failure in memory_region_init_io */
|
||||
+ .read = tz_ppc_dummy_read,
|
||||
+ .write = tz_ppc_dummy_write,
|
||||
.valid.accepts = tz_ppc_dummy_accepts,
|
||||
};
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
44
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-8.patch
Normal file
44
meta/recipes-devtools/qemu/qemu/CVE-2020-15469-8.patch
Normal file
@@ -0,0 +1,44 @@
|
||||
From 735754aaa15a6ed46db51fd731e88331c446ea54 Mon Sep 17 00:00:00 2001
|
||||
From: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Date: Tue, 11 Aug 2020 17:11:32 +0530
|
||||
Subject: [PATCH] imx7-ccm: add digprog mmio write method
|
||||
|
||||
Add digprog mmio write method to avoid assert failure during
|
||||
initialisation.
|
||||
|
||||
Reviewed-by: Li Qiang <liq3ea@gmail.com>
|
||||
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
||||
Message-Id: <20200811114133.672647-9-ppandit@redhat.com>
|
||||
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15469
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-15469-8.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/735754aaa15a6ed46db51fd731e88331c446ea54]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/misc/imx7_ccm.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/hw/misc/imx7_ccm.c b/hw/misc/imx7_ccm.c
|
||||
index 02fc1ae..075159e 100644
|
||||
--- a/hw/misc/imx7_ccm.c
|
||||
+++ b/hw/misc/imx7_ccm.c
|
||||
@@ -131,8 +131,16 @@ static const struct MemoryRegionOps imx7_set_clr_tog_ops = {
|
||||
},
|
||||
};
|
||||
|
||||
+static void imx7_digprog_write(void *opaque, hwaddr addr,
|
||||
+ uint64_t data, unsigned size)
|
||||
+{
|
||||
+ qemu_log_mask(LOG_GUEST_ERROR,
|
||||
+ "Guest write to read-only ANALOG_DIGPROG register\n");
|
||||
+}
|
||||
+
|
||||
static const struct MemoryRegionOps imx7_digprog_ops = {
|
||||
.read = imx7_set_clr_tog_read,
|
||||
+ .write = imx7_digprog_write,
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
.impl = {
|
||||
.min_access_size = 4,
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
39
meta/recipes-devtools/qemu/qemu/CVE-2020-15859.patch
Normal file
39
meta/recipes-devtools/qemu/qemu/CVE-2020-15859.patch
Normal file
@@ -0,0 +1,39 @@
|
||||
From 22dc8663d9fc7baa22100544c600b6285a63c7a3 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Wang <jasowang@redhat.com>
|
||||
Date: Wed, 22 Jul 2020 16:57:46 +0800
|
||||
Subject: [PATCH] net: forbid the reentrant RX
|
||||
|
||||
The memory API allows DMA into NIC's MMIO area. This means the NIC's
|
||||
RX routine must be reentrant. Instead of auditing all the NIC, we can
|
||||
simply detect the reentrancy and return early. The queue->delivering
|
||||
is set and cleared by qemu_net_queue_deliver() for other queue helpers
|
||||
to know whether the delivering in on going (NIC's receive is being
|
||||
called). We can check it and return early in qemu_net_queue_flush() to
|
||||
forbid reentrant RX.
|
||||
|
||||
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
||||
|
||||
CVE: CVE-2020-15859
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/ubuntu/CVE-2020-15859.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/22dc8663d9fc7baa22100544c600b6285a63c7a3 ]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
net/queue.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/net/queue.c b/net/queue.c
|
||||
index 0164727..19e32c8 100644
|
||||
--- a/net/queue.c
|
||||
+++ b/net/queue.c
|
||||
@@ -250,6 +250,9 @@ void qemu_net_queue_purge(NetQueue *queue, NetClientState *from)
|
||||
|
||||
bool qemu_net_queue_flush(NetQueue *queue)
|
||||
{
|
||||
+ if (queue->delivering)
|
||||
+ return false;
|
||||
+
|
||||
while (!QTAILQ_EMPTY(&queue->packets)) {
|
||||
NetPacket *packet;
|
||||
int ret;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
51
meta/recipes-devtools/qemu/qemu/CVE-2020-35504.patch
Normal file
51
meta/recipes-devtools/qemu/qemu/CVE-2020-35504.patch
Normal file
@@ -0,0 +1,51 @@
|
||||
Backport of:
|
||||
|
||||
From 0db895361b8a82e1114372ff9f4857abea605701 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
|
||||
Date: Wed, 7 Apr 2021 20:57:50 +0100
|
||||
Subject: [PATCH] esp: always check current_req is not NULL before use in DMA
|
||||
callbacks
|
||||
|
||||
After issuing a SCSI command the SCSI layer can call the SCSIBusInfo .cancel
|
||||
callback which resets both current_req and current_dev to NULL. If any data
|
||||
is left in the transfer buffer (async_len != 0) then the next TI (Transfer
|
||||
Information) command will attempt to reference the NULL pointer causing a
|
||||
segfault.
|
||||
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1910723
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1909247
|
||||
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
|
||||
Tested-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Message-Id: <20210407195801.685-2-mark.cave-ayland@ilande.co.uk>
|
||||
|
||||
CVE: CVE-2020-35504
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-35504.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/0db895361b8a82e1114372ff9f4857abea605701 ]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/scsi/esp.c | 19 ++++++++++++++-----
|
||||
1 file changed, 14 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/hw/scsi/esp.c
|
||||
+++ b/hw/scsi/esp.c
|
||||
@@ -362,6 +362,11 @@ static void do_dma_pdma_cb(ESPState *s)
|
||||
do_cmd(s, s->cmdbuf);
|
||||
return;
|
||||
}
|
||||
+
|
||||
+ if (!s->current_req) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
s->dma_left -= len;
|
||||
s->async_buf += len;
|
||||
s->async_len -= len;
|
||||
@@ -415,6 +420,9 @@ static void esp_do_dma(ESPState *s)
|
||||
do_cmd(s, s->cmdbuf);
|
||||
return;
|
||||
}
|
||||
+ if (!s->current_req) {
|
||||
+ return;
|
||||
+ }
|
||||
if (s->async_len == 0) {
|
||||
/* Defer until data is available. */
|
||||
return;
|
||||
42
meta/recipes-devtools/qemu/qemu/CVE-2020-35505.patch
Normal file
42
meta/recipes-devtools/qemu/qemu/CVE-2020-35505.patch
Normal file
@@ -0,0 +1,42 @@
|
||||
Backport of:
|
||||
|
||||
From 99545751734035b76bd372c4e7215bb337428d89 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
|
||||
Date: Wed, 7 Apr 2021 20:57:55 +0100
|
||||
Subject: [PATCH] esp: ensure cmdfifo is not empty and current_dev is non-NULL
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When about to execute a SCSI command, ensure that cmdfifo is not empty and
|
||||
current_dev is non-NULL. This can happen if the guest tries to execute a TI
|
||||
(Transfer Information) command without issuing one of the select commands
|
||||
first.
|
||||
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1910723
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1909247
|
||||
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
|
||||
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
Tested-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Message-Id: <20210407195801.685-7-mark.cave-ayland@ilande.co.uk>
|
||||
|
||||
CVE: CVE-2020-35504
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2020-35505.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/99545751734035b76bd372c4e7215bb337428d89 ]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/scsi/esp.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
--- a/hw/scsi/esp.c
|
||||
+++ b/hw/scsi/esp.c
|
||||
@@ -193,6 +193,10 @@ static void do_busid_cmd(ESPState *s, ui
|
||||
|
||||
trace_esp_do_busid_cmd(busid);
|
||||
lun = busid & 7;
|
||||
+
|
||||
+ if (!s->current_dev) {
|
||||
+ return;
|
||||
+ }
|
||||
current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, lun);
|
||||
s->current_req = scsi_req_new(current_lun, 0, lun, buf, s);
|
||||
datalen = scsi_req_enqueue(s->current_req);
|
||||
85
meta/recipes-devtools/qemu/qemu/CVE-2021-3409-1.patch
Normal file
85
meta/recipes-devtools/qemu/qemu/CVE-2021-3409-1.patch
Normal file
@@ -0,0 +1,85 @@
|
||||
From b263d8f928001b5cfa2a993ea43b7a5b3a1811e8 Mon Sep 17 00:00:00 2001
|
||||
From: Bin Meng <bmeng.cn@gmail.com>
|
||||
Date: Wed, 3 Mar 2021 20:26:35 +0800
|
||||
Subject: [PATCH] hw/sd: sdhci: Don't transfer any data when command time out
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
At the end of sdhci_send_command(), it starts a data transfer if the
|
||||
command register indicates data is associated. But the data transfer
|
||||
should only be initiated when the command execution has succeeded.
|
||||
|
||||
With this fix, the following reproducer:
|
||||
|
||||
outl 0xcf8 0x80001810
|
||||
outl 0xcfc 0xe1068000
|
||||
outl 0xcf8 0x80001804
|
||||
outw 0xcfc 0x7
|
||||
write 0xe106802c 0x1 0x0f
|
||||
write 0xe1068004 0xc 0x2801d10101fffffbff28a384
|
||||
write 0xe106800c 0x1f 0x9dacbbcad9e8f7061524334251606f7e8d9cabbac9d8e7f60514233241505f
|
||||
write 0xe1068003 0x28 0x80d000251480d000252280d000253080d000253e80d000254c80d000255a80d000256880d0002576
|
||||
write 0xe1068003 0x1 0xfe
|
||||
|
||||
cannot be reproduced with the following QEMU command line:
|
||||
|
||||
$ qemu-system-x86_64 -nographic -M pc-q35-5.0 \
|
||||
-device sdhci-pci,sd-spec-version=3 \
|
||||
-drive if=sd,index=0,file=null-co://,format=raw,id=mydrive \
|
||||
-device sd-card,drive=mydrive \
|
||||
-monitor none -serial none -qtest stdio
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: CVE-2020-17380
|
||||
Fixes: CVE-2020-25085
|
||||
Fixes: CVE-2021-3409
|
||||
Fixes: d7dfca0807a0 ("hw/sdhci: introduce standard SD host controller")
|
||||
Reported-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Reported-by: Cornelius Aschermann (Ruhr-Universität Bochum)
|
||||
Reported-by: Sergej Schumilo (Ruhr-Universität Bochum)
|
||||
Reported-by: Simon Wörner (Ruhr-Universität Bochum)
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1892960
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1909418
|
||||
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1928146
|
||||
Acked-by: Alistair Francis <alistair.francis@wdc.com>
|
||||
Tested-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
|
||||
Message-Id: <20210303122639.20004-2-bmeng.cn@gmail.com>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
|
||||
CVE: CVE-2021-3409 CVE-2020-17380
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2021-3409-1.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/b263d8f928001b5cfa2a993ea43b7a5b3a1811e8 ]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/sd/sdhci.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/hw/sd/sdhci.c
|
||||
+++ b/hw/sd/sdhci.c
|
||||
@@ -316,6 +316,7 @@ static void sdhci_send_command(SDHCIStat
|
||||
SDRequest request;
|
||||
uint8_t response[16];
|
||||
int rlen;
|
||||
+ bool timeout = false;
|
||||
|
||||
s->errintsts = 0;
|
||||
s->acmd12errsts = 0;
|
||||
@@ -339,6 +340,7 @@ static void sdhci_send_command(SDHCIStat
|
||||
trace_sdhci_response16(s->rspreg[3], s->rspreg[2],
|
||||
s->rspreg[1], s->rspreg[0]);
|
||||
} else {
|
||||
+ timeout = true;
|
||||
trace_sdhci_error("timeout waiting for command response");
|
||||
if (s->errintstsen & SDHC_EISEN_CMDTIMEOUT) {
|
||||
s->errintsts |= SDHC_EIS_CMDTIMEOUT;
|
||||
@@ -359,7 +361,7 @@ static void sdhci_send_command(SDHCIStat
|
||||
|
||||
sdhci_update_irq(s);
|
||||
|
||||
- if (s->blksize && (s->cmdreg & SDHC_CMD_DATA_PRESENT)) {
|
||||
+ if (!timeout && s->blksize && (s->cmdreg & SDHC_CMD_DATA_PRESENT)) {
|
||||
s->data_count = 0;
|
||||
sdhci_data_transfer(s);
|
||||
}
|
||||
103
meta/recipes-devtools/qemu/qemu/CVE-2021-3409-2.patch
Normal file
103
meta/recipes-devtools/qemu/qemu/CVE-2021-3409-2.patch
Normal file
@@ -0,0 +1,103 @@
|
||||
From 8be45cc947832b3c02144c9d52921f499f2d77fe Mon Sep 17 00:00:00 2001
|
||||
From: Bin Meng <bmeng.cn@gmail.com>
|
||||
Date: Wed, 3 Mar 2021 20:26:36 +0800
|
||||
Subject: [PATCH] hw/sd: sdhci: Don't write to SDHC_SYSAD register when
|
||||
transfer is in progress
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Per "SD Host Controller Standard Specification Version 7.00"
|
||||
chapter 2.2.1 SDMA System Address Register:
|
||||
|
||||
This register can be accessed only if no transaction is executing
|
||||
(i.e., after a transaction has stopped).
|
||||
|
||||
With this fix, the following reproducer:
|
||||
|
||||
outl 0xcf8 0x80001010
|
||||
outl 0xcfc 0xfbefff00
|
||||
outl 0xcf8 0x80001001
|
||||
outl 0xcfc 0x06000000
|
||||
write 0xfbefff2c 0x1 0x05
|
||||
write 0xfbefff0f 0x1 0x37
|
||||
write 0xfbefff0a 0x1 0x01
|
||||
write 0xfbefff0f 0x1 0x29
|
||||
write 0xfbefff0f 0x1 0x02
|
||||
write 0xfbefff0f 0x1 0x03
|
||||
write 0xfbefff04 0x1 0x01
|
||||
write 0xfbefff05 0x1 0x01
|
||||
write 0xfbefff07 0x1 0x02
|
||||
write 0xfbefff0c 0x1 0x33
|
||||
write 0xfbefff0e 0x1 0x20
|
||||
write 0xfbefff0f 0x1 0x00
|
||||
write 0xfbefff2a 0x1 0x01
|
||||
write 0xfbefff0c 0x1 0x00
|
||||
write 0xfbefff03 0x1 0x00
|
||||
write 0xfbefff05 0x1 0x00
|
||||
write 0xfbefff2a 0x1 0x02
|
||||
write 0xfbefff0c 0x1 0x32
|
||||
write 0xfbefff01 0x1 0x01
|
||||
write 0xfbefff02 0x1 0x01
|
||||
write 0xfbefff03 0x1 0x01
|
||||
|
||||
cannot be reproduced with the following QEMU command line:
|
||||
|
||||
$ qemu-system-x86_64 -nographic -machine accel=qtest -m 512M \
|
||||
-nodefaults -device sdhci-pci,sd-spec-version=3 \
|
||||
-drive if=sd,index=0,file=null-co://,format=raw,id=mydrive \
|
||||
-device sd-card,drive=mydrive -qtest stdio
|
||||
|
||||
Cc: qemu-stable@nongnu.org
|
||||
Fixes: CVE-2020-17380
|
||||
Fixes: CVE-2020-25085
|
||||
Fixes: CVE-2021-3409
|
||||
Fixes: d7dfca0807a0 ("hw/sdhci: introduce standard SD host controller")
|
||||
Reported-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Reported-by: Cornelius Aschermann (Ruhr-Universität Bochum)
|
||||
Reported-by: Sergej Schumilo (Ruhr-Universität Bochum)
|
||||
Reported-by: Simon Wörner (Ruhr-Universität Bochum)
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1892960
|
||||
Buglink: https://bugs.launchpad.net/qemu/+bug/1909418
|
||||
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1928146
|
||||
Tested-by: Alexander Bulekov <alxndr@bu.edu>
|
||||
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
|
||||
Message-Id: <20210303122639.20004-3-bmeng.cn@gmail.com>
|
||||
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
|
||||
CVE: CVE-2021-3409 CVE-2020-17380
|
||||
Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/qemu/tree/debian/patches/CVE-2021-3409-2.patch?h=ubuntu/focal-security Upstream commit https://github.com/qemu/qemu/commit/8be45cc947832b3c02144c9d52921f499f2d77fe ]
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
hw/sd/sdhci.c | 20 +++++++++++---------
|
||||
1 file changed, 11 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/hw/sd/sdhci.c
|
||||
+++ b/hw/sd/sdhci.c
|
||||
@@ -1117,15 +1117,17 @@ sdhci_write(void *opaque, hwaddr offset,
|
||||
|
||||
switch (offset & ~0x3) {
|
||||
case SDHC_SYSAD:
|
||||
- s->sdmasysad = (s->sdmasysad & mask) | value;
|
||||
- MASKED_WRITE(s->sdmasysad, mask, value);
|
||||
- /* Writing to last byte of sdmasysad might trigger transfer */
|
||||
- if (!(mask & 0xFF000000) && TRANSFERRING_DATA(s->prnsts) && s->blkcnt &&
|
||||
- s->blksize && SDHC_DMA_TYPE(s->hostctl1) == SDHC_CTRL_SDMA) {
|
||||
- if (s->trnmod & SDHC_TRNS_MULTI) {
|
||||
- sdhci_sdma_transfer_multi_blocks(s);
|
||||
- } else {
|
||||
- sdhci_sdma_transfer_single_block(s);
|
||||
+ if (!TRANSFERRING_DATA(s->prnsts)) {
|
||||
+ s->sdmasysad = (s->sdmasysad & mask) | value;
|
||||
+ MASKED_WRITE(s->sdmasysad, mask, value);
|
||||
+ /* Writing to last byte of sdmasysad might trigger transfer */
|
||||
+ if (!(mask & 0xFF000000) && s->blkcnt && s->blksize &&
|
||||
+ SDHC_DMA_TYPE(s->hostctl1) == SDHC_CTRL_SDMA) {
|
||||
+ if (s->trnmod & SDHC_TRNS_MULTI) {
|
||||
+ sdhci_sdma_transfer_multi_blocks(s);
|
||||
+ } else {
|
||||
+ sdhci_sdma_transfer_single_block(s);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
break;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user