메모리 할당 이후에 rebooting이 됩니다.

study의 이미지

아래는 지금 디버깅중인 리눅스 모듈에 포함된 함수인데요.
ip_session_add1()을 호출하면, 시스템이 잠시 멈춘것 같다가 리부팅이 됩니다.
하지만, ip_session_add2()를 호출하면, 그런 문제가 없네요.

차이점은 session 이라는 pointer가 가리키는 메모리를 스택에서 할당했는지, 아니면 힙에서 할당했는지
차이인 것 같은데요.
왜 이런 문제가 발생하는지 잘 모르겠네요 ㅜㅜ

    struct ip_session {
        struct ip_session *next;
        __be32   addr;
        __be32   netmask;
    };
    #define HASH_SESSION_SIZE 	256
    #define HASH_SESSION(addr) 	(ntohr(addr) & 0xFF)
 
    static struct ip_session *ip_sessions[HASH_SESSION_SIZE] = {};
    static inline struct ip_session **ip_session_bucket(__be32 addr)
    {
        __be32   h0 = HASH_SESSION(addr);
 
        return (&(ip_sessions[h0]));
    }
 
    static int ip_session_add1(__be32 addr, __be32 netmask)
    {
        struct ip_session *session, **ms;
 
        write_lock(&session_lock);
 
        if((session = (struct ip_session *)kzalloc(sizeof(struct ip_session), GFP_ATOMIC)) == NULL)
        {
            write_unlock(&session_lock);
            return -1;
        }
 
        session->addr = addr;
        session->netmask = netmask;
 
        ms = ip_session_bucket(addr);
        session->next = *ms;
        *ms = session;
 
        write_unlock(&session_lock);
        return 0;
    }
 
    static int ip_session_add2(__be32 addr, __be32 netmask)
    {
        struct ip_session *session, **ms;
        struct ip_session s;
 
        write_lock(&session_lock);
 
        session = &s;	
 
        session->addr = addr;
        session->netmask = netmask;
 
        ms = ip_session_bucket(addr);
        session->next = *ms;
        *ms = session;
 
        write_unlock(&session_lock);
        return 0;
    }

shint의 이미지

ㅇ_ㅇ;;

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

Necromancer의 이미지

메모리 관련해서 조사 해보셔야 할 것 같은데요.
제때 해제 안해서 full 난다든지 아님 할당영역을 overwrite 하는 부분이 있는지.

커널모드는 권한이 많은만큼 할거 하지말거 다 할 수 있어서 디버깅이 꽤 어렵습니다.

Written By the Black Knight of Destruction

tyhan의 이미지

verbose모드로 부팅하셔서
어디서 어떻게 커널이 멈추는지 확인해봐야 알것 같습니다.

추측이지만 위의 코드 보다 session을 읽거나 삭제할때
할당되지 않은 부분 억세스 혹은 널포인트 억세스 같습니다.

bushi의 이미지

코드로 보기엔, 오히려 ip_session_add2() 가 몹시 잘못된 것 같은데요.

ip_session_remove() 쯤에 해당하는 코드를 보면 정답이 손 번쩍 들고 기다리고 있을 것 같습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.