Your message dated Sat, 08 Mar 2025 00:10:15 +0000
with message-id <e1tqhlf-003mij...@fasolo.debian.org>
and subject line Bug#1098892: fixed in mrgingham 1.25-1
has caused the Debian Bug report #1098892,
regarding python3-mrgingham: autopkgtest failure with glibc 2.41 due to use of 
executable stack
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
1098892: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1098892
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Package: python3-mrgingham
Version: 1.24-2
Severity: important
Tags: upstream patch
X-Debbugs-Cc: debian-gl...@lists.debian.org
User: debian-gl...@lists.debian.org
Usertags: glibc2.41 dlopen-executable-stack

Dear maintainer,

Starting with glibc 2.41, the dlopen and dlmopen functions no longer make
the stack executable if a shared library requires it and instead just
fail. This change aims to improve security, as the previous behaviour
was used as a vector for RCE (CVE-2023-38408).

Unfortunately the python3-mrgingham provides a Python module with an
executable stack, and Python uses dlopen() to open module. With the
glibc change, the mrgingham module can't be loaded anymore, causing the
testsuite to fail during build or autopkgtest:

| 58s autopkgtest [18:26:56]: test autodep8-python3: [-----------------------
| 58s Testing with python3.12:
| 58s Traceback (most recent call last):
| 58s   File "<string>", line 1, in <module>
| 58s ImportError: 
/usr/lib/python3/dist-packages/mrgingham.cpython-312-x86_64-linux-gnu.so: 
cannot enable executable stack as shared object requires: Invalid argument
| 58s autopkgtest [18:26:56]: test autodep8-python3: -----------------------]

For a full log, see:
https://ci.debian.net/packages/m/mrgingham/unstable/amd64/58113030/

I have tracked the issue to the use of nested functions require
trampoline in the python wrapper code (the library is not affected and
does not need an executable stack). While GCC provides a
'-ftrampoline-impl=heap' option, it does not work on all architectures.
Fortunately the API is defined by the C++ bridge and specific to the
wrapper. Therefore it can be changed to pass the result variable as an
opaque pointer (opaque to keep the bridge outside of the Python world)
instead of relying on a trampoline for it.

You will find attached a proposed patch, I guess other alternatives are
possible to reach the same result.

Regards
Aurelien
--- mrgingham-1.24.orig/mrgingham_pywrap.c
+++ mrgingham-1.24/mrgingham_pywrap.c
@@ -160,14 +160,15 @@ static PyObject* find_points(PyObject* N
         goto done;
     }
 
-    bool add_points(int* xy, int N, double scale)
+    bool add_points(int* xy, int N, double scale, void *opaque)
     {
-        result = PyArray_SimpleNew(2,
-                                   ((npy_intp[]){N, 2}),
-                                   NPY_DOUBLE);
-        if(result == NULL) return false;
+        PyObject** resultp = (PyObject**) opaque;
+        *resultp = PyArray_SimpleNew(2,
+                                     ((npy_intp[]){N, 2}),
+                                     NPY_DOUBLE);
+        if(*resultp == NULL) return false;
 
-        double* out_data = (double*)PyArray_BYTES((PyArrayObject*)result);
+        double* out_data = (double*)PyArray_BYTES((PyArrayObject*)*resultp);
         for(int i=0; i<2*N; i++)
             out_data[i] = scale * (double)xy[i];
         return true;
@@ -179,7 +180,7 @@ static PyObject* find_points(PyObject* N
 
                                                     image_pyramid_level,
                                                     blobs,
-                                                    &add_points) )
+                                                    &add_points, &result) )
     {
         if(result == NULL)
         {
@@ -260,14 +261,15 @@ static PyObject* find_board(PyObject* NP
         goto done;
     }
 
-    bool add_points(double* xy, int N)
+    bool add_points(double* xy, int N, void *opaque)
     {
-        result = PyArray_SimpleNew(2,
-                                   ((npy_intp[]){N, 2}),
-                                   NPY_DOUBLE);
-        if(result == NULL) return false;
+        PyObject **resultp = (PyObject **)opaque;
+        *resultp = PyArray_SimpleNew(2,
+                                    ((npy_intp[]){N, 2}),
+                                    NPY_DOUBLE);
+        if(*resultp == NULL) return false;
 
-        double* out_data = (double*)PyArray_BYTES((PyArrayObject*)result);
+        double* out_data = (double*)PyArray_BYTES((PyArrayObject*)*resultp);
         memcpy(out_data, xy, 2*N*sizeof(double));
         return true;
     }
@@ -279,7 +281,7 @@ static PyObject* find_board(PyObject* NP
                                             gridn,
                                             image_pyramid_level,
                                             blobs,
-                                            &add_points) )
+                                            &add_points, &result) )
     {
         // This is allowed to fail. We possibly found no chessboard. This is
         // sloppy since it ignore other potential errors, but there shouldn't 
be
--- mrgingham-1.24.orig/mrgingham_pywrap_cplusplus_bridge.cc
+++ mrgingham-1.24/mrgingham_pywrap_cplusplus_bridge.cc
@@ -37,7 +37,8 @@ bool find_chessboard_corners_from_image_
                                                 int image_pyramid_level,
                                                 bool doblobs,
 
-                                                bool (*add_points)(int* xy, 
int N, double scale) )
+                                                bool (*add_points)(int* xy, 
int N, double scale, void *opaque),
+                                                void *opaque )
 {
     cv::Mat cvimage(Nrows, Ncols, CV_8UC1,
                     imagebuffer, stride);
@@ -62,7 +63,7 @@ bool find_chessboard_corners_from_image_
                    "add_points() assumes PointInt is simply 2 ints");
     return
         (*add_points)( &out_points[0].x, (int)out_points.size(),
-                       1. / (double)FIND_GRID_SCALE);
+                       1. / (double)FIND_GRID_SCALE, opaque);
 }
 
 extern "C"
@@ -79,7 +80,8 @@ bool find_chessboard_from_image_array_C(
                                         int image_pyramid_level,
                                         bool doblobs,
 
-                                        bool (*add_points)(double* xy, int N) )
+                                        bool (*add_points)(double* xy, int N, 
void *opaque),
+                                        void *opaque )
 {
     cv::Mat cvimage(Nrows, Ncols, CV_8UC1,
                     imagebuffer, stride);
@@ -111,5 +113,5 @@ bool find_chessboard_from_image_array_C(
     static_assert( sizeof(mrgingham::PointDouble) == 2*sizeof(double),
                    "add_points() assumes PointDouble is simply 2 doubles");
     return
-        (*add_points)( &out_points[0].x, (int)out_points.size() );
+        (*add_points)( &out_points[0].x, (int)out_points.size(), opaque );
 }
--- mrgingham-1.24.orig/mrgingham_pywrap_cplusplus_bridge.h
+++ mrgingham-1.24/mrgingham_pywrap_cplusplus_bridge.h
@@ -18,7 +18,8 @@ bool find_chessboard_corners_from_image_
                                                 int image_pyramid_level,
                                                 bool doblobs,
 
-                                                bool (*add_points)(int* xy, 
int N, double scale) );
+                                                bool (*add_points)(int* xy, 
int N, double scale, void *opaque),
+                                                void *opaque );
 
 bool find_chessboard_from_image_array_C( // in
                                         int Nrows, int Ncols,
@@ -33,7 +34,9 @@ bool find_chessboard_from_image_array_C(
                                         int image_pyramid_level,
                                         bool doblobs,
 
-                                        bool (*add_points)(double* xy, int N) 
);
+                                        bool (*add_points)(double* xy, int N, 
void *opaque),
+                                        void *opaque );
+
 #ifdef __cplusplus
 }
 #endif

--- End Message ---
--- Begin Message ---
Source: mrgingham
Source-Version: 1.25-1
Done: Dima Kogan <dko...@debian.org>

We believe that the bug you reported is fixed in the latest version of
mrgingham, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1098...@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Dima Kogan <dko...@debian.org> (supplier of updated mrgingham package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmas...@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Fri, 07 Mar 2025 15:38:26 -0800
Source: mrgingham
Architecture: source
Version: 1.25-1
Distribution: unstable
Urgency: medium
Maintainer: Debian Science Maintainers 
<debian-science-maintain...@lists.alioth.debian.org>
Changed-By: Dima Kogan <dko...@debian.org>
Closes: 1098892
Changes:
 mrgingham (1.25-1) unstable; urgency=medium
 .
   * New upstream release (Closes: #1098892)
Checksums-Sha1:
 36689b3953ddf6ca452a16792920c26ec66d25fd 2338 mrgingham_1.25-1.dsc
 0163833e33f9a0be78264b8aff754ec2515fdfb2 58426 mrgingham_1.25.orig.tar.gz
 e06d067da97446c4fa83c2efd9769bf2924c24c9 3880 mrgingham_1.25-1.debian.tar.xz
 c451a458cd0384d8ba0d0986ba64a636306fbdd0 21114 
mrgingham_1.25-1_source.buildinfo
Checksums-Sha256:
 2d1946e9610c8d5485466a982d5c4c17f91ebc945f8fecfbe3a50c7987fdfeb6 2338 
mrgingham_1.25-1.dsc
 1a73a72f59bcb3e9759600e92383698518727accaaf18d471e8310dadc3a3be9 58426 
mrgingham_1.25.orig.tar.gz
 0a3fea4384b16bd96ad08b1aa5887cf3e9d22dee6e942f38148e492d6c04c6e1 3880 
mrgingham_1.25-1.debian.tar.xz
 67160adc5b03041f1bd2ee183bf5fd3977762105825ac33848bc449451927792 21114 
mrgingham_1.25-1_source.buildinfo
Files:
 194722271f9b1c8090a9e2302b64fe38 2338 devel optional mrgingham_1.25-1.dsc
 765a76304c55abb099019010672535b4 58426 devel optional 
mrgingham_1.25.orig.tar.gz
 f0e292c98b65e16105050de5e7202f24 3880 devel optional 
mrgingham_1.25-1.debian.tar.xz
 3c1be077496502672b71648fb2530a51 21114 devel optional 
mrgingham_1.25-1_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJGBAEBCgAwFiEEteL6GQ/fmv4hiInPrMfCzzCUEYgFAmfLg7MSHGRrb2dhbkBk
ZWJpYW4ub3JnAAoJEKzHws8wlBGI+pkP/iAwckPUanJF/aVa1F4ggl5J2q3xyboY
Yg/9vlp9FdlK7RVfK+SKbZ27sPTk9izaL6gtHqLGUnHzzvdvc0PnKc2O8VlNUrvH
cuxHznUoE1Cuo9l1RZQ8ZKCXoOP58VmzVoiruIXfPP3zCTpQ9czD/hnMY2DPPHM5
Qbzx9ZTTW+OuC5DlTExom3f5Wgxw/VWRiE3cvEUMqXCFrFTzNpm17ffpBxndRgtc
ZX8hscQD8vpUoG4us14ip7oIiQZEMsY7+hZg7w1tfXAw0dNWtoWNhv6L+AMOPnuL
szmsQlku95ScwArs12v0LxSgh68kBDGp/0J2mTUyoHrfz1miOdy37Gm5aDQwni3o
tmMhl3VdIfcI/g/+bhdAN9Bw4klXZc+7ETMMy9Ri4fFSCRSc6s/FhSN2OuCi7nFs
s5CgkqQVbyuolJpW6jsTIBgCWY433Yf/q25fjhdN1ZkO41lr6hwDKywrLvig5EG5
5506a18E0JNck290mM+3tTCfjuHTbPU70O51/fzozXWpiUKScyH/7Q7ctvoWfXnK
buyeA4Tb+jEbGNAkSFdS/nSWBNf2PZJNqxA4ZnUHtxVku65HsScqD290rfcU/ofM
xkgHY8WONpm0YBdEwMP+DkIGBKuBcOqnD9k/KQeNW/rMLmN4drZ2gJvUMakZFX+j
p+/4KK0bdbZM
=Er0i
-----END PGP SIGNATURE-----

Attachment: pgpDExfpEyrAd.pgp
Description: PGP signature


--- End Message ---

Reply via email to