All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/ghostscript: fix CVE-2020-15900
@ 2020-08-10  9:14 Fabrice Fontaine
  2020-08-13 20:54 ` Thomas Petazzoni
  2020-08-28 16:11 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Fabrice Fontaine @ 2020-08-10  9:14 UTC (permalink / raw)
  To: buildroot

A memory corruption issue was found in Artifex Ghostscript 9.50 and
9.52. Use of a non-standard PostScript operator can allow overriding of
file access controls. The 'rsearch' calculation for the 'post' size
resulted in a size that was too large, and could underflow to max
uint32_t. This was fixed in commit
5d499272b95a6b890a1397e11d20937de000d31b.

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 ...emory-Corruption-in-Ghostscript-9-52.patch | 54 +++++++++++++++++++
 package/ghostscript/ghostscript.mk            |  3 ++
 2 files changed, 57 insertions(+)
 create mode 100644 package/ghostscript/0002-Bug-702582-CVE-2020-15900-Memory-Corruption-in-Ghostscript-9-52.patch

diff --git a/package/ghostscript/0002-Bug-702582-CVE-2020-15900-Memory-Corruption-in-Ghostscript-9-52.patch b/package/ghostscript/0002-Bug-702582-CVE-2020-15900-Memory-Corruption-in-Ghostscript-9-52.patch
new file mode 100644
index 0000000000..893b96c5be
--- /dev/null
+++ b/package/ghostscript/0002-Bug-702582-CVE-2020-15900-Memory-Corruption-in-Ghostscript-9-52.patch
@@ -0,0 +1,54 @@
+From 5d499272b95a6b890a1397e11d20937de000d31b Mon Sep 17 00:00:00 2001
+From: Ray Johnston <ray.johnston@artifex.com>
+Date: Wed, 22 Jul 2020 09:57:54 -0700
+Subject: [PATCH] Bug 702582, CVE 2020-15900 Memory Corruption in Ghostscript
+ 9.52
+
+Fix the 'rsearch' calculation for the 'post' size to give the correct
+size.  Previous calculation would result in a size that was too large,
+and could underflow to max uint32_t. Also fix 'rsearch' to return the
+correct 'pre' string with empty string match.
+
+A future change may 'undefine' this undocumented, non-standard operator
+during initialization as we do with the many other non-standard internal
+PostScript operators and procedures.
+
+[Retrieved from:
+https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=5d499272b95a6b890a1397e11d20937de000d31b]
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ psi/zstring.c | 17 +++++++++++------
+ 1 file changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/psi/zstring.c b/psi/zstring.c
+index 33662dafa..58e1af2b3 100644
+--- a/psi/zstring.c
++++ b/psi/zstring.c
+@@ -142,13 +142,18 @@ search_impl(i_ctx_t *i_ctx_p, bool forward)
+     return 0;
+ found:
+     op->tas.type_attrs = op1->tas.type_attrs;
+-    op->value.bytes = ptr;
+-    r_set_size(op, size);
++    op->value.bytes = ptr;				/* match */
++    op->tas.rsize = size;				/* match */
+     push(2);
+-    op[-1] = *op1;
+-    r_set_size(op - 1, ptr - op[-1].value.bytes);
+-    op1->value.bytes = ptr + size;
+-    r_set_size(op1, count + (!forward ? (size - 1) : 0));
++    op[-1] = *op1;					/* pre */
++    op[-3].value.bytes = ptr + size;			/* post */
++    if (forward) {
++        op[-1].tas.rsize = ptr - op[-1].value.bytes;	/* pre */
++        op[-3].tas.rsize = count;			/* post */
++    } else {
++        op[-1].tas.rsize = count;			/* pre */
++        op[-3].tas.rsize -= count + size;		/* post */
++    }
+     make_true(op);
+     return 0;
+ }
+-- 
+2.17.1
+
diff --git a/package/ghostscript/ghostscript.mk b/package/ghostscript/ghostscript.mk
index 7d12195f17..5c2c14de0b 100644
--- a/package/ghostscript/ghostscript.mk
+++ b/package/ghostscript/ghostscript.mk
@@ -23,6 +23,9 @@ GHOSTSCRIPT_DEPENDENCIES = \
 	libpng \
 	tiff
 
+# 0002-Bug-702582-CVE-2020-15900-Memory-Corruption-in-Ghostscript-9-52.patch
+GHOSTSCRIPT_IGNORE_CVES += CVE-2020-15900
+
 # Ghostscript includes (old) copies of several libraries, delete them.
 # Inspired by linuxfromscratch:
 # http://www.linuxfromscratch.org/blfs/view/svn/pst/gs.html
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] package/ghostscript: fix CVE-2020-15900
  2020-08-10  9:14 [Buildroot] [PATCH 1/1] package/ghostscript: fix CVE-2020-15900 Fabrice Fontaine
@ 2020-08-13 20:54 ` Thomas Petazzoni
  2020-08-28 16:11 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2020-08-13 20:54 UTC (permalink / raw)
  To: buildroot

On Mon, 10 Aug 2020 11:14:41 +0200
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> A memory corruption issue was found in Artifex Ghostscript 9.50 and
> 9.52. Use of a non-standard PostScript operator can allow overriding of
> file access controls. The 'rsearch' calculation for the 'post' size
> resulted in a size that was too large, and could underflow to max
> uint32_t. This was fixed in commit
> 5d499272b95a6b890a1397e11d20937de000d31b.
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>  ...emory-Corruption-in-Ghostscript-9-52.patch | 54 +++++++++++++++++++
>  package/ghostscript/ghostscript.mk            |  3 ++
>  2 files changed, 57 insertions(+)
>  create mode 100644 package/ghostscript/0002-Bug-702582-CVE-2020-15900-Memory-Corruption-in-Ghostscript-9-52.patch

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] package/ghostscript: fix CVE-2020-15900
  2020-08-10  9:14 [Buildroot] [PATCH 1/1] package/ghostscript: fix CVE-2020-15900 Fabrice Fontaine
  2020-08-13 20:54 ` Thomas Petazzoni
@ 2020-08-28 16:11 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2020-08-28 16:11 UTC (permalink / raw)
  To: buildroot

>>>>> "Fabrice" == Fabrice Fontaine <fontaine.fabrice@gmail.com> writes:

 > A memory corruption issue was found in Artifex Ghostscript 9.50 and
 > 9.52. Use of a non-standard PostScript operator can allow overriding of
 > file access controls. The 'rsearch' calculation for the 'post' size
 > resulted in a size that was too large, and could underflow to max
 > uint32_t. This was fixed in commit
 > 5d499272b95a6b890a1397e11d20937de000d31b.

 > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Committed to 2020.02.x and 2020.05.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-28 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10  9:14 [Buildroot] [PATCH 1/1] package/ghostscript: fix CVE-2020-15900 Fabrice Fontaine
2020-08-13 20:54 ` Thomas Petazzoni
2020-08-28 16:11 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.