buglibffcall - foreign function call libraries - Bugs: bug #32466, segfault

 
 

bug #32466: segfault

Submitter:  Andrey Kutejko <andy128k>
Submitted:  Sun 13 Feb 2011 11:06:05 PM UTC
   
 
Category:  None Severity:  4 - Important
Item Group:  None Status:  Fix Released
Privacy:  Public Assigned to:  haible
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 11 Feb 2017 03:07:22 PM UTC, comment #6: 
Bruno Haible <haible>
Group administrator
Mon 02 Jan 2017 10:52:45 PM UTC, comment #5: 

Re Sam:

> packaging libffcall as a shared library is a mistake.


I disagree. There is a move to position-independent code in the industry (think of ASLR). And when security bugs need to be fixed, you don't want to recompile all packages that use the library. So, compiling libffcall as a shared library should be made possible.

Re Andrey:

> Some code from ld.so corrupts r10 register which is used to pass callback data.

Yup. It's the routine, in ld.so, which resolves the address of function.

I found your patch (0001-fix-callback-on-x86_64.patch) very inspiring. Sure, it is wrong because it does not respect the required alignment of %rsp. But what I like about it is the ability to insert arbitrary instructions at the beginning of the function __vacall_r.

Now fixed for x86_64 and other CPU types through http://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=commit;h=cb99e282fc978c77c4fb44d7965b331b89dd55ac

Bruno Haible <haible>
Group administrator
Mon 14 Feb 2011 03:56:39 AM UTC, comment #4: 

packaging libffcall as a shared library is a mistake.
see libffcall/README
I will leave it to Bruno to decide whether to accept the patch.

Sam Steingold <sds>
Group administrator
Mon 14 Feb 2011 12:16:49 AM UTC, comment #3: 

I use CVS snaphot 1.10+cvs20100619 (Debian Unstable).

There is no segfault when libcallback is linked as static library. But program crashes when libcallback is linked as shared library.

Some code from ld.so corrupts r10 register which is used to pass callback data.

Andrey Kutejko <andy128k>
Sun 13 Feb 2011 11:59:43 PM UTC, comment #2: 

wfm on Linux sysu76 2.6.32-28-generic #55-Ubuntu SMP Mon Jan 10 23:42:43 UTC 2011 x86_64 GNU/Linux
and cvs head of ffcall:
$ gcc  -I ~/src/top/include/ test_callback.c  ~/src/top/lib/libvacall.a  ~/src/top/lib/libtrampoline.a  ~/src/top/lib/libcallback.a -o test_callback.exe
$ ./test_callback.exe
data = 0xbebebe: 2 + 3 = 5
5
$

are you reporting a bug in the released version or in cvs head?

Sam Steingold <sds>
Group administrator
Sun 13 Feb 2011 11:12:00 PM UTC, comment #1: 

libcallback.so crashes on amd64.

I attach simple program which reproduces an error and a patch.

(file #22679, file #22680)

Andrey Kutejko <andy128k>
Sun 13 Feb 2011 11:06:05 PM UTC, original submission:  


Andrey Kutejko <andy128k>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #22679:  test_callback.c added by andy128k (457B - text/x-csrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by sds (Posted a comment)
  • -email is unavailable- added by andy128k (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-04 haible StatusFixed Fix Released
    2017-01-02 haible Severity3 - Normal 4 - Important
        StatusNone Fixed
        Open/ClosedOpen Closed
    2011-02-13 sds Assigned toNone haible
    2011-02-13 andy128k Attached File- Added test_callback.c, #22679
        Attached File- Added 0001-fix-callback-on-x86_64.patch, #22680

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code