Chinaunix首页 | 论坛 | 博客
  • 博客访问: 593594
  • 博文数量: 353
  • 博客积分: 1104
  • 博客等级: 少尉
  • 技术积分: 1457
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-23 23:02
个人简介

1、刚工作时做Linux 流控;后来做安全操作系统;再后来做操作系统加固;现在做TCP 加速。唉!没离开过类Unix!!!但是水平有限。。

文章存档

2015年(80)

2013年(4)

2012年(90)

2011年(177)

2010年(1)

2009年(1)

分类:

2011-12-08 13:15:42

sales are assholes, engineers are dicks. assholes always ask dicks to do dirty things, when it's done, assholes are happy, while engineers are covered with shit all over them.

sale: "please modify this driver, make it not work on other OS."
me: "why?"
after 0.1 second...
me: "i see."
me: "where is the source code?"
sale: "no source code"
me: "i cannot modify the binary without the source code."
sale: "can you just hide the driver somewhere?"
me: "they will find it anyway."
sale: "anyway, i just want it tomorrow."
me: "OK, let me think what i can do."

OK, basic knowledge of linking and ELF is not totally useless. here is how to do that:

support the original driver is foo.ko,

1. rename the __this_module to something else (e.g. __THIS_module)

2. write some code to replace the original __this_module symbol:

struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
.name = __stringify(KBUILD_MODNAME),
.init = new_module_init,
.exit = cleanup_module,
};

3. in new_module_init(), check if OS is ours, if NOT, puke. otherwise, call the original module_init():

static int is_ax(void)
{
        if (strstr(system_utsname.release, "AX") == NULL)
                return 0;
        else
                return 1;
}

static int new_module_init(void)
{
        int err = -1;
        if (is_ax())
                err = original_init();
        return err;
}

4. link foo.ko with the code generated in step 2 and 3. build a new driver module.

that's it. simple and evil.

when you dive deep into technical issues, the notion of ethic simply disappears, so you wont go crazy.

阅读(339) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~