Remote Exploit Forums

Go Back   Remote Exploit Forums > Specialist Topics > Programming


Programming A place for our community to discuss their own security related coding projects.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-30-2009, 12:13 PM
Schtekarn's Avatar
Junior Member
 
Join Date: Feb 2008
Location: Sweden
Posts: 29
Default gcc compiling error help

Hi,

I've encountered a error when trying to compile a program.

The error is:

Code:
In function 'ldt':
error: storage size of 'l' isn't known
the program im trying to compile is a local linux exploit found here
Linux Kernel <= 2.4.22 (do_brk) Local Root Exploit (working)

The function in question looks like this:

Code:
int modify_ldt(int, void *, unsigned);
void ldt(unsigned * m)
{
struct modify_ldt_ldt_s l;
map(m);
memset(&l, 0, sizeof(l));
l.entry_number = LDT_ENTRIES - 1;
l.seg_32bit = 1;
l.base_addr = MAGIC >> 16;
l.limit = MAGIC & 0xffff;
if (modify_ldt(1, &l, sizeof(l)) == -1)
fatal("Unable to set up LDT");
l.entry_number = ENTRY_MAGIC / 2;
if (modify_ldt(1, &l, sizeof(l)) == -1)
fatal("Unable to set up LDT");
find(m);
Any help on how to get rid of the error is apreciated.
Reply With Quote
  #2 (permalink)  
Old 10-01-2009, 04:02 AM
Senior Member
 
Join Date: Jun 2008
Posts: 358
Default

Can you post some more off the code

Code:
struct modify_ldt_ldt_s l;
map(m);
memset(&l, 0, sizeof(l));
is there any code somewere else for
struct modify_ldt_ldt_s l;
Reply With Quote
  #3 (permalink)  
Old 10-01-2009, 06:43 AM
Gitsnik's Avatar
Senior Member
 
Join Date: Jun 2009
Location: The Crystal Wind
Posts: 494
Default

Quote:
Originally Posted by compaq View Post
Can you post some more off the code

Code:
struct modify_ldt_ldt_s l;
map(m);
memset(&l, 0, sizeof(l));
is there any code somewere else for
struct modify_ldt_ldt_s l;
It's the milw0rm code for the exploit. Does seem like the error message was missing something though, as gcc should be able to tell you the line number as well. Anyway this is the problematic function:
Code:
void ldt(unsigned * m)
{
struct modify_ldt_ldt_s l;
map(m);
memset(&l, 0, sizeof(l));
l.entry_number = LDT_ENTRIES - 1;
l.seg_32bit = 1;
l.base_addr = MAGIC >> 16;
l.limit = MAGIC & 0xffff;
if (modify_ldt(1, &l, sizeof(l)) == -1)
fatal("Unable to set up LDT");
l.entry_number = ENTRY_MAGIC / 2;
if (modify_ldt(1, &l, sizeof(l)) == -1)
fatal("Unable to set up LDT");
find(m);
}
I have an idea of what is going wrong, but it's only a vague one.

OP: gcc version, linux version (BT version as well!). Did you wget the code down or get it out of the milw0rm tarball etc.
__________________
Never underestimate the power of human stupidity - it is like a force of nature, capable of destroying even the most well laid plans.
Reply With Quote
  #4 (permalink)  
Old 10-01-2009, 01:23 PM
Schtekarn's Avatar
Junior Member
 
Join Date: Feb 2008
Location: Sweden
Posts: 29
Default

I'll try to be a little more clear.

The full error message looks like this

Code:
linux-kernel-2.4.22-do_brk-local.c: In function 'ldt':
linux-kernel-2.4.22-do_brk-local.c:150: error: storage size of 'l' isn't known
The 150 line is pointing to the function posted above.

Also near the end of the program there is a ldt code:

Code:
ldt(m);
expand();
knockout();
...
My gcc version is 4.1.2. Im running BT3 Final. Linux kernel 2.6.21.5.

I really appreciate the help as my C skills are not that deep.
Reply With Quote
  #5 (permalink)  
Old 10-02-2009, 12:09 AM
Senior Member
 
Join Date: Jun 2008
Posts: 358
Default

try this
Code:
void ldt(unsigned * m)
{
struct modify_ldt_ldt_s l;
map(m);
//memset(&l, 0, sizeof(l));
l.entry_number = LDT_ENTRIES - 1;
l.seg_32bit = 1;
l.base_addr = MAGIC >> 16;
l.limit = MAGIC & 0xffff;
if (modify_ldt(1, &l, sizeof(l)) == -1)
fatal("Unable to set up LDT");
l.entry_number = ENTRY_MAGIC / 2;
if (modify_ldt(1, &l, sizeof(l)) == -1)
fatal("Unable to set up LDT");
find(m);
}
Reply With Quote
  #6 (permalink)  
Old 10-02-2009, 12:03 PM
Schtekarn's Avatar
Junior Member
 
Join Date: Feb 2008
Location: Sweden
Posts: 29
Default

Quote:
Originally Posted by compaq View Post
try this
Code:
void ldt(unsigned * m)
{
struct modify_ldt_ldt_s l;
map(m);
//memset(&l, 0, sizeof(l));
l.entry_number = LDT_ENTRIES - 1;
l.seg_32bit = 1;
l.base_addr = MAGIC >> 16;
l.limit = MAGIC & 0xffff;
if (modify_ldt(1, &l, sizeof(l)) == -1)
fatal("Unable to set up LDT");
l.entry_number = ENTRY_MAGIC / 2;
if (modify_ldt(1, &l, sizeof(l)) == -1)
fatal("Unable to set up LDT");
find(m);
}
That didn't do it, still same error.
Reply With Quote
  #7 (permalink)  
Old 10-03-2009, 07:42 AM
Virchanza's Avatar
Senior Member
 
Join Date: Sep 2008
Location: I am not living
Posts: 728
Default

It is possible to "declare" a structure without "defining" it.

When you declare a structure, all you're doing is saying to the compiler "This is the name of a structure", you're not giving it any information such as what the structure contains or how much memory it consumes.

When you define a structure, you give full details of what the structure contains, so the compiler knows how much memory the structure will take up.

The problem with your code is that "modify_ldt_ldt_s" has been declared but it has not been defined.

I can see either one of two reasons why:
1) You're missing the inclusion of the header file that defines this structure (this is most likely)
2) You've included all the right header files, but they contain errors (not very likely)

You can duplicate the error you got using this simple code:

Code:
struct Struct_That_Hasnt_Been_Defined;

int main(void)
{
    struct Struct_That_Hasnt_Been_Defined my_object;

    return 0;
}
Go find out which header file you're missing.
__________________
Ask questions on the open forums, that way everybody benefits from the solution, and everybody can be corrected when they make mistakes. Don't send me private messages asking questions that should be asked on the open forums, I won't respond. I decline all "Friend Requests".
Reply With Quote
Reply

Bookmarks

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2