First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 130889
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo Security <security@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Tavis Ormandy (RETIRED) <taviso@gentoo.org>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:
Flags: Requestee:
 
 
  ()

Filename Description Type Creator Created Size Actions
max_memory_to_use.jpg example image image/jpeg Tavis Ormandy (RETIRED) 2006-04-22 14:24 0000 738 bytes Details
jpeg-sysconf-maxmem.diff jpeg-sysconf-maxmem.diff patch Tavis Ormandy (RETIRED) 2006-04-23 01:26 0000 662 bytes Details | Diff
jpeg-sysconf-maxmem.diff sysconf maxmem patch patch Tavis Ormandy (RETIRED) 2006-04-23 02:56 0000 678 bytes Details | Diff
60_all_jpeg-maxmem-sysconf.patch Updated patch supporting FreeBSD and DragonFly and with fallback. patch Diego E. 'Flameeyes' Pettenò 2006-05-28 17:50 0000 1.28 KB Details | Diff
60_all_jpeg-maxmem-sysconf.patch Updated patch supporting *BSD and Darwin and with fallback. patch Diego E. 'Flameeyes' Pettenò 2006-05-31 12:01 0000 1.36 KB Details | Diff
patch Re-Updated patch supporting *BSD and Darwin and with fallback. patch Fabian Groffen 2006-05-31 12:39 0000 1.38 KB Details | Diff
60_all_jpeg-maxmem-sysconf.patch latest darwin/bsd/linux maxmem patch from SVN by Flameeyes patch Fabian Groffen 2006-05-31 12:53 0000 1.37 KB Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 130889 depends on: Show dependency tree
Bug 130889 blocks:

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2006-04-22 14:22 0000
we're distribute the jpeg library without a feature it calls `maxmem`, which is
used to restrict images from allocating ridiculous amounts of memory and
allowing developers to specify a reasonable limit for allocation.

The documentation all assumes this feature is enabled, and documents settings
suc as the JPEGMEM environment variable, max_mem_to_use jpeg option, the
-maxmemory argument to djpeg and so on. A user might reasonably expect these
setttings to prevent a malicious image from disrupting any image processing
routines that accept images from users, however they do nothing, potentially
resulting in a dos via memory exhaustion.

Suggest adding --enable-maxmem option to configure, which will solve this
problem.

------- Comment #1 From Tavis Ormandy (RETIRED) 2006-04-22 14:24:10 0000 -------
Created an attachment (id=85214) [edit]
example image

------- Comment #2 From Tavis Ormandy (RETIRED) 2006-04-22 14:36:19 0000 -------
graphics herd: please provide an updated ebuild, or comment if appropriate.

------- Comment #3 From SpanKY 2006-04-22 21:08:48 0000 -------
what exactly would you say a reasonable limit is ?

------- Comment #4 From Tavis Ormandy (RETIRED) 2006-04-23 01:05:11 0000 -------
How about we replace jpeg_mem_init() in jmemansi.c with a routine that that
uses sysconf() with _SC_PHYS_PAGES? 

example:

GLOBAL(long)
jpeg_mem_init (j_common_ptr cinfo)
{
    long phys_size;

    if ((phys_size = sysconf(_SC_PHYS_PAGES)) == -1)
        return DEFAULT_MAX_MEM; /* defined by libjpeg via --enable-maxmem=xx */
    if ((phys_size *= sysconf(_SC_PAGESIZE)) < 0)
        return DEFAULT_MAX_MEM;
    return phys_size;
}

and set DEFAULT_MAX_MEM to 64M or similar as a fallback? This would be a
reasonable default, but allow JPEGMEM and max_memory_to_use to be honoured by
users who want to prevent memory exhaustion.

------- Comment #5 From Tavis Ormandy (RETIRED) 2006-04-23 01:26:23 0000 -------
Created an attachment (id=85252) [edit]
jpeg-sysconf-maxmem.diff

suggested patch, tested with --enable-maxmem=64 (only used as a fallback)

------- Comment #6 From Tavis Ormandy (RETIRED) 2006-04-23 02:56:53 0000 -------
Created an attachment (id=85260) [edit]
sysconf maxmem patch

the comments in jmemansi.c say "If you can actually get the available space,
it's a good idea to subtract a slop factor of 5% or so.", so this patch does
that.

------- Comment #7 From Thierry Carrez (RETIRED) 2006-05-14 10:14:42 0000 -------
Misplaced

------- Comment #8 From Thierry Carrez (RETIRED) 2006-05-18 10:08:21 0000 -------
graphics team please patch

------- Comment #9 From Diego E. 'Flameeyes' Pettenò 2006-05-28 17:49:17 0000 -------
I had to drop ~x86-fbsd keyword from -r7 because the calls are very linux
specific, I do have a portable patch, if that can be used instead of the
current would be perfect.

------- Comment #10 From Diego E. 'Flameeyes' Pettenò 2006-05-28 17:50:07 0000 -------
Created an attachment (id=87770) [edit]
Updated patch supporting FreeBSD and DragonFly and with fallback.

------- Comment #11 From Stefan Cornelius (RETIRED) 2006-05-31 10:28:13 0000 -------
arches please test and mark 6b-r7 stable, thanks

------- Comment #12 From Thomas Cort (RETIRED) 2006-05-31 10:37:03 0000 -------
alpha stable.

------- Comment #13 From Fabian Groffen 2006-05-31 11:10:57 0000 -------
Darwin has a problem similar to BSD.  However, Diego's patch won't work for us.
 I need something like this:

#if HAVE_SYSCTL && defined HW_PHYSMEM
  { /* This works on *bsd and darwin.  */
    unsigned int physmem;
    size_t len = sizeof physmem;
    static int mib[2] = { CTL_HW, HW_PHYSMEM };

    if (sysctl (mib, ARRAY_SIZE (mib), &physmem, &len, NULL, 0) == 0
        && len == sizeof (physmem))
      return (double) physmem;
  }
#endif

Diego, is your patch yet in (doesn't look like so), and can above code be
combined with yours?  I grabbed above thing from
http://www.opensource.apple.com/darwinsource/WWDC2004/gccfast-1614/libiberty/physmem.c

I cannot mark this package stable on ppc-macos because the package doesn't
compile.

------- Comment #14 From Gustavo Zacarias (RETIRED) 2006-05-31 11:51:56 0000 -------
sparc stable.

------- Comment #15 From Diego E. 'Flameeyes' Pettenò 2006-05-31 12:01:55 0000 -------
Created an attachment (id=88017) [edit]
Updated patch supporting *BSD and Darwin and with fallback.

Here it is, thanks Fabian :)

------- Comment #16 From Fabian Groffen 2006-05-31 12:39:59 0000 -------
Created an attachment (id=88028) [edit]
Re-Updated patch supporting *BSD and Darwin and with fallback.

this patch fixes the return type to be long, and to return 0 in case the
condition does not hold.

------- Comment #17 From Markus Rothe 2006-05-31 12:42:46 0000 -------
stable on ppc64

------- Comment #18 From Fabian Groffen 2006-05-31 12:46:13 0000 -------
(From update of attachment 88028 [edit])
this patch is wrong.  Don't use it.  Sorry for the spam.

------- Comment #19 From Fabian Groffen 2006-05-31 12:53:35 0000 -------
Created an attachment (id=88029) [edit]
latest darwin/bsd/linux maxmem patch from SVN by Flameeyes

Attached is the proper fix for BSD/Darwin and GNU/Linux.  This patch should be
put in the patch file after which I can mark ppc-macos stable.

Taviso or who is responsible: could you add + patchrevbump this patch to the
current ebuild?  Thanks.

------- Comment #20 From Thomas Cort (RETIRED) 2006-05-31 16:49:52 0000 -------
amd64 stable.

------- Comment #21 From Sander Knopper 2006-06-01 06:13:10 0000 -------
on x86:

compiles fine. Further I ran several transformations on an image which also
went fine and gave the expected result. I also tested the functionality of the
library itself by using KDE and Gimp which worked fine as well.

------- Comment #22 From Tobias Scherbaum 2006-06-01 11:14:19 0000 -------
ppc stable

------- Comment #23 From Mark Loeser 2006-06-01 20:56:38 0000 -------
x86 done, thanks for testing Sander

------- Comment #24 From René Nussbaumer 2006-06-03 02:24:35 0000 -------
Stable on hppa

------- Comment #25 From Diego E. 'Flameeyes' Pettenò 2006-06-05 09:35:20 0000 -------
*** Bug 135644 has been marked as a duplicate of this bug. ***

------- Comment #26 From Sune Kloppenborg Jeppesen 2006-06-10 00:33:45 0000 -------
Calling a GLSA vote on this one:

<taviso> re jpeg, i dont think glsa is nescessary, it's very lame...just a
client dos

Does any important applications use this?

------- Comment #27 From Thomas Cort (RETIRED) 2006-06-10 05:29:46 0000 -------
(In reply to comment #26)
> Does any important applications use this?

Many applications do. Here is a list of some popular apps that use it: emacs,
wine, abiword, ghostscript-*, php, blender, gimp, gphoto2, cups,
mozilla{-firefox}, qt, opera, and others.

Complete List: http://gentoo-portage.com/media-libs/jpeg/RDep#ptabs

------- Comment #28 From Sune Kloppenborg Jeppesen 2006-06-10 05:42:41 0000 -------
Ok lets have the GLSA.

------- Comment #29 From Raphael Marichez 2006-06-10 23:36:06 0000 -------
yes, as for me a GLSA is needed, since this issue allows me to crash nearly
every computer of my friends :), whatever they use (konq, firefox, safari,
IE...).  Some other linux distributions, and MacOS, windows... are affected
too.

------- Comment #30 From Sune Kloppenborg Jeppesen 2006-06-11 13:29:47 0000 -------
GLSA 200606-11

arm, bsd, ia64, mips, ppc-macos, s390, sh don't forget to mark stable to
benifit from the GLSA.

------- Comment #31 From Diego E. 'Flameeyes' Pettenò 2006-06-11 14:11:24 0000 -------
Did _anybody_ take into consideration my and Grobian's messages?

Both Gentoo/*BSD and Gentoo for Mac OSX are cut off by that patch unless
someone apply our version, that's a no-op for anyone else.

If nobody from the interested parts is going to make that change in 24h, I
suppose either me or Grobian will do that, but consider that anybody wanting to
scream at us afterward will have had enough time to validate and comment.

------- Comment #32 From Sune Kloppenborg Jeppesen 2006-06-11 21:29:05 0000 -------
Sorry Diego I thought that it had already been applied. Taviso who applied the
initial patch has been mostly away for some weeks due to a job change. (no
screaming from here)

------- Comment #33 From Fabian Groffen 2006-06-12 00:52:17 0000 -------
Diego, as I'll not be able to do this and mark ppc-macos today/tonight (no
access to my machine), can you do this if you have time?  Please also set the
proper ppc-macos keyword if you do, I already tested with your patch.  Thanks.

------- Comment #34 From Fabian Groffen 2006-06-16 12:04:08 0000 -------
I updated the patchset to include Darwin/BSD fixes.  Marked ppc-macos stable. 
Flameeyes can you manage the overlay (to which I committed the last cleaned up
and working version of the patch) in the way you like?  (e.g. removing or
whatever, the patch is now in the main tree)

------- Comment #35 From Joshua Kinard 2006-09-03 21:01:11 0000 -------
6b-r7 stable on mips.

First Last Prev Next    No search results available      Search page      Enter new bug