mirror of
https://git.yoctoproject.org/poky
synced 2026-02-20 08:29:42 +01:00
Compare commits
132 Commits
yocto-3.1.
...
dunfell-23
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b41d4e46d3 | ||
|
|
f593e21aad | ||
|
|
ce4a1354cc | ||
|
|
f3baa35d42 | ||
|
|
e4cc9273f5 | ||
|
|
11fba270e7 | ||
|
|
3b70636be4 | ||
|
|
b9917c90a2 | ||
|
|
8ddcfbfe01 | ||
|
|
f07bd53e6a | ||
|
|
9b9fd2b095 | ||
|
|
76fa5fae9e | ||
|
|
94b275e15e | ||
|
|
3cb3cee660 | ||
|
|
13aefbd92d | ||
|
|
fcd27727c1 | ||
|
|
4c7c64cc6e | ||
|
|
820be4beeb | ||
|
|
d6d65d7685 | ||
|
|
2658fb04ac | ||
|
|
99bb7a2d30 | ||
|
|
18161d9e47 | ||
|
|
81a3da3b99 | ||
|
|
32db22beec | ||
|
|
e173db21d0 | ||
|
|
746111afa0 | ||
|
|
e8fef0c8cf | ||
|
|
415757639d | ||
|
|
dfd900b5b0 | ||
|
|
6bba192936 | ||
|
|
9426c3c83d | ||
|
|
7fae28df19 | ||
|
|
8d050d1e45 | ||
|
|
9b69e69160 | ||
|
|
6360727bb1 | ||
|
|
1a338ab466 | ||
|
|
d65bf404bc | ||
|
|
11b10eac41 | ||
|
|
a558b15d7f | ||
|
|
dfae695343 | ||
|
|
f82639b50e | ||
|
|
4463703292 | ||
|
|
eca24c02ea | ||
|
|
628257a582 | ||
|
|
7e7b8e38dc | ||
|
|
b5eaa833ba | ||
|
|
acec862ed2 | ||
|
|
bd3bda5d03 | ||
|
|
4c7bfa8abe | ||
|
|
b46710743b | ||
|
|
e2f193d252 | ||
|
|
10d619c8bb | ||
|
|
1246e75875 | ||
|
|
f4c3f4508a | ||
|
|
0dd3f436f4 | ||
|
|
b461e69025 | ||
|
|
3348511b94 | ||
|
|
e97cfd1660 | ||
|
|
40d7b77030 | ||
|
|
b854e27c58 | ||
|
|
da4ba2d04e | ||
|
|
90b1d407c6 | ||
|
|
495bf963be | ||
|
|
37f35c4782 | ||
|
|
877ea55a5b | ||
|
|
ba476f819f | ||
|
|
ab977b3f49 | ||
|
|
e1122f6dad | ||
|
|
db637b0555 | ||
|
|
c4ca12868c | ||
|
|
4a5a4dbcf6 | ||
|
|
763007dff1 | ||
|
|
ee33ef8242 | ||
|
|
058d20254f | ||
|
|
6b514d38b7 | ||
|
|
01eb48b7f5 | ||
|
|
ac746716fc | ||
|
|
940fcf35b2 | ||
|
|
df471272ae | ||
|
|
bb6b6f5a55 | ||
|
|
c8987e7bca | ||
|
|
febd9f6715 | ||
|
|
acc692cfec | ||
|
|
3bb6c52e22 | ||
|
|
4359fb29f9 | ||
|
|
dffd5c120b | ||
|
|
7c237d3b2d | ||
|
|
c6b1d0eac1 | ||
|
|
f58e88f4d8 | ||
|
|
6060b500b9 | ||
|
|
2a96d2a932 | ||
|
|
b34672df17 | ||
|
|
a4501bdd1a | ||
|
|
6ea06ed9f0 | ||
|
|
32bf0d1e48 | ||
|
|
fedd12ae6d | ||
|
|
8d3efda87d | ||
|
|
7b27c85ed9 | ||
|
|
e3f9b3a497 | ||
|
|
97586f5d62 | ||
|
|
599987e984 | ||
|
|
4d679f1e07 | ||
|
|
d9a3341394 | ||
|
|
ea8e23b482 | ||
|
|
19d3dc1ebb | ||
|
|
0c48142849 | ||
|
|
9c8b420096 | ||
|
|
17023dee9b | ||
|
|
08ecf46de0 | ||
|
|
6836180997 | ||
|
|
3d5dd4dd8d | ||
|
|
7f93b8dff5 | ||
|
|
fca7b22674 | ||
|
|
e340dafa0e | ||
|
|
e92b9b6bf6 | ||
|
|
762912b1b5 | ||
|
|
7cee8440c4 | ||
|
|
fb2d910ef7 | ||
|
|
055b8c2093 | ||
|
|
76a93e4ac9 | ||
|
|
ea8e0dd072 | ||
|
|
2a4cdd5ff5 | ||
|
|
094a3ba047 | ||
|
|
4cd2d8de2a | ||
|
|
169e03b9b3 | ||
|
|
239fa60002 | ||
|
|
5eab654048 | ||
|
|
b03d18892c | ||
|
|
9959bee1af | ||
|
|
f5fe6f2a64 | ||
|
|
40d6918639 | ||
|
|
bbd2561fe9 |
@@ -991,7 +991,7 @@ class FetcherNetworkTest(FetcherTest):
|
||||
""" Prevent regression on deeply nested submodules not being checked out properly, even though they were fetched. """
|
||||
|
||||
# This repository also has submodules where the module (name), path and url do not align
|
||||
url = "gitsm://github.com/azure/iotedge.git;protocol=https;rev=d76e0316c6f324345d77c48a83ce836d09392699"
|
||||
url = "gitsm://github.com/azure/iotedge.git;protocol=https;rev=d76e0316c6f324345d77c48a83ce836d09392699;branch=main"
|
||||
fetcher = bb.fetch.Fetch([url], self.d)
|
||||
fetcher.download()
|
||||
# Previous cwd has been deleted
|
||||
|
||||
@@ -166,8 +166,9 @@ section.
|
||||
#. *Determine the BSP Layer You Want:* The Yocto Project supports many
|
||||
BSPs, which are maintained in their own layers or in layers designed
|
||||
to contain several BSPs. To get an idea of machine support through
|
||||
BSP layers, you can look at the `index of
|
||||
machines <&YOCTO_RELEASE_DL_URL;/machines>`__ for the release.
|
||||
BSP layers, you can look at the
|
||||
:yocto_dl:`index of machines </releases/yocto/&DISTRO_REL_TAG;/machines>`
|
||||
for the release.
|
||||
|
||||
#. *Optionally Clone the meta-intel BSP Layer:* If your hardware is
|
||||
based on current Intel CPUs and devices, you can leverage this BSP
|
||||
|
||||
@@ -16,7 +16,7 @@ import os
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
current_version = "3.1.13"
|
||||
current_version = "3.1.14"
|
||||
bitbake_version = "1.46"
|
||||
|
||||
# String used in sidebar
|
||||
|
||||
@@ -2168,7 +2168,7 @@ recipe, but which one? You can configure your build to call out the
|
||||
kernel recipe you want by using the
|
||||
:term:`PREFERRED_PROVIDER`
|
||||
variable. As an example, consider the
|
||||
`x86-base.inc <https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/machine/include/x86-base.inc>`_
|
||||
:yocto_git:`x86-base.inc </cgit/cgit.cgi/poky/tree/meta/conf/machine/include/x86-base.inc>`
|
||||
include file, which is a machine (i.e.
|
||||
:term:`MACHINE`) configuration file.
|
||||
This include file is the reason all x86-based machines use the
|
||||
|
||||
@@ -422,7 +422,7 @@ files. Git uses "branches" to organize different development efforts.
|
||||
For example, the ``poky`` repository has several branches that include
|
||||
the current "&DISTRO_NAME_NO_CAP;" branch, the "master" branch, and many
|
||||
branches for past Yocto Project releases. You can see all the branches
|
||||
by going to https://git.yoctoproject.org/cgit.cgi/poky/ and clicking on the
|
||||
by going to :yocto_git:`/cgit.cgi/poky/` and clicking on the
|
||||
``[...]`` link beneath the "Branch" heading.
|
||||
|
||||
Each of these branches represents a specific area of development. The
|
||||
@@ -468,7 +468,7 @@ Git uses "tags" to mark specific changes in a repository branch
|
||||
structure. Typically, a tag is used to mark a special point such as the
|
||||
final change (or commit) before a project is released. You can see the
|
||||
tags used with the ``poky`` Git repository by going to
|
||||
https://git.yoctoproject.org/cgit.cgi/poky/ and clicking on the ``[...]`` link
|
||||
:yocto_git:`/cgit.cgi/poky/` and clicking on the ``[...]`` link
|
||||
beneath the "Tag" heading.
|
||||
|
||||
Some key tags for the ``poky`` repository are ``jethro-14.0.3``,
|
||||
|
||||
@@ -271,8 +271,8 @@ with the string ``meta-``.
|
||||
, but it is a commonly accepted standard in the Yocto Project
|
||||
community.
|
||||
|
||||
For example, if you were to examine the `tree
|
||||
view <https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/>`__ of the
|
||||
For example, if you were to examine the :yocto_git:`tree
|
||||
view </cgit/cgit.cgi/poky/tree/>` of the
|
||||
``poky`` repository, you will see several layers: ``meta``,
|
||||
``meta-skeleton``, ``meta-selftest``, ``meta-poky``, and
|
||||
``meta-yocto-bsp``. Each of these repositories represents a distinct
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
DISTRO : "3.1.13"
|
||||
DISTRO : "3.1.14"
|
||||
DISTRO_NAME_NO_CAP : "dunfell"
|
||||
DISTRO_NAME : "Dunfell"
|
||||
DISTRO_NAME_NO_CAP_MINUS_ONE : "zeus"
|
||||
YOCTO_DOC_VERSION : "3.1.13"
|
||||
YOCTO_DOC_VERSION : "3.1.14"
|
||||
YOCTO_DOC_VERSION_MINUS_ONE : "3.0.4"
|
||||
DISTRO_REL_TAG : "yocto-3.1.13"
|
||||
POKYVERSION : "23.0.13"
|
||||
DISTRO_REL_TAG : "yocto-3.1.14"
|
||||
POKYVERSION : "23.0.14"
|
||||
YOCTO_POKY : "poky-&DISTRO_NAME_NO_CAP;-&POKYVERSION;"
|
||||
YOCTO_DL_URL : "https://downloads.yoctoproject.org"
|
||||
YOCTO_AB_URL : "https://autobuilder.yoctoproject.org"
|
||||
|
||||
@@ -1169,9 +1169,8 @@ e.g. 'perf help' or 'perf help record'.
|
||||
|
||||
However, by default Yocto doesn't install man pages, but perf invokes
|
||||
the man pages for most help functionality. This is a bug and is being
|
||||
addressed by a Yocto bug: `Bug 3388 - perf: enable man pages for basic
|
||||
'help'
|
||||
functionality <https://bugzilla.yoctoproject.org/show_bug.cgi?id=3388>`__.
|
||||
addressed by a Yocto bug: :yocto_bugs:`Bug 3388 - perf: enable man pages for basic
|
||||
'help' functionality </show_bug.cgi?id=3388>`.
|
||||
|
||||
The man pages in text form, along with some other files, such as a set
|
||||
of examples, can be found in the 'perf' directory of the kernel tree: ::
|
||||
|
||||
@@ -59,6 +59,8 @@ distributions:
|
||||
|
||||
- Fedora 34
|
||||
|
||||
- Fedora 35
|
||||
|
||||
- CentOS 7.x
|
||||
|
||||
- Debian GNU/Linux 8.x (Jessie)
|
||||
@@ -73,6 +75,9 @@ distributions:
|
||||
|
||||
- OpenSUSE Leap 15.2
|
||||
|
||||
- OpenSUSE Leap 15.3
|
||||
|
||||
- AlmaLinux 8.5
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -346,7 +351,7 @@ Downloading a Pre-Built ``buildtools`` Tarball
|
||||
Downloading and running a pre-built buildtools installer is the easiest
|
||||
of the two methods by which you can get these tools:
|
||||
|
||||
1. Locate and download the ``*.sh`` at &YOCTO_RELEASE_DL_URL;/buildtools/
|
||||
1. Locate and download the ``*.sh`` at :yocto_dl:`/releases/yocto/&DISTRO_REL_TAG;/buildtools/`
|
||||
|
||||
2. Execute the installation script. Here is an example for the
|
||||
traditional installer:
|
||||
|
||||
@@ -39,6 +39,7 @@ Release Series 3.1 (dunfell)
|
||||
- :yocto_docs:`3.1.11 Documentation </3.1.11>`
|
||||
- :yocto_docs:`3.1.12 Documentation </3.1.12>`
|
||||
- :yocto_docs:`3.1.13 Documentation </3.1.13>`
|
||||
- :yocto_docs:`3.1.14 Documentation </3.1.14>`
|
||||
|
||||
==========================
|
||||
Outdated Release Manuals
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'3.4.1': '3.4.1',
|
||||
'3.3.4': '3.3.4',
|
||||
'3.2.4': '3.2.4',
|
||||
'3.1.13': '3.1.13',
|
||||
'3.1.14': '3.1.14',
|
||||
'3.0.4': '3.0.4',
|
||||
'2.7.4': '2.7.4',
|
||||
};
|
||||
|
||||
@@ -173,13 +173,13 @@ As shipped, Toaster is configured to work with the following releases:
|
||||
- *Yocto Project &DISTRO; "&DISTRO_NAME;" or OpenEmbedded "&DISTRO_NAME;":*
|
||||
This release causes your Toaster projects to build against the head
|
||||
of the &DISTRO_NAME_NO_CAP; branch at
|
||||
https://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?h=&DISTRO_NAME_NO_CAP; or
|
||||
:yocto_git:`/cgit/cgit.cgi/poky/log/?h=&DISTRO_NAME_NO_CAP;` or
|
||||
http://git.openembedded.org/openembedded-core/commit/?h=&DISTRO_NAME_NO_CAP;.
|
||||
|
||||
- *Yocto Project "Master" or OpenEmbedded "Master":* This release
|
||||
causes your Toaster Projects to build against the head of the master
|
||||
branch, which is where active development takes place, at
|
||||
https://git.yoctoproject.org/cgit/cgit.cgi/poky/log/ or
|
||||
:yocto_git:`/cgit/cgit.cgi/poky/log/` or
|
||||
http://git.openembedded.org/openembedded-core/log/.
|
||||
|
||||
- *Local Yocto Project or Local OpenEmbedded:* This release causes your
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
DISTRO = "poky"
|
||||
DISTRO_NAME = "Poky (Yocto Project Reference Distro)"
|
||||
DISTRO_VERSION = "3.1.14"
|
||||
DISTRO_VERSION = "3.1.15"
|
||||
DISTRO_CODENAME = "dunfell"
|
||||
SDK_VENDOR = "-pokysdk"
|
||||
SDK_VERSION = "${@d.getVar('DISTRO_VERSION').replace('snapshot-${DATE}', 'snapshot')}"
|
||||
@@ -62,6 +62,7 @@ SANITY_TESTED_DISTROS ?= " \
|
||||
fedora-32 \n \
|
||||
fedora-33 \n \
|
||||
fedora-34 \n \
|
||||
fedora-35 \n \
|
||||
centos-7 \n \
|
||||
centos-8 \n \
|
||||
debian-8 \n \
|
||||
@@ -70,6 +71,8 @@ SANITY_TESTED_DISTROS ?= " \
|
||||
debian-11 \n \
|
||||
opensuseleap-15.1 \n \
|
||||
opensuseleap-15.2 \n \
|
||||
opensuseleap-15.3 \n \
|
||||
almalinux-8.5 \n \
|
||||
"
|
||||
# add poky sanity bbclass
|
||||
INHERIT += "poky-sanity"
|
||||
|
||||
@@ -7,8 +7,8 @@ KMACHINE_genericx86 ?= "common-pc"
|
||||
KMACHINE_genericx86-64 ?= "common-pc-64"
|
||||
KMACHINE_beaglebone-yocto ?= "beaglebone"
|
||||
|
||||
SRCREV_machine_genericx86 ?= "76404f1ae59698b6a446dba29c885ca78c69c330"
|
||||
SRCREV_machine_genericx86-64 ?= "76404f1ae59698b6a446dba29c885ca78c69c330"
|
||||
SRCREV_machine_genericx86 ?= "e2020dbe2ccaef50d7e8f37a5bf08c68a006a064"
|
||||
SRCREV_machine_genericx86-64 ?= "e2020dbe2ccaef50d7e8f37a5bf08c68a006a064"
|
||||
SRCREV_machine_edgerouter ?= "706efec4c1e270ec5dda92275898cd465dfdc7dd"
|
||||
SRCREV_machine_beaglebone-yocto ?= "706efec4c1e270ec5dda92275898cd465dfdc7dd"
|
||||
|
||||
@@ -17,7 +17,7 @@ COMPATIBLE_MACHINE_genericx86-64 = "genericx86-64"
|
||||
COMPATIBLE_MACHINE_edgerouter = "edgerouter"
|
||||
COMPATIBLE_MACHINE_beaglebone-yocto = "beaglebone-yocto"
|
||||
|
||||
LINUX_VERSION_genericx86 = "5.4.158"
|
||||
LINUX_VERSION_genericx86-64 = "5.4.158"
|
||||
LINUX_VERSION_genericx86 = "5.4.178"
|
||||
LINUX_VERSION_genericx86-64 = "5.4.178"
|
||||
LINUX_VERSION_edgerouter = "5.4.58"
|
||||
LINUX_VERSION_beaglebone-yocto = "5.4.58"
|
||||
|
||||
@@ -865,6 +865,7 @@ python buildhistory_eventhandler() {
|
||||
if os.path.isdir(olddir):
|
||||
shutil.rmtree(olddir)
|
||||
rootdir = e.data.getVar("BUILDHISTORY_DIR")
|
||||
bb.utils.mkdirhier(rootdir)
|
||||
entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ]
|
||||
bb.utils.mkdirhier(olddir)
|
||||
for entry in entries:
|
||||
|
||||
@@ -36,6 +36,14 @@ python do_menuconfig() {
|
||||
except OSError:
|
||||
mtime = 0
|
||||
|
||||
# setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
|
||||
d.setVar("PKG_CONFIG_DIR", "${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig")
|
||||
d.setVar("PKG_CONFIG_PATH", "${PKG_CONFIG_DIR}:${STAGING_DATADIR_NATIVE}/pkgconfig")
|
||||
d.setVar("PKG_CONFIG_LIBDIR", "${PKG_CONFIG_DIR}")
|
||||
d.setVarFlag("PKG_CONFIG_SYSROOT_DIR", "unexport", "1")
|
||||
# ensure that environment variables are overwritten with this tasks 'd' values
|
||||
d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR")
|
||||
|
||||
oe_terminal("sh -c \"make %s; if [ \\$? -ne 0 ]; then echo 'Command failed.'; printf 'Press any key to continue... '; read r; fi\"" % d.getVar('KCONFIG_CONFIG_COMMAND'),
|
||||
d.getVar('PN') + ' Configuration', d)
|
||||
|
||||
|
||||
@@ -110,7 +110,6 @@ python do_cve_check () {
|
||||
}
|
||||
|
||||
addtask cve_check before do_build after do_fetch
|
||||
do_cve_check[lockfiles] += "${CVE_CHECK_DB_FILE_LOCK}"
|
||||
do_cve_check[depends] = "cve-update-db-native:do_fetch"
|
||||
do_cve_check[nostamp] = "1"
|
||||
|
||||
@@ -143,6 +142,7 @@ python cve_check_write_rootfs_manifest () {
|
||||
manifest_name = d.getVar("CVE_CHECK_MANIFEST")
|
||||
cve_tmp_file = d.getVar("CVE_CHECK_TMP_FILE")
|
||||
|
||||
bb.utils.mkdirhier(os.path.dirname(manifest_name))
|
||||
shutil.copyfile(cve_tmp_file, manifest_name)
|
||||
|
||||
if manifest_name and os.path.exists(manifest_name):
|
||||
@@ -322,7 +322,8 @@ def get_cve_info(d, cves):
|
||||
import sqlite3
|
||||
|
||||
cve_data = {}
|
||||
conn = sqlite3.connect(d.getVar("CVE_CHECK_DB_FILE"))
|
||||
db_file = d.expand("file:${CVE_CHECK_DB_FILE}?mode=ro")
|
||||
conn = sqlite3.connect(db_file, uri=True)
|
||||
|
||||
for cve in cves:
|
||||
for row in conn.execute("SELECT * FROM NVD WHERE ID IS ?", (cve,)):
|
||||
|
||||
@@ -395,7 +395,7 @@ def check_connectivity(d):
|
||||
msg += " Please ensure your host's network is configured correctly.\n"
|
||||
msg += " If your ISP or network is blocking the above URL,\n"
|
||||
msg += " try with another domain name, for example by setting:\n"
|
||||
msg += " CONNECTIVITY_CHECK_URIS = \"https://www.yoctoproject.org/\""
|
||||
msg += " CONNECTIVITY_CHECK_URIS = \"https://www.example.com/\""
|
||||
msg += " You could also set BB_NO_NETWORK = \"1\" to disable network\n"
|
||||
msg += " access if all required sources are on local disk.\n"
|
||||
retval = msg
|
||||
|
||||
@@ -841,14 +841,18 @@ sstate_create_package () {
|
||||
fi
|
||||
chmod 0664 $TFILE
|
||||
# Skip if it was already created by some other process
|
||||
if [ ! -e ${SSTATE_PKG} ]; then
|
||||
if [ -h ${SSTATE_PKG} ] && [ ! -e ${SSTATE_PKG} ]; then
|
||||
# There is a symbolic link, but it links to nothing.
|
||||
# Forcefully replace it with the new file.
|
||||
ln -f $TFILE ${SSTATE_PKG} || true
|
||||
elif [ ! -e ${SSTATE_PKG} ]; then
|
||||
# Move into place using ln to attempt an atomic op.
|
||||
# Abort if it already exists
|
||||
ln $TFILE ${SSTATE_PKG} && rm $TFILE
|
||||
ln $TFILE ${SSTATE_PKG} || true
|
||||
else
|
||||
rm $TFILE
|
||||
touch ${SSTATE_PKG} 2>/dev/null || true
|
||||
fi
|
||||
touch ${SSTATE_PKG} 2>/dev/null || true
|
||||
rm $TFILE
|
||||
}
|
||||
|
||||
python sstate_sign_package () {
|
||||
@@ -878,7 +882,7 @@ python sstate_report_unihash() {
|
||||
sstate_unpack_package () {
|
||||
tar -xvzf ${SSTATE_PKG}
|
||||
# update .siginfo atime on local/NFS mirror if it is a symbolic link
|
||||
[ ! -h ${SSTATE_PKG}.siginfo ] || touch -a ${SSTATE_PKG}.siginfo 2>/dev/null || true
|
||||
[ ! -h ${SSTATE_PKG}.siginfo ] || [ ! -e ${SSTATE_PKG}.siginfo ] || touch -a ${SSTATE_PKG}.siginfo 2>/dev/null || true
|
||||
# update each symbolic link instead of any referenced file
|
||||
touch --no-dereference ${SSTATE_PKG} 2>/dev/null || true
|
||||
[ ! -e ${SSTATE_PKG}.sig ] || touch --no-dereference ${SSTATE_PKG}.sig 2>/dev/null || true
|
||||
@@ -957,7 +961,7 @@ def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, summary=True,
|
||||
|
||||
localdata2 = bb.data.createCopy(localdata)
|
||||
srcuri = "file://" + sstatefile
|
||||
localdata.setVar('SRC_URI', srcuri)
|
||||
localdata2.setVar('SRC_URI', srcuri)
|
||||
bb.debug(2, "SState: Attempting to fetch %s" % srcuri)
|
||||
|
||||
try:
|
||||
|
||||
@@ -2,7 +2,7 @@ UNINATIVE_LOADER ?= "${UNINATIVE_STAGING_DIR}-uninative/${BUILD_ARCH}-linux/lib/
|
||||
UNINATIVE_STAGING_DIR ?= "${STAGING_DIR}"
|
||||
|
||||
UNINATIVE_URL ?= "unset"
|
||||
UNINATIVE_TARBALL ?= "${BUILD_ARCH}-nativesdk-libc.tar.xz"
|
||||
UNINATIVE_TARBALL ?= "${BUILD_ARCH}-nativesdk-libc-${UNINATIVE_VERSION}.tar.xz"
|
||||
# Example checksums
|
||||
#UNINATIVE_CHECKSUM[aarch64] = "dead"
|
||||
#UNINATIVE_CHECKSUM[i686] = "dead"
|
||||
|
||||
@@ -48,4 +48,4 @@ KERNEL_IMAGETYPES ??= "${KERNEL_IMAGETYPE}"
|
||||
# fetch from the network (and warn you if not). To disable the test set
|
||||
# the variable to be empty.
|
||||
# Git example url: git://git.yoctoproject.org/yocto-firewall-test;protocol=git;rev=master;branch=master
|
||||
CONNECTIVITY_CHECK_URIS ?= "https://www.example.com/"
|
||||
CONNECTIVITY_CHECK_URIS ?= "https://yoctoproject.org/connectivity.html"
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
# to the distro running on the build machine.
|
||||
#
|
||||
|
||||
UNINATIVE_MAXGLIBCVERSION = "2.34"
|
||||
UNINATIVE_MAXGLIBCVERSION = "2.35"
|
||||
UNINATIVE_VERSION = "3.5"
|
||||
|
||||
UNINATIVE_URL ?= "http://downloads.yoctoproject.org/releases/uninative/3.4/"
|
||||
UNINATIVE_CHECKSUM[aarch64] ?= "3013cdda8f0dc6639ce1c80f33eabce66f06b890bd5b58739a6d7a92a0bb7100"
|
||||
UNINATIVE_CHECKSUM[i686] ?= "abed500de584aad63ec237546db20cdd0c69d8870a6f8e94ac31721ace64b376"
|
||||
UNINATIVE_CHECKSUM[x86_64] ?= "126f4f7f6f21084ee140dac3eb4c536b963837826b7c38599db0b512c3377ba2"
|
||||
UNINATIVE_URL ?= "http://downloads.yoctoproject.org/releases/uninative/${UNINATIVE_VERSION}/"
|
||||
UNINATIVE_CHECKSUM[aarch64] ?= "6de0771bd21e0fcb5e80388e5b561a8023b24083bcbf46e056a089982aff75d7"
|
||||
UNINATIVE_CHECKSUM[i686] ?= "8c8745becbfa1c341bae839c7eab56ddf17ce36c303bcd73d3b2f2f788b631c2"
|
||||
UNINATIVE_CHECKSUM[x86_64] ?= "e8047a5748e6f266165da141eb6d08b23674f30e477b0e5505b6403d50fbc4b2"
|
||||
|
||||
12
meta/files/common-licenses/Spencer-94
Normal file
12
meta/files/common-licenses/Spencer-94
Normal file
@@ -0,0 +1,12 @@
|
||||
Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved.
|
||||
This software is not subject to any license of the American Telephone and Telegraph Company or of the Regents of the University of California.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose on any computer system, and to alter it and redistribute it, subject to the following restrictions:
|
||||
|
||||
1. The author is not responsible for the consequences of use of this software, no matter how awful, even if they arise from flaws in it.
|
||||
|
||||
2. The origin of this software must not be misrepresented, either by explicit claim or by omission. Since few users ever read sources, credits must appear in the documentation.
|
||||
|
||||
3. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. Since few users ever read sources, credits must appear in the documentation.
|
||||
|
||||
4. This notice may not be removed or altered.
|
||||
@@ -5,7 +5,7 @@ fi
|
||||
|
||||
# fix dynamic loader paths in all ELF SDK binaries
|
||||
native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"')
|
||||
dl_path=$($SUDO_EXEC find $native_sysroot/lib -name "ld-linux*")
|
||||
dl_path=$($SUDO_EXEC find $native_sysroot/lib -maxdepth 1 -name "ld-linux*")
|
||||
if [ "$dl_path" = "" ] ; then
|
||||
echo "SDK could not be set up. Relocate script unable to find ld-linux.so. Abort!"
|
||||
exit 1
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
From 0900f11def2e7fbb4880efff0cd9c9b32f1cdb86 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 3 Dec 2020 14:39:45 +0000
|
||||
Subject: [PATCH] mmap: Fix memory leak when iterating over mapped memory
|
||||
|
||||
When returning from grub_mmap_iterate() the memory allocated to present
|
||||
is not being released causing it to leak.
|
||||
|
||||
Fixes: CID 96655
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=8cb2848f9699642a698af84b12ba187cab722031]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/mmap/mmap.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c
|
||||
index 7ebf32e..8bf235f 100644
|
||||
--- a/grub-core/mmap/mmap.c
|
||||
+++ b/grub-core/mmap/mmap.c
|
||||
@@ -270,6 +270,7 @@ grub_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
||||
hook_data))
|
||||
{
|
||||
grub_free (ctx.scanline_events);
|
||||
+ grub_free (present);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -282,6 +283,7 @@ grub_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
||||
}
|
||||
|
||||
grub_free (ctx.scanline_events);
|
||||
+ grub_free (present);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
From f216a75e884ed5e4e94bf86965000dde51148f94 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 27 Nov 2020 15:10:26 +0000
|
||||
Subject: [PATCH] net/net: Fix possible dereference to of a NULL pointer
|
||||
|
||||
It is always possible that grub_zalloc() could fail, so we should check for
|
||||
a NULL return. Otherwise we run the risk of dereferencing a NULL pointer.
|
||||
|
||||
Fixes: CID 296221
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=03f2515ae0c503406f1a99a2178405049c6555db]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/net/net.c | 9 +++++++--
|
||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
|
||||
index 38f19df..7c2cdf2 100644
|
||||
--- a/grub-core/net/net.c
|
||||
+++ b/grub-core/net/net.c
|
||||
@@ -86,8 +86,13 @@ grub_net_link_layer_add_address (struct grub_net_card *card,
|
||||
|
||||
/* Add sender to cache table. */
|
||||
if (card->link_layer_table == NULL)
|
||||
- card->link_layer_table = grub_zalloc (LINK_LAYER_CACHE_SIZE
|
||||
- * sizeof (card->link_layer_table[0]));
|
||||
+ {
|
||||
+ card->link_layer_table = grub_zalloc (LINK_LAYER_CACHE_SIZE
|
||||
+ * sizeof (card->link_layer_table[0]));
|
||||
+ if (card->link_layer_table == NULL)
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
entry = &(card->link_layer_table[card->new_ll_entry]);
|
||||
entry->avail = 1;
|
||||
grub_memcpy (&entry->ll_address, ll, sizeof (entry->ll_address));
|
||||
@@ -0,0 +1,33 @@
|
||||
From 09cc0df477758b60f51fbc0da1dee2f5d54c333d Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 19 Feb 2021 17:12:23 +0000
|
||||
Subject: [PATCH] net/tftp: Fix dangling memory pointer
|
||||
|
||||
The static code analysis tool, Parfait, reported that the valid of
|
||||
file->data was left referencing memory that was freed by the call to
|
||||
grub_free(data) where data was initialized from file->data.
|
||||
|
||||
To ensure that there is no unintentional access to this memory
|
||||
referenced by file->data we should set the pointer to NULL.
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=0cb838b281a68b536a09681f9557ea6a7ac5da7a]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/net/tftp.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
|
||||
index 7d90bf6..f76b19f 100644
|
||||
--- a/grub-core/net/tftp.c
|
||||
+++ b/grub-core/net/tftp.c
|
||||
@@ -468,6 +468,7 @@ tftp_close (struct grub_file *file)
|
||||
}
|
||||
destroy_pq (data);
|
||||
grub_free (data);
|
||||
+ file->data = NULL;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
From 8861fa6226f7229105722ba669465e879b56ee2b Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 22 Jan 2021 12:32:41 +0000
|
||||
Subject: [PATCH] kern/parser: Fix resource leak if argc == 0
|
||||
|
||||
After processing the command-line yet arriving at the point where we are
|
||||
setting argv, we are allocating memory, even if argc == 0, which makes
|
||||
no sense since we never put anything into the allocated argv.
|
||||
|
||||
The solution is to simply return that we've successfully processed the
|
||||
arguments but that argc == 0, and also ensure that argv is NULL when
|
||||
we're not allocating anything in it.
|
||||
|
||||
There are only 2 callers of this function, and both are handling a zero
|
||||
value in argc assuming nothing is allocated in argv.
|
||||
|
||||
Fixes: CID 96680
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=d06161b035dde4769199ad65aa0a587a5920012b]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/kern/parser.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c
|
||||
index 619db31..d1cf061 100644
|
||||
--- a/grub-core/kern/parser.c
|
||||
+++ b/grub-core/kern/parser.c
|
||||
@@ -146,6 +146,7 @@ grub_parser_split_cmdline (const char *cmdline,
|
||||
int i;
|
||||
|
||||
*argc = 0;
|
||||
+ *argv = NULL;
|
||||
do
|
||||
{
|
||||
if (!rd || !*rd)
|
||||
@@ -207,6 +208,10 @@ grub_parser_split_cmdline (const char *cmdline,
|
||||
(*argc)++;
|
||||
}
|
||||
|
||||
+ /* If there are no args, then we're done. */
|
||||
+ if (!*argc)
|
||||
+ return 0;
|
||||
+
|
||||
/* Reserve memory for the return values. */
|
||||
args = grub_malloc (bp - buffer);
|
||||
if (!args)
|
||||
@@ -0,0 +1,235 @@
|
||||
From 16a4d739b19f8680cf93a3c8fa0ae9fc1b1c310b Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Sun, 19 Jul 2020 16:53:27 -0400
|
||||
Subject: [PATCH] efi: Fix some malformed device path arithmetic errors
|
||||
|
||||
Several places we take the length of a device path and subtract 4 from
|
||||
it, without ever checking that it's >= 4. There are also cases where
|
||||
this kind of malformation will result in unpredictable iteration,
|
||||
including treating the length from one dp node as the type in the next
|
||||
node. These are all errors, no matter where the data comes from.
|
||||
|
||||
This patch adds a checking macro, GRUB_EFI_DEVICE_PATH_VALID(), which
|
||||
can be used in several places, and makes GRUB_EFI_NEXT_DEVICE_PATH()
|
||||
return NULL and GRUB_EFI_END_ENTIRE_DEVICE_PATH() evaluate as true when
|
||||
the length is too small. Additionally, it makes several places in the
|
||||
code check for and return errors in these cases.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=d2cf823d0e31818d1b7a223daff6d5e006596543]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/kern/efi/efi.c | 64 +++++++++++++++++++++++++-----
|
||||
grub-core/loader/efi/chainloader.c | 13 +++++-
|
||||
grub-core/loader/i386/xnu.c | 9 +++--
|
||||
include/grub/efi/api.h | 14 ++++---
|
||||
4 files changed, 79 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
|
||||
index ad170c7..6a38080 100644
|
||||
--- a/grub-core/kern/efi/efi.c
|
||||
+++ b/grub-core/kern/efi/efi.c
|
||||
@@ -360,7 +360,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
|
||||
|
||||
dp = dp0;
|
||||
|
||||
- while (1)
|
||||
+ while (dp)
|
||||
{
|
||||
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
|
||||
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
|
||||
@@ -370,9 +370,15 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
|
||||
if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
|
||||
&& subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE)
|
||||
{
|
||||
- grub_efi_uint16_t len;
|
||||
- len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
|
||||
- / sizeof (grub_efi_char16_t));
|
||||
+ grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
|
||||
+
|
||||
+ if (len < 4)
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
+ "malformed EFI Device Path node has length=%d", len);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ len = (len - 4) / sizeof (grub_efi_char16_t);
|
||||
filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 2;
|
||||
}
|
||||
|
||||
@@ -388,7 +394,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
- while (1)
|
||||
+ while (dp)
|
||||
{
|
||||
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
|
||||
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
|
||||
@@ -404,8 +410,15 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
|
||||
|
||||
*p++ = '/';
|
||||
|
||||
- len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
|
||||
- / sizeof (grub_efi_char16_t));
|
||||
+ len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
|
||||
+ if (len < 4)
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
+ "malformed EFI Device Path node has length=%d", len);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ len = (len - 4) / sizeof (grub_efi_char16_t);
|
||||
fp = (grub_efi_file_path_device_path_t *) dp;
|
||||
/* According to EFI spec Path Name is NULL terminated */
|
||||
while (len > 0 && fp->path_name[len - 1] == 0)
|
||||
@@ -480,7 +493,26 @@ grub_efi_duplicate_device_path (const grub_efi_device_path_t *dp)
|
||||
;
|
||||
p = GRUB_EFI_NEXT_DEVICE_PATH (p))
|
||||
{
|
||||
- total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
|
||||
+ grub_size_t len = GRUB_EFI_DEVICE_PATH_LENGTH (p);
|
||||
+
|
||||
+ /*
|
||||
+ * In the event that we find a node that's completely garbage, for
|
||||
+ * example if we get to 0x7f 0x01 0x02 0x00 ... (EndInstance with a size
|
||||
+ * of 2), GRUB_EFI_END_ENTIRE_DEVICE_PATH() will be true and
|
||||
+ * GRUB_EFI_NEXT_DEVICE_PATH() will return NULL, so we won't continue,
|
||||
+ * and neither should our consumers, but there won't be any error raised
|
||||
+ * even though the device path is junk.
|
||||
+ *
|
||||
+ * This keeps us from passing junk down back to our caller.
|
||||
+ */
|
||||
+ if (len < 4)
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
+ "malformed EFI Device Path node has length=%d", len);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ total_size += len;
|
||||
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
|
||||
break;
|
||||
}
|
||||
@@ -525,7 +557,7 @@ dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor)
|
||||
void
|
||||
grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
{
|
||||
- while (1)
|
||||
+ while (GRUB_EFI_DEVICE_PATH_VALID (dp))
|
||||
{
|
||||
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
|
||||
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
|
||||
@@ -937,7 +969,10 @@ grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1,
|
||||
/* Return non-zero. */
|
||||
return 1;
|
||||
|
||||
- while (1)
|
||||
+ if (dp1 == dp2)
|
||||
+ return 0;
|
||||
+
|
||||
+ while (GRUB_EFI_DEVICE_PATH_VALID (dp1) && GRUB_EFI_DEVICE_PATH_VALID (dp2))
|
||||
{
|
||||
grub_efi_uint8_t type1, type2;
|
||||
grub_efi_uint8_t subtype1, subtype2;
|
||||
@@ -973,5 +1008,14 @@ grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1,
|
||||
dp2 = (grub_efi_device_path_t *) ((char *) dp2 + len2);
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * There's no "right" answer here, but we probably don't want to call a valid
|
||||
+ * dp and an invalid dp equal, so pick one way or the other.
|
||||
+ */
|
||||
+ if (GRUB_EFI_DEVICE_PATH_VALID (dp1) && !GRUB_EFI_DEVICE_PATH_VALID (dp2))
|
||||
+ return 1;
|
||||
+ else if (!GRUB_EFI_DEVICE_PATH_VALID (dp1) && GRUB_EFI_DEVICE_PATH_VALID (dp2))
|
||||
+ return -1;
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
|
||||
index daf8c6b..a8d7b91 100644
|
||||
--- a/grub-core/loader/efi/chainloader.c
|
||||
+++ b/grub-core/loader/efi/chainloader.c
|
||||
@@ -156,9 +156,18 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename)
|
||||
|
||||
size = 0;
|
||||
d = dp;
|
||||
- while (1)
|
||||
+ while (d)
|
||||
{
|
||||
- size += GRUB_EFI_DEVICE_PATH_LENGTH (d);
|
||||
+ grub_size_t len = GRUB_EFI_DEVICE_PATH_LENGTH (d);
|
||||
+
|
||||
+ if (len < 4)
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
+ "malformed EFI Device Path node has length=%d", len);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ size += len;
|
||||
if ((GRUB_EFI_END_ENTIRE_DEVICE_PATH (d)))
|
||||
break;
|
||||
d = GRUB_EFI_NEXT_DEVICE_PATH (d);
|
||||
diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
|
||||
index b7d176b..c50cb54 100644
|
||||
--- a/grub-core/loader/i386/xnu.c
|
||||
+++ b/grub-core/loader/i386/xnu.c
|
||||
@@ -516,14 +516,15 @@ grub_cmd_devprop_load (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
devhead = buf;
|
||||
buf = devhead + 1;
|
||||
- dpstart = buf;
|
||||
+ dp = dpstart = buf;
|
||||
|
||||
- do
|
||||
+ while (GRUB_EFI_DEVICE_PATH_VALID (dp) && buf < bufend)
|
||||
{
|
||||
- dp = buf;
|
||||
buf = (char *) buf + GRUB_EFI_DEVICE_PATH_LENGTH (dp);
|
||||
+ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
|
||||
+ break;
|
||||
+ dp = buf;
|
||||
}
|
||||
- while (!GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp) && buf < bufend);
|
||||
|
||||
dev = grub_xnu_devprop_add_device (dpstart, (char *) buf
|
||||
- (char *) dpstart);
|
||||
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
|
||||
index addcbfa..cf1355a 100644
|
||||
--- a/include/grub/efi/api.h
|
||||
+++ b/include/grub/efi/api.h
|
||||
@@ -625,6 +625,7 @@ typedef struct grub_efi_device_path grub_efi_device_path_protocol_t;
|
||||
#define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f)
|
||||
#define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype)
|
||||
#define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length)
|
||||
+#define GRUB_EFI_DEVICE_PATH_VALID(dp) ((dp) != NULL && GRUB_EFI_DEVICE_PATH_LENGTH (dp) >= 4)
|
||||
|
||||
/* The End of Device Path nodes. */
|
||||
#define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f)
|
||||
@@ -633,13 +634,16 @@ typedef struct grub_efi_device_path grub_efi_device_path_protocol_t;
|
||||
#define GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE 0x01
|
||||
|
||||
#define GRUB_EFI_END_ENTIRE_DEVICE_PATH(dp) \
|
||||
- (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \
|
||||
- && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \
|
||||
- == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE))
|
||||
+ (!GRUB_EFI_DEVICE_PATH_VALID (dp) || \
|
||||
+ (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \
|
||||
+ && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \
|
||||
+ == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)))
|
||||
|
||||
#define GRUB_EFI_NEXT_DEVICE_PATH(dp) \
|
||||
- ((grub_efi_device_path_t *) ((char *) (dp) \
|
||||
- + GRUB_EFI_DEVICE_PATH_LENGTH (dp)))
|
||||
+ (GRUB_EFI_DEVICE_PATH_VALID (dp) \
|
||||
+ ? ((grub_efi_device_path_t *) \
|
||||
+ ((char *) (dp) + GRUB_EFI_DEVICE_PATH_LENGTH (dp))) \
|
||||
+ : NULL)
|
||||
|
||||
/* Hardware Device Path. */
|
||||
#define GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE 1
|
||||
@@ -0,0 +1,30 @@
|
||||
From d4fd0243920b71cc6e03cc0cadf23b4fe03c352f Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 5 Nov 2020 10:15:25 +0000
|
||||
Subject: [PATCH] kern/efi: Fix memory leak on failure
|
||||
|
||||
Free the memory allocated to name before returning on failure.
|
||||
|
||||
Fixes: CID 296222
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=ed286ceba6015d37a9304f04602451c47bf195d7]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/kern/efi/efi.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
|
||||
index 6a38080..baeeef0 100644
|
||||
--- a/grub-core/kern/efi/efi.c
|
||||
+++ b/grub-core/kern/efi/efi.c
|
||||
@@ -415,6 +415,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
"malformed EFI Device Path node has length=%d", len);
|
||||
+ grub_free (name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
From be03a18b8767be50f16a845c389fd5ed29aae055 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 11 Dec 2020 15:03:13 +0000
|
||||
Subject: [PATCH] kern/efi/mm: Fix possible NULL pointer dereference
|
||||
|
||||
The model of grub_efi_get_memory_map() is that if memory_map is NULL,
|
||||
then the purpose is to discover how much memory should be allocated to
|
||||
it for the subsequent call.
|
||||
|
||||
The problem here is that with grub_efi_is_finished set to 1, there is no
|
||||
check at all that the function is being called with a non-NULL memory_map.
|
||||
|
||||
While this MAY be true, we shouldn't assume it.
|
||||
|
||||
The solution to this is to behave as expected, and if memory_map is NULL,
|
||||
then don't try to use it and allow memory_map_size to be filled in, and
|
||||
return 0 as is done later in the code if the buffer is too small (or NULL).
|
||||
|
||||
Additionally, drop unneeded ret = 1.
|
||||
|
||||
Fixes: CID 96632
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=6aee4bfd6973c714056fb7b56890b8d524e94ee1]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/kern/efi/mm.c | 19 ++++++++++++++-----
|
||||
1 file changed, 14 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
|
||||
index b02fab1..5afcef7 100644
|
||||
--- a/grub-core/kern/efi/mm.c
|
||||
+++ b/grub-core/kern/efi/mm.c
|
||||
@@ -328,15 +328,24 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
|
||||
if (grub_efi_is_finished)
|
||||
{
|
||||
int ret = 1;
|
||||
- if (*memory_map_size < finish_mmap_size)
|
||||
+
|
||||
+ if (memory_map != NULL)
|
||||
{
|
||||
- grub_memcpy (memory_map, finish_mmap_buf, *memory_map_size);
|
||||
- ret = 0;
|
||||
+ if (*memory_map_size < finish_mmap_size)
|
||||
+ {
|
||||
+ grub_memcpy (memory_map, finish_mmap_buf, *memory_map_size);
|
||||
+ ret = 0;
|
||||
+ }
|
||||
+ else
|
||||
+ grub_memcpy (memory_map, finish_mmap_buf, finish_mmap_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
- grub_memcpy (memory_map, finish_mmap_buf, finish_mmap_size);
|
||||
- ret = 1;
|
||||
+ /*
|
||||
+ * Incomplete, no buffer to copy into, same as
|
||||
+ * GRUB_EFI_BUFFER_TOO_SMALL below.
|
||||
+ */
|
||||
+ ret = 0;
|
||||
}
|
||||
*memory_map_size = finish_mmap_size;
|
||||
if (map_key)
|
||||
@@ -0,0 +1,59 @@
|
||||
From 9d36bce5d516b6379ba3a0dd1a94a9c035838827 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Wed, 21 Oct 2020 14:41:27 +0000
|
||||
Subject: [PATCH] gnulib/regexec: Resolve unused variable
|
||||
|
||||
This is a really minor issue where a variable is being assigned to but
|
||||
not checked before it is overwritten again.
|
||||
|
||||
The reason for this issue is that we are not building with DEBUG set and
|
||||
this in turn means that the assert() that reads the value of the
|
||||
variable match_last is being processed out.
|
||||
|
||||
The solution, move the assignment to match_last in to an ifdef DEBUG too.
|
||||
|
||||
Fixes: CID 292459
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=a983d36bd9178d377d2072fd4b11c635fdc404b4]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
conf/Makefile.extra-dist | 1 +
|
||||
.../lib/gnulib-patches/fix-unused-value.patch | 14 ++++++++++++++
|
||||
2 files changed, 15 insertions(+)
|
||||
create mode 100644 grub-core/lib/gnulib-patches/fix-unused-value.patch
|
||||
|
||||
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
|
||||
index 46c4e95..9b01152 100644
|
||||
--- a/conf/Makefile.extra-dist
|
||||
+++ b/conf/Makefile.extra-dist
|
||||
@@ -29,6 +29,7 @@ EXTRA_DIST += grub-core/genemuinit.sh
|
||||
EXTRA_DIST += grub-core/genemuinitheader.sh
|
||||
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch
|
||||
+EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch
|
||||
|
||||
diff --git a/grub-core/lib/gnulib-patches/fix-unused-value.patch b/grub-core/lib/gnulib-patches/fix-unused-value.patch
|
||||
new file mode 100644
|
||||
index 0000000..ba51f1b
|
||||
--- /dev/null
|
||||
+++ b/grub-core/lib/gnulib-patches/fix-unused-value.patch
|
||||
@@ -0,0 +1,14 @@
|
||||
+--- a/lib/regexec.c 2020-10-21 14:25:35.310195912 +0000
|
||||
++++ b/lib/regexec.c 2020-10-21 14:32:07.961765604 +0000
|
||||
+@@ -828,7 +828,11 @@
|
||||
+ break;
|
||||
+ if (__glibc_unlikely (err != REG_NOMATCH))
|
||||
+ goto free_return;
|
||||
++#ifdef DEBUG
|
||||
++ /* Only used for assertion below when DEBUG is set, otherwise
|
||||
++ it will be over-written when we loop around. */
|
||||
+ match_last = -1;
|
||||
++#endif
|
||||
+ }
|
||||
+ else
|
||||
+ break; /* We found a match. */
|
||||
@@ -0,0 +1,53 @@
|
||||
From 2af8df02cca7fd4b584575eac304cd03fa23f5cc Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 22 Oct 2020 13:54:06 +0000
|
||||
Subject: [PATCH] gnulib/regcomp: Fix uninitialized token structure
|
||||
|
||||
The code is assuming that the value of br_token.constraint was
|
||||
initialized to zero when it wasn't.
|
||||
|
||||
While some compilers will ensure that, not all do, so it is better to
|
||||
fix this explicitly than leave it to chance.
|
||||
|
||||
Fixes: CID 73749
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=75c3d3cec4f408848f575d6d5e30a95bd6313db0]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
conf/Makefile.extra-dist | 1 +
|
||||
.../lib/gnulib-patches/fix-uninit-structure.patch | 11 +++++++++++
|
||||
2 files changed, 12 insertions(+)
|
||||
create mode 100644 grub-core/lib/gnulib-patches/fix-uninit-structure.patch
|
||||
|
||||
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
|
||||
index 9b01152..9e55458 100644
|
||||
--- a/conf/Makefile.extra-dist
|
||||
+++ b/conf/Makefile.extra-dist
|
||||
@@ -29,6 +29,7 @@ EXTRA_DIST += grub-core/genemuinit.sh
|
||||
EXTRA_DIST += grub-core/genemuinitheader.sh
|
||||
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch
|
||||
+EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch
|
||||
diff --git a/grub-core/lib/gnulib-patches/fix-uninit-structure.patch b/grub-core/lib/gnulib-patches/fix-uninit-structure.patch
|
||||
new file mode 100644
|
||||
index 0000000..7b4d9f6
|
||||
--- /dev/null
|
||||
+++ b/grub-core/lib/gnulib-patches/fix-uninit-structure.patch
|
||||
@@ -0,0 +1,11 @@
|
||||
+--- a/lib/regcomp.c 2020-10-22 13:49:06.770168928 +0000
|
||||
++++ b/lib/regcomp.c 2020-10-22 13:50:37.026528298 +0000
|
||||
+@@ -3662,7 +3662,7 @@
|
||||
+ Idx alloc = 0;
|
||||
+ #endif /* not RE_ENABLE_I18N */
|
||||
+ reg_errcode_t ret;
|
||||
+- re_token_t br_token;
|
||||
++ re_token_t br_token = {0};
|
||||
+ bin_tree_t *tree;
|
||||
+
|
||||
+ sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
|
||||
@@ -0,0 +1,52 @@
|
||||
From eaf9da8b5f8349c51cfc89dd8e39a1a61f89790a Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Wed, 28 Oct 2020 14:43:01 +0000
|
||||
Subject: [PATCH] gnulib/argp-help: Fix dereference of a possibly NULL state
|
||||
|
||||
All other instances of call to __argp_failure() where there is
|
||||
a dgettext() call is first checking whether state is NULL before
|
||||
attempting to dereference it to get the root_argp->argp_domain.
|
||||
|
||||
Fixes: CID 292436
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=3a37bf120a9194c373257c70175cdb5b337bc107]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
conf/Makefile.extra-dist | 1 +
|
||||
.../lib/gnulib-patches/fix-null-state-deref.patch | 12 ++++++++++++
|
||||
2 files changed, 13 insertions(+)
|
||||
create mode 100644 grub-core/lib/gnulib-patches/fix-null-state-deref.patch
|
||||
|
||||
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
|
||||
index 9e55458..96d7e69 100644
|
||||
--- a/conf/Makefile.extra-dist
|
||||
+++ b/conf/Makefile.extra-dist
|
||||
@@ -29,6 +29,7 @@ EXTRA_DIST += grub-core/genemuinit.sh
|
||||
EXTRA_DIST += grub-core/genemuinitheader.sh
|
||||
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch
|
||||
+EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-state-deref.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
|
||||
diff --git a/grub-core/lib/gnulib-patches/fix-null-state-deref.patch b/grub-core/lib/gnulib-patches/fix-null-state-deref.patch
|
||||
new file mode 100644
|
||||
index 0000000..813ec09
|
||||
--- /dev/null
|
||||
+++ b/grub-core/lib/gnulib-patches/fix-null-state-deref.patch
|
||||
@@ -0,0 +1,12 @@
|
||||
+--- a/lib/argp-help.c 2020-10-28 14:32:19.189215988 +0000
|
||||
++++ b/lib/argp-help.c 2020-10-28 14:38:21.204673940 +0000
|
||||
+@@ -145,7 +145,8 @@
|
||||
+ if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin)
|
||||
+ {
|
||||
+ __argp_failure (state, 0, 0,
|
||||
+- dgettext (state->root_argp->argp_domain,
|
||||
++ dgettext (state == NULL ? NULL
|
||||
++ : state->root_argp->argp_domain,
|
||||
+ "\
|
||||
+ ARGP_HELP_FMT: %s value is less than or equal to %s"),
|
||||
+ "rmargin", up->name);
|
||||
@@ -0,0 +1,53 @@
|
||||
From 244dc2b1f518635069a556c424b2e7627f0cf036 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 5 Nov 2020 10:57:14 +0000
|
||||
Subject: [PATCH] gnulib/regexec: Fix possible null-dereference
|
||||
|
||||
It appears to be possible that the mctx->state_log field may be NULL,
|
||||
and the name of this function, clean_state_log_if_needed(), suggests
|
||||
that it should be checking that it is valid to be cleaned before
|
||||
assuming that it does.
|
||||
|
||||
Fixes: CID 86720
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=0b7f347638153e403ee2dd518af3ce26f4f99647]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
conf/Makefile.extra-dist | 1 +
|
||||
.../lib/gnulib-patches/fix-regexec-null-deref.patch | 12 ++++++++++++
|
||||
2 files changed, 13 insertions(+)
|
||||
create mode 100644 grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
|
||||
|
||||
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
|
||||
index 96d7e69..d27d3a9 100644
|
||||
--- a/conf/Makefile.extra-dist
|
||||
+++ b/conf/Makefile.extra-dist
|
||||
@@ -30,6 +30,7 @@ EXTRA_DIST += grub-core/genemuinitheader.sh
|
||||
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-state-deref.patch
|
||||
+EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
|
||||
diff --git a/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch b/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
|
||||
new file mode 100644
|
||||
index 0000000..db6dac9
|
||||
--- /dev/null
|
||||
+++ b/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
|
||||
@@ -0,0 +1,12 @@
|
||||
+--- a/lib/regexec.c 2020-10-21 14:25:35.310195912 +0000
|
||||
++++ b/lib/regexec.c 2020-11-05 10:55:09.621542984 +0000
|
||||
+@@ -1692,6 +1692,9 @@
|
||||
+ {
|
||||
+ Idx top = mctx->state_log_top;
|
||||
+
|
||||
++ if (mctx->state_log == NULL)
|
||||
++ return REG_NOERROR;
|
||||
++
|
||||
+ if ((next_state_log_idx >= mctx->input.bufs_len
|
||||
+ && mctx->input.bufs_len < mctx->input.len)
|
||||
+ || (next_state_log_idx >= mctx->input.valid_len
|
||||
@@ -0,0 +1,55 @@
|
||||
From 512b6bb380a77233b88c84b7a712896c70281d2f Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 24 Nov 2020 18:04:22 +0000
|
||||
Subject: [PATCH] gnulib/regcomp: Fix uninitialized re_token
|
||||
|
||||
This issue has been fixed in the latest version of gnulib, so to
|
||||
maintain consistency, I've backported that change rather than doing
|
||||
something different.
|
||||
|
||||
Fixes: CID 73828
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=03477085f9a33789ba6cca7cd49ab9326a1baa0e]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
conf/Makefile.extra-dist | 1 +
|
||||
.../gnulib-patches/fix-regcomp-uninit-token.patch | 15 +++++++++++++++
|
||||
2 files changed, 16 insertions(+)
|
||||
create mode 100644 grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch
|
||||
|
||||
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
|
||||
index d27d3a9..ffe6829 100644
|
||||
--- a/conf/Makefile.extra-dist
|
||||
+++ b/conf/Makefile.extra-dist
|
||||
@@ -30,6 +30,7 @@ EXTRA_DIST += grub-core/genemuinitheader.sh
|
||||
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-state-deref.patch
|
||||
+EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch
|
||||
EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch
|
||||
diff --git a/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch b/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch
|
||||
new file mode 100644
|
||||
index 0000000..02e0631
|
||||
--- /dev/null
|
||||
+++ b/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch
|
||||
@@ -0,0 +1,15 @@
|
||||
+--- a/lib/regcomp.c 2020-11-24 17:06:08.159223858 +0000
|
||||
++++ b/lib/regcomp.c 2020-11-24 17:06:15.630253923 +0000
|
||||
+@@ -3808,11 +3808,7 @@
|
||||
+ create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
|
||||
+ re_token_type_t type)
|
||||
+ {
|
||||
+- re_token_t t;
|
||||
+-#if defined GCC_LINT || defined lint
|
||||
+- memset (&t, 0, sizeof t);
|
||||
+-#endif
|
||||
+- t.type = type;
|
||||
++ re_token_t t = { .type = type };
|
||||
+ return create_token_tree (dfa, left, right, &t);
|
||||
+ }
|
||||
+
|
||||
@@ -0,0 +1,41 @@
|
||||
From c529ca446424f1a9c64f0007dfe31fa7645d13ac Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Wed, 21 Oct 2020 14:44:10 +0000
|
||||
Subject: [PATCH] io/lzopio: Resolve unnecessary self-assignment errors
|
||||
|
||||
These 2 assignments are unnecessary since they are just assigning
|
||||
to themselves.
|
||||
|
||||
Fixes: CID 73643
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=59666e520f44177c97b82a44c169b3b315d63b42]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/io/lzopio.c | 4 ----
|
||||
1 file changed, 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/io/lzopio.c b/grub-core/io/lzopio.c
|
||||
index 3014485..a7d4425 100644
|
||||
--- a/grub-core/io/lzopio.c
|
||||
+++ b/grub-core/io/lzopio.c
|
||||
@@ -125,8 +125,6 @@ read_block_header (struct grub_lzopio *lzopio)
|
||||
sizeof (lzopio->block.ucheck)) !=
|
||||
sizeof (lzopio->block.ucheck))
|
||||
return -1;
|
||||
-
|
||||
- lzopio->block.ucheck = lzopio->block.ucheck;
|
||||
}
|
||||
|
||||
/* Read checksum of compressed data. */
|
||||
@@ -143,8 +141,6 @@ read_block_header (struct grub_lzopio *lzopio)
|
||||
sizeof (lzopio->block.ccheck)) !=
|
||||
sizeof (lzopio->block.ccheck))
|
||||
return -1;
|
||||
-
|
||||
- lzopio->block.ccheck = lzopio->block.ccheck;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
From f55ffe6bd8b844a8cd9956702f42ac2eb96ad56f Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 5 Nov 2020 10:29:59 +0000
|
||||
Subject: [PATCH] zstd: Initialize seq_t structure fully
|
||||
|
||||
While many compilers will initialize this to zero, not all will, so it
|
||||
is better to be sure that fields not being explicitly set are at known
|
||||
values, and there is code that checks this fields value elsewhere in the
|
||||
code.
|
||||
|
||||
Fixes: CID 292440
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=2777cf4466719921dbe4b30af358a75e7d76f217]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/lib/zstd/zstd_decompress.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/lib/zstd/zstd_decompress.c b/grub-core/lib/zstd/zstd_decompress.c
|
||||
index 711b5b6..e4b5670 100644
|
||||
--- a/grub-core/lib/zstd/zstd_decompress.c
|
||||
+++ b/grub-core/lib/zstd/zstd_decompress.c
|
||||
@@ -1325,7 +1325,7 @@ typedef enum { ZSTD_lo_isRegularOffset, ZSTD_lo_isLongOffset=1 } ZSTD_longOffset
|
||||
FORCE_INLINE_TEMPLATE seq_t
|
||||
ZSTD_decodeSequence(seqState_t* seqState, const ZSTD_longOffset_e longOffsets)
|
||||
{
|
||||
- seq_t seq;
|
||||
+ seq_t seq = {0};
|
||||
U32 const llBits = seqState->stateLL.table[seqState->stateLL.state].nbAdditionalBits;
|
||||
U32 const mlBits = seqState->stateML.table[seqState->stateML.state].nbAdditionalBits;
|
||||
U32 const ofBits = seqState->stateOffb.table[seqState->stateOffb.state].nbAdditionalBits;
|
||||
@@ -0,0 +1,43 @@
|
||||
From 0da8ef2e03a8591586b53a29af92d2ace76a04e3 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 23 Oct 2020 09:49:59 +0000
|
||||
Subject: [PATCH] kern/partition: Check for NULL before dereferencing input
|
||||
string
|
||||
|
||||
There is the possibility that the value of str comes from an external
|
||||
source and continuing to use it before ever checking its validity is
|
||||
wrong. So, needs fixing.
|
||||
|
||||
Additionally, drop unneeded part initialization.
|
||||
|
||||
Fixes: CID 292444
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=bc9c468a2ce84bc767234eec888b71f1bc744fff]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/kern/partition.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c
|
||||
index e499147..b10a184 100644
|
||||
--- a/grub-core/kern/partition.c
|
||||
+++ b/grub-core/kern/partition.c
|
||||
@@ -109,11 +109,14 @@ grub_partition_map_probe (const grub_partition_map_t partmap,
|
||||
grub_partition_t
|
||||
grub_partition_probe (struct grub_disk *disk, const char *str)
|
||||
{
|
||||
- grub_partition_t part = 0;
|
||||
+ grub_partition_t part;
|
||||
grub_partition_t curpart = 0;
|
||||
grub_partition_t tail;
|
||||
const char *ptr;
|
||||
|
||||
+ if (str == NULL)
|
||||
+ return 0;
|
||||
+
|
||||
part = tail = disk->partition;
|
||||
|
||||
for (ptr = str; *ptr;)
|
||||
@@ -0,0 +1,128 @@
|
||||
From 0c5d0fd796e6cafba179321de396681a493c4158 Mon Sep 17 00:00:00 2001
|
||||
From: Marco A Benatto <mbenatto@redhat.com>
|
||||
Date: Mon, 7 Dec 2020 11:53:03 -0300
|
||||
Subject: [PATCH] disk/ldm: Make sure comp data is freed before exiting from
|
||||
make_vg()
|
||||
|
||||
Several error handling paths in make_vg() do not free comp data before
|
||||
jumping to fail2 label and returning from the function. This will leak
|
||||
memory. So, let's fix all issues of that kind.
|
||||
|
||||
Fixes: CID 73804
|
||||
|
||||
Signed-off-by: Marco A Benatto <mbenatto@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=23e39f50ca7a107f6b66396ed4d177a914dee035]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/disk/ldm.c | 51 ++++++++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 44 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
|
||||
index 58f8a53..428415f 100644
|
||||
--- a/grub-core/disk/ldm.c
|
||||
+++ b/grub-core/disk/ldm.c
|
||||
@@ -554,7 +554,11 @@ make_vg (grub_disk_t disk,
|
||||
comp->segments = grub_calloc (comp->segment_alloc,
|
||||
sizeof (*comp->segments));
|
||||
if (!comp->segments)
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (comp->internal_id);
|
||||
+ grub_free (comp);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -562,7 +566,11 @@ make_vg (grub_disk_t disk,
|
||||
comp->segment_count = 1;
|
||||
comp->segments = grub_malloc (sizeof (*comp->segments));
|
||||
if (!comp->segments)
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (comp->internal_id);
|
||||
+ grub_free (comp);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
comp->segments->start_extent = 0;
|
||||
comp->segments->extent_count = lv->size;
|
||||
comp->segments->layout = 0;
|
||||
@@ -574,15 +582,26 @@ make_vg (grub_disk_t disk,
|
||||
comp->segments->layout = GRUB_RAID_LAYOUT_SYMMETRIC_MASK;
|
||||
}
|
||||
else
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (comp->segments);
|
||||
+ grub_free (comp->internal_id);
|
||||
+ grub_free (comp);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
ptr += *ptr + 1;
|
||||
ptr++;
|
||||
if (!(vblk[i].flags & 0x10))
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (comp->segments);
|
||||
+ grub_free (comp->internal_id);
|
||||
+ grub_free (comp);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
if (ptr >= vblk[i].dynamic + sizeof (vblk[i].dynamic)
|
||||
|| ptr + *ptr + 1 >= vblk[i].dynamic
|
||||
+ sizeof (vblk[i].dynamic))
|
||||
{
|
||||
+ grub_free (comp->segments);
|
||||
grub_free (comp->internal_id);
|
||||
grub_free (comp);
|
||||
goto fail2;
|
||||
@@ -592,6 +611,7 @@ make_vg (grub_disk_t disk,
|
||||
if (ptr + *ptr + 1 >= vblk[i].dynamic
|
||||
+ sizeof (vblk[i].dynamic))
|
||||
{
|
||||
+ grub_free (comp->segments);
|
||||
grub_free (comp->internal_id);
|
||||
grub_free (comp);
|
||||
goto fail2;
|
||||
@@ -601,7 +621,12 @@ make_vg (grub_disk_t disk,
|
||||
comp->segments->nodes = grub_calloc (comp->segments->node_alloc,
|
||||
sizeof (*comp->segments->nodes));
|
||||
if (!lv->segments->nodes)
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (comp->segments);
|
||||
+ grub_free (comp->internal_id);
|
||||
+ grub_free (comp);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (lv->segments->node_alloc == lv->segments->node_count)
|
||||
@@ -611,11 +636,23 @@ make_vg (grub_disk_t disk,
|
||||
|
||||
if (grub_mul (lv->segments->node_alloc, 2, &lv->segments->node_alloc) ||
|
||||
grub_mul (lv->segments->node_alloc, sizeof (*lv->segments->nodes), &sz))
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (comp->segments->nodes);
|
||||
+ grub_free (comp->segments);
|
||||
+ grub_free (comp->internal_id);
|
||||
+ grub_free (comp);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
|
||||
t = grub_realloc (lv->segments->nodes, sz);
|
||||
if (!t)
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (comp->segments->nodes);
|
||||
+ grub_free (comp->segments);
|
||||
+ grub_free (comp->internal_id);
|
||||
+ grub_free (comp);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
lv->segments->nodes = t;
|
||||
}
|
||||
lv->segments->nodes[lv->segments->node_count].pv = 0;
|
||||
@@ -0,0 +1,28 @@
|
||||
From 253485e8df3c9dedac848567e638157530184295 Mon Sep 17 00:00:00 2001
|
||||
From: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
|
||||
Date: Mon, 7 Dec 2020 10:07:47 -0300
|
||||
Subject: [PATCH] disk/ldm: If failed then free vg variable too
|
||||
|
||||
Fixes: CID 73809
|
||||
|
||||
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=e0b83df5da538d2a38f770e60817b3a4b9d5b4d7]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/disk/ldm.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
|
||||
index 428415f..54713f4 100644
|
||||
--- a/grub-core/disk/ldm.c
|
||||
+++ b/grub-core/disk/ldm.c
|
||||
@@ -199,6 +199,7 @@ make_vg (grub_disk_t disk,
|
||||
{
|
||||
grub_free (vg->uuid);
|
||||
grub_free (vg->name);
|
||||
+ grub_free (vg);
|
||||
return NULL;
|
||||
}
|
||||
grub_memcpy (vg->uuid, label->group_guid, LDM_GUID_STRLEN);
|
||||
@@ -0,0 +1,50 @@
|
||||
From 3e1d2f1959acbe5152cdd5818d495f6455d1a158 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 8 Dec 2020 10:00:51 +0000
|
||||
Subject: [PATCH] disk/ldm: Fix memory leak on uninserted lv references
|
||||
|
||||
The problem here is that the memory allocated to the variable lv is not
|
||||
yet inserted into the list that is being processed at the label fail2.
|
||||
|
||||
As we can already see at line 342, which correctly frees lv before going
|
||||
to fail2, we should also be doing that at these earlier jumps to fail2.
|
||||
|
||||
Fixes: CID 73824
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=156c281a1625dc73fd350530630c6f2d5673d4f6]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/disk/ldm.c | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
|
||||
index 54713f4..e82e989 100644
|
||||
--- a/grub-core/disk/ldm.c
|
||||
+++ b/grub-core/disk/ldm.c
|
||||
@@ -321,7 +321,10 @@ make_vg (grub_disk_t disk,
|
||||
lv->visible = 1;
|
||||
lv->segments = grub_zalloc (sizeof (*lv->segments));
|
||||
if (!lv->segments)
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (lv);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
lv->segments->start_extent = 0;
|
||||
lv->segments->type = GRUB_DISKFILTER_MIRROR;
|
||||
lv->segments->node_count = 0;
|
||||
@@ -329,7 +332,10 @@ make_vg (grub_disk_t disk,
|
||||
lv->segments->nodes = grub_calloc (lv->segments->node_alloc,
|
||||
sizeof (*lv->segments->nodes));
|
||||
if (!lv->segments->nodes)
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (lv);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
ptr = vblk[i].dynamic;
|
||||
if (ptr + *ptr + 1 >= vblk[i].dynamic
|
||||
+ sizeof (vblk[i].dynamic))
|
||||
@@ -0,0 +1,50 @@
|
||||
From 2550aaa0c23fdf8b6c54e00c6b838f2e3aa81fe2 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 21 Jan 2021 11:38:31 +0000
|
||||
Subject: [PATCH] disk/cryptodisk: Fix potential integer overflow
|
||||
|
||||
The encrypt and decrypt functions expect a grub_size_t. So, we need to
|
||||
ensure that the constant bit shift is using grub_size_t rather than
|
||||
unsigned int when it is performing the shift.
|
||||
|
||||
Fixes: CID 307788
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=a201ad17caa430aa710654fdf2e6ab4c8166f031]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/disk/cryptodisk.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
|
||||
index 5037768..6883f48 100644
|
||||
--- a/grub-core/disk/cryptodisk.c
|
||||
+++ b/grub-core/disk/cryptodisk.c
|
||||
@@ -311,10 +311,10 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
case GRUB_CRYPTODISK_MODE_CBC:
|
||||
if (do_encrypt)
|
||||
err = grub_crypto_cbc_encrypt (dev->cipher, data + i, data + i,
|
||||
- (1U << dev->log_sector_size), iv);
|
||||
+ ((grub_size_t) 1 << dev->log_sector_size), iv);
|
||||
else
|
||||
err = grub_crypto_cbc_decrypt (dev->cipher, data + i, data + i,
|
||||
- (1U << dev->log_sector_size), iv);
|
||||
+ ((grub_size_t) 1 << dev->log_sector_size), iv);
|
||||
if (err)
|
||||
return err;
|
||||
break;
|
||||
@@ -322,10 +322,10 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
case GRUB_CRYPTODISK_MODE_PCBC:
|
||||
if (do_encrypt)
|
||||
err = grub_crypto_pcbc_encrypt (dev->cipher, data + i, data + i,
|
||||
- (1U << dev->log_sector_size), iv);
|
||||
+ ((grub_size_t) 1 << dev->log_sector_size), iv);
|
||||
else
|
||||
err = grub_crypto_pcbc_decrypt (dev->cipher, data + i, data + i,
|
||||
- (1U << dev->log_sector_size), iv);
|
||||
+ ((grub_size_t) 1 << dev->log_sector_size), iv);
|
||||
if (err)
|
||||
return err;
|
||||
break;
|
||||
@@ -0,0 +1,43 @@
|
||||
From 7c1813eeec78892fa651046cc224ae4e80d0c94d Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 23 Oct 2020 17:09:31 +0000
|
||||
Subject: [PATCH] hfsplus: Check that the volume name length is valid
|
||||
|
||||
HFS+ documentation suggests that the maximum filename and volume name is
|
||||
255 Unicode characters in length.
|
||||
|
||||
So, when converting from big-endian to little-endian, we should ensure
|
||||
that the name of the volume has a length that is between 0 and 255,
|
||||
inclusive.
|
||||
|
||||
Fixes: CID 73641
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=2298f6e0d951251bb9ca97d891d1bc8b74515f8c]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/fs/hfsplus.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c
|
||||
index dae43be..03c3c4c 100644
|
||||
--- a/grub-core/fs/hfsplus.c
|
||||
+++ b/grub-core/fs/hfsplus.c
|
||||
@@ -1007,6 +1007,15 @@ grub_hfsplus_label (grub_device_t device, char **label)
|
||||
grub_hfsplus_btree_recptr (&data->catalog_tree, node, ptr);
|
||||
|
||||
label_len = grub_be_to_cpu16 (catkey->namelen);
|
||||
+
|
||||
+ /* Ensure that the length is >= 0. */
|
||||
+ if (label_len < 0)
|
||||
+ label_len = 0;
|
||||
+
|
||||
+ /* Ensure label length is at most 255 Unicode characters. */
|
||||
+ if (label_len > 255)
|
||||
+ label_len = 255;
|
||||
+
|
||||
label_name = grub_calloc (label_len, sizeof (*label_name));
|
||||
if (!label_name)
|
||||
{
|
||||
@@ -0,0 +1,42 @@
|
||||
From c757779e5d09719666c3b155afd2421978a107bd Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 24 Nov 2020 16:41:49 +0000
|
||||
Subject: [PATCH] zfs: Fix possible negative shift operation
|
||||
|
||||
While it is possible for the return value from zfs_log2() to be zero
|
||||
(0), it is quite unlikely, given that the previous assignment to blksz
|
||||
is shifted up by SPA_MINBLOCKSHIFT (9) before 9 is subtracted at the
|
||||
assignment to epbs.
|
||||
|
||||
But, while unlikely during a normal operation, it may be that a carefully
|
||||
crafted ZFS filesystem could result in a zero (0) value to the
|
||||
dn_datalbkszsec field, which means that the shift left does nothing
|
||||
and assigns zero (0) to blksz, resulting in a negative epbs value.
|
||||
|
||||
Fixes: CID 73608
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=a02091834d3e167320d8a262ff04b8e83c5e616d]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/fs/zfs/zfs.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
|
||||
index 36d0373..0c42cba 100644
|
||||
--- a/grub-core/fs/zfs/zfs.c
|
||||
+++ b/grub-core/fs/zfs/zfs.c
|
||||
@@ -2667,6 +2667,11 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type,
|
||||
blksz = grub_zfs_to_cpu16 (mdn->dn.dn_datablkszsec,
|
||||
mdn->endian) << SPA_MINBLOCKSHIFT;
|
||||
epbs = zfs_log2 (blksz) - DNODE_SHIFT;
|
||||
+
|
||||
+ /* While this should never happen, we should check that epbs is not negative. */
|
||||
+ if (epbs < 0)
|
||||
+ epbs = 0;
|
||||
+
|
||||
blkid = objnum >> epbs;
|
||||
idx = objnum & ((1 << epbs) - 1);
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
From 83fdffc07ec4586b375ab36189f255ffbd8f99c2 Mon Sep 17 00:00:00 2001
|
||||
From: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
|
||||
Date: Mon, 14 Dec 2020 18:54:49 -0300
|
||||
Subject: [PATCH] zfs: Fix resource leaks while constructing path
|
||||
|
||||
There are several exit points in dnode_get_path() that are causing possible
|
||||
memory leaks.
|
||||
|
||||
In the while(1) the correct exit mechanism should not be to do a direct return,
|
||||
but to instead break out of the loop, setting err first if it is not already set.
|
||||
|
||||
The reason behind this is that the dnode_path is a linked list, and while doing
|
||||
through this loop, it is being allocated and built up - the only way to
|
||||
correctly unravel it is to traverse it, which is what is being done at the end
|
||||
of the function outside of the loop.
|
||||
|
||||
Several of the existing exit points correctly did a break, but not all so this
|
||||
change makes that more consistent and should resolve the leaking of memory as
|
||||
found by Coverity.
|
||||
|
||||
Fixes: CID 73741
|
||||
|
||||
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=89bdab965805e8d54d7f75349024e1a11cbe2eb8]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/fs/zfs/zfs.c | 30 +++++++++++++++++++++---------
|
||||
1 file changed, 21 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
|
||||
index 0c42cba..9087a72 100644
|
||||
--- a/grub-core/fs/zfs/zfs.c
|
||||
+++ b/grub-core/fs/zfs/zfs.c
|
||||
@@ -2836,8 +2836,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
||||
|
||||
if (dnode_path->dn.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS)
|
||||
{
|
||||
- grub_free (path_buf);
|
||||
- return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
|
||||
+ err = grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
|
||||
+ break;
|
||||
}
|
||||
err = zap_lookup (&(dnode_path->dn), cname, &objnum,
|
||||
data, subvol->case_insensitive);
|
||||
@@ -2879,11 +2879,18 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
||||
<< SPA_MINBLOCKSHIFT);
|
||||
|
||||
if (blksz == 0)
|
||||
- return grub_error(GRUB_ERR_BAD_FS, "0-sized block");
|
||||
+ {
|
||||
+ err = grub_error (GRUB_ERR_BAD_FS, "0-sized block");
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
sym_value = grub_malloc (sym_sz);
|
||||
if (!sym_value)
|
||||
- return grub_errno;
|
||||
+ {
|
||||
+ err = grub_errno;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
for (block = 0; block < (sym_sz + blksz - 1) / blksz; block++)
|
||||
{
|
||||
void *t;
|
||||
@@ -2893,7 +2900,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
||||
if (err)
|
||||
{
|
||||
grub_free (sym_value);
|
||||
- return err;
|
||||
+ break;
|
||||
}
|
||||
|
||||
movesize = sym_sz - block * blksz;
|
||||
@@ -2903,6 +2910,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
||||
grub_memcpy (sym_value + block * blksz, t, movesize);
|
||||
grub_free (t);
|
||||
}
|
||||
+ if (err)
|
||||
+ break;
|
||||
free_symval = 1;
|
||||
}
|
||||
path = path_buf = grub_malloc (sym_sz + grub_strlen (oldpath) + 1);
|
||||
@@ -2911,7 +2920,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
||||
grub_free (oldpathbuf);
|
||||
if (free_symval)
|
||||
grub_free (sym_value);
|
||||
- return grub_errno;
|
||||
+ err = grub_errno;
|
||||
+ break;
|
||||
}
|
||||
grub_memcpy (path, sym_value, sym_sz);
|
||||
if (free_symval)
|
||||
@@ -2949,11 +2959,12 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
||||
|
||||
err = zio_read (bp, dnode_path->dn.endian, &sahdrp, NULL, data);
|
||||
if (err)
|
||||
- return err;
|
||||
+ break;
|
||||
}
|
||||
else
|
||||
{
|
||||
- return grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
|
||||
+ err = grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
|
||||
+ break;
|
||||
}
|
||||
|
||||
hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp));
|
||||
@@ -2974,7 +2985,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
|
||||
if (!path_buf)
|
||||
{
|
||||
grub_free (oldpathbuf);
|
||||
- return grub_errno;
|
||||
+ err = grub_errno;
|
||||
+ break;
|
||||
}
|
||||
grub_memcpy (path, sym_value, sym_sz);
|
||||
path [sym_sz] = 0;
|
||||
@@ -0,0 +1,56 @@
|
||||
From ec35d862f3567671048aa0d0d8ad1ded1fd25336 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 8 Dec 2020 22:17:04 +0000
|
||||
Subject: [PATCH] zfs: Fix possible integer overflows
|
||||
|
||||
In all cases the problem is that the value being acted upon by
|
||||
a left-shift is a 32-bit number which is then being used in the
|
||||
context of a 64-bit number.
|
||||
|
||||
To avoid overflow we ensure that the number being shifted is 64-bit
|
||||
before the shift is done.
|
||||
|
||||
Fixes: CID 73684, CID 73695, CID 73764
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=302c12ff5714bc455949117c1c9548ccb324d55b]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/fs/zfs/zfs.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
|
||||
index 9087a72..b078ccc 100644
|
||||
--- a/grub-core/fs/zfs/zfs.c
|
||||
+++ b/grub-core/fs/zfs/zfs.c
|
||||
@@ -564,7 +564,7 @@ find_bestub (uberblock_phys_t * ub_array,
|
||||
ubptr = (uberblock_phys_t *) ((grub_properly_aligned_t *) ub_array
|
||||
+ ((i << ub_shift)
|
||||
/ sizeof (grub_properly_aligned_t)));
|
||||
- err = uberblock_verify (ubptr, offset, 1 << ub_shift);
|
||||
+ err = uberblock_verify (ubptr, offset, (grub_size_t) 1 << ub_shift);
|
||||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
@@ -1543,7 +1543,7 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
|
||||
|
||||
high = grub_divmod64 ((offset >> desc->ashift) + c,
|
||||
desc->n_children, &devn);
|
||||
- csize = bsize << desc->ashift;
|
||||
+ csize = (grub_size_t) bsize << desc->ashift;
|
||||
if (csize > len)
|
||||
csize = len;
|
||||
|
||||
@@ -1635,8 +1635,8 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
- grub_size_t csize;
|
||||
- csize = ((s / (desc->n_children - desc->nparity))
|
||||
+ grub_size_t csize = s;
|
||||
+ csize = ((csize / (desc->n_children - desc->nparity))
|
||||
<< desc->ashift);
|
||||
if (csize > len)
|
||||
csize = len;
|
||||
@@ -0,0 +1,35 @@
|
||||
From b085da8efda9b81f94aa197ee045226563554fdf Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 26 Nov 2020 10:56:45 +0000
|
||||
Subject: [PATCH] zfsinfo: Correct a check for error allocating memory
|
||||
|
||||
While arguably the check for grub_errno is correct, we should really be
|
||||
checking the return value from the function since it is always possible
|
||||
that grub_errno was set elsewhere, making this code behave incorrectly.
|
||||
|
||||
Fixes: CID 73668
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=7aab03418ec6a9b991aa44416cb2585aff4e7972]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/fs/zfs/zfsinfo.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c
|
||||
index c8a28ac..bf29180 100644
|
||||
--- a/grub-core/fs/zfs/zfsinfo.c
|
||||
+++ b/grub-core/fs/zfs/zfsinfo.c
|
||||
@@ -358,8 +358,8 @@ grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc,
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
|
||||
devname = grub_file_get_device_name (args[0]);
|
||||
- if (grub_errno)
|
||||
- return grub_errno;
|
||||
+ if (devname == NULL)
|
||||
+ return GRUB_ERR_OUT_OF_MEMORY;
|
||||
|
||||
dev = grub_device_open (devname);
|
||||
grub_free (devname);
|
||||
82
meta/recipes-bsp/grub/files/0025-affs-Fix-memory-leaks.patch
Normal file
82
meta/recipes-bsp/grub/files/0025-affs-Fix-memory-leaks.patch
Normal file
@@ -0,0 +1,82 @@
|
||||
From 929c2ce8214c53cb95abff57a89556cd18444097 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 26 Nov 2020 12:48:07 +0000
|
||||
Subject: [PATCH] affs: Fix memory leaks
|
||||
|
||||
The node structure reference is being allocated but not freed if it
|
||||
reaches the end of the function. If any of the hooks had returned
|
||||
a non-zero value, then node would have been copied in to the context
|
||||
reference, but otherwise node is not stored and should be freed.
|
||||
|
||||
Similarly, the call to grub_affs_create_node() replaces the allocated
|
||||
memory in node with a newly allocated structure, leaking the existing
|
||||
memory pointed by node.
|
||||
|
||||
Finally, when dir->parent is set, then we again replace node with newly
|
||||
allocated memory, which seems unnecessary when we copy in the values
|
||||
from dir->parent immediately after.
|
||||
|
||||
Fixes: CID 73759
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=178ac5107389f8e5b32489d743d6824a5ebf342a]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/fs/affs.c | 18 ++++++++----------
|
||||
1 file changed, 8 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c
|
||||
index 220b371..230e26a 100644
|
||||
--- a/grub-core/fs/affs.c
|
||||
+++ b/grub-core/fs/affs.c
|
||||
@@ -400,12 +400,12 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
|
||||
{
|
||||
unsigned int i;
|
||||
struct grub_affs_file file;
|
||||
- struct grub_fshelp_node *node = 0;
|
||||
+ struct grub_fshelp_node *node, *orig_node;
|
||||
struct grub_affs_data *data = dir->data;
|
||||
grub_uint32_t *hashtable;
|
||||
|
||||
/* Create the directory entries for `.' and `..'. */
|
||||
- node = grub_zalloc (sizeof (*node));
|
||||
+ node = orig_node = grub_zalloc (sizeof (*node));
|
||||
if (!node)
|
||||
return 1;
|
||||
|
||||
@@ -414,9 +414,6 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
|
||||
return 1;
|
||||
if (dir->parent)
|
||||
{
|
||||
- node = grub_zalloc (sizeof (*node));
|
||||
- if (!node)
|
||||
- return 1;
|
||||
*node = *dir->parent;
|
||||
if (hook ("..", GRUB_FSHELP_DIR, node, hook_data))
|
||||
return 1;
|
||||
@@ -456,17 +453,18 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
|
||||
|
||||
if (grub_affs_create_node (dir, hook, hook_data, &node, &hashtable,
|
||||
next, &file))
|
||||
- return 1;
|
||||
+ {
|
||||
+ /* Node has been replaced in function. */
|
||||
+ grub_free (orig_node);
|
||||
+ return 1;
|
||||
+ }
|
||||
|
||||
next = grub_be_to_cpu32 (file.next);
|
||||
}
|
||||
}
|
||||
|
||||
- grub_free (hashtable);
|
||||
- return 0;
|
||||
-
|
||||
fail:
|
||||
- grub_free (node);
|
||||
+ grub_free (orig_node);
|
||||
grub_free (hashtable);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
From 9b16d7bcad1c7fea7f26eb2fb3af1a5ca70ba34e Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 3 Nov 2020 16:43:37 +0000
|
||||
Subject: [PATCH] libgcrypt/mpi: Fix possible unintended sign extension
|
||||
|
||||
The array of unsigned char gets promoted to a signed 32-bit int before
|
||||
it is finally promoted to a size_t. There is the possibility that this
|
||||
may result in the signed-bit being set for the intermediate signed
|
||||
32-bit int. We should ensure that the promotion is to the correct type
|
||||
before we bitwise-OR the values.
|
||||
|
||||
Fixes: CID 96697
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=e8814c811132a70f9b55418f7567378a34ad3883]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
|
||||
---
|
||||
grub-core/lib/libgcrypt/mpi/mpicoder.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/lib/libgcrypt/mpi/mpicoder.c b/grub-core/lib/libgcrypt/mpi/mpicoder.c
|
||||
index a3435ed..7ecad27 100644
|
||||
--- a/grub-core/lib/libgcrypt/mpi/mpicoder.c
|
||||
+++ b/grub-core/lib/libgcrypt/mpi/mpicoder.c
|
||||
@@ -458,7 +458,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
|
||||
if (len && len < 4)
|
||||
return gcry_error (GPG_ERR_TOO_SHORT);
|
||||
|
||||
- n = (s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
|
||||
+ n = ((size_t)s[0] << 24 | (size_t)s[1] << 16 | (size_t)s[2] << 8 | (size_t)s[3]);
|
||||
s += 4;
|
||||
if (len)
|
||||
len -= 4;
|
||||
@@ -0,0 +1,33 @@
|
||||
From d26c8771293637b0465f2cb67d97cb58bacc62da Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 26 Nov 2020 10:41:54 +0000
|
||||
Subject: [PATCH] libgcrypt/mpi: Fix possible NULL dereference
|
||||
|
||||
The code in gcry_mpi_scan() assumes that buffer is not NULL, but there
|
||||
is no explicit check for that, so we add one.
|
||||
|
||||
Fixes: CID 73757
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=ae0f3fabeba7b393113d5dc185b6aff9b728136d]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/lib/libgcrypt/mpi/mpicoder.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/grub-core/lib/libgcrypt/mpi/mpicoder.c b/grub-core/lib/libgcrypt/mpi/mpicoder.c
|
||||
index 7ecad27..6fe3891 100644
|
||||
--- a/grub-core/lib/libgcrypt/mpi/mpicoder.c
|
||||
+++ b/grub-core/lib/libgcrypt/mpi/mpicoder.c
|
||||
@@ -379,6 +379,9 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
|
||||
unsigned int len;
|
||||
int secure = (buffer && gcry_is_secure (buffer));
|
||||
|
||||
+ if (!buffer)
|
||||
+ return gcry_error (GPG_ERR_INV_ARG);
|
||||
+
|
||||
if (format == GCRYMPI_FMT_SSH)
|
||||
len = 0;
|
||||
else
|
||||
@@ -0,0 +1,43 @@
|
||||
From ea12feb69b6af93c7e2fa03df7ac3bd1f4edd599 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 26 Nov 2020 15:31:53 +0000
|
||||
Subject: [PATCH] syslinux: Fix memory leak while parsing
|
||||
|
||||
In syslinux_parse_real() the 2 points where return is being called
|
||||
didn't release the memory stored in buf which is no longer required.
|
||||
|
||||
Fixes: CID 176634
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=95bc016dba94cab3d398dd74160665915cd08ad6]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/lib/syslinux_parse.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
|
||||
index 4afa992..3acc6b4 100644
|
||||
--- a/grub-core/lib/syslinux_parse.c
|
||||
+++ b/grub-core/lib/syslinux_parse.c
|
||||
@@ -737,7 +737,10 @@ syslinux_parse_real (struct syslinux_menu *menu)
|
||||
&& grub_strncasecmp ("help", ptr3, ptr4 - ptr3) == 0))
|
||||
{
|
||||
if (helptext (ptr5, file, menu))
|
||||
- return 1;
|
||||
+ {
|
||||
+ grub_free (buf);
|
||||
+ return 1;
|
||||
+ }
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -757,6 +760,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
|
||||
}
|
||||
fail:
|
||||
grub_file_close (file);
|
||||
+ grub_free (buf);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
From 2367049d2021e00d82d19cee923e06a4b04ebc30 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 4 Dec 2020 18:56:48 +0000
|
||||
Subject: [PATCH] normal/completion: Fix leaking of memory when processing a
|
||||
completion
|
||||
|
||||
It is possible for the code to reach the end of the function without
|
||||
freeing the memory allocated to argv and argc still to be 0.
|
||||
|
||||
We should always call grub_free(argv). The grub_free() will handle
|
||||
a NULL argument correctly if it reaches that code without the memory
|
||||
being allocated.
|
||||
|
||||
Fixes: CID 96672
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=9213575b7a95b514bce80be5964a28d407d7d56d]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/normal/completion.c | 10 ++++------
|
||||
1 file changed, 4 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c
|
||||
index 5961028..46e473c 100644
|
||||
--- a/grub-core/normal/completion.c
|
||||
+++ b/grub-core/normal/completion.c
|
||||
@@ -400,8 +400,8 @@ char *
|
||||
grub_normal_do_completion (char *buf, int *restore,
|
||||
void (*hook) (const char *, grub_completion_type_t, int))
|
||||
{
|
||||
- int argc;
|
||||
- char **argv;
|
||||
+ int argc = 0;
|
||||
+ char **argv = NULL;
|
||||
|
||||
/* Initialize variables. */
|
||||
match = 0;
|
||||
@@ -516,10 +516,8 @@ grub_normal_do_completion (char *buf, int *restore,
|
||||
|
||||
fail:
|
||||
if (argc != 0)
|
||||
- {
|
||||
- grub_free (argv[0]);
|
||||
- grub_free (argv);
|
||||
- }
|
||||
+ grub_free (argv[0]);
|
||||
+ grub_free (argv);
|
||||
grub_free (match);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
From b136fa14d26d1833ffcb852f86e65da5960cfb99 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Coulson <chris.coulson@canonical.com>
|
||||
Date: Tue, 1 Dec 2020 23:41:24 +0000
|
||||
Subject: [PATCH] commands/hashsum: Fix a memory leak
|
||||
|
||||
check_list() uses grub_file_getline(), which allocates a buffer.
|
||||
If the hash list file contains invalid lines, the function leaks
|
||||
this buffer when it returns an error.
|
||||
|
||||
Fixes: CID 176635
|
||||
|
||||
Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=8b6f528e52e18b7a69f90b8dc3671d7b1147d9f3]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/commands/hashsum.c | 15 ++++++++++++---
|
||||
1 file changed, 12 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/hashsum.c b/grub-core/commands/hashsum.c
|
||||
index 456ba90..b8a22b0 100644
|
||||
--- a/grub-core/commands/hashsum.c
|
||||
+++ b/grub-core/commands/hashsum.c
|
||||
@@ -128,11 +128,17 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
||||
high = hextoval (*p++);
|
||||
low = hextoval (*p++);
|
||||
if (high < 0 || low < 0)
|
||||
- return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
|
||||
+ {
|
||||
+ grub_free (buf);
|
||||
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
|
||||
+ }
|
||||
expected[i] = (high << 4) | low;
|
||||
}
|
||||
if ((p[0] != ' ' && p[0] != '\t') || (p[1] != ' ' && p[1] != '\t'))
|
||||
- return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
|
||||
+ {
|
||||
+ grub_free (buf);
|
||||
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
|
||||
+ }
|
||||
p += 2;
|
||||
if (prefix)
|
||||
{
|
||||
@@ -140,7 +146,10 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
||||
|
||||
filename = grub_xasprintf ("%s/%s", prefix, p);
|
||||
if (!filename)
|
||||
- return grub_errno;
|
||||
+ {
|
||||
+ grub_free (buf);
|
||||
+ return grub_errno;
|
||||
+ }
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: GRUB_FILE_TYPE_NONE));
|
||||
@@ -0,0 +1,94 @@
|
||||
From 2a1e5659763790201a342f8a897c8c9d8d91b1cc Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 8 Dec 2020 21:14:31 +0000
|
||||
Subject: [PATCH] video/efi_gop: Remove unnecessary return value of
|
||||
grub_video_gop_fill_mode_info()
|
||||
|
||||
The return value of grub_video_gop_fill_mode_info() is never able to be
|
||||
anything other than GRUB_ERR_NONE. So, rather than continue to return
|
||||
a value and checking it each time, it is more correct to redefine the
|
||||
function to not return anything and remove checks of its return value
|
||||
altogether.
|
||||
|
||||
Fixes: CID 96701
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=fc5951d3b1616055ef81a019a5affc09d13344d0]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/video/efi_gop.c | 25 ++++++-------------------
|
||||
1 file changed, 6 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c
|
||||
index 7f9d1c2..db2ee98 100644
|
||||
--- a/grub-core/video/efi_gop.c
|
||||
+++ b/grub-core/video/efi_gop.c
|
||||
@@ -227,7 +227,7 @@ grub_video_gop_fill_real_mode_info (unsigned mode,
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
-static grub_err_t
|
||||
+static void
|
||||
grub_video_gop_fill_mode_info (unsigned mode,
|
||||
struct grub_efi_gop_mode_info *in,
|
||||
struct grub_video_mode_info *out)
|
||||
@@ -252,8 +252,6 @@ grub_video_gop_fill_mode_info (unsigned mode,
|
||||
out->blit_format = GRUB_VIDEO_BLIT_FORMAT_BGRA_8888;
|
||||
out->mode_type |= (GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED
|
||||
| GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP);
|
||||
-
|
||||
- return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -266,7 +264,6 @@ grub_video_gop_iterate (int (*hook) (const struct grub_video_mode_info *info, vo
|
||||
grub_efi_uintn_t size;
|
||||
grub_efi_status_t status;
|
||||
struct grub_efi_gop_mode_info *info = NULL;
|
||||
- grub_err_t err;
|
||||
struct grub_video_mode_info mode_info;
|
||||
|
||||
status = efi_call_4 (gop->query_mode, gop, mode, &size, &info);
|
||||
@@ -277,12 +274,7 @@ grub_video_gop_iterate (int (*hook) (const struct grub_video_mode_info *info, vo
|
||||
continue;
|
||||
}
|
||||
|
||||
- err = grub_video_gop_fill_mode_info (mode, info, &mode_info);
|
||||
- if (err)
|
||||
- {
|
||||
- grub_errno = GRUB_ERR_NONE;
|
||||
- continue;
|
||||
- }
|
||||
+ grub_video_gop_fill_mode_info (mode, info, &mode_info);
|
||||
if (hook (&mode_info, hook_arg))
|
||||
return 1;
|
||||
}
|
||||
@@ -466,13 +458,8 @@ grub_video_gop_setup (unsigned int width, unsigned int height,
|
||||
|
||||
info = gop->mode->info;
|
||||
|
||||
- err = grub_video_gop_fill_mode_info (gop->mode->mode, info,
|
||||
- &framebuffer.mode_info);
|
||||
- if (err)
|
||||
- {
|
||||
- grub_dprintf ("video", "GOP: couldn't fill mode info\n");
|
||||
- return err;
|
||||
- }
|
||||
+ grub_video_gop_fill_mode_info (gop->mode->mode, info,
|
||||
+ &framebuffer.mode_info);
|
||||
|
||||
framebuffer.ptr = (void *) (grub_addr_t) gop->mode->fb_base;
|
||||
framebuffer.offscreen
|
||||
@@ -486,8 +473,8 @@ grub_video_gop_setup (unsigned int width, unsigned int height,
|
||||
{
|
||||
grub_dprintf ("video", "GOP: couldn't allocate shadow\n");
|
||||
grub_errno = 0;
|
||||
- err = grub_video_gop_fill_mode_info (gop->mode->mode, info,
|
||||
- &framebuffer.mode_info);
|
||||
+ grub_video_gop_fill_mode_info (gop->mode->mode, info,
|
||||
+ &framebuffer.mode_info);
|
||||
buffer = framebuffer.ptr;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
From 99ecf5a44b99d529a6405fe276bedcefa3657a0a Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Wed, 4 Nov 2020 15:10:51 +0000
|
||||
Subject: [PATCH] video/fb/fbfill: Fix potential integer overflow
|
||||
|
||||
The multiplication of 2 unsigned 32-bit integers may overflow before
|
||||
promotion to unsigned 64-bit. We should ensure that the multiplication
|
||||
is done with overflow detection. Additionally, use grub_sub() for
|
||||
subtraction.
|
||||
|
||||
Fixes: CID 73640, CID 73697, CID 73702, CID 73823
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Signed-off-by: Marco A Benatto <mbenatto@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=7ce3259f67ac2cd93acb0ec0080c24b3b69e66c6]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/video/fb/fbfill.c | 17 +++++++++++++----
|
||||
1 file changed, 13 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/video/fb/fbfill.c b/grub-core/video/fb/fbfill.c
|
||||
index 11816d0..a37acd1 100644
|
||||
--- a/grub-core/video/fb/fbfill.c
|
||||
+++ b/grub-core/video/fb/fbfill.c
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <grub/fbfill.h>
|
||||
#include <grub/fbutil.h>
|
||||
#include <grub/types.h>
|
||||
+#include <grub/safemath.h>
|
||||
#include <grub/video.h>
|
||||
|
||||
/* Generic filler that works for every supported mode. */
|
||||
@@ -61,7 +62,9 @@ grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst,
|
||||
|
||||
/* Calculate the number of bytes to advance from the end of one line
|
||||
to the beginning of the next line. */
|
||||
- rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
|
||||
+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
|
||||
+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
|
||||
+ return;
|
||||
|
||||
/* Get the start address. */
|
||||
dstptr = grub_video_fb_get_video_ptr (dst, x, y);
|
||||
@@ -98,7 +101,9 @@ grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst,
|
||||
#endif
|
||||
/* Calculate the number of bytes to advance from the end of one line
|
||||
to the beginning of the next line. */
|
||||
- rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
|
||||
+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
|
||||
+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
|
||||
+ return;
|
||||
|
||||
/* Get the start address. */
|
||||
dstptr = grub_video_fb_get_video_ptr (dst, x, y);
|
||||
@@ -131,7 +136,9 @@ grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst,
|
||||
|
||||
/* Calculate the number of bytes to advance from the end of one line
|
||||
to the beginning of the next line. */
|
||||
- rowskip = (dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width);
|
||||
+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
|
||||
+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
|
||||
+ return;
|
||||
|
||||
/* Get the start address. */
|
||||
dstptr = grub_video_fb_get_video_ptr (dst, x, y);
|
||||
@@ -161,7 +168,9 @@ grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst,
|
||||
|
||||
/* Calculate the number of bytes to advance from the end of one line
|
||||
to the beginning of the next line. */
|
||||
- rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
|
||||
+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
|
||||
+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
|
||||
+ return;
|
||||
|
||||
/* Get the start address. */
|
||||
dstptr = grub_video_fb_get_video_ptr (dst, x, y);
|
||||
@@ -0,0 +1,104 @@
|
||||
From 69b91f7466a5ad5fb85039a5b4118efb77ad6347 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Wed, 4 Nov 2020 14:43:44 +0000
|
||||
Subject: [PATCH] video/fb/video_fb: Fix multiple integer overflows
|
||||
|
||||
The calculation of the unsigned 64-bit value is being generated by
|
||||
multiplying 2, signed or unsigned, 32-bit integers which may overflow
|
||||
before promotion to unsigned 64-bit. Fix all of them.
|
||||
|
||||
Fixes: CID 73703, CID 73767, CID 73833
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=08e098b1dbf01e96376f594b337491bc4cfa48dd]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/video/fb/video_fb.c | 52 ++++++++++++++++++++++++-----------
|
||||
1 file changed, 36 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c
|
||||
index 1a602c8..1c9a138 100644
|
||||
--- a/grub-core/video/fb/video_fb.c
|
||||
+++ b/grub-core/video/fb/video_fb.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <grub/fbutil.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/dl.h>
|
||||
+#include <grub/safemath.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -1417,15 +1418,23 @@ doublebuf_blit_update_screen (void)
|
||||
{
|
||||
if (framebuffer.current_dirty.first_line
|
||||
<= framebuffer.current_dirty.last_line)
|
||||
- grub_memcpy ((char *) framebuffer.pages[0]
|
||||
- + framebuffer.current_dirty.first_line
|
||||
- * framebuffer.back_target->mode_info.pitch,
|
||||
- (char *) framebuffer.back_target->data
|
||||
- + framebuffer.current_dirty.first_line
|
||||
- * framebuffer.back_target->mode_info.pitch,
|
||||
- framebuffer.back_target->mode_info.pitch
|
||||
- * (framebuffer.current_dirty.last_line
|
||||
- - framebuffer.current_dirty.first_line));
|
||||
+ {
|
||||
+ grub_size_t copy_size;
|
||||
+
|
||||
+ if (grub_sub (framebuffer.current_dirty.last_line,
|
||||
+ framebuffer.current_dirty.first_line, ©_size) ||
|
||||
+ grub_mul (framebuffer.back_target->mode_info.pitch, copy_size, ©_size))
|
||||
+ {
|
||||
+ /* Shouldn't happen, but if it does we've a bug. */
|
||||
+ return GRUB_ERR_BUG;
|
||||
+ }
|
||||
+
|
||||
+ grub_memcpy ((char *) framebuffer.pages[0] + framebuffer.current_dirty.first_line *
|
||||
+ framebuffer.back_target->mode_info.pitch,
|
||||
+ (char *) framebuffer.back_target->data + framebuffer.current_dirty.first_line *
|
||||
+ framebuffer.back_target->mode_info.pitch,
|
||||
+ copy_size);
|
||||
+ }
|
||||
framebuffer.current_dirty.first_line
|
||||
= framebuffer.back_target->mode_info.height;
|
||||
framebuffer.current_dirty.last_line = 0;
|
||||
@@ -1439,7 +1448,7 @@ grub_video_fb_doublebuf_blit_init (struct grub_video_fbrender_target **back,
|
||||
volatile void *framebuf)
|
||||
{
|
||||
grub_err_t err;
|
||||
- grub_size_t page_size = mode_info.pitch * mode_info.height;
|
||||
+ grub_size_t page_size = (grub_size_t) mode_info.pitch * mode_info.height;
|
||||
|
||||
framebuffer.offscreen_buffer = grub_zalloc (page_size);
|
||||
if (! framebuffer.offscreen_buffer)
|
||||
@@ -1482,12 +1491,23 @@ doublebuf_pageflipping_update_screen (void)
|
||||
last_line = framebuffer.previous_dirty.last_line;
|
||||
|
||||
if (first_line <= last_line)
|
||||
- grub_memcpy ((char *) framebuffer.pages[framebuffer.render_page]
|
||||
- + first_line * framebuffer.back_target->mode_info.pitch,
|
||||
- (char *) framebuffer.back_target->data
|
||||
- + first_line * framebuffer.back_target->mode_info.pitch,
|
||||
- framebuffer.back_target->mode_info.pitch
|
||||
- * (last_line - first_line));
|
||||
+ {
|
||||
+ grub_size_t copy_size;
|
||||
+
|
||||
+ if (grub_sub (last_line, first_line, ©_size) ||
|
||||
+ grub_mul (framebuffer.back_target->mode_info.pitch, copy_size, ©_size))
|
||||
+ {
|
||||
+ /* Shouldn't happen, but if it does we've a bug. */
|
||||
+ return GRUB_ERR_BUG;
|
||||
+ }
|
||||
+
|
||||
+ grub_memcpy ((char *) framebuffer.pages[framebuffer.render_page] + first_line *
|
||||
+ framebuffer.back_target->mode_info.pitch,
|
||||
+ (char *) framebuffer.back_target->data + first_line *
|
||||
+ framebuffer.back_target->mode_info.pitch,
|
||||
+ copy_size);
|
||||
+ }
|
||||
+
|
||||
framebuffer.previous_dirty = framebuffer.current_dirty;
|
||||
framebuffer.current_dirty.first_line
|
||||
= framebuffer.back_target->mode_info.height;
|
||||
@@ -0,0 +1,39 @@
|
||||
From aac5574ff340a665ccc78d4c3d61596ac67acbbe Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 4 Dec 2020 14:51:30 +0000
|
||||
Subject: [PATCH] video/fb/video_fb: Fix possible integer overflow
|
||||
|
||||
It is minimal possibility that the values being used here will overflow.
|
||||
So, change the code to use the safemath function grub_mul() to ensure
|
||||
that doesn't happen.
|
||||
|
||||
Fixes: CID 73761
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=08413f2f4edec0e2d9bf15f836f6ee5ca2e379cb]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/video/fb/video_fb.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c
|
||||
index 1c9a138..ae6b89f 100644
|
||||
--- a/grub-core/video/fb/video_fb.c
|
||||
+++ b/grub-core/video/fb/video_fb.c
|
||||
@@ -1537,7 +1537,13 @@ doublebuf_pageflipping_init (struct grub_video_mode_info *mode_info,
|
||||
volatile void *page1_ptr)
|
||||
{
|
||||
grub_err_t err;
|
||||
- grub_size_t page_size = mode_info->pitch * mode_info->height;
|
||||
+ grub_size_t page_size = 0;
|
||||
+
|
||||
+ if (grub_mul (mode_info->pitch, mode_info->height, &page_size))
|
||||
+ {
|
||||
+ /* Shouldn't happen, but if it does we've a bug. */
|
||||
+ return GRUB_ERR_BUG;
|
||||
+ }
|
||||
|
||||
framebuffer.offscreen_buffer = grub_malloc (page_size);
|
||||
if (! framebuffer.offscreen_buffer)
|
||||
@@ -0,0 +1,38 @@
|
||||
From 88361a7fd4e481a76e1159a63c9014fa997ef29c Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 4 Dec 2020 15:39:00 +0000
|
||||
Subject: [PATCH] video/readers/jpeg: Test for an invalid next marker reference
|
||||
from a jpeg file
|
||||
|
||||
While it may never happen, and potentially could be caught at the end of
|
||||
the function, it is worth checking up front for a bad reference to the
|
||||
next marker just in case of a maliciously crafted file being provided.
|
||||
|
||||
Fixes: CID 73694
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=5f5eb7ca8e971227e95745abe541df3e1509360e]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/video/readers/jpeg.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
|
||||
index 31359a4..0b6ce3c 100644
|
||||
--- a/grub-core/video/readers/jpeg.c
|
||||
+++ b/grub-core/video/readers/jpeg.c
|
||||
@@ -253,6 +253,12 @@ grub_jpeg_decode_quan_table (struct grub_jpeg_data *data)
|
||||
next_marker = data->file->offset;
|
||||
next_marker += grub_jpeg_get_word (data);
|
||||
|
||||
+ if (next_marker > data->file->size)
|
||||
+ {
|
||||
+ /* Should never be set beyond the size of the file. */
|
||||
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid next reference");
|
||||
+ }
|
||||
+
|
||||
while (data->file->offset + sizeof (data->quan_table[id]) + 1
|
||||
<= next_marker)
|
||||
{
|
||||
@@ -0,0 +1,34 @@
|
||||
From 9433cb3a37c03f22c2fa769121f1f509fd031ae9 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Mon, 7 Dec 2020 14:44:47 +0000
|
||||
Subject: [PATCH] gfxmenu/gui_list: Remove code that coverity is flagging as
|
||||
dead
|
||||
|
||||
The test of value for NULL before calling grub_strdup() is not required,
|
||||
since the if condition prior to this has already tested for value being
|
||||
NULL and cannot reach this code if it is.
|
||||
|
||||
Fixes: CID 73659
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=4a1aa5917595650efbd46b581368c470ebee42ab]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/gfxmenu/gui_list.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/gfxmenu/gui_list.c b/grub-core/gfxmenu/gui_list.c
|
||||
index 01477cd..df334a6 100644
|
||||
--- a/grub-core/gfxmenu/gui_list.c
|
||||
+++ b/grub-core/gfxmenu/gui_list.c
|
||||
@@ -771,7 +771,7 @@ list_set_property (void *vself, const char *name, const char *value)
|
||||
{
|
||||
self->need_to_recreate_boxes = 1;
|
||||
grub_free (self->selected_item_box_pattern);
|
||||
- self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
|
||||
+ self->selected_item_box_pattern = grub_strdup (value);
|
||||
self->selected_item_box_pattern_inherit = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
From 7899384c8fdf9ed96566978c49b0c6e40e70703d Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 8 Dec 2020 21:47:13 +0000
|
||||
Subject: [PATCH] loader/bsd: Check for NULL arg up-front
|
||||
|
||||
The code in the next block suggests that it is possible for .set to be
|
||||
true but .arg may still be NULL.
|
||||
|
||||
This code assumes that it is never NULL, yet later is testing if it is
|
||||
NULL - that is inconsistent.
|
||||
|
||||
So we should check first if .arg is not NULL, and remove this check that
|
||||
is being flagged by Coverity since it is no longer required.
|
||||
|
||||
Fixes: CID 292471
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=5d5391b0a05abe76e04c1eb68dcc6cbef5326c4a]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/loader/i386/bsd.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
|
||||
index b92cbe9..8432283 100644
|
||||
--- a/grub-core/loader/i386/bsd.c
|
||||
+++ b/grub-core/loader/i386/bsd.c
|
||||
@@ -1605,7 +1605,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
||||
kernel_type = KERNEL_TYPE_OPENBSD;
|
||||
bootflags = grub_bsd_parse_flags (ctxt->state, openbsd_flags);
|
||||
|
||||
- if (ctxt->state[OPENBSD_ROOT_ARG].set)
|
||||
+ if (ctxt->state[OPENBSD_ROOT_ARG].set && ctxt->state[OPENBSD_ROOT_ARG].arg != NULL)
|
||||
{
|
||||
const char *arg = ctxt->state[OPENBSD_ROOT_ARG].arg;
|
||||
unsigned type, unit, part;
|
||||
@@ -1622,7 +1622,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
||||
"unknown disk type name");
|
||||
|
||||
unit = grub_strtoul (arg, (char **) &arg, 10);
|
||||
- if (! (arg && *arg >= 'a' && *arg <= 'z'))
|
||||
+ if (! (*arg >= 'a' && *arg <= 'z'))
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"only device specifications of form "
|
||||
"<type><number><lowercase letter> are supported");
|
||||
@@ -0,0 +1,38 @@
|
||||
From 0a4aa7c16f65cdfaa1013f0796afa929f8d6dc1a Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 26 Nov 2020 12:53:10 +0000
|
||||
Subject: [PATCH] loader/xnu: Fix memory leak
|
||||
|
||||
The code here is finished with the memory stored in name, but it only
|
||||
frees it if there curvalue is valid, while it could actually free it
|
||||
regardless.
|
||||
|
||||
The fix is a simple relocation of the grub_free() to before the test
|
||||
of curvalue.
|
||||
|
||||
Fixes: CID 96646
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=bcb59ece3263d118510c4440c4da0950f224bb7f]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/loader/xnu.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
|
||||
index 07232d2..b3029a8 100644
|
||||
--- a/grub-core/loader/xnu.c
|
||||
+++ b/grub-core/loader/xnu.c
|
||||
@@ -1388,9 +1388,9 @@ grub_xnu_fill_devicetree (void)
|
||||
name[len] = 0;
|
||||
|
||||
curvalue = grub_xnu_create_value (curkey, name);
|
||||
+ grub_free (name);
|
||||
if (!curvalue)
|
||||
return grub_errno;
|
||||
- grub_free (name);
|
||||
|
||||
data = grub_malloc (grub_strlen (var->value) + 1);
|
||||
if (!data)
|
||||
@@ -0,0 +1,77 @@
|
||||
From 81117a77a9e945ee5e7c1f12bd5667e2a16cbe32 Mon Sep 17 00:00:00 2001
|
||||
From: Marco A Benatto <mbenatto@redhat.com>
|
||||
Date: Mon, 30 Nov 2020 12:18:24 -0300
|
||||
Subject: [PATCH] loader/xnu: Free driverkey data when an error is detected in
|
||||
grub_xnu_writetree_toheap()
|
||||
|
||||
... to avoid memory leaks.
|
||||
|
||||
Fixes: CID 96640
|
||||
|
||||
Signed-off-by: Marco A Benatto <mbenatto@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=4b4027b6b1c877d7ab467896b04c7bd1aadcfa15]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/loader/xnu.c | 24 ++++++++++++++++++++----
|
||||
1 file changed, 20 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
|
||||
index b3029a8..39ceff8 100644
|
||||
--- a/grub-core/loader/xnu.c
|
||||
+++ b/grub-core/loader/xnu.c
|
||||
@@ -224,26 +224,33 @@ grub_xnu_writetree_toheap (grub_addr_t *target, grub_size_t *size)
|
||||
if (! memorymap)
|
||||
return grub_errno;
|
||||
|
||||
- driverkey = (struct grub_xnu_devtree_key *) grub_malloc (sizeof (*driverkey));
|
||||
+ driverkey = (struct grub_xnu_devtree_key *) grub_zalloc (sizeof (*driverkey));
|
||||
if (! driverkey)
|
||||
return grub_errno;
|
||||
driverkey->name = grub_strdup ("DeviceTree");
|
||||
if (! driverkey->name)
|
||||
- return grub_errno;
|
||||
+ {
|
||||
+ err = grub_errno;
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
driverkey->datasize = sizeof (*extdesc);
|
||||
driverkey->next = memorymap->first_child;
|
||||
memorymap->first_child = driverkey;
|
||||
driverkey->data = extdesc
|
||||
= (struct grub_xnu_extdesc *) grub_malloc (sizeof (*extdesc));
|
||||
if (! driverkey->data)
|
||||
- return grub_errno;
|
||||
+ {
|
||||
+ err = grub_errno;
|
||||
+ goto fail;
|
||||
+ }
|
||||
|
||||
/* Allocate the space based on the size with dummy value. */
|
||||
*size = grub_xnu_writetree_get_size (grub_xnu_devtree_root, "/");
|
||||
err = grub_xnu_heap_malloc (ALIGN_UP (*size + 1, GRUB_XNU_PAGESIZE),
|
||||
&src, target);
|
||||
if (err)
|
||||
- return err;
|
||||
+ goto fail;
|
||||
|
||||
/* Put real data in the dummy. */
|
||||
extdesc->addr = *target;
|
||||
@@ -252,6 +259,15 @@ grub_xnu_writetree_toheap (grub_addr_t *target, grub_size_t *size)
|
||||
/* Write the tree to heap. */
|
||||
grub_xnu_writetree_toheap_real (src, grub_xnu_devtree_root, "/");
|
||||
return GRUB_ERR_NONE;
|
||||
+
|
||||
+ fail:
|
||||
+ memorymap->first_child = NULL;
|
||||
+
|
||||
+ grub_free (driverkey->data);
|
||||
+ grub_free (driverkey->name);
|
||||
+ grub_free (driverkey);
|
||||
+
|
||||
+ return err;
|
||||
}
|
||||
|
||||
/* Find a key or value in parent key. */
|
||||
@@ -0,0 +1,42 @@
|
||||
From 778a3fffd19229e5650a1abfb06c974949991cd4 Mon Sep 17 00:00:00 2001
|
||||
From: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
|
||||
Date: Mon, 30 Nov 2020 10:36:00 -0300
|
||||
Subject: [PATCH] loader/xnu: Check if pointer is NULL before using it
|
||||
|
||||
Fixes: CID 73654
|
||||
|
||||
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=7c8a2b5d1421a0f2a33d33531f7561f3da93b844]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/loader/xnu.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
|
||||
index 39ceff8..adc048c 100644
|
||||
--- a/grub-core/loader/xnu.c
|
||||
+++ b/grub-core/loader/xnu.c
|
||||
@@ -667,6 +667,9 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
|
||||
char *name, *nameend;
|
||||
int namelen;
|
||||
|
||||
+ if (infoplistname == NULL)
|
||||
+ return grub_error (GRUB_ERR_BAD_FILENAME, N_("missing p-list filename"));
|
||||
+
|
||||
name = get_name_ptr (infoplistname);
|
||||
nameend = grub_strchr (name, '/');
|
||||
|
||||
@@ -698,10 +701,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
|
||||
else
|
||||
macho = 0;
|
||||
|
||||
- if (infoplistname)
|
||||
- infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
|
||||
- else
|
||||
- infoplist = 0;
|
||||
+ infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
if (infoplist)
|
||||
{
|
||||
@@ -0,0 +1,41 @@
|
||||
From 5d2dd0052474a882a22e47cc8c3ed87a01819f6b Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
Date: Thu, 25 Feb 2021 18:35:01 +0100
|
||||
Subject: [PATCH] util/grub-install: Fix NULL pointer dereferences
|
||||
|
||||
Two grub_device_open() calls does not have associated NULL checks
|
||||
for returned values. Fix that and appease the Coverity.
|
||||
|
||||
Fixes: CID 314583
|
||||
|
||||
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=8b3a95655b4391122e7b0315d8cc6f876caf8183]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
util/grub-install.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/util/grub-install.c b/util/grub-install.c
|
||||
index a82725f..367350f 100644
|
||||
--- a/util/grub-install.c
|
||||
+++ b/util/grub-install.c
|
||||
@@ -1775,6 +1775,8 @@ main (int argc, char *argv[])
|
||||
fill_core_services (core_services);
|
||||
|
||||
ins_dev = grub_device_open (install_drive);
|
||||
+ if (ins_dev == NULL)
|
||||
+ grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
bless (ins_dev, core_services, 0);
|
||||
|
||||
@@ -1875,6 +1877,8 @@ main (int argc, char *argv[])
|
||||
fill_core_services(core_services);
|
||||
|
||||
ins_dev = grub_device_open (install_drive);
|
||||
+ if (ins_dev == NULL)
|
||||
+ grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
bless (ins_dev, boot_efi, 1);
|
||||
if (!removable && update_nvram)
|
||||
@@ -0,0 +1,46 @@
|
||||
From 3d68daf2567aace4b52bd238cfd4a8111af3bc04 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 5 Nov 2020 14:33:50 +0000
|
||||
Subject: [PATCH] util/grub-editenv: Fix incorrect casting of a signed value
|
||||
|
||||
The return value of ftell() may be negative (-1) on error. While it is
|
||||
probably unlikely to occur, we should not blindly cast to an unsigned
|
||||
value without first testing that it is not negative.
|
||||
|
||||
Fixes: CID 73856
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=5dc41edc4eba259c6043ae7698c245ec1baaacc6]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
util/grub-editenv.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/util/grub-editenv.c b/util/grub-editenv.c
|
||||
index f3662c9..db6f187 100644
|
||||
--- a/util/grub-editenv.c
|
||||
+++ b/util/grub-editenv.c
|
||||
@@ -125,6 +125,7 @@ open_envblk_file (const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
char *buf;
|
||||
+ long loc;
|
||||
size_t size;
|
||||
grub_envblk_t envblk;
|
||||
|
||||
@@ -143,7 +144,12 @@ open_envblk_file (const char *name)
|
||||
grub_util_error (_("cannot seek `%s': %s"), name,
|
||||
strerror (errno));
|
||||
|
||||
- size = (size_t) ftell (fp);
|
||||
+ loc = ftell (fp);
|
||||
+ if (loc < 0)
|
||||
+ grub_util_error (_("cannot get file location `%s': %s"), name,
|
||||
+ strerror (errno));
|
||||
+
|
||||
+ size = (size_t) loc;
|
||||
|
||||
if (fseek (fp, 0, SEEK_SET) < 0)
|
||||
grub_util_error (_("cannot seek `%s': %s"), name,
|
||||
@@ -0,0 +1,50 @@
|
||||
From e301a0f38a2130eb80f346c31e43bf5089af583c Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Fri, 4 Dec 2020 15:04:28 +0000
|
||||
Subject: [PATCH] util/glue-efi: Fix incorrect use of a possibly negative value
|
||||
|
||||
It is possible for the ftell() function to return a negative value,
|
||||
although it is fairly unlikely here, we should be checking for
|
||||
a negative value before we assign it to an unsigned value.
|
||||
|
||||
Fixes: CID 73744
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=1641d74e16f9d1ca35ba1a87ee4a0bf3afa48e72]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
util/glue-efi.c | 14 ++++++++++++--
|
||||
1 file changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/util/glue-efi.c b/util/glue-efi.c
|
||||
index 68f5316..de0fa6d 100644
|
||||
--- a/util/glue-efi.c
|
||||
+++ b/util/glue-efi.c
|
||||
@@ -39,13 +39,23 @@ write_fat (FILE *in32, FILE *in64, FILE *out, const char *out_filename,
|
||||
struct grub_macho_fat_header head;
|
||||
struct grub_macho_fat_arch arch32, arch64;
|
||||
grub_uint32_t size32, size64;
|
||||
+ long size;
|
||||
char *buf;
|
||||
|
||||
fseek (in32, 0, SEEK_END);
|
||||
- size32 = ftell (in32);
|
||||
+ size = ftell (in32);
|
||||
+ if (size < 0)
|
||||
+ grub_util_error ("cannot get end of input file '%s': %s",
|
||||
+ name32, strerror (errno));
|
||||
+ size32 = (grub_uint32_t) size;
|
||||
fseek (in32, 0, SEEK_SET);
|
||||
+
|
||||
fseek (in64, 0, SEEK_END);
|
||||
- size64 = ftell (in64);
|
||||
+ size = ftell (in64);
|
||||
+ if (size < 0)
|
||||
+ grub_util_error ("cannot get end of input file '%s': %s",
|
||||
+ name64, strerror (errno));
|
||||
+ size64 = (grub_uint64_t) size;
|
||||
fseek (in64, 0, SEEK_SET);
|
||||
|
||||
head.magic = grub_cpu_to_le32_compile_time (GRUB_MACHO_FAT_EFI_MAGIC);
|
||||
@@ -0,0 +1,28 @@
|
||||
From f5fb56954e5926ced42a980c3e0842ffd5fea2aa Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Axtens <dja@axtens.net>
|
||||
Date: Fri, 3 Apr 2020 23:05:13 +1100
|
||||
Subject: [PATCH] script/execute: Fix NULL dereference in
|
||||
grub_script_execute_cmdline()
|
||||
|
||||
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=41ae93b2e6c75453514629bcfe684300e3aec0ce]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/script/execute.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
|
||||
index 7e028e1..5ea2aef 100644
|
||||
--- a/grub-core/script/execute.c
|
||||
+++ b/grub-core/script/execute.c
|
||||
@@ -940,7 +940,7 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
||||
struct grub_script_argv argv = { 0, 0, 0 };
|
||||
|
||||
/* Lookup the command. */
|
||||
- if (grub_script_arglist_to_argv (cmdline->arglist, &argv) || ! argv.args[0])
|
||||
+ if (grub_script_arglist_to_argv (cmdline->arglist, &argv) || ! argv.args || ! argv.args[0])
|
||||
return grub_errno;
|
||||
|
||||
for (i = 0; i < argv.argc; i++)
|
||||
@@ -0,0 +1,33 @@
|
||||
From dd82f98fa642907817f59aeaf3761b786898df85 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Axtens <dja@axtens.net>
|
||||
Date: Mon, 11 Jan 2021 16:57:37 +1100
|
||||
Subject: [PATCH] commands/ls: Require device_name is not NULL before printing
|
||||
|
||||
This can be triggered with:
|
||||
ls -l (0 0*)
|
||||
and causes a NULL deref in grub_normal_print_device_info().
|
||||
|
||||
I'm not sure if there's any implication with the IEEE 1275 platform.
|
||||
|
||||
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=6afbe6063c95b827372f9ec310c9fc7461311eb1]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/commands/ls.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
|
||||
index 5b7491a..326d2d6 100644
|
||||
--- a/grub-core/commands/ls.c
|
||||
+++ b/grub-core/commands/ls.c
|
||||
@@ -196,7 +196,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- if (! *path)
|
||||
+ if (! *path && device_name)
|
||||
{
|
||||
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
@@ -0,0 +1,37 @@
|
||||
From df2505c4c3cf42b0c419c99a5f9e1ce63e5a5938 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Axtens <dja@axtens.net>
|
||||
Date: Mon, 11 Jan 2021 17:30:42 +1100
|
||||
Subject: [PATCH] script/execute: Avoid crash when using "$#" outside a
|
||||
function scope
|
||||
|
||||
"$#" represents the number of arguments to a function. It is only
|
||||
defined in a function scope, where "scope" is non-NULL. Currently,
|
||||
if we attempt to evaluate "$#" outside a function scope, "scope" will
|
||||
be NULL and we will crash with a NULL pointer dereference.
|
||||
|
||||
Do not attempt to count arguments for "$#" if "scope" is NULL. This
|
||||
will result in "$#" being interpreted as an empty string if evaluated
|
||||
outside a function scope.
|
||||
|
||||
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=fe0586347ee46f927ae27bb9673532da9f5dead5]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/script/execute.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
|
||||
index 5ea2aef..23d34bd 100644
|
||||
--- a/grub-core/script/execute.c
|
||||
+++ b/grub-core/script/execute.c
|
||||
@@ -485,7 +485,7 @@ gettext_putvar (const char *str, grub_size_t len,
|
||||
return 0;
|
||||
|
||||
/* Enough for any number. */
|
||||
- if (len == 1 && str[0] == '#')
|
||||
+ if (len == 1 && str[0] == '#' && scope != NULL)
|
||||
{
|
||||
grub_snprintf (*ptr, 30, "%u", scope->argv.argc);
|
||||
*ptr += grub_strlen (*ptr);
|
||||
90
meta/recipes-bsp/grub/files/CVE-2020-25632.patch
Normal file
90
meta/recipes-bsp/grub/files/CVE-2020-25632.patch
Normal file
@@ -0,0 +1,90 @@
|
||||
From 7630ec5397fe418276b360f9011934b8c034936c Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 29 Sep 2020 14:08:55 +0200
|
||||
Subject: [PATCH] dl: Only allow unloading modules that are not dependencies
|
||||
|
||||
When a module is attempted to be removed its reference counter is always
|
||||
decremented. This means that repeated rmmod invocations will cause the
|
||||
module to be unloaded even if another module depends on it.
|
||||
|
||||
This may lead to a use-after-free scenario allowing an attacker to execute
|
||||
arbitrary code and by-pass the UEFI Secure Boot protection.
|
||||
|
||||
While being there, add the extern keyword to some function declarations in
|
||||
that header file.
|
||||
|
||||
Fixes: CVE-2020-25632
|
||||
|
||||
Reported-by: Chris Coulson <chris.coulson@canonical.com>
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=7630ec5397fe418276b360f9011934b8c034936c]
|
||||
CVE: CVE-2020-25632
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/commands/minicmd.c | 7 +++++--
|
||||
grub-core/kern/dl.c | 9 +++++++++
|
||||
include/grub/dl.h | 8 +++++---
|
||||
3 files changed, 19 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c
|
||||
index 6bbce3128..fa498931e 100644
|
||||
--- a/grub-core/commands/minicmd.c
|
||||
+++ b/grub-core/commands/minicmd.c
|
||||
@@ -140,8 +140,11 @@ grub_mini_cmd_rmmod (struct grub_command *cmd __attribute__ ((unused)),
|
||||
if (grub_dl_is_persistent (mod))
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "cannot unload persistent module");
|
||||
|
||||
- if (grub_dl_unref (mod) <= 0)
|
||||
- grub_dl_unload (mod);
|
||||
+ if (grub_dl_ref_count (mod) > 1)
|
||||
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "cannot unload referenced module");
|
||||
+
|
||||
+ grub_dl_unref (mod);
|
||||
+ grub_dl_unload (mod);
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
|
||||
index 48eb5e7b6..48f8a7907 100644
|
||||
--- a/grub-core/kern/dl.c
|
||||
+++ b/grub-core/kern/dl.c
|
||||
@@ -549,6 +549,15 @@ grub_dl_unref (grub_dl_t mod)
|
||||
return --mod->ref_count;
|
||||
}
|
||||
|
||||
+int
|
||||
+grub_dl_ref_count (grub_dl_t mod)
|
||||
+{
|
||||
+ if (mod == NULL)
|
||||
+ return 0;
|
||||
+
|
||||
+ return mod->ref_count;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
grub_dl_flush_cache (grub_dl_t mod)
|
||||
{
|
||||
diff --git a/include/grub/dl.h b/include/grub/dl.h
|
||||
index f03c03561..b3753c9ca 100644
|
||||
--- a/include/grub/dl.h
|
||||
+++ b/include/grub/dl.h
|
||||
@@ -203,9 +203,11 @@ grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
|
||||
grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
|
||||
grub_dl_t EXPORT_FUNC(grub_dl_load_core_noinit) (void *addr, grub_size_t size);
|
||||
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
|
||||
-void grub_dl_unload_unneeded (void);
|
||||
-int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
||||
-int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
|
||||
+extern void grub_dl_unload_unneeded (void);
|
||||
+extern int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
||||
+extern int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
|
||||
+extern int EXPORT_FUNC(grub_dl_ref_count) (grub_dl_t mod);
|
||||
+
|
||||
extern grub_dl_t EXPORT_VAR(grub_dl_head);
|
||||
|
||||
#ifndef GRUB_UTIL
|
||||
--
|
||||
2.33.0
|
||||
|
||||
119
meta/recipes-bsp/grub/files/CVE-2020-25647.patch
Normal file
119
meta/recipes-bsp/grub/files/CVE-2020-25647.patch
Normal file
@@ -0,0 +1,119 @@
|
||||
From 128c16a682034263eb519c89bc0934eeb6fa8cfa Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Fri, 11 Dec 2020 19:19:21 +0100
|
||||
Subject: [PATCH] usb: Avoid possible out-of-bound accesses caused by malicious
|
||||
devices
|
||||
|
||||
The maximum number of configurations and interfaces are fixed but there is
|
||||
no out-of-bound checking to prevent a malicious USB device to report large
|
||||
values for these and cause accesses outside the arrays' memory.
|
||||
|
||||
Fixes: CVE-2020-25647
|
||||
|
||||
Reported-by: Joseph Tartaro <joseph.tartaro@ioactive.com>
|
||||
Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=128c16a682034263eb519c89bc0934eeb6fa8cfa]
|
||||
CVE: CVE-2020-25647
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/bus/usb/usb.c | 15 ++++++++++++---
|
||||
include/grub/usb.h | 10 +++++++---
|
||||
2 files changed, 19 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/grub-core/bus/usb/usb.c b/grub-core/bus/usb/usb.c
|
||||
index 8da5e4c74..7cb3cc230 100644
|
||||
--- a/grub-core/bus/usb/usb.c
|
||||
+++ b/grub-core/bus/usb/usb.c
|
||||
@@ -75,6 +75,9 @@ grub_usb_controller_iterate (grub_usb_controller_iterate_hook_t hook,
|
||||
grub_usb_err_t
|
||||
grub_usb_clear_halt (grub_usb_device_t dev, int endpoint)
|
||||
{
|
||||
+ if (endpoint >= GRUB_USB_MAX_TOGGLE)
|
||||
+ return GRUB_USB_ERR_BADDEVICE;
|
||||
+
|
||||
dev->toggle[endpoint] = 0;
|
||||
return grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
|
||||
| GRUB_USB_REQTYPE_STANDARD
|
||||
@@ -134,10 +137,10 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
||||
return err;
|
||||
descdev = &dev->descdev;
|
||||
|
||||
- for (i = 0; i < 8; i++)
|
||||
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++)
|
||||
dev->config[i].descconf = NULL;
|
||||
|
||||
- if (descdev->configcnt == 0)
|
||||
+ if (descdev->configcnt == 0 || descdev->configcnt > GRUB_USB_MAX_CONF)
|
||||
{
|
||||
err = GRUB_USB_ERR_BADDEVICE;
|
||||
goto fail;
|
||||
@@ -172,6 +175,12 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
||||
/* Skip the configuration descriptor. */
|
||||
pos = dev->config[i].descconf->length;
|
||||
|
||||
+ if (dev->config[i].descconf->numif > GRUB_USB_MAX_IF)
|
||||
+ {
|
||||
+ err = GRUB_USB_ERR_BADDEVICE;
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
/* Read all interfaces. */
|
||||
for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
|
||||
{
|
||||
@@ -217,7 +226,7 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
||||
|
||||
fail:
|
||||
|
||||
- for (i = 0; i < 8; i++)
|
||||
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++)
|
||||
grub_free (dev->config[i].descconf);
|
||||
|
||||
return err;
|
||||
diff --git a/include/grub/usb.h b/include/grub/usb.h
|
||||
index 512ae1dd0..6475c552f 100644
|
||||
--- a/include/grub/usb.h
|
||||
+++ b/include/grub/usb.h
|
||||
@@ -23,6 +23,10 @@
|
||||
#include <grub/usbdesc.h>
|
||||
#include <grub/usbtrans.h>
|
||||
|
||||
+#define GRUB_USB_MAX_CONF 8
|
||||
+#define GRUB_USB_MAX_IF 32
|
||||
+#define GRUB_USB_MAX_TOGGLE 256
|
||||
+
|
||||
typedef struct grub_usb_device *grub_usb_device_t;
|
||||
typedef struct grub_usb_controller *grub_usb_controller_t;
|
||||
typedef struct grub_usb_controller_dev *grub_usb_controller_dev_t;
|
||||
@@ -167,7 +171,7 @@ struct grub_usb_configuration
|
||||
struct grub_usb_desc_config *descconf;
|
||||
|
||||
/* Interfaces associated to this configuration. */
|
||||
- struct grub_usb_interface interf[32];
|
||||
+ struct grub_usb_interface interf[GRUB_USB_MAX_IF];
|
||||
};
|
||||
|
||||
struct grub_usb_hub_port
|
||||
@@ -191,7 +195,7 @@ struct grub_usb_device
|
||||
struct grub_usb_controller controller;
|
||||
|
||||
/* Device configurations (after opening the device). */
|
||||
- struct grub_usb_configuration config[8];
|
||||
+ struct grub_usb_configuration config[GRUB_USB_MAX_CONF];
|
||||
|
||||
/* Device address. */
|
||||
int addr;
|
||||
@@ -203,7 +207,7 @@ struct grub_usb_device
|
||||
int initialized;
|
||||
|
||||
/* Data toggle values (used for bulk transfers only). */
|
||||
- int toggle[256];
|
||||
+ int toggle[GRUB_USB_MAX_TOGGLE];
|
||||
|
||||
/* Used by libusb wrapper. Schedulded for removal. */
|
||||
void *data;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@@ -45,7 +45,55 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
file://CVE-2020-27779_5.patch \
|
||||
file://CVE-2020-27779_6.patch \
|
||||
file://CVE-2020-27779_7.patch \
|
||||
"
|
||||
file://CVE-2020-25632.patch \
|
||||
file://CVE-2020-25647.patch \
|
||||
file://0001-mmap-Fix-memory-leak-when-iterating-over-mapped-memo.patch \
|
||||
file://0002-net-net-Fix-possible-dereference-to-of-a-NULL-pointe.patch \
|
||||
file://0003-net-tftp-Fix-dangling-memory-pointer.patch \
|
||||
file://0004-kern-parser-Fix-resource-leak-if-argc-0.patch \
|
||||
file://0005-efi-Fix-some-malformed-device-path-arithmetic-errors.patch \
|
||||
file://0006-kern-efi-Fix-memory-leak-on-failure.patch \
|
||||
file://0007-kern-efi-mm-Fix-possible-NULL-pointer-dereference.patch \
|
||||
file://0008-gnulib-regexec-Resolve-unused-variable.patch \
|
||||
file://0009-gnulib-regcomp-Fix-uninitialized-token-structure.patch \
|
||||
file://0010-gnulib-argp-help-Fix-dereference-of-a-possibly-NULL-.patch \
|
||||
file://0011-gnulib-regexec-Fix-possible-null-dereference.patch \
|
||||
file://0012-gnulib-regcomp-Fix-uninitialized-re_token.patch \
|
||||
file://0013-io-lzopio-Resolve-unnecessary-self-assignment-errors.patch \
|
||||
file://0014-zstd-Initialize-seq_t-structure-fully.patch \
|
||||
file://0015-kern-partition-Check-for-NULL-before-dereferencing-i.patch \
|
||||
file://0016-disk-ldm-Make-sure-comp-data-is-freed-before-exiting.patch \
|
||||
file://0017-disk-ldm-If-failed-then-free-vg-variable-too.patch \
|
||||
file://0018-disk-ldm-Fix-memory-leak-on-uninserted-lv-references.patch \
|
||||
file://0019-disk-cryptodisk-Fix-potential-integer-overflow.patch \
|
||||
file://0020-hfsplus-Check-that-the-volume-name-length-is-valid.patch \
|
||||
file://0021-zfs-Fix-possible-negative-shift-operation.patch \
|
||||
file://0022-zfs-Fix-resource-leaks-while-constructing-path.patch \
|
||||
file://0023-zfs-Fix-possible-integer-overflows.patch \
|
||||
file://0024-zfsinfo-Correct-a-check-for-error-allocating-memory.patch \
|
||||
file://0025-affs-Fix-memory-leaks.patch \
|
||||
file://0026-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch \
|
||||
file://0027-libgcrypt-mpi-Fix-possible-NULL-dereference.patch \
|
||||
file://0028-syslinux-Fix-memory-leak-while-parsing.patch \
|
||||
file://0029-normal-completion-Fix-leaking-of-memory-when-process.patch \
|
||||
file://0030-commands-hashsum-Fix-a-memory-leak.patch \
|
||||
file://0031-video-efi_gop-Remove-unnecessary-return-value-of-gru.patch \
|
||||
file://0032-video-fb-fbfill-Fix-potential-integer-overflow.patch \
|
||||
file://0033-video-fb-video_fb-Fix-multiple-integer-overflows.patch \
|
||||
file://0034-video-fb-video_fb-Fix-possible-integer-overflow.patch \
|
||||
file://0035-video-readers-jpeg-Test-for-an-invalid-next-marker-r.patch \
|
||||
file://0036-gfxmenu-gui_list-Remove-code-that-coverity-is-flaggi.patch \
|
||||
file://0037-loader-bsd-Check-for-NULL-arg-up-front.patch \
|
||||
file://0038-loader-xnu-Fix-memory-leak.patch \
|
||||
file://0039-loader-xnu-Free-driverkey-data-when-an-error-is-dete.patch \
|
||||
file://0040-loader-xnu-Check-if-pointer-is-NULL-before-using-it.patch \
|
||||
file://0041-util-grub-install-Fix-NULL-pointer-dereferences.patch \
|
||||
file://0042-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch \
|
||||
file://0043-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch \
|
||||
file://0044-script-execute-Fix-NULL-dereference-in-grub_script_e.patch \
|
||||
file://0045-commands-ls-Require-device_name-is-not-NULL-before-p.patch \
|
||||
file://0046-script-execute-Avoid-crash-when-using-outside-a-func.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ SRC_URI = "https://ftp.isc.org/isc/bind9/${PV}/${BPN}-${PV}.tar.gz \
|
||||
file://0001-avoid-start-failure-with-bind-user.patch \
|
||||
"
|
||||
|
||||
SRC_URI[sha256sum] = "1c882705827b6aafa45d917ae3b20eccccc8d5df3c4477df44b04382e6c47562"
|
||||
SRC_URI[sha256sum] = "c953fcb6703b395aaa53e65ff8b2869b69a5303dd60507cba2201305e1811681"
|
||||
|
||||
UPSTREAM_CHECK_URI = "https://ftp.isc.org/isc/bind9/"
|
||||
# stay at 9.11 until 9.16, from 9.16 follow the ESV versions divisible by 4
|
||||
@@ -0,0 +1,72 @@
|
||||
From eceb2e8d2341c041df55a5e2f047d9a8c491463c Mon Sep 17 00:00:00 2001
|
||||
From: Valery Kashcheev <v.kascheev@omp.ru>
|
||||
Date: Mon, 7 Jun 2021 18:58:24 +0200
|
||||
Subject: dnsproxy: Check the length of buffers before memcpy
|
||||
|
||||
Fix using a stack-based buffer overflow attack by checking the length of
|
||||
the ptr and uptr buffers.
|
||||
|
||||
Fix debug message output.
|
||||
|
||||
Fixes: CVE-2021-33833
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=eceb2e8d2341c041df55a5e2f047d9a8c491463c
|
||||
CVE: CVE-2021-33833
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
src/dnsproxy.c | 20 +++++++++++---------
|
||||
1 file changed, 11 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
|
||||
index de52df5a..38dbdd71 100644
|
||||
--- a/src/dnsproxy.c
|
||||
+++ b/src/dnsproxy.c
|
||||
@@ -1788,17 +1788,15 @@ static char *uncompress(int16_t field_count, char *start, char *end,
|
||||
* tmp buffer.
|
||||
*/
|
||||
|
||||
- debug("pos %d ulen %d left %d name %s", pos, ulen,
|
||||
- (int)(uncomp_len - (uptr - uncompressed)), uptr);
|
||||
-
|
||||
- ulen = strlen(name);
|
||||
- if ((uptr + ulen + 1) > uncomp_end) {
|
||||
+ ulen = strlen(name) + 1;
|
||||
+ if ((uptr + ulen) > uncomp_end)
|
||||
goto out;
|
||||
- }
|
||||
- strncpy(uptr, name, uncomp_len - (uptr - uncompressed));
|
||||
+ strncpy(uptr, name, ulen);
|
||||
+
|
||||
+ debug("pos %d ulen %d left %d name %s", pos, ulen,
|
||||
+ (int)(uncomp_end - (uptr + ulen)), uptr);
|
||||
|
||||
uptr += ulen;
|
||||
- *uptr++ = '\0';
|
||||
|
||||
ptr += pos;
|
||||
|
||||
@@ -1841,7 +1839,7 @@ static char *uncompress(int16_t field_count, char *start, char *end,
|
||||
} else if (dns_type == ns_t_a || dns_type == ns_t_aaaa) {
|
||||
dlen = uptr[-2] << 8 | uptr[-1];
|
||||
|
||||
- if (ptr + dlen > end) {
|
||||
+ if ((ptr + dlen) > end || (uptr + dlen) > uncomp_end) {
|
||||
debug("data len %d too long", dlen);
|
||||
goto out;
|
||||
}
|
||||
@@ -1880,6 +1878,10 @@ static char *uncompress(int16_t field_count, char *start, char *end,
|
||||
* refresh interval, retry interval, expiration
|
||||
* limit and minimum ttl). They are 20 bytes long.
|
||||
*/
|
||||
+ if ((uptr + 20) > uncomp_end || (ptr + 20) > end) {
|
||||
+ debug("soa record too long");
|
||||
+ goto out;
|
||||
+ }
|
||||
memcpy(uptr, ptr, 20);
|
||||
uptr += 20;
|
||||
ptr += 20;
|
||||
--
|
||||
cgit 1.2.3-1.el7
|
||||
|
||||
121
meta/recipes-connectivity/connman/connman/CVE-2022-23096-7.patch
Normal file
121
meta/recipes-connectivity/connman/connman/CVE-2022-23096-7.patch
Normal file
@@ -0,0 +1,121 @@
|
||||
From e5a313736e13c90d19085e953a26256a198e4950 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Wagner <wagi@monom.org>
|
||||
Date: Tue, 25 Jan 2022 10:00:24 +0100
|
||||
Subject: dnsproxy: Validate input data before using them
|
||||
|
||||
dnsproxy is not validating various input data. Add a bunch of checks.
|
||||
|
||||
Fixes: CVE-2022-23097
|
||||
Fixes: CVE-2022-23096
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=e5a313736e13c90d19085e953a26256a198e4950
|
||||
|
||||
CVE: CVE-2022-23096 CVE-2022-23097
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
src/dnsproxy.c | 31 ++++++++++++++++++++++++++-----
|
||||
1 file changed, 26 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
|
||||
index cdfafbc2..c027bcb9 100644
|
||||
--- a/src/dnsproxy.c
|
||||
+++ b/src/dnsproxy.c
|
||||
@@ -1951,6 +1951,12 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol,
|
||||
|
||||
if (offset < 0)
|
||||
return offset;
|
||||
+ if (reply_len < 0)
|
||||
+ return -EINVAL;
|
||||
+ if (reply_len < offset + 1)
|
||||
+ return -EINVAL;
|
||||
+ if ((size_t)reply_len < sizeof(struct domain_hdr))
|
||||
+ return -EINVAL;
|
||||
|
||||
hdr = (void *)(reply + offset);
|
||||
dns_id = reply[offset] | reply[offset + 1] << 8;
|
||||
@@ -1986,23 +1992,31 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol,
|
||||
*/
|
||||
if (req->append_domain && ntohs(hdr->qdcount) == 1) {
|
||||
uint16_t domain_len = 0;
|
||||
- uint16_t header_len;
|
||||
+ uint16_t header_len, payload_len;
|
||||
uint16_t dns_type, dns_class;
|
||||
uint8_t host_len, dns_type_pos;
|
||||
char uncompressed[NS_MAXDNAME], *uptr;
|
||||
char *ptr, *eom = (char *)reply + reply_len;
|
||||
+ char *domain;
|
||||
|
||||
/*
|
||||
* ptr points to the first char of the hostname.
|
||||
* ->hostname.domain.net
|
||||
*/
|
||||
header_len = offset + sizeof(struct domain_hdr);
|
||||
+ if (reply_len < header_len)
|
||||
+ return -EINVAL;
|
||||
+ payload_len = reply_len - header_len;
|
||||
+
|
||||
ptr = (char *)reply + header_len;
|
||||
|
||||
host_len = *ptr;
|
||||
+ domain = ptr + 1 + host_len;
|
||||
+ if (domain > eom)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
if (host_len > 0)
|
||||
- domain_len = strnlen(ptr + 1 + host_len,
|
||||
- reply_len - header_len);
|
||||
+ domain_len = strnlen(domain, eom - domain);
|
||||
|
||||
/*
|
||||
* If the query type is anything other than A or AAAA,
|
||||
@@ -2011,6 +2025,8 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol,
|
||||
*/
|
||||
dns_type_pos = host_len + 1 + domain_len + 1;
|
||||
|
||||
+ if (ptr + (dns_type_pos + 3) > eom)
|
||||
+ return -EINVAL;
|
||||
dns_type = ptr[dns_type_pos] << 8 |
|
||||
ptr[dns_type_pos + 1];
|
||||
dns_class = ptr[dns_type_pos + 2] << 8 |
|
||||
@@ -2040,6 +2056,8 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol,
|
||||
int new_len, fixed_len;
|
||||
char *answers;
|
||||
|
||||
+ if (len > payload_len)
|
||||
+ return -EINVAL;
|
||||
/*
|
||||
* First copy host (without domain name) into
|
||||
* tmp buffer.
|
||||
@@ -2054,6 +2072,8 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol,
|
||||
* Copy type and class fields of the question.
|
||||
*/
|
||||
ptr += len + domain_len + 1;
|
||||
+ if (ptr + NS_QFIXEDSZ > eom)
|
||||
+ return -EINVAL;
|
||||
memcpy(uptr, ptr, NS_QFIXEDSZ);
|
||||
|
||||
/*
|
||||
@@ -2063,6 +2083,8 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol,
|
||||
uptr += NS_QFIXEDSZ;
|
||||
answers = uptr;
|
||||
fixed_len = answers - uncompressed;
|
||||
+ if (ptr + offset > eom)
|
||||
+ return -EINVAL;
|
||||
|
||||
/*
|
||||
* We then uncompress the result to buffer
|
||||
@@ -2257,8 +2279,7 @@ static gboolean udp_server_event(GIOChannel *channel, GIOCondition condition,
|
||||
|
||||
len = recv(sk, buf, sizeof(buf), 0);
|
||||
|
||||
- if (len >= 12)
|
||||
- forward_dns_reply(buf, len, IPPROTO_UDP, data);
|
||||
+ forward_dns_reply(buf, len, IPPROTO_UDP, data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
--
|
||||
cgit 1.2.3-1.el7
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
From d8708b85c1e8fe25af7803e8a20cf20e7201d8a4 Mon Sep 17 00:00:00 2001
|
||||
From: Matthias Gerstner <mgerstner@suse.de>
|
||||
Date: Tue, 25 Jan 2022 10:00:25 +0100
|
||||
Subject: dnsproxy: Avoid 100 % busy loop in TCP server case
|
||||
|
||||
Once the TCP socket is connected and until the remote server is
|
||||
responding (if ever) ConnMan executes a 100 % CPU loop, since
|
||||
the connected socket will always be writable (G_IO_OUT).
|
||||
|
||||
To fix this, modify the watch after the connection is established to
|
||||
remove the G_IO_OUT from the callback conditions.
|
||||
|
||||
Fixes: CVE-2022-23098
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=d8708b85c1e8fe25af7803e8a20cf20e7201d8a4
|
||||
|
||||
CVE: CVE-2022-23098
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
src/dnsproxy.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
|
||||
index c027bcb9..1ccf36a9 100644
|
||||
--- a/src/dnsproxy.c
|
||||
+++ b/src/dnsproxy.c
|
||||
@@ -2360,6 +2360,18 @@ hangup:
|
||||
}
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * Remove the G_IO_OUT flag from the watch, otherwise we end
|
||||
+ * up in a busy loop, because the socket is constantly writable.
|
||||
+ *
|
||||
+ * There seems to be no better way in g_io to do that than
|
||||
+ * re-adding the watch.
|
||||
+ */
|
||||
+ g_source_remove(server->watch);
|
||||
+ server->watch = g_io_add_watch(server->channel,
|
||||
+ G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR,
|
||||
+ tcp_server_event, server);
|
||||
+
|
||||
server->connected = true;
|
||||
server_list = g_slist_append(server_list, server);
|
||||
|
||||
--
|
||||
cgit 1.2.3-1.el7
|
||||
|
||||
@@ -9,6 +9,9 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \
|
||||
file://CVE-2021-26675.patch \
|
||||
file://CVE-2021-26676-0001.patch \
|
||||
file://CVE-2021-26676-0002.patch \
|
||||
file://CVE-2021-33833.patch \
|
||||
file://CVE-2022-23096-7.patch \
|
||||
file://CVE-2022-23098.patch \
|
||||
"
|
||||
|
||||
SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch"
|
||||
|
||||
145
meta/recipes-connectivity/openssl/openssl/CVE-2021-4160.patch
Normal file
145
meta/recipes-connectivity/openssl/openssl/CVE-2021-4160.patch
Normal file
@@ -0,0 +1,145 @@
|
||||
From e9e726506cd2a3fd9c0f12daf8cc1fe934c7dddb Mon Sep 17 00:00:00 2001
|
||||
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
Date: Sat, 11 Dec 2021 20:28:11 +0100
|
||||
Subject: [PATCH] Fix a carry overflow bug in bn_sqr_comba4/8 for mips 32-bit
|
||||
targets
|
||||
|
||||
bn_sqr_comba8 does for instance compute a wrong result for the value:
|
||||
a=0x4aaac919 62056c84 fba7334e 1a6be678 022181ba fd3aa878 899b2346 ee210f45
|
||||
|
||||
The correct result is:
|
||||
r=0x15c72e32 605a3061 d11b1012 3c187483 6df96999 bd0c22ba d3e7d437 4724a82f
|
||||
912c5e61 6a187efe 8f7c47fc f6945fe5 75be8e3d 97ed17d4 7950b465 3cb32899
|
||||
|
||||
but the actual result was:
|
||||
r=0x15c72e32 605a3061 d11b1012 3c187483 6df96999 bd0c22ba d3e7d437 4724a82f
|
||||
912c5e61 6a187efe 8f7c47fc f6945fe5 75be8e3c 97ed17d4 7950b465 3cb32899
|
||||
|
||||
so the forth word of the result was 0x75be8e3c but should have been
|
||||
0x75be8e3d instead.
|
||||
|
||||
Likewise bn_sqr_comba4 has an identical bug for the same value as well:
|
||||
a=0x022181ba fd3aa878 899b2346 ee210f45
|
||||
|
||||
correct result:
|
||||
r=0x00048a69 9fe82f8b 62bd2ed1 88781335 75be8e3d 97ed17d4 7950b465 3cb32899
|
||||
|
||||
wrong result:
|
||||
r=0x00048a69 9fe82f8b 62bd2ed1 88781335 75be8e3c 97ed17d4 7950b465 3cb32899
|
||||
|
||||
Fortunately the bn_mul_comba4/8 code paths are not affected.
|
||||
|
||||
Also the mips64 target does in fact not handle the carry propagation
|
||||
correctly.
|
||||
|
||||
Example:
|
||||
a=0x4aaac91900000000 62056c8400000000 fba7334e00000000 1a6be67800000000
|
||||
022181ba00000000 fd3aa87800000000 899b234635dad283 ee210f4500000001
|
||||
|
||||
correct result:
|
||||
r=0x15c72e32272c4471 392debf018c679c8 b85496496bf8254c d0204f36611e2be1
|
||||
0cdb3db8f3c081d8 c94ba0e1bacc5061 191b83d47ff929f6 5be0aebfc13ae68d
|
||||
3eea7a7fdf2f5758 42f7ec656cab3cb5 6a28095be34756f2 64f24687bf37de06
|
||||
2822309cd1d292f9 6fa698c972372f09 771e97d3a868cda0 dc421e8a00000001
|
||||
|
||||
wrong result:
|
||||
r=0x15c72e32272c4471 392debf018c679c8 b85496496bf8254c d0204f36611e2be1
|
||||
0cdb3db8f3c081d8 c94ba0e1bacc5061 191b83d47ff929f6 5be0aebfc13ae68d
|
||||
3eea7a7fdf2f5758 42f7ec656cab3cb5 6a28095be34756f2 64f24687bf37de06
|
||||
2822309cd1d292f8 6fa698c972372f09 771e97d3a868cda0 dc421e8a00000001
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/17258)
|
||||
|
||||
(cherry picked from commit 336923c0c8d705cb8af5216b29a205662db0d590)
|
||||
|
||||
Upstream-Status: Backport [https://git.openssl.org/gitweb/?p=openssl.git;a=patch;h=e9e726506cd2a3fd9c0f12daf8cc1fe934c7dddb]
|
||||
CVE: CVE-2021-4160
|
||||
Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
|
||||
|
||||
---
|
||||
crypto/bn/asm/mips.pl | 4 ++++
|
||||
test/bntest.c | 45 +++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 49 insertions(+)
|
||||
|
||||
diff --git a/crypto/bn/asm/mips.pl b/crypto/bn/asm/mips.pl
|
||||
index 8ad715bda4..74101030f2 100644
|
||||
--- a/crypto/bn/asm/mips.pl
|
||||
+++ b/crypto/bn/asm/mips.pl
|
||||
@@ -1984,6 +1984,8 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
+ sltu $at,$c_3,$t_2
|
||||
+ $ADDU $c_1,$at
|
||||
mflo ($t_1,$a_2,$a_0)
|
||||
mfhi ($t_2,$a_2,$a_0)
|
||||
___
|
||||
@@ -2194,6 +2196,8 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
+ sltu $at,$c_3,$t_2
|
||||
+ $ADDU $c_1,$at
|
||||
mflo ($t_1,$a_2,$a_0)
|
||||
mfhi ($t_2,$a_2,$a_0)
|
||||
___
|
||||
diff --git a/test/bntest.c b/test/bntest.c
|
||||
index b58028a301..bab34ba54b 100644
|
||||
--- a/test/bntest.c
|
||||
+++ b/test/bntest.c
|
||||
@@ -627,6 +627,51 @@ static int test_modexp_mont5(void)
|
||||
if (!TEST_BN_eq(c, d))
|
||||
goto err;
|
||||
|
||||
+ /*
|
||||
+ * Regression test for overflow bug in bn_sqr_comba4/8 for
|
||||
+ * mips-linux-gnu and mipsel-linux-gnu 32bit targets.
|
||||
+ */
|
||||
+ {
|
||||
+ static const char *ehex[] = {
|
||||
+ "95564994a96c45954227b845a1e99cb939d5a1da99ee91acc962396ae999a9ee",
|
||||
+ "38603790448f2f7694c242a875f0cad0aae658eba085f312d2febbbd128dd2b5",
|
||||
+ "8f7d1149f03724215d704344d0d62c587ae3c5939cba4b9b5f3dc5e8e911ef9a",
|
||||
+ "5ce1a5a749a4989d0d8368f6e1f8cdf3a362a6c97fb02047ff152b480a4ad985",
|
||||
+ "2d45efdf0770542992afca6a0590d52930434bba96017afbc9f99e112950a8b1",
|
||||
+ "a359473ec376f329bdae6a19f503be6d4be7393c4e43468831234e27e3838680",
|
||||
+ "b949390d2e416a3f9759e5349ab4c253f6f29f819a6fe4cbfd27ada34903300e",
|
||||
+ "da021f62839f5878a36f1bc3085375b00fd5fa3e68d316c0fdace87a97558465",
|
||||
+ NULL};
|
||||
+ static const char *phex[] = {
|
||||
+ "f95dc0f980fbd22e90caa5a387cc4a369f3f830d50dd321c40db8c09a7e1a241",
|
||||
+ "a536e096622d3280c0c1ba849c1f4a79bf490f60006d081e8cf69960189f0d31",
|
||||
+ "2cd9e17073a3fba7881b21474a13b334116cb2f5dbf3189a6de3515d0840f053",
|
||||
+ "c776d3982d391b6d04d642dda5cc6d1640174c09875addb70595658f89efb439",
|
||||
+ "dc6fbd55f903aadd307982d3f659207f265e1ec6271b274521b7a5e28e8fd7a5",
|
||||
+ "5df089292820477802a43cf5b6b94e999e8c9944ddebb0d0e95a60f88cb7e813",
|
||||
+ "ba110d20e1024774107dd02949031864923b3cb8c3f7250d6d1287b0a40db6a4",
|
||||
+ "7bd5a469518eb65aa207ddc47d8c6e5fc8e0c105be8fc1d4b57b2e27540471d5",
|
||||
+ NULL};
|
||||
+ static const char *mhex[] = {
|
||||
+ "fef15d5ce4625f1bccfbba49fc8439c72bf8202af039a2259678941b60bb4a8f",
|
||||
+ "2987e965d58fd8cf86a856674d519763d0e1211cc9f8596971050d56d9b35db3",
|
||||
+ "785866cfbca17cfdbed6060be3629d894f924a89fdc1efc624f80d41a22f1900",
|
||||
+ "9503fcc3824ef62ccb9208430c26f2d8ceb2c63488ec4c07437aa4c96c43dd8b",
|
||||
+ "9289ed00a712ff66ee195dc71f5e4ead02172b63c543d69baf495f5fd63ba7bc",
|
||||
+ "c633bd309c016e37736da92129d0b053d4ab28d21ad7d8b6fab2a8bbdc8ee647",
|
||||
+ "d2fbcf2cf426cf892e6f5639e0252993965dfb73ccd277407014ea784aaa280c",
|
||||
+ "b7b03972bc8b0baa72360bdb44b82415b86b2f260f877791cd33ba8f2d65229b",
|
||||
+ NULL};
|
||||
+
|
||||
+ if (!TEST_true(parse_bigBN(&e, ehex))
|
||||
+ || !TEST_true(parse_bigBN(&p, phex))
|
||||
+ || !TEST_true(parse_bigBN(&m, mhex))
|
||||
+ || !TEST_true(BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))
|
||||
+ || !TEST_true(BN_mod_exp_simple(a, e, p, m, ctx))
|
||||
+ || !TEST_BN_eq(a, d))
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
/* Zero input */
|
||||
if (!TEST_true(BN_bntest_rand(p, 1024, 0, 0)))
|
||||
goto err;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -18,6 +18,7 @@ SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
|
||||
file://afalg.patch \
|
||||
file://reproducible.patch \
|
||||
file://reproducibility.patch \
|
||||
file://CVE-2021-4160.patch \
|
||||
"
|
||||
|
||||
SRC_URI_append_class-nativesdk = " \
|
||||
|
||||
@@ -0,0 +1,609 @@
|
||||
From 208e5687ff2e48622e28d8888ce5444a54353bbd Mon Sep 17 00:00:00 2001
|
||||
From: Jouni Malinen <jouni@codeaurora.org>
|
||||
Date: Tue, 27 Aug 2019 16:33:15 +0300
|
||||
Subject: [PATCH 1/4] crypto: Add more bignum/EC helper functions
|
||||
|
||||
These are needed for implementing SAE hash-to-element.
|
||||
|
||||
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://w1.fi/security/2022-1/
|
||||
|
||||
CVE: CVE-2022-23303 CVE-2022-23304
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
src/crypto/crypto.h | 45 ++++++++++++++++++
|
||||
src/crypto/crypto_openssl.c | 94 +++++++++++++++++++++++++++++++++++++
|
||||
src/crypto/crypto_wolfssl.c | 66 ++++++++++++++++++++++++++
|
||||
3 files changed, 205 insertions(+)
|
||||
|
||||
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
|
||||
index 15f8ad04cea4..68476dbce96c 100644
|
||||
--- a/src/crypto/crypto.h
|
||||
+++ b/src/crypto/crypto.h
|
||||
@@ -518,6 +518,13 @@ struct crypto_bignum * crypto_bignum_init(void);
|
||||
*/
|
||||
struct crypto_bignum * crypto_bignum_init_set(const u8 *buf, size_t len);
|
||||
|
||||
+/**
|
||||
+ * crypto_bignum_init_set - Allocate memory for bignum and set the value (uint)
|
||||
+ * @val: Value to set
|
||||
+ * Returns: Pointer to allocated bignum or %NULL on failure
|
||||
+ */
|
||||
+struct crypto_bignum * crypto_bignum_init_uint(unsigned int val);
|
||||
+
|
||||
/**
|
||||
* crypto_bignum_deinit - Free bignum
|
||||
* @n: Bignum from crypto_bignum_init() or crypto_bignum_init_set()
|
||||
@@ -612,6 +619,19 @@ int crypto_bignum_div(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
struct crypto_bignum *c);
|
||||
|
||||
+/**
|
||||
+ * crypto_bignum_addmod - d = a + b (mod c)
|
||||
+ * @a: Bignum
|
||||
+ * @b: Bignum
|
||||
+ * @c: Bignum
|
||||
+ * @d: Bignum; used to store the result of (a + b) % c
|
||||
+ * Returns: 0 on success, -1 on failure
|
||||
+ */
|
||||
+int crypto_bignum_addmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ const struct crypto_bignum *c,
|
||||
+ struct crypto_bignum *d);
|
||||
+
|
||||
/**
|
||||
* crypto_bignum_mulmod - d = a * b (mod c)
|
||||
* @a: Bignum
|
||||
@@ -625,6 +645,28 @@ int crypto_bignum_mulmod(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *c,
|
||||
struct crypto_bignum *d);
|
||||
|
||||
+/**
|
||||
+ * crypto_bignum_sqrmod - c = a^2 (mod b)
|
||||
+ * @a: Bignum
|
||||
+ * @b: Bignum
|
||||
+ * @c: Bignum; used to store the result of a^2 % b
|
||||
+ * Returns: 0 on success, -1 on failure
|
||||
+ */
|
||||
+int crypto_bignum_sqrmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ struct crypto_bignum *c);
|
||||
+
|
||||
+/**
|
||||
+ * crypto_bignum_sqrtmod - returns sqrt(a) (mod b)
|
||||
+ * @a: Bignum
|
||||
+ * @b: Bignum
|
||||
+ * @c: Bignum; used to store the result
|
||||
+ * Returns: 0 on success, -1 on failure
|
||||
+ */
|
||||
+int crypto_bignum_sqrtmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ struct crypto_bignum *c);
|
||||
+
|
||||
/**
|
||||
* crypto_bignum_rshift - r = a >> n
|
||||
* @a: Bignum
|
||||
@@ -731,6 +773,9 @@ const struct crypto_bignum * crypto_ec_get_prime(struct crypto_ec *e);
|
||||
*/
|
||||
const struct crypto_bignum * crypto_ec_get_order(struct crypto_ec *e);
|
||||
|
||||
+const struct crypto_bignum * crypto_ec_get_a(struct crypto_ec *e);
|
||||
+const struct crypto_bignum * crypto_ec_get_b(struct crypto_ec *e);
|
||||
+
|
||||
/**
|
||||
* struct crypto_ec_point - Elliptic curve point
|
||||
*
|
||||
diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c
|
||||
index bab33a537293..ed463105e8f1 100644
|
||||
--- a/src/crypto/crypto_openssl.c
|
||||
+++ b/src/crypto/crypto_openssl.c
|
||||
@@ -1283,6 +1283,24 @@ struct crypto_bignum * crypto_bignum_init_set(const u8 *buf, size_t len)
|
||||
}
|
||||
|
||||
|
||||
+struct crypto_bignum * crypto_bignum_init_uint(unsigned int val)
|
||||
+{
|
||||
+ BIGNUM *bn;
|
||||
+
|
||||
+ if (TEST_FAIL())
|
||||
+ return NULL;
|
||||
+
|
||||
+ bn = BN_new();
|
||||
+ if (!bn)
|
||||
+ return NULL;
|
||||
+ if (BN_set_word(bn, val) != 1) {
|
||||
+ BN_free(bn);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ return (struct crypto_bignum *) bn;
|
||||
+}
|
||||
+
|
||||
+
|
||||
void crypto_bignum_deinit(struct crypto_bignum *n, int clear)
|
||||
{
|
||||
if (clear)
|
||||
@@ -1449,6 +1467,28 @@ int crypto_bignum_div(const struct crypto_bignum *a,
|
||||
}
|
||||
|
||||
|
||||
+int crypto_bignum_addmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ const struct crypto_bignum *c,
|
||||
+ struct crypto_bignum *d)
|
||||
+{
|
||||
+ int res;
|
||||
+ BN_CTX *bnctx;
|
||||
+
|
||||
+ if (TEST_FAIL())
|
||||
+ return -1;
|
||||
+
|
||||
+ bnctx = BN_CTX_new();
|
||||
+ if (!bnctx)
|
||||
+ return -1;
|
||||
+ res = BN_mod_add((BIGNUM *) d, (const BIGNUM *) a, (const BIGNUM *) b,
|
||||
+ (const BIGNUM *) c, bnctx);
|
||||
+ BN_CTX_free(bnctx);
|
||||
+
|
||||
+ return res ? 0 : -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
int crypto_bignum_mulmod(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
const struct crypto_bignum *c,
|
||||
@@ -1472,6 +1512,48 @@ int crypto_bignum_mulmod(const struct crypto_bignum *a,
|
||||
}
|
||||
|
||||
|
||||
+int crypto_bignum_sqrmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ struct crypto_bignum *c)
|
||||
+{
|
||||
+ int res;
|
||||
+ BN_CTX *bnctx;
|
||||
+
|
||||
+ if (TEST_FAIL())
|
||||
+ return -1;
|
||||
+
|
||||
+ bnctx = BN_CTX_new();
|
||||
+ if (!bnctx)
|
||||
+ return -1;
|
||||
+ res = BN_mod_sqr((BIGNUM *) c, (const BIGNUM *) a, (const BIGNUM *) b,
|
||||
+ bnctx);
|
||||
+ BN_CTX_free(bnctx);
|
||||
+
|
||||
+ return res ? 0 : -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+int crypto_bignum_sqrtmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ struct crypto_bignum *c)
|
||||
+{
|
||||
+ BN_CTX *bnctx;
|
||||
+ BIGNUM *res;
|
||||
+
|
||||
+ if (TEST_FAIL())
|
||||
+ return -1;
|
||||
+
|
||||
+ bnctx = BN_CTX_new();
|
||||
+ if (!bnctx)
|
||||
+ return -1;
|
||||
+ res = BN_mod_sqrt((BIGNUM *) c, (const BIGNUM *) a, (const BIGNUM *) b,
|
||||
+ bnctx);
|
||||
+ BN_CTX_free(bnctx);
|
||||
+
|
||||
+ return res ? 0 : -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
int crypto_bignum_rshift(const struct crypto_bignum *a, int n,
|
||||
struct crypto_bignum *r)
|
||||
{
|
||||
@@ -1682,6 +1764,18 @@ const struct crypto_bignum * crypto_ec_get_order(struct crypto_ec *e)
|
||||
}
|
||||
|
||||
|
||||
+const struct crypto_bignum * crypto_ec_get_a(struct crypto_ec *e)
|
||||
+{
|
||||
+ return (const struct crypto_bignum *) e->a;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+const struct crypto_bignum * crypto_ec_get_b(struct crypto_ec *e)
|
||||
+{
|
||||
+ return (const struct crypto_bignum *) e->b;
|
||||
+}
|
||||
+
|
||||
+
|
||||
void crypto_ec_point_deinit(struct crypto_ec_point *p, int clear)
|
||||
{
|
||||
if (clear)
|
||||
diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c
|
||||
index 4cedab4367cd..e9894b335e53 100644
|
||||
--- a/src/crypto/crypto_wolfssl.c
|
||||
+++ b/src/crypto/crypto_wolfssl.c
|
||||
@@ -1042,6 +1042,26 @@ struct crypto_bignum * crypto_bignum_init_set(const u8 *buf, size_t len)
|
||||
}
|
||||
|
||||
|
||||
+struct crypto_bignum * crypto_bignum_init_uint(unsigned int val)
|
||||
+{
|
||||
+ mp_int *a;
|
||||
+
|
||||
+ if (TEST_FAIL())
|
||||
+ return NULL;
|
||||
+
|
||||
+ a = (mp_int *) crypto_bignum_init();
|
||||
+ if (!a)
|
||||
+ return NULL;
|
||||
+
|
||||
+ if (mp_set_int(a, val) != MP_OKAY) {
|
||||
+ os_free(a);
|
||||
+ a = NULL;
|
||||
+ }
|
||||
+
|
||||
+ return (struct crypto_bignum *) a;
|
||||
+}
|
||||
+
|
||||
+
|
||||
void crypto_bignum_deinit(struct crypto_bignum *n, int clear)
|
||||
{
|
||||
if (!n)
|
||||
@@ -1168,6 +1188,19 @@ int crypto_bignum_div(const struct crypto_bignum *a,
|
||||
}
|
||||
|
||||
|
||||
+int crypto_bignum_addmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ const struct crypto_bignum *c,
|
||||
+ struct crypto_bignum *d)
|
||||
+{
|
||||
+ if (TEST_FAIL())
|
||||
+ return -1;
|
||||
+
|
||||
+ return mp_addmod((mp_int *) a, (mp_int *) b, (mp_int *) c,
|
||||
+ (mp_int *) d) == MP_OKAY ? 0 : -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
int crypto_bignum_mulmod(const struct crypto_bignum *a,
|
||||
const struct crypto_bignum *b,
|
||||
const struct crypto_bignum *m,
|
||||
@@ -1181,6 +1214,27 @@ int crypto_bignum_mulmod(const struct crypto_bignum *a,
|
||||
}
|
||||
|
||||
|
||||
+int crypto_bignum_sqrmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ struct crypto_bignum *c)
|
||||
+{
|
||||
+ if (TEST_FAIL())
|
||||
+ return -1;
|
||||
+
|
||||
+ return mp_sqrmod((mp_int *) a, (mp_int *) b,
|
||||
+ (mp_int *) c) == MP_OKAY ? 0 : -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+int crypto_bignum_sqrtmod(const struct crypto_bignum *a,
|
||||
+ const struct crypto_bignum *b,
|
||||
+ struct crypto_bignum *c)
|
||||
+{
|
||||
+ /* TODO */
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
int crypto_bignum_rshift(const struct crypto_bignum *a, int n,
|
||||
struct crypto_bignum *r)
|
||||
{
|
||||
@@ -1386,6 +1440,18 @@ const struct crypto_bignum * crypto_ec_get_order(struct crypto_ec *e)
|
||||
}
|
||||
|
||||
|
||||
+const struct crypto_bignum * crypto_ec_get_a(struct crypto_ec *e)
|
||||
+{
|
||||
+ return (const struct crypto_bignum *) &e->a;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+const struct crypto_bignum * crypto_ec_get_b(struct crypto_ec *e)
|
||||
+{
|
||||
+ return (const struct crypto_bignum *) &e->b;
|
||||
+}
|
||||
+
|
||||
+
|
||||
void crypto_ec_point_deinit(struct crypto_ec_point *p, int clear)
|
||||
{
|
||||
ecc_point *point = (ecc_point *) p;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
From 2232d3d5f188b65dbb6c823ac62175412739eb16 Mon Sep 17 00:00:00 2001
|
||||
From: Jouni Malinen <j@w1.fi>
|
||||
Date: Fri, 7 Jan 2022 13:47:16 +0200
|
||||
Subject: [PATCH 2/4] dragonfly: Add sqrt() helper function
|
||||
|
||||
This is a backport of "SAE: Move sqrt() implementation into a helper
|
||||
function" to introduce the helper function needed for the following
|
||||
patches.
|
||||
|
||||
Signed-off-by: Jouni Malinen <j@w1.fi>
|
||||
---
|
||||
src/common/dragonfly.c | 34 ++++++++++++++++++++++++++++++++++
|
||||
src/common/dragonfly.h | 2 ++
|
||||
2 files changed, 36 insertions(+)
|
||||
|
||||
diff --git a/src/common/dragonfly.c b/src/common/dragonfly.c
|
||||
index 547be66f1561..1e842716668e 100644
|
||||
--- a/src/common/dragonfly.c
|
||||
+++ b/src/common/dragonfly.c
|
||||
@@ -213,3 +213,37 @@ int dragonfly_generate_scalar(const struct crypto_bignum *order,
|
||||
"dragonfly: Unable to get randomness for own scalar");
|
||||
return -1;
|
||||
}
|
||||
+
|
||||
+
|
||||
+/* res = sqrt(val) */
|
||||
+int dragonfly_sqrt(struct crypto_ec *ec, const struct crypto_bignum *val,
|
||||
+ struct crypto_bignum *res)
|
||||
+{
|
||||
+ const struct crypto_bignum *prime;
|
||||
+ struct crypto_bignum *tmp, *one;
|
||||
+ int ret = 0;
|
||||
+ u8 prime_bin[DRAGONFLY_MAX_ECC_PRIME_LEN];
|
||||
+ size_t prime_len;
|
||||
+
|
||||
+ /* For prime p such that p = 3 mod 4, sqrt(w) = w^((p+1)/4) mod p */
|
||||
+
|
||||
+ prime = crypto_ec_get_prime(ec);
|
||||
+ prime_len = crypto_ec_prime_len(ec);
|
||||
+ tmp = crypto_bignum_init();
|
||||
+ one = crypto_bignum_init_uint(1);
|
||||
+
|
||||
+ if (crypto_bignum_to_bin(prime, prime_bin, sizeof(prime_bin),
|
||||
+ prime_len) < 0 ||
|
||||
+ (prime_bin[prime_len - 1] & 0x03) != 3 ||
|
||||
+ !tmp || !one ||
|
||||
+ /* tmp = (p+1)/4 */
|
||||
+ crypto_bignum_add(prime, one, tmp) < 0 ||
|
||||
+ crypto_bignum_rshift(tmp, 2, tmp) < 0 ||
|
||||
+ /* res = sqrt(val) */
|
||||
+ crypto_bignum_exptmod(val, tmp, prime, res) < 0)
|
||||
+ ret = -1;
|
||||
+
|
||||
+ crypto_bignum_deinit(tmp, 0);
|
||||
+ crypto_bignum_deinit(one, 0);
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/src/common/dragonfly.h b/src/common/dragonfly.h
|
||||
index ec3dd593eda4..84d67f575c54 100644
|
||||
--- a/src/common/dragonfly.h
|
||||
+++ b/src/common/dragonfly.h
|
||||
@@ -27,5 +27,7 @@ int dragonfly_generate_scalar(const struct crypto_bignum *order,
|
||||
struct crypto_bignum *_rand,
|
||||
struct crypto_bignum *_mask,
|
||||
struct crypto_bignum *scalar);
|
||||
+int dragonfly_sqrt(struct crypto_ec *ec, const struct crypto_bignum *val,
|
||||
+ struct crypto_bignum *res);
|
||||
|
||||
#endif /* DRAGONFLY_H */
|
||||
--
|
||||
2.25.1
|
||||
|
||||
From fe534b0baaa8c0e6ddeb24cf529d6e50e33dc501 Mon Sep 17 00:00:00 2001
|
||||
From: Jouni Malinen <j@w1.fi>
|
||||
Date: Fri, 7 Jan 2022 13:47:16 +0200
|
||||
Subject: [PATCH 3/4] SAE: Derive the y coordinate for PWE with own
|
||||
implementation
|
||||
|
||||
The crypto_ec_point_solve_y_coord() wrapper function might not use
|
||||
constant time operations in the crypto library and as such, could leak
|
||||
side channel information about the password that is used to generate the
|
||||
PWE in the hunting and pecking loop. As such, calculate the two possible
|
||||
y coordinate values and pick the correct one to use with constant time
|
||||
selection.
|
||||
|
||||
Signed-off-by: Jouni Malinen <j@w1.fi>
|
||||
---
|
||||
src/common/sae.c | 47 +++++++++++++++++++++++++++++++++--------------
|
||||
1 file changed, 33 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/src/common/sae.c b/src/common/sae.c
|
||||
index 08fdbfd18173..8d79ed962768 100644
|
||||
--- a/src/common/sae.c
|
||||
+++ b/src/common/sae.c
|
||||
@@ -286,14 +286,16 @@ static int sae_derive_pwe_ecc(struct sae_data *sae, const u8 *addr1,
|
||||
int pwd_seed_odd = 0;
|
||||
u8 prime[SAE_MAX_ECC_PRIME_LEN];
|
||||
size_t prime_len;
|
||||
- struct crypto_bignum *x = NULL, *qr = NULL, *qnr = NULL;
|
||||
+ struct crypto_bignum *x = NULL, *y = NULL, *qr = NULL, *qnr = NULL;
|
||||
u8 x_bin[SAE_MAX_ECC_PRIME_LEN];
|
||||
u8 x_cand_bin[SAE_MAX_ECC_PRIME_LEN];
|
||||
u8 qr_bin[SAE_MAX_ECC_PRIME_LEN];
|
||||
u8 qnr_bin[SAE_MAX_ECC_PRIME_LEN];
|
||||
+ u8 x_y[2 * SAE_MAX_ECC_PRIME_LEN];
|
||||
int res = -1;
|
||||
u8 found = 0; /* 0 (false) or 0xff (true) to be used as const_time_*
|
||||
* mask */
|
||||
+ unsigned int is_eq;
|
||||
|
||||
os_memset(x_bin, 0, sizeof(x_bin));
|
||||
|
||||
@@ -402,25 +404,42 @@ static int sae_derive_pwe_ecc(struct sae_data *sae, const u8 *addr1,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- if (!sae->tmp->pwe_ecc)
|
||||
- sae->tmp->pwe_ecc = crypto_ec_point_init(sae->tmp->ec);
|
||||
- if (!sae->tmp->pwe_ecc)
|
||||
- res = -1;
|
||||
- else
|
||||
- res = crypto_ec_point_solve_y_coord(sae->tmp->ec,
|
||||
- sae->tmp->pwe_ecc, x,
|
||||
- pwd_seed_odd);
|
||||
- if (res < 0) {
|
||||
- /*
|
||||
- * This should not happen since we already checked that there
|
||||
- * is a result.
|
||||
- */
|
||||
+ /* y = sqrt(x^3 + ax + b) mod p
|
||||
+ * if LSB(save) == LSB(y): PWE = (x, y)
|
||||
+ * else: PWE = (x, p - y)
|
||||
+ *
|
||||
+ * Calculate y and the two possible values for PWE and after that,
|
||||
+ * use constant time selection to copy the correct alternative.
|
||||
+ */
|
||||
+ y = crypto_ec_point_compute_y_sqr(sae->tmp->ec, x);
|
||||
+ if (!y ||
|
||||
+ dragonfly_sqrt(sae->tmp->ec, y, y) < 0 ||
|
||||
+ crypto_bignum_to_bin(y, x_y, SAE_MAX_ECC_PRIME_LEN,
|
||||
+ prime_len) < 0 ||
|
||||
+ crypto_bignum_sub(sae->tmp->prime, y, y) < 0 ||
|
||||
+ crypto_bignum_to_bin(y, x_y + SAE_MAX_ECC_PRIME_LEN,
|
||||
+ SAE_MAX_ECC_PRIME_LEN, prime_len) < 0) {
|
||||
wpa_printf(MSG_DEBUG, "SAE: Could not solve y");
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ is_eq = const_time_eq(pwd_seed_odd, x_y[prime_len - 1] & 0x01);
|
||||
+ const_time_select_bin(is_eq, x_y, x_y + SAE_MAX_ECC_PRIME_LEN,
|
||||
+ prime_len, x_y + prime_len);
|
||||
+ os_memcpy(x_y, x_bin, prime_len);
|
||||
+ wpa_hexdump_key(MSG_DEBUG, "SAE: PWE", x_y, 2 * prime_len);
|
||||
+ crypto_ec_point_deinit(sae->tmp->pwe_ecc, 1);
|
||||
+ sae->tmp->pwe_ecc = crypto_ec_point_from_bin(sae->tmp->ec, x_y);
|
||||
+ if (!sae->tmp->pwe_ecc) {
|
||||
+ wpa_printf(MSG_DEBUG, "SAE: Could not generate PWE");
|
||||
+ res = -1;
|
||||
}
|
||||
|
||||
fail:
|
||||
+ forced_memzero(x_y, sizeof(x_y));
|
||||
crypto_bignum_deinit(qr, 0);
|
||||
crypto_bignum_deinit(qnr, 0);
|
||||
+ crypto_bignum_deinit(y, 1);
|
||||
os_free(dummy_password);
|
||||
bin_clear_free(tmp_password, password_len);
|
||||
crypto_bignum_deinit(x, 1);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
From 603cd880e7f90595482658a7136fa6a7be5cb485 Mon Sep 17 00:00:00 2001
|
||||
From: Jouni Malinen <j@w1.fi>
|
||||
Date: Fri, 7 Jan 2022 18:52:27 +0200
|
||||
Subject: [PATCH 4/4] EAP-pwd: Derive the y coordinate for PWE with own
|
||||
implementation
|
||||
|
||||
The crypto_ec_point_solve_y_coord() wrapper function might not use
|
||||
constant time operations in the crypto library and as such, could leak
|
||||
side channel information about the password that is used to generate the
|
||||
PWE in the hunting and pecking loop. As such, calculate the two possible
|
||||
y coordinate values and pick the correct one to use with constant time
|
||||
selection.
|
||||
|
||||
Signed-off-by: Jouni Malinen <j@w1.fi>
|
||||
---
|
||||
src/eap_common/eap_pwd_common.c | 46 ++++++++++++++++++++++++++-------
|
||||
1 file changed, 36 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/eap_common/eap_pwd_common.c b/src/eap_common/eap_pwd_common.c
|
||||
index 2b2b8efdbd01..ff22b29b087a 100644
|
||||
--- a/src/eap_common/eap_pwd_common.c
|
||||
+++ b/src/eap_common/eap_pwd_common.c
|
||||
@@ -127,7 +127,8 @@ int compute_password_element(EAP_PWD_group *grp, u16 num,
|
||||
u8 qr_or_qnr_bin[MAX_ECC_PRIME_LEN];
|
||||
u8 x_bin[MAX_ECC_PRIME_LEN];
|
||||
u8 prime_bin[MAX_ECC_PRIME_LEN];
|
||||
- struct crypto_bignum *tmp2 = NULL;
|
||||
+ u8 x_y[2 * MAX_ECC_PRIME_LEN];
|
||||
+ struct crypto_bignum *tmp2 = NULL, *y = NULL;
|
||||
struct crypto_hash *hash;
|
||||
unsigned char pwe_digest[SHA256_MAC_LEN], *prfbuf = NULL, ctr;
|
||||
int ret = 0, res;
|
||||
@@ -139,6 +140,7 @@ int compute_password_element(EAP_PWD_group *grp, u16 num,
|
||||
u8 found_ctr = 0, is_odd = 0;
|
||||
int cmp_prime;
|
||||
unsigned int in_range;
|
||||
+ unsigned int is_eq;
|
||||
|
||||
if (grp->pwe)
|
||||
return -1;
|
||||
@@ -151,11 +153,6 @@ int compute_password_element(EAP_PWD_group *grp, u16 num,
|
||||
if (crypto_bignum_to_bin(prime, prime_bin, sizeof(prime_bin),
|
||||
primebytelen) < 0)
|
||||
return -1;
|
||||
- grp->pwe = crypto_ec_point_init(grp->group);
|
||||
- if (!grp->pwe) {
|
||||
- wpa_printf(MSG_INFO, "EAP-pwd: unable to create bignums");
|
||||
- goto fail;
|
||||
- }
|
||||
|
||||
if ((prfbuf = os_malloc(primebytelen)) == NULL) {
|
||||
wpa_printf(MSG_INFO, "EAP-pwd: unable to malloc space for prf "
|
||||
@@ -261,10 +258,37 @@ int compute_password_element(EAP_PWD_group *grp, u16 num,
|
||||
*/
|
||||
crypto_bignum_deinit(x_candidate, 1);
|
||||
x_candidate = crypto_bignum_init_set(x_bin, primebytelen);
|
||||
- if (!x_candidate ||
|
||||
- crypto_ec_point_solve_y_coord(grp->group, grp->pwe, x_candidate,
|
||||
- is_odd) != 0) {
|
||||
- wpa_printf(MSG_INFO, "EAP-pwd: Could not solve for y");
|
||||
+ if (!x_candidate)
|
||||
+ goto fail;
|
||||
+
|
||||
+ /* y = sqrt(x^3 + ax + b) mod p
|
||||
+ * if LSB(y) == LSB(pwd-seed): PWE = (x, y)
|
||||
+ * else: PWE = (x, p - y)
|
||||
+ *
|
||||
+ * Calculate y and the two possible values for PWE and after that,
|
||||
+ * use constant time selection to copy the correct alternative.
|
||||
+ */
|
||||
+ y = crypto_ec_point_compute_y_sqr(grp->group, x_candidate);
|
||||
+ if (!y ||
|
||||
+ dragonfly_sqrt(grp->group, y, y) < 0 ||
|
||||
+ crypto_bignum_to_bin(y, x_y, MAX_ECC_PRIME_LEN, primebytelen) < 0 ||
|
||||
+ crypto_bignum_sub(prime, y, y) < 0 ||
|
||||
+ crypto_bignum_to_bin(y, x_y + MAX_ECC_PRIME_LEN,
|
||||
+ MAX_ECC_PRIME_LEN, primebytelen) < 0) {
|
||||
+ wpa_printf(MSG_DEBUG, "SAE: Could not solve y");
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ /* Constant time selection of the y coordinate from the two
|
||||
+ * options */
|
||||
+ is_eq = const_time_eq(is_odd, x_y[primebytelen - 1] & 0x01);
|
||||
+ const_time_select_bin(is_eq, x_y, x_y + MAX_ECC_PRIME_LEN,
|
||||
+ primebytelen, x_y + primebytelen);
|
||||
+ os_memcpy(x_y, x_bin, primebytelen);
|
||||
+ wpa_hexdump_key(MSG_DEBUG, "EAP-pwd: PWE", x_y, 2 * primebytelen);
|
||||
+ grp->pwe = crypto_ec_point_from_bin(grp->group, x_y);
|
||||
+ if (!grp->pwe) {
|
||||
+ wpa_printf(MSG_DEBUG, "EAP-pwd: Could not generate PWE");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -289,6 +313,7 @@ int compute_password_element(EAP_PWD_group *grp, u16 num,
|
||||
/* cleanliness and order.... */
|
||||
crypto_bignum_deinit(x_candidate, 1);
|
||||
crypto_bignum_deinit(tmp2, 1);
|
||||
+ crypto_bignum_deinit(y, 1);
|
||||
crypto_bignum_deinit(qr, 1);
|
||||
crypto_bignum_deinit(qnr, 1);
|
||||
bin_clear_free(prfbuf, primebytelen);
|
||||
@@ -296,6 +321,7 @@ int compute_password_element(EAP_PWD_group *grp, u16 num,
|
||||
os_memset(qnr_bin, 0, sizeof(qnr_bin));
|
||||
os_memset(qr_or_qnr_bin, 0, sizeof(qr_or_qnr_bin));
|
||||
os_memset(pwe_digest, 0, sizeof(pwe_digest));
|
||||
+ forced_memzero(x_y, sizeof(x_y));
|
||||
|
||||
return ret;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -33,6 +33,7 @@ SRC_URI = "http://w1.fi/releases/wpa_supplicant-${PV}.tar.gz \
|
||||
file://CVE-2021-0326.patch \
|
||||
file://CVE-2021-27803.patch \
|
||||
file://CVE-2021-30004.patch \
|
||||
file://CVE-2022-23303-4.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "2d2958c782576dc9901092fbfecb4190"
|
||||
SRC_URI[sha256sum] = "fcbdee7b4a64bea8177973299c8c824419c413ec2e3a95db63dd6a5dc3541f17"
|
||||
|
||||
@@ -206,6 +206,3 @@ do_install_ptest () {
|
||||
}
|
||||
|
||||
FILES_${PN}-ptest += "${bindir}/getlimits"
|
||||
|
||||
# These are specific to Opensuse
|
||||
CVE_WHITELIST += "CVE-2013-0221 CVE-2013-0222 CVE-2013-0223"
|
||||
|
||||
@@ -4,6 +4,12 @@ Date: Sat, 25 Dec 2021 20:52:08 +0100
|
||||
Subject: [PATCH] lib: Prevent integer overflow on m_groupSize in function
|
||||
doProlog (CVE-2021-46143)
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://github.com/libexpat/libexpat/pull/538/commits/85ae9a2d7d0e9358f356b33977b842df8ebaec2b
|
||||
|
||||
CVE: CVE-2021-46143
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
---
|
||||
expat/lib/xmlparse.c | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
33
meta/recipes-core/expat/expat/CVE-2022-23852.patch
Normal file
33
meta/recipes-core/expat/expat/CVE-2022-23852.patch
Normal file
@@ -0,0 +1,33 @@
|
||||
From 847a645152f5ebc10ac63b74b604d0c1a79fae40 Mon Sep 17 00:00:00 2001
|
||||
From: Samanta Navarro <ferivoz@riseup.net>
|
||||
Date: Sat, 22 Jan 2022 17:48:00 +0100
|
||||
Subject: [PATCH] lib: Detect and prevent integer overflow in XML_GetBuffer
|
||||
(CVE-2022-23852)
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://github.com/libexpat/libexpat/commit/847a645152f5ebc10ac63b74b604d0c1a79fae40
|
||||
|
||||
CVE: CVE-2022-23852
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
expat/lib/xmlparse.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
|
||||
index d54af683..5ce31402 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -2067,6 +2067,11 @@ XML_GetBuffer(XML_Parser parser, int len) {
|
||||
keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer);
|
||||
if (keep > XML_CONTEXT_BYTES)
|
||||
keep = XML_CONTEXT_BYTES;
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (keep > INT_MAX - neededSize) {
|
||||
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
|
||||
+ return NULL;
|
||||
+ }
|
||||
neededSize += keep;
|
||||
#endif /* defined XML_CONTEXT_BYTES */
|
||||
if (neededSize
|
||||
49
meta/recipes-core/expat/expat/CVE-2022-23990.patch
Normal file
49
meta/recipes-core/expat/expat/CVE-2022-23990.patch
Normal file
@@ -0,0 +1,49 @@
|
||||
From ede41d1e186ed2aba88a06e84cac839b770af3a1 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Wed, 26 Jan 2022 02:36:43 +0100
|
||||
Subject: [PATCH] lib: Prevent integer overflow in doProlog (CVE-2022-23990)
|
||||
|
||||
The change from "int nameLen" to "size_t nameLen"
|
||||
addresses the overflow on "nameLen++" in code
|
||||
"for (; name[nameLen++];)" right above the second
|
||||
change in the patch.
|
||||
|
||||
Upstream-Status: Backport:
|
||||
https://github.com/libexpat/libexpat/pull/551/commits/ede41d1e186ed2aba88a06e84cac839b770af3a1
|
||||
|
||||
CVE: CVE-2022-23990
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
lib/xmlparse.c | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/xmlparse.c b/expat/lib/xmlparse.c
|
||||
index 5ce31402..d1d17005 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -5372,7 +5372,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
|
||||
if (dtd->in_eldecl) {
|
||||
ELEMENT_TYPE *el;
|
||||
const XML_Char *name;
|
||||
- int nameLen;
|
||||
+ size_t nameLen;
|
||||
const char *nxt
|
||||
= (quant == XML_CQUANT_NONE ? next : next - enc->minBytesPerChar);
|
||||
int myindex = nextScaffoldPart(parser);
|
||||
@@ -5388,7 +5388,13 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
|
||||
nameLen = 0;
|
||||
for (; name[nameLen++];)
|
||||
;
|
||||
- dtd->contentStringLen += nameLen;
|
||||
+
|
||||
+ /* Detect and prevent integer overflow */
|
||||
+ if (nameLen > UINT_MAX - dtd->contentStringLen) {
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
+ dtd->contentStringLen += (unsigned)nameLen;
|
||||
if (parser->m_elementDeclHandler)
|
||||
handleDefault = XML_FALSE;
|
||||
}
|
||||
283
meta/recipes-core/expat/expat/CVE-2022-25235.patch
Normal file
283
meta/recipes-core/expat/expat/CVE-2022-25235.patch
Normal file
@@ -0,0 +1,283 @@
|
||||
From ee2a5b50e7d1940ba8745715b62ceb9efd3a96da Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Tue, 8 Feb 2022 17:37:14 +0100
|
||||
Subject: [PATCH] lib: Drop unused macro UTF8_GET_NAMING
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://github.com/libexpat/libexpat/pull/562/commits
|
||||
|
||||
CVE: CVE-2022-25235
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
expat/lib/xmltok.c | 5 -----
|
||||
1 file changed, 5 deletions(-)
|
||||
|
||||
diff --git a/lib/xmltok.c b/lib/xmltok.c
|
||||
index a72200e8..3bddf125 100644
|
||||
--- a/lib/xmltok.c
|
||||
+++ b/lib/xmltok.c
|
||||
@@ -95,11 +95,6 @@
|
||||
+ ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \
|
||||
& (1u << (((byte)[2]) & 0x1F)))
|
||||
|
||||
-#define UTF8_GET_NAMING(pages, p, n) \
|
||||
- ((n) == 2 \
|
||||
- ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
|
||||
- : ((n) == 3 ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) : 0))
|
||||
-
|
||||
/* Detection of invalid UTF-8 sequences is based on Table 3.1B
|
||||
of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/
|
||||
with the additional restriction of not allowing the Unicode
|
||||
From 3f0a0cb644438d4d8e3294cd0b1245d0edb0c6c6 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Tue, 8 Feb 2022 04:32:20 +0100
|
||||
Subject: [PATCH] lib: Add missing validation of encoding (CVE-2022-25235)
|
||||
|
||||
---
|
||||
expat/lib/xmltok_impl.c | 8 ++++++--
|
||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/xmltok_impl.c b/lib/xmltok_impl.c
|
||||
index 0430591b4..64a3b2c15 100644
|
||||
--- a/lib/xmltok_impl.c
|
||||
+++ b/lib/xmltok_impl.c
|
||||
@@ -61,7 +61,7 @@
|
||||
case BT_LEAD##n: \
|
||||
if (end - ptr < n) \
|
||||
return XML_TOK_PARTIAL_CHAR; \
|
||||
- if (! IS_NAME_CHAR(enc, ptr, n)) { \
|
||||
+ if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NAME_CHAR(enc, ptr, n)) { \
|
||||
*nextTokPtr = ptr; \
|
||||
return XML_TOK_INVALID; \
|
||||
} \
|
||||
@@ -90,7 +90,7 @@
|
||||
case BT_LEAD##n: \
|
||||
if (end - ptr < n) \
|
||||
return XML_TOK_PARTIAL_CHAR; \
|
||||
- if (! IS_NMSTRT_CHAR(enc, ptr, n)) { \
|
||||
+ if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NMSTRT_CHAR(enc, ptr, n)) { \
|
||||
*nextTokPtr = ptr; \
|
||||
return XML_TOK_INVALID; \
|
||||
} \
|
||||
@@ -1134,6 +1134,10 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
case BT_LEAD##n: \
|
||||
if (end - ptr < n) \
|
||||
return XML_TOK_PARTIAL_CHAR; \
|
||||
+ if (IS_INVALID_CHAR(enc, ptr, n)) { \
|
||||
+ *nextTokPtr = ptr; \
|
||||
+ return XML_TOK_INVALID; \
|
||||
+ } \
|
||||
if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
|
||||
ptr += n; \
|
||||
tok = XML_TOK_NAME; \
|
||||
From c85a3025e7a1be086dc34e7559fbc543914d047f Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Wed, 9 Feb 2022 01:00:38 +0100
|
||||
Subject: [PATCH] lib: Add comments to BT_LEAD* cases where encoding has
|
||||
already been validated
|
||||
|
||||
---
|
||||
expat/lib/xmltok_impl.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/lib/xmltok_impl.c b/lib/xmltok_impl.c
|
||||
index 64a3b2c1..84ff35f9 100644
|
||||
--- a/lib/xmltok_impl.c
|
||||
+++ b/lib/xmltok_impl.c
|
||||
@@ -1266,7 +1266,7 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
# define LEAD_CASE(n) \
|
||||
case BT_LEAD##n: \
|
||||
- ptr += n; \
|
||||
+ ptr += n; /* NOTE: The encoding has already been validated. */ \
|
||||
break;
|
||||
LEAD_CASE(2)
|
||||
LEAD_CASE(3)
|
||||
@@ -1335,7 +1335,7 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
# define LEAD_CASE(n) \
|
||||
case BT_LEAD##n: \
|
||||
- ptr += n; \
|
||||
+ ptr += n; /* NOTE: The encoding has already been validated. */ \
|
||||
break;
|
||||
LEAD_CASE(2)
|
||||
LEAD_CASE(3)
|
||||
@@ -1514,7 +1514,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
|
||||
state = inName; \
|
||||
}
|
||||
# define LEAD_CASE(n) \
|
||||
- case BT_LEAD##n: \
|
||||
+ case BT_LEAD##n: /* NOTE: The encoding has already been validated. */ \
|
||||
START_NAME ptr += (n - MINBPC(enc)); \
|
||||
break;
|
||||
LEAD_CASE(2)
|
||||
@@ -1726,7 +1726,7 @@ PREFIX(nameLength)(const ENCODING *enc, const char *ptr) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
# define LEAD_CASE(n) \
|
||||
case BT_LEAD##n: \
|
||||
- ptr += n; \
|
||||
+ ptr += n; /* NOTE: The encoding has already been validated. */ \
|
||||
break;
|
||||
LEAD_CASE(2)
|
||||
LEAD_CASE(3)
|
||||
@@ -1771,7 +1771,7 @@ PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
# define LEAD_CASE(n) \
|
||||
case BT_LEAD##n: \
|
||||
- ptr += n; \
|
||||
+ ptr += n; /* NOTE: The encoding has already been validated. */ \
|
||||
break;
|
||||
LEAD_CASE(2)
|
||||
LEAD_CASE(3)
|
||||
From 6a5510bc6b7efe743356296724e0b38300f05379 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Tue, 8 Feb 2022 04:06:21 +0100
|
||||
Subject: [PATCH] tests: Cover missing validation of encoding (CVE-2022-25235)
|
||||
|
||||
---
|
||||
expat/tests/runtests.c | 109 +++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 109 insertions(+)
|
||||
|
||||
diff --git a/tests/runtests.c b/tests/runtests.c
|
||||
index bc5344b1..9b155b82 100644
|
||||
--- a/tests/runtests.c
|
||||
+++ b/tests/runtests.c
|
||||
@@ -5998,6 +5998,105 @@ START_TEST(test_utf8_in_cdata_section_2) {
|
||||
}
|
||||
END_TEST
|
||||
|
||||
+START_TEST(test_utf8_in_start_tags) {
|
||||
+ struct test_case {
|
||||
+ bool goodName;
|
||||
+ bool goodNameStart;
|
||||
+ const char *tagName;
|
||||
+ };
|
||||
+
|
||||
+ // The idea with the tests below is this:
|
||||
+ // We want to cover 1-, 2- and 3-byte sequences, 4-byte sequences
|
||||
+ // go to isNever and are hence not a concern.
|
||||
+ //
|
||||
+ // We start with a character that is a valid name character
|
||||
+ // (or even name-start character, see XML 1.0r4 spec) and then we flip
|
||||
+ // single bits at places where (1) the result leaves the UTF-8 encoding space
|
||||
+ // and (2) we stay in the same n-byte sequence family.
|
||||
+ //
|
||||
+ // The flipped bits are highlighted in angle brackets in comments,
|
||||
+ // e.g. "[<1>011 1001]" means we had [0011 1001] but we now flipped
|
||||
+ // the most significant bit to 1 to leave UTF-8 encoding space.
|
||||
+ struct test_case cases[] = {
|
||||
+ // 1-byte UTF-8: [0xxx xxxx]
|
||||
+ {true, true, "\x3A"}, // [0011 1010] = ASCII colon ':'
|
||||
+ {false, false, "\xBA"}, // [<1>011 1010]
|
||||
+ {true, false, "\x39"}, // [0011 1001] = ASCII nine '9'
|
||||
+ {false, false, "\xB9"}, // [<1>011 1001]
|
||||
+
|
||||
+ // 2-byte UTF-8: [110x xxxx] [10xx xxxx]
|
||||
+ {true, true, "\xDB\xA5"}, // [1101 1011] [1010 0101] =
|
||||
+ // Arabic small waw U+06E5
|
||||
+ {false, false, "\x9B\xA5"}, // [1<0>01 1011] [1010 0101]
|
||||
+ {false, false, "\xDB\x25"}, // [1101 1011] [<0>010 0101]
|
||||
+ {false, false, "\xDB\xE5"}, // [1101 1011] [1<1>10 0101]
|
||||
+ {true, false, "\xCC\x81"}, // [1100 1100] [1000 0001] =
|
||||
+ // combining char U+0301
|
||||
+ {false, false, "\x8C\x81"}, // [1<0>00 1100] [1000 0001]
|
||||
+ {false, false, "\xCC\x01"}, // [1100 1100] [<0>000 0001]
|
||||
+ {false, false, "\xCC\xC1"}, // [1100 1100] [1<1>00 0001]
|
||||
+
|
||||
+ // 3-byte UTF-8: [1110 xxxx] [10xx xxxx] [10xxxxxx]
|
||||
+ {true, true, "\xE0\xA4\x85"}, // [1110 0000] [1010 0100] [1000 0101] =
|
||||
+ // Devanagari Letter A U+0905
|
||||
+ {false, false, "\xA0\xA4\x85"}, // [1<0>10 0000] [1010 0100] [1000 0101]
|
||||
+ {false, false, "\xE0\x24\x85"}, // [1110 0000] [<0>010 0100] [1000 0101]
|
||||
+ {false, false, "\xE0\xE4\x85"}, // [1110 0000] [1<1>10 0100] [1000 0101]
|
||||
+ {false, false, "\xE0\xA4\x05"}, // [1110 0000] [1010 0100] [<0>000 0101]
|
||||
+ {false, false, "\xE0\xA4\xC5"}, // [1110 0000] [1010 0100] [1<1>00 0101]
|
||||
+ {true, false, "\xE0\xA4\x81"}, // [1110 0000] [1010 0100] [1000 0001] =
|
||||
+ // combining char U+0901
|
||||
+ {false, false, "\xA0\xA4\x81"}, // [1<0>10 0000] [1010 0100] [1000 0001]
|
||||
+ {false, false, "\xE0\x24\x81"}, // [1110 0000] [<0>010 0100] [1000 0001]
|
||||
+ {false, false, "\xE0\xE4\x81"}, // [1110 0000] [1<1>10 0100] [1000 0001]
|
||||
+ {false, false, "\xE0\xA4\x01"}, // [1110 0000] [1010 0100] [<0>000 0001]
|
||||
+ {false, false, "\xE0\xA4\xC1"}, // [1110 0000] [1010 0100] [1<1>00 0001]
|
||||
+ };
|
||||
+ const bool atNameStart[] = {true, false};
|
||||
+
|
||||
+ size_t i = 0;
|
||||
+ char doc[1024];
|
||||
+ size_t failCount = 0;
|
||||
+
|
||||
+ for (; i < sizeof(cases) / sizeof(cases[0]); i++) {
|
||||
+ size_t j = 0;
|
||||
+ for (; j < sizeof(atNameStart) / sizeof(atNameStart[0]); j++) {
|
||||
+ const bool expectedSuccess
|
||||
+ = atNameStart[j] ? cases[i].goodNameStart : cases[i].goodName;
|
||||
+ sprintf(doc, "<%s%s><!--", atNameStart[j] ? "" : "a", cases[i].tagName);
|
||||
+ XML_Parser parser = XML_ParserCreate(NULL);
|
||||
+
|
||||
+ const enum XML_Status status
|
||||
+ = XML_Parse(parser, doc, (int)strlen(doc), /*isFinal=*/XML_FALSE);
|
||||
+
|
||||
+ bool success = true;
|
||||
+ if ((status == XML_STATUS_OK) != expectedSuccess) {
|
||||
+ success = false;
|
||||
+ }
|
||||
+ if ((status == XML_STATUS_ERROR)
|
||||
+ && (XML_GetErrorCode(parser) != XML_ERROR_INVALID_TOKEN)) {
|
||||
+ success = false;
|
||||
+ }
|
||||
+
|
||||
+ if (! success) {
|
||||
+ fprintf(
|
||||
+ stderr,
|
||||
+ "FAIL case %2u (%sat name start, %u-byte sequence, error code %d)\n",
|
||||
+ (unsigned)i + 1u, atNameStart[j] ? " " : "not ",
|
||||
+ (unsigned)strlen(cases[i].tagName), XML_GetErrorCode(parser));
|
||||
+ failCount++;
|
||||
+ }
|
||||
+
|
||||
+ XML_ParserFree(parser);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (failCount > 0) {
|
||||
+ fail("UTF-8 regression detected");
|
||||
+ }
|
||||
+}
|
||||
+END_TEST
|
||||
+
|
||||
/* Test trailing spaces in elements are accepted */
|
||||
static void XMLCALL
|
||||
record_element_end_handler(void *userData, const XML_Char *name) {
|
||||
@@ -6175,6 +6274,14 @@ START_TEST(test_bad_doctype) {
|
||||
}
|
||||
END_TEST
|
||||
|
||||
+START_TEST(test_bad_doctype_utf8) {
|
||||
+ const char *text = "<!DOCTYPE \xDB\x25"
|
||||
+ "doc><doc/>"; // [1101 1011] [<0>010 0101]
|
||||
+ expect_failure(text, XML_ERROR_INVALID_TOKEN,
|
||||
+ "Invalid UTF-8 in DOCTYPE not faulted");
|
||||
+}
|
||||
+END_TEST
|
||||
+
|
||||
START_TEST(test_bad_doctype_utf16) {
|
||||
const char text[] =
|
||||
/* <!DOCTYPE doc [ \x06f2 ]><doc/>
|
||||
@@ -11870,6 +11977,7 @@ make_suite(void) {
|
||||
tcase_add_test(tc_basic, test_ext_entity_utf8_non_bom);
|
||||
tcase_add_test(tc_basic, test_utf8_in_cdata_section);
|
||||
tcase_add_test(tc_basic, test_utf8_in_cdata_section_2);
|
||||
+ tcase_add_test(tc_basic, test_utf8_in_start_tags);
|
||||
tcase_add_test(tc_basic, test_trailing_spaces_in_elements);
|
||||
tcase_add_test(tc_basic, test_utf16_attribute);
|
||||
tcase_add_test(tc_basic, test_utf16_second_attr);
|
||||
@@ -11878,6 +11986,7 @@ make_suite(void) {
|
||||
tcase_add_test(tc_basic, test_bad_attr_desc_keyword);
|
||||
tcase_add_test(tc_basic, test_bad_attr_desc_keyword_utf16);
|
||||
tcase_add_test(tc_basic, test_bad_doctype);
|
||||
+ tcase_add_test(tc_basic, test_bad_doctype_utf8);
|
||||
tcase_add_test(tc_basic, test_bad_doctype_utf16);
|
||||
tcase_add_test(tc_basic, test_bad_doctype_plus);
|
||||
tcase_add_test(tc_basic, test_bad_doctype_star);
|
||||
129
meta/recipes-core/expat/expat/CVE-2022-25236.patch
Normal file
129
meta/recipes-core/expat/expat/CVE-2022-25236.patch
Normal file
@@ -0,0 +1,129 @@
|
||||
From 6881a4fc8596307ab9ff2e85e605afa2e413ab71 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Sat, 12 Feb 2022 00:19:13 +0100
|
||||
Subject: [PATCH] lib: Fix (harmless) use of uninitialized memory
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://github.com/libexpat/libexpat/pull/561/commits
|
||||
|
||||
CVE: CVE-2022-25236
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
expat/lib/xmlparse.c | 6 ++----
|
||||
1 file changed, 2 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
index 902895d5..c768f856 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -718,8 +718,7 @@ XML_ParserCreate(const XML_Char *encodingName) {
|
||||
|
||||
XML_Parser XMLCALL
|
||||
XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) {
|
||||
- XML_Char tmp[2];
|
||||
- *tmp = nsSep;
|
||||
+ XML_Char tmp[2] = {nsSep, 0};
|
||||
return XML_ParserCreate_MM(encodingName, NULL, tmp);
|
||||
}
|
||||
|
||||
@@ -1344,8 +1343,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context,
|
||||
would be otherwise.
|
||||
*/
|
||||
if (parser->m_ns) {
|
||||
- XML_Char tmp[2];
|
||||
- *tmp = parser->m_namespaceSeparator;
|
||||
+ XML_Char tmp[2] = {parser->m_namespaceSeparator, 0};
|
||||
parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd);
|
||||
} else {
|
||||
parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd);
|
||||
From a2fe525e660badd64b6c557c2b1ec26ddc07f6e4 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Sat, 12 Feb 2022 01:09:29 +0100
|
||||
Subject: [PATCH] lib: Protect against malicious namespace declarations
|
||||
(CVE-2022-25236)
|
||||
|
||||
---
|
||||
expat/lib/xmlparse.c | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
index c768f856..a3aef88c 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -3754,6 +3754,17 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
|
||||
if (! mustBeXML && isXMLNS
|
||||
&& (len > xmlnsLen || uri[len] != xmlnsNamespace[len]))
|
||||
isXMLNS = XML_FALSE;
|
||||
+
|
||||
+ // NOTE: While Expat does not validate namespace URIs against RFC 3986,
|
||||
+ // we have to at least make sure that the XML processor on top of
|
||||
+ // Expat (that is splitting tag names by namespace separator into
|
||||
+ // 2- or 3-tuples (uri-local or uri-local-prefix)) cannot be confused
|
||||
+ // by an attacker putting additional namespace separator characters
|
||||
+ // into namespace declarations. That would be ambiguous and not to
|
||||
+ // be expected.
|
||||
+ if (parser->m_ns && (uri[len] == parser->m_namespaceSeparator)) {
|
||||
+ return XML_ERROR_SYNTAX;
|
||||
+ }
|
||||
}
|
||||
isXML = isXML && len == xmlLen;
|
||||
isXMLNS = isXMLNS && len == xmlnsLen;
|
||||
From 2de077423fb22750ebea599677d523b53cb93b1d Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Pipping <sebastian@pipping.org>
|
||||
Date: Sat, 12 Feb 2022 00:51:43 +0100
|
||||
Subject: [PATCH] tests: Cover CVE-2022-25236
|
||||
|
||||
---
|
||||
expat/tests/runtests.c | 30 ++++++++++++++++++++++++++++++
|
||||
1 file changed, 30 insertions(+)
|
||||
|
||||
diff --git a/tests/runtests.c b/tests/runtests.c
|
||||
index d07203f2..bc5344b1 100644
|
||||
--- a/tests/runtests.c
|
||||
+++ b/tests/runtests.c
|
||||
@@ -7220,6 +7220,35 @@ START_TEST(test_ns_double_colon_doctype) {
|
||||
}
|
||||
END_TEST
|
||||
|
||||
+START_TEST(test_ns_separator_in_uri) {
|
||||
+ struct test_case {
|
||||
+ enum XML_Status expectedStatus;
|
||||
+ const char *doc;
|
||||
+ };
|
||||
+ struct test_case cases[] = {
|
||||
+ {XML_STATUS_OK, "<doc xmlns='one_two' />"},
|
||||
+ {XML_STATUS_ERROR, "<doc xmlns='one
two' />"},
|
||||
+ };
|
||||
+
|
||||
+ size_t i = 0;
|
||||
+ size_t failCount = 0;
|
||||
+ for (; i < sizeof(cases) / sizeof(cases[0]); i++) {
|
||||
+ XML_Parser parser = XML_ParserCreateNS(NULL, '\n');
|
||||
+ XML_SetElementHandler(parser, dummy_start_element, dummy_end_element);
|
||||
+ if (XML_Parse(parser, cases[i].doc, (int)strlen(cases[i].doc),
|
||||
+ /*isFinal*/ XML_TRUE)
|
||||
+ != cases[i].expectedStatus) {
|
||||
+ failCount++;
|
||||
+ }
|
||||
+ XML_ParserFree(parser);
|
||||
+ }
|
||||
+
|
||||
+ if (failCount) {
|
||||
+ fail("Namespace separator handling is broken");
|
||||
+ }
|
||||
+}
|
||||
+END_TEST
|
||||
+
|
||||
/* Control variable; the number of times duff_allocator() will successfully
|
||||
* allocate */
|
||||
#define ALLOC_ALWAYS_SUCCEED (-1)
|
||||
@@ -11905,6 +11934,7 @@ make_suite(void) {
|
||||
tcase_add_test(tc_namespace, test_ns_utf16_doctype);
|
||||
tcase_add_test(tc_namespace, test_ns_invalid_doctype);
|
||||
tcase_add_test(tc_namespace, test_ns_double_colon_doctype);
|
||||
+ tcase_add_test(tc_namespace, test_ns_separator_in_uri);
|
||||
|
||||
suite_add_tcase(s, tc_misc);
|
||||
tcase_add_checked_fixture(tc_misc, NULL, basic_teardown);
|
||||
131
meta/recipes-core/expat/expat/CVE-2022-25313-regression.patch
Normal file
131
meta/recipes-core/expat/expat/CVE-2022-25313-regression.patch
Normal file
@@ -0,0 +1,131 @@
|
||||
From b12f34fe32821a69dc12ff9a021daca0856de238 Mon Sep 17 00:00:00 2001
|
||||
From: Samanta Navarro <ferivoz@riseup.net>
|
||||
Date: Sat, 19 Feb 2022 23:59:25 +0000
|
||||
Subject: [PATCH] Fix build_model regression.
|
||||
|
||||
The iterative approach in build_model failed to fill children arrays
|
||||
correctly. A preorder traversal is not required and turned out to be the
|
||||
culprit. Use an easier algorithm:
|
||||
|
||||
Add nodes from scaffold tree starting at index 0 (root) to the target
|
||||
array whenever children are encountered. This ensures that children
|
||||
are adjacent to each other. This complies with the recursive version.
|
||||
|
||||
Store only the scaffold index in numchildren field to prevent a direct
|
||||
processing of these children, which would require a recursive solution.
|
||||
This allows the algorithm to iterate through the target array from start
|
||||
to end without jumping back and forth, converting on the fly.
|
||||
|
||||
Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
|
||||
---
|
||||
lib/xmlparse.c | 79 ++++++++++++++++++++++++++------------------
|
||||
1 file changed, 47 insertions(+), 32 deletions(-)
|
||||
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
index c479a258..84885b5a 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -7373,39 +7373,58 @@ build_model(XML_Parser parser) {
|
||||
*
|
||||
* The iterative approach works as follows:
|
||||
*
|
||||
- * - We use space in the target array for building a temporary stack structure
|
||||
- * while that space is still unused.
|
||||
- * The stack grows from the array's end downwards and the "actual data"
|
||||
- * grows from the start upwards, sequentially.
|
||||
- * (Because stack grows downwards, pushing onto the stack is a decrement
|
||||
- * while popping off the stack is an increment.)
|
||||
+ * - We have two writing pointers, both walking up the result array; one does
|
||||
+ * the work, the other creates "jobs" for its colleague to do, and leads
|
||||
+ * the way:
|
||||
*
|
||||
- * - A stack element appears as a regular XML_Content node on the outside,
|
||||
- * but only uses a single field -- numchildren -- to store the source
|
||||
- * tree node array index. These are the breadcrumbs leading the way back
|
||||
- * during pre-order (node first) depth-first traversal.
|
||||
+ * - The faster one, pointer jobDest, always leads and writes "what job
|
||||
+ * to do" by the other, once they reach that place in the
|
||||
+ * array: leader "jobDest" stores the source node array index (relative
|
||||
+ * to array dtd->scaffold) in field "numchildren".
|
||||
*
|
||||
- * - The reason we know the stack will never grow into (or overlap with)
|
||||
- * the area with data of value at the start of the array is because
|
||||
- * the overall number of elements to process matches the size of the array,
|
||||
- * and the sum of fully processed nodes and yet-to-be processed nodes
|
||||
- * on the stack, cannot be more than the total number of nodes.
|
||||
- * It is possible for the top of the stack and the about-to-write node
|
||||
- * to meet, but that is safe because we get the source index out
|
||||
- * before doing any writes on that node.
|
||||
+ * - The slower one, pointer dest, looks at the value stored in the
|
||||
+ * "numchildren" field (which actually holds a source node array index
|
||||
+ * at that time) and puts the real data from dtd->scaffold in.
|
||||
+ *
|
||||
+ * - Before the loop starts, jobDest writes source array index 0
|
||||
+ * (where the root node is located) so that dest will have something to do
|
||||
+ * when it starts operation.
|
||||
+ *
|
||||
+ * - Whenever nodes with children are encountered, jobDest appends
|
||||
+ * them as new jobs, in order. As a result, tree node siblings are
|
||||
+ * adjacent in the resulting array, for example:
|
||||
+ *
|
||||
+ * [0] root, has two children
|
||||
+ * [1] first child of 0, has three children
|
||||
+ * [3] first child of 1, does not have children
|
||||
+ * [4] second child of 1, does not have children
|
||||
+ * [5] third child of 1, does not have children
|
||||
+ * [2] second child of 0, does not have children
|
||||
+ *
|
||||
+ * Or (the same data) presented in flat array view:
|
||||
+ *
|
||||
+ * [0] root, has two children
|
||||
+ *
|
||||
+ * [1] first child of 0, has three children
|
||||
+ * [2] second child of 0, does not have children
|
||||
+ *
|
||||
+ * [3] first child of 1, does not have children
|
||||
+ * [4] second child of 1, does not have children
|
||||
+ * [5] third child of 1, does not have children
|
||||
+ *
|
||||
+ * - The algorithm repeats until all target array indices have been processed.
|
||||
*/
|
||||
XML_Content *dest = ret; /* tree node writing location, moves upwards */
|
||||
XML_Content *const destLimit = &ret[dtd->scaffCount];
|
||||
- XML_Content *const stackBottom = &ret[dtd->scaffCount];
|
||||
- XML_Content *stackTop = stackBottom; /* i.e. stack is initially empty */
|
||||
+ XML_Content *jobDest = ret; /* next free writing location in target array */
|
||||
str = (XML_Char *)&ret[dtd->scaffCount];
|
||||
|
||||
- /* Push source tree root node index onto the stack */
|
||||
- (--stackTop)->numchildren = 0;
|
||||
+ /* Add the starting job, the root node (index 0) of the source tree */
|
||||
+ (jobDest++)->numchildren = 0;
|
||||
|
||||
for (; dest < destLimit; dest++) {
|
||||
- /* Pop source tree node index off the stack */
|
||||
- const int src_node = (int)(stackTop++)->numchildren;
|
||||
+ /* Retrieve source tree array index from job storage */
|
||||
+ const int src_node = (int)dest->numchildren;
|
||||
|
||||
/* Convert item */
|
||||
dest->type = dtd->scaffold[src_node].type;
|
||||
@@ -7427,16 +7446,12 @@ build_model(XML_Parser parser) {
|
||||
int cn;
|
||||
dest->name = NULL;
|
||||
dest->numchildren = dtd->scaffold[src_node].childcnt;
|
||||
- dest->children = &dest[1];
|
||||
+ dest->children = jobDest;
|
||||
|
||||
- /* Push children to the stack
|
||||
- * in a way where the first child ends up at the top of the
|
||||
- * (downwards growing) stack, in order to be processed first. */
|
||||
- stackTop -= dest->numchildren;
|
||||
+ /* Append scaffold indices of children to array */
|
||||
for (i = 0, cn = dtd->scaffold[src_node].firstchild;
|
||||
- i < dest->numchildren; i++, cn = dtd->scaffold[cn].nextsib) {
|
||||
- (stackTop + i)->numchildren = (unsigned int)cn;
|
||||
- }
|
||||
+ i < dest->numchildren; i++, cn = dtd->scaffold[cn].nextsib)
|
||||
+ (jobDest++)->numchildren = (unsigned int)cn;
|
||||
}
|
||||
}
|
||||
|
||||
230
meta/recipes-core/expat/expat/CVE-2022-25313.patch
Normal file
230
meta/recipes-core/expat/expat/CVE-2022-25313.patch
Normal file
@@ -0,0 +1,230 @@
|
||||
From 9b4ce651b26557f16103c3a366c91934ecd439ab Mon Sep 17 00:00:00 2001
|
||||
From: Samanta Navarro <ferivoz@riseup.net>
|
||||
Date: Tue, 15 Feb 2022 11:54:29 +0000
|
||||
Subject: [PATCH] Prevent stack exhaustion in build_model
|
||||
|
||||
It is possible to trigger stack exhaustion in build_model function if
|
||||
depth of nested children in DTD element is large enough. This happens
|
||||
because build_node is a recursively called function within build_model.
|
||||
|
||||
The code has been adjusted to run iteratively. It uses the already
|
||||
allocated heap space as temporary stack (growing from top to bottom).
|
||||
|
||||
Output is identical to recursive version. No new fields in data
|
||||
structures were added, i.e. it keeps full API and ABI compatibility.
|
||||
Instead the numchildren variable is used to temporarily keep the
|
||||
index of items (uint vs int).
|
||||
|
||||
Documentation and readability improvements kindly added by Sebastian.
|
||||
|
||||
Proof of Concept:
|
||||
|
||||
1. Compile poc binary which parses XML file line by line
|
||||
|
||||
```
|
||||
cat > poc.c << EOF
|
||||
#include <err.h>
|
||||
#include <expat.h>
|
||||
#include <stdio.h>
|
||||
|
||||
XML_Parser parser;
|
||||
|
||||
static void XMLCALL
|
||||
dummy_element_decl_handler(void *userData, const XML_Char *name,
|
||||
XML_Content *model) {
|
||||
XML_FreeContentModel(parser, model);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
FILE *fp;
|
||||
char *p = NULL;
|
||||
size_t s = 0;
|
||||
ssize_t l;
|
||||
if (argc != 2)
|
||||
errx(1, "usage: poc poc.xml");
|
||||
if ((parser = XML_ParserCreate(NULL)) == NULL)
|
||||
errx(1, "XML_ParserCreate");
|
||||
XML_SetElementDeclHandler(parser, dummy_element_decl_handler);
|
||||
if ((fp = fopen(argv[1], "r")) == NULL)
|
||||
err(1, "fopen");
|
||||
while ((l = getline(&p, &s, fp)) > 0)
|
||||
if (XML_Parse(parser, p, (int)l, XML_FALSE) != XML_STATUS_OK)
|
||||
errx(1, "XML_Parse");
|
||||
XML_ParserFree(parser);
|
||||
free(p);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
cc -std=c11 -D_POSIX_C_SOURCE=200809L -lexpat -o poc poc.c
|
||||
```
|
||||
|
||||
2. Create XML file with a lot of nested groups in DTD element
|
||||
|
||||
```
|
||||
cat > poc.xml.zst.b64 << EOF
|
||||
KLUv/aQkACAAPAEA+DwhRE9DVFlQRSB1d3UgWwo8IUVMRU1FTlQgdXd1CigBAHv/58AJAgAQKAIA
|
||||
ECgCABAoAgAQKAIAECgCABAoAgAQKHwAAChvd28KKQIA2/8gV24XBAIAECkCABApAgAQKQIAECkC
|
||||
ABApAgAQKQIAEClVAAAgPl0+CgEA4A4I2VwwnQ==
|
||||
EOF
|
||||
base64 -d poc.xml.zst.b64 | zstd -d > poc.xml
|
||||
```
|
||||
|
||||
3. Run Proof of Concept
|
||||
|
||||
```
|
||||
./poc poc.xml
|
||||
```
|
||||
|
||||
Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://github.com/libexpat/libexpat/pull/558/commits/9b4ce651b26557f16103c3a366c91934ecd439ab
|
||||
|
||||
CVE: CVE-2022-25313
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
expat/lib/xmlparse.c | 116 +++++++++++++++++++++++++++++--------------
|
||||
1 file changed, 79 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
index 4b43e613..594cf12c 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -7317,44 +7317,15 @@ nextScaffoldPart(XML_Parser parser) {
|
||||
return next;
|
||||
}
|
||||
|
||||
-static void
|
||||
-build_node(XML_Parser parser, int src_node, XML_Content *dest,
|
||||
- XML_Content **contpos, XML_Char **strpos) {
|
||||
- DTD *const dtd = parser->m_dtd; /* save one level of indirection */
|
||||
- dest->type = dtd->scaffold[src_node].type;
|
||||
- dest->quant = dtd->scaffold[src_node].quant;
|
||||
- if (dest->type == XML_CTYPE_NAME) {
|
||||
- const XML_Char *src;
|
||||
- dest->name = *strpos;
|
||||
- src = dtd->scaffold[src_node].name;
|
||||
- for (;;) {
|
||||
- *(*strpos)++ = *src;
|
||||
- if (! *src)
|
||||
- break;
|
||||
- src++;
|
||||
- }
|
||||
- dest->numchildren = 0;
|
||||
- dest->children = NULL;
|
||||
- } else {
|
||||
- unsigned int i;
|
||||
- int cn;
|
||||
- dest->numchildren = dtd->scaffold[src_node].childcnt;
|
||||
- dest->children = *contpos;
|
||||
- *contpos += dest->numchildren;
|
||||
- for (i = 0, cn = dtd->scaffold[src_node].firstchild; i < dest->numchildren;
|
||||
- i++, cn = dtd->scaffold[cn].nextsib) {
|
||||
- build_node(parser, cn, &(dest->children[i]), contpos, strpos);
|
||||
- }
|
||||
- dest->name = NULL;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
static XML_Content *
|
||||
build_model(XML_Parser parser) {
|
||||
+ /* Function build_model transforms the existing parser->m_dtd->scaffold
|
||||
+ * array of CONTENT_SCAFFOLD tree nodes into a new array of
|
||||
+ * XML_Content tree nodes followed by a gapless list of zero-terminated
|
||||
+ * strings. */
|
||||
DTD *const dtd = parser->m_dtd; /* save one level of indirection */
|
||||
XML_Content *ret;
|
||||
- XML_Content *cpos;
|
||||
- XML_Char *str;
|
||||
+ XML_Char *str; /* the current string writing location */
|
||||
|
||||
/* Detect and prevent integer overflow.
|
||||
* The preprocessor guard addresses the "always false" warning
|
||||
@@ -7380,10 +7351,81 @@ build_model(XML_Parser parser) {
|
||||
if (! ret)
|
||||
return NULL;
|
||||
|
||||
- str = (XML_Char *)(&ret[dtd->scaffCount]);
|
||||
- cpos = &ret[1];
|
||||
+ /* What follows is an iterative implementation (of what was previously done
|
||||
+ * recursively in a dedicated function called "build_node". The old recursive
|
||||
+ * build_node could be forced into stack exhaustion from input as small as a
|
||||
+ * few megabyte, and so that was a security issue. Hence, a function call
|
||||
+ * stack is avoided now by resolving recursion.)
|
||||
+ *
|
||||
+ * The iterative approach works as follows:
|
||||
+ *
|
||||
+ * - We use space in the target array for building a temporary stack structure
|
||||
+ * while that space is still unused.
|
||||
+ * The stack grows from the array's end downwards and the "actual data"
|
||||
+ * grows from the start upwards, sequentially.
|
||||
+ * (Because stack grows downwards, pushing onto the stack is a decrement
|
||||
+ * while popping off the stack is an increment.)
|
||||
+ *
|
||||
+ * - A stack element appears as a regular XML_Content node on the outside,
|
||||
+ * but only uses a single field -- numchildren -- to store the source
|
||||
+ * tree node array index. These are the breadcrumbs leading the way back
|
||||
+ * during pre-order (node first) depth-first traversal.
|
||||
+ *
|
||||
+ * - The reason we know the stack will never grow into (or overlap with)
|
||||
+ * the area with data of value at the start of the array is because
|
||||
+ * the overall number of elements to process matches the size of the array,
|
||||
+ * and the sum of fully processed nodes and yet-to-be processed nodes
|
||||
+ * on the stack, cannot be more than the total number of nodes.
|
||||
+ * It is possible for the top of the stack and the about-to-write node
|
||||
+ * to meet, but that is safe because we get the source index out
|
||||
+ * before doing any writes on that node.
|
||||
+ */
|
||||
+ XML_Content *dest = ret; /* tree node writing location, moves upwards */
|
||||
+ XML_Content *const destLimit = &ret[dtd->scaffCount];
|
||||
+ XML_Content *const stackBottom = &ret[dtd->scaffCount];
|
||||
+ XML_Content *stackTop = stackBottom; /* i.e. stack is initially empty */
|
||||
+ str = (XML_Char *)&ret[dtd->scaffCount];
|
||||
+
|
||||
+ /* Push source tree root node index onto the stack */
|
||||
+ (--stackTop)->numchildren = 0;
|
||||
+
|
||||
+ for (; dest < destLimit; dest++) {
|
||||
+ /* Pop source tree node index off the stack */
|
||||
+ const int src_node = (int)(stackTop++)->numchildren;
|
||||
+
|
||||
+ /* Convert item */
|
||||
+ dest->type = dtd->scaffold[src_node].type;
|
||||
+ dest->quant = dtd->scaffold[src_node].quant;
|
||||
+ if (dest->type == XML_CTYPE_NAME) {
|
||||
+ const XML_Char *src;
|
||||
+ dest->name = str;
|
||||
+ src = dtd->scaffold[src_node].name;
|
||||
+ for (;;) {
|
||||
+ *str++ = *src;
|
||||
+ if (! *src)
|
||||
+ break;
|
||||
+ src++;
|
||||
+ }
|
||||
+ dest->numchildren = 0;
|
||||
+ dest->children = NULL;
|
||||
+ } else {
|
||||
+ unsigned int i;
|
||||
+ int cn;
|
||||
+ dest->name = NULL;
|
||||
+ dest->numchildren = dtd->scaffold[src_node].childcnt;
|
||||
+ dest->children = &dest[1];
|
||||
+
|
||||
+ /* Push children to the stack
|
||||
+ * in a way where the first child ends up at the top of the
|
||||
+ * (downwards growing) stack, in order to be processed first. */
|
||||
+ stackTop -= dest->numchildren;
|
||||
+ for (i = 0, cn = dtd->scaffold[src_node].firstchild;
|
||||
+ i < dest->numchildren; i++, cn = dtd->scaffold[cn].nextsib) {
|
||||
+ (stackTop + i)->numchildren = (unsigned int)cn;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- build_node(parser, 0, ret, &cpos, &str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
32
meta/recipes-core/expat/expat/CVE-2022-25314.patch
Normal file
32
meta/recipes-core/expat/expat/CVE-2022-25314.patch
Normal file
@@ -0,0 +1,32 @@
|
||||
From efcb347440ade24b9f1054671e6bd05e60b4cafd Mon Sep 17 00:00:00 2001
|
||||
From: Samanta Navarro <ferivoz@riseup.net>
|
||||
Date: Tue, 15 Feb 2022 11:56:57 +0000
|
||||
Subject: [PATCH] Prevent integer overflow in copyString
|
||||
|
||||
The copyString function is only used for encoding string supplied by
|
||||
the library user.
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://github.com/libexpat/libexpat/pull/560/commits/efcb347440ade24b9f1054671e6bd05e60b4cafd
|
||||
|
||||
CVE: CVE-2022-25314
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
|
||||
---
|
||||
expat/lib/xmlparse.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
index 4b43e613..a39377c2 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -7412,7 +7412,7 @@ getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr,
|
||||
|
||||
static XML_Char *
|
||||
copyString(const XML_Char *s, const XML_Memory_Handling_Suite *memsuite) {
|
||||
- int charsRequired = 0;
|
||||
+ size_t charsRequired = 0;
|
||||
XML_Char *result;
|
||||
|
||||
/* First determine how long the string is */
|
||||
145
meta/recipes-core/expat/expat/CVE-2022-25315.patch
Normal file
145
meta/recipes-core/expat/expat/CVE-2022-25315.patch
Normal file
@@ -0,0 +1,145 @@
|
||||
From eb0362808b4f9f1e2345a0cf203b8cc196d776d9 Mon Sep 17 00:00:00 2001
|
||||
From: Samanta Navarro <ferivoz@riseup.net>
|
||||
Date: Tue, 15 Feb 2022 11:55:46 +0000
|
||||
Subject: [PATCH] Prevent integer overflow in storeRawNames
|
||||
|
||||
It is possible to use an integer overflow in storeRawNames for out of
|
||||
boundary heap writes. Default configuration is affected. If compiled
|
||||
with XML_UNICODE then the attack does not work. Compiling with
|
||||
-fsanitize=address confirms the following proof of concept.
|
||||
|
||||
The problem can be exploited by abusing the m_buffer expansion logic.
|
||||
Even though the initial size of m_buffer is a power of two, eventually
|
||||
it can end up a little bit lower, thus allowing allocations very close
|
||||
to INT_MAX (since INT_MAX/2 can be surpassed). This means that tag
|
||||
names can be parsed which are almost INT_MAX in size.
|
||||
|
||||
Unfortunately (from an attacker point of view) INT_MAX/2 is also a
|
||||
limitation in string pools. Having a tag name of INT_MAX/2 characters
|
||||
or more is not possible.
|
||||
|
||||
Expat can convert between different encodings. UTF-16 documents which
|
||||
contain only ASCII representable characters are twice as large as their
|
||||
ASCII encoded counter-parts.
|
||||
|
||||
The proof of concept works by taking these three considerations into
|
||||
account:
|
||||
|
||||
1. Move the m_buffer size slightly below a power of two by having a
|
||||
short root node <a>. This allows the m_buffer to grow very close
|
||||
to INT_MAX.
|
||||
2. The string pooling forbids tag names longer than or equal to
|
||||
INT_MAX/2, so keep the attack tag name smaller than that.
|
||||
3. To be able to still overflow INT_MAX even though the name is
|
||||
limited at INT_MAX/2-1 (nul byte) we use UTF-16 encoding and a tag
|
||||
which only contains ASCII characters. UTF-16 always stores two
|
||||
bytes per character while the tag name is converted to using only
|
||||
one. Our attack node byte count must be a bit higher than
|
||||
2/3 INT_MAX so the converted tag name is around INT_MAX/3 which
|
||||
in sum can overflow INT_MAX.
|
||||
|
||||
Thanks to our small root node, m_buffer can handle 2/3 INT_MAX bytes
|
||||
without running into INT_MAX boundary check. The string pooling is
|
||||
able to store INT_MAX/3 as tag name because the amount is below
|
||||
INT_MAX/2 limitation. And creating the sum of both eventually overflows
|
||||
in storeRawNames.
|
||||
|
||||
Proof of Concept:
|
||||
|
||||
1. Compile expat with -fsanitize=address.
|
||||
|
||||
2. Create Proof of Concept binary which iterates through input
|
||||
file 16 MB at once for better performance and easier integer
|
||||
calculations:
|
||||
|
||||
```
|
||||
cat > poc.c << EOF
|
||||
#include <err.h>
|
||||
#include <expat.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define CHUNK (16 * 1024 * 1024)
|
||||
int main(int argc, char *argv[]) {
|
||||
XML_Parser parser;
|
||||
FILE *fp;
|
||||
char *buf;
|
||||
int i;
|
||||
|
||||
if (argc != 2)
|
||||
errx(1, "usage: poc file.xml");
|
||||
if ((parser = XML_ParserCreate(NULL)) == NULL)
|
||||
errx(1, "failed to create expat parser");
|
||||
if ((fp = fopen(argv[1], "r")) == NULL) {
|
||||
XML_ParserFree(parser);
|
||||
err(1, "failed to open file");
|
||||
}
|
||||
if ((buf = malloc(CHUNK)) == NULL) {
|
||||
fclose(fp);
|
||||
XML_ParserFree(parser);
|
||||
err(1, "failed to allocate buffer");
|
||||
}
|
||||
i = 0;
|
||||
while (fread(buf, CHUNK, 1, fp) == 1) {
|
||||
printf("iteration %d: XML_Parse returns %d\n", ++i,
|
||||
XML_Parse(parser, buf, CHUNK, XML_FALSE));
|
||||
}
|
||||
free(buf);
|
||||
fclose(fp);
|
||||
XML_ParserFree(parser);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
gcc -fsanitize=address -lexpat -o poc poc.c
|
||||
```
|
||||
|
||||
3. Construct specially prepared UTF-16 XML file:
|
||||
|
||||
```
|
||||
dd if=/dev/zero bs=1024 count=794624 | tr '\0' 'a' > poc-utf8.xml
|
||||
echo -n '<a><' | dd conv=notrunc of=poc-utf8.xml
|
||||
echo -n '><' | dd conv=notrunc of=poc-utf8.xml bs=1 seek=805306368
|
||||
iconv -f UTF-8 -t UTF-16LE poc-utf8.xml > poc-utf16.xml
|
||||
```
|
||||
|
||||
4. Run proof of concept:
|
||||
|
||||
```
|
||||
./poc poc-utf16.xml
|
||||
```
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://github.com/libexpat/libexpat/pull/559/commits/eb0362808b4f9f1e2345a0cf203b8cc196d776d9
|
||||
|
||||
CVE: CVE-2022-25315
|
||||
|
||||
Signed-off-by: Steve Sakoman <steve@sakoman.com>
|
||||
---
|
||||
lib/xmlparse.c | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
index 4b43e613..f34d6ab5 100644
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -2563,6 +2563,7 @@ storeRawNames(XML_Parser parser) {
|
||||
while (tag) {
|
||||
int bufSize;
|
||||
int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1);
|
||||
+ size_t rawNameLen;
|
||||
char *rawNameBuf = tag->buf + nameLen;
|
||||
/* Stop if already stored. Since m_tagStack is a stack, we can stop
|
||||
at the first entry that has already been copied; everything
|
||||
@@ -2574,7 +2575,11 @@ storeRawNames(XML_Parser parser) {
|
||||
/* For re-use purposes we need to ensure that the
|
||||
size of tag->buf is a multiple of sizeof(XML_Char).
|
||||
*/
|
||||
- bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
|
||||
+ rawNameLen = ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
|
||||
+ /* Detect and prevent integer overflow. */
|
||||
+ if (rawNameLen > (size_t)INT_MAX - nameLen)
|
||||
+ return XML_FALSE;
|
||||
+ bufSize = nameLen + (int)rawNameLen;
|
||||
if (bufSize > tag->bufEnd - tag->buf) {
|
||||
char *temp = (char *)REALLOC(parser, tag->buf, bufSize);
|
||||
if (temp == NULL)
|
||||
@@ -11,6 +11,14 @@ SRC_URI = "git://github.com/libexpat/libexpat.git;protocol=https;branch=master \
|
||||
file://CVE-2021-45960.patch \
|
||||
file://CVE-2021-46143.patch \
|
||||
file://CVE-2022-22822-27.patch \
|
||||
file://CVE-2022-23852.patch \
|
||||
file://CVE-2022-23990.patch \
|
||||
file://CVE-2022-25235.patch \
|
||||
file://CVE-2022-25236.patch \
|
||||
file://CVE-2022-25313.patch \
|
||||
file://CVE-2022-25313-regression.patch \
|
||||
file://CVE-2022-25314.patch \
|
||||
file://CVE-2022-25315.patch \
|
||||
file://libtool-tag.patch \
|
||||
"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ HOMEPAGE = "https://developer.gnome.org/glib/"
|
||||
|
||||
# pcre is under BSD;
|
||||
# docs/reference/COPYING is with a 'public domain'-like license!
|
||||
LICENSE = "LGPLv2.1+ & BSD & PD"
|
||||
LICENSE = "LGPLv2.1+ & BSD-3-Clause & PD"
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c \
|
||||
file://glib/glib.h;beginline=4;endline=17;md5=b88abb7f3ad09607e71cb9d530155906 \
|
||||
file://gmodule/COPYING;md5=4fbd65380cdd255951079008b364516c \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
SRCBRANCH ?= "release/2.31/master"
|
||||
PV = "2.31+git${SRCPV}"
|
||||
SRCREV_glibc ?= "4f0a61f75385c9a5879cbe7202042e88f692a3c8"
|
||||
SRCREV_glibc ?= "3ef8be9b89ef98300951741f381eb79126ac029f"
|
||||
SRCREV_localedef ?= "cd9f958c4c94a638fa7b2b4e21627364f1a1a655"
|
||||
|
||||
GLIBC_GIT_URI ?= "git://sourceware.org/git/glibc.git"
|
||||
|
||||
@@ -3,6 +3,7 @@ require glibc-version.inc
|
||||
|
||||
CVE_CHECK_WHITELIST += "CVE-2020-10029 CVE-2020-6096 CVE-2016-10228 CVE-2020-1751 CVE-2020-1752 \
|
||||
CVE-2021-27645 CVE-2021-3326 CVE-2020-27618 CVE-2020-29562 CVE-2019-25013 \
|
||||
CVE-2022-23218 CVE-2022-23219 \
|
||||
"
|
||||
|
||||
# glibc https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-1010022
|
||||
|
||||
65
meta/recipes-core/systemd/systemd/CVE-2021-3997-1.patch
Normal file
65
meta/recipes-core/systemd/systemd/CVE-2021-3997-1.patch
Normal file
@@ -0,0 +1,65 @@
|
||||
Backport of the following upstream commit:
|
||||
From fbb77e1e55866633c9f064e2b3bcf2b6402d962d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 23 Nov 2021 15:55:45 +0100
|
||||
Subject: [PATCH 1/3] shared/rm_rf: refactor rm_rf_children_inner() to shorten
|
||||
code a bit
|
||||
|
||||
CVE: CVE-2021-3997
|
||||
Upstream-Status: Backport [http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/systemd_245.4-4ubuntu3.15.debian.tar.xz]
|
||||
Signed-off-by: Purushottam Choudhary <Purushottam.Choudhary@kpit.com>
|
||||
---
|
||||
src/basic/rm-rf.c | 27 +++++++++------------------
|
||||
1 file changed, 9 insertions(+), 18 deletions(-)
|
||||
|
||||
--- a/src/basic/rm-rf.c
|
||||
+++ b/src/basic/rm-rf.c
|
||||
@@ -34,7 +34,7 @@
|
||||
const struct stat *root_dev) {
|
||||
|
||||
struct stat st;
|
||||
- int r;
|
||||
+ int r, q = 0;
|
||||
|
||||
assert(fd >= 0);
|
||||
assert(fname);
|
||||
@@ -50,7 +50,6 @@
|
||||
|
||||
if (is_dir) {
|
||||
_cleanup_close_ int subdir_fd = -1;
|
||||
- int q;
|
||||
|
||||
/* if root_dev is set, remove subdirectories only if device is same */
|
||||
if (root_dev && st.st_dev != root_dev->st_dev)
|
||||
@@ -86,23 +85,15 @@
|
||||
* again for each directory */
|
||||
q = rm_rf_children(TAKE_FD(subdir_fd), flags | REMOVE_PHYSICAL, root_dev);
|
||||
|
||||
- r = unlinkat(fd, fname, AT_REMOVEDIR);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
- if (q < 0)
|
||||
- return q;
|
||||
-
|
||||
- return 1;
|
||||
-
|
||||
- } else if (!(flags & REMOVE_ONLY_DIRECTORIES)) {
|
||||
- r = unlinkat(fd, fname, 0);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
-
|
||||
- return 1;
|
||||
- }
|
||||
+ } else if (flags & REMOVE_ONLY_DIRECTORIES)
|
||||
+ return 0;
|
||||
|
||||
- return 0;
|
||||
+ r = unlinkat(fd, fname, is_dir ? AT_REMOVEDIR : 0);
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
+ if (q < 0)
|
||||
+ return q;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
int rm_rf_children(
|
||||
101
meta/recipes-core/systemd/systemd/CVE-2021-3997-2.patch
Normal file
101
meta/recipes-core/systemd/systemd/CVE-2021-3997-2.patch
Normal file
@@ -0,0 +1,101 @@
|
||||
Backport of the following upstream commit:
|
||||
From bd0127daaaae009ade053718f7d2f297aee4acaf Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 23 Nov 2021 16:56:42 +0100
|
||||
Subject: [PATCH 2/3] shared/rm_rf: refactor rm_rf() to shorten code a bit
|
||||
|
||||
CVE: CVE-2021-3997
|
||||
Upstream-Status: Backport [http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/systemd_245.4-4ubuntu3.15.debian.tar.xz]
|
||||
Signed-off-by: Purushottam Choudhary <Purushottam.Choudhary@kpit.com>
|
||||
---
|
||||
src/basic/rm-rf.c | 53 ++++++++++++++++++++--------------------------
|
||||
1 file changed, 23 insertions(+), 30 deletions(-)
|
||||
|
||||
--- a/src/basic/rm-rf.c
|
||||
+++ b/src/basic/rm-rf.c
|
||||
@@ -159,7 +159,7 @@
|
||||
}
|
||||
|
||||
int rm_rf(const char *path, RemoveFlags flags) {
|
||||
- int fd, r;
|
||||
+ int fd, r, q = 0;
|
||||
|
||||
assert(path);
|
||||
|
||||
@@ -191,49 +191,47 @@
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME);
|
||||
- if (fd < 0) {
|
||||
+ if (fd >= 0) {
|
||||
+ /* We have a dir */
|
||||
+ r = rm_rf_children(fd, flags, NULL);
|
||||
+
|
||||
+ if (FLAGS_SET(flags, REMOVE_ROOT)) {
|
||||
+ q = rmdir(path);
|
||||
+ if (q < 0)
|
||||
+ q = -errno;
|
||||
+ }
|
||||
+ } else {
|
||||
if (FLAGS_SET(flags, REMOVE_MISSING_OK) && errno == ENOENT)
|
||||
return 0;
|
||||
|
||||
if (!IN_SET(errno, ENOTDIR, ELOOP))
|
||||
return -errno;
|
||||
|
||||
- if (FLAGS_SET(flags, REMOVE_ONLY_DIRECTORIES))
|
||||
+ if (FLAGS_SET(flags, REMOVE_ONLY_DIRECTORIES) || !FLAGS_SET(flags, REMOVE_ROOT))
|
||||
return 0;
|
||||
|
||||
- if (FLAGS_SET(flags, REMOVE_ROOT)) {
|
||||
-
|
||||
- if (!FLAGS_SET(flags, REMOVE_PHYSICAL)) {
|
||||
- struct statfs s;
|
||||
-
|
||||
- if (statfs(path, &s) < 0)
|
||||
- return -errno;
|
||||
- if (is_physical_fs(&s))
|
||||
- return log_error_errno(SYNTHETIC_ERRNO(EPERM),
|
||||
- "Attempted to remove files from a disk file system under \"%s\", refusing.",
|
||||
- path);
|
||||
- }
|
||||
-
|
||||
- if (unlink(path) < 0) {
|
||||
- if (FLAGS_SET(flags, REMOVE_MISSING_OK) && errno == ENOENT)
|
||||
- return 0;
|
||||
+ if (!FLAGS_SET(flags, REMOVE_PHYSICAL)) {
|
||||
+ struct statfs s;
|
||||
|
||||
+ if (statfs(path, &s) < 0)
|
||||
return -errno;
|
||||
- }
|
||||
+ if (is_physical_fs(&s))
|
||||
+ return log_error_errno(SYNTHETIC_ERRNO(EPERM),
|
||||
+ "Attempted to remove files from a disk file system under \"%s\", refusing.",
|
||||
+ path);
|
||||
}
|
||||
|
||||
- return 0;
|
||||
+ r = 0;
|
||||
+ q = unlink(path);
|
||||
+ if (q < 0)
|
||||
+ q = -errno;
|
||||
}
|
||||
|
||||
- r = rm_rf_children(fd, flags, NULL);
|
||||
-
|
||||
- if (FLAGS_SET(flags, REMOVE_ROOT) &&
|
||||
- rmdir(path) < 0 &&
|
||||
- r >= 0 &&
|
||||
- (!FLAGS_SET(flags, REMOVE_MISSING_OK) || errno != ENOENT))
|
||||
- r = -errno;
|
||||
-
|
||||
- return r;
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
+ if (q < 0 && (q != -ENOENT || !FLAGS_SET(flags, REMOVE_MISSING_OK)))
|
||||
+ return q;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
int rm_rf_child(int fd, const char *name, RemoveFlags flags) {
|
||||
266
meta/recipes-core/systemd/systemd/CVE-2021-3997-3.patch
Normal file
266
meta/recipes-core/systemd/systemd/CVE-2021-3997-3.patch
Normal file
@@ -0,0 +1,266 @@
|
||||
Backport of the following upstream commit:
|
||||
From bef8e8e577368697b2e6f85183b1dbc99e0e520f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 30 Nov 2021 22:29:05 +0100
|
||||
Subject: [PATCH 3/3] shared/rm-rf: loop over nested directories instead of
|
||||
instead of recursing
|
||||
|
||||
To remove directory structures, we need to remove the innermost items first,
|
||||
and then recursively remove higher-level directories. We would recursively
|
||||
descend into directories and invoke rm_rf_children and rm_rm_children_inner.
|
||||
This is problematic when too many directories are nested.
|
||||
|
||||
Instead, let's create a "TODO" queue. In the the queue, for each level we
|
||||
hold the DIR* object we were working on, and the name of the directory. This
|
||||
allows us to leave a partially-processed directory, and restart the removal
|
||||
loop one level down. When done with the inner directory, we use the name to
|
||||
unlinkat() it from the parent, and proceed with the removal of other items.
|
||||
|
||||
Because the nesting is increased by one level, it is best to view this patch
|
||||
with -b/--ignore-space-change.
|
||||
|
||||
This fixes CVE-2021-3997, https://bugzilla.redhat.com/show_bug.cgi?id=2024639.
|
||||
The issue was reported and patches reviewed by Qualys Team.
|
||||
Mauro Matteo Cascella and Riccardo Schirone from Red Hat handled the disclosure.
|
||||
|
||||
CVE: CVE-2021-3997
|
||||
Upstream-Status: Backport [http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/systemd_245.4-4ubuntu3.15.debian.tar.xz]
|
||||
Signed-off-by: Purushottam Choudhary <Purushottam.Choudhary@kpit.com>
|
||||
---
|
||||
src/basic/rm-rf.c | 161 +++++++++++++++++++++++++++++++--------------
|
||||
1 file changed, 113 insertions(+), 48 deletions(-)
|
||||
|
||||
--- a/src/basic/rm-rf.c
|
||||
+++ b/src/basic/rm-rf.c
|
||||
@@ -26,12 +26,13 @@
|
||||
return !is_temporary_fs(sfs) && !is_cgroup_fs(sfs);
|
||||
}
|
||||
|
||||
-static int rm_rf_children_inner(
|
||||
+static int rm_rf_inner_child(
|
||||
int fd,
|
||||
const char *fname,
|
||||
int is_dir,
|
||||
RemoveFlags flags,
|
||||
- const struct stat *root_dev) {
|
||||
+ const struct stat *root_dev,
|
||||
+ bool allow_recursion) {
|
||||
|
||||
struct stat st;
|
||||
int r, q = 0;
|
||||
@@ -49,9 +50,7 @@
|
||||
}
|
||||
|
||||
if (is_dir) {
|
||||
- _cleanup_close_ int subdir_fd = -1;
|
||||
-
|
||||
- /* if root_dev is set, remove subdirectories only if device is same */
|
||||
+ /* If root_dev is set, remove subdirectories only if device is same */
|
||||
if (root_dev && st.st_dev != root_dev->st_dev)
|
||||
return 0;
|
||||
|
||||
@@ -63,7 +62,6 @@
|
||||
return 0;
|
||||
|
||||
if ((flags & REMOVE_SUBVOLUME) && st.st_ino == 256) {
|
||||
-
|
||||
/* This could be a subvolume, try to remove it */
|
||||
|
||||
r = btrfs_subvol_remove_fd(fd, fname, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA);
|
||||
@@ -77,13 +75,16 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
- subdir_fd = openat(fd, fname, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME);
|
||||
+ if (!allow_recursion)
|
||||
+ return -EISDIR;
|
||||
+
|
||||
+ int subdir_fd = openat(fd, fname, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME);
|
||||
if (subdir_fd < 0)
|
||||
return -errno;
|
||||
|
||||
/* We pass REMOVE_PHYSICAL here, to avoid doing the fstatfs() to check the file system type
|
||||
* again for each directory */
|
||||
- q = rm_rf_children(TAKE_FD(subdir_fd), flags | REMOVE_PHYSICAL, root_dev);
|
||||
+ q = rm_rf_children(subdir_fd, flags | REMOVE_PHYSICAL, root_dev);
|
||||
|
||||
} else if (flags & REMOVE_ONLY_DIRECTORIES)
|
||||
return 0;
|
||||
@@ -96,64 +97,128 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
+typedef struct TodoEntry {
|
||||
+ DIR *dir; /* A directory that we were operating on. */
|
||||
+ char *dirname; /* The filename of that directory itself. */
|
||||
+} TodoEntry;
|
||||
+
|
||||
+static void free_todo_entries(TodoEntry **todos) {
|
||||
+ for (TodoEntry *x = *todos; x && x->dir; x++) {
|
||||
+ closedir(x->dir);
|
||||
+ free(x->dirname);
|
||||
+ }
|
||||
+
|
||||
+ freep(todos);
|
||||
+}
|
||||
+
|
||||
int rm_rf_children(
|
||||
int fd,
|
||||
RemoveFlags flags,
|
||||
const struct stat *root_dev) {
|
||||
|
||||
- _cleanup_closedir_ DIR *d = NULL;
|
||||
- struct dirent *de;
|
||||
+ _cleanup_(free_todo_entries) TodoEntry *todos = NULL;
|
||||
+ size_t n_todo = 0, allocated = 0;
|
||||
+ _cleanup_free_ char *dirname = NULL; /* Set when we are recursing and want to delete ourselves */
|
||||
int ret = 0, r;
|
||||
|
||||
- assert(fd >= 0);
|
||||
+ /* Return the first error we run into, but nevertheless try to go on.
|
||||
+ * The passed fd is closed in all cases, including on failure. */
|
||||
|
||||
- /* This returns the first error we run into, but nevertheless tries to go on. This closes the passed
|
||||
- * fd, in all cases, including on failure. */
|
||||
+ for (;;) { /* This loop corresponds to the directory nesting level. */
|
||||
+ _cleanup_closedir_ DIR *d = NULL;
|
||||
+ struct dirent *de;
|
||||
+
|
||||
+ if (n_todo > 0) {
|
||||
+ /* We know that we are in recursion here, because n_todo is set.
|
||||
+ * We need to remove the inner directory we were operating on. */
|
||||
+ assert(dirname);
|
||||
+ r = unlinkat(dirfd(todos[n_todo-1].dir), dirname, AT_REMOVEDIR);
|
||||
+ if (r < 0 && r != -ENOENT && ret == 0)
|
||||
+ ret = r;
|
||||
+ dirname = mfree(dirname);
|
||||
+
|
||||
+ /* And now let's back out one level up */
|
||||
+ n_todo --;
|
||||
+ d = TAKE_PTR(todos[n_todo].dir);
|
||||
+ dirname = TAKE_PTR(todos[n_todo].dirname);
|
||||
+
|
||||
+ assert(d);
|
||||
+ fd = dirfd(d); /* Retrieve the file descriptor from the DIR object */
|
||||
+ assert(fd >= 0);
|
||||
+ } else {
|
||||
+ next_fd:
|
||||
+ assert(fd >= 0);
|
||||
+ d = fdopendir(fd);
|
||||
+ if (!d) {
|
||||
+ safe_close(fd);
|
||||
+ return -errno;
|
||||
+ }
|
||||
+ fd = dirfd(d); /* We donated the fd to fdopendir(). Let's make sure we sure we have
|
||||
+ * the right descriptor even if it were to internally invalidate the
|
||||
+ * one we passed. */
|
||||
+
|
||||
+ if (!(flags & REMOVE_PHYSICAL)) {
|
||||
+ struct statfs sfs;
|
||||
+
|
||||
+ if (fstatfs(fd, &sfs) < 0)
|
||||
+ return -errno;
|
||||
+
|
||||
+ if (is_physical_fs(&sfs)) {
|
||||
+ /* We refuse to clean physical file systems with this call, unless
|
||||
+ * explicitly requested. This is extra paranoia just to be sure we
|
||||
+ * never ever remove non-state data. */
|
||||
+
|
||||
+ _cleanup_free_ char *path = NULL;
|
||||
+
|
||||
+ (void) fd_get_path(fd, &path);
|
||||
+ return log_error_errno(SYNTHETIC_ERRNO(EPERM),
|
||||
+ "Attempted to remove disk file system under \"%s\", and we can't allow that.",
|
||||
+ strna(path));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- d = fdopendir(fd);
|
||||
- if (!d) {
|
||||
- safe_close(fd);
|
||||
- return -errno;
|
||||
- }
|
||||
+ FOREACH_DIRENT_ALL(de, d, return -errno) {
|
||||
+ int is_dir;
|
||||
|
||||
- if (!(flags & REMOVE_PHYSICAL)) {
|
||||
- struct statfs sfs;
|
||||
+ if (dot_or_dot_dot(de->d_name))
|
||||
+ continue;
|
||||
|
||||
- if (fstatfs(dirfd(d), &sfs) < 0)
|
||||
- return -errno;
|
||||
- }
|
||||
+ is_dir = de->d_type == DT_UNKNOWN ? -1 : de->d_type == DT_DIR;
|
||||
|
||||
- if (is_physical_fs(&sfs)) {
|
||||
- /* We refuse to clean physical file systems with this call, unless explicitly
|
||||
- * requested. This is extra paranoia just to be sure we never ever remove non-state
|
||||
- * data. */
|
||||
-
|
||||
- _cleanup_free_ char *path = NULL;
|
||||
-
|
||||
- (void) fd_get_path(fd, &path);
|
||||
- return log_error_errno(SYNTHETIC_ERRNO(EPERM),
|
||||
- "Attempted to remove disk file system under \"%s\", and we can't allow that.",
|
||||
- strna(path));
|
||||
- }
|
||||
- }
|
||||
+ r = rm_rf_inner_child(fd, de->d_name, is_dir, flags, root_dev, false);
|
||||
+ if (r == -EISDIR) {
|
||||
+ /* Push the current working state onto the todo list */
|
||||
|
||||
- FOREACH_DIRENT_ALL(de, d, return -errno) {
|
||||
- int is_dir;
|
||||
+ if (!GREEDY_REALLOC0(todos, allocated, n_todo + 2))
|
||||
+ return log_oom();
|
||||
|
||||
- if (dot_or_dot_dot(de->d_name))
|
||||
- continue;
|
||||
+ _cleanup_free_ char *newdirname = strdup(de->d_name);
|
||||
+ if (!newdirname)
|
||||
+ return log_oom();
|
||||
|
||||
- is_dir =
|
||||
- de->d_type == DT_UNKNOWN ? -1 :
|
||||
- de->d_type == DT_DIR;
|
||||
-
|
||||
- r = rm_rf_children_inner(dirfd(d), de->d_name, is_dir, flags, root_dev);
|
||||
- if (r < 0 && r != -ENOENT && ret == 0)
|
||||
- ret = r;
|
||||
- }
|
||||
+ int newfd = openat(fd, de->d_name,
|
||||
+ O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME);
|
||||
+ if (newfd >= 0) {
|
||||
+ todos[n_todo++] = (TodoEntry) { TAKE_PTR(d), TAKE_PTR(dirname) };
|
||||
+ fd = newfd;
|
||||
+ dirname = TAKE_PTR(newdirname);
|
||||
+
|
||||
+ goto next_fd;
|
||||
|
||||
- if (FLAGS_SET(flags, REMOVE_SYNCFS) && syncfs(dirfd(d)) < 0 && ret >= 0)
|
||||
- ret = -errno;
|
||||
+ } else if (errno != -ENOENT && ret == 0)
|
||||
+ ret = -errno;
|
||||
+
|
||||
+ } else if (r < 0 && r != -ENOENT && ret == 0)
|
||||
+ ret = r;
|
||||
+ }
|
||||
+
|
||||
+ if (FLAGS_SET(flags, REMOVE_SYNCFS) && syncfs(fd) < 0 && ret >= 0)
|
||||
+ ret = -errno;
|
||||
+
|
||||
+ if (n_todo == 0)
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -250,5 +315,5 @@
|
||||
if (FLAGS_SET(flags, REMOVE_ONLY_DIRECTORIES|REMOVE_SUBVOLUME))
|
||||
return -EINVAL;
|
||||
|
||||
- return rm_rf_children_inner(fd, name, -1, flags, NULL);
|
||||
+ return rm_rf_inner_child(fd, name, -1, flags, NULL, true);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
Backport of the following upstream commit:
|
||||
From bdfe7ada0d4d66e6d6e65f2822acbb1ec230f9c2 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Tue, 5 Oct 2021 10:32:56 +0200
|
||||
Subject: [PATCH] rm-rf: optionally fsync() after removing directory tree
|
||||
|
||||
Upstream-Status: Backport [http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/systemd_245.4-4ubuntu3.15.debian.tar.xz]
|
||||
Signed-off-by: Purushottam Choudhary <Purushottam.Choudhary@kpit.com>
|
||||
---
|
||||
src/basic/rm-rf.c | 3 +++
|
||||
src/basic/rm-rf.h | 1 +
|
||||
2 files changed, 4 insertions(+)
|
||||
|
||||
--- a/src/basic/rm-rf.c
|
||||
+++ b/src/basic/rm-rf.c
|
||||
@@ -161,6 +161,9 @@
|
||||
ret = r;
|
||||
}
|
||||
|
||||
+ if (FLAGS_SET(flags, REMOVE_SYNCFS) && syncfs(dirfd(d)) < 0 && ret >= 0)
|
||||
+ ret = -errno;
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
--- a/src/basic/rm-rf.h
|
||||
+++ b/src/basic/rm-rf.h
|
||||
@@ -11,6 +11,7 @@
|
||||
REMOVE_PHYSICAL = 1 << 2, /* If not set, only removes files on tmpfs, never physical file systems */
|
||||
REMOVE_SUBVOLUME = 1 << 3, /* Drop btrfs subvolumes in the tree too */
|
||||
REMOVE_MISSING_OK = 1 << 4, /* If the top-level directory is missing, ignore the ENOENT for it */
|
||||
+ REMOVE_SYNCFS = 1 << 7, /* syncfs() the root of the specified directory after removing everything in it */
|
||||
} RemoveFlags;
|
||||
|
||||
int rm_rf_children(int fd, RemoveFlags flags, const struct stat *root_dev);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user