public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/ghostscript] f44: CVE-2026-101258 (fedora#2546645)
@ 2026-10-16 13:49 RHEL Packaging Agent
0 siblings, 0 replies; only message in thread
From: RHEL Packaging Agent @ 2026-10-16 13:49 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/ghostscript
Branch : f44
Commit : 5eac88225d9894ccfb79314c1f23ccad150785df
Author : RHEL Packaging Agent <redhat-ymir-agent@redhat.com>
Date : 2026-10-16T15:15:52+02:00
Stats : +386/-0 in 4 file(s)
URL : https://src.fedoraproject.org/rpms/ghostscript/c/5eac88225d9894ccfb79314c1f23ccad150785df?branch=f44
Log:
CVE-2026-101258 (fedora#2546645)
---
diff --git a/0001-PostScript-interpreter-don-t-permit-local-inside-glo.patch b/0001-PostScript-interpreter-don-t-permit-local-inside-glo.patch
new file mode 100644
index 0000000..9db6c70
--- /dev/null
+++ b/0001-PostScript-interpreter-don-t-permit-local-inside-glo.patch
@@ -0,0 +1,109 @@
+From 5894dca6f875d327c425e80c10025adbb4211ef7 Mon Sep 17 00:00:00 2001
+From: Ken Sharp <Ken.Sharp@artifex.com>
+Date: Wed, 24 Jun 2026 09:28:01 +0100
+Subject: [PATCH] PostScript interpreter - don't permit local inside global
+ storage
+
+Bug #709461 "Use-after-free in procedure-source filter state across `restore` (`psi/zfproc.c`)"
+
+The problem is that the C code stores a reference to a PostScript
+string object, but does not check the allocation space. If the owner of
+the C structure is allocated in global VM, and the string is allocated
+in local VM, then the string can be restored away while the structure
+stil holds a pointer to it. When we reclaim memory this causes a crash.
+
+From a spec perspective there's no reason to retain a pointer to a local
+object in a global object, its just an implementation detail. Just to
+be sure I ran the file on Distiller and that has no problems.
+
+So in this commit; if the 'file' object (which owns the structure) is
+not in local VM, and the string returned by the procedural data source
+is in local VM, then make a copy of the string in global VM. This
+avoids any potential problems at the cost of using extra memory.
+
+This issue was reported by 'Rick de Jager <rick@v12.sh>'.
+---
+ psi/zfproc.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 46 insertions(+), 1 deletion(-)
+
+diff --git a/psi/zfproc.c b/psi/zfproc.c
+index 4917236a5..259c1aa7e 100644
+--- a/psi/zfproc.c
++++ b/psi/zfproc.c
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 2001-2023 Artifex Software, Inc.
++/* Copyright (C) 2001-2026 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+@@ -124,6 +124,30 @@ s_proc_set_defaults(stream_state * st)
+ make_null(&ss->data);
+ }
+
++static int s_proc_copy_string(i_ctx_t * i_ctx_p, ref *dest, ref *src, uint mem)
++{
++ int code = 0;
++ uint saved_space = avm_local;
++
++ saved_space = imemory_space(iimemory);
++
++ if (imemory_space(iimemory) != mem)
++ ialloc_set_space(idmemory, mem);
++
++ code = gs_alloc_string_ref(iimemory, dest, 0, r_size(src), "copy_cspace_string");
++
++ if (imemory_space(iimemory) != saved_space)
++ ialloc_set_space(idmemory, saved_space);
++
++ if (code < 0)
++ return code;
++
++ r_copy_attrs(dest, a_all, src);
++
++ memcpy(dest->value.bytes, src->value.bytes, r_size(src));
++ return 0;
++}
++
+ /* ---------------- Read streams ---------------- */
+
+ /* Forward references */
+@@ -220,11 +244,23 @@ s_proc_read_continue(i_ctx_t *i_ctx_p)
+ os_ptr opbuf = op - 1;
+ stream *ps;
+ stream_proc_state *ss;
++ uint s1, s2;
+
+ check_file(ps, op);
+ check_read_type(*opbuf, t_string);
+ while ((ps->end_status = 0, ps->strm) != 0)
+ ps = ps->strm;
++ s1 = r_space(op);
++ s2 = r_space(opbuf);
++ if (!r_is_local(op) && r_is_local(opbuf)) {
++ ref copy;
++ int code = 0;
++
++ code = s_proc_copy_string(i_ctx_p, ©, opbuf, r_space(op));
++ if (code < 0)
++ return code;
++ *opbuf = copy;
++ }
+ ss = (stream_proc_state *) ps->state;
+ ss->data = *opbuf;
+ ss->index = 0;
+@@ -359,6 +395,15 @@ s_proc_write_continue(i_ctx_t *i_ctx_p)
+ ps = ps->strm;
+ }
+ ps->end_status = 0;
++ if (!r_is_local(op) && r_is_local(opbuf)) {
++ ref copy;
++ int code = 0;
++
++ code = s_proc_copy_string(i_ctx_p, ©, opbuf, r_space(op));
++ if (code < 0)
++ return code;
++ *opbuf = copy;
++ }
+ ss = (stream_proc_state *) ps->state;
+ ss->data = *opbuf;
+ ss->index = 0;
diff --git a/0001-PostScript-interpreter-procedural-data-sink-filter-d.patch b/0001-PostScript-interpreter-procedural-data-sink-filter-d.patch
new file mode 100644
index 0000000..5b9c4a7
--- /dev/null
+++ b/0001-PostScript-interpreter-procedural-data-sink-filter-d.patch
@@ -0,0 +1,206 @@
+From 8a8a62700517b0f20e95d9399b88e4d4dd7a41e8 Mon Sep 17 00:00:00 2001
+From: Ken Sharp <Ken.Sharp@artifex.com>
+Date: Tue, 4 Aug 2026 09:03:51 +0100
+Subject: [PATCH] PostScript interpreter - procedural data sink filter, detect
+ restore
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Bug #709605 "Procedure-stream buffer survives restore: heap- use-after-free write in s_proc_write_process — Ghostscript PostScript interpreter (procedure streams)"
+
+When a filter writes to a procedural target, the PostScript returns
+a string to continue writing to. If the string is restored away before
+the end of data then we were continuing to write to it.
+
+The PLRM states "If the string returned by the procedure is reclaimed by
+a restore operation before the filter becomes closed, the results are
+unpredictable. Typically, an ioerror occurs."
+
+So we need to detect that a restore has reclaimed our string, we do this
+by noting the meory allocator, and save ID of the current state when the
+PostScript program returns a string to use.
+
+Whenever we need to write tothe string we first check to see if the
+save is still in existence. If it is (or there was no save, or the
+string was allocated in memory other than local VM) then we can safely
+write to the string.
+
+This issue was reported by 'zachlanley@gmail.com', and a patch was
+provided, the commit here is similar to that patch but differs in a few
+ares; only local VM is subject to save and restore so we don't need to
+consider global VM as the original commit did. The original commit did
+not check the return from s_proc_data_valid() I've chosen to do that and
+to raise an ioerror if the string is restored away, to match the PLRM.
+
+Also added some required header files and update the makefile to apply
+the new dependencies.
+
+Finally the supplied patch had a chunk of code change which was not
+relevant to this commit and was therefore not used.
+---
+ psi/ifilter.h | 4 ++-
+ psi/int.mak | 2 +-
+ psi/zfproc.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++-
+ 3 files changed, 72 insertions(+), 3 deletions(-)
+
+diff --git a/psi/ifilter.h b/psi/ifilter.h
+index 645a118d8..444bcc76f 100644
+--- a/psi/ifilter.h
++++ b/psi/ifilter.h
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 2001-2023 Artifex Software, Inc.
++/* Copyright (C) 2001-2026 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+@@ -80,6 +80,8 @@ typedef struct stream_proc_state_s {
+ uint index; /* current index within data */
+ ref proc;
+ ref data;
++ gs_ref_memory_t *data_memory; /* memory allocator 'data' belongs to, */
++ ulong data_save_id; /* innermost save id when 'data' was stored */
+ } stream_proc_state;
+
+ #define private_st_stream_proc_state() /* in zfproc.c */\
+diff --git a/psi/int.mak b/psi/int.mak
+index 43535bd6e..325c6b852 100644
+--- a/psi/int.mak
++++ b/psi/int.mak
+@@ -363,7 +363,7 @@ $(PSOBJ)zfilter.$(OBJ) : $(PSSRC)zfilter.c $(OP) $(memory__h)\
+ $(PSOBJ)zfproc.$(OBJ) : $(PSSRC)zfproc.c $(GH) $(memory__h) $(stat__h)\
+ $(oper_h)\
+ $(estack_h) $(files_h) $(gsstruct_h) $(ialloc_h) $(ifilter_h) $(istruct_h)\
+- $(store_h) $(stream_h) $(strimpl_h)\
++ $(store_h) $(stream_h) $(strimpl_h) $(isave_h) $(isstate_h)\
+ $(INT_MAK) $(MAKEDIRS)
+ $(PSCC) $(PSO_)zfproc.$(OBJ) $(C_) $(PSSRC)zfproc.c
+
+diff --git a/psi/zfproc.c b/psi/zfproc.c
+index 259c1aa7e..d95ec9ac4 100644
+--- a/psi/zfproc.c
++++ b/psi/zfproc.c
+@@ -29,6 +29,8 @@
+ #include "files.h"
+ #include "store.h"
+
++#include "isave.h"
++#include "isstate.h"
+ /* ---------------- Generic ---------------- */
+
+ /* GC procedures */
+@@ -81,12 +83,67 @@ s_proc_init(ref * sop, stream ** psstrm, uint mode,
+ state->eof = 0;
+ state->proc = *sop;
+ make_empty_string(&state->data, a_all);
++ state->data_memory = NULL;
++ state->data_save_id = 0;
+ state->index = 0;
+ sstrm->state = (stream_state *) state;
+ *psstrm = sstrm;
+ return 0;
+ }
+
++/*
++ * Note where the data string just stored in ss->data was allocated, and
++ * which save was innermost at that time (if the space the string was created
++ * in was local VM). The procedure may hand us a string allocated after an
++ * enclosing 'save' while the stream state itself predates that save;
++ * if that save is restored, the string is freed but the stream survives,
++ * so we must be able to detect this before using the string again.
++ * The PLRM is explicit that PostScript program should not do this, and the
++ * result is 'unpredictable'.
++ */
++static void
++s_proc_record_data(i_ctx_t *i_ctx_p, stream_proc_state *ss, const ref *pdata)
++{
++ int space_index = r_space_index(pdata);
++ gs_ref_memory_t *mem;
++
++ ss->data_memory = NULL;
++ ss->data_save_id = 0;
++ if (space_index != i_vm_local)
++ return; /* global, foreign or system VM: not restorable */
++ mem = idmemory->spaces_indexed[space_index];
++ if (mem == NULL || mem->saved == NULL)
++ return; /* no save active: string cannot be restored away */
++ ss->data_memory = mem;
++ /* Save ids are unique and never reused; 0 means 'invisible' save. */
++ ss->data_save_id = (mem->saved->id != 0 ? mem->saved->id : (ulong)-1);
++}
++
++/*
++ * Check that the string in ss->data has not been freed by a restore,
++ * i.e. that the save that was innermost when it was stored is still
++ * active. If it is not, the string may no longer exist: replace the
++ * dangling reference with an empty string so it cannot be used.
++ * Returns true if ss->data is safe to use.
++ */
++static bool
++s_proc_data_valid(stream_proc_state *ss)
++{
++ const alloc_save_t *save;
++
++ if (ss->data_memory == NULL)
++ return true;
++ for (save = ss->data_memory->saved; save != NULL;
++ save = save->state.saved)
++ if (save->id == ss->data_save_id)
++ return true;
++ make_empty_string(&ss->data, a_all);
++ ss->index = 0;
++ ss->data_memory = NULL;
++ ss->data_save_id = 0;
++ return false;
++}
++
+ /* Handle an interrupt during a stream operation. */
+ /* This is logically unrelated to procedure streams, */
+ /* but it is also associated with the interpreter stream machinery. */
+@@ -187,7 +244,11 @@ s_proc_read_process(stream_state * st, stream_cursor_read * ignore_pr,
+ /* Move data from the string returned by the procedure */
+ /* into the stream buffer, or ask for a callback. */
+ stream_proc_state *const ss = (stream_proc_state *) st;
+- uint count = r_size(&ss->data) - ss->index;
++ uint count;
++
++ if (!s_proc_data_valid(ss))
++ return_error(gs_error_ioerror);
++ count = r_size(&ss->data) - ss->index;
+
+ if (count > 0) {
+ uint wcount = pw->limit - pw->ptr;
+@@ -263,6 +324,7 @@ s_proc_read_continue(i_ctx_t *i_ctx_p)
+ }
+ ss = (stream_proc_state *) ps->state;
+ ss->data = *opbuf;
++ s_proc_record_data(i_ctx_p, ss, opbuf);
+ ss->index = 0;
+ if (r_size(opbuf) == 0)
+ ss->eof = true;
+@@ -306,6 +368,8 @@ s_proc_write_process(stream_state * st, stream_cursor_read * pr,
+ stream_proc_state *const ss = (stream_proc_state *) st;
+ uint rcount = pr->limit - pr->ptr;
+
++ if (!s_proc_data_valid(ss))
++ return_error(gs_error_ioerror);
+ /* if 'last' return CALLC even when rcount == 0. ss->eof terminates */
+ if (rcount > 0 || (last && !ss->eof)) {
+ uint wcount = r_size(&ss->data) - ss->index;
+@@ -357,6 +421,8 @@ s_handle_write_exception(i_ctx_t *i_ctx_p, int status, const ref * fop,
+ for (ps = fptr(fop); ps->strm != 0;)
+ ps = ps->strm;
+ psst = (stream_proc_state *) ps->state;
++ if (!s_proc_data_valid(psst))
++ return_error(gs_error_ioerror);
+ {
+ int npush = nstate + 6;
+
+@@ -406,6 +472,7 @@ s_proc_write_continue(i_ctx_t *i_ctx_p)
+ }
+ ss = (stream_proc_state *) ps->state;
+ ss->data = *opbuf;
++ s_proc_record_data(i_ctx_p, ss, opbuf);
+ ss->index = 0;
+ pop(2);
+ return 0;
diff --git a/0001-graphics-library-Shadings-with-arrays-of-Functions-v.patch b/0001-graphics-library-Shadings-with-arrays-of-Functions-v.patch
new file mode 100644
index 0000000..b8d4d55
--- /dev/null
+++ b/0001-graphics-library-Shadings-with-arrays-of-Functions-v.patch
@@ -0,0 +1,66 @@
+From 79a4f05f48f2f4149bab0cd9e8b48836a832a9fd Mon Sep 17 00:00:00 2001
+From: Ken Sharp <Ken.Sharp@artifex.com>
+Date: Thu, 25 Jun 2026 13:51:51 +0100
+Subject: [PATCH] graphics library - Shadings with arrays of Functions,
+ validate 1-out
+
+Bug #709462 "Ghostscript: Heap buffer overflow (OOB write) via array-wrapped shading `/Function` (`base/gsfunc3.c`)"
+
+The basic problem is that the shading checks for arrays of functions are
+only checking to see if the number of functions in the array matches
+the number of colour space ocmponents. If the functions are not 1-in,
+1 out (or for type 1 shadings only; 2-in, 1 out) then the evaluation
+of the function could overrun the output buffer.
+
+We don't actually need to check the total number of output components,
+because the only valid values are 'n' 1-in, 1-out (or 2-in, 1 out)
+functions; the 1-in (or 2-in) n-out case is always a single function.
+
+We already check (in effect) that the number of functions in the array
+matches the colour space so all we need to add is a check that the
+number of input components matches (1 or 2) and the number of output
+components is always 1, for each function.
+
+This bug was reported by 'Rick de Jager <rick@v12.sh>'
+---
+ base/gsshade.c | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/base/gsshade.c b/base/gsshade.c
+index b4379f96b..436dc627d 100644
+--- a/base/gsshade.c
++++ b/base/gsshade.c
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 2001-2023 Artifex Software, Inc.
++/* Copyright (C) 2001-2026 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+@@ -31,6 +31,7 @@
+ #include "gxshade4.h"
+ #include "gzpath.h"
+ #include "gzcpath.h"
++#include "gsfunc3.h"
+
+ /* ================ Initialize shadings ================ */
+
+@@ -78,6 +79,19 @@ check_CBFD(const gs_shading_params_t * params,
+ if (function != 0) {
+ if (function->params.m != m || function->params.n != ncomp)
+ return_error(gs_error_rangecheck);
++ if (function->head.type == function_type_ArrayedOutput) {
++ /* If the Function member is an array it must contain either n 1-in, 1-out function dictionaries
++ * or (type 1, function-based shadings) n 2-in, 1-out function dictionaries. Either way all the
++ * functions have to have a single output, so we need to check that.
++ */
++ int i = 0;
++ gs_function_AdOt_params_t *a_params = (gs_function_AdOt_params_t *)&function->params;
++
++ for (i = 0; i < a_params->n;i++) {
++ if (a_params->Functions[i]->params.m != m || a_params->Functions[i]->params.n != 1)
++ return_error(gs_error_rangecheck);
++ }
++ }
+ /*
+ * The Adobe documentation says that the function's domain must
+ * be a superset of the domain defined in the shading dictionary.
diff --git a/ghostscript.spec b/ghostscript.spec
index 0ed1c37..f2052e8 100644
--- a/ghostscript.spec
+++ b/ghostscript.spec
@@ -122,6 +122,9 @@ Patch001: 0001-Reinstate-pdf2dsc.patch
# https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/commit/?id=3c0be6e4fcffa6
Patch002: 0001-Fix-32-bit-build.patch
Patch003: 0001-OpenJPEG-Fix-overreading-bytes-in-some-conditions.patch
+Patch004: 0001-PostScript-interpreter-don-t-permit-local-inside-glo.patch
+Patch005: 0001-graphics-library-Shadings-with-arrays-of-Functions-v.patch
+Patch006: 0001-PostScript-interpreter-procedural-data-sink-filter-d.patch
# Downstream patches -- these should be always included when doing rebase:
@@ -491,6 +494,8 @@ done
%changelog
* Fri Oct 16 2026 Zdenek Dohnal <zdohnal@redhat.com> - 10.06.0-3
- CVE-2026-39919 ghostscript: Heap buffer overflow in JPEG 2000 JPXDecode output adapter
+- CVE-2026-101258 ghostscript: ghostscript: -dSAFER sandbox bypass via Type 5 shading OOB write and procedure-stream use-after-free
+ bypass via Type 5 shading OOB write and procedure-stream use-after-free
* Fri Jan 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 10.06.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-16 13:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 13:49 [rpms/ghostscript] f44: CVE-2026-101258 (fedora#2546645) RHEL Packaging Agent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox