OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 10:55 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Stack Smashing Protector
PostPosted: Wed Oct 22, 2014 5:54 pm 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
Hi,

I rewrote our article on the Stack Smashing Protector provided by modern compilers. I added it to my OS yesterday and it was quite easy. I spent some time pondering how best to implement it, whether to use gcc's libssp or whether to denounce it and use my own, how the randomness should be delivered, how it should be initialized, how best to handle such issues (realizing the handler environment could be very hostile), and so on.

I figured I'd perhaps start making forum topics when I made useful changes to the wiki that the general community could be interested in. Is that something you'd be interested in?

I took the liberty of linking it from Meaty Skeleton (a new-ish tutorial that continues Bare Bones with a full project template). I didn't add it to Bare Bones as it might just be a little too irrelevant for absolute novices, but meaty skeleton does already assume global constructors and a minimal C library is in place.

I notice we have a Security page and Security category. It could be interesting to add some stuff there and reorder it and link it better to the rest of the wiki. I think security and robustness is one of the areas where osdev can seriously compete in. For instance, I build and run my entire OS (even kernel and libc) with -fsanitize=undefined (ubsan) to catch undefined behavior, and now -fstack-protector-all to catch buffer overflows. I might actually be the first reasonably-sized operating system to use both ubsan and stack protector in the entire system. Hardening is pretty fun and straightforward to add when the base operating system is clean code, as opposed to the third party code that breaks big-time when features like this are used.

Anyways,

Share and Enjoy!


Top
 Profile  
 
 Post subject: Re: Stack Smashing Protector
PostPosted: Wed Oct 22, 2014 8:54 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
Thanks for making the Wiki suck less sortie. :D

_________________
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.


Top
 Profile  
 
 Post subject: Re: Stack Smashing Protector
PostPosted: Wed Oct 22, 2014 11:39 pm 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1110
Location: Tartu, Estonia
sortie wrote:
I figured I'd perhaps start making forum topics when I made useful changes to the wiki that the general community could be interested in. Is that something you'd be interested in?

Yes, definitely.

I stumbled a bit over this sentence:
Quote:
The detection is perfect is a impossible to fake the correct value

I guess it should be "The detection is perfect if it is impossible to fake the correct value"?

Also, those security topics are really interesting and helpful. Many things are rather new to me and it's really nice to have this kind of introductory articles. Good work!

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: Stack Smashing Protector
PostPosted: Thu Oct 23, 2014 12:14 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Interesting to state that the canary should contain a null byte, and then not doing it in the example :wink:

Before I ignorantly go put back some different magic values, where did you get these from?

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Stack Smashing Protector
PostPosted: Thu Oct 23, 2014 5:59 am 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
I didn't say it should have a nul byte. It makes some cases safe, but offers no protection in many others. Existing operating systems randomize every bit to get more entropy. Perhaps it is worth making one byte zero on 64 bit, but I doubt it.

Those constants doesn't matter except being unlikely to collide with bugs. They are cryptographic random nunbers from /dev/random. Either use them or your own constants, it is equally bad. You must generate a random number at kernel load time.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group