summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2018-12-10 01:10:00 +0100
committerMarius Bakke <mbakke@fastmail.com>2018-12-12 20:49:13 +0100
commit87f29c1e5d00050ffb7bef0ee26cb6a4cad49d0d (patch)
tree4908d92070e3d1df68ee527caacf761bbd4ecc3e
parent30eb854a5714600405f2817a4965663c7d6e0d7e (diff)
gnu: ghostscript: Update to 9.26.
* gnu/packages/patches/ghostscript-bug-699708.patch, gnu/packages/patches/ghostscript-CVE-2018-16509.patch: Delete files. * gnu/local.mk (dist_patch_DATA): Remove them. * gnu/packages/ghostscript.scm (ghostscript): Update to 9.26. [source](patches): Remove obsolete.
-rw-r--r--gnu/local.mk2
-rw-r--r--gnu/packages/ghostscript.scm8
-rw-r--r--gnu/packages/patches/ghostscript-CVE-2018-16509.patch193
-rw-r--r--gnu/packages/patches/ghostscript-bug-699708.patch160
4 files changed, 3 insertions, 360 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index aaab4c72ec2..45d8effc11b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -738,8 +738,6 @@ dist_patch_DATA = \
738 %D%/packages/patches/ghc-8.0-fall-back-to-madv_dontneed.patch \ 738 %D%/packages/patches/ghc-8.0-fall-back-to-madv_dontneed.patch \
739 %D%/packages/patches/ghc-dont-pass-linker-flags-via-response-files.patch \ 739 %D%/packages/patches/ghc-dont-pass-linker-flags-via-response-files.patch \
740 %D%/packages/patches/ghc-haddock-library-unbundle.patch \ 740 %D%/packages/patches/ghc-haddock-library-unbundle.patch \
741 %D%/packages/patches/ghostscript-CVE-2018-16509.patch \
742 %D%/packages/patches/ghostscript-bug-699708.patch \
743 %D%/packages/patches/ghostscript-no-header-id.patch \ 741 %D%/packages/patches/ghostscript-no-header-id.patch \
744 %D%/packages/patches/ghostscript-no-header-uuid.patch \ 742 %D%/packages/patches/ghostscript-no-header-uuid.patch \
745 %D%/packages/patches/ghostscript-no-header-creationdate.patch \ 743 %D%/packages/patches/ghostscript-no-header-creationdate.patch \
diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index b46451d94e3..d8c00505131 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -135,7 +135,7 @@ printing, and psresize, for adjusting page sizes.")
135(define-public ghostscript 135(define-public ghostscript
136 (package 136 (package
137 (name "ghostscript") 137 (name "ghostscript")
138 (version "9.24") 138 (version "9.26")
139 (source 139 (source
140 (origin 140 (origin
141 (method url-fetch) 141 (method url-fetch)
@@ -145,10 +145,8 @@ printing, and psresize, for adjusting page sizes.")
145 "/ghostscript-" version ".tar.xz")) 145 "/ghostscript-" version ".tar.xz"))
146 (sha256 146 (sha256
147 (base32 147 (base32
148 "1mk922rnml93w2g42yxiyn8xqanc50cm65irrgh0b6lp4kgifjfl")) 148 "1645f47all5w27bfhiq15vycdm954lmr6agqkrp68ksq6xglgvch"))
149 (patches (search-patches "ghostscript-CVE-2018-16509.patch" 149 (patches (search-patches "ghostscript-no-header-creationdate.patch"
150 "ghostscript-bug-699708.patch"
151 "ghostscript-no-header-creationdate.patch"
152 "ghostscript-no-header-id.patch" 150 "ghostscript-no-header-id.patch"
153 "ghostscript-no-header-uuid.patch")) 151 "ghostscript-no-header-uuid.patch"))
154 (modules '((guix build utils))) 152 (modules '((guix build utils)))
diff --git a/gnu/packages/patches/ghostscript-CVE-2018-16509.patch b/gnu/packages/patches/ghostscript-CVE-2018-16509.patch
deleted file mode 100644
index 50ffa3cb983..00000000000
--- a/gnu/packages/patches/ghostscript-CVE-2018-16509.patch
+++ /dev/null
@@ -1,193 +0,0 @@
1Ghostscript 9.24 was released with an incomplete fix for CVE-2018-16509:
2https://nvd.nist.gov/vuln/detail/CVE-2018-16509
3https://bugs.chromium.org/p/project-zero/issues/detail?id=1640#c19
4https://bugs.ghostscript.com/show_bug.cgi?id=699718
5
6The reproducers no longer work after applying these commits:
7
8https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=5812b1b78fc4d36fdc293b7859de69241140d590
9https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=e914f1da46e33decc534486598dc3eadf69e6efb
10https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=3e5d316b72e3965b7968bb1d96baa137cd063ac6
11https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=643b24dbd002fb9c131313253c307cf3951b3d47
12
13This patch is a "squashed" version of those.
14
15diff --git a/Resource/Init/gs_setpd.ps b/Resource/Init/gs_setpd.ps
16index bba3c8c0e..8fa7c51df 100644
17--- a/Resource/Init/gs_setpd.ps
18+++ b/Resource/Init/gs_setpd.ps
19@@ -95,27 +95,41 @@ level2dict begin
20 { % Since setpagedevice doesn't create new device objects,
21 % we must (carefully) reinstall the old parameters in
22 % the same device.
23- .currentpagedevice pop //null currentdevice //null .trysetparams
24+ .currentpagedevice pop //null currentdevice //null
25+ { .trysetparams } .internalstopped
26+ {
27+ //null
28+ } if
29 dup type /booleantype eq
30 { pop pop }
31- { % This should never happen!
32+ {
33 SETPDDEBUG { (Error in .trysetparams!) = pstack flush } if
34- cleartomark pop pop pop
35+ {cleartomark pop pop pop} .internalstopped pop
36+ % if resetting the entire device state failed, at least put back the
37+ % security related key
38+ currentdevice //null //false mark /.LockSafetyParams
39+ currentpagedevice /.LockSafetyParams .knownget not
40+ {systemdict /SAFER .knownget not {//false} } if
41+ .putdeviceparamsonly
42 /.installpagedevice cvx /rangecheck signalerror
43 }
44 ifelse pop pop
45 % A careful reading of the Red Book reveals that an erasepage
46 % should occur, but *not* an initgraphics.
47 erasepage .beginpage
48- } bind def
49+ } bind executeonly def
50
51 /.uninstallpagedevice
52- { 2 .endpage { .currentnumcopies //false .outputpage } if
53+ {
54+ {2 .endpage { .currentnumcopies //false .outputpage } if} .internalstopped pop
55 nulldevice
56 } bind def
57
58 (%grestorepagedevice) cvn
59- { .uninstallpagedevice grestore .installpagedevice
60+ {
61+ .uninstallpagedevice
62+ grestore
63+ .installpagedevice
64 } bind def
65
66 (%grestoreallpagedevice) cvn
67diff --git a/psi/zdevice2.c b/psi/zdevice2.c
68index 0c7080d57..159a0c0d9 100644
69--- a/psi/zdevice2.c
70+++ b/psi/zdevice2.c
71@@ -251,8 +251,8 @@ z2currentgstate(i_ctx_t *i_ctx_p)
72 /* ------ Wrappers for operators that reset the graphics state. ------ */
73
74 /* Check whether we need to call out to restore the page device. */
75-static bool
76-restore_page_device(const gs_gstate * pgs_old, const gs_gstate * pgs_new)
77+static int
78+restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate * pgs_new)
79 {
80 gx_device *dev_old = gs_currentdevice(pgs_old);
81 gx_device *dev_new;
82@@ -260,9 +260,10 @@ restore_page_device(const gs_gstate * pgs_old, const gs_gstate * pgs_new)
83 gx_device *dev_t2;
84 bool samepagedevice = obj_eq(dev_old->memory, &gs_int_gstate(pgs_old)->pagedevice,
85 &gs_int_gstate(pgs_new)->pagedevice);
86+ bool LockSafetyParams = dev_old->LockSafetyParams;
87
88 if ((dev_t1 = (*dev_proc(dev_old, get_page_device)) (dev_old)) == 0)
89- return false;
90+ return 0;
91 /* If we are going to putdeviceparams in a callout, we need to */
92 /* unlock temporarily. The device will be re-locked as needed */
93 /* by putdeviceparams from the pgs_old->pagedevice dict state. */
94@@ -271,23 +272,51 @@ restore_page_device(const gs_gstate * pgs_old, const gs_gstate * pgs_new)
95 dev_new = gs_currentdevice(pgs_new);
96 if (dev_old != dev_new) {
97 if ((dev_t2 = (*dev_proc(dev_new, get_page_device)) (dev_new)) == 0)
98- return false;
99- if (dev_t1 != dev_t2)
100- return true;
101+ samepagedevice = true;
102+ else if (dev_t1 != dev_t2)
103+ samepagedevice = false;
104+ }
105+
106+ if (LockSafetyParams && !samepagedevice) {
107+ const int required_ops = 512;
108+ const int required_es = 32;
109+
110+ /* The %grestorepagedevice must complete: the biggest danger
111+ is operand stack overflow. As we use get/putdeviceparams
112+ that means pushing all the device params onto the stack,
113+ pdfwrite having by far the largest number of parameters
114+ at (currently) 212 key/value pairs - thus needing (currently)
115+ 424 entries on the op stack. Allowing for working stack
116+ space, and safety margin.....
117+ */
118+ if (required_ops + ref_stack_count(&o_stack) >= ref_stack_max_count(&o_stack)) {
119+ gs_currentdevice(pgs_old)->LockSafetyParams = LockSafetyParams;
120+ return_error(gs_error_stackoverflow);
121+ }
122+ /* We also want enough exec stack space - 32 is an overestimate of
123+ what we need to complete the Postscript call out.
124+ */
125+ if (required_es + ref_stack_count(&e_stack) >= ref_stack_max_count(&e_stack)) {
126+ gs_currentdevice(pgs_old)->LockSafetyParams = LockSafetyParams;
127+ return_error(gs_error_execstackoverflow);
128+ }
129 }
130 /*
131 * The current implementation of setpagedevice just sets new
132 * parameters in the same device object, so we have to check
133 * whether the page device dictionaries are the same.
134 */
135- return !samepagedevice;
136+ return samepagedevice ? 0 : 1;
137 }
138
139 /* - grestore - */
140 static int
141 z2grestore(i_ctx_t *i_ctx_p)
142 {
143- if (!restore_page_device(igs, gs_gstate_saved(igs)))
144+ int code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
145+ if (code < 0) return code;
146+
147+ if (code == 0)
148 return gs_grestore(igs);
149 return push_callout(i_ctx_p, "%grestorepagedevice");
150 }
151@@ -297,7 +326,9 @@ static int
152 z2grestoreall(i_ctx_t *i_ctx_p)
153 {
154 for (;;) {
155- if (!restore_page_device(igs, gs_gstate_saved(igs))) {
156+ int code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
157+ if (code < 0) return code;
158+ if (code == 0) {
159 bool done = !gs_gstate_saved(gs_gstate_saved(igs));
160
161 gs_grestore(igs);
162@@ -328,11 +359,15 @@ z2restore(i_ctx_t *i_ctx_p)
163 if (code < 0) return code;
164
165 while (gs_gstate_saved(gs_gstate_saved(igs))) {
166- if (restore_page_device(igs, gs_gstate_saved(igs)))
167+ code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
168+ if (code < 0) return code;
169+ if (code > 0)
170 return push_callout(i_ctx_p, "%restore1pagedevice");
171 gs_grestore(igs);
172 }
173- if (restore_page_device(igs, gs_gstate_saved(igs)))
174+ code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
175+ if (code < 0) return code;
176+ if (code > 0)
177 return push_callout(i_ctx_p, "%restorepagedevice");
178
179 code = dorestore(i_ctx_p, asave);
180@@ -355,9 +390,12 @@ static int
181 z2setgstate(i_ctx_t *i_ctx_p)
182 {
183 os_ptr op = osp;
184+ int code;
185
186 check_stype(*op, st_igstate_obj);
187- if (!restore_page_device(igs, igstate_ptr(op)))
188+ code = restore_page_device(i_ctx_p, igs, igstate_ptr(op));
189+ if (code < 0) return code;
190+ if (code == 0)
191 return zsetgstate(i_ctx_p);
192 return push_callout(i_ctx_p, "%setgstatepagedevice");
193 }
diff --git a/gnu/packages/patches/ghostscript-bug-699708.patch b/gnu/packages/patches/ghostscript-bug-699708.patch
deleted file mode 100644
index 1567be1c6fe..00000000000
--- a/gnu/packages/patches/ghostscript-bug-699708.patch
+++ /dev/null
@@ -1,160 +0,0 @@
1Additional security fix that missed 9.24.
2
3Taken from upstream:
4http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=fb713b3818b52d8a6cf62c951eba2e1795ff9624
5
6From fb713b3818b52d8a6cf62c951eba2e1795ff9624 Mon Sep 17 00:00:00 2001
7From: Chris Liddell <chris.liddell@artifex.com>
8Date: Thu, 6 Sep 2018 09:16:22 +0100
9Subject: [PATCH] Bug 699708 (part 1): 'Hide' non-replaceable error handlers
10 for SAFER
11
12We already had a 'private' dictionary for non-standard errors: gserrordict.
13
14This now includes all the default error handlers, the dictionary is made
15noaccess and all the prodedures are bound and executeonly.
16
17When running with -dSAFER, in the event of a Postscript error, instead of
18pulling the handler from errordict, we'll pull it from gserrordict - thus
19malicious input cannot trigger problems by the use of custom error handlers.
20
21errordict remains open and writeable, so files such as the Quality Logic tests
22that install their own handlers will still 'work', with the exception that the
23custom error handlers will not be called.
24
25This is a 'first pass', 'sledgehammer' approach: a nice addition would to allow
26an integrator to specify a list of errors that are not to be replaced (for
27example, embedded applications would probably want to ensure that VMerror is
28always handled as they intend).
29---
30 Resource/Init/gs_init.ps | 29 ++++++++++++++++++-----------
31 psi/interp.c | 30 +++++++++++++++++++++---------
32 2 files changed, 39 insertions(+), 20 deletions(-)
33
34diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
35index 071c39205..bc8b7951c 100644
36--- a/Resource/Init/gs_init.ps
37+++ b/Resource/Init/gs_init.ps
38@@ -881,7 +881,7 @@ userdict /.currentresourcefile //null put
39 { not exch pop exit } { pop } ifelse
40 }
41 for exch pop .quit
42- } bind def
43+ } bind executeonly def
44 /.errorhandler % <command> <errorname> .errorhandler -
45 { % Detect an internal 'stopped'.
46 1 .instopped { //null eq { pop pop stop } if } if
47@@ -926,7 +926,7 @@ userdict /.currentresourcefile //null put
48 $error /globalmode get $error /.nosetlocal get and .setglobal
49 $error /.inerror //false put
50 stop
51- } bind def
52+ } bind executeonly def
53 % Define the standard handleerror. We break out the printing procedure
54 % (.printerror) so that it can be extended for binary output
55 % if the Level 2 facilities are present.
56@@ -976,7 +976,7 @@ userdict /.currentresourcefile //null put
57 ifelse % newerror
58 end
59 flush
60- } bind def
61+ } bind executeonly def
62 /.printerror_long % long error printout,
63 % $error is on the dict stack
64 { % Push the (anonymous) stack printing procedure.
65@@ -1053,14 +1053,14 @@ userdict /.currentresourcefile //null put
66 { (Current file position is ) print position = }
67 if
68
69- } bind def
70+ } bind executeonly def
71 % Define a procedure for clearing the error indication.
72 /.clearerror
73 { $error /newerror //false put
74 $error /errorname //null put
75 $error /errorinfo //null put
76 0 .setoserrno
77- } bind def
78+ } bind executeonly def
79
80 % Define $error. This must be in local VM.
81 .currentglobal //false .setglobal
82@@ -1086,11 +1086,15 @@ end
83 /errordict ErrorNames length 3 add dict
84 .forcedef % errordict is local, systemdict is global
85 .setglobal % back to global VM
86-% For greater Adobe compatibility, we put all non-standard errors in a
87-% separate dictionary, gserrordict. It does not need to be in local VM,
88-% because PostScript programs do not access it.
89+% gserrordict contains all the default error handling methods, but unlike
90+% errordict it is noaccess after creation (also it is in global VM).
91+% When running 'SAFER', we'll ignore the contents of errordict, which
92+% may have been tampered with by the running job, and always use gserrordict
93+% gserrordict also contains any non-standard errors, for better compatibility
94+% with Adobe.
95+%
96 % NOTE: the name gserrordict is known to the interpreter.
97-/gserrordict 5 dict def
98+/gserrordict ErrorNames length 3 add dict def
99 % Register an error in errordict. We make this a procedure because we only
100 % register the Level 1 errors here: the rest are registered by "feature"
101 % files. However, ErrorNames contains all of the error names regardless of
102@@ -1119,8 +1123,11 @@ errordict begin
103 } bind def
104 end % errordict
105
106-% Put non-standard errors in gserrordict.
107-gserrordict /unknownerror errordict /unknownerror get put
108+% Put all the default handlers in gserrordict
109+gserrordict
110+errordict {2 index 3 1 roll put} forall
111+noaccess pop
112+% remove the non-standard errors from errordict
113 errordict /unknownerror .undef
114 % Define a stable private copy of handleerror that we will always use under
115 % JOBSERVER mode.
116diff --git a/psi/interp.c b/psi/interp.c
117index c27b70dca..d41a9d3f5 100644
118--- a/psi/interp.c
119+++ b/psi/interp.c
120@@ -661,16 +661,28 @@ again:
121 return code;
122 if (gs_errorname(i_ctx_p, code, &error_name) < 0)
123 return code; /* out-of-range error code! */
124- /*
125- * For greater Adobe compatibility, only the standard PostScript errors
126- * are defined in errordict; the rest are in gserrordict.
127+
128+ /* If LockFilePermissions is true, we only refer to gserrordict, which
129+ * is not accessible to Postcript jobs
130 */
131- if (dict_find_string(systemdict, "errordict", &perrordict) <= 0 ||
132- (dict_find(perrordict, &error_name, &epref) <= 0 &&
133- (dict_find_string(systemdict, "gserrordict", &perrordict) <= 0 ||
134- dict_find(perrordict, &error_name, &epref) <= 0))
135- )
136- return code; /* error name not in errordict??? */
137+ if (i_ctx_p->LockFilePermissions) {
138+ if (((dict_find_string(systemdict, "gserrordict", &perrordict) <= 0 ||
139+ dict_find(perrordict, &error_name, &epref) <= 0))
140+ )
141+ return code; /* error name not in errordict??? */
142+ }
143+ else {
144+ /*
145+ * For greater Adobe compatibility, only the standard PostScript errors
146+ * are defined in errordict; the rest are in gserrordict.
147+ */
148+ if (dict_find_string(systemdict, "errordict", &perrordict) <= 0 ||
149+ (dict_find(perrordict, &error_name, &epref) <= 0 &&
150+ (dict_find_string(systemdict, "gserrordict", &perrordict) <= 0 ||
151+ dict_find(perrordict, &error_name, &epref) <= 0))
152+ )
153+ return code; /* error name not in errordict??? */
154+ }
155 doref = *epref;
156 epref = &doref;
157 /* Push the error object on the operand stack if appropriate. */
158--
1592.18.0
160