Advertisement

Detecting invalid pointer in system call of calling process

Started by November 19, 2005 08:49 AM
3 comments, last by demonkoryu 19 years, 2 months ago
I have the following wrapper code:

#include <errno.h>

int getpath (int pid, int *array, int size) {
  long __res;
  __asm__ volatile (
    "movl $243, %%eax;"
    "movl %1, %%ebx;"
    "movl %2, %%ecx;"
    "movl %3, %%edx;"
    "int $0x80;"
    "movl %%eax, %0"
      : "=m" (__res)
      : "m" (pid), "m" ((long)array), "m" (size)
      : "%eax", "%ebx", "%ecx", "%edx"
    );
  if ((unsigned long)(__res)>=(unsigned long)(-125)) {
    errno = -(__res);
    __res = -1;
  }
  return (int)(__res);
}

As you can see I pass a pointer to an int array, named array. I need to verify inside sys_getpath (which the interrupt will call) if the pointer of the array, passed to it as a parameter, doesnt belong to the calling process address space. How do I check this? Is there a specific function/macro that does that? Please help. Thanks in advance.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote: Original post by Toolmaker Quote: Original post by The C modest godHow is my improoved signature?It sucks, just like you.
I have found __adr_ok and __range_ok inside uaccess.h, but I need some reference on those.
Where can I find reference for these two macros?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote: Original post by Toolmaker Quote: Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Advertisement
The specific rules for how each UNIX kernel does argument checking vary by what flavor of UNIX you're using. Is it Solaris? Linux? FreeBSD? NetBSD? Your own?

Also, for kernel development, I suggest asking the kernel development list for the flavor you're using, as those typically have more kernel hackers on them than this particular forum (although we get 'em here, too :-)
enum Bool { True, False, FileNotFound };
Quote: Original post by hplus0603
The specific rules for how each UNIX kernel does argument checking vary by what flavor of UNIX you're using. Is it Solaris? Linux? FreeBSD? NetBSD? Your own?

Also, for kernel development, I suggest asking the kernel development list for the flavor you're using, as those typically have more kernel hackers on them than this particular forum (although we get 'em here, too :-)

What is the kernel developer list?

It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote: Original post by Toolmaker Quote: Original post by The C modest godHow is my improoved signature?It sucks, just like you.
List is short for mailing list.

This topic is closed to new replies.

Advertisement