Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 1st, 2005, 10:50 AM   #1
snow
Newbie
 
Join Date: Sep 2005
Location: Slovenia
Posts: 17
Rep Power: 0 snow is on a distinguished road
memory protection, jump protection, infinite loop prevention

Hi guys!

Let say i have some random generated assembly code and i wonder if i can (and how) do this:
1) prevent this code of accessing memory except some part of it... let say restrict it to 1kb of memory
2) prevent jumps to outside of this code
3) prevent infinite loops... e.g. restrict execution of programme to max. number of cycles (or time) as accurate as possible

Any ideas, comments are welcome!

If i wasnt clear about something please ask!
snow is offline   Reply With Quote
Old Oct 1st, 2005, 12:48 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Build it into the OS.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 1st, 2005, 1:18 PM   #3
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
It's like dawei said... it has to be built into the OS. Only high-level, interpretted languages can prevent a program from doing such things.
Polyphemus_ is offline   Reply With Quote
Old Oct 1st, 2005, 1:38 PM   #4
snow
Newbie
 
Join Date: Sep 2005
Location: Slovenia
Posts: 17
Rep Power: 0 snow is on a distinguished road
Hm.
What about timer interrupts for loops?

And if i could modify code a bit... with some algorithm.. so build in checking before every instruction that deals with memory or makes a jump?
snow is offline   Reply With Quote
Old Oct 1st, 2005, 1:40 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
It has nothing to do with the language, or the level of it. It has to do with oversight of running code. This is accomplished with an executive that has control of the running of processes and the assignment and management of memory.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 1st, 2005, 1:41 PM   #6
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
All 3 are part of the fundamental functioning of an OS for x86 protected mode. The ring-0 code can set up the pages or segments for running apps, which is why you can't overwrite memory in App B from App A without using system calls. Address X might map to address Y in physical memory for App A, but Address X might map to Address Z for App B. I forget if there's another way to do it, but I know that on some processors the kernel-mode code can set the NX bit on pages to, for example, prevent execution of code on the stack. And thanks to your timer interrupt, applications forcibly share time with the others at the discretion of the OS.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Oct 1st, 2005, 1:41 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Your latter suggestion is somewhat akin to shoveling shit against the tide so as to make the sea shallower.

EDIT: Not Dameon's, that was a simultaneous post. Snows.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:36 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC