Can you post some more off the code
is there any code somewere else forCode:struct modify_ldt_ldt_s l; map(m); memset(&l, 0, sizeof(l));
struct modify_ldt_ldt_s l;
Hi,
I've encountered a error when trying to compile a program.
The error is:
the program im trying to compile is a local linux exploit found hereCode:In function 'ldt': error: storage size of 'l' isn't known
Linux Kernel <= 2.4.22 (do_brk) Local Root Exploit (working)
The function in question looks like this:
Any help on how to get rid of the error is apreciated.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);
Can you post some more off the code
is there any code somewere else forCode:struct modify_ldt_ldt_s l; map(m); memset(&l, 0, sizeof(l));
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:I have an idea of what is going wrong, but it's only a vague one.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); }
OP: gcc version, linux version (BT version as well!). Did you wget the code down or get it out of the milw0rm tarball etc.
Still not underestimating the power...
There is no such thing as bad information - There is truth in the data, so you sift it all, even the crap stuff.
I'll try to be a little more clear.
The full error message looks like this
The 150 line is pointing to the function posted above.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
Also near the end of the program there is a ldt code:
My gcc version is 4.1.2. Im running BT3 Final. Linux kernel 2.6.21.5.Code:ldt(m); expand(); knockout(); ...
I really appreciate the help as my C skills are not that deep.
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); }
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:
Go find out which header file you're missing.Code:struct Struct_That_Hasnt_Been_Defined; int main(void) { struct Struct_That_Hasnt_Been_Defined my_object; return 0; }
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".