LSM 커널 모듈로 프로그래밍 테스트 중..

stypr의 이미지

[root@localhost lsm]# uname -r
2.6.10-1.14_FC2

[root@localhost lsm]# find /lib/modules/2.6.10-1.1
2.6.10-1.12_FC2  2.6.10-1.14_FC2  
[root@localhost lsm]# find /lib/modules/2.6.10-1.14_FC2/build/include/  | xargs grep "register_security"
/lib/modules/2.6.10-1.14_FC2/build/include/linux/security.h: * @register_security:
/lib/modules/2.6.10-1.14_FC2/build/include/linux/security.h: * @unregister_security:
/lib/modules/2.6.10-1.14_FC2/build/include/linux/security.h:    int (*register_security) (const char *name,
/lib/modules/2.6.10-1.14_FC2/build/include/linux/security.h:    int (*unregister_security) (const char *name,
/lib/modules/2.6.10-1.14_FC2/build/include/linux/security.h:extern int register_security        (struct security_operations *ops);
/lib/modules/2.6.10-1.14_FC2/build/include/linux/security.h:extern int unregister_security      (struct security_operations *ops);

[root@localhost lsm]# cat st.c
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/security.h>

static int rootplug_task_setuid (uid_t id0, uid_t id1, uid_t id2, int flags)
{
        return 0;
}

static struct security_operations lsrc_security_ops = {
        .task_setuid =  rootplug_task_setuid,
};


static int __init rootplug_init (void)
{
        register_security (&lsrc_security_ops);
}

static void __exit rootplug_exit (void)
{
        unregister_security (&lsrc_security_ops);
}
module_init (rootplug_init);
module_exit (rootplug_exit);


MODULE_DESCRIPTION("LSM module");
MODULE_LICENSE("GPL");

[root@localhost lsm]# gcc st.c -I/lib/modules/`uname -r`/build/include/ -D__KERNEL__
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
/tmp/cccIVaHb.o(.init.text+0xf): In function `rootplug_init':
: undefined reference to `register_security'
/tmp/cccIVaHb.o(.exit.text+0xf): In function `rootplug_exit':
: undefined reference to `unregister_security'
collect2: ld returned 1 exit status

분명히 security.h 에 정의 되어 있는데 왜 에러가 -_-;;;;;

ㅠ.ㅠ 엄청 삽질중이네요 -_-;;

pastime의 이미지

link 과정에서 실제 함수를 찾으려고 하니 에러가 발생하는 거 같습니다.
-c 옵션으로 컴파일 단계까지만 진행되도록 해주세요..

그리고 아래는 예전에 flyduck 님이 올리신 글입니다.
참조하세요..

flyduck wrote:
2.6 커널이군요. 2.6 커널에서는 커널 모듈의 확장자가 .ko로 바뀌었으며 확장자가 .o인 파일을 로드하려고 하면 그런 에러 메시지가 나오게 됩니다.

2.6 커널인 경우 모듈 소스를 컴파일할 때 Makefile을 만들어서 사용하는 것을 권장합니다. Makefile은 다음과 같이 간단하게 만들면 됩니다.

obj-m := make_module.o

그리고 컴파일할 때는 make를 사용하는데 커널 소스 파일이 있는 위치가 /usr/src/linux-2.6 이라면

make -C /usr/src/linux-2.6 SUBDIRS=`pwd` modules

이렇게 하면 됩니다. 그리고 printf는 printk로 바꾸기 바랍니다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.