public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Very large font size crashing X Font Server and Grounding Server to a Halt (was: remote DoS in Mozilla 1.0)
@ 2002-06-13 16:53 Melchior FRANZ
  0 siblings, 0 replies; 18+ messages in thread
From: Melchior FRANZ @ 2002-06-13 16:53 UTC (permalink / raw)
  To: linux-kernel

* rjh@world.std.com -- Thursday 13 June 2002 18:33:
> It resulted in an almost infinite size malloc() request.

No. AFAIK it is caused in the file xc/lib/font/Type1/t1font.c
by wrong RAM requirement estimation heuristics. Not too much
memory is requested but too few! And if XFree actually needs
more memory than it had originally estimated and requested, it
simply aborts.

m.


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: Very large font size crashing X Font Server and Grounding Server to a Halt (was: remote DoS in Mozilla 1.0)
@ 2002-06-13 17:17 Melchior FRANZ
  2002-06-13 17:34 ` Billy O'Connor
  0 siblings, 1 reply; 18+ messages in thread
From: Melchior FRANZ @ 2002-06-13 17:17 UTC (permalink / raw)
  To: linux-kernel

* Melchior FRANZ -- Thursday 13 June 2002 18:49:
> * rjh@world.std.com -- Thursday 13 June 2002 18:33:
> > It resulted in an almost infinite size malloc() request.
> 
> No. AFAIK it is caused in the file xc/lib/font/Type1/t1font.c
                                                       ^^^^^^^^
This should have been t1func.c, sorry.

m. 



^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: Very large font size crashing X Font Server and Grounding Server to a Halt (was: remote DoS in Mozilla 1.0)
@ 2002-06-13 21:47 Jesse Pollard
  2002-06-13 22:09 ` Matthew Wakeling
  0 siblings, 1 reply; 18+ messages in thread
From: Jesse Pollard @ 2002-06-13 21:47 UTC (permalink / raw)
  To: mnw21, BugTraq Mailing List, Linux Kernel Mailing List

Matthew Wakeling <mnw21@bigfoot.com>:
> 
> On Thu, 13 Jun 2002, Federico Sevilla III wrote:
> 
> > I was able to log on to the server with enough time to SIGKILL the
> > xfs-daemon process. Unfortunately this wasn't good enough. The server
> > started running up various processes stuck in "D" state, the OOM killer
> > went on panic mode and started killing things left and right, mostly from
> > what I notice apache and apache-ssl processes with messages like "Out of
> > Memory: Killed process xxxx (apache)". I was also able to do a `free`
> > after killing xfs-daemon and noticed that there was a lot of free memory
> > both physically and on swap.
> > 
> > Within less than ten minutes on this relatively lightly-loaded server, I
> > could not log in to the machine locally, even as root (whose home
> > directory is not NFS-exported) and load levels shot up to around 25, which
> > is definitely abnormal. Existing logged-on processes also got stuck in
> > whatever they were doing (`ps ax`, in particular is what I remember).
> 
> It has always puzzled me that a process using lots of memory can bring 
> down an entire (otherwise relatively idle) server to the extent that one 
> cannot even get mingetty on a local terminal to respond to keypresses. I 
> can confirm that the described situation is not just a one-off.
> 
> It is my experience that a single process using large amounts of memory 
> causes the system to start swapping. Once it starts swapping, every 
> process that does anything (apart from indefinite wait) goes into "I'm 
> ready to do some processing, but my memory is swapped out" state, and the 
> whole system collapses.

Not necessarily. The condition can also be caused by having a large, well
behaved process working its' little heart out properly, and a small process
that grows suddenly (or even slowly - it doesn't take much to push it over
the limit). As the small process grows, the larger one is paged out. Once
the swap space is filled just adding one more page could do it. And it doesn't
matter what process allocates that page. Key: disable oversubscription of
memory.

[snip]

> > While I agree with BugTraq posts in response to this that applications
> > like Mozilla which accept font-sizes from unknown sources should have some
> > check to prevent such large sizes from crashing X and/or the X Font
> > Server, I'm alarmed by (1) the way the X font server allows itself to be
> > crashed like this, and (2) the way the entire Linux kernel seems to have
> > been unable to handle the situation.
> 
> I am in complete agreement with both points, but particularly that the 
> kernel should be able to cope with the situation gracefully. I know one 
> can set limits on processes, but the kernel should still be able to cope 
> if we don't.

It can't decide what causes the problem. There are too may possibilities.

This is NOT a bug. I consider it a problem of a misconfigured server. As long
as memory oversubscription is permitted, there are a LOT of things that can
cause a system failure. Examples are:

	DNS cache table fills memory
	X font server fills memory (the discussed failure)
	Sendmail recieves large Email (2-8MB)
	Web server recieves a lot of requests (though this one is harder and
		needs a lot of static pages to be loaded into memory)
	Database recieves lots of queries for lots of data
	All cron jobs kick off at once, with several requiring lots of memory

(I've even seen that last one kill solaris)
	

> > Suggestions on how to work around this on multiple levels would definitely
> > be appreciated.
> 
> My suggestion would be to set a maximum core size for the xfs-daemon 
> process. Given your setup, something like 400MB seems appropriate - maybe 
> a little lower. Details for doing this seem to differ from linux to linux. 
> Having done that, I would make sure xfs respawns when it dies - that way 
> someone can't just DOS your whole network by asking for a large font.
> Finally, wait for the xfs developers to put in a font size limit, or patch 
> the source yourself.

Also put a maximum limit on the X server.

> Apart from that, I wouldn't move xfs to a bigger server unless you have 
> already had people complaining about its performance. Moving it to a 
> bigger system just changes the constant in the equation - the attacker 
> would only need to specify a 100000 point font instead of a 50000 point 
> font to bring the system down.

Even if the font server survives - the X server wouldn't. In both cases,
only huristics can be applied.

1. Do not generate a font with more than 100 pixels high (around 1 inch
   on display) by the font server. This would have to be a configuration
   item, since there will be cases where that size is unreasonable. Also
   might be a good idea to not cache fonts > X size even if generated.
2. Do not have more than X active fonts at a time (to cover the case of
   multiple fonts at the maximum) where X is based on an external
   configuration (XF86Config parameter limit). Or specify the maximum
   amount of memory to allocate to fonts, when that space is filled, return
   a font error (font not available) to the application. Again, deallocate
   fonts > X size when not in use.

The easiest fix is to disable oversubscription of memory, though that may
cause some daemons to abort if they don't check for allocation failures
(which I do consider a bug).

> I doubt any of my kernel suggestions have not already been thought about, 
> but it was worth a try. Please can this problem be fixed soon?
> 
> Matthew
> 
> -- 
> "If I wanted to kill a battleship, I'd use a s?!tload of Harpoons."
> "NT is a lot cheaper."  -- Paul Tomblin & Petro

Good signature... :)

-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil

Any opinions expressed are solely my own.

^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: Very large font size crashing X Font Server and Grounding Server to a Halt (was: remote DoS in Mozilla 1.0)
@ 2002-06-14 13:46 Juliusz Chroboczek
  2002-06-22  1:36 ` Alan Cox
  0 siblings, 1 reply; 18+ messages in thread
From: Juliusz Chroboczek @ 2002-06-14 13:46 UTC (permalink / raw)
  To: linux-kernel

To answer a couple of the questions in this thread.

The Type 1 backend currently in XFree86 (originally by IBM and
Lexmark) uses static memory allocation (it was designed for embedded
systems) and does indeed have very poor error handling.  The current
plan is to replace the Type 1 backend altoghether with a unified Type
1 and TrueType backend based on the FreeType library.  This will
hopefully happen in 4.3.0.

As far as I know, nobody is currently working on fixing the (legacy)
Type 1 backend.  While patches to fix its behaviour are likely to get
accepted, I think that getting the Type 1 backend to work reasonably
is more work than it's worth now that FreeType does a decent job with
Type 1 fonts.

As to out of memory allocations: with a few exceptions, the core X
server code deals smartly with malloc returning NULL: the current
client receives a BadAlloc error (``insufficient resources''), and
other clients are not bothered.  (On the other hand, it is a rare
client that will deal gracefully with a BadAlloc; and if it's your
window manager that gets the error, all hell breaks loose.)

With current Linux kernels, this careful coding brings no benefit
whatsover, as malloc never (?) returns NULL.  What is worse, as far as
I know the kernel doesn't send advance warning of an OOM situation; it
would not be too difficult to stop allocating memory when that happens.

I suggest xpert at xfree86.org as the right list to continue this
discussion.  If you follow up on linux-kernel, please be so kind as to
CC me.

Regards,

                                        Juliusz Chroboczek

P.S. As always, none of the above represents an official position of
the XFree86 project, but merely my personal perception of the
situation.  This message may or may not have any sort of relationship
with reality.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2002-06-22  1:13 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20020610102006.A6947@lemuria.org>
2002-06-13  1:44 ` Very large font size crashing X Font Server and Grounding Server to a Halt (was: remote DoS in Mozilla 1.0) Federico Sevilla III
2002-06-13  5:39   ` Very large font size crashing X Font Server and Grounding Server to Alan Cox
2002-06-13  5:57     ` rlimits and non overcommit (was: Very large font size ...) Federico Sevilla III
2002-06-13  6:11       ` Keith Owens
2002-06-13  9:25         ` rlimits and non overcommit Federico Sevilla III
2002-06-13  7:18   ` Very large font size crashing X Font Server and Grounding Server to a Halt (was: remote DoS in Mozilla 1.0) Matti Aarnio
2002-06-13 16:26   ` rjh
2002-06-14 13:50     ` Security Coordinator
2002-06-13 21:10   ` Matthew Wakeling
2002-06-13 22:33     ` Very large font size crashing X Font Server and Grounding Server to a Halt Bernd Eckenfels
2002-06-13 16:53 Very large font size crashing X Font Server and Grounding Server to a Halt (was: remote DoS in Mozilla 1.0) Melchior FRANZ
  -- strict thread matches above, loose matches on Subject: below --
2002-06-13 17:17 Melchior FRANZ
2002-06-13 17:34 ` Billy O'Connor
2002-06-13 18:44   ` Melchior FRANZ
2002-06-13 21:47 Jesse Pollard
2002-06-13 22:09 ` Matthew Wakeling
2002-06-14 13:46 Juliusz Chroboczek
2002-06-22  1:36 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox