Find the answer to your Linux question:
Results 1 to 4 of 4
Hi All I have developed a userspace program similar to FTP protocol that transfers files between a client and server in native C using the POSIX userspace APIs. I make ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2011
    Location
    Iran
    Posts
    2

    Linux Shutdown in using the POSIX getrusage() function.


    Hi All

    I have developed a userspace program similar to FTP protocol
    that transfers files between a client and server in native C using
    the POSIX userspace APIs.

    I make use of the getrusage() function to profile my program in
    source code level.

    The server program is correctly running. However, the client program causes the system
    to shut down; but when I remove the getrusage() function from the source code
    in client side, everything is working well without any shutdown.

    Has everybody any ideas of what is happening?
    Last edited by poshtkohi; 04-13-2011 at 08:59 AM.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,158
    My guess is that the problem isn't with calling getrusage(), but somewhere else. In all likelihood, the second argument, a pointer to a 'struct rusage', is either bogus, or corrupted. If that structure is passed to the kernel, then it may well cause the sort of problem you describe. In any case, this is serious, as a user-space function like this should NOT have the ability to shutdown the system. It could be used as a denial of service attack. Please investigate further, and DO report it to the kernel developers. I can't emphasize this enough to you. You may well have stumbled upon a major security flaw in the operating system. BTW, what is the kernel you are using? Please post the output of 'uname -r' here asap.

    Thanks.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Apr 2011
    Location
    Iran
    Posts
    2

    Smile Other Two Points

    Quote Originally Posted by Rubberman View Post
    My guess is that the problem isn't with calling getrusage(), but somewhere else. In all likelihood, the second argument, a pointer to a 'struct rusage', is either bogus, or corrupted. If that structure is passed to the kernel, then it may well cause the sort of problem you describe. In any case, this is serious, as a user-space function like this should NOT have the ability to shutdown the system. It could be used as a denial of service attack. Please investigate further, and DO report it to the kernel developers. I can't emphasize this enough to you. You may well have stumbled upon a major security flaw in the operating system. BTW, what is the kernel you are using? Please post the output of 'uname -r' here asap.

    Thanks.
    There are two interesting points about this phenomenon!

    1. The server also contains the getrusage() function, but it does not result in shutting down the server machine!

    2. The client-side program is working well in some times and correctly reports the desired profiles contained in the reference of the passed structure rusage, but in nearly every 5 runs it randomly causes the client-side machine to unexpectedly shutdown !

    The following log shows the Linux version used:

    [root]# uname -r
    2.6.9-100.ELsmp
    [root]# uname -a
    Linux ce.math 2.6.9-100.ELsmp #1 SMP Fri Feb 18 02:12:11 EST 2011 x86_64 x86_64 x86_64 GNU/Linux


    I will more investigate the main reason of this negative bug, and will post the results here .
    Last edited by poshtkohi; 04-17-2011 at 05:35 PM.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,158
    Build your application with the -g option and don't strip it, so you can run it in the debugger (gdb). Run it outside of gdb to see if it still crashes the system. If it does, then run it inside the debugger until it crashes again. You may find where things are getting munged. Also, check with dmesg and look in /var/log/messages to see if there was any kernel notifications of this event.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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