Results 1 to 7 of 7

Thread: gcc compiling error help

  1. #1
    Junior Member Schtekarn's Avatar
    Join Date
    Feb 2008
    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.

  2. #2
    Good friend of the forums
    Join Date
    Jun 2008
    Posts
    425

    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;

  3. #3
    Very good friend of the forum Gitsnik's Avatar
    Join Date
    Jan 2010
    Location
    The Crystal Wind
    Posts
    851

    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.
    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.

  4. #4
    Junior Member Schtekarn's Avatar
    Join Date
    Feb 2008
    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.

  5. #5
    Good friend of the forums
    Join Date
    Jun 2008
    Posts
    425

    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);
    }

  6. #6
    Junior Member Schtekarn's Avatar
    Join Date
    Feb 2008
    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.

  7. #7
    Very good friend of the forum Virchanza's Avatar
    Join Date
    Jan 2010
    Posts
    863

    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".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •