Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 115568 - TEXTREL in media-video/ffmpeg-0.4.9_p20050226-r5
Summary: TEXTREL in media-video/ffmpeg-0.4.9_p20050226-r5
Status: RESOLVED DUPLICATE of bug 179872
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
: 166189 245107 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-12-14 11:08 UTC by Lares Moreau
Modified: 2008-12-10 23:21 UTC (History)
9 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
latest pic patch (ffmpeg-pic-20051204.patch,40.02 KB, patch)
2005-12-14 13:00 UTC, Luca Barbato
Details | Diff
Text relocations log (scanelf-textrel.log,63.10 KB, text/plain)
2006-12-23 09:41 UTC, Abraham Marin Perez
Details
forward port of the textrel fixing patch (ffmpeg-0.4.9_p20061016-pic.patch,55.22 KB, patch)
2007-01-28 01:34 UTC, PaX Team
Details | Diff
forward port to ffmpeg-0.4.9_p20070129 (ffmpeg-0.4.9_p20070129-pic.patch,55.22 KB, patch)
2007-01-29 23:35 UTC, PaX Team
Details | Diff
forward port to ffmpeg-0.4.9_p20070129 (ffmpeg-0.4.9_p20070129-pic.patch,57.89 KB, patch)
2007-01-30 01:49 UTC, PaX Team
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lares Moreau 2005-12-14 11:08:15 UTC
After some instructions form solar:

media-video/ffmpeg-0.4.9_p20050226-r5 (/usr/lib/libavcodec-0.4.9-pre1.so)
media-video/ffmpeg-0.4.9_p20050226-r5 (/usr/lib/libpostproc.so.0.0.1)
Comment 1 solar (RETIRED) gentoo-dev 2005-12-14 12:00:18 UTC
We have been testing a patch offlist. I'll let lu_zero attach it here for
further testing.
Comment 2 Luca Barbato gentoo-dev 2005-12-14 13:00:00 UTC
Created attachment 74758 [details, diff]
latest pic patch

It should be fixed for working on gcc-2.95, please benchmark it
Comment 3 Michael Cramer 2005-12-20 23:55:44 UTC
got the same here with version media-video/ffmpeg-0.4.9_p20051216

QA Notice: the following files contain runtime text relocations
 Text relocations force the dynamic linker to perform extra
 work at startup, waste system resources, and may pose a security
 risk.  On some architectures, the code may not even function
 properly, if at all.
TEXTREL usr/lib/libpostproc.so.51.0.0
TEXTREL usr/lib/libavcodec.so.51.0.0
Comment 4 Alexandru Toma 2006-01-05 07:06:30 UTC
I got the same for media-video/ffmpeg-0.4.9_p20051216 on regular (not hardened) system
Comment 5 Sascha G. 2006-07-08 19:18:59 UTC
Regarding ffmpeg-0.4.9_p20060530 on x86 (which is, unfortunately, not keyworded, but works very well nonetheless), only some TEXTRELs are left:

 $ scanelf -T /usr/lib/libavcodec.so
 TYPE   TEXTRELS FILE 
  libavcodec.so: (memory/fake?) [0x205AF1] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x205AF8] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x205AFF] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x205B06] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x205BCA] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x205C82] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x205DAA] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x205EBD] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x20601D] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x206103] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x2061D1] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x2062AA] in a52_crc16_block [0x204E2C]
  libavcodec.so: (memory/fake?) [0x206397] in a52_crc16_block [0x204E2C]

If someone has a patch for this, I am willing to play the guinea pig.
I have been trying to write one myself, but boy, is this over my head. :-)
Comment 6 PaX Team 2006-07-09 03:11:56 UTC
(In reply to comment #5)
> Regarding ffmpeg-0.4.9_p20060530 on x86 (which is, unfortunately, not
> keyworded, but works very well nonetheless), only some TEXTRELs are left:

no, it doesn't work:

i686-pc-linux-gnu-gcc -Wall -Wno-switch -O2 -march=pentium4 -fomit-frame-pointer -DHAVE_AV_CONFIG_H -I.. -I/var/tmp/portage/ffmpeg-0.4.9_p20060530/work/ffmpeg-0.4.9-p20060530-shared/libavutil -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE   -fPIC -DPIC -c -o i386/idct_mmx_xvid.o i386/idct_mmx_xvid.c
i386/snowdsp_mmx.c: In function `ff_snow_vertical_compose97i_sse2':
i386/snowdsp_mmx.c:461: error: PIC register `%ebx' clobbered in `asm'
i386/snowdsp_mmx.c: In function `ff_snow_vertical_compose97i_mmx':
i386/snowdsp_mmx.c:568: error: PIC register `%ebx' clobbered in `asm'
i386/snowdsp_mmx.c: In function `inner_add_yblock_bw_8_obmc_16_mmx':
i386/snowdsp_mmx.c:869: error: PIC register `%ebx' clobbered in `asm'
make[1]: *** [i386/snowdsp_mmx.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/var/tmp/portage/ffmpeg-0.4.9_p20060530/work/ffmpeg-0.4.9-p20060530-shared/libavcodec'
make: *** [lib] Error 2

the asm block in question hardcodes register use and will need a proper patch before it can be PIC.
Comment 7 Sascha G. 2006-07-09 04:46:27 UTC
(In reply to comment #6)

> the asm block in question hardcodes register use and will need a proper patch
> before it can be PIC.

Oh, I see. That's why it is not keyworded. :-)
As I wrote, it does work over here; I just compiled it again and saw in the log that mmx is disabled although the mmx USE flag is set... I find this a bit disturbing, but this certainly explains the difference.
And I wondered where all the other TEXTRELS were gone.
Comment 8 Jordan Callicoat 2006-08-02 14:44:51 UTC
Yes, needs a patch for PIC:

http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-April/010297.html

So for x86 it would probably be a good idea _not_ to do this in the ebuild:

  # Make it use pic always since we don't need textrels
  sed -i -e "s:LIBOBJFLAGS=\"\":LIBOBJFLAGS=\'\$\(PIC\)\':" configure
Comment 9 Patrick Lauer gentoo-dev 2006-08-13 03:54:27 UTC
still exists in media-video/ffmpeg-0.4.9_p20060302
Comment 10 Matthias Schwarzott gentoo-dev 2006-12-23 04:51:55 UTC
and what about media-video/ffmpeg-0.4.9_p20061016 ?
Comment 11 Abraham Marin Perez 2006-12-23 09:40:37 UTC
(In reply to comment #10)
> and what about media-video/ffmpeg-0.4.9_p20061016 ?
> 

Still troublesome, at least in my system:

TEXTREL usr/lib/libavcodec.so.51.20.0
TEXTREL usr/lib/libpostproc.so.51.20.0


!!! ERROR: media-video/ffmpeg-0.4.9_p20061016 failed.

######################
emerge --info

Portage 2.1.1-r2 (default-linux/x86/2006.0, gcc-3.4.6, glibc-2.3.5-r2, 2.6.17-gentoo-r4 i686)
=================================================================
System uname: 2.6.17-gentoo-r4 i686 AMD Athlon(tm) XP 1700+
Gentoo Base System version 1.12.6
Last Sync: Sat, 23 Dec 2006 16:20:01 +0000
distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.3 [enabled]
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.3.7, 2.0.30
dev-lang/python:     2.3.5-r2, 2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.3
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r4
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.8.1-r1, 2.6.17-r1
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=athlon-xp"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/share/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/splash /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=athlon-xp"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig ccache distlocks metadata-transfer sandbox sfperms strict stricter test"
GENTOO_MIRRORS="http://ftp.caliu.info/pub/gentoo/ http://mirror.ovh.net/gentoo-distfiles/"
LANG="es_ES.UTF-8@euro"
LC_ALL="es_ES.UTF-8@euro"
LINGUAS="es en"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="3dnow X a52 acpi alsa alsa_cards_emu10k1 alsa_pcm_plugins_adpcm alsa_pcm_plugins_alaw alsa_pcm_plugins_asym alsa_pcm_plugins_copy alsa_pcm_plugins_dmix alsa_pcm_plugins_dshare alsa_pcm_plugins_dsnoop alsa_pcm_plugins_empty alsa_pcm_plugins_extplug alsa_pcm_plugins_file alsa_pcm_plugins_hooks alsa_pcm_plugins_iec958 alsa_pcm_plugins_ioplug alsa_pcm_plugins_ladspa alsa_pcm_plugins_lfloat alsa_pcm_plugins_linear alsa_pcm_plugins_meter alsa_pcm_plugins_mulaw alsa_pcm_plugins_multi alsa_pcm_plugins_null alsa_pcm_plugins_plug alsa_pcm_plugins_rate alsa_pcm_plugins_route alsa_pcm_plugins_share alsa_pcm_plugins_shm alsa_pcm_plugins_softvol apache2 asf audiofile avi bash-completion bidi bitmap-fonts bzip2 bzlib canna cdr cjk cli cracklib crypt cups dbus dga directfb divx4linux dlloader doc dri dvb dvd dvdr dvdread eds elibc_glibc emboss encode esd evo exif fbcon fftw firefox flac foomaticdb freewnn ftp gb gcj gd gdbm gif glut gmp gnome gpm gstreamer gtk gtk2 gtkhtml hal iconv imlib input_devices_evdev input_devices_keyboard input_devices_mouse iodbc isdnlog java jikes jpeg kde kernel_linux libg++ libwww linguas_en linguas_es mad memlimit mikmod mime mmx motif mozilla mp3 mpeg msn nas nls nptl nptlonly nsplugin nvidia odbc offensive ogg oggvorbis openal opengl pam pcre pdflib perl png pnp posix ppds pppd qt3 qt4 quicktime readline reflection sdl session sharedmem simplexml spell spl ssl svg svga sysvipc szip tcltk tcpd tetex theora threads tiff truetype truetype-fonts type1-fonts udev unicode usb userland_GNU video_cards_nvidia videos vorbis win32codecs wmf x86 xine xml xorg xprint xv xvid zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LDFLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 12 Abraham Marin Perez 2006-12-23 09:41:36 UTC
Created attachment 104643 [details]
Text relocations log

Attached as requested by error message.
Comment 13 PaX Team 2007-01-28 01:34:58 UTC
Created attachment 108330 [details, diff]
forward port of the textrel fixing patch

besides fixing the textrels i also tried to make the asm stuff to compile with the frame pointer, so its omission can now be removed from the ebuild. as usual, this needs testing, not only for crashes but also artifacts ;-).
Comment 14 PaX Team 2007-01-29 23:35:12 UTC
Created attachment 108552 [details, diff]
forward port to ffmpeg-0.4.9_p20070129

no changes, even the previous ones applies with just some offsets.
Comment 15 PaX Team 2007-01-30 01:49:36 UTC
Created attachment 108563 [details, diff]
forward port to ffmpeg-0.4.9_p20070129

they managed to sneak in a few more textrels, fixed now.
Comment 16 Luca Barbato gentoo-dev 2007-01-30 16:39:27 UTC
Rejected by upstream.

Michael Niedermayer wrote:
> 
>> diff -urp ffmpeg-old/libavcodec/i386/dsputil_mmx.c ffmpeg/libavcodec/i386/dsputil_mmx.c
>> --- ffmpeg-old/libavcodec/i386/dsputil_mmx.c	2007-01-30 01:09:30.000000000 +0100
>> +++ ffmpeg/libavcodec/i386/dsputil_mmx.c	2007-01-30 01:11:41.000000000 +0100
>> @@ -657,15 +657,14 @@ static inline void transpose4x4(uint8_t 
>>          "punpckhwd %%mm2, %%mm1         \n\t"
>>          "movd  %%mm0, %0                \n\t"
>>          "punpckhdq %%mm0, %%mm0         \n\t"
>> -        "movd  %%mm0, %1                \n\t"
>> -        "movd  %%mm1, %2                \n\t"
>> +        "movd  %%mm0, (%0,%1)           \n\t"
>> +        "movd  %%mm1, (%0,%1,2)         \n\t"
>>          "punpckhdq %%mm1, %%mm1         \n\t"
>> -        "movd  %%mm1, %3                \n\t"
>> +        "lea (%1,%1,2), %1              \n\t"
>> +        "movd  %%mm1, (%0,%1)           \n\t"
>>  
>> -        : "=m" (*(uint32_t*)(dst + 0*dst_stride)),
>> -          "=m" (*(uint32_t*)(dst + 1*dst_stride)),
>> -          "=m" (*(uint32_t*)(dst + 2*dst_stride)),
>> -          "=m" (*(uint32_t*)(dst + 3*dst_stride))
>> +        : "=r" (*(uint32_t*)(dst)), "+r" (dst_stride)
>> +        :: "memory"
>>      );
> 
> this code is wrong , it can be used to write arbitrary data to an arbitrary
> address, its ironic that this is written by someone with the name "pax team"
> to be more precisse %%mm0 contains some pixels which have been decoded, they
> can be set arbitrarily by using PCM macroblocks
> %%mm0 is then written into %0 (a register after the patch) which is then later
> used as base for writing 3 more decoded 32bit values
> 

> 
> checking here means
> 1. does it apply?
> 2. do the regression tests pass?
> 3. does the changed code still work (h.264 decoding and other cases not 
>    covered by the regression tests) also ensure that the changed code
>    really is executed during the test
> 4. changes to asm should be tested with at least gcc 2.95, 3.4, 4.something
> 5. non cosmatic changes to asm MUST be benchmarked or they are almost
>    certainly going to be rejected (see START/STOP_TIMER)
Comment 17 Jakub Moc (RETIRED) gentoo-dev 2007-02-10 10:57:20 UTC
*** Bug 166189 has been marked as a duplicate of this bug. ***
Comment 18 Jeroen Roovers (RETIRED) gentoo-dev 2008-11-03 03:40:59 UTC
*** Bug 245107 has been marked as a duplicate of this bug. ***
Comment 19 Samuli Suominen (RETIRED) gentoo-dev 2008-12-10 23:21:46 UTC

*** This bug has been marked as a duplicate of bug 179872 ***