Unix Technical Forum

Re: tftp diff

This is a discussion on Re: tftp diff within the lucky.openbsd.tech forums, part of the OpenBSD category; --> > The setjmp(3) in main.c which is used when ctrl-c is catched (SIGINT) > is kept which is legitim ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 12:22 PM
Theo de Raadt
 
Posts: n/a
Default Re: tftp diff

> The setjmp(3) in main.c which is used when ctrl-c is catched (SIGINT)
> is kept which is legitim IMO for that use and done this way by a lot
> of command line programs (ftp, ed, restore etc.) to return to the
> command prompt no matter which routine was active (e.g. blocking
> fgets(3)).


Well, just because lots of programs use that method does not make it
legitimate, because in the end I must say this: IT IS STILL NOT SAFE.

Think about it.

When that ^C comes in, is it not possible that our code is currently running
inside malloc()? Just picking an example here, but what about stdio? Or
who knows what else?

So then the signal comes in, and we longjmp back into main, and now what?

Now your malloc heap is unsafe. Or stdio is in an inconsistant state.
Or who knows what else.

And now the code WILL crash later on. And there is no solution to
this besides adding signal blocking stubs all through the code, for
everytime you wish to do something which might conceiveably not be
re-entrant.

So while it might be what a lot of programs do, my point is that it
is 100% unsafe -- in all cases -- to ever use setjmp. Well, I have
actually used it safely in one program before, but the costs are very
high because you really must do signal blocks around just about any
sequence of code which calls a function which is NOT LISTED in signal.h

This is what I call a reverse signal race.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:42 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com